Skip to content

Commit

Permalink
cache unresolvedsymbol
Browse files Browse the repository at this point in the history
As per PR review
  • Loading branch information
hubertp committed May 3, 2023
1 parent 80a65be commit d771f6f
Showing 1 changed file with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,17 @@ public void setTailStatus(TailStatus tailStatus) {
public abstract Object execute(
VirtualFrame frame, State state, UnresolvedSymbol symbol, Object self, Object[] arguments);

@Specialization(guards = {"typesLibrary.hasType(self)", "!typesLibrary.hasSpecialDispatch(self)"})
Object doFunctionalDispatch(
@Specialization(guards = {"typesLibrary.hasType(self)", "!typesLibrary.hasSpecialDispatch(self)", "cachedSymbol == symbol"})
Object doFunctionalDispatchCachedSymbol(
VirtualFrame frame,
State state,
UnresolvedSymbol symbol,
Object self,
Object[] arguments,
@CachedLibrary(limit = "10") TypesLibrary typesLibrary,
@Cached MethodResolverNode methodResolverNode,
@Cached("anyFunction(symbol)") Function anyFun) {
@Cached("symbol") UnresolvedSymbol cachedSymbol,
@Cached("anyFunction(cachedSymbol)") Function anyFun) {

Type selfTpe = typesLibrary.getType(self);
Function function = methodResolverNode.expectNonNull(self, selfTpe, symbol);
Expand Down Expand Up @@ -148,6 +149,20 @@ private boolean typeCanOverride(MethodRootNode node, EnsoContext ctx) {
&& warning.getEigentype() != methodOwnerType;
}

@Specialization(replaces = "doFunctionalDispatchCachedSymbol", guards = {"typesLibrary.hasType(self)", "!typesLibrary.hasSpecialDispatch(self)"})
Object doFunctionalDispatchUncachedSymbol(
VirtualFrame frame,
State state,
UnresolvedSymbol symbol,
Object self,
Object[] arguments,
@CachedLibrary(limit = "10") TypesLibrary typesLibrary,
@Cached MethodResolverNode methodResolverNode) {
Type selfTpe = typesLibrary.getType(self);
Function function = methodResolverNode.expectNonNull(self, selfTpe, symbol);
return invokeFunctionNode.execute(function, frame, state, arguments);
}

@Specialization
Object doDataflowError(
VirtualFrame frame,
Expand Down

0 comments on commit d771f6f

Please sign in to comment.