@@ -27,7 +27,8 @@ public abstract class LiteralCallNode extends RubyContextSourceNode {
27
27
@ Child private CopyHashAndSetRuby2KeywordsNode copyHashAndSetRuby2KeywordsNode ;
28
28
29
29
protected final boolean isSplatted ;
30
- @ CompilationFinal private boolean notRuby2KeywordsHashProfile , emptyKeywordsProfile , notEmptyKeywordsProfile ;
30
+ @ CompilationFinal private boolean lastArgIsNotHashProfile , notRuby2KeywordsHashProfile , emptyKeywordsProfile ,
31
+ notEmptyKeywordsProfile ;
31
32
32
33
protected LiteralCallNode (boolean isSplatted , ArgumentsDescriptor descriptor ) {
33
34
this .isSplatted = isSplatted ;
@@ -42,7 +43,17 @@ protected ArgumentsDescriptor getArgumentsDescriptorAndCheckRuby2KeywordsHash(Ob
42
43
if (userArgsCount > 0 ) {
43
44
final Object lastArgument = ArrayUtils .getLast (args );
44
45
assert lastArgument != null ;
45
- if (isRuby2KeywordsHash (lastArgument )) { // both branches profiled
46
+
47
+ if (!(lastArgument instanceof RubyHash )) {
48
+ if (!lastArgIsNotHashProfile ) {
49
+ CompilerDirectives .transferToInterpreterAndInvalidate ();
50
+ lastArgIsNotHashProfile = true ;
51
+ }
52
+
53
+ return descriptor ;
54
+ }
55
+
56
+ if (((RubyHash ) lastArgument ).ruby2_keywords ) { // both branches profiled
46
57
if (copyHashAndSetRuby2KeywordsNode == null ) {
47
58
CompilerDirectives .transferToInterpreterAndInvalidate ();
48
59
copyHashAndSetRuby2KeywordsNode = insert (CopyHashAndSetRuby2KeywordsNode .create ());
@@ -63,12 +74,10 @@ protected ArgumentsDescriptor getArgumentsDescriptorAndCheckRuby2KeywordsHash(Ob
63
74
return descriptor ;
64
75
}
65
76
66
- private boolean isRuby2KeywordsHash (Object lastArgument ) {
67
- return lastArgument instanceof RubyHash && ((RubyHash ) lastArgument ).ruby2_keywords ;
68
- }
69
-
70
77
// NOTE: args is either frame args or user args
71
78
protected boolean emptyKeywordArguments (Object [] args ) {
79
+ assert isSplatted || descriptor instanceof KeywordArgumentsDescriptor ;
80
+
72
81
if (((RubyHash ) ArrayUtils .getLast (args )).empty ()) {
73
82
if (!emptyKeywordsProfile ) {
74
83
CompilerDirectives .transferToInterpreterAndInvalidate ();
0 commit comments