OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/code-factory.h" | 5 #include "src/code-factory.h" |
6 #include "src/code-stubs.h" | 6 #include "src/code-stubs.h" |
7 #include "src/compiler/common-operator.h" | 7 #include "src/compiler/common-operator.h" |
8 #include "src/compiler/js-generic-lowering.h" | 8 #include "src/compiler/js-generic-lowering.h" |
9 #include "src/compiler/js-graph.h" | 9 #include "src/compiler/js-graph.h" |
10 #include "src/compiler/machine-operator.h" | 10 #include "src/compiler/machine-operator.h" |
11 #include "src/compiler/node-matchers.h" | 11 #include "src/compiler/node-matchers.h" |
12 #include "src/compiler/node-properties.h" | 12 #include "src/compiler/node-properties.h" |
13 #include "src/compiler/operator-properties.h" | 13 #include "src/compiler/operator-properties.h" |
14 #include "src/unique.h" | 14 #include "src/unique.h" |
15 | 15 |
16 namespace v8 { | 16 namespace v8 { |
17 namespace internal { | 17 namespace internal { |
18 namespace compiler { | 18 namespace compiler { |
19 | 19 |
| 20 static CallDescriptor::Flags AdjustFrameStatesForCall(Node* node) { |
| 21 int count = OperatorProperties::GetFrameStateInputCount(node->op()); |
| 22 if (count > 1) { |
| 23 int index = NodeProperties::FirstFrameStateIndex(node) + 1; |
| 24 do { |
| 25 node->RemoveInput(index); |
| 26 } while (--count > 1); |
| 27 } |
| 28 return count > 0 ? CallDescriptor::kNeedsFrameState |
| 29 : CallDescriptor::kNoFlags; |
| 30 } |
| 31 |
| 32 |
20 JSGenericLowering::JSGenericLowering(bool is_typing_enabled, JSGraph* jsgraph) | 33 JSGenericLowering::JSGenericLowering(bool is_typing_enabled, JSGraph* jsgraph) |
21 : is_typing_enabled_(is_typing_enabled), jsgraph_(jsgraph) {} | 34 : is_typing_enabled_(is_typing_enabled), jsgraph_(jsgraph) {} |
22 | 35 |
23 | 36 |
24 JSGenericLowering::~JSGenericLowering() {} | 37 JSGenericLowering::~JSGenericLowering() {} |
25 | 38 |
26 | 39 |
27 Reduction JSGenericLowering::Reduce(Node* node) { | 40 Reduction JSGenericLowering::Reduce(Node* node) { |
28 switch (node->opcode()) { | 41 switch (node->opcode()) { |
29 #define DECLARE_CASE(x) \ | 42 #define DECLARE_CASE(x) \ |
(...skipping 15 matching lines...) Expand all Loading... |
45 } | 58 } |
46 // Fall-through. | 59 // Fall-through. |
47 default: | 60 default: |
48 // Nothing to see. | 61 // Nothing to see. |
49 return NoChange(); | 62 return NoChange(); |
50 } | 63 } |
51 return Changed(node); | 64 return Changed(node); |
52 } | 65 } |
53 | 66 |
54 | 67 |
55 #define REPLACE_BINARY_OP_IC_CALL(op, token) \ | 68 #define REPLACE_BINARY_OP_IC_CALL(op, token) \ |
56 void JSGenericLowering::Lower##op(Node* node) { \ | 69 void JSGenericLowering::Lower##op(Node* node) { \ |
57 ReplaceWithStubCall(node, CodeFactory::BinaryOpIC(isolate(), token, \ | 70 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); \ |
58 OpParameter<LanguageMode>(node)), \ | 71 ReplaceWithStubCall( \ |
59 CallDescriptor::kPatchableCallSiteWithNop); \ | 72 node, CodeFactory::BinaryOpIC(isolate(), token, \ |
| 73 OpParameter<LanguageMode>(node)), \ |
| 74 CallDescriptor::kPatchableCallSiteWithNop | flags); \ |
60 } | 75 } |
61 REPLACE_BINARY_OP_IC_CALL(JSBitwiseOr, Token::BIT_OR) | 76 REPLACE_BINARY_OP_IC_CALL(JSBitwiseOr, Token::BIT_OR) |
62 REPLACE_BINARY_OP_IC_CALL(JSBitwiseXor, Token::BIT_XOR) | 77 REPLACE_BINARY_OP_IC_CALL(JSBitwiseXor, Token::BIT_XOR) |
63 REPLACE_BINARY_OP_IC_CALL(JSBitwiseAnd, Token::BIT_AND) | 78 REPLACE_BINARY_OP_IC_CALL(JSBitwiseAnd, Token::BIT_AND) |
64 REPLACE_BINARY_OP_IC_CALL(JSShiftLeft, Token::SHL) | 79 REPLACE_BINARY_OP_IC_CALL(JSShiftLeft, Token::SHL) |
65 REPLACE_BINARY_OP_IC_CALL(JSShiftRight, Token::SAR) | 80 REPLACE_BINARY_OP_IC_CALL(JSShiftRight, Token::SAR) |
66 REPLACE_BINARY_OP_IC_CALL(JSShiftRightLogical, Token::SHR) | 81 REPLACE_BINARY_OP_IC_CALL(JSShiftRightLogical, Token::SHR) |
67 REPLACE_BINARY_OP_IC_CALL(JSAdd, Token::ADD) | 82 REPLACE_BINARY_OP_IC_CALL(JSAdd, Token::ADD) |
68 REPLACE_BINARY_OP_IC_CALL(JSSubtract, Token::SUB) | 83 REPLACE_BINARY_OP_IC_CALL(JSSubtract, Token::SUB) |
69 REPLACE_BINARY_OP_IC_CALL(JSMultiply, Token::MUL) | 84 REPLACE_BINARY_OP_IC_CALL(JSMultiply, Token::MUL) |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 if (OperatorProperties::GetFrameStateInputCount(node->op()) > 0) { | 126 if (OperatorProperties::GetFrameStateInputCount(node->op()) > 0) { |
112 result |= CallDescriptor::kNeedsFrameState; | 127 result |= CallDescriptor::kNeedsFrameState; |
113 } | 128 } |
114 return result; | 129 return result; |
115 } | 130 } |
116 | 131 |
117 | 132 |
118 void JSGenericLowering::ReplaceWithCompareIC(Node* node, Token::Value token) { | 133 void JSGenericLowering::ReplaceWithCompareIC(Node* node, Token::Value token) { |
119 Callable callable = | 134 Callable callable = |
120 CodeFactory::CompareIC(isolate(), token, OpParameter<LanguageMode>(node)); | 135 CodeFactory::CompareIC(isolate(), token, OpParameter<LanguageMode>(node)); |
121 CallDescriptor* desc_compare = Linkage::GetStubCallDescriptor( | |
122 isolate(), zone(), callable.descriptor(), 0, | |
123 CallDescriptor::kPatchableCallSiteWithNop | FlagsForNode(node), | |
124 Operator::kNoProperties, kMachIntPtr); | |
125 | 136 |
126 // Create a new call node asking a CompareIC for help. | 137 // Create a new call node asking a CompareIC for help. |
127 NodeVector inputs(zone()); | 138 NodeVector inputs(zone()); |
128 inputs.reserve(node->InputCount() + 1); | 139 inputs.reserve(node->InputCount() + 1); |
129 inputs.push_back(jsgraph()->HeapConstant(callable.code())); | 140 inputs.push_back(jsgraph()->HeapConstant(callable.code())); |
130 inputs.push_back(NodeProperties::GetValueInput(node, 0)); | 141 inputs.push_back(NodeProperties::GetValueInput(node, 0)); |
131 inputs.push_back(NodeProperties::GetValueInput(node, 1)); | 142 inputs.push_back(NodeProperties::GetValueInput(node, 1)); |
132 inputs.push_back(NodeProperties::GetContextInput(node)); | 143 inputs.push_back(NodeProperties::GetContextInput(node)); |
133 if (node->op()->HasProperty(Operator::kPure)) { | 144 if (node->op()->HasProperty(Operator::kPure)) { |
134 // A pure (strict) comparison doesn't have an effect, control or frame | 145 // A pure (strict) comparison doesn't have an effect, control or frame |
135 // state. But for the graph, we need to add control and effect inputs. | 146 // state. But for the graph, we need to add control and effect inputs. |
136 DCHECK(OperatorProperties::GetFrameStateInputCount(node->op()) == 0); | 147 DCHECK(OperatorProperties::GetFrameStateInputCount(node->op()) == 0); |
137 inputs.push_back(graph()->start()); | 148 inputs.push_back(graph()->start()); |
138 inputs.push_back(graph()->start()); | 149 inputs.push_back(graph()->start()); |
139 } else { | 150 } else { |
140 inputs.push_back(NodeProperties::GetFrameStateInput(node, 0)); | 151 inputs.push_back(NodeProperties::GetFrameStateInput(node, 0)); |
141 inputs.push_back(NodeProperties::GetEffectInput(node)); | 152 inputs.push_back(NodeProperties::GetEffectInput(node)); |
142 inputs.push_back(NodeProperties::GetControlInput(node)); | 153 inputs.push_back(NodeProperties::GetControlInput(node)); |
143 } | 154 } |
| 155 CallDescriptor* desc_compare = Linkage::GetStubCallDescriptor( |
| 156 isolate(), zone(), callable.descriptor(), 0, |
| 157 CallDescriptor::kPatchableCallSiteWithNop | FlagsForNode(node), |
| 158 Operator::kNoProperties, kMachIntPtr); |
144 Node* compare = | 159 Node* compare = |
145 graph()->NewNode(common()->Call(desc_compare), | 160 graph()->NewNode(common()->Call(desc_compare), |
146 static_cast<int>(inputs.size()), &inputs.front()); | 161 static_cast<int>(inputs.size()), &inputs.front()); |
147 | 162 |
148 // Decide how the return value from the above CompareIC can be converted into | 163 // Decide how the return value from the above CompareIC can be converted into |
149 // a JavaScript boolean oddball depending on the given token. | 164 // a JavaScript boolean oddball depending on the given token. |
150 Node* false_value = jsgraph()->FalseConstant(); | 165 Node* false_value = jsgraph()->FalseConstant(); |
151 Node* true_value = jsgraph()->TrueConstant(); | 166 Node* true_value = jsgraph()->TrueConstant(); |
152 const Operator* op = nullptr; | 167 const Operator* op = nullptr; |
153 switch (token) { | 168 switch (token) { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 node->TrimInputCount(3); | 202 node->TrimInputCount(3); |
188 node->ReplaceInput(0, booleanize); | 203 node->ReplaceInput(0, booleanize); |
189 node->ReplaceInput(1, true_value); | 204 node->ReplaceInput(1, true_value); |
190 node->ReplaceInput(2, false_value); | 205 node->ReplaceInput(2, false_value); |
191 node->set_op(common()->Select(kMachAnyTagged)); | 206 node->set_op(common()->Select(kMachAnyTagged)); |
192 } | 207 } |
193 | 208 |
194 | 209 |
195 void JSGenericLowering::ReplaceWithStubCall(Node* node, Callable callable, | 210 void JSGenericLowering::ReplaceWithStubCall(Node* node, Callable callable, |
196 CallDescriptor::Flags flags) { | 211 CallDescriptor::Flags flags) { |
197 Operator::Properties properties = node->op()->properties(); | 212 const Operator* old_op = node->op(); |
198 flags |= FlagsForNode(node); | 213 Operator::Properties properties = old_op->properties(); |
199 CallDescriptor* desc = Linkage::GetStubCallDescriptor( | 214 CallDescriptor* desc = Linkage::GetStubCallDescriptor( |
200 isolate(), zone(), callable.descriptor(), 0, flags, properties); | 215 isolate(), zone(), callable.descriptor(), 0, flags, properties); |
201 const Operator* new_op = common()->Call(desc); | 216 const Operator* new_op = common()->Call(desc); |
202 | 217 |
203 // Take care of frame states. | |
204 int old_frame_state_count = | |
205 OperatorProperties::GetFrameStateInputCount(node->op()); | |
206 int new_frame_state_count = | |
207 (flags & CallDescriptor::kNeedsFrameState) ? 1 : 0; | |
208 DCHECK_GE(old_frame_state_count, new_frame_state_count); | |
209 // If there are extra frame states, get rid of them. | |
210 for (int i = new_frame_state_count; i < old_frame_state_count; i++) { | |
211 node->RemoveInput(NodeProperties::FirstFrameStateIndex(node) + | |
212 new_frame_state_count); | |
213 } | |
214 | |
215 Node* stub_code = jsgraph()->HeapConstant(callable.code()); | 218 Node* stub_code = jsgraph()->HeapConstant(callable.code()); |
216 node->InsertInput(zone(), 0, stub_code); | 219 node->InsertInput(zone(), 0, stub_code); |
217 node->set_op(new_op); | 220 node->set_op(new_op); |
| 221 |
| 222 #if 0 && DEBUG |
| 223 // Check for at most one framestate and that it's at the right position. |
| 224 int where = -1; |
| 225 for (int index = 0; index < node->InputCount(); index++) { |
| 226 if (node->InputAt(index)->opcode() == IrOpcode::kFrameState) { |
| 227 if (where >= 0) { |
| 228 V8_Fatal(__FILE__, __LINE__, |
| 229 "node #%d:%s already has a framestate at index %d", |
| 230 node->id(), node->op()->mnemonic(), where); |
| 231 } |
| 232 where = index; |
| 233 DCHECK_EQ(NodeProperties::FirstFrameStateIndex(node), where); |
| 234 DCHECK(flags & CallDescriptor::kNeedsFrameState); |
| 235 } |
| 236 } |
| 237 if (flags & CallDescriptor::kNeedsFrameState) { |
| 238 DCHECK_GE(where, 0); // should have found a frame state. |
| 239 } |
| 240 #endif |
218 } | 241 } |
219 | 242 |
220 | 243 |
221 void JSGenericLowering::ReplaceWithBuiltinCall(Node* node, | 244 void JSGenericLowering::ReplaceWithBuiltinCall(Node* node, |
222 Builtins::JavaScript id, | 245 Builtins::JavaScript id, |
223 int nargs) { | 246 int nargs) { |
| 247 Node* context_input = NodeProperties::GetContextInput(node); |
| 248 Node* effect_input = NodeProperties::GetEffectInput(node); |
| 249 |
| 250 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); |
224 Operator::Properties properties = node->op()->properties(); | 251 Operator::Properties properties = node->op()->properties(); |
225 Callable callable = | 252 Callable callable = |
226 CodeFactory::CallFunction(isolate(), nargs - 1, NO_CALL_FUNCTION_FLAGS); | 253 CodeFactory::CallFunction(isolate(), nargs - 1, NO_CALL_FUNCTION_FLAGS); |
227 CallDescriptor* desc = | 254 CallDescriptor* desc = Linkage::GetStubCallDescriptor( |
228 Linkage::GetStubCallDescriptor(isolate(), zone(), callable.descriptor(), | 255 isolate(), zone(), callable.descriptor(), nargs, flags, properties); |
229 nargs, FlagsForNode(node), properties); | 256 Node* global_object = |
230 Node* global_object = graph()->NewNode( | 257 graph()->NewNode(machine()->Load(kMachAnyTagged), context_input, |
231 machine()->Load(kMachAnyTagged), NodeProperties::GetContextInput(node), | 258 jsgraph()->IntPtrConstant( |
232 jsgraph()->IntPtrConstant( | 259 Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX)), |
233 Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX)), | 260 effect_input, graph()->start()); |
234 NodeProperties::GetEffectInput(node), graph()->start()); | |
235 Node* builtins_object = graph()->NewNode( | 261 Node* builtins_object = graph()->NewNode( |
236 machine()->Load(kMachAnyTagged), global_object, | 262 machine()->Load(kMachAnyTagged), global_object, |
237 jsgraph()->IntPtrConstant(GlobalObject::kBuiltinsOffset - kHeapObjectTag), | 263 jsgraph()->IntPtrConstant(GlobalObject::kBuiltinsOffset - kHeapObjectTag), |
238 NodeProperties::GetEffectInput(node), graph()->start()); | 264 effect_input, graph()->start()); |
239 Node* function = graph()->NewNode( | 265 Node* function = graph()->NewNode( |
240 machine()->Load(kMachAnyTagged), builtins_object, | 266 machine()->Load(kMachAnyTagged), builtins_object, |
241 jsgraph()->IntPtrConstant(JSBuiltinsObject::OffsetOfFunctionWithId(id) - | 267 jsgraph()->IntPtrConstant(JSBuiltinsObject::OffsetOfFunctionWithId(id) - |
242 kHeapObjectTag), | 268 kHeapObjectTag), |
243 NodeProperties::GetEffectInput(node), graph()->start()); | 269 effect_input, graph()->start()); |
244 Node* stub_code = jsgraph()->HeapConstant(callable.code()); | 270 Node* stub_code = jsgraph()->HeapConstant(callable.code()); |
245 node->InsertInput(zone(), 0, stub_code); | 271 node->InsertInput(zone(), 0, stub_code); |
246 node->InsertInput(zone(), 1, function); | 272 node->InsertInput(zone(), 1, function); |
247 node->set_op(common()->Call(desc)); | 273 node->set_op(common()->Call(desc)); |
248 } | 274 } |
249 | 275 |
250 | 276 |
251 void JSGenericLowering::ReplaceWithRuntimeCall(Node* node, | 277 void JSGenericLowering::ReplaceWithRuntimeCall(Node* node, |
252 Runtime::FunctionId f, | 278 Runtime::FunctionId f, |
253 int nargs_override) { | 279 int nargs_override) { |
254 Operator::Properties properties = node->op()->properties(); | 280 Operator::Properties properties = node->op()->properties(); |
255 const Runtime::Function* fun = Runtime::FunctionForId(f); | 281 const Runtime::Function* fun = Runtime::FunctionForId(f); |
256 int nargs = (nargs_override < 0) ? fun->nargs : nargs_override; | 282 int nargs = (nargs_override < 0) ? fun->nargs : nargs_override; |
257 CallDescriptor* desc = | 283 CallDescriptor* desc = |
258 Linkage::GetRuntimeCallDescriptor(zone(), f, nargs, properties); | 284 Linkage::GetRuntimeCallDescriptor(zone(), f, nargs, properties); |
259 Node* ref = jsgraph()->ExternalConstant(ExternalReference(f, isolate())); | 285 Node* ref = jsgraph()->ExternalConstant(ExternalReference(f, isolate())); |
260 Node* arity = jsgraph()->Int32Constant(nargs); | 286 Node* arity = jsgraph()->Int32Constant(nargs); |
261 node->InsertInput(zone(), 0, jsgraph()->CEntryStubConstant(fun->result_size)); | 287 node->InsertInput(zone(), 0, jsgraph()->CEntryStubConstant(fun->result_size)); |
262 node->InsertInput(zone(), nargs + 1, ref); | 288 node->InsertInput(zone(), nargs + 1, ref); |
263 node->InsertInput(zone(), nargs + 2, arity); | 289 node->InsertInput(zone(), nargs + 2, arity); |
264 node->set_op(common()->Call(desc)); | 290 node->set_op(common()->Call(desc)); |
265 } | 291 } |
266 | 292 |
267 | 293 |
268 void JSGenericLowering::LowerJSUnaryNot(Node* node) { | 294 void JSGenericLowering::LowerJSUnaryNot(Node* node) { |
269 Callable callable = CodeFactory::ToBoolean( | 295 Callable callable = CodeFactory::ToBoolean( |
270 isolate(), ToBooleanStub::RESULT_AS_INVERSE_ODDBALL); | 296 isolate(), ToBooleanStub::RESULT_AS_INVERSE_ODDBALL); |
271 ReplaceWithStubCall(node, callable, CallDescriptor::kPatchableCallSite); | 297 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); |
| 298 ReplaceWithStubCall(node, callable, |
| 299 CallDescriptor::kPatchableCallSite | flags); |
272 } | 300 } |
273 | 301 |
274 | 302 |
275 void JSGenericLowering::LowerJSTypeOf(Node* node) { | 303 void JSGenericLowering::LowerJSTypeOf(Node* node) { |
276 Callable callable = CodeFactory::Typeof(isolate()); | 304 Callable callable = CodeFactory::Typeof(isolate()); |
277 ReplaceWithStubCall(node, callable, CallDescriptor::kNoFlags); | 305 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); |
| 306 ReplaceWithStubCall(node, callable, flags); |
278 } | 307 } |
279 | 308 |
280 | 309 |
281 void JSGenericLowering::LowerJSToBoolean(Node* node) { | 310 void JSGenericLowering::LowerJSToBoolean(Node* node) { |
282 Callable callable = | 311 Callable callable = |
283 CodeFactory::ToBoolean(isolate(), ToBooleanStub::RESULT_AS_ODDBALL); | 312 CodeFactory::ToBoolean(isolate(), ToBooleanStub::RESULT_AS_ODDBALL); |
284 ReplaceWithStubCall(node, callable, CallDescriptor::kPatchableCallSite); | 313 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); |
| 314 ReplaceWithStubCall(node, callable, |
| 315 CallDescriptor::kPatchableCallSite | flags); |
285 } | 316 } |
286 | 317 |
287 | 318 |
288 void JSGenericLowering::LowerJSToNumber(Node* node) { | 319 void JSGenericLowering::LowerJSToNumber(Node* node) { |
289 Callable callable = CodeFactory::ToNumber(isolate()); | 320 Callable callable = CodeFactory::ToNumber(isolate()); |
290 ReplaceWithStubCall(node, callable, FlagsForNode(node)); | 321 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); |
| 322 ReplaceWithStubCall(node, callable, flags); |
291 } | 323 } |
292 | 324 |
293 | 325 |
294 void JSGenericLowering::LowerJSToString(Node* node) { | 326 void JSGenericLowering::LowerJSToString(Node* node) { |
295 ReplaceWithBuiltinCall(node, Builtins::TO_STRING, 1); | 327 ReplaceWithBuiltinCall(node, Builtins::TO_STRING, 1); |
296 } | 328 } |
297 | 329 |
298 | 330 |
299 void JSGenericLowering::LowerJSToName(Node* node) { | 331 void JSGenericLowering::LowerJSToName(Node* node) { |
300 ReplaceWithBuiltinCall(node, Builtins::TO_NAME, 1); | 332 ReplaceWithBuiltinCall(node, Builtins::TO_NAME, 1); |
301 } | 333 } |
302 | 334 |
303 | 335 |
304 void JSGenericLowering::LowerJSToObject(Node* node) { | 336 void JSGenericLowering::LowerJSToObject(Node* node) { |
305 ReplaceWithBuiltinCall(node, Builtins::TO_OBJECT, 1); | 337 ReplaceWithBuiltinCall(node, Builtins::TO_OBJECT, 1); |
306 } | 338 } |
307 | 339 |
308 | 340 |
309 void JSGenericLowering::LowerJSLoadProperty(Node* node) { | 341 void JSGenericLowering::LowerJSLoadProperty(Node* node) { |
| 342 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); |
310 const LoadPropertyParameters& p = LoadPropertyParametersOf(node->op()); | 343 const LoadPropertyParameters& p = LoadPropertyParametersOf(node->op()); |
311 Callable callable = | 344 Callable callable = |
312 CodeFactory::KeyedLoadICInOptimizedCode(isolate(), UNINITIALIZED); | 345 CodeFactory::KeyedLoadICInOptimizedCode(isolate(), UNINITIALIZED); |
313 if (FLAG_vector_ics) { | 346 if (FLAG_vector_ics) { |
314 node->InsertInput(zone(), 2, jsgraph()->SmiConstant(p.feedback().index())); | 347 node->InsertInput(zone(), 2, jsgraph()->SmiConstant(p.feedback().index())); |
315 node->InsertInput(zone(), 3, | 348 node->InsertInput(zone(), 3, |
316 jsgraph()->HeapConstant(p.feedback().vector())); | 349 jsgraph()->HeapConstant(p.feedback().vector())); |
317 } | 350 } |
318 ReplaceWithStubCall(node, callable, CallDescriptor::kPatchableCallSite); | 351 ReplaceWithStubCall(node, callable, |
| 352 CallDescriptor::kPatchableCallSite | flags); |
319 } | 353 } |
320 | 354 |
321 | 355 |
322 void JSGenericLowering::LowerJSLoadNamed(Node* node) { | 356 void JSGenericLowering::LowerJSLoadNamed(Node* node) { |
| 357 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); |
323 const LoadNamedParameters& p = LoadNamedParametersOf(node->op()); | 358 const LoadNamedParameters& p = LoadNamedParametersOf(node->op()); |
324 Callable callable = | 359 Callable callable = |
325 p.load_ic() == NAMED | 360 p.load_ic() == NAMED |
326 ? CodeFactory::LoadICInOptimizedCode(isolate(), p.contextual_mode(), | 361 ? CodeFactory::LoadICInOptimizedCode(isolate(), p.contextual_mode(), |
327 UNINITIALIZED) | 362 UNINITIALIZED) |
328 : CodeFactory::KeyedLoadICInOptimizedCode(isolate(), UNINITIALIZED); | 363 : CodeFactory::KeyedLoadICInOptimizedCode(isolate(), UNINITIALIZED); |
329 node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.name())); | 364 node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.name())); |
330 if (FLAG_vector_ics) { | 365 if (FLAG_vector_ics) { |
331 node->InsertInput(zone(), 2, jsgraph()->SmiConstant(p.feedback().index())); | 366 node->InsertInput(zone(), 2, jsgraph()->SmiConstant(p.feedback().index())); |
332 node->InsertInput(zone(), 3, | 367 node->InsertInput(zone(), 3, |
333 jsgraph()->HeapConstant(p.feedback().vector())); | 368 jsgraph()->HeapConstant(p.feedback().vector())); |
334 } | 369 } |
335 ReplaceWithStubCall(node, callable, CallDescriptor::kPatchableCallSite); | 370 ReplaceWithStubCall(node, callable, |
| 371 CallDescriptor::kPatchableCallSite | flags); |
336 } | 372 } |
337 | 373 |
338 | 374 |
339 void JSGenericLowering::LowerJSStoreProperty(Node* node) { | 375 void JSGenericLowering::LowerJSStoreProperty(Node* node) { |
| 376 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); |
340 LanguageMode language_mode = OpParameter<LanguageMode>(node); | 377 LanguageMode language_mode = OpParameter<LanguageMode>(node); |
341 Callable callable = CodeFactory::KeyedStoreICInOptimizedCode( | 378 Callable callable = CodeFactory::KeyedStoreICInOptimizedCode( |
342 isolate(), language_mode, UNINITIALIZED); | 379 isolate(), language_mode, UNINITIALIZED); |
343 ReplaceWithStubCall(node, callable, CallDescriptor::kPatchableCallSite); | 380 ReplaceWithStubCall(node, callable, |
| 381 CallDescriptor::kPatchableCallSite | flags); |
344 } | 382 } |
345 | 383 |
346 | 384 |
347 void JSGenericLowering::LowerJSStoreNamed(Node* node) { | 385 void JSGenericLowering::LowerJSStoreNamed(Node* node) { |
| 386 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); |
348 const StoreNamedParameters& p = StoreNamedParametersOf(node->op()); | 387 const StoreNamedParameters& p = StoreNamedParametersOf(node->op()); |
349 Callable callable = p.store_ic() == NAMED | 388 Callable callable = p.store_ic() == NAMED |
350 ? CodeFactory::StoreIC(isolate(), p.language_mode()) | 389 ? CodeFactory::StoreIC(isolate(), p.language_mode()) |
351 : CodeFactory::KeyedStoreICInOptimizedCode( | 390 : CodeFactory::KeyedStoreICInOptimizedCode( |
352 isolate(), p.language_mode(), UNINITIALIZED); | 391 isolate(), p.language_mode(), UNINITIALIZED); |
353 node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.name())); | 392 node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.name())); |
354 ReplaceWithStubCall(node, callable, CallDescriptor::kPatchableCallSite); | 393 ReplaceWithStubCall(node, callable, |
| 394 CallDescriptor::kPatchableCallSite | flags); |
355 } | 395 } |
356 | 396 |
357 | 397 |
358 void JSGenericLowering::LowerJSDeleteProperty(Node* node) { | 398 void JSGenericLowering::LowerJSDeleteProperty(Node* node) { |
359 LanguageMode language_mode = OpParameter<LanguageMode>(node); | 399 LanguageMode language_mode = OpParameter<LanguageMode>(node); |
360 ReplaceWithBuiltinCall(node, Builtins::DELETE, 3); | 400 ReplaceWithBuiltinCall(node, Builtins::DELETE, 3); |
361 node->InsertInput(zone(), 4, jsgraph()->SmiConstant(language_mode)); | 401 node->InsertInput(zone(), 4, jsgraph()->SmiConstant(language_mode)); |
362 } | 402 } |
363 | 403 |
364 | 404 |
365 void JSGenericLowering::LowerJSHasProperty(Node* node) { | 405 void JSGenericLowering::LowerJSHasProperty(Node* node) { |
366 ReplaceWithBuiltinCall(node, Builtins::IN, 2); | 406 ReplaceWithBuiltinCall(node, Builtins::IN, 2); |
367 } | 407 } |
368 | 408 |
369 | 409 |
370 void JSGenericLowering::LowerJSInstanceOf(Node* node) { | 410 void JSGenericLowering::LowerJSInstanceOf(Node* node) { |
371 InstanceofStub::Flags flags = static_cast<InstanceofStub::Flags>( | 411 InstanceofStub::Flags flags = static_cast<InstanceofStub::Flags>( |
372 InstanceofStub::kReturnTrueFalseObject | | 412 InstanceofStub::kReturnTrueFalseObject | |
373 InstanceofStub::kArgsInRegisters); | 413 InstanceofStub::kArgsInRegisters); |
374 InstanceofStub stub(isolate(), flags); | 414 InstanceofStub stub(isolate(), flags); |
375 CallInterfaceDescriptor d = stub.GetCallInterfaceDescriptor(); | 415 CallInterfaceDescriptor d = stub.GetCallInterfaceDescriptor(); |
376 CallDescriptor* desc = Linkage::GetStubCallDescriptor(isolate(), zone(), d, 0, | 416 CallDescriptor::Flags desc_flags = AdjustFrameStatesForCall(node); |
377 FlagsForNode(node)); | 417 CallDescriptor* desc = |
| 418 Linkage::GetStubCallDescriptor(isolate(), zone(), d, 0, desc_flags); |
378 Node* stub_code = jsgraph()->HeapConstant(stub.GetCode()); | 419 Node* stub_code = jsgraph()->HeapConstant(stub.GetCode()); |
379 node->InsertInput(zone(), 0, stub_code); | 420 node->InsertInput(zone(), 0, stub_code); |
380 node->set_op(common()->Call(desc)); | 421 node->set_op(common()->Call(desc)); |
381 } | 422 } |
382 | 423 |
383 | 424 |
384 void JSGenericLowering::LowerJSLoadContext(Node* node) { | 425 void JSGenericLowering::LowerJSLoadContext(Node* node) { |
385 const ContextAccess& access = ContextAccessOf(node->op()); | 426 const ContextAccess& access = ContextAccessOf(node->op()); |
386 for (size_t i = 0; i < access.depth(); ++i) { | 427 for (size_t i = 0; i < access.depth(); ++i) { |
387 node->ReplaceInput( | 428 node->ReplaceInput( |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 Unique<String> name = OpParameter<Unique<String>>(node); | 485 Unique<String> name = OpParameter<Unique<String>>(node); |
445 node->InsertInput(zone(), 0, jsgraph()->HeapConstant(name)); | 486 node->InsertInput(zone(), 0, jsgraph()->HeapConstant(name)); |
446 ReplaceWithRuntimeCall(node, Runtime::kPushCatchContext); | 487 ReplaceWithRuntimeCall(node, Runtime::kPushCatchContext); |
447 } | 488 } |
448 | 489 |
449 | 490 |
450 void JSGenericLowering::LowerJSCallConstruct(Node* node) { | 491 void JSGenericLowering::LowerJSCallConstruct(Node* node) { |
451 int arity = OpParameter<int>(node); | 492 int arity = OpParameter<int>(node); |
452 CallConstructStub stub(isolate(), NO_CALL_CONSTRUCTOR_FLAGS); | 493 CallConstructStub stub(isolate(), NO_CALL_CONSTRUCTOR_FLAGS); |
453 CallInterfaceDescriptor d = stub.GetCallInterfaceDescriptor(); | 494 CallInterfaceDescriptor d = stub.GetCallInterfaceDescriptor(); |
454 CallDescriptor* desc = Linkage::GetStubCallDescriptor( | 495 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); |
455 isolate(), zone(), d, arity, FlagsForNode(node)); | 496 CallDescriptor* desc = |
| 497 Linkage::GetStubCallDescriptor(isolate(), zone(), d, arity, flags); |
456 Node* stub_code = jsgraph()->HeapConstant(stub.GetCode()); | 498 Node* stub_code = jsgraph()->HeapConstant(stub.GetCode()); |
457 Node* construct = NodeProperties::GetValueInput(node, 0); | 499 Node* construct = NodeProperties::GetValueInput(node, 0); |
458 node->InsertInput(zone(), 0, stub_code); | 500 node->InsertInput(zone(), 0, stub_code); |
459 node->InsertInput(zone(), 1, jsgraph()->Int32Constant(arity - 1)); | 501 node->InsertInput(zone(), 1, jsgraph()->Int32Constant(arity - 1)); |
460 node->InsertInput(zone(), 2, construct); | 502 node->InsertInput(zone(), 2, construct); |
461 node->InsertInput(zone(), 3, jsgraph()->UndefinedConstant()); | 503 node->InsertInput(zone(), 3, jsgraph()->UndefinedConstant()); |
462 node->set_op(common()->Call(desc)); | 504 node->set_op(common()->Call(desc)); |
463 } | 505 } |
464 | 506 |
465 | 507 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 | 548 |
507 void JSGenericLowering::LowerJSCallFunction(Node* node) { | 549 void JSGenericLowering::LowerJSCallFunction(Node* node) { |
508 // Fast case: call function directly. | 550 // Fast case: call function directly. |
509 if (TryLowerDirectJSCall(node)) return; | 551 if (TryLowerDirectJSCall(node)) return; |
510 | 552 |
511 // General case: CallFunctionStub. | 553 // General case: CallFunctionStub. |
512 const CallFunctionParameters& p = CallFunctionParametersOf(node->op()); | 554 const CallFunctionParameters& p = CallFunctionParametersOf(node->op()); |
513 int arg_count = static_cast<int>(p.arity() - 2); | 555 int arg_count = static_cast<int>(p.arity() - 2); |
514 CallFunctionStub stub(isolate(), arg_count, p.flags()); | 556 CallFunctionStub stub(isolate(), arg_count, p.flags()); |
515 CallInterfaceDescriptor d = stub.GetCallInterfaceDescriptor(); | 557 CallInterfaceDescriptor d = stub.GetCallInterfaceDescriptor(); |
| 558 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); |
516 CallDescriptor* desc = Linkage::GetStubCallDescriptor( | 559 CallDescriptor* desc = Linkage::GetStubCallDescriptor( |
517 isolate(), zone(), d, static_cast<int>(p.arity() - 1), | 560 isolate(), zone(), d, static_cast<int>(p.arity() - 1), flags); |
518 FlagsForNode(node)); | |
519 Node* stub_code = jsgraph()->HeapConstant(stub.GetCode()); | 561 Node* stub_code = jsgraph()->HeapConstant(stub.GetCode()); |
520 node->InsertInput(zone(), 0, stub_code); | 562 node->InsertInput(zone(), 0, stub_code); |
521 node->set_op(common()->Call(desc)); | 563 node->set_op(common()->Call(desc)); |
522 } | 564 } |
523 | 565 |
524 | 566 |
525 void JSGenericLowering::LowerJSCallRuntime(Node* node) { | 567 void JSGenericLowering::LowerJSCallRuntime(Node* node) { |
526 const CallRuntimeParameters& p = CallRuntimeParametersOf(node->op()); | 568 const CallRuntimeParameters& p = CallRuntimeParametersOf(node->op()); |
527 ReplaceWithRuntimeCall(node, p.id(), static_cast<int>(p.arity())); | 569 ReplaceWithRuntimeCall(node, p.id(), static_cast<int>(p.arity())); |
528 } | 570 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
576 } | 618 } |
577 | 619 |
578 | 620 |
579 MachineOperatorBuilder* JSGenericLowering::machine() const { | 621 MachineOperatorBuilder* JSGenericLowering::machine() const { |
580 return jsgraph()->machine(); | 622 return jsgraph()->machine(); |
581 } | 623 } |
582 | 624 |
583 } // namespace compiler | 625 } // namespace compiler |
584 } // namespace internal | 626 } // namespace internal |
585 } // namespace v8 | 627 } // namespace v8 |
OLD | NEW |