121121import com .oracle .graal .python .builtins .objects .slice .SliceNodes .ComputeIndices ;
122122import com .oracle .graal .python .builtins .objects .str .StringBuiltinsClinicProviders .FormatNodeClinicProviderGen ;
123123import com .oracle .graal .python .builtins .objects .str .StringBuiltinsClinicProviders .SplitNodeClinicProviderGen ;
124- import com .oracle .graal .python .builtins .objects .str .StringBuiltinsFactory .EqNodeFactory ;
125124import com .oracle .graal .python .builtins .objects .str .StringBuiltinsFactory .LtNodeFactory ;
126125import com .oracle .graal .python .builtins .objects .str .StringNodes .CastToJavaStringCheckedNode ;
127126import com .oracle .graal .python .builtins .objects .str .StringNodes .CastToTruffleStringCheckedNode ;
173172import com .oracle .truffle .api .dsl .Cached ;
174173import com .oracle .truffle .api .dsl .Cached .Exclusive ;
175174import com .oracle .truffle .api .dsl .Cached .Shared ;
175+ import com .oracle .truffle .api .dsl .GenerateCached ;
176176import com .oracle .truffle .api .dsl .GenerateInline ;
177177import com .oracle .truffle .api .dsl .GenerateNodeFactory ;
178178import com .oracle .truffle .api .dsl .GenerateUncached ;
@@ -355,20 +355,23 @@ PTuple doGeneric(Object self,
355355 }
356356 }
357357
358- abstract static class StringEqOpBaseNode extends PythonBinaryBuiltinNode {
358+ @ GenerateInline
359+ @ GenerateCached (false )
360+ abstract static class StringEqOpHelperNode extends Node {
361+
362+ abstract Object execute (Node inliningTarget , Object self , Object other , boolean negate );
363+
359364 @ Specialization
360- boolean doStrings (TruffleString self , TruffleString other ,
361- @ Shared ( "equal" ) @ Cached TruffleString .EqualNode equalNode ) {
362- return processResult ( equalNode .execute (self , other , TS_ENCODING )) ;
365+ static boolean doStrings (TruffleString self , TruffleString other , boolean negate ,
366+ @ Shared @ Cached ( inline = false ) TruffleString .EqualNode equalNode ) {
367+ return equalNode .execute (self , other , TS_ENCODING ) != negate ;
363368 }
364369
365370 @ Specialization
366- @ SuppressWarnings ("truffle-static-method" )
367- Object doGeneric (Object self , Object other ,
368- @ Bind ("this" ) Node inliningTarget ,
371+ static Object doGeneric (Node inliningTarget , Object self , Object other , boolean negate ,
369372 @ Cached CastToTruffleStringCheckedNode castSelfNode ,
370373 @ Cached CastToTruffleStringNode castOtherNode ,
371- @ Shared ( "equal" ) @ Cached TruffleString .EqualNode equalNode ,
374+ @ Shared @ Cached ( inline = false ) TruffleString .EqualNode equalNode ,
372375 @ Cached InlinedBranchProfile noStringBranch ) {
373376 TruffleString selfStr = castSelfNode .cast (inliningTarget , self , ErrorMessages .REQUIRES_STR_OBJECT_BUT_RECEIVED_P , T___EQ__ , self );
374377 TruffleString otherStr ;
@@ -378,13 +381,7 @@ Object doGeneric(Object self, Object other,
378381 noStringBranch .enter (inliningTarget );
379382 return PNotImplemented .NOT_IMPLEMENTED ;
380383 }
381- return doStrings (selfStr , otherStr , equalNode );
382- }
383-
384- @ SuppressWarnings ("unused" )
385- boolean processResult (boolean eqResult ) {
386- CompilerAsserts .neverPartOfCompilation ();
387- throw new IllegalStateException ("should not be reached" );
384+ return doStrings (selfStr , otherStr , negate , equalNode );
388385 }
389386 }
390387
@@ -440,24 +437,25 @@ static boolean doit(Object self, Object other,
440437
441438 @ Builtin (name = J___EQ__ , minNumOfPositionalArgs = 2 )
442439 @ GenerateNodeFactory
443- public abstract static class EqNode extends StringEqOpBaseNode {
444- @ Override
445- boolean processResult (boolean eqResult ) {
446- return eqResult ;
447- }
440+ public abstract static class EqNode extends PythonBinaryBuiltinNode {
448441
449- @ NeverDefault
450- public static EqNode create () {
451- return EqNodeFactory .create ();
442+ @ Specialization
443+ static Object doIt (Object self , Object other ,
444+ @ Bind ("this" ) Node inliningTarget ,
445+ @ Cached StringEqOpHelperNode stringEqOpHelperNode ) {
446+ return stringEqOpHelperNode .execute (inliningTarget , self , other , false );
452447 }
453448 }
454449
455450 @ Builtin (name = J___NE__ , minNumOfPositionalArgs = 2 )
456451 @ GenerateNodeFactory
457- public abstract static class NeNode extends StringEqOpBaseNode {
458- @ Override
459- boolean processResult (boolean eqResult ) {
460- return !eqResult ;
452+ public abstract static class NeNode extends PythonBinaryBuiltinNode {
453+
454+ @ Specialization
455+ static Object doIt (Object self , Object other ,
456+ @ Bind ("this" ) Node inliningTarget ,
457+ @ Cached StringEqOpHelperNode stringEqOpHelperNode ) {
458+ return stringEqOpHelperNode .execute (inliningTarget , self , other , true );
461459 }
462460 }
463461
0 commit comments