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/interpreter/interpreter-assembler.h" | 5 #include "src/interpreter/interpreter-assembler.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <ostream> | 8 #include <ostream> |
9 | 9 |
10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 Bytecode bytecode, | 26 Bytecode bytecode, |
27 OperandScale operand_scale) | 27 OperandScale operand_scale) |
28 : compiler::CodeStubAssembler(isolate, zone, | 28 : compiler::CodeStubAssembler(isolate, zone, |
29 InterpreterDispatchDescriptor(isolate), | 29 InterpreterDispatchDescriptor(isolate), |
30 Code::ComputeFlags(Code::BYTECODE_HANDLER), | 30 Code::ComputeFlags(Code::BYTECODE_HANDLER), |
31 Bytecodes::ToString(bytecode), 0), | 31 Bytecodes::ToString(bytecode), 0), |
32 bytecode_(bytecode), | 32 bytecode_(bytecode), |
33 operand_scale_(operand_scale), | 33 operand_scale_(operand_scale), |
34 accumulator_(this, MachineRepresentation::kTagged), | 34 accumulator_(this, MachineRepresentation::kTagged), |
35 accumulator_use_(AccumulatorUse::kNone), | 35 accumulator_use_(AccumulatorUse::kNone), |
36 context_(this, MachineRepresentation::kTagged), | |
37 bytecode_array_(this, MachineRepresentation::kTagged), | 36 bytecode_array_(this, MachineRepresentation::kTagged), |
38 disable_stack_check_across_call_(false), | 37 disable_stack_check_across_call_(false), |
39 stack_pointer_before_call_(nullptr) { | 38 stack_pointer_before_call_(nullptr) { |
40 accumulator_.Bind( | 39 accumulator_.Bind( |
41 Parameter(InterpreterDispatchDescriptor::kAccumulatorParameter)); | 40 Parameter(InterpreterDispatchDescriptor::kAccumulatorParameter)); |
42 context_.Bind(Parameter(InterpreterDispatchDescriptor::kContextParameter)); | |
43 bytecode_array_.Bind( | 41 bytecode_array_.Bind( |
44 Parameter(InterpreterDispatchDescriptor::kBytecodeArrayParameter)); | 42 Parameter(InterpreterDispatchDescriptor::kBytecodeArrayParameter)); |
45 if (FLAG_trace_ignition) { | 43 if (FLAG_trace_ignition) { |
46 TraceBytecode(Runtime::kInterpreterTraceBytecodeEntry); | 44 TraceBytecode(Runtime::kInterpreterTraceBytecodeEntry); |
47 } | 45 } |
48 } | 46 } |
49 | 47 |
50 InterpreterAssembler::~InterpreterAssembler() { | 48 InterpreterAssembler::~InterpreterAssembler() { |
51 // If the following check fails the handler does not use the | 49 // If the following check fails the handler does not use the |
52 // accumulator in the way described in the bytecode definitions in | 50 // accumulator in the way described in the bytecode definitions in |
(...skipping 10 matching lines...) Expand all Loading... |
63 accumulator_use_ = accumulator_use_ | AccumulatorUse::kRead; | 61 accumulator_use_ = accumulator_use_ | AccumulatorUse::kRead; |
64 return GetAccumulatorUnchecked(); | 62 return GetAccumulatorUnchecked(); |
65 } | 63 } |
66 | 64 |
67 void InterpreterAssembler::SetAccumulator(Node* value) { | 65 void InterpreterAssembler::SetAccumulator(Node* value) { |
68 DCHECK(Bytecodes::WritesAccumulator(bytecode_)); | 66 DCHECK(Bytecodes::WritesAccumulator(bytecode_)); |
69 accumulator_use_ = accumulator_use_ | AccumulatorUse::kWrite; | 67 accumulator_use_ = accumulator_use_ | AccumulatorUse::kWrite; |
70 accumulator_.Bind(value); | 68 accumulator_.Bind(value); |
71 } | 69 } |
72 | 70 |
73 Node* InterpreterAssembler::GetContext() { return context_.value(); } | 71 Node* InterpreterAssembler::GetContext() { |
| 72 return LoadRegister(Register::current_context()); |
| 73 } |
74 | 74 |
75 void InterpreterAssembler::SetContext(Node* value) { | 75 void InterpreterAssembler::SetContext(Node* value) { |
76 StoreRegister(value, Register::current_context()); | 76 StoreRegister(value, Register::current_context()); |
77 context_.Bind(value); | |
78 } | 77 } |
79 | 78 |
80 Node* InterpreterAssembler::BytecodeOffset() { | 79 Node* InterpreterAssembler::BytecodeOffset() { |
81 return Parameter(InterpreterDispatchDescriptor::kBytecodeOffsetParameter); | 80 return Parameter(InterpreterDispatchDescriptor::kBytecodeOffsetParameter); |
82 } | 81 } |
83 | 82 |
84 Node* InterpreterAssembler::RegisterFileRawPointer() { | 83 Node* InterpreterAssembler::RegisterFileRawPointer() { |
85 return Parameter(InterpreterDispatchDescriptor::kRegisterFileParameter); | 84 return Parameter(InterpreterDispatchDescriptor::kRegisterFileParameter); |
86 } | 85 } |
87 | 86 |
88 Node* InterpreterAssembler::BytecodeArrayTaggedPointer() { | 87 Node* InterpreterAssembler::BytecodeArrayTaggedPointer() { |
89 return bytecode_array_.value(); | 88 return bytecode_array_.value(); |
90 } | 89 } |
91 | 90 |
92 Node* InterpreterAssembler::DispatchTableRawPointer() { | 91 Node* InterpreterAssembler::DispatchTableRawPointer() { |
93 return Parameter(InterpreterDispatchDescriptor::kDispatchTableParameter); | 92 return Parameter(InterpreterDispatchDescriptor::kDispatchTableParameter); |
94 } | 93 } |
95 | 94 |
96 Node* InterpreterAssembler::RegisterLocation(Node* reg_index) { | 95 Node* InterpreterAssembler::RegisterLocation(Node* reg_index) { |
97 return IntPtrAdd(RegisterFileRawPointer(), RegisterFrameOffset(reg_index)); | 96 return IntPtrAdd(RegisterFileRawPointer(), RegisterFrameOffset(reg_index)); |
98 } | 97 } |
99 | 98 |
100 Node* InterpreterAssembler::LoadRegister(int offset) { | 99 Node* InterpreterAssembler::LoadRegister(int offset) { |
101 return Load(MachineType::AnyTagged(), RegisterFileRawPointer(), | 100 return Load(MachineType::AnyTagged(), RegisterFileRawPointer(), |
102 IntPtrConstant(offset)); | 101 IntPtrConstant(offset)); |
103 } | 102 } |
104 | 103 |
105 Node* InterpreterAssembler::LoadRegister(Register reg) { | 104 Node* InterpreterAssembler::LoadRegister(Register reg) { |
106 return LoadRegister(IntPtrConstant(-reg.index())); | 105 return LoadRegister(-reg.index() << kPointerSizeLog2); |
107 } | 106 } |
108 | 107 |
109 Node* InterpreterAssembler::RegisterFrameOffset(Node* index) { | 108 Node* InterpreterAssembler::RegisterFrameOffset(Node* index) { |
110 return WordShl(index, kPointerSizeLog2); | 109 return WordShl(index, kPointerSizeLog2); |
111 } | 110 } |
112 | 111 |
113 Node* InterpreterAssembler::LoadRegister(Node* reg_index) { | 112 Node* InterpreterAssembler::LoadRegister(Node* reg_index) { |
114 return Load(MachineType::AnyTagged(), RegisterFileRawPointer(), | 113 return Load(MachineType::AnyTagged(), RegisterFileRawPointer(), |
115 RegisterFrameOffset(reg_index)); | 114 RegisterFrameOffset(reg_index)); |
116 } | 115 } |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 } | 573 } |
575 | 574 |
576 void InterpreterAssembler::DispatchToBytecodeHandlerEntry( | 575 void InterpreterAssembler::DispatchToBytecodeHandlerEntry( |
577 Node* handler_entry, Node* bytecode_offset) { | 576 Node* handler_entry, Node* bytecode_offset) { |
578 if (FLAG_trace_ignition) { | 577 if (FLAG_trace_ignition) { |
579 TraceBytecode(Runtime::kInterpreterTraceBytecodeExit); | 578 TraceBytecode(Runtime::kInterpreterTraceBytecodeExit); |
580 } | 579 } |
581 | 580 |
582 InterpreterDispatchDescriptor descriptor(isolate()); | 581 InterpreterDispatchDescriptor descriptor(isolate()); |
583 Node* args[] = {GetAccumulatorUnchecked(), RegisterFileRawPointer(), | 582 Node* args[] = {GetAccumulatorUnchecked(), RegisterFileRawPointer(), |
584 bytecode_offset, BytecodeArrayTaggedPointer(), | 583 bytecode_offset, BytecodeArrayTaggedPointer(), |
585 DispatchTableRawPointer(), GetContext()}; | 584 DispatchTableRawPointer()}; |
586 TailCallBytecodeDispatch(descriptor, handler_entry, args); | 585 TailCallBytecodeDispatch(descriptor, handler_entry, args); |
587 } | 586 } |
588 | 587 |
589 void InterpreterAssembler::DispatchWide(OperandScale operand_scale) { | 588 void InterpreterAssembler::DispatchWide(OperandScale operand_scale) { |
590 // Dispatching a wide bytecode requires treating the prefix | 589 // Dispatching a wide bytecode requires treating the prefix |
591 // bytecode a base pointer into the dispatch table and dispatching | 590 // bytecode a base pointer into the dispatch table and dispatching |
592 // the bytecode that follows relative to this base. | 591 // the bytecode that follows relative to this base. |
593 // | 592 // |
594 // Indices 0-255 correspond to bytecodes with operand_scale == 0 | 593 // Indices 0-255 correspond to bytecodes with operand_scale == 0 |
595 // Indices 256-511 correspond to bytecodes with operand_scale == 1 | 594 // Indices 256-511 correspond to bytecodes with operand_scale == 1 |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
727 V8_TARGET_ARCH_S390 | 726 V8_TARGET_ARCH_S390 |
728 return true; | 727 return true; |
729 #else | 728 #else |
730 #error "Unknown Architecture" | 729 #error "Unknown Architecture" |
731 #endif | 730 #endif |
732 } | 731 } |
733 | 732 |
734 } // namespace interpreter | 733 } // namespace interpreter |
735 } // namespace internal | 734 } // namespace internal |
736 } // namespace v8 | 735 } // namespace v8 |
OLD | NEW |