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" |
(...skipping 27 matching lines...) Expand all Loading... |
38 Lower##x(node); \ | 38 Lower##x(node); \ |
39 break; | 39 break; |
40 JS_OP_LIST(DECLARE_CASE) | 40 JS_OP_LIST(DECLARE_CASE) |
41 #undef DECLARE_CASE | 41 #undef DECLARE_CASE |
42 default: | 42 default: |
43 // Nothing to see. | 43 // Nothing to see. |
44 return NoChange(); | 44 return NoChange(); |
45 } | 45 } |
46 return Changed(node); | 46 return Changed(node); |
47 } | 47 } |
48 #define REPLACE_RUNTIME_CALL(op, fun) \ | |
49 void JSGenericLowering::Lower##op(Node* node) { \ | |
50 ReplaceWithRuntimeCall(node, fun); \ | |
51 } | |
52 REPLACE_RUNTIME_CALL(JSCreateWithContext, Runtime::kPushWithContext) | |
53 REPLACE_RUNTIME_CALL(JSConvertReceiver, Runtime::kConvertReceiver) | |
54 #undef REPLACE_RUNTIME_CALL | |
55 | 48 |
56 #define REPLACE_STUB_CALL(Name) \ | 49 #define REPLACE_STUB_CALL(Name) \ |
57 void JSGenericLowering::LowerJS##Name(Node* node) { \ | 50 void JSGenericLowering::LowerJS##Name(Node* node) { \ |
58 CallDescriptor::Flags flags = FrameStateFlagForCall(node); \ | 51 CallDescriptor::Flags flags = FrameStateFlagForCall(node); \ |
59 Callable callable = CodeFactory::Name(isolate()); \ | 52 Callable callable = CodeFactory::Name(isolate()); \ |
60 ReplaceWithStubCall(node, callable, flags); \ | 53 ReplaceWithStubCall(node, callable, flags); \ |
61 } | 54 } |
62 REPLACE_STUB_CALL(Add) | 55 REPLACE_STUB_CALL(Add) |
63 REPLACE_STUB_CALL(Subtract) | 56 REPLACE_STUB_CALL(Subtract) |
64 REPLACE_STUB_CALL(Multiply) | 57 REPLACE_STUB_CALL(Multiply) |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 void JSGenericLowering::LowerJSCreateCatchContext(Node* node) { | 504 void JSGenericLowering::LowerJSCreateCatchContext(Node* node) { |
512 const CreateCatchContextParameters& parameters = | 505 const CreateCatchContextParameters& parameters = |
513 CreateCatchContextParametersOf(node->op()); | 506 CreateCatchContextParametersOf(node->op()); |
514 node->InsertInput(zone(), 0, | 507 node->InsertInput(zone(), 0, |
515 jsgraph()->HeapConstant(parameters.catch_name())); | 508 jsgraph()->HeapConstant(parameters.catch_name())); |
516 node->InsertInput(zone(), 2, | 509 node->InsertInput(zone(), 2, |
517 jsgraph()->HeapConstant(parameters.scope_info())); | 510 jsgraph()->HeapConstant(parameters.scope_info())); |
518 ReplaceWithRuntimeCall(node, Runtime::kPushCatchContext); | 511 ReplaceWithRuntimeCall(node, Runtime::kPushCatchContext); |
519 } | 512 } |
520 | 513 |
| 514 void JSGenericLowering::LowerJSCreateWithContext(Node* node) { |
| 515 Handle<ScopeInfo> scope_info = OpParameter<Handle<ScopeInfo>>(node); |
| 516 node->InsertInput(zone(), 1, jsgraph()->HeapConstant(scope_info)); |
| 517 ReplaceWithRuntimeCall(node, Runtime::kPushWithContext); |
| 518 } |
521 | 519 |
522 void JSGenericLowering::LowerJSCreateBlockContext(Node* node) { | 520 void JSGenericLowering::LowerJSCreateBlockContext(Node* node) { |
523 Handle<ScopeInfo> scope_info = OpParameter<Handle<ScopeInfo>>(node); | 521 Handle<ScopeInfo> scope_info = OpParameter<Handle<ScopeInfo>>(node); |
524 node->InsertInput(zone(), 0, jsgraph()->HeapConstant(scope_info)); | 522 node->InsertInput(zone(), 0, jsgraph()->HeapConstant(scope_info)); |
525 ReplaceWithRuntimeCall(node, Runtime::kPushBlockContext); | 523 ReplaceWithRuntimeCall(node, Runtime::kPushBlockContext); |
526 } | 524 } |
527 | 525 |
528 | 526 |
529 void JSGenericLowering::LowerJSCreateScriptContext(Node* node) { | 527 void JSGenericLowering::LowerJSCreateScriptContext(Node* node) { |
530 Handle<ScopeInfo> scope_info = OpParameter<Handle<ScopeInfo>>(node); | 528 Handle<ScopeInfo> scope_info = OpParameter<Handle<ScopeInfo>>(node); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
570 node->InsertInput(zone(), 2, stub_arity); | 568 node->InsertInput(zone(), 2, stub_arity); |
571 NodeProperties::ChangeOp(node, common()->Call(desc)); | 569 NodeProperties::ChangeOp(node, common()->Call(desc)); |
572 } | 570 } |
573 | 571 |
574 | 572 |
575 void JSGenericLowering::LowerJSCallRuntime(Node* node) { | 573 void JSGenericLowering::LowerJSCallRuntime(Node* node) { |
576 const CallRuntimeParameters& p = CallRuntimeParametersOf(node->op()); | 574 const CallRuntimeParameters& p = CallRuntimeParametersOf(node->op()); |
577 ReplaceWithRuntimeCall(node, p.id(), static_cast<int>(p.arity())); | 575 ReplaceWithRuntimeCall(node, p.id(), static_cast<int>(p.arity())); |
578 } | 576 } |
579 | 577 |
| 578 void JSGenericLowering::LowerJSConvertReceiver(Node* node) { |
| 579 ReplaceWithRuntimeCall(node, Runtime::kConvertReceiver); |
| 580 } |
580 | 581 |
581 void JSGenericLowering::LowerJSForInNext(Node* node) { | 582 void JSGenericLowering::LowerJSForInNext(Node* node) { |
582 ReplaceWithRuntimeCall(node, Runtime::kForInNext); | 583 ReplaceWithRuntimeCall(node, Runtime::kForInNext); |
583 } | 584 } |
584 | 585 |
585 | 586 |
586 void JSGenericLowering::LowerJSForInPrepare(Node* node) { | 587 void JSGenericLowering::LowerJSForInPrepare(Node* node) { |
587 ReplaceWithRuntimeCall(node, Runtime::kForInPrepare); | 588 ReplaceWithRuntimeCall(node, Runtime::kForInPrepare); |
588 } | 589 } |
589 | 590 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 } | 678 } |
678 | 679 |
679 | 680 |
680 MachineOperatorBuilder* JSGenericLowering::machine() const { | 681 MachineOperatorBuilder* JSGenericLowering::machine() const { |
681 return jsgraph()->machine(); | 682 return jsgraph()->machine(); |
682 } | 683 } |
683 | 684 |
684 } // namespace compiler | 685 } // namespace compiler |
685 } // namespace internal | 686 } // namespace internal |
686 } // namespace v8 | 687 } // namespace v8 |
OLD | NEW |