@@ -2618,78 +2618,75 @@ abstract static class InputNode extends PythonUnaryBuiltinNode {
26182618 static Object input (VirtualFrame frame , Object prompt ,
26192619 @ Bind Node inliningTarget ,
26202620 @ Bind PythonContext context ,
2621- @ Cached SysModuleBuiltins .AuditNode auditNode ,
2622- @ Cached PyObjectCallMethodObjArgs callMethod ,
2623- @ Cached PyObjectStrAsObjectNode strNode ,
2624- @ Cached PyObjectLookupAttr lookupAttr ,
2625- @ Cached PyBytesCheckNode bytesCheck ,
2626- @ Cached PyUnicodeCheckNode unicodeCheck ,
2627- @ Cached CastToTruffleStringNode castToTruffleStringNode ,
2628- @ Cached TruffleString .CodePointLengthNode codePointLengthNode ,
2629- @ Cached TruffleString .CodePointAtIndexNode codePointAtIndexNode ,
2630- @ Cached TruffleString .SubstringNode substringNode ,
2631- @ Cached BytesNodes .ToBytesNode toBytesNode ,
2632- @ Cached PRaiseNode raiseLostNode ,
2633- @ Cached PRaiseNode raiseEOFNode ,
2634- @ Cached PRaiseNode raiseWrongType ) {
2621+ @ Cached ("createFor($node)" ) IndirectCallData indirectCallData ) {
2622+ Object savedState = IndirectCallContext .enter (frame , inliningTarget , indirectCallData );
2623+ try {
2624+ return doInput (prompt , inliningTarget , context );
2625+ } finally {
2626+ IndirectCallContext .exit (frame , inliningTarget , indirectCallData , savedState );
2627+ }
2628+ }
2629+
2630+ @ TruffleBoundary
2631+ private static Object doInput (Object prompt , Node inliningTarget , PythonContext context ) {
26352632 PythonModule sysModule = context .getSysModule ();
2636- Object stdin = lookupAttr . execute ( frame , inliningTarget , sysModule , T_STDIN );
2637- Object stdout = lookupAttr . execute ( frame , inliningTarget , sysModule , T_STDOUT );
2638- Object stderr = lookupAttr . execute ( frame , inliningTarget , sysModule , T_STDERR );
2633+ Object stdin = PyObjectLookupAttr . executeUncached ( sysModule , T_STDIN );
2634+ Object stdout = PyObjectLookupAttr . executeUncached ( sysModule , T_STDOUT );
2635+ Object stderr = PyObjectLookupAttr . executeUncached ( sysModule , T_STDERR );
26392636
26402637 if (stdin instanceof PNone ) {
2641- throw raiseLostNode . raise (inliningTarget , RuntimeError , ErrorMessages .INPUT_LOST_SYS_S , T_STDIN );
2638+ throw PRaiseNode . raiseStatic (inliningTarget , RuntimeError , ErrorMessages .INPUT_LOST_SYS_S , T_STDIN );
26422639 }
26432640 if (stdout instanceof PNone ) {
2644- throw raiseLostNode . raise (inliningTarget , RuntimeError , ErrorMessages .INPUT_LOST_SYS_S , T_STDOUT );
2641+ throw PRaiseNode . raiseStatic (inliningTarget , RuntimeError , ErrorMessages .INPUT_LOST_SYS_S , T_STDOUT );
26452642 }
26462643 if (stderr instanceof PNone ) {
2647- throw raiseLostNode . raise (inliningTarget , RuntimeError , ErrorMessages .INPUT_LOST_SYS_S , T_STDERR );
2644+ throw PRaiseNode . raiseStatic (inliningTarget , RuntimeError , ErrorMessages .INPUT_LOST_SYS_S , T_STDERR );
26482645 }
26492646
2650- auditNode . audit ( inliningTarget , "builtins.input" , prompt != NO_VALUE ? prompt : NONE );
2647+ SysModuleBuiltins . AuditNode . auditUncached ( "builtins.input" , prompt != NO_VALUE ? prompt : NONE );
26512648
26522649 try {
2653- callMethod . execute ( frame , inliningTarget , stderr , T_FLUSH );
2650+ PyObjectCallMethodObjArgs . executeUncached ( stderr , T_FLUSH );
26542651 } catch (AbstractTruffleException e ) {
26552652 // Ignore
26562653 }
26572654
26582655 if (!(prompt instanceof PNone )) {
2659- Object promptStr = strNode . execute ( frame , inliningTarget , prompt );
2660- callMethod . execute ( frame , inliningTarget , stdout , T_WRITE , promptStr );
2656+ Object promptStr = PyObjectStrAsObjectNode . executeUncached ( prompt );
2657+ PyObjectCallMethodObjArgs . executeUncached ( stdout , T_WRITE , promptStr );
26612658 try {
2662- callMethod . execute ( frame , inliningTarget , stdout , T_FLUSH );
2659+ PyObjectCallMethodObjArgs . executeUncached ( stdout , T_FLUSH );
26632660 } catch (AbstractTruffleException e ) {
26642661 // Ignore
26652662 }
26662663 }
26672664
2668- Object line = callMethod . execute ( frame , inliningTarget , stdin , T_READLINE );
2669- if (unicodeCheck . execute ( inliningTarget , line )) {
2670- TruffleString strLine = castToTruffleStringNode . castKnownString ( inliningTarget , line );
2671- int len = codePointLengthNode . execute ( strLine , TS_ENCODING );
2665+ Object line = PyObjectCallMethodObjArgs . executeUncached ( stdin , T_READLINE );
2666+ if (PyUnicodeCheckNode . executeUncached ( line )) {
2667+ TruffleString strLine = CastToTruffleStringNode . castKnownStringUncached ( line );
2668+ int len = strLine . codePointLengthUncached ( TS_ENCODING );
26722669 if (len == 0 ) {
2673- throw raiseEOFNode . raise (inliningTarget , EOFError , ErrorMessages .EOF_WHEN_READING_A_LINE );
2670+ throw PRaiseNode . raiseStatic (inliningTarget , EOFError , ErrorMessages .EOF_WHEN_READING_A_LINE );
26742671 }
2675- int lastChar = codePointAtIndexNode . execute ( strLine , len - 1 , TS_ENCODING );
2672+ int lastChar = strLine . codePointAtIndexUncached ( len - 1 , TS_ENCODING );
26762673 if (lastChar == '\n' ) {
2677- strLine = substringNode . execute ( strLine , 0 , len - 1 , TS_ENCODING , false );
2674+ strLine = strLine . substringUncached ( 0 , len - 1 , TS_ENCODING , false );
26782675 }
26792676 return strLine ;
2680- } else if (bytesCheck . execute ( inliningTarget , line )) {
2681- byte [] bytesLine = toBytesNode . execute ( frame , line );
2677+ } else if (PyBytesCheckNode . executeUncached ( line )) {
2678+ byte [] bytesLine = PythonBufferAccessLibrary . getUncached (). getCopiedByteArray ( BytesNodes . GetBytesStorage . executeUncached ( line ) );
26822679 if (bytesLine .length == 0 ) {
2683- throw raiseEOFNode . raise (inliningTarget , EOFError , ErrorMessages .EOF_WHEN_READING_A_LINE );
2680+ throw PRaiseNode . raiseStatic (inliningTarget , EOFError , ErrorMessages .EOF_WHEN_READING_A_LINE );
26842681 }
2685- PythonLanguage language = context .getLanguage (inliningTarget );
2682+ PythonLanguage language = context .getLanguage ();
26862683 if (bytesLine [bytesLine .length - 1 ] == '\n' ) {
26872684 return PFactory .createBytes (language , bytesLine , bytesLine .length - 1 );
26882685 } else {
26892686 return PFactory .createBytes (language , bytesLine );
26902687 }
26912688 } else {
2692- throw raiseWrongType . raise (inliningTarget , TypeError , ErrorMessages .OBJECT_READLINE_RETURNED_NON_STRING );
2689+ throw PRaiseNode . raiseStatic (inliningTarget , TypeError , ErrorMessages .OBJECT_READLINE_RETURNED_NON_STRING );
26932690 }
26942691 }
26952692 }
0 commit comments