15
15
16
16
import com .oracle .truffle .api .TruffleSafepoint ;
17
17
import 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 ;
19
20
import com .oracle .truffle .api .object .DynamicObjectLibrary ;
20
21
import com .oracle .truffle .api .profiles .InlinedBranchProfile ;
21
22
import com .oracle .truffle .api .profiles .InlinedConditionProfile ;
35
36
import org .truffleruby .builtins .CoreMethodArrayArgumentsNode ;
36
37
import org .truffleruby .builtins .CoreMethodNode ;
37
38
import org .truffleruby .builtins .PrimitiveArrayArgumentsNode ;
38
- import org .truffleruby .cext .CExtNodesFactory .StringToNativeNodeGen ;
39
39
import org .truffleruby .cext .UnwrapNode .UnwrapCArrayNode ;
40
40
import org .truffleruby .core .MarkingService .ExtensionCallStack ;
41
41
import org .truffleruby .core .MarkingServiceNodes ;
@@ -713,7 +713,7 @@ public abstract static class RbEncCodeRangeClear extends CoreMethodArrayArgument
713
713
@ Specialization
714
714
protected RubyString clearCodeRange (RubyString string ,
715
715
@ Cached StringToNativeNode stringToNativeNode ) {
716
- stringToNativeNode .executeToNative (string );
716
+ stringToNativeNode .executeToNative (this , string );
717
717
string .clearCodeRange ();
718
718
719
719
return string ;
@@ -814,7 +814,7 @@ public abstract static class RbStrCapacityNode extends CoreMethodArrayArgumentsN
814
814
@ Specialization
815
815
protected long capacity (Object string ,
816
816
@ Cached StringToNativeNode stringToNativeNode ) {
817
- return getNativeStringCapacity (stringToNativeNode .executeToNative (string ));
817
+ return getNativeStringCapacity (stringToNativeNode .executeToNative (this , string ));
818
818
}
819
819
}
820
820
@@ -827,7 +827,7 @@ protected RubyString strSetLen(RubyString string, int newByteLength,
827
827
@ Cached StringToNativeNode stringToNativeNode ,
828
828
@ Cached MutableTruffleString .FromNativePointerNode fromNativePointerNode ,
829
829
@ Cached InlinedConditionProfile minLengthOneProfile ) {
830
- var pointer = stringToNativeNode .executeToNative (string );
830
+ var pointer = stringToNativeNode .executeToNative (this , string );
831
831
832
832
var encoding = libString .getEncoding (string );
833
833
int minLength = encoding .jcoding .minLength ();
@@ -857,7 +857,7 @@ protected RubyString rbStrResize(RubyString string, int newByteLength,
857
857
@ Cached RubyStringLibrary libString ,
858
858
@ Cached StringToNativeNode stringToNativeNode ,
859
859
@ Cached MutableTruffleString .FromNativePointerNode fromNativePointerNode ) {
860
- var pointer = stringToNativeNode .executeToNative (string );
860
+ var pointer = stringToNativeNode .executeToNative (this , string );
861
861
var tencoding = libString .getTEncoding (string );
862
862
int byteLength = string .tstring .byteLength (tencoding );
863
863
@@ -886,7 +886,7 @@ protected RubyString trStrCapaResize(RubyString string, int newCapacity,
886
886
@ Cached RubyStringLibrary libString ,
887
887
@ Cached StringToNativeNode stringToNativeNode ,
888
888
@ Cached MutableTruffleString .FromNativePointerNode fromNativePointerNode ) {
889
- var pointer = stringToNativeNode .executeToNative (string );
889
+ var pointer = stringToNativeNode .executeToNative (this , string );
890
890
var tencoding = libString .getTEncoding (string );
891
891
892
892
if (getNativeStringCapacity (pointer ) == newCapacity ) {
@@ -1333,37 +1333,34 @@ public abstract static class RbHashNode extends CoreMethodArrayArgumentsNode {
1333
1333
@ Specialization
1334
1334
protected int rbHash (Object object ,
1335
1335
@ Cached HashingNodes .ToHashByHashCode toHashByHashCode ) {
1336
- return toHashByHashCode .execute (object );
1336
+ return toHashByHashCode .execute (this , object );
1337
1337
}
1338
1338
}
1339
1339
1340
+ @ GenerateInline
1341
+ @ GenerateCached (false )
1340
1342
public abstract static class StringToNativeNode extends RubyBaseNode {
1341
1343
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 );
1348
1345
1349
1346
@ Specialization
1350
- protected Pointer toNative (RubyString string ,
1347
+ protected static Pointer toNative (Node node , RubyString string ,
1351
1348
@ Cached RubyStringLibrary libString ,
1352
1349
@ 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 ) {
1356
1353
var tstring = string .tstring ;
1357
1354
var tencoding = libString .getTEncoding (string );
1358
1355
1359
1356
final Pointer pointer ;
1360
1357
1361
- if (convertProfile .profile (this , tstring .isNative ())) {
1358
+ if (convertProfile .profile (node , tstring .isNative ())) {
1362
1359
assert tstring .isMutable ();
1363
1360
pointer = (Pointer ) getInternalNativePointerNode .execute (tstring , tencoding );
1364
1361
} else {
1365
1362
int byteLength = tstring .byteLength (tencoding );
1366
- pointer = allocateAndCopyToNative (getLanguage (), getContext (), tstring , tencoding , byteLength ,
1363
+ pointer = allocateAndCopyToNative (getLanguage (node ), getContext (node ), tstring , tencoding , byteLength ,
1367
1364
copyToNativeMemoryNode );
1368
1365
1369
1366
var nativeTString = fromNativePointerNode .execute (pointer , 0 , byteLength , tencoding , false );
@@ -1374,8 +1371,8 @@ protected Pointer toNative(RubyString string,
1374
1371
}
1375
1372
1376
1373
@ 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 ));
1379
1376
}
1380
1377
1381
1378
public static Pointer allocateAndCopyToNative (RubyLanguage language , RubyContext context ,
@@ -1394,7 +1391,7 @@ public abstract static class StringPointerToNativeNode extends PrimitiveArrayArg
1394
1391
@ Specialization
1395
1392
protected long toNative (Object string ,
1396
1393
@ Cached StringToNativeNode stringToNativeNode ) {
1397
- return stringToNativeNode .executeToNative (string ).getAddress ();
1394
+ return stringToNativeNode .executeToNative (this , string ).getAddress ();
1398
1395
}
1399
1396
}
1400
1397
@@ -1404,7 +1401,7 @@ public abstract static class StringToFFIPointerNode extends CoreMethodArrayArgum
1404
1401
@ Specialization
1405
1402
protected RubyPointer toNative (Object string ,
1406
1403
@ Cached StringToNativeNode stringToNativeNode ) {
1407
- var pointer = stringToNativeNode .executeToNative (string );
1404
+ var pointer = stringToNativeNode .executeToNative (this , string );
1408
1405
1409
1406
final RubyPointer instance = new RubyPointer (
1410
1407
coreLibrary ().truffleFFIPointerClass ,
@@ -1543,56 +1540,58 @@ public abstract static class ExtractRubyTag extends CoreMethodArrayArgumentsNode
1543
1540
@ Specialization
1544
1541
protected int extractRubyTag (CapturedException captured ,
1545
1542
@ Cached ExtractRubyTagHelperNode helperNode ) {
1546
- return helperNode .execute (captured .getException ());
1543
+ return helperNode .execute (this , captured .getException ());
1547
1544
}
1548
1545
}
1549
1546
1547
+ @ GenerateInline
1548
+ @ GenerateCached (false )
1550
1549
public abstract static class ExtractRubyTagHelperNode extends RubyBaseNode {
1551
1550
1552
- public abstract int execute (Throwable e );
1551
+ public abstract int execute (Node node , Throwable e );
1553
1552
1554
1553
@ Specialization
1555
- protected int dynamicReturnTag (DynamicReturnException e ) {
1554
+ protected static int dynamicReturnTag (DynamicReturnException e ) {
1556
1555
return RUBY_TAG_RETURN ;
1557
1556
}
1558
1557
1559
1558
@ Specialization
1560
- protected int localReturnTag (LocalReturnException e ) {
1559
+ protected static int localReturnTag (LocalReturnException e ) {
1561
1560
return RUBY_TAG_RETURN ;
1562
1561
}
1563
1562
1564
1563
@ Specialization
1565
- protected int breakTag (BreakException e ) {
1564
+ protected static int breakTag (BreakException e ) {
1566
1565
return RUBY_TAG_BREAK ;
1567
1566
}
1568
1567
1569
1568
@ Specialization
1570
- protected int nextTag (NextException e ) {
1569
+ protected static int nextTag (NextException e ) {
1571
1570
return RUBY_TAG_NEXT ;
1572
1571
}
1573
1572
1574
1573
@ Specialization
1575
- protected int retryTag (RetryException e ) {
1574
+ protected static int retryTag (RetryException e ) {
1576
1575
return RUBY_TAG_RETRY ;
1577
1576
}
1578
1577
1579
1578
@ Specialization
1580
- protected int redoTag (RedoException e ) {
1579
+ protected static int redoTag (RedoException e ) {
1581
1580
return RUBY_TAG_REDO ;
1582
1581
}
1583
1582
1584
1583
@ Specialization
1585
- protected int raiseTag (RaiseException e ) {
1584
+ protected static int raiseTag (RaiseException e ) {
1586
1585
return RUBY_TAG_RAISE ;
1587
1586
}
1588
1587
1589
1588
@ Specialization
1590
- protected int throwTag (ThrowException e ) {
1589
+ protected static int throwTag (ThrowException e ) {
1591
1590
return RUBY_TAG_THROW ;
1592
1591
}
1593
1592
1594
1593
@ Fallback
1595
- protected int noTag (Throwable e ) {
1594
+ protected static int noTag (Throwable e ) {
1596
1595
return 0 ;
1597
1596
}
1598
1597
}
0 commit comments