| 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/interpreter-assembler.h" |    5 #include "src/compiler/interpreter-assembler.h" | 
|    6  |    6  | 
|    7 #include <ostream> |    7 #include <ostream> | 
|    8  |    8  | 
 |    9 #include "src/code-factory.h" | 
|    9 #include "src/compiler/graph.h" |   10 #include "src/compiler/graph.h" | 
|   10 #include "src/compiler/instruction-selector.h" |   11 #include "src/compiler/instruction-selector.h" | 
|   11 #include "src/compiler/linkage.h" |   12 #include "src/compiler/linkage.h" | 
|   12 #include "src/compiler/machine-type.h" |   13 #include "src/compiler/machine-type.h" | 
|   13 #include "src/compiler/pipeline.h" |   14 #include "src/compiler/pipeline.h" | 
|   14 #include "src/compiler/raw-machine-assembler.h" |   15 #include "src/compiler/raw-machine-assembler.h" | 
|   15 #include "src/compiler/schedule.h" |   16 #include "src/compiler/schedule.h" | 
|   16 #include "src/frames.h" |   17 #include "src/frames.h" | 
|   17 #include "src/interface-descriptors.h" |   18 #include "src/interface-descriptors.h" | 
|   18 #include "src/interpreter/bytecodes.h" |   19 #include "src/interpreter/bytecodes.h" | 
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   95       Linkage::kInterpreterBytecodeOffsetParameter); |   96       Linkage::kInterpreterBytecodeOffsetParameter); | 
|   96 } |   97 } | 
|   97  |   98  | 
|   98  |   99  | 
|   99 Node* InterpreterAssembler::DispatchTableRawPointer() { |  100 Node* InterpreterAssembler::DispatchTableRawPointer() { | 
|  100   return raw_assembler_->Parameter(Linkage::kInterpreterDispatchTableParameter); |  101   return raw_assembler_->Parameter(Linkage::kInterpreterDispatchTableParameter); | 
|  101 } |  102 } | 
|  102  |  103  | 
|  103  |  104  | 
|  104 Node* InterpreterAssembler::RegisterFrameOffset(Node* index) { |  105 Node* InterpreterAssembler::RegisterFrameOffset(Node* index) { | 
|  105   return raw_assembler_->WordShl(index, Int32Constant(kPointerSizeLog2)); |  106   return WordShl(index, kPointerSizeLog2); | 
|  106 } |  107 } | 
|  107  |  108  | 
|  108  |  109  | 
 |  110 Node* InterpreterAssembler::RegisterLocation(Node* reg_index) { | 
 |  111   return IntPtrAdd(RegisterFileRawPointer(), RegisterFrameOffset(reg_index)); | 
 |  112 } | 
 |  113  | 
 |  114  | 
|  109 Node* InterpreterAssembler::LoadRegister(Node* reg_index) { |  115 Node* InterpreterAssembler::LoadRegister(Node* reg_index) { | 
|  110   return raw_assembler_->Load(kMachAnyTagged, RegisterFileRawPointer(), |  116   return raw_assembler_->Load(kMachAnyTagged, RegisterFileRawPointer(), | 
|  111                               RegisterFrameOffset(reg_index)); |  117                               RegisterFrameOffset(reg_index)); | 
|  112 } |  118 } | 
|  113  |  119  | 
|  114  |  120  | 
|  115 Node* InterpreterAssembler::StoreRegister(Node* value, Node* reg_index) { |  121 Node* InterpreterAssembler::StoreRegister(Node* value, Node* reg_index) { | 
|  116   return raw_assembler_->Store(kMachAnyTagged, RegisterFileRawPointer(), |  122   return raw_assembler_->Store(kMachAnyTagged, RegisterFileRawPointer(), | 
|  117                                RegisterFrameOffset(reg_index), value); |  123                                RegisterFrameOffset(reg_index), value); | 
|  118 } |  124 } | 
|  119  |  125  | 
|  120  |  126  | 
|  121 Node* InterpreterAssembler::BytecodeOperand(int operand_index) { |  127 Node* InterpreterAssembler::BytecodeOperand(int operand_index) { | 
|  122   DCHECK_LT(operand_index, interpreter::Bytecodes::NumberOfOperands(bytecode_)); |  128   DCHECK_LT(operand_index, interpreter::Bytecodes::NumberOfOperands(bytecode_)); | 
|  123   return raw_assembler_->Load( |  129   return raw_assembler_->Load( | 
|  124       kMachUint8, BytecodeArrayTaggedPointer(), |  130       kMachUint8, BytecodeArrayTaggedPointer(), | 
|  125       raw_assembler_->IntPtrAdd(BytecodeOffset(), |  131       IntPtrAdd(BytecodeOffset(), Int32Constant(1 + operand_index))); | 
|  126                                 Int32Constant(1 + operand_index))); |  | 
|  127 } |  132 } | 
|  128  |  133  | 
|  129  |  134  | 
|  130 Node* InterpreterAssembler::BytecodeOperandSignExtended(int operand_index) { |  135 Node* InterpreterAssembler::BytecodeOperandSignExtended(int operand_index) { | 
|  131   DCHECK_LT(operand_index, interpreter::Bytecodes::NumberOfOperands(bytecode_)); |  136   DCHECK_LT(operand_index, interpreter::Bytecodes::NumberOfOperands(bytecode_)); | 
|  132   Node* load = raw_assembler_->Load( |  137   Node* load = raw_assembler_->Load( | 
|  133       kMachInt8, BytecodeArrayTaggedPointer(), |  138       kMachInt8, BytecodeArrayTaggedPointer(), | 
|  134       raw_assembler_->IntPtrAdd(BytecodeOffset(), |  139       IntPtrAdd(BytecodeOffset(), Int32Constant(1 + operand_index))); | 
|  135                                 Int32Constant(1 + operand_index))); |  | 
|  136   // Ensure that we sign extend to full pointer size |  140   // Ensure that we sign extend to full pointer size | 
|  137   if (kPointerSize == 8) { |  141   if (kPointerSize == 8) { | 
|  138     load = raw_assembler_->ChangeInt32ToInt64(load); |  142     load = raw_assembler_->ChangeInt32ToInt64(load); | 
|  139   } |  143   } | 
|  140   return load; |  144   return load; | 
|  141 } |  145 } | 
|  142  |  146  | 
|  143  |  147  | 
 |  148 Node* InterpreterAssembler::BytecodeOperandCount(int operand_index) { | 
 |  149   DCHECK_EQ(interpreter::OperandType::kCount, | 
 |  150             interpreter::Bytecodes::GetOperandType(bytecode_, operand_index)); | 
 |  151   return BytecodeOperand(operand_index); | 
 |  152 } | 
 |  153  | 
 |  154  | 
|  144 Node* InterpreterAssembler::BytecodeOperandImm8(int operand_index) { |  155 Node* InterpreterAssembler::BytecodeOperandImm8(int operand_index) { | 
|  145   DCHECK_EQ(interpreter::OperandType::kImm8, |  156   DCHECK_EQ(interpreter::OperandType::kImm8, | 
|  146             interpreter::Bytecodes::GetOperandType(bytecode_, operand_index)); |  157             interpreter::Bytecodes::GetOperandType(bytecode_, operand_index)); | 
|  147   return BytecodeOperandSignExtended(operand_index); |  158   return BytecodeOperandSignExtended(operand_index); | 
|  148 } |  159 } | 
|  149  |  160  | 
|  150  |  161  | 
|  151 Node* InterpreterAssembler::BytecodeOperandIdx(int operand_index) { |  162 Node* InterpreterAssembler::BytecodeOperandIdx(int operand_index) { | 
|  152   DCHECK_EQ(interpreter::OperandType::kIdx, |  163   DCHECK_EQ(interpreter::OperandType::kIdx, | 
|  153             interpreter::Bytecodes::GetOperandType(bytecode_, operand_index)); |  164             interpreter::Bytecodes::GetOperandType(bytecode_, operand_index)); | 
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  190 Node* InterpreterAssembler::SmiTag(Node* value) { |  201 Node* InterpreterAssembler::SmiTag(Node* value) { | 
|  191   return raw_assembler_->WordShl(value, SmiShiftBitsConstant()); |  202   return raw_assembler_->WordShl(value, SmiShiftBitsConstant()); | 
|  192 } |  203 } | 
|  193  |  204  | 
|  194  |  205  | 
|  195 Node* InterpreterAssembler::SmiUntag(Node* value) { |  206 Node* InterpreterAssembler::SmiUntag(Node* value) { | 
|  196   return raw_assembler_->WordSar(value, SmiShiftBitsConstant()); |  207   return raw_assembler_->WordSar(value, SmiShiftBitsConstant()); | 
|  197 } |  208 } | 
|  198  |  209  | 
|  199  |  210  | 
 |  211 Node* InterpreterAssembler::IntPtrAdd(Node* a, Node* b) { | 
 |  212   return raw_assembler_->IntPtrAdd(a, b); | 
 |  213 } | 
 |  214  | 
 |  215  | 
 |  216 Node* InterpreterAssembler::IntPtrSub(Node* a, Node* b) { | 
 |  217   return raw_assembler_->IntPtrSub(a, b); | 
 |  218 } | 
 |  219  | 
 |  220  | 
 |  221 Node* InterpreterAssembler::WordShl(Node* value, int shift) { | 
 |  222   return raw_assembler_->WordShl(value, Int32Constant(shift)); | 
 |  223 } | 
 |  224  | 
 |  225  | 
|  200 Node* InterpreterAssembler::LoadConstantPoolEntry(Node* index) { |  226 Node* InterpreterAssembler::LoadConstantPoolEntry(Node* index) { | 
|  201   Node* constant_pool = LoadObjectField(BytecodeArrayTaggedPointer(), |  227   Node* constant_pool = LoadObjectField(BytecodeArrayTaggedPointer(), | 
|  202                                         BytecodeArray::kConstantPoolOffset); |  228                                         BytecodeArray::kConstantPoolOffset); | 
|  203   Node* entry_offset = raw_assembler_->IntPtrAdd( |  229   Node* entry_offset = | 
|  204       IntPtrConstant(FixedArray::kHeaderSize - kHeapObjectTag), |  230       IntPtrAdd(IntPtrConstant(FixedArray::kHeaderSize - kHeapObjectTag), | 
|  205       raw_assembler_->WordShl(index, Int32Constant(kPointerSizeLog2))); |  231                 WordShl(index, kPointerSizeLog2)); | 
|  206   return raw_assembler_->Load(kMachAnyTagged, constant_pool, entry_offset); |  232   return raw_assembler_->Load(kMachAnyTagged, constant_pool, entry_offset); | 
|  207 } |  233 } | 
|  208  |  234  | 
|  209  |  235  | 
|  210 Node* InterpreterAssembler::LoadObjectField(Node* object, int offset) { |  236 Node* InterpreterAssembler::LoadObjectField(Node* object, int offset) { | 
|  211   return raw_assembler_->Load(kMachAnyTagged, object, |  237   return raw_assembler_->Load(kMachAnyTagged, object, | 
|  212                               IntPtrConstant(offset - kHeapObjectTag)); |  238                               IntPtrConstant(offset - kHeapObjectTag)); | 
|  213 } |  239 } | 
|  214  |  240  | 
|  215  |  241  | 
| (...skipping 13 matching lines...) Expand all  Loading... | 
|  229       kMachAnyTagged, RegisterFileRawPointer(), |  255       kMachAnyTagged, RegisterFileRawPointer(), | 
|  230       IntPtrConstant(InterpreterFrameConstants::kFunctionFromRegisterPointer)); |  256       IntPtrConstant(InterpreterFrameConstants::kFunctionFromRegisterPointer)); | 
|  231   Node* shared_info = |  257   Node* shared_info = | 
|  232       LoadObjectField(function, JSFunction::kSharedFunctionInfoOffset); |  258       LoadObjectField(function, JSFunction::kSharedFunctionInfoOffset); | 
|  233   Node* vector = |  259   Node* vector = | 
|  234       LoadObjectField(shared_info, SharedFunctionInfo::kFeedbackVectorOffset); |  260       LoadObjectField(shared_info, SharedFunctionInfo::kFeedbackVectorOffset); | 
|  235   return vector; |  261   return vector; | 
|  236 } |  262 } | 
|  237  |  263  | 
|  238  |  264  | 
 |  265 Node* InterpreterAssembler::CallJS(Node* function, Node* first_arg, | 
 |  266                                    Node* arg_count) { | 
 |  267   Callable builtin = CodeFactory::PushArgsAndCall(isolate()); | 
 |  268   CallDescriptor* descriptor = Linkage::GetStubCallDescriptor( | 
 |  269       isolate(), zone(), builtin.descriptor(), 0, CallDescriptor::kNoFlags); | 
 |  270  | 
 |  271   Node* code_target = HeapConstant(builtin.code()); | 
 |  272  | 
 |  273   Node** args = zone()->NewArray<Node*>(4); | 
 |  274   args[0] = arg_count; | 
 |  275   args[1] = first_arg; | 
 |  276   args[2] = function; | 
 |  277   args[3] = ContextTaggedPointer(); | 
 |  278  | 
 |  279   return raw_assembler_->CallN(descriptor, code_target, args); | 
 |  280 } | 
 |  281  | 
 |  282  | 
|  239 Node* InterpreterAssembler::CallIC(CallInterfaceDescriptor descriptor, |  283 Node* InterpreterAssembler::CallIC(CallInterfaceDescriptor descriptor, | 
|  240                                    Node* target, Node** args) { |  284                                    Node* target, Node** args) { | 
|  241   CallDescriptor* call_descriptor = Linkage::GetStubCallDescriptor( |  285   CallDescriptor* call_descriptor = Linkage::GetStubCallDescriptor( | 
|  242       isolate(), zone(), descriptor, 0, CallDescriptor::kNoFlags); |  286       isolate(), zone(), descriptor, 0, CallDescriptor::kNoFlags); | 
|  243   return raw_assembler_->CallN(call_descriptor, target, args); |  287   return raw_assembler_->CallN(call_descriptor, target, args); | 
|  244 } |  288 } | 
|  245  |  289  | 
|  246  |  290  | 
|  247 Node* InterpreterAssembler::CallIC(CallInterfaceDescriptor descriptor, |  291 Node* InterpreterAssembler::CallIC(CallInterfaceDescriptor descriptor, | 
|  248                                    Node* target, Node* arg1, Node* arg2, |  292                                    Node* target, Node* arg1, Node* arg2, | 
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  295                    DispatchTableRawPointer(), |  339                    DispatchTableRawPointer(), | 
|  296                    ContextTaggedPointer() }; |  340                    ContextTaggedPointer() }; | 
|  297   Node* tail_call = raw_assembler_->TailCallN( |  341   Node* tail_call = raw_assembler_->TailCallN( | 
|  298       call_descriptor(), exit_trampoline_code_object, args); |  342       call_descriptor(), exit_trampoline_code_object, args); | 
|  299   // This should always be the end node. |  343   // This should always be the end node. | 
|  300   SetEndInput(tail_call); |  344   SetEndInput(tail_call); | 
|  301 } |  345 } | 
|  302  |  346  | 
|  303  |  347  | 
|  304 Node* InterpreterAssembler::Advance(int delta) { |  348 Node* InterpreterAssembler::Advance(int delta) { | 
|  305   return raw_assembler_->IntPtrAdd(BytecodeOffset(), Int32Constant(delta)); |  349   return IntPtrAdd(BytecodeOffset(), Int32Constant(delta)); | 
|  306 } |  350 } | 
|  307  |  351  | 
|  308  |  352  | 
|  309 void InterpreterAssembler::Dispatch() { |  353 void InterpreterAssembler::Dispatch() { | 
|  310   Node* new_bytecode_offset = Advance(interpreter::Bytecodes::Size(bytecode_)); |  354   Node* new_bytecode_offset = Advance(interpreter::Bytecodes::Size(bytecode_)); | 
|  311   Node* target_bytecode = raw_assembler_->Load( |  355   Node* target_bytecode = raw_assembler_->Load( | 
|  312       kMachUint8, BytecodeArrayTaggedPointer(), new_bytecode_offset); |  356       kMachUint8, BytecodeArrayTaggedPointer(), new_bytecode_offset); | 
|  313  |  357  | 
|  314   // TODO(rmcilroy): Create a code target dispatch table to avoid conversion |  358   // TODO(rmcilroy): Create a code target dispatch table to avoid conversion | 
|  315   // from code object on every dispatch. |  359   // from code object on every dispatch. | 
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  368   return raw_assembler_->schedule(); |  412   return raw_assembler_->schedule(); | 
|  369 } |  413 } | 
|  370  |  414  | 
|  371  |  415  | 
|  372 Zone* InterpreterAssembler::zone() { return raw_assembler_->zone(); } |  416 Zone* InterpreterAssembler::zone() { return raw_assembler_->zone(); } | 
|  373  |  417  | 
|  374  |  418  | 
|  375 }  // namespace interpreter |  419 }  // namespace interpreter | 
|  376 }  // namespace internal |  420 }  // namespace internal | 
|  377 }  // namespace v8 |  421 }  // namespace v8 | 
| OLD | NEW |