1515
1616import com .oracle .truffle .api .TruffleSafepoint ;
1717import com .oracle .truffle .api .dsl .Bind ;
18- import com .oracle .truffle .api .dsl .NeverDefault ;
18+ import com .oracle .truffle .api .dsl .GenerateCached ;
19+ import com .oracle .truffle .api .dsl .GenerateInline ;
1920import com .oracle .truffle .api .object .DynamicObjectLibrary ;
2021import com .oracle .truffle .api .profiles .InlinedBranchProfile ;
2122import com .oracle .truffle .api .profiles .InlinedConditionProfile ;
3536import org .truffleruby .builtins .CoreMethodArrayArgumentsNode ;
3637import org .truffleruby .builtins .CoreMethodNode ;
3738import org .truffleruby .builtins .PrimitiveArrayArgumentsNode ;
38- import org .truffleruby .cext .CExtNodesFactory .StringToNativeNodeGen ;
3939import org .truffleruby .cext .UnwrapNode .UnwrapCArrayNode ;
4040import org .truffleruby .core .MarkingService .ExtensionCallStack ;
4141import org .truffleruby .core .MarkingServiceNodes ;
@@ -713,7 +713,7 @@ public abstract static class RbEncCodeRangeClear extends CoreMethodArrayArgument
713713 @ Specialization
714714 protected RubyString clearCodeRange (RubyString string ,
715715 @ Cached StringToNativeNode stringToNativeNode ) {
716- stringToNativeNode .executeToNative (string );
716+ stringToNativeNode .executeToNative (this , string );
717717 string .clearCodeRange ();
718718
719719 return string ;
@@ -814,7 +814,7 @@ public abstract static class RbStrCapacityNode extends CoreMethodArrayArgumentsN
814814 @ Specialization
815815 protected long capacity (Object string ,
816816 @ Cached StringToNativeNode stringToNativeNode ) {
817- return getNativeStringCapacity (stringToNativeNode .executeToNative (string ));
817+ return getNativeStringCapacity (stringToNativeNode .executeToNative (this , string ));
818818 }
819819 }
820820
@@ -827,7 +827,7 @@ protected RubyString strSetLen(RubyString string, int newByteLength,
827827 @ Cached StringToNativeNode stringToNativeNode ,
828828 @ Cached MutableTruffleString .FromNativePointerNode fromNativePointerNode ,
829829 @ Cached InlinedConditionProfile minLengthOneProfile ) {
830- var pointer = stringToNativeNode .executeToNative (string );
830+ var pointer = stringToNativeNode .executeToNative (this , string );
831831
832832 var encoding = libString .getEncoding (string );
833833 int minLength = encoding .jcoding .minLength ();
@@ -857,7 +857,7 @@ protected RubyString rbStrResize(RubyString string, int newByteLength,
857857 @ Cached RubyStringLibrary libString ,
858858 @ Cached StringToNativeNode stringToNativeNode ,
859859 @ Cached MutableTruffleString .FromNativePointerNode fromNativePointerNode ) {
860- var pointer = stringToNativeNode .executeToNative (string );
860+ var pointer = stringToNativeNode .executeToNative (this , string );
861861 var tencoding = libString .getTEncoding (string );
862862 int byteLength = string .tstring .byteLength (tencoding );
863863
@@ -886,7 +886,7 @@ protected RubyString trStrCapaResize(RubyString string, int newCapacity,
886886 @ Cached RubyStringLibrary libString ,
887887 @ Cached StringToNativeNode stringToNativeNode ,
888888 @ Cached MutableTruffleString .FromNativePointerNode fromNativePointerNode ) {
889- var pointer = stringToNativeNode .executeToNative (string );
889+ var pointer = stringToNativeNode .executeToNative (this , string );
890890 var tencoding = libString .getTEncoding (string );
891891
892892 if (getNativeStringCapacity (pointer ) == newCapacity ) {
@@ -1333,37 +1333,34 @@ public abstract static class RbHashNode extends CoreMethodArrayArgumentsNode {
13331333 @ Specialization
13341334 protected int rbHash (Object object ,
13351335 @ Cached HashingNodes .ToHashByHashCode toHashByHashCode ) {
1336- return toHashByHashCode .execute (object );
1336+ return toHashByHashCode .execute (this , object );
13371337 }
13381338 }
13391339
1340+ @ GenerateInline
1341+ @ GenerateCached (false )
13401342 public abstract static class StringToNativeNode extends RubyBaseNode {
13411343
1342- @ NeverDefault
1343- public static StringToNativeNode create () {
1344- return StringToNativeNodeGen .create ();
1345- }
1346-
1347- public abstract Pointer executeToNative (Object string );
1344+ public abstract Pointer executeToNative (Node node , Object string );
13481345
13491346 @ Specialization
1350- protected Pointer toNative (RubyString string ,
1347+ protected static Pointer toNative (Node node , RubyString string ,
13511348 @ Cached RubyStringLibrary libString ,
13521349 @ Cached InlinedConditionProfile convertProfile ,
1353- @ Cached TruffleString .CopyToNativeMemoryNode copyToNativeMemoryNode ,
1354- @ Cached MutableTruffleString .FromNativePointerNode fromNativePointerNode ,
1355- @ Cached TruffleString .GetInternalNativePointerNode getInternalNativePointerNode ) {
1350+ @ Cached ( inline = false ) TruffleString .CopyToNativeMemoryNode copyToNativeMemoryNode ,
1351+ @ Cached ( inline = false ) MutableTruffleString .FromNativePointerNode fromNativePointerNode ,
1352+ @ Cached ( inline = false ) TruffleString .GetInternalNativePointerNode getInternalNativePointerNode ) {
13561353 var tstring = string .tstring ;
13571354 var tencoding = libString .getTEncoding (string );
13581355
13591356 final Pointer pointer ;
13601357
1361- if (convertProfile .profile (this , tstring .isNative ())) {
1358+ if (convertProfile .profile (node , tstring .isNative ())) {
13621359 assert tstring .isMutable ();
13631360 pointer = (Pointer ) getInternalNativePointerNode .execute (tstring , tencoding );
13641361 } else {
13651362 int byteLength = tstring .byteLength (tencoding );
1366- pointer = allocateAndCopyToNative (getLanguage (), getContext (), tstring , tencoding , byteLength ,
1363+ pointer = allocateAndCopyToNative (getLanguage (node ), getContext (node ), tstring , tencoding , byteLength ,
13671364 copyToNativeMemoryNode );
13681365
13691366 var nativeTString = fromNativePointerNode .execute (pointer , 0 , byteLength , tencoding , false );
@@ -1374,8 +1371,8 @@ protected Pointer toNative(RubyString string,
13741371 }
13751372
13761373 @ Specialization
1377- protected Pointer toNativeImmutable (ImmutableRubyString string ) {
1378- return string .getNativeString (getLanguage ());
1374+ protected static Pointer toNativeImmutable (Node node , ImmutableRubyString string ) {
1375+ return string .getNativeString (getLanguage (node ));
13791376 }
13801377
13811378 public static Pointer allocateAndCopyToNative (RubyLanguage language , RubyContext context ,
@@ -1394,7 +1391,7 @@ public abstract static class StringPointerToNativeNode extends PrimitiveArrayArg
13941391 @ Specialization
13951392 protected long toNative (Object string ,
13961393 @ Cached StringToNativeNode stringToNativeNode ) {
1397- return stringToNativeNode .executeToNative (string ).getAddress ();
1394+ return stringToNativeNode .executeToNative (this , string ).getAddress ();
13981395 }
13991396 }
14001397
@@ -1404,7 +1401,7 @@ public abstract static class StringToFFIPointerNode extends CoreMethodArrayArgum
14041401 @ Specialization
14051402 protected RubyPointer toNative (Object string ,
14061403 @ Cached StringToNativeNode stringToNativeNode ) {
1407- var pointer = stringToNativeNode .executeToNative (string );
1404+ var pointer = stringToNativeNode .executeToNative (this , string );
14081405
14091406 final RubyPointer instance = new RubyPointer (
14101407 coreLibrary ().truffleFFIPointerClass ,
@@ -1543,56 +1540,58 @@ public abstract static class ExtractRubyTag extends CoreMethodArrayArgumentsNode
15431540 @ Specialization
15441541 protected int extractRubyTag (CapturedException captured ,
15451542 @ Cached ExtractRubyTagHelperNode helperNode ) {
1546- return helperNode .execute (captured .getException ());
1543+ return helperNode .execute (this , captured .getException ());
15471544 }
15481545 }
15491546
1547+ @ GenerateInline
1548+ @ GenerateCached (false )
15501549 public abstract static class ExtractRubyTagHelperNode extends RubyBaseNode {
15511550
1552- public abstract int execute (Throwable e );
1551+ public abstract int execute (Node node , Throwable e );
15531552
15541553 @ Specialization
1555- protected int dynamicReturnTag (DynamicReturnException e ) {
1554+ protected static int dynamicReturnTag (DynamicReturnException e ) {
15561555 return RUBY_TAG_RETURN ;
15571556 }
15581557
15591558 @ Specialization
1560- protected int localReturnTag (LocalReturnException e ) {
1559+ protected static int localReturnTag (LocalReturnException e ) {
15611560 return RUBY_TAG_RETURN ;
15621561 }
15631562
15641563 @ Specialization
1565- protected int breakTag (BreakException e ) {
1564+ protected static int breakTag (BreakException e ) {
15661565 return RUBY_TAG_BREAK ;
15671566 }
15681567
15691568 @ Specialization
1570- protected int nextTag (NextException e ) {
1569+ protected static int nextTag (NextException e ) {
15711570 return RUBY_TAG_NEXT ;
15721571 }
15731572
15741573 @ Specialization
1575- protected int retryTag (RetryException e ) {
1574+ protected static int retryTag (RetryException e ) {
15761575 return RUBY_TAG_RETRY ;
15771576 }
15781577
15791578 @ Specialization
1580- protected int redoTag (RedoException e ) {
1579+ protected static int redoTag (RedoException e ) {
15811580 return RUBY_TAG_REDO ;
15821581 }
15831582
15841583 @ Specialization
1585- protected int raiseTag (RaiseException e ) {
1584+ protected static int raiseTag (RaiseException e ) {
15861585 return RUBY_TAG_RAISE ;
15871586 }
15881587
15891588 @ Specialization
1590- protected int throwTag (ThrowException e ) {
1589+ protected static int throwTag (ThrowException e ) {
15911590 return RUBY_TAG_THROW ;
15921591 }
15931592
15941593 @ Fallback
1595- protected int noTag (Throwable e ) {
1594+ protected static int noTag (Throwable e ) {
15961595 return 0 ;
15971596 }
15981597 }
0 commit comments