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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 REPLACE_COMPARE_IC_CALL_WITH_LANGUAGE_MODE(JSGreaterThan, Token::GT) | 107 REPLACE_COMPARE_IC_CALL_WITH_LANGUAGE_MODE(JSGreaterThan, Token::GT) |
108 REPLACE_COMPARE_IC_CALL_WITH_LANGUAGE_MODE(JSLessThanOrEqual, Token::LTE) | 108 REPLACE_COMPARE_IC_CALL_WITH_LANGUAGE_MODE(JSLessThanOrEqual, Token::LTE) |
109 REPLACE_COMPARE_IC_CALL_WITH_LANGUAGE_MODE(JSGreaterThanOrEqual, Token::GTE) | 109 REPLACE_COMPARE_IC_CALL_WITH_LANGUAGE_MODE(JSGreaterThanOrEqual, Token::GTE) |
110 #undef REPLACE_COMPARE_IC_CALL_WITH_LANGUAGE_MODE | 110 #undef REPLACE_COMPARE_IC_CALL_WITH_LANGUAGE_MODE |
111 | 111 |
112 | 112 |
113 #define REPLACE_RUNTIME_CALL(op, fun) \ | 113 #define REPLACE_RUNTIME_CALL(op, fun) \ |
114 void JSGenericLowering::Lower##op(Node* node) { \ | 114 void JSGenericLowering::Lower##op(Node* node) { \ |
115 ReplaceWithRuntimeCall(node, fun); \ | 115 ReplaceWithRuntimeCall(node, fun); \ |
116 } | 116 } |
117 REPLACE_RUNTIME_CALL(JSCreate, Runtime::kAbort) | |
118 REPLACE_RUNTIME_CALL(JSCreateFunctionContext, Runtime::kNewFunctionContext) | 117 REPLACE_RUNTIME_CALL(JSCreateFunctionContext, Runtime::kNewFunctionContext) |
119 REPLACE_RUNTIME_CALL(JSCreateWithContext, Runtime::kPushWithContext) | 118 REPLACE_RUNTIME_CALL(JSCreateWithContext, Runtime::kPushWithContext) |
120 REPLACE_RUNTIME_CALL(JSCreateBlockContext, Runtime::kPushBlockContext) | |
121 REPLACE_RUNTIME_CALL(JSCreateModuleContext, Runtime::kPushModuleContext) | 119 REPLACE_RUNTIME_CALL(JSCreateModuleContext, Runtime::kPushModuleContext) |
122 REPLACE_RUNTIME_CALL(JSCreateScriptContext, Runtime::kNewScriptContext) | |
123 #undef REPLACE_RUNTIME | 120 #undef REPLACE_RUNTIME |
124 | 121 |
125 | 122 |
126 #define REPLACE_UNIMPLEMENTED(op) \ | |
127 void JSGenericLowering::Lower##op(Node* node) { UNIMPLEMENTED(); } | |
128 REPLACE_UNIMPLEMENTED(JSYield) | |
129 #undef REPLACE_UNIMPLEMENTED | |
130 | |
131 | |
132 static CallDescriptor::Flags FlagsForNode(Node* node) { | 123 static CallDescriptor::Flags FlagsForNode(Node* node) { |
133 CallDescriptor::Flags result = CallDescriptor::kNoFlags; | 124 CallDescriptor::Flags result = CallDescriptor::kNoFlags; |
134 if (OperatorProperties::GetFrameStateInputCount(node->op()) > 0) { | 125 if (OperatorProperties::GetFrameStateInputCount(node->op()) > 0) { |
135 result |= CallDescriptor::kNeedsFrameState; | 126 result |= CallDescriptor::kNeedsFrameState; |
136 } | 127 } |
137 return result; | 128 return result; |
138 } | 129 } |
139 | 130 |
140 | 131 |
141 void JSGenericLowering::ReplaceWithCompareIC(Node* node, Token::Value token, | 132 void JSGenericLowering::ReplaceWithCompareIC(Node* node, Token::Value token, |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 void JSGenericLowering::LowerJSLoadDynamicContext(Node* node) { | 473 void JSGenericLowering::LowerJSLoadDynamicContext(Node* node) { |
483 const DynamicContextAccess& access = DynamicContextAccessOf(node->op()); | 474 const DynamicContextAccess& access = DynamicContextAccessOf(node->op()); |
484 Node* projection = graph()->NewNode(common()->Projection(0), node); | 475 Node* projection = graph()->NewNode(common()->Projection(0), node); |
485 NodeProperties::ReplaceUses(node, projection, node, node, node); | 476 NodeProperties::ReplaceUses(node, projection, node, node, node); |
486 node->InsertInput(zone(), 1, jsgraph()->Constant(access.name())); | 477 node->InsertInput(zone(), 1, jsgraph()->Constant(access.name())); |
487 ReplaceWithRuntimeCall(node, Runtime::kLoadLookupSlot); | 478 ReplaceWithRuntimeCall(node, Runtime::kLoadLookupSlot); |
488 projection->ReplaceInput(0, node); | 479 projection->ReplaceInput(0, node); |
489 } | 480 } |
490 | 481 |
491 | 482 |
| 483 void JSGenericLowering::LowerJSCreate(Node* node) { UNIMPLEMENTED(); } |
| 484 |
| 485 |
492 void JSGenericLowering::LowerJSCreateArguments(Node* node) { | 486 void JSGenericLowering::LowerJSCreateArguments(Node* node) { |
493 const CreateArgumentsParameters& p = CreateArgumentsParametersOf(node->op()); | 487 const CreateArgumentsParameters& p = CreateArgumentsParametersOf(node->op()); |
494 switch (p.type()) { | 488 switch (p.type()) { |
495 case CreateArgumentsParameters::kMappedArguments: | 489 case CreateArgumentsParameters::kMappedArguments: |
496 ReplaceWithRuntimeCall(node, Runtime::kNewSloppyArguments_Generic); | 490 ReplaceWithRuntimeCall(node, Runtime::kNewSloppyArguments_Generic); |
497 break; | 491 break; |
498 case CreateArgumentsParameters::kUnmappedArguments: | 492 case CreateArgumentsParameters::kUnmappedArguments: |
499 ReplaceWithRuntimeCall(node, Runtime::kNewStrictArguments_Generic); | 493 ReplaceWithRuntimeCall(node, Runtime::kNewStrictArguments_Generic); |
500 break; | 494 break; |
501 case CreateArgumentsParameters::kRestArray: | 495 case CreateArgumentsParameters::kRestArray: |
(...skipping 26 matching lines...) Expand all Loading... |
528 } | 522 } |
529 | 523 |
530 | 524 |
531 void JSGenericLowering::LowerJSCreateCatchContext(Node* node) { | 525 void JSGenericLowering::LowerJSCreateCatchContext(Node* node) { |
532 Handle<String> name = OpParameter<Handle<String>>(node); | 526 Handle<String> name = OpParameter<Handle<String>>(node); |
533 node->InsertInput(zone(), 0, jsgraph()->HeapConstant(name)); | 527 node->InsertInput(zone(), 0, jsgraph()->HeapConstant(name)); |
534 ReplaceWithRuntimeCall(node, Runtime::kPushCatchContext); | 528 ReplaceWithRuntimeCall(node, Runtime::kPushCatchContext); |
535 } | 529 } |
536 | 530 |
537 | 531 |
| 532 void JSGenericLowering::LowerJSCreateBlockContext(Node* node) { |
| 533 Handle<ScopeInfo> scope_info = OpParameter<Handle<ScopeInfo>>(node); |
| 534 node->InsertInput(zone(), 0, jsgraph()->HeapConstant(scope_info)); |
| 535 ReplaceWithRuntimeCall(node, Runtime::kPushBlockContext); |
| 536 } |
| 537 |
| 538 |
| 539 void JSGenericLowering::LowerJSCreateScriptContext(Node* node) { |
| 540 Handle<ScopeInfo> scope_info = OpParameter<Handle<ScopeInfo>>(node); |
| 541 node->InsertInput(zone(), 1, jsgraph()->HeapConstant(scope_info)); |
| 542 ReplaceWithRuntimeCall(node, Runtime::kNewScriptContext); |
| 543 } |
| 544 |
| 545 |
538 void JSGenericLowering::LowerJSCallConstruct(Node* node) { | 546 void JSGenericLowering::LowerJSCallConstruct(Node* node) { |
539 int arity = OpParameter<int>(node); | 547 int arity = OpParameter<int>(node); |
540 CallConstructStub stub(isolate(), SUPER_CONSTRUCTOR_CALL); | 548 CallConstructStub stub(isolate(), SUPER_CONSTRUCTOR_CALL); |
541 CallInterfaceDescriptor d = stub.GetCallInterfaceDescriptor(); | 549 CallInterfaceDescriptor d = stub.GetCallInterfaceDescriptor(); |
542 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); | 550 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); |
543 CallDescriptor* desc = | 551 CallDescriptor* desc = |
544 Linkage::GetStubCallDescriptor(isolate(), zone(), d, arity - 1, flags); | 552 Linkage::GetStubCallDescriptor(isolate(), zone(), d, arity - 1, flags); |
545 Node* stub_code = jsgraph()->HeapConstant(stub.GetCode()); | 553 Node* stub_code = jsgraph()->HeapConstant(stub.GetCode()); |
546 Node* actual_construct = NodeProperties::GetValueInput(node, 0); | 554 Node* actual_construct = NodeProperties::GetValueInput(node, 0); |
547 Node* original_construct = NodeProperties::GetValueInput(node, arity - 1); | 555 Node* original_construct = NodeProperties::GetValueInput(node, arity - 1); |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
777 } | 785 } |
778 } | 786 } |
779 } | 787 } |
780 | 788 |
781 | 789 |
782 void JSGenericLowering::LowerJSForInStep(Node* node) { | 790 void JSGenericLowering::LowerJSForInStep(Node* node) { |
783 ReplaceWithRuntimeCall(node, Runtime::kForInStep); | 791 ReplaceWithRuntimeCall(node, Runtime::kForInStep); |
784 } | 792 } |
785 | 793 |
786 | 794 |
| 795 void JSGenericLowering::LowerJSYield(Node* node) { UNIMPLEMENTED(); } |
| 796 |
| 797 |
787 void JSGenericLowering::LowerJSStackCheck(Node* node) { | 798 void JSGenericLowering::LowerJSStackCheck(Node* node) { |
788 Node* effect = NodeProperties::GetEffectInput(node); | 799 Node* effect = NodeProperties::GetEffectInput(node); |
789 Node* control = NodeProperties::GetControlInput(node); | 800 Node* control = NodeProperties::GetControlInput(node); |
790 | 801 |
791 Node* limit = graph()->NewNode( | 802 Node* limit = graph()->NewNode( |
792 machine()->Load(kMachPtr), | 803 machine()->Load(kMachPtr), |
793 jsgraph()->ExternalConstant( | 804 jsgraph()->ExternalConstant( |
794 ExternalReference::address_of_stack_limit(isolate())), | 805 ExternalReference::address_of_stack_limit(isolate())), |
795 jsgraph()->IntPtrConstant(0), effect, control); | 806 jsgraph()->IntPtrConstant(0), effect, control); |
796 Node* pointer = graph()->NewNode(machine()->LoadStackPointer()); | 807 Node* pointer = graph()->NewNode(machine()->LoadStackPointer()); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
841 } | 852 } |
842 | 853 |
843 | 854 |
844 MachineOperatorBuilder* JSGenericLowering::machine() const { | 855 MachineOperatorBuilder* JSGenericLowering::machine() const { |
845 return jsgraph()->machine(); | 856 return jsgraph()->machine(); |
846 } | 857 } |
847 | 858 |
848 } // namespace compiler | 859 } // namespace compiler |
849 } // namespace internal | 860 } // namespace internal |
850 } // namespace v8 | 861 } // namespace v8 |
OLD | NEW |