@@ -83,117 +83,22 @@ REPLACE_BINARY_OP_IC_CALL(JSDivide, Token::DIV)
8383REPLACE_BINARY_OP_IC_CALL (JSModulus, Token::MOD)
8484#undef REPLACE_BINARY_OP_IC_CALL
8585
86-
87- // These ops are not language mode dependent; we arbitrarily pass Strength::WEAK
88- // here.
89- #define REPLACE_COMPARE_IC_CALL (op, token ) \
90- void JSGenericLowering::Lower##op(Node* node) { \
91- ReplaceWithCompareIC (node, token); \
92- }
93- REPLACE_COMPARE_IC_CALL (JSEqual, Token::EQ)
94- REPLACE_COMPARE_IC_CALL (JSNotEqual, Token::NE)
95- REPLACE_COMPARE_IC_CALL (JSStrictEqual, Token::EQ_STRICT)
96- REPLACE_COMPARE_IC_CALL (JSStrictNotEqual, Token::NE_STRICT)
97- REPLACE_COMPARE_IC_CALL (JSLessThan, Token::LT)
98- REPLACE_COMPARE_IC_CALL (JSGreaterThan, Token::GT)
99- REPLACE_COMPARE_IC_CALL (JSLessThanOrEqual, Token::LTE)
100- REPLACE_COMPARE_IC_CALL (JSGreaterThanOrEqual, Token::GTE)
101- #undef REPLACE_COMPARE_IC_CALL
102-
103-
10486#define REPLACE_RUNTIME_CALL (op, fun ) \
10587 void JSGenericLowering::Lower##op(Node* node) { \
10688 ReplaceWithRuntimeCall (node, fun); \
10789 }
90+ REPLACE_RUNTIME_CALL (JSEqual, Runtime::kEqual )
91+ REPLACE_RUNTIME_CALL (JSNotEqual, Runtime::kNotEqual )
92+ REPLACE_RUNTIME_CALL (JSStrictEqual, Runtime::kStrictEqual )
93+ REPLACE_RUNTIME_CALL (JSStrictNotEqual, Runtime::kStrictNotEqual )
94+ REPLACE_RUNTIME_CALL (JSLessThan, Runtime::kLessThan )
95+ REPLACE_RUNTIME_CALL (JSGreaterThan, Runtime::kGreaterThan )
96+ REPLACE_RUNTIME_CALL (JSLessThanOrEqual, Runtime::kLessThanOrEqual )
97+ REPLACE_RUNTIME_CALL (JSGreaterThanOrEqual, Runtime::kGreaterThanOrEqual )
10898REPLACE_RUNTIME_CALL (JSCreateWithContext, Runtime::kPushWithContext )
10999REPLACE_RUNTIME_CALL (JSCreateModuleContext, Runtime::kPushModuleContext )
110100REPLACE_RUNTIME_CALL (JSConvertReceiver, Runtime::kConvertReceiver )
111- #undef REPLACE_RUNTIME
112-
113-
114- static CallDescriptor::Flags FlagsForNode (Node* node) {
115- CallDescriptor::Flags result = CallDescriptor::kNoFlags ;
116- if (OperatorProperties::GetFrameStateInputCount (node->op ()) > 0 ) {
117- result |= CallDescriptor::kNeedsFrameState ;
118- }
119- return result;
120- }
121-
122- void JSGenericLowering::ReplaceWithCompareIC (Node* node, Token::Value token) {
123- Callable callable = CodeFactory::CompareIC (isolate (), token);
124-
125- // Create a new call node asking a CompareIC for help.
126- NodeVector inputs (zone ());
127- inputs.reserve (node->InputCount () + 1 );
128- inputs.push_back (jsgraph ()->HeapConstant (callable.code ()));
129- inputs.push_back (NodeProperties::GetValueInput (node, 0 ));
130- inputs.push_back (NodeProperties::GetValueInput (node, 1 ));
131- inputs.push_back (NodeProperties::GetContextInput (node));
132- // Some comparisons (StrictEqual) don't have an effect, control or frame
133- // state inputs, so handle those cases here.
134- if (OperatorProperties::GetFrameStateInputCount (node->op ()) > 0 ) {
135- inputs.push_back (NodeProperties::GetFrameStateInput (node, 0 ));
136- }
137- Node* effect = (node->op ()->EffectInputCount () > 0 )
138- ? NodeProperties::GetEffectInput (node)
139- : graph ()->start ();
140- inputs.push_back (effect);
141- Node* control = (node->op ()->ControlInputCount () > 0 )
142- ? NodeProperties::GetControlInput (node)
143- : graph ()->start ();
144- inputs.push_back (control);
145- CallDescriptor* desc_compare = Linkage::GetStubCallDescriptor (
146- isolate (), zone (), callable.descriptor (), 0 ,
147- CallDescriptor::kPatchableCallSiteWithNop | FlagsForNode (node),
148- Operator::kNoProperties , MachineType::IntPtr ());
149- Node* compare =
150- graph ()->NewNode (common ()->Call (desc_compare),
151- static_cast <int >(inputs.size ()), &inputs.front ());
152-
153- // Decide how the return value from the above CompareIC can be converted into
154- // a JavaScript boolean oddball depending on the given token.
155- Node* false_value = jsgraph ()->FalseConstant ();
156- Node* true_value = jsgraph ()->TrueConstant ();
157- const Operator* op = nullptr ;
158- switch (token) {
159- case Token::EQ: // a == 0
160- case Token::EQ_STRICT:
161- op = machine ()->WordEqual ();
162- break ;
163- case Token::NE: // a != 0 becomes !(a == 0)
164- case Token::NE_STRICT:
165- op = machine ()->WordEqual ();
166- std::swap (true_value, false_value);
167- break ;
168- case Token::LT: // a < 0
169- op = machine ()->IntLessThan ();
170- break ;
171- case Token::GT: // a > 0 becomes !(a <= 0)
172- op = machine ()->IntLessThanOrEqual ();
173- std::swap (true_value, false_value);
174- break ;
175- case Token::LTE: // a <= 0
176- op = machine ()->IntLessThanOrEqual ();
177- break ;
178- case Token::GTE: // a >= 0 becomes !(a < 0)
179- op = machine ()->IntLessThan ();
180- std::swap (true_value, false_value);
181- break ;
182- default :
183- UNREACHABLE ();
184- }
185- Node* booleanize = graph ()->NewNode (op, compare, jsgraph ()->ZeroConstant ());
186-
187- // Finally patch the original node to select a boolean.
188- NodeProperties::ReplaceUses (node, node, compare, compare, compare);
189- node->TrimInputCount (3 );
190- node->ReplaceInput (0 , booleanize);
191- node->ReplaceInput (1 , true_value);
192- node->ReplaceInput (2 , false_value);
193- NodeProperties::ChangeOp (node,
194- common ()->Select (MachineRepresentation::kTagged ));
195- }
196-
101+ #undef REPLACE_RUNTIME_CALL
197102
198103void JSGenericLowering::ReplaceWithStubCall (Node* node, Callable callable,
199104 CallDescriptor::Flags flags) {
@@ -209,11 +114,12 @@ void JSGenericLowering::ReplaceWithStubCall(Node* node, Callable callable,
209114void JSGenericLowering::ReplaceWithRuntimeCall (Node* node,
210115 Runtime::FunctionId f,
211116 int nargs_override) {
117+ CallDescriptor::Flags flags = AdjustFrameStatesForCall (node);
212118 Operator::Properties properties = node->op ()->properties ();
213119 const Runtime::Function* fun = Runtime::FunctionForId (f);
214120 int nargs = (nargs_override < 0 ) ? fun->nargs : nargs_override;
215- CallDescriptor* desc = Linkage::GetRuntimeCallDescriptor (
216- zone (), f, nargs, properties, CallDescriptor:: kNeedsFrameState );
121+ CallDescriptor* desc =
122+ Linkage::GetRuntimeCallDescriptor ( zone (), f, nargs, properties, flags );
217123 Node* ref = jsgraph ()->ExternalConstant (ExternalReference (f, isolate ()));
218124 Node* arity = jsgraph ()->Int32Constant (nargs);
219125 node->InsertInput (zone (), 0 , jsgraph ()->CEntryStubConstant (fun->result_size ));
0 commit comments