Skip to content

Commit

Permalink
Share TruffleString.EqualNode between cached specialization instances.
Browse files Browse the repository at this point in the history
  • Loading branch information
woess committed Jan 28, 2025
1 parent 784d46f commit fc453bd
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* The Universal Permissive License (UPL), Version 1.0
Expand Down Expand Up @@ -394,6 +394,12 @@ protected static TruffleString uncached(JSObject object) {

public abstract static class FormatCacheNode extends JavaScriptBaseNode {

@Child TruffleString.EqualNode equalsNode;

protected FormatCacheNode() {
this.equalsNode = TruffleString.EqualNode.create();
}

public abstract TruffleString execute(TruffleString name);

public static FormatCacheNode create() {
Expand All @@ -404,8 +410,7 @@ public static FormatCacheNode create() {
@Specialization(guards = {"stringEquals(equalsNode, cachedName, name)"}, limit = "10")
protected TruffleString doCached(TruffleString name,
@Cached("name") TruffleString cachedName,
@Cached("doUncached(name)") TruffleString cachedResult,
@Cached TruffleString.EqualNode equalsNode) {
@Cached("doUncached(name)") TruffleString cachedResult) {
return cachedResult;
}

Expand Down

0 comments on commit fc453bd

Please sign in to comment.