OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "src/interpreter/interpreter.h" |
| 6 |
| 7 #include "src/compiler.h" |
| 8 #include "src/compiler/interpreter-assembler.h" |
| 9 #include "src/factory.h" |
| 10 #include "src/interpreter/bytecodes.h" |
| 11 #include "src/zone.h" |
| 12 |
| 13 namespace v8 { |
| 14 namespace internal { |
| 15 namespace interpreter { |
| 16 |
| 17 using compiler::Node; |
| 18 #define __ assembler-> |
| 19 |
| 20 |
| 21 Interpreter::Interpreter() {} |
| 22 |
| 23 |
| 24 void Interpreter::Initialize(Isolate* isolate, bool create_heap_objects) { |
| 25 if (create_heap_objects) { |
| 26 Zone zone; |
| 27 HandleScope scope(isolate); |
| 28 Handle<FixedArray> handler_table = isolate->factory()->NewFixedArray( |
| 29 static_cast<int>(Bytecode::kLast) + 1, TENURED); |
| 30 isolate->heap()->public_set_interpreter_table(*handler_table); |
| 31 |
| 32 #define GENERATE_CODE(Name, _) \ |
| 33 { \ |
| 34 compiler::InterpreterAssembler assembler(isolate, &zone, \ |
| 35 Bytecode::k##Name); \ |
| 36 Do##Name(&assembler); \ |
| 37 handler_table->set(static_cast<int>(Bytecode::k##Name), \ |
| 38 *assembler.GenerateCode()); \ |
| 39 } |
| 40 BYTECODE_LIST(GENERATE_CODE) |
| 41 #undef GENERATE_CODE |
| 42 } |
| 43 } |
| 44 |
| 45 |
| 46 // Load literal '0' into the register index specified by the bytecode's |
| 47 // argument. |
| 48 void Interpreter::DoLoadLiteral0(compiler::InterpreterAssembler* assembler) { |
| 49 Node* register_index = __ BytecodeArg(0); |
| 50 __ StoreRegister(__ NumberConstant(0), register_index); |
| 51 __ Dispatch(); |
| 52 } |
| 53 |
| 54 |
| 55 // Return the value in register 0. |
| 56 void Interpreter::DoReturn(compiler::InterpreterAssembler* assembler) { |
| 57 __ Return(__ LoadRegister(0)); |
| 58 } |
| 59 |
| 60 |
| 61 } // namespace interpreter |
| 62 } // namespace internal |
| 63 } // namespace v8 |
OLD | NEW |