| 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.h" | 5 #include "src/interpreter/interpreter.h" |
| 6 | 6 |
| 7 #include "src/code-factory.h" |
| 7 #include "src/compiler.h" | 8 #include "src/compiler.h" |
| 8 #include "src/compiler/interpreter-assembler.h" | 9 #include "src/compiler/interpreter-assembler.h" |
| 9 #include "src/factory.h" | 10 #include "src/factory.h" |
| 10 #include "src/interpreter/bytecode-generator.h" | 11 #include "src/interpreter/bytecode-generator.h" |
| 11 #include "src/interpreter/bytecodes.h" | 12 #include "src/interpreter/bytecodes.h" |
| 12 #include "src/zone.h" | 13 #include "src/zone.h" |
| 13 | 14 |
| 14 namespace v8 { | 15 namespace v8 { |
| 15 namespace internal { | 16 namespace internal { |
| 16 namespace interpreter { | 17 namespace interpreter { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 BYTECODE_LIST(GENERATE_CODE) | 55 BYTECODE_LIST(GENERATE_CODE) |
| 55 #undef GENERATE_CODE | 56 #undef GENERATE_CODE |
| 56 } | 57 } |
| 57 } | 58 } |
| 58 | 59 |
| 59 | 60 |
| 60 bool Interpreter::MakeBytecode(CompilationInfo* info) { | 61 bool Interpreter::MakeBytecode(CompilationInfo* info) { |
| 61 Handle<SharedFunctionInfo> shared_info = info->shared_info(); | 62 Handle<SharedFunctionInfo> shared_info = info->shared_info(); |
| 62 | 63 |
| 63 BytecodeGenerator generator(info->isolate(), info->zone()); | 64 BytecodeGenerator generator(info->isolate(), info->zone()); |
| 65 info->EnsureFeedbackVector(); |
| 64 Handle<BytecodeArray> bytecodes = generator.MakeBytecode(info); | 66 Handle<BytecodeArray> bytecodes = generator.MakeBytecode(info); |
| 65 if (FLAG_print_bytecode) { | 67 if (FLAG_print_bytecode) { |
| 66 bytecodes->Print(); | 68 bytecodes->Print(); |
| 67 } | 69 } |
| 68 | 70 |
| 69 DCHECK(shared_info->function_data()->IsUndefined()); | 71 DCHECK(shared_info->function_data()->IsUndefined()); |
| 70 if (!shared_info->function_data()->IsUndefined()) { | 72 if (!shared_info->function_data()->IsUndefined()) { |
| 71 return false; | 73 return false; |
| 72 } | 74 } |
| 73 | 75 |
| 74 shared_info->set_function_data(*bytecodes); | 76 shared_info->set_function_data(*bytecodes); |
| 75 info->SetCode(info->isolate()->builtins()->InterpreterEntryTrampoline()); | 77 info->SetCode(info->isolate()->builtins()->InterpreterEntryTrampoline()); |
| 76 info->EnsureFeedbackVector(); | |
| 77 return true; | 78 return true; |
| 78 } | 79 } |
| 79 | 80 |
| 80 | 81 |
| 81 bool Interpreter::IsInterpreterTableInitialized( | 82 bool Interpreter::IsInterpreterTableInitialized( |
| 82 Handle<FixedArray> handler_table) { | 83 Handle<FixedArray> handler_table) { |
| 83 DCHECK(handler_table->length() == static_cast<int>(Bytecode::kLast) + 1); | 84 DCHECK(handler_table->length() == static_cast<int>(Bytecode::kLast) + 1); |
| 84 return handler_table->get(0) != isolate_->heap()->undefined_value(); | 85 return handler_table->get(0) != isolate_->heap()->undefined_value(); |
| 85 } | 86 } |
| 86 | 87 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 // | 184 // |
| 184 // Store accumulator to register <dst>. | 185 // Store accumulator to register <dst>. |
| 185 void Interpreter::DoStar(compiler::InterpreterAssembler* assembler) { | 186 void Interpreter::DoStar(compiler::InterpreterAssembler* assembler) { |
| 186 Node* reg_index = __ BytecodeOperandReg(0); | 187 Node* reg_index = __ BytecodeOperandReg(0); |
| 187 Node* accumulator = __ GetAccumulator(); | 188 Node* accumulator = __ GetAccumulator(); |
| 188 __ StoreRegister(accumulator, reg_index); | 189 __ StoreRegister(accumulator, reg_index); |
| 189 __ Dispatch(); | 190 __ Dispatch(); |
| 190 } | 191 } |
| 191 | 192 |
| 192 | 193 |
| 194 void Interpreter::DoPropertyLoadIC(Callable ic, |
| 195 compiler::InterpreterAssembler* assembler) { |
| 196 Node* code_target = __ HeapConstant(ic.code()); |
| 197 Node* reg_index = __ BytecodeOperandReg(0); |
| 198 Node* object = __ LoadRegister(reg_index); |
| 199 Node* name = __ GetAccumulator(); |
| 200 Node* raw_slot = __ BytecodeOperandIdx(1); |
| 201 Node* smi_slot = __ SmiTag(raw_slot); |
| 202 Node* type_feedback_vector = __ LoadTypeFeedbackVector(); |
| 203 Node* result = __ CallIC(ic.descriptor(), code_target, object, name, smi_slot, |
| 204 type_feedback_vector); |
| 205 __ SetAccumulator(result); |
| 206 __ Dispatch(); |
| 207 } |
| 208 |
| 209 |
| 210 // LoadIC <object> <slot> |
| 211 // |
| 212 // Calls the LoadIC at FeedBackVector slot <slot> for <object> and the name |
| 213 // in the accumulator. |
| 214 void Interpreter::DoLoadIC(compiler::InterpreterAssembler* assembler) { |
| 215 Callable ic = CodeFactory::LoadICInOptimizedCode(isolate_, NOT_INSIDE_TYPEOF, |
| 216 SLOPPY, UNINITIALIZED); |
| 217 DoPropertyLoadIC(ic, assembler); |
| 218 } |
| 219 |
| 220 |
| 221 // KeyedLoadIC <object> <slot> |
| 222 // |
| 223 // Calls the LoadIC at FeedBackVector slot <slot> for <object> and the key |
| 224 // in the accumulator. |
| 225 void Interpreter::DoKeyedLoadIC(compiler::InterpreterAssembler* assembler) { |
| 226 Callable ic = |
| 227 CodeFactory::KeyedLoadICInOptimizedCode(isolate_, SLOPPY, UNINITIALIZED); |
| 228 DoPropertyLoadIC(ic, assembler); |
| 229 } |
| 230 |
| 231 |
| 193 void Interpreter::DoBinaryOp(int builtin_context_index, | 232 void Interpreter::DoBinaryOp(int builtin_context_index, |
| 194 compiler::InterpreterAssembler* assembler) { | 233 compiler::InterpreterAssembler* assembler) { |
| 195 // TODO(rmcilroy): Call ICs which back-patch bytecode with type specialized | 234 // TODO(rmcilroy): Call ICs which back-patch bytecode with type specialized |
| 196 // operations, instead of calling builtins directly. | 235 // operations, instead of calling builtins directly. |
| 197 Node* reg_index = __ BytecodeOperandReg(0); | 236 Node* reg_index = __ BytecodeOperandReg(0); |
| 198 Node* lhs = __ LoadRegister(reg_index); | 237 Node* lhs = __ LoadRegister(reg_index); |
| 199 Node* rhs = __ GetAccumulator(); | 238 Node* rhs = __ GetAccumulator(); |
| 200 Node* result = __ CallJSBuiltin(builtin_context_index, lhs, rhs); | 239 Node* result = __ CallJSBuiltin(builtin_context_index, lhs, rhs); |
| 201 __ SetAccumulator(result); | 240 __ SetAccumulator(result); |
| 202 __ Dispatch(); | 241 __ Dispatch(); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 // | 286 // |
| 248 // Return the value in register 0. | 287 // Return the value in register 0. |
| 249 void Interpreter::DoReturn(compiler::InterpreterAssembler* assembler) { | 288 void Interpreter::DoReturn(compiler::InterpreterAssembler* assembler) { |
| 250 __ Return(); | 289 __ Return(); |
| 251 } | 290 } |
| 252 | 291 |
| 253 | 292 |
| 254 } // namespace interpreter | 293 } // namespace interpreter |
| 255 } // namespace internal | 294 } // namespace internal |
| 256 } // namespace v8 | 295 } // namespace v8 |
| OLD | NEW |