Skip to content

Commit 81c519f

Browse files
Nicolas Laurenteregon
authored andcommitted
use a ContextReference in RubyContextNode
(cherry picked from commit f0fac2f)
1 parent 677a93d commit 81c519f

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/main/java/org/truffleruby/language/RubyContextNode.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*/
1010
package org.truffleruby.language;
1111

12+
import com.oracle.truffle.api.TruffleLanguage.ContextReference;
1213
import org.truffleruby.RubyContext;
1314
import org.truffleruby.RubyLanguage;
1415

@@ -18,18 +19,15 @@
1819
/** Has context but nothing else. */
1920
public abstract class RubyContextNode extends RubyBaseNode implements RubyNode.WithContext {
2021

21-
@CompilationFinal private RubyContext context;
22-
23-
// Accessors
22+
@CompilationFinal private ContextReference<RubyContext> contextReference;
2423

2524
@Override
2625
public RubyContext getContext() {
27-
if (context == null) {
26+
if (contextReference == null) {
2827
CompilerDirectives.transferToInterpreterAndInvalidate();
29-
context = RubyLanguage.getCurrentContext();
28+
contextReference = lookupContextReference(RubyLanguage.class);
3029
}
3130

32-
return context;
31+
return contextReference.get();
3332
}
34-
3533
}

0 commit comments

Comments
 (0)