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/compiler.h" | 7 #include "src/compiler.h" |
8 #include "src/compiler/interpreter-assembler.h" | 8 #include "src/compiler/interpreter-assembler.h" |
9 #include "src/factory.h" | 9 #include "src/factory.h" |
| 10 #include "src/interpreter/bytecode-generator.h" |
10 #include "src/interpreter/bytecodes.h" | 11 #include "src/interpreter/bytecodes.h" |
11 #include "src/zone.h" | 12 #include "src/zone.h" |
12 | 13 |
13 namespace v8 { | 14 namespace v8 { |
14 namespace internal { | 15 namespace internal { |
15 namespace interpreter { | 16 namespace interpreter { |
16 | 17 |
17 using compiler::Node; | 18 using compiler::Node; |
18 #define __ assembler-> | 19 #define __ assembler-> |
19 | 20 |
(...skipping 29 matching lines...) Expand all Loading... |
49 Do##Name(&assembler); \ | 50 Do##Name(&assembler); \ |
50 Handle<Code> code = assembler.GenerateCode(); \ | 51 Handle<Code> code = assembler.GenerateCode(); \ |
51 handler_table->set(static_cast<int>(Bytecode::k##Name), *code); \ | 52 handler_table->set(static_cast<int>(Bytecode::k##Name), *code); \ |
52 } | 53 } |
53 BYTECODE_LIST(GENERATE_CODE) | 54 BYTECODE_LIST(GENERATE_CODE) |
54 #undef GENERATE_CODE | 55 #undef GENERATE_CODE |
55 } | 56 } |
56 } | 57 } |
57 | 58 |
58 | 59 |
| 60 bool Interpreter::MakeBytecode(CompilationInfo* info) { |
| 61 Handle<SharedFunctionInfo> shared_info = info->shared_info(); |
| 62 |
| 63 BytecodeGenerator generator(info->isolate(), info->zone()); |
| 64 Handle<BytecodeArray> bytecodes = generator.MakeBytecode(info); |
| 65 if (FLAG_print_bytecode) { |
| 66 bytecodes->Print(); |
| 67 } |
| 68 |
| 69 DCHECK(shared_info->function_data()->IsUndefined()); |
| 70 if (!shared_info->function_data()->IsUndefined()) { |
| 71 return false; |
| 72 } |
| 73 |
| 74 shared_info->set_function_data(*bytecodes); |
| 75 info->SetCode(info->isolate()->builtins()->InterpreterEntryTrampoline()); |
| 76 info->EnsureFeedbackVector(); |
| 77 return true; |
| 78 } |
| 79 |
| 80 |
59 bool Interpreter::IsInterpreterTableInitialized( | 81 bool Interpreter::IsInterpreterTableInitialized( |
60 Handle<FixedArray> handler_table) { | 82 Handle<FixedArray> handler_table) { |
61 DCHECK(handler_table->length() == static_cast<int>(Bytecode::kLast) + 1); | 83 DCHECK(handler_table->length() == static_cast<int>(Bytecode::kLast) + 1); |
62 return handler_table->get(0) != isolate_->heap()->undefined_value(); | 84 return handler_table->get(0) != isolate_->heap()->undefined_value(); |
63 } | 85 } |
64 | 86 |
65 | 87 |
66 // LdaZero | 88 // LdaZero |
67 // | 89 // |
68 // Load literal '0' into the accumulator. | 90 // Load literal '0' into the accumulator. |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 // | 206 // |
185 // Return the value in register 0. | 207 // Return the value in register 0. |
186 void Interpreter::DoReturn(compiler::InterpreterAssembler* assembler) { | 208 void Interpreter::DoReturn(compiler::InterpreterAssembler* assembler) { |
187 __ Return(); | 209 __ Return(); |
188 } | 210 } |
189 | 211 |
190 | 212 |
191 } // namespace interpreter | 213 } // namespace interpreter |
192 } // namespace internal | 214 } // namespace internal |
193 } // namespace v8 | 215 } // namespace v8 |
OLD | NEW |