Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(404)

Side by Side Diff: src/interpreter/interpreter.cc

Issue 1288893003: [interpreter]: Fix interpreter handler table initialization. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@interpreter_bytecode_regs
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/bytecodes.h" 10 #include "src/interpreter/bytecodes.h"
(...skipping 13 matching lines...) Expand all
24 24
25 // static 25 // static
26 Handle<FixedArray> Interpreter::CreateUninitializedInterpreterTable( 26 Handle<FixedArray> Interpreter::CreateUninitializedInterpreterTable(
27 Isolate* isolate) { 27 Isolate* isolate) {
28 Handle<FixedArray> handler_table = isolate->factory()->NewFixedArray( 28 Handle<FixedArray> handler_table = isolate->factory()->NewFixedArray(
29 static_cast<int>(Bytecode::kLast) + 1, TENURED); 29 static_cast<int>(Bytecode::kLast) + 1, TENURED);
30 // We rely on the interpreter handler table being immovable, so check that 30 // We rely on the interpreter handler table being immovable, so check that
31 // it was allocated on the first page (which is always immovable). 31 // it was allocated on the first page (which is always immovable).
32 DCHECK(isolate->heap()->old_space()->FirstPage()->Contains( 32 DCHECK(isolate->heap()->old_space()->FirstPage()->Contains(
33 handler_table->address())); 33 handler_table->address()));
34 for (int i = 0; i < static_cast<int>(Bytecode::kLast); i++) {
35 handler_table->set(i, isolate->builtins()->builtin(Builtins::kIllegal));
36 }
37 return handler_table; 34 return handler_table;
38 } 35 }
39 36
40 37
41 void Interpreter::Initialize() { 38 void Interpreter::Initialize() {
42 DCHECK(FLAG_ignition); 39 DCHECK(FLAG_ignition);
43 Handle<FixedArray> handler_table = isolate_->factory()->interpreter_table(); 40 Handle<FixedArray> handler_table = isolate_->factory()->interpreter_table();
44 if (!IsInterpreterTableInitialized(handler_table)) { 41 if (!IsInterpreterTableInitialized(handler_table)) {
45 Zone zone; 42 Zone zone;
46 HandleScope scope(isolate_); 43 HandleScope scope(isolate_);
47 44
48 #define GENERATE_CODE(Name, ...) \ 45 #define GENERATE_CODE(Name, ...) \
49 { \ 46 { \
50 compiler::InterpreterAssembler assembler(isolate_, &zone, \ 47 compiler::InterpreterAssembler assembler(isolate_, &zone, \
51 Bytecode::k##Name); \ 48 Bytecode::k##Name); \
52 Do##Name(&assembler); \ 49 Do##Name(&assembler); \
53 Handle<Code> code = assembler.GenerateCode(); \ 50 Handle<Code> code = assembler.GenerateCode(); \
54 handler_table->set(static_cast<int>(Bytecode::k##Name), *code); \ 51 handler_table->set(static_cast<int>(Bytecode::k##Name), *code); \
55 } 52 }
56 BYTECODE_LIST(GENERATE_CODE) 53 BYTECODE_LIST(GENERATE_CODE)
57 #undef GENERATE_CODE 54 #undef GENERATE_CODE
58 } 55 }
59 } 56 }
60 57
61 58
62 bool Interpreter::IsInterpreterTableInitialized( 59 bool Interpreter::IsInterpreterTableInitialized(
63 Handle<FixedArray> handler_table) { 60 Handle<FixedArray> handler_table) {
64 DCHECK(handler_table->length() == static_cast<int>(Bytecode::kLast) + 1); 61 DCHECK(handler_table->length() == static_cast<int>(Bytecode::kLast) + 1);
65 return handler_table->get(0) == 62 return handler_table->get(0) != isolate_->heap()->undefined_value();
66 isolate_->builtins()->builtin(Builtins::kIllegal);
67 } 63 }
68 64
69 65
70 // LdaZero 66 // LdaZero
71 // 67 //
72 // Load literal '0' into the accumulator. 68 // Load literal '0' into the accumulator.
73 void Interpreter::DoLdaZero(compiler::InterpreterAssembler* assembler) { 69 void Interpreter::DoLdaZero(compiler::InterpreterAssembler* assembler) {
74 // TODO(rmcilroy) Implement. 70 // TODO(rmcilroy) Implement.
75 __ Dispatch(); 71 __ Dispatch();
76 } 72 }
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 // 184 //
189 // Return the value in register 0. 185 // Return the value in register 0.
190 void Interpreter::DoReturn(compiler::InterpreterAssembler* assembler) { 186 void Interpreter::DoReturn(compiler::InterpreterAssembler* assembler) {
191 __ Return(); 187 __ Return();
192 } 188 }
193 189
194 190
195 } // namespace interpreter 191 } // namespace interpreter
196 } // namespace internal 192 } // namespace internal
197 } // namespace v8 193 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698