Skip to content

Commit

Permalink
fix blacklisted method
Browse files Browse the repository at this point in the history
  • Loading branch information
arvyy committed Jun 15, 2024
1 parent 254bc67 commit 44ed4ba
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public abstract class ISLISPGenericFunctionDispatchNode extends Node {

@ExplodeLoop
@Specialization(
guards = { "applicableMethodsArg.equals(applicableMethods)" }
guards = { "applicableMethodsEqual(applicableMethodsArg, applicableMethods)" }
)
Object doCached(
GenericMethodApplicableMethods applicableMethodsArg,
Expand Down Expand Up @@ -67,6 +67,25 @@ Object doCached(
}
}

boolean applicableMethodsEqual(GenericMethodApplicableMethods m1, GenericMethodApplicableMethods m2) {
return arraySliceEqual(m1.primaryMethods(), m2.primaryMethods())
&& arraySliceEqual(m1.aroundMethods(), m2.aroundMethods())
&& arraySliceEqual(m1.beforeMethods(), m2.beforeMethods())
&& arraySliceEqual(m1.afterMethods(), m2.afterMethods());
}

boolean arraySliceEqual(ArraySlice s1, ArraySlice s2) {
if (s1.size() != s2.size()) {
return false;
}
for (var i = 0; i < s1.size(); i++) {
if (s1.get(i) != s2.get(i)) {
return false;
}
}
return true;
}

@Specialization
Object doUncached(
GenericMethodApplicableMethods applicableMethods,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,28 +82,4 @@ public void forEach(Consumer<T> consumer) {
}
}

@Override
public boolean equals(Object obj) {
if (obj instanceof ArraySlice o) {
if (end - start != o.end - o.start) {
return false;
}
for (var i = 0; i < end - start; i++) {
if (!get(i).equals(o.get(i))) {
return false;
}
}
return true;
}
return false;
}

@Override
public int hashCode() {
var arr = new Object[size()];
for (int i = 0; i < size(); i++) {
arr[i] = get(i);
}
return Arrays.hashCode(arr);
}
}

0 comments on commit 44ed4ba

Please sign in to comment.