88
88
import com .oracle .graal .python .runtime .object .PythonObjectFactory ;
89
89
import com .oracle .truffle .api .CompilerDirectives ;
90
90
import com .oracle .truffle .api .CompilerDirectives .TruffleBoundary ;
91
+ import com .oracle .truffle .api .dsl .Bind ;
91
92
import com .oracle .truffle .api .dsl .Cached ;
92
93
import com .oracle .truffle .api .dsl .Cached .Shared ;
93
94
import com .oracle .truffle .api .dsl .GenerateNodeFactory ;
105
106
import com .oracle .truffle .api .interop .UnsupportedMessageException ;
106
107
import com .oracle .truffle .api .interop .UnsupportedTypeException ;
107
108
import com .oracle .truffle .api .library .CachedLibrary ;
108
- import com .oracle .truffle .api .profiles .BranchProfile ;
109
- import com .oracle .truffle .api .profiles .ConditionProfile ;
109
+ import com .oracle .truffle .api .nodes .Node ;
110
+ import com .oracle .truffle .api .profiles .InlinedBranchProfile ;
111
+ import com .oracle .truffle .api .profiles .InlinedConditionProfile ;
110
112
import com .oracle .truffle .api .source .Source ;
111
113
import com .oracle .truffle .api .source .SourceSection ;
112
114
import com .oracle .truffle .api .strings .TruffleString ;
@@ -541,16 +543,17 @@ abstract static class RECheckInputTypeNode extends PNodeWithRaise {
541
543
542
544
@ Specialization
543
545
protected void check (VirtualFrame frame , Object input , boolean expectBytes ,
546
+ @ Bind ("this" ) Node inliningTarget ,
544
547
@ Cached BuiltinFunctions .IsInstanceNode isStringNode ,
545
548
@ Cached BuiltinFunctions .IsInstanceNode isBytesNode ,
546
- @ Cached ConditionProfile unsupportedInputTypeProfile ,
547
- @ Cached ConditionProfile unexpectedInputTypeProfile ) {
549
+ @ Cached InlinedConditionProfile unsupportedInputTypeProfile ,
550
+ @ Cached InlinedConditionProfile unexpectedInputTypeProfile ) {
548
551
boolean isString = (boolean ) isStringNode .execute (frame , input , PythonBuiltinClassType .PString );
549
552
boolean isBytes = !isString && (boolean ) isBytesNode .execute (frame , input , SUPPORTED_BINARY_INPUT_TYPES );
550
- if (unsupportedInputTypeProfile .profile (!isString && !isBytes )) {
553
+ if (unsupportedInputTypeProfile .profile (inliningTarget , !isString && !isBytes )) {
551
554
throw getRaiseNode ().raise (TypeError , T_UNSUPPORTED_INPUT_TYPE );
552
555
}
553
- if (unexpectedInputTypeProfile .profile (expectBytes != isBytes )) {
556
+ if (unexpectedInputTypeProfile .profile (inliningTarget , expectBytes != isBytes )) {
554
557
if (expectBytes ) {
555
558
throw getRaiseNode ().raise (TypeError , T_UNEXPECTED_STR );
556
559
} else {
@@ -569,13 +572,14 @@ abstract static class CreateMatchFromTRegexResultNode extends PNodeWithContext {
569
572
570
573
@ Specialization
571
574
protected Object createMatch (VirtualFrame frame , Object pattern , int pos , int endPos , Object regexResult , Object input ,
575
+ @ Bind ("this" ) Node inliningTarget ,
572
576
@ Cached ("lookupMatchConstructor()" ) Object matchConstructor ,
573
- @ Cached ConditionProfile matchProfile ,
577
+ @ Cached InlinedConditionProfile matchProfile ,
574
578
@ CachedLibrary (limit = "1" ) InteropLibrary libResult ,
575
579
@ Cached PyObjectLookupAttr lookupIndexGroupNode ,
576
580
@ Cached CallNode constructResultNode ) {
577
581
try {
578
- if (matchProfile .profile ((boolean ) libResult .readMember (regexResult , "isMatch" ))) {
582
+ if (matchProfile .profile (inliningTarget , (boolean ) libResult .readMember (regexResult , "isMatch" ))) {
579
583
Object indexGroup = lookupIndexGroupNode .execute (frame , pattern , T__PATTERN__INDEXGROUP );
580
584
return constructResultNode .execute (matchConstructor , pattern , pos , endPos , regexResult , input , indexGroup );
581
585
} else {
@@ -608,16 +612,18 @@ abstract static class TRegexSearch extends PythonSenaryBuiltinNode {
608
612
@ Child private PyObjectGetItem getItemNode ;
609
613
610
614
@ Specialization (guards = {"isSingleContext()" , "pattern == cachedPattern" , "method == cachedMethod" , "mustAdvance == cachedMustAdvance" , "!tRegexCache.isLocaleSensitive()" }, limit = "1" )
615
+ @ SuppressWarnings ("truffle-static-method" )
611
616
protected Object doCached (VirtualFrame frame , Object pattern , Object input , Object posArg , Object endPosArg , int method , boolean mustAdvance ,
617
+ @ Bind ("this" ) Node inliningTarget ,
612
618
@ Cached ("pattern" ) Object cachedPattern ,
613
619
@ Cached ("method" ) int cachedMethod ,
614
620
@ Cached ("mustAdvance" ) boolean cachedMustAdvance ,
615
621
@ Cached @ Shared ReadAttributeFromObjectNode readCacheNode ,
616
622
@ Cached @ Shared TRegexCompile tRegexCompileNode ,
617
623
@ Cached ("getTRegexCache(readCacheNode, pattern)" ) TRegexCache tRegexCache ,
618
624
@ Cached ("tRegexCompileNode.execute(frame, tRegexCache, method, mustAdvance)" ) Object compiledRegex ,
619
- @ Cached @ Shared ConditionProfile fallbackProfile ,
620
- @ Cached @ Shared ConditionProfile truncatingInputProfile ,
625
+ @ Cached @ Shared InlinedConditionProfile fallbackProfile ,
626
+ @ Cached @ Shared InlinedConditionProfile truncatingInputProfile ,
621
627
@ Cached @ Shared RECheckInputTypeNode reCheckInputTypeNode ,
622
628
@ Cached @ Shared PyNumberIndexNode indexNode ,
623
629
@ Cached @ Shared PyNumberAsSizeNode asSizeNode ,
@@ -642,13 +648,13 @@ protected Object doCached(VirtualFrame frame, Object pattern, Object input, Obje
642
648
endPos = length ;
643
649
}
644
650
645
- if (fallbackProfile .profile (libCompiledRegex .isNull (compiledRegex ))) {
651
+ if (fallbackProfile .profile (inliningTarget , libCompiledRegex .isNull (compiledRegex ))) {
646
652
Object fallbackRegex = getCallFallbackCompileNode ().execute (getGetFallbackCompileNode ().executeObject (frame , pattern ));
647
653
return getCallFallbackMethodNode ().execute (getFallbackMethodNode .executeObject (frame , fallbackRegex ), input , pos , endPos );
648
654
}
649
655
650
656
Object truncatedInput = input ;
651
- if (truncatingInputProfile .profile (endPos != length )) {
657
+ if (truncatingInputProfile .profile (inliningTarget , endPos != length )) {
652
658
truncatedInput = getGetItemNode ().execute (frame , input , getCreateSliceNode ().execute (0 , endPos , 1 ));
653
659
}
654
660
Object regexResult = tRegexCallExec .execute (frame , compiledRegex , truncatedInput , pos );
@@ -658,15 +664,17 @@ protected Object doCached(VirtualFrame frame, Object pattern, Object input, Obje
658
664
659
665
@ Specialization (guards = {"tRegexCompileNode.execute(frame, getTRegexCache(readCacheNode, pattern), method, mustAdvance) == compiledRegex" , "method == cachedMethod" ,
660
666
"mustAdvance == cachedMustAdvance" , "!tRegexCache.isLocaleSensitive()" }, limit = "1" )
667
+ @ SuppressWarnings ("truffle-static-method" )
661
668
protected Object doCachedRegex (VirtualFrame frame , Object pattern , Object input , Object posArg , Object endPosArg , int method , boolean mustAdvance ,
669
+ @ Bind ("this" ) Node inliningTarget ,
662
670
@ Cached ("method" ) int cachedMethod ,
663
671
@ Cached ("mustAdvance" ) boolean cachedMustAdvance ,
664
672
@ Cached @ Shared ReadAttributeFromObjectNode readCacheNode ,
665
673
@ Cached @ Shared TRegexCompile tRegexCompileNode ,
666
674
@ Cached ("getTRegexCache(readCacheNode, pattern)" ) TRegexCache tRegexCache ,
667
675
@ Cached ("tRegexCompileNode.execute(frame, tRegexCache, method, mustAdvance)" ) Object compiledRegex ,
668
- @ Cached @ Shared ConditionProfile fallbackProfile ,
669
- @ Cached @ Shared ConditionProfile truncatingInputProfile ,
676
+ @ Cached @ Shared InlinedConditionProfile fallbackProfile ,
677
+ @ Cached @ Shared InlinedConditionProfile truncatingInputProfile ,
670
678
@ Cached @ Shared RECheckInputTypeNode reCheckInputTypeNode ,
671
679
@ Cached @ Shared PyNumberIndexNode indexNode ,
672
680
@ Cached @ Shared PyNumberAsSizeNode asSizeNode ,
@@ -675,30 +683,32 @@ protected Object doCachedRegex(VirtualFrame frame, Object pattern, Object input,
675
683
@ Cached ("create(getMethodName(method))" ) GetAttributeNode getFallbackMethodNode ,
676
684
@ Cached @ Shared TRegexCallExec tRegexCallExec ,
677
685
@ Cached @ Shared CreateMatchFromTRegexResultNode createMatchFromTRegexResultNode ) {
678
- return doCached (frame , pattern , input , posArg , endPosArg , method , mustAdvance , pattern , cachedMethod , mustAdvance , readCacheNode , tRegexCompileNode , tRegexCache ,
686
+ return doCached (frame , pattern , input , posArg , endPosArg , method , mustAdvance , inliningTarget , pattern , cachedMethod , mustAdvance , readCacheNode , tRegexCompileNode , tRegexCache ,
679
687
compiledRegex , fallbackProfile , truncatingInputProfile , reCheckInputTypeNode , indexNode , asSizeNode , lengthNode , libCompiledRegex , getFallbackMethodNode ,
680
688
tRegexCallExec , createMatchFromTRegexResultNode );
681
689
}
682
690
683
691
@ Specialization (guards = "method == cachedMethod" , limit = "3" , replaces = {"doCached" , "doCachedRegex" })
692
+ @ SuppressWarnings ("truffle-static-method" )
684
693
@ ReportPolymorphism .Megamorphic
685
694
protected Object doDynamic (VirtualFrame frame , Object pattern , Object input , Object posArg , Object endPosArg , int method , boolean mustAdvance ,
695
+ @ Bind ("this" ) Node inliningTarget ,
686
696
@ Cached ("method" ) int cachedMethod ,
687
697
@ Cached @ Shared ReadAttributeFromObjectNode readCacheNode ,
688
698
@ Cached @ Shared TRegexCompile tRegexCompileNode ,
689
699
@ Cached @ Shared PyNumberIndexNode indexNode ,
690
700
@ Cached @ Shared PyNumberAsSizeNode asSizeNode ,
691
701
@ Cached @ Shared RECheckInputTypeNode reCheckInputTypeNode ,
692
702
@ Cached @ Shared PyObjectSizeNode lengthNode ,
693
- @ Cached @ Shared ConditionProfile fallbackProfile ,
694
- @ Cached @ Shared ConditionProfile truncatingInputProfile ,
703
+ @ Cached @ Shared InlinedConditionProfile fallbackProfile ,
704
+ @ Cached @ Shared InlinedConditionProfile truncatingInputProfile ,
695
705
@ CachedLibrary (limit = "1" ) @ Shared InteropLibrary libCompiledRegex ,
696
706
@ Cached ("create(getMethodName(method))" ) GetAttributeNode getFallbackMethodNode ,
697
707
@ Cached @ Shared TRegexCallExec tRegexCallExec ,
698
708
@ Cached @ Shared CreateMatchFromTRegexResultNode createMatchFromTRegexResultNode ) {
699
709
TRegexCache tRegexCache = getTRegexCache (readCacheNode , pattern );
700
710
Object compiledRegex = tRegexCompileNode .execute (frame , tRegexCache , method , mustAdvance );
701
- return doCached (frame , pattern , input , posArg , endPosArg , method , mustAdvance , pattern , cachedMethod , mustAdvance , readCacheNode , tRegexCompileNode , tRegexCache ,
711
+ return doCached (frame , pattern , input , posArg , endPosArg , method , mustAdvance , inliningTarget , pattern , cachedMethod , mustAdvance , readCacheNode , tRegexCompileNode , tRegexCache ,
702
712
compiledRegex , fallbackProfile , truncatingInputProfile , reCheckInputTypeNode , indexNode , asSizeNode , lengthNode , libCompiledRegex , getFallbackMethodNode ,
703
713
tRegexCallExec , createMatchFromTRegexResultNode );
704
714
}
@@ -760,21 +770,23 @@ abstract static class TRegexCallExec extends PythonTernaryBuiltinNode {
760
770
@ Child private BufferToTruffleStringNode bufferToTruffleStringNode ;
761
771
762
772
@ Specialization (guards = "callable == cachedCallable" , limit = "2" )
773
+ @ SuppressWarnings ("truffle-static-method" )
763
774
Object doCached (VirtualFrame frame , Object callable , Object inputStringOrBytes , Number fromIndex ,
775
+ @ Bind ("this" ) Node inliningTarget ,
764
776
@ Cached ("callable" ) Object cachedCallable ,
765
777
@ Cached @ Shared CastToTruffleStringNode cast ,
766
778
@ CachedLibrary (limit = "3" ) @ Shared PythonBufferAcquireLibrary bufferAcquireLib ,
767
779
@ CachedLibrary (limit = "1" ) @ Shared PythonBufferAccessLibrary bufferLib ,
768
780
@ CachedLibrary ("callable" ) InteropLibrary interop ,
769
- @ Cached @ Shared BranchProfile binaryProfile ) {
781
+ @ Cached @ Shared InlinedBranchProfile binaryProfile ) {
770
782
TruffleString input ;
771
783
Object buffer = null ;
772
784
try {
773
785
try {
774
786
// This would materialize the string if it was native
775
787
input = cast .execute (inputStringOrBytes );
776
788
} catch (CannotCastException e1 ) {
777
- binaryProfile .enter ();
789
+ binaryProfile .enter (inliningTarget );
778
790
// It's bytes or other buffer object
779
791
buffer = bufferAcquireLib .acquireReadonly (inputStringOrBytes , frame , this );
780
792
input = getBufferToTruffleStringNode ().execute (buffer , 0 );
@@ -794,12 +806,13 @@ Object doCached(VirtualFrame frame, Object callable, Object inputStringOrBytes,
794
806
@ Specialization (limit = "1" , replaces = "doCached" )
795
807
@ ReportPolymorphism .Megamorphic
796
808
Object doUncached (VirtualFrame frame , Object callable , Object inputStringOrBytes , Number fromIndex ,
809
+ @ Bind ("this" ) Node inliningTarget ,
797
810
@ Cached @ Shared CastToTruffleStringNode cast ,
798
811
@ CachedLibrary (limit = "3" ) @ Shared PythonBufferAcquireLibrary bufferAcquireLib ,
799
812
@ CachedLibrary (limit = "1" ) @ Shared PythonBufferAccessLibrary bufferLib ,
800
813
@ CachedLibrary ("callable" ) InteropLibrary interop ,
801
- @ Cached @ Shared BranchProfile binaryProfile ) {
802
- return doCached (frame , callable , inputStringOrBytes , fromIndex , callable , cast , bufferAcquireLib , bufferLib , interop , binaryProfile );
814
+ @ Cached @ Shared InlinedBranchProfile binaryProfile ) {
815
+ return doCached (frame , callable , inputStringOrBytes , fromIndex , inliningTarget , callable , cast , bufferAcquireLib , bufferLib , interop , binaryProfile );
803
816
}
804
817
805
818
private BufferToTruffleStringNode getBufferToTruffleStringNode () {
0 commit comments