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-stubs.h" | 5 #include "src/code-stubs.h" |
6 #include "src/compiler/common-operator.h" | 6 #include "src/compiler/common-operator.h" |
7 #include "src/compiler/graph-inl.h" | 7 #include "src/compiler/graph-inl.h" |
8 #include "src/compiler/js-generic-lowering.h" | 8 #include "src/compiler/js-generic-lowering.h" |
9 #include "src/compiler/machine-operator.h" | 9 #include "src/compiler/machine-operator.h" |
10 #include "src/compiler/node-aux-data-inl.h" | 10 #include "src/compiler/node-aux-data-inl.h" |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 UNIMPLEMENTED(); \ | 285 UNIMPLEMENTED(); \ |
286 return node; \ | 286 return node; \ |
287 } | 287 } |
288 REPLACE_UNIMPLEMENTED(JSToString) | 288 REPLACE_UNIMPLEMENTED(JSToString) |
289 REPLACE_UNIMPLEMENTED(JSToName) | 289 REPLACE_UNIMPLEMENTED(JSToName) |
290 REPLACE_UNIMPLEMENTED(JSYield) | 290 REPLACE_UNIMPLEMENTED(JSYield) |
291 REPLACE_UNIMPLEMENTED(JSDebugger) | 291 REPLACE_UNIMPLEMENTED(JSDebugger) |
292 #undef REPLACE_UNIMPLEMENTED | 292 #undef REPLACE_UNIMPLEMENTED |
293 | 293 |
294 | 294 |
| 295 static CallDescriptor::DeoptimizationSupport DeoptimizationSupportForNode( |
| 296 Node* node) { |
| 297 return OperatorProperties::CanLazilyDeoptimize(node->op()) |
| 298 ? CallDescriptor::kCanDeoptimize |
| 299 : CallDescriptor::kCannotDeoptimize; |
| 300 } |
| 301 |
| 302 |
295 void JSGenericLowering::ReplaceWithCompareIC(Node* node, Token::Value token, | 303 void JSGenericLowering::ReplaceWithCompareIC(Node* node, Token::Value token, |
296 bool pure) { | 304 bool pure) { |
297 BinaryOpICStub stub(isolate(), Token::ADD); // TODO(mstarzinger): Hack. | 305 BinaryOpICStub stub(isolate(), Token::ADD); // TODO(mstarzinger): Hack. |
298 CodeStubInterfaceDescriptor* d = stub.GetInterfaceDescriptor(); | 306 CodeStubInterfaceDescriptor* d = stub.GetInterfaceDescriptor(); |
299 CallDescriptor* desc_compare = linkage()->GetStubCallDescriptor(d); | 307 CallDescriptor* desc_compare = linkage()->GetStubCallDescriptor(d); |
300 Handle<Code> ic = CompareIC::GetUninitialized(isolate(), token); | 308 Handle<Code> ic = CompareIC::GetUninitialized(isolate(), token); |
301 Node* compare; | 309 Node* compare; |
302 if (pure) { | 310 if (pure) { |
303 // A pure (strict) comparison doesn't have an effect or control. | 311 // A pure (strict) comparison doesn't have an effect or control. |
304 // But for the graph, we need to add these inputs. | 312 // But for the graph, we need to add these inputs. |
(...skipping 12 matching lines...) Expand all Loading... |
317 } | 325 } |
318 node->ReplaceInput(0, compare); | 326 node->ReplaceInput(0, compare); |
319 node->ReplaceInput(1, SmiConstant(token)); | 327 node->ReplaceInput(1, SmiConstant(token)); |
320 ReplaceWithRuntimeCall(node, Runtime::kBooleanize); | 328 ReplaceWithRuntimeCall(node, Runtime::kBooleanize); |
321 } | 329 } |
322 | 330 |
323 | 331 |
324 void JSGenericLowering::ReplaceWithICStubCall(Node* node, | 332 void JSGenericLowering::ReplaceWithICStubCall(Node* node, |
325 HydrogenCodeStub* stub) { | 333 HydrogenCodeStub* stub) { |
326 CodeStubInterfaceDescriptor* d = stub->GetInterfaceDescriptor(); | 334 CodeStubInterfaceDescriptor* d = stub->GetInterfaceDescriptor(); |
327 CallDescriptor* desc = linkage()->GetStubCallDescriptor(d); | 335 CallDescriptor* desc = linkage()->GetStubCallDescriptor( |
| 336 d, 0, DeoptimizationSupportForNode(node)); |
328 Node* stub_code = CodeConstant(stub->GetCode()); | 337 Node* stub_code = CodeConstant(stub->GetCode()); |
329 PatchInsertInput(node, 0, stub_code); | 338 PatchInsertInput(node, 0, stub_code); |
330 PatchOperator(node, common()->Call(desc)); | 339 PatchOperator(node, common()->Call(desc)); |
331 } | 340 } |
332 | 341 |
333 | 342 |
334 void JSGenericLowering::ReplaceWithBuiltinCall(Node* node, | 343 void JSGenericLowering::ReplaceWithBuiltinCall(Node* node, |
335 Builtins::JavaScript id, | 344 Builtins::JavaScript id, |
336 int nargs) { | 345 int nargs) { |
337 CallFunctionStub stub(isolate(), nargs - 1, NO_CALL_FUNCTION_FLAGS); | 346 CallFunctionStub stub(isolate(), nargs - 1, NO_CALL_FUNCTION_FLAGS); |
(...skipping 10 matching lines...) Expand all Loading... |
348 PatchOperator(node, common()->Call(desc)); | 357 PatchOperator(node, common()->Call(desc)); |
349 } | 358 } |
350 | 359 |
351 | 360 |
352 void JSGenericLowering::ReplaceWithRuntimeCall(Node* node, | 361 void JSGenericLowering::ReplaceWithRuntimeCall(Node* node, |
353 Runtime::FunctionId f, | 362 Runtime::FunctionId f, |
354 int nargs_override) { | 363 int nargs_override) { |
355 Operator::Property props = node->op()->properties(); | 364 Operator::Property props = node->op()->properties(); |
356 const Runtime::Function* fun = Runtime::FunctionForId(f); | 365 const Runtime::Function* fun = Runtime::FunctionForId(f); |
357 int nargs = (nargs_override < 0) ? fun->nargs : nargs_override; | 366 int nargs = (nargs_override < 0) ? fun->nargs : nargs_override; |
358 CallDescriptor::DeoptimizationSupport deopt = | 367 CallDescriptor* desc = linkage()->GetRuntimeCallDescriptor( |
359 OperatorProperties::CanLazilyDeoptimize(node->op()) | 368 f, nargs, props, DeoptimizationSupportForNode(node)); |
360 ? CallDescriptor::kCanDeoptimize | |
361 : CallDescriptor::kCannotDeoptimize; | |
362 CallDescriptor* desc = | |
363 linkage()->GetRuntimeCallDescriptor(f, nargs, props, deopt); | |
364 Node* ref = ExternalConstant(ExternalReference(f, isolate())); | 369 Node* ref = ExternalConstant(ExternalReference(f, isolate())); |
365 Node* arity = Int32Constant(nargs); | 370 Node* arity = Int32Constant(nargs); |
366 if (!centrystub_constant_.is_set()) { | 371 if (!centrystub_constant_.is_set()) { |
367 centrystub_constant_.set(CodeConstant(CEntryStub(isolate(), 1).GetCode())); | 372 centrystub_constant_.set(CodeConstant(CEntryStub(isolate(), 1).GetCode())); |
368 } | 373 } |
369 PatchInsertInput(node, 0, centrystub_constant_.get()); | 374 PatchInsertInput(node, 0, centrystub_constant_.get()); |
370 PatchInsertInput(node, nargs + 1, ref); | 375 PatchInsertInput(node, nargs + 1, ref); |
371 PatchInsertInput(node, nargs + 2, arity); | 376 PatchInsertInput(node, nargs + 2, arity); |
372 PatchOperator(node, common()->Call(desc)); | 377 PatchOperator(node, common()->Call(desc)); |
373 } | 378 } |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 node->ReplaceInput(1, Int32Constant(Context::SlotOffset(access.index()))); | 506 node->ReplaceInput(1, Int32Constant(Context::SlotOffset(access.index()))); |
502 PatchOperator(node, machine()->Store(kMachineTagged, kFullWriteBarrier)); | 507 PatchOperator(node, machine()->Store(kMachineTagged, kFullWriteBarrier)); |
503 return node; | 508 return node; |
504 } | 509 } |
505 | 510 |
506 | 511 |
507 Node* JSGenericLowering::LowerJSCallConstruct(Node* node) { | 512 Node* JSGenericLowering::LowerJSCallConstruct(Node* node) { |
508 int arity = OpParameter<int>(node); | 513 int arity = OpParameter<int>(node); |
509 CallConstructStub stub(isolate(), NO_CALL_CONSTRUCTOR_FLAGS); | 514 CallConstructStub stub(isolate(), NO_CALL_CONSTRUCTOR_FLAGS); |
510 CodeStubInterfaceDescriptor* d = GetInterfaceDescriptor(isolate(), &stub); | 515 CodeStubInterfaceDescriptor* d = GetInterfaceDescriptor(isolate(), &stub); |
511 CallDescriptor* desc = linkage()->GetStubCallDescriptor(d, arity); | 516 CallDescriptor* desc = linkage()->GetStubCallDescriptor( |
| 517 d, arity, DeoptimizationSupportForNode(node)); |
512 Node* stub_code = CodeConstant(stub.GetCode()); | 518 Node* stub_code = CodeConstant(stub.GetCode()); |
513 Node* construct = NodeProperties::GetValueInput(node, 0); | 519 Node* construct = NodeProperties::GetValueInput(node, 0); |
514 PatchInsertInput(node, 0, stub_code); | 520 PatchInsertInput(node, 0, stub_code); |
515 PatchInsertInput(node, 1, Int32Constant(arity - 1)); | 521 PatchInsertInput(node, 1, Int32Constant(arity - 1)); |
516 PatchInsertInput(node, 2, construct); | 522 PatchInsertInput(node, 2, construct); |
517 PatchInsertInput(node, 3, jsgraph()->UndefinedConstant()); | 523 PatchInsertInput(node, 3, jsgraph()->UndefinedConstant()); |
518 PatchOperator(node, common()->Call(desc)); | 524 PatchOperator(node, common()->Call(desc)); |
519 return node; | 525 return node; |
520 } | 526 } |
521 | 527 |
522 | 528 |
523 Node* JSGenericLowering::LowerJSCallFunction(Node* node) { | 529 Node* JSGenericLowering::LowerJSCallFunction(Node* node) { |
524 CallParameters p = OpParameter<CallParameters>(node); | 530 CallParameters p = OpParameter<CallParameters>(node); |
525 CallFunctionStub stub(isolate(), p.arity - 2, p.flags); | 531 CallFunctionStub stub(isolate(), p.arity - 2, p.flags); |
526 CodeStubInterfaceDescriptor* d = GetInterfaceDescriptor(isolate(), &stub); | 532 CodeStubInterfaceDescriptor* d = GetInterfaceDescriptor(isolate(), &stub); |
527 CallDescriptor* desc = linkage()->GetStubCallDescriptor(d, p.arity - 1); | 533 CallDescriptor* desc = linkage()->GetStubCallDescriptor( |
| 534 d, p.arity - 1, DeoptimizationSupportForNode(node)); |
528 Node* stub_code = CodeConstant(stub.GetCode()); | 535 Node* stub_code = CodeConstant(stub.GetCode()); |
529 PatchInsertInput(node, 0, stub_code); | 536 PatchInsertInput(node, 0, stub_code); |
530 PatchOperator(node, common()->Call(desc)); | 537 PatchOperator(node, common()->Call(desc)); |
531 return node; | 538 return node; |
532 } | 539 } |
533 | 540 |
534 | 541 |
535 Node* JSGenericLowering::LowerJSCallRuntime(Node* node) { | 542 Node* JSGenericLowering::LowerJSCallRuntime(Node* node) { |
536 Runtime::FunctionId function = OpParameter<Runtime::FunctionId>(node); | 543 Runtime::FunctionId function = OpParameter<Runtime::FunctionId>(node); |
537 int arity = OperatorProperties::GetValueInputCount(node->op()); | 544 int arity = OperatorProperties::GetValueInputCount(node->op()); |
538 ReplaceWithRuntimeCall(node, function, arity); | 545 ReplaceWithRuntimeCall(node, function, arity); |
539 return node; | 546 return node; |
540 } | 547 } |
541 } | 548 } |
542 } | 549 } |
543 } // namespace v8::internal::compiler | 550 } // namespace v8::internal::compiler |
OLD | NEW |