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/ast/prettyprinter.h" | 7 #include "src/ast/prettyprinter.h" |
8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
9 #include "src/compiler.h" | 9 #include "src/compiler.h" |
10 #include "src/factory.h" | 10 #include "src/factory.h" |
11 #include "src/interpreter/bytecode-generator.h" | 11 #include "src/interpreter/bytecode-generator.h" |
12 #include "src/interpreter/bytecodes.h" | 12 #include "src/interpreter/bytecodes.h" |
13 #include "src/interpreter/interpreter-assembler.h" | 13 #include "src/interpreter/interpreter-assembler.h" |
| 14 #include "src/log.h" |
14 #include "src/zone.h" | 15 #include "src/zone.h" |
15 | 16 |
16 namespace v8 { | 17 namespace v8 { |
17 namespace internal { | 18 namespace internal { |
18 namespace interpreter { | 19 namespace interpreter { |
19 | 20 |
20 using compiler::Node; | 21 using compiler::Node; |
21 | 22 |
22 #define __ assembler-> | 23 #define __ assembler-> |
23 | 24 |
24 Interpreter::Interpreter(Isolate* isolate) : isolate_(isolate) { | 25 Interpreter::Interpreter(Isolate* isolate) : isolate_(isolate) { |
25 memset(&dispatch_table_, 0, sizeof(dispatch_table_)); | 26 memset(&dispatch_table_, 0, sizeof(dispatch_table_)); |
26 } | 27 } |
27 | 28 |
28 void Interpreter::Initialize() { | 29 void Interpreter::Initialize() { |
29 DCHECK(FLAG_ignition); | 30 DCHECK(FLAG_ignition); |
30 if (IsDispatchTableInitialized()) return; | 31 if (IsDispatchTableInitialized()) return; |
31 Zone zone; | 32 Zone zone; |
32 HandleScope scope(isolate_); | 33 HandleScope scope(isolate_); |
33 | 34 |
34 #define GENERATE_CODE(Name, ...) \ | 35 #define GENERATE_CODE(Name, ...) \ |
35 { \ | 36 { \ |
36 InterpreterAssembler assembler(isolate_, &zone, Bytecode::k##Name); \ | 37 InterpreterAssembler assembler(isolate_, &zone, Bytecode::k##Name); \ |
37 Do##Name(&assembler); \ | 38 Do##Name(&assembler); \ |
38 Handle<Code> code = assembler.GenerateCode(); \ | 39 Handle<Code> code = assembler.GenerateCode(); \ |
39 TraceCodegen(code, #Name); \ | 40 TraceCodegen(code, #Name); \ |
| 41 LOG_CODE_EVENT(isolate_, \ |
| 42 CodeCreateEvent(Logger::BYTECODE_HANDLER_TAG, \ |
| 43 AbstractCode::cast(*code), #Name)); \ |
40 dispatch_table_[Bytecodes::ToByte(Bytecode::k##Name)] = *code; \ | 44 dispatch_table_[Bytecodes::ToByte(Bytecode::k##Name)] = *code; \ |
41 } | 45 } |
42 BYTECODE_LIST(GENERATE_CODE) | 46 BYTECODE_LIST(GENERATE_CODE) |
43 #undef GENERATE_CODE | 47 #undef GENERATE_CODE |
44 } | 48 } |
45 | 49 |
46 Code* Interpreter::GetBytecodeHandler(Bytecode bytecode) { | 50 Code* Interpreter::GetBytecodeHandler(Bytecode bytecode) { |
47 DCHECK(IsDispatchTableInitialized()); | 51 DCHECK(IsDispatchTableInitialized()); |
48 return dispatch_table_[Bytecodes::ToByte(bytecode)]; | 52 return dispatch_table_[Bytecodes::ToByte(bytecode)]; |
49 } | 53 } |
(...skipping 1854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1904 Node* index = __ LoadRegister(index_reg); | 1908 Node* index = __ LoadRegister(index_reg); |
1905 Node* one = __ SmiConstant(Smi::FromInt(1)); | 1909 Node* one = __ SmiConstant(Smi::FromInt(1)); |
1906 Node* result = __ SmiAdd(index, one); | 1910 Node* result = __ SmiAdd(index, one); |
1907 __ SetAccumulator(result); | 1911 __ SetAccumulator(result); |
1908 __ Dispatch(); | 1912 __ Dispatch(); |
1909 } | 1913 } |
1910 | 1914 |
1911 } // namespace interpreter | 1915 } // namespace interpreter |
1912 } // namespace internal | 1916 } // namespace internal |
1913 } // namespace v8 | 1917 } // namespace v8 |
OLD | NEW |