| 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/ast/ast.h" | 7 #include "src/ast/ast.h" |
| 8 #include "src/ast/scopes.h" | 8 #include "src/ast/scopes.h" |
| 9 #include "src/compilation-info.h" | 9 #include "src/compilation-info.h" |
| 10 #include "src/compiler/bytecode-branch-analysis.h" | 10 #include "src/compiler/bytecode-branch-analysis.h" |
| (...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 802 // available in bytecode array. update this code when the implementation | 802 // available in bytecode array. update this code when the implementation |
| 803 // changes. | 803 // changes. |
| 804 const Operator* op = javascript()->LoadContext( | 804 const Operator* op = javascript()->LoadContext( |
| 805 bytecode_iterator().GetUnsignedImmediateOperand(2), | 805 bytecode_iterator().GetUnsignedImmediateOperand(2), |
| 806 bytecode_iterator().GetIndexOperand(1), false); | 806 bytecode_iterator().GetIndexOperand(1), false); |
| 807 Node* context = | 807 Node* context = |
| 808 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); | 808 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
| 809 return NewNode(op, context); | 809 return NewNode(op, context); |
| 810 } | 810 } |
| 811 | 811 |
| 812 Node* BytecodeGraphBuilder::BuildLoadCurrentContextSlot() { |
| 813 // TODO(mythria): immutable flag is also set to false. This information is not |
| 814 // available in bytecode array. update this code when the implementation |
| 815 // changes. |
| 816 const Operator* op = javascript()->LoadContext( |
| 817 0, bytecode_iterator().GetIndexOperand(0), false); |
| 818 Node* context = environment()->Context(); |
| 819 return NewNode(op, context); |
| 820 } |
| 821 |
| 812 void BytecodeGraphBuilder::VisitLdaContextSlot() { | 822 void BytecodeGraphBuilder::VisitLdaContextSlot() { |
| 813 Node* node = BuildLoadContextSlot(); | 823 Node* node = BuildLoadContextSlot(); |
| 814 environment()->BindAccumulator(node); | 824 environment()->BindAccumulator(node); |
| 815 } | 825 } |
| 816 | 826 |
| 827 void BytecodeGraphBuilder::VisitLdaCurrentContextSlot() { |
| 828 Node* node = BuildLoadCurrentContextSlot(); |
| 829 environment()->BindAccumulator(node); |
| 830 } |
| 831 |
| 817 void BytecodeGraphBuilder::VisitLdrContextSlot() { | 832 void BytecodeGraphBuilder::VisitLdrContextSlot() { |
| 818 Node* node = BuildLoadContextSlot(); | 833 Node* node = BuildLoadContextSlot(); |
| 819 environment()->BindRegister(bytecode_iterator().GetRegisterOperand(3), node); | 834 environment()->BindRegister(bytecode_iterator().GetRegisterOperand(3), node); |
| 820 } | 835 } |
| 821 | 836 |
| 837 void BytecodeGraphBuilder::VisitLdrCurrentContextSlot() { |
| 838 Node* node = BuildLoadCurrentContextSlot(); |
| 839 environment()->BindRegister(bytecode_iterator().GetRegisterOperand(1), node); |
| 840 } |
| 841 |
| 822 void BytecodeGraphBuilder::VisitStaContextSlot() { | 842 void BytecodeGraphBuilder::VisitStaContextSlot() { |
| 823 const Operator* op = javascript()->StoreContext( | 843 const Operator* op = javascript()->StoreContext( |
| 824 bytecode_iterator().GetUnsignedImmediateOperand(2), | 844 bytecode_iterator().GetUnsignedImmediateOperand(2), |
| 825 bytecode_iterator().GetIndexOperand(1)); | 845 bytecode_iterator().GetIndexOperand(1)); |
| 826 Node* context = | 846 Node* context = |
| 827 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); | 847 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
| 828 Node* value = environment()->LookupAccumulator(); | 848 Node* value = environment()->LookupAccumulator(); |
| 829 NewNode(op, context, value); | 849 NewNode(op, context, value); |
| 830 } | 850 } |
| 831 | 851 |
| 852 void BytecodeGraphBuilder::VisitStaCurrentContextSlot() { |
| 853 const Operator* op = |
| 854 javascript()->StoreContext(0, bytecode_iterator().GetIndexOperand(0)); |
| 855 Node* context = environment()->Context(); |
| 856 Node* value = environment()->LookupAccumulator(); |
| 857 NewNode(op, context, value); |
| 858 } |
| 859 |
| 832 void BytecodeGraphBuilder::BuildLdaLookupSlot(TypeofMode typeof_mode) { | 860 void BytecodeGraphBuilder::BuildLdaLookupSlot(TypeofMode typeof_mode) { |
| 833 PrepareEagerCheckpoint(); | 861 PrepareEagerCheckpoint(); |
| 834 Node* name = | 862 Node* name = |
| 835 jsgraph()->Constant(bytecode_iterator().GetConstantForIndexOperand(0)); | 863 jsgraph()->Constant(bytecode_iterator().GetConstantForIndexOperand(0)); |
| 836 const Operator* op = | 864 const Operator* op = |
| 837 javascript()->CallRuntime(typeof_mode == TypeofMode::NOT_INSIDE_TYPEOF | 865 javascript()->CallRuntime(typeof_mode == TypeofMode::NOT_INSIDE_TYPEOF |
| 838 ? Runtime::kLoadLookupSlot | 866 ? Runtime::kLoadLookupSlot |
| 839 : Runtime::kLoadLookupSlotInsideTypeof); | 867 : Runtime::kLoadLookupSlotInsideTypeof); |
| 840 Node* value = NewNode(op, name); | 868 Node* value = NewNode(op, name); |
| 841 environment()->BindAccumulator(value, Environment::kAttachFrameState); | 869 environment()->BindAccumulator(value, Environment::kAttachFrameState); |
| (...skipping 1363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2205 source_positions_->set_current_position(it->source_position()); | 2233 source_positions_->set_current_position(it->source_position()); |
| 2206 it->Advance(); | 2234 it->Advance(); |
| 2207 } else { | 2235 } else { |
| 2208 DCHECK_GT(it->code_offset(), offset); | 2236 DCHECK_GT(it->code_offset(), offset); |
| 2209 } | 2237 } |
| 2210 } | 2238 } |
| 2211 | 2239 |
| 2212 } // namespace compiler | 2240 } // namespace compiler |
| 2213 } // namespace internal | 2241 } // namespace internal |
| 2214 } // namespace v8 | 2242 } // namespace v8 |
| OLD | NEW |