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 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 Handle<JSFunction> function( | 342 Handle<JSFunction> function( |
343 JSFunction::cast(info()->context()->builtins()->javascript_builtin(id))); | 343 JSFunction::cast(info()->context()->builtins()->javascript_builtin(id))); |
344 Node* stub_code = CodeConstant(stub.GetCode()); | 344 Node* stub_code = CodeConstant(stub.GetCode()); |
345 Node* function_node = FunctionConstant(function); | 345 Node* function_node = FunctionConstant(function); |
346 PatchInsertInput(node, 0, stub_code); | 346 PatchInsertInput(node, 0, stub_code); |
347 PatchInsertInput(node, 1, function_node); | 347 PatchInsertInput(node, 1, function_node); |
348 PatchOperator(node, common()->Call(desc)); | 348 PatchOperator(node, common()->Call(desc)); |
349 } | 349 } |
350 | 350 |
351 | 351 |
| 352 static CallDescriptor::DeoptimizationSupport DeoptimizationSupportForNode( |
| 353 Node* node) { |
| 354 return OperatorProperties::CanLazilyDeoptimize(node->op()) |
| 355 ? CallDescriptor::kCanDeoptimize |
| 356 : CallDescriptor::kCannotDeoptimize; |
| 357 } |
| 358 |
| 359 |
352 void JSGenericLowering::ReplaceWithRuntimeCall(Node* node, | 360 void JSGenericLowering::ReplaceWithRuntimeCall(Node* node, |
353 Runtime::FunctionId f, | 361 Runtime::FunctionId f, |
354 int nargs_override) { | 362 int nargs_override) { |
355 Operator::Property props = node->op()->properties(); | 363 Operator::Property props = node->op()->properties(); |
356 const Runtime::Function* fun = Runtime::FunctionForId(f); | 364 const Runtime::Function* fun = Runtime::FunctionForId(f); |
357 int nargs = (nargs_override < 0) ? fun->nargs : nargs_override; | 365 int nargs = (nargs_override < 0) ? fun->nargs : nargs_override; |
358 CallDescriptor::DeoptimizationSupport deopt = | 366 CallDescriptor* desc = linkage()->GetRuntimeCallDescriptor( |
359 OperatorProperties::CanLazilyDeoptimize(node->op()) | 367 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())); | 368 Node* ref = ExternalConstant(ExternalReference(f, isolate())); |
365 Node* arity = Int32Constant(nargs); | 369 Node* arity = Int32Constant(nargs); |
366 if (!centrystub_constant_.is_set()) { | 370 if (!centrystub_constant_.is_set()) { |
367 centrystub_constant_.set(CodeConstant(CEntryStub(isolate(), 1).GetCode())); | 371 centrystub_constant_.set(CodeConstant(CEntryStub(isolate(), 1).GetCode())); |
368 } | 372 } |
369 PatchInsertInput(node, 0, centrystub_constant_.get()); | 373 PatchInsertInput(node, 0, centrystub_constant_.get()); |
370 PatchInsertInput(node, nargs + 1, ref); | 374 PatchInsertInput(node, nargs + 1, ref); |
371 PatchInsertInput(node, nargs + 2, arity); | 375 PatchInsertInput(node, nargs + 2, arity); |
372 PatchOperator(node, common()->Call(desc)); | 376 PatchOperator(node, common()->Call(desc)); |
373 } | 377 } |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 PatchInsertInput(node, 3, jsgraph()->UndefinedConstant()); | 541 PatchInsertInput(node, 3, jsgraph()->UndefinedConstant()); |
538 PatchOperator(node, common()->Call(desc)); | 542 PatchOperator(node, common()->Call(desc)); |
539 return node; | 543 return node; |
540 } | 544 } |
541 | 545 |
542 | 546 |
543 Node* JSGenericLowering::LowerJSCallFunction(Node* node) { | 547 Node* JSGenericLowering::LowerJSCallFunction(Node* node) { |
544 CallParameters p = OpParameter<CallParameters>(node); | 548 CallParameters p = OpParameter<CallParameters>(node); |
545 CallFunctionStub stub(isolate(), p.arity - 2, p.flags); | 549 CallFunctionStub stub(isolate(), p.arity - 2, p.flags); |
546 CodeStubInterfaceDescriptor* d = GetInterfaceDescriptor(isolate(), &stub); | 550 CodeStubInterfaceDescriptor* d = GetInterfaceDescriptor(isolate(), &stub); |
547 CallDescriptor* desc = linkage()->GetStubCallDescriptor(d, p.arity - 1); | 551 CallDescriptor* desc = linkage()->GetStubCallDescriptor( |
| 552 d, p.arity - 1, DeoptimizationSupportForNode(node)); |
548 Node* stub_code = CodeConstant(stub.GetCode()); | 553 Node* stub_code = CodeConstant(stub.GetCode()); |
549 PatchInsertInput(node, 0, stub_code); | 554 PatchInsertInput(node, 0, stub_code); |
550 PatchOperator(node, common()->Call(desc)); | 555 PatchOperator(node, common()->Call(desc)); |
551 return node; | 556 return node; |
552 } | 557 } |
553 | 558 |
554 | 559 |
555 Node* JSGenericLowering::LowerJSCallRuntime(Node* node) { | 560 Node* JSGenericLowering::LowerJSCallRuntime(Node* node) { |
556 Runtime::FunctionId function = OpParameter<Runtime::FunctionId>(node); | 561 Runtime::FunctionId function = OpParameter<Runtime::FunctionId>(node); |
557 int arity = OperatorProperties::GetValueInputCount(node->op()); | 562 int arity = OperatorProperties::GetValueInputCount(node->op()); |
558 ReplaceWithRuntimeCall(node, function, arity); | 563 ReplaceWithRuntimeCall(node, function, arity); |
559 return node; | 564 return node; |
560 } | 565 } |
561 } | 566 } |
562 } | 567 } |
563 } // namespace v8::internal::compiler | 568 } // namespace v8::internal::compiler |
OLD | NEW |