114
114
import com .oracle .graal .python .nodes .function .builtins .PythonBinaryClinicBuiltinNode ;
115
115
import com .oracle .graal .python .nodes .function .builtins .PythonUnaryBuiltinNode ;
116
116
import com .oracle .graal .python .nodes .function .builtins .clinic .ArgumentClinicProvider ;
117
- import com .oracle .graal .python .nodes .object .IsBuiltinClassProfile ;
117
+ import com .oracle .graal .python .nodes .object .BuiltinClassProfiles . IsBuiltinObjectProfile ;
118
118
import com .oracle .graal .python .nodes .object .IsNode ;
119
119
import com .oracle .graal .python .runtime .exception .PException ;
120
120
import com .oracle .graal .python .util .ArrayBuilder ;
121
+ import com .oracle .truffle .api .dsl .Bind ;
121
122
import com .oracle .truffle .api .dsl .Cached ;
122
123
import com .oracle .truffle .api .dsl .GenerateNodeFactory ;
123
124
import com .oracle .truffle .api .dsl .ImportStatic ;
124
125
import com .oracle .truffle .api .dsl .NodeFactory ;
125
126
import com .oracle .truffle .api .dsl .Specialization ;
126
127
import com .oracle .truffle .api .frame .VirtualFrame ;
127
128
import com .oracle .truffle .api .library .CachedLibrary ;
129
+ import com .oracle .truffle .api .nodes .Node ;
128
130
import com .oracle .truffle .api .profiles .BranchProfile ;
129
131
import com .oracle .truffle .api .profiles .ConditionProfile ;
132
+ import com .oracle .truffle .api .profiles .InlinedConditionProfile ;
130
133
import com .oracle .truffle .api .strings .TruffleString ;
131
134
132
135
@ CoreFunctions (extendClasses = PythonBuiltinClassType .PIOBase )
@@ -382,9 +385,10 @@ Object next(VirtualFrame frame, PythonObject self,
382
385
abstract static class WriteLinesNode extends PythonBinaryBuiltinNode {
383
386
@ Specialization
384
387
static Object writeLines (VirtualFrame frame , PythonObject self , Object lines ,
388
+ @ Bind ("this" ) Node inliningTarget ,
385
389
@ Cached CheckClosedNode checkClosedNode ,
386
390
@ Cached GetNextNode getNextNode ,
387
- @ Cached IsBuiltinClassProfile errorProfile ,
391
+ @ Cached IsBuiltinObjectProfile errorProfile ,
388
392
@ Cached PyObjectCallMethodObjArgs callMethod ,
389
393
@ Cached PyObjectGetIter getIter ) {
390
394
checkClosedNode .execute (frame , self );
@@ -394,7 +398,7 @@ static Object writeLines(VirtualFrame frame, PythonObject self, Object lines,
394
398
try {
395
399
line = getNextNode .execute (frame , iter );
396
400
} catch (PException e ) {
397
- e .expectStopIteration (errorProfile );
401
+ e .expectStopIteration (inliningTarget , errorProfile );
398
402
break ;
399
403
}
400
404
callMethod .execute (frame , self , T_WRITE , line );
@@ -478,21 +482,15 @@ protected ArgumentClinicProvider getArgumentClinic() {
478
482
return IOBaseBuiltinsClinicProviders .ReadlinesNodeClinicProviderGen .INSTANCE ;
479
483
}
480
484
481
- @ Specialization (guards = "hint <= 0" )
482
- Object doall (VirtualFrame frame , Object self , @ SuppressWarnings ("unused" ) int hint ,
483
- @ Cached GetNextNode next ,
484
- @ Cached IsBuiltinClassProfile errorProfile ,
485
- @ Cached PyObjectGetIter getIter ,
486
- @ Cached PyObjectSizeNode sizeNode ) {
487
- return withHint (frame , self , Integer .MAX_VALUE , next , errorProfile , getIter , sizeNode );
488
- }
489
-
490
- @ Specialization (guards = "hint > 0" )
491
- Object withHint (VirtualFrame frame , Object self , int hint ,
485
+ @ Specialization
486
+ Object withHint (VirtualFrame frame , Object self , int hintIn ,
487
+ @ Bind ("this" ) Node inliningTarget ,
492
488
@ Cached GetNextNode next ,
493
- @ Cached IsBuiltinClassProfile errorProfile ,
489
+ @ Cached InlinedConditionProfile isNegativeHintProfile ,
490
+ @ Cached IsBuiltinObjectProfile errorProfile ,
494
491
@ Cached PyObjectGetIter getIter ,
495
492
@ Cached PyObjectSizeNode sizeNode ) {
493
+ int hint = isNegativeHintProfile .profile (inliningTarget , hintIn <= 0 ) ? Integer .MAX_VALUE : hintIn ;
496
494
int length = 0 ;
497
495
Object iterator = getIter .execute (frame , self );
498
496
ArrayBuilder <Object > list = new ArrayBuilder <>();
@@ -506,7 +504,7 @@ Object withHint(VirtualFrame frame, Object self, int hint,
506
504
}
507
505
length += lineLength ;
508
506
} catch (PException e ) {
509
- e .expectStopIteration (errorProfile );
507
+ e .expectStopIteration (inliningTarget , errorProfile );
510
508
break ;
511
509
}
512
510
}
0 commit comments