Skip to content

Commit 2953280

Browse files
committed
Mark RubyLanguage.getCurrentLanguage() and getCurrentContext() as neverPartOfCompilation
* neverPartOfCompilation() is much safer to use now that it is checked statically when building a Native Image.
1 parent 8049d2c commit 2953280

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/main/java/org/truffleruby/RubyContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ public Hashing getHashing() {
533533

534534
public RubyLanguage getLanguageSlow() {
535535
CompilerAsserts.neverPartOfCompilation(
536-
"@CachedLanguage or a final field in the node should be used so the RubyLanguage instance is constant in PE code");
536+
"Use getLanguage() or @CachedLanguage instead, so the RubyLanguage instance is constant in PE code");
537537
return language;
538538
}
539539

src/main/java/org/truffleruby/RubyLanguage.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import java.util.concurrent.atomic.AtomicLong;
1515
import java.util.concurrent.locks.ReentrantLock;
1616

17+
import com.oracle.truffle.api.CompilerAsserts;
1718
import com.oracle.truffle.api.CompilerDirectives;
1819
import com.oracle.truffle.api.instrumentation.AllocationReporter;
1920
import com.oracle.truffle.api.object.Shape;
@@ -327,10 +328,12 @@ protected void disposeContext(RubyContext context) {
327328
}
328329

329330
public static RubyContext getCurrentContext() {
331+
CompilerAsserts.neverPartOfCompilation("Use getContext() or @CachedContext instead in PE code");
330332
return getCurrentContext(RubyLanguage.class);
331333
}
332334

333335
public static RubyLanguage getCurrentLanguage() {
336+
CompilerAsserts.neverPartOfCompilation("Use getLanguage() or @CachedLanguage instead in PE code");
334337
return getCurrentLanguage(RubyLanguage.class);
335338
}
336339

0 commit comments

Comments
 (0)