OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/compiler/bytecode-graph-builder.h" | 5 #include "src/compiler/bytecode-graph-builder.h" |
6 | 6 |
7 #include "src/compiler/bytecode-branch-analysis.h" | 7 #include "src/compiler/bytecode-branch-analysis.h" |
8 #include "src/compiler/linkage.h" | 8 #include "src/compiler/linkage.h" |
9 #include "src/compiler/operator-properties.h" | 9 #include "src/compiler/operator-properties.h" |
10 #include "src/interpreter/bytecodes.h" | 10 #include "src/interpreter/bytecodes.h" |
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 if (!function_closure_.is_set()) { | 485 if (!function_closure_.is_set()) { |
486 int index = Linkage::kJSCallClosureParamIndex; | 486 int index = Linkage::kJSCallClosureParamIndex; |
487 const Operator* op = common()->Parameter(index, "%closure"); | 487 const Operator* op = common()->Parameter(index, "%closure"); |
488 Node* node = NewNode(op, graph()->start()); | 488 Node* node = NewNode(op, graph()->start()); |
489 function_closure_.set(node); | 489 function_closure_.set(node); |
490 } | 490 } |
491 return function_closure_.get(); | 491 return function_closure_.get(); |
492 } | 492 } |
493 | 493 |
494 | 494 |
495 Node* BytecodeGraphBuilder::BuildLoadImmutableObjectField(Node* object, | |
496 int offset) { | |
497 return graph()->NewNode(jsgraph()->machine()->Load(MachineType::AnyTagged()), | |
498 object, | |
499 jsgraph()->IntPtrConstant(offset - kHeapObjectTag), | |
500 graph()->start(), graph()->start()); | |
501 } | |
502 | |
503 | |
504 Node* BytecodeGraphBuilder::BuildLoadNativeContextField(int index) { | 495 Node* BytecodeGraphBuilder::BuildLoadNativeContextField(int index) { |
505 const Operator* op = | 496 const Operator* op = |
506 javascript()->LoadContext(0, Context::NATIVE_CONTEXT_INDEX, true); | 497 javascript()->LoadContext(0, Context::NATIVE_CONTEXT_INDEX, true); |
507 Node* native_context = NewNode(op, environment()->Context()); | 498 Node* native_context = NewNode(op, environment()->Context()); |
508 return NewNode(javascript()->LoadContext(0, index, true), native_context); | 499 return NewNode(javascript()->LoadContext(0, index, true), native_context); |
509 } | 500 } |
510 | 501 |
511 | 502 |
512 Node* BytecodeGraphBuilder::BuildLoadFeedbackVector() { | |
513 if (!feedback_vector_.is_set()) { | |
514 Node* closure = GetFunctionClosure(); | |
515 Node* shared = BuildLoadImmutableObjectField( | |
516 closure, JSFunction::kSharedFunctionInfoOffset); | |
517 Node* vector = BuildLoadImmutableObjectField( | |
518 shared, SharedFunctionInfo::kFeedbackVectorOffset); | |
519 feedback_vector_.set(vector); | |
520 } | |
521 return feedback_vector_.get(); | |
522 } | |
523 | |
524 | |
525 VectorSlotPair BytecodeGraphBuilder::CreateVectorSlotPair(int slot_id) { | 503 VectorSlotPair BytecodeGraphBuilder::CreateVectorSlotPair(int slot_id) { |
526 Handle<TypeFeedbackVector> feedback_vector = info()->feedback_vector(); | 504 Handle<TypeFeedbackVector> feedback_vector = info()->feedback_vector(); |
527 FeedbackVectorSlot slot; | 505 FeedbackVectorSlot slot; |
528 if (slot_id >= TypeFeedbackVector::kReservedIndexCount) { | 506 if (slot_id >= TypeFeedbackVector::kReservedIndexCount) { |
529 slot = feedback_vector->ToSlot(slot_id); | 507 slot = feedback_vector->ToSlot(slot_id); |
530 } | 508 } |
531 return VectorSlotPair(feedback_vector, slot); | 509 return VectorSlotPair(feedback_vector, slot); |
532 } | 510 } |
533 | 511 |
534 bool BytecodeGraphBuilder::CreateGraph() { | 512 bool BytecodeGraphBuilder::CreateGraph() { |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
754 Node* context = | 732 Node* context = |
755 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); | 733 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
756 Node* value = environment()->LookupAccumulator(); | 734 Node* value = environment()->LookupAccumulator(); |
757 NewNode(op, context, value); | 735 NewNode(op, context, value); |
758 } | 736 } |
759 | 737 |
760 void BytecodeGraphBuilder::VisitStaContextSlotWide() { VisitStaContextSlot(); } | 738 void BytecodeGraphBuilder::VisitStaContextSlotWide() { VisitStaContextSlot(); } |
761 | 739 |
762 void BytecodeGraphBuilder::BuildLdaLookupSlot(TypeofMode typeof_mode) { | 740 void BytecodeGraphBuilder::BuildLdaLookupSlot(TypeofMode typeof_mode) { |
763 FrameStateBeforeAndAfter states(this); | 741 FrameStateBeforeAndAfter states(this); |
764 Handle<String> name = | 742 Node* name = |
765 Handle<String>::cast(bytecode_iterator().GetConstantForIndexOperand(0)); | 743 jsgraph()->Constant(bytecode_iterator().GetConstantForIndexOperand(0)); |
766 const Operator* op = javascript()->LoadDynamic(name, typeof_mode); | 744 const Operator* op = |
767 Node* value = | 745 javascript()->CallRuntime(typeof_mode == TypeofMode::NOT_INSIDE_TYPEOF |
768 NewNode(op, BuildLoadFeedbackVector(), environment()->Context()); | 746 ? Runtime::kLoadLookupSlot |
| 747 : Runtime::kLoadLookupSlotInsideTypeof); |
| 748 Node* value = NewNode(op, name); |
769 environment()->BindAccumulator(value, &states); | 749 environment()->BindAccumulator(value, &states); |
770 } | 750 } |
771 | 751 |
772 void BytecodeGraphBuilder::VisitLdaLookupSlot() { | 752 void BytecodeGraphBuilder::VisitLdaLookupSlot() { |
773 BuildLdaLookupSlot(TypeofMode::NOT_INSIDE_TYPEOF); | 753 BuildLdaLookupSlot(TypeofMode::NOT_INSIDE_TYPEOF); |
774 } | 754 } |
775 | 755 |
776 void BytecodeGraphBuilder::VisitLdaLookupSlotInsideTypeof() { | 756 void BytecodeGraphBuilder::VisitLdaLookupSlotInsideTypeof() { |
777 BuildLdaLookupSlot(TypeofMode::INSIDE_TYPEOF); | 757 BuildLdaLookupSlot(TypeofMode::INSIDE_TYPEOF); |
778 } | 758 } |
779 | 759 |
780 void BytecodeGraphBuilder::BuildStaLookupSlot(LanguageMode language_mode) { | 760 void BytecodeGraphBuilder::BuildStaLookupSlot(LanguageMode language_mode) { |
781 FrameStateBeforeAndAfter states(this); | 761 FrameStateBeforeAndAfter states(this); |
782 Node* value = environment()->LookupAccumulator(); | 762 Node* value = environment()->LookupAccumulator(); |
783 Node* name = | 763 Node* name = |
784 jsgraph()->Constant(bytecode_iterator().GetConstantForIndexOperand(0)); | 764 jsgraph()->Constant(bytecode_iterator().GetConstantForIndexOperand(0)); |
785 Node* language = jsgraph()->Constant(language_mode); | 765 const Operator* op = javascript()->CallRuntime( |
786 const Operator* op = javascript()->CallRuntime(Runtime::kStoreLookupSlot); | 766 is_strict(language_mode) ? Runtime::kStoreLookupSlot_Strict |
787 Node* store = NewNode(op, value, environment()->Context(), name, language); | 767 : Runtime::kStoreLookupSlot_Sloppy); |
| 768 Node* store = NewNode(op, name, value); |
788 environment()->BindAccumulator(store, &states); | 769 environment()->BindAccumulator(store, &states); |
789 } | 770 } |
790 | 771 |
791 void BytecodeGraphBuilder::VisitLdaLookupSlotWide() { VisitLdaLookupSlot(); } | 772 void BytecodeGraphBuilder::VisitLdaLookupSlotWide() { VisitLdaLookupSlot(); } |
792 | 773 |
793 void BytecodeGraphBuilder::VisitLdaLookupSlotInsideTypeofWide() { | 774 void BytecodeGraphBuilder::VisitLdaLookupSlotInsideTypeofWide() { |
794 VisitLdaLookupSlotInsideTypeof(); | 775 VisitLdaLookupSlotInsideTypeof(); |
795 } | 776 } |
796 | 777 |
797 void BytecodeGraphBuilder::VisitStaLookupSlotSloppy() { | 778 void BytecodeGraphBuilder::VisitStaLookupSlotSloppy() { |
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1321 } | 1302 } |
1322 | 1303 |
1323 void BytecodeGraphBuilder::VisitDeletePropertySloppy() { | 1304 void BytecodeGraphBuilder::VisitDeletePropertySloppy() { |
1324 BuildDelete(LanguageMode::SLOPPY); | 1305 BuildDelete(LanguageMode::SLOPPY); |
1325 } | 1306 } |
1326 | 1307 |
1327 void BytecodeGraphBuilder::VisitDeleteLookupSlot() { | 1308 void BytecodeGraphBuilder::VisitDeleteLookupSlot() { |
1328 FrameStateBeforeAndAfter states(this); | 1309 FrameStateBeforeAndAfter states(this); |
1329 Node* name = environment()->LookupAccumulator(); | 1310 Node* name = environment()->LookupAccumulator(); |
1330 const Operator* op = javascript()->CallRuntime(Runtime::kDeleteLookupSlot); | 1311 const Operator* op = javascript()->CallRuntime(Runtime::kDeleteLookupSlot); |
1331 Node* result = NewNode(op, environment()->Context(), name); | 1312 Node* result = NewNode(op, name); |
1332 environment()->BindAccumulator(result, &states); | 1313 environment()->BindAccumulator(result, &states); |
1333 } | 1314 } |
1334 | 1315 |
1335 void BytecodeGraphBuilder::BuildCompareOp(const Operator* js_op) { | 1316 void BytecodeGraphBuilder::BuildCompareOp(const Operator* js_op) { |
1336 FrameStateBeforeAndAfter states(this); | 1317 FrameStateBeforeAndAfter states(this); |
1337 Node* left = | 1318 Node* left = |
1338 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); | 1319 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
1339 Node* right = environment()->LookupAccumulator(); | 1320 Node* right = environment()->LookupAccumulator(); |
1340 Node* node = NewNode(js_op, left, right); | 1321 Node* node = NewNode(js_op, left, right); |
1341 environment()->BindAccumulator(node, &states); | 1322 environment()->BindAccumulator(node, &states); |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1813 // Phi does not exist yet, introduce one. | 1794 // Phi does not exist yet, introduce one. |
1814 value = NewPhi(inputs, value, control); | 1795 value = NewPhi(inputs, value, control); |
1815 value->ReplaceInput(inputs - 1, other); | 1796 value->ReplaceInput(inputs - 1, other); |
1816 } | 1797 } |
1817 return value; | 1798 return value; |
1818 } | 1799 } |
1819 | 1800 |
1820 } // namespace compiler | 1801 } // namespace compiler |
1821 } // namespace internal | 1802 } // namespace internal |
1822 } // namespace v8 | 1803 } // namespace v8 |
OLD | NEW |