| 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 #ifndef V8_INTERPRETER_INTERPRETER_H_ | 5 #ifndef V8_INTERPRETER_INTERPRETER_H_ |
| 6 #define V8_INTERPRETER_INTERPRETER_H_ | 6 #define V8_INTERPRETER_INTERPRETER_H_ |
| 7 | 7 |
| 8 // Clients of this interface shouldn't depend on lots of interpreter internals. | 8 // Clients of this interface shouldn't depend on lots of interpreter internals. |
| 9 // Do not include anything from src/interpreter other than | 9 // Do not include anything from src/interpreter other than |
| 10 // src/interpreter/bytecodes.h here! | 10 // src/interpreter/bytecodes.h here! |
| 11 #include "src/base/macros.h" | 11 #include "src/base/macros.h" |
| 12 #include "src/builtins.h" | 12 #include "src/builtins.h" |
| 13 #include "src/interpreter/bytecodes.h" | 13 #include "src/interpreter/bytecodes.h" |
| 14 #include "src/parsing/token.h" | 14 #include "src/parsing/token.h" |
| 15 #include "src/runtime/runtime.h" | 15 #include "src/runtime/runtime.h" |
| 16 | 16 |
| 17 namespace v8 { | 17 namespace v8 { |
| 18 namespace internal { | 18 namespace internal { |
| 19 | 19 |
| 20 class Isolate; | 20 class Isolate; |
| 21 class Callable; | 21 class Callable; |
| 22 class CompilationInfo; | 22 class CompilationInfo; |
| 23 | 23 |
| 24 namespace compiler { | 24 namespace interpreter { |
| 25 |
| 25 class InterpreterAssembler; | 26 class InterpreterAssembler; |
| 26 } | |
| 27 | |
| 28 namespace interpreter { | |
| 29 | 27 |
| 30 class Interpreter { | 28 class Interpreter { |
| 31 public: | 29 public: |
| 32 explicit Interpreter(Isolate* isolate); | 30 explicit Interpreter(Isolate* isolate); |
| 33 virtual ~Interpreter() {} | 31 virtual ~Interpreter() {} |
| 34 | 32 |
| 35 // Initializes the interpreter dispatch table. | 33 // Initializes the interpreter dispatch table. |
| 36 void Initialize(); | 34 void Initialize(); |
| 37 | 35 |
| 38 // Generate bytecode for |info|. | 36 // Generate bytecode for |info|. |
| 39 static bool MakeBytecode(CompilationInfo* info); | 37 static bool MakeBytecode(CompilationInfo* info); |
| 40 | 38 |
| 41 // GC support. | 39 // GC support. |
| 42 void IterateDispatchTable(ObjectVisitor* v); | 40 void IterateDispatchTable(ObjectVisitor* v); |
| 43 | 41 |
| 42 void TraceCodegen(Handle<Code> code, const char* name); |
| 43 |
| 44 Address dispatch_table_address() { | 44 Address dispatch_table_address() { |
| 45 return reinterpret_cast<Address>(&dispatch_table_[0]); | 45 return reinterpret_cast<Address>(&dispatch_table_[0]); |
| 46 } | 46 } |
| 47 | 47 |
| 48 private: | 48 private: |
| 49 // Bytecode handler generator functions. | 49 // Bytecode handler generator functions. |
| 50 #define DECLARE_BYTECODE_HANDLER_GENERATOR(Name, ...) \ | 50 #define DECLARE_BYTECODE_HANDLER_GENERATOR(Name, ...) \ |
| 51 void Do##Name(compiler::InterpreterAssembler* assembler); | 51 void Do##Name(InterpreterAssembler* assembler); |
| 52 BYTECODE_LIST(DECLARE_BYTECODE_HANDLER_GENERATOR) | 52 BYTECODE_LIST(DECLARE_BYTECODE_HANDLER_GENERATOR) |
| 53 #undef DECLARE_BYTECODE_HANDLER_GENERATOR | 53 #undef DECLARE_BYTECODE_HANDLER_GENERATOR |
| 54 | 54 |
| 55 // Generates code to perform the binary operations via |function_id|. | 55 // Generates code to perform the binary operations via |function_id|. |
| 56 void DoBinaryOp(Runtime::FunctionId function_id, | 56 void DoBinaryOp(Runtime::FunctionId function_id, |
| 57 compiler::InterpreterAssembler* assembler); | 57 InterpreterAssembler* assembler); |
| 58 | 58 |
| 59 // Generates code to perform the count operations via |function_id|. | 59 // Generates code to perform the count operations via |function_id|. |
| 60 void DoCountOp(Runtime::FunctionId function_id, | 60 void DoCountOp(Runtime::FunctionId function_id, |
| 61 compiler::InterpreterAssembler* assembler); | 61 InterpreterAssembler* assembler); |
| 62 | 62 |
| 63 // Generates code to perform the comparison operation associated with | 63 // Generates code to perform the comparison operation associated with |
| 64 // |compare_op|. | 64 // |compare_op|. |
| 65 void DoCompareOp(Token::Value compare_op, | 65 void DoCompareOp(Token::Value compare_op, InterpreterAssembler* assembler); |
| 66 compiler::InterpreterAssembler* assembler); | |
| 67 | 66 |
| 68 // Generates code to load a constant from the constant pool. | 67 // Generates code to load a constant from the constant pool. |
| 69 void DoLoadConstant(compiler::InterpreterAssembler* assembler); | 68 void DoLoadConstant(InterpreterAssembler* assembler); |
| 70 | 69 |
| 71 // Generates code to perform a global load via |ic|. | 70 // Generates code to perform a global load via |ic|. |
| 72 void DoLoadGlobal(Callable ic, compiler::InterpreterAssembler* assembler); | 71 void DoLoadGlobal(Callable ic, InterpreterAssembler* assembler); |
| 73 | 72 |
| 74 // Generates code to perform a global store via |ic|. | 73 // Generates code to perform a global store via |ic|. |
| 75 void DoStoreGlobal(Callable ic, compiler::InterpreterAssembler* assembler); | 74 void DoStoreGlobal(Callable ic, InterpreterAssembler* assembler); |
| 76 | 75 |
| 77 // Generates code to perform a named property load via |ic|. | 76 // Generates code to perform a named property load via |ic|. |
| 78 void DoLoadIC(Callable ic, compiler::InterpreterAssembler* assembler); | 77 void DoLoadIC(Callable ic, InterpreterAssembler* assembler); |
| 79 | 78 |
| 80 // Generates code to perform a keyed property load via |ic|. | 79 // Generates code to perform a keyed property load via |ic|. |
| 81 void DoKeyedLoadIC(Callable ic, compiler::InterpreterAssembler* assembler); | 80 void DoKeyedLoadIC(Callable ic, InterpreterAssembler* assembler); |
| 82 | 81 |
| 83 // Generates code to perform a namedproperty store via |ic|. | 82 // Generates code to perform a namedproperty store via |ic|. |
| 84 void DoStoreIC(Callable ic, compiler::InterpreterAssembler* assembler); | 83 void DoStoreIC(Callable ic, InterpreterAssembler* assembler); |
| 85 | 84 |
| 86 // Generates code to perform a keyed property store via |ic|. | 85 // Generates code to perform a keyed property store via |ic|. |
| 87 void DoKeyedStoreIC(Callable ic, compiler::InterpreterAssembler* assembler); | 86 void DoKeyedStoreIC(Callable ic, InterpreterAssembler* assembler); |
| 88 | 87 |
| 89 // Generates code to perform a JS call. | 88 // Generates code to perform a JS call. |
| 90 void DoJSCall(compiler::InterpreterAssembler* assembler); | 89 void DoJSCall(InterpreterAssembler* assembler); |
| 91 | 90 |
| 92 // Generates code to perform a runtime call. | 91 // Generates code to perform a runtime call. |
| 93 void DoCallRuntimeCommon(compiler::InterpreterAssembler* assembler); | 92 void DoCallRuntimeCommon(InterpreterAssembler* assembler); |
| 94 | 93 |
| 95 // Generates code to perform a runtime call returning a pair. | 94 // Generates code to perform a runtime call returning a pair. |
| 96 void DoCallRuntimeForPairCommon(compiler::InterpreterAssembler* assembler); | 95 void DoCallRuntimeForPairCommon(InterpreterAssembler* assembler); |
| 97 | 96 |
| 98 // Generates code to perform a JS runtime call. | 97 // Generates code to perform a JS runtime call. |
| 99 void DoCallJSRuntimeCommon(compiler::InterpreterAssembler* assembler); | 98 void DoCallJSRuntimeCommon(InterpreterAssembler* assembler); |
| 100 | 99 |
| 101 // Generates code to perform a constructor call.. | 100 // Generates code to perform a constructor call.. |
| 102 void DoCallConstruct(compiler::InterpreterAssembler* assembler); | 101 void DoCallConstruct(InterpreterAssembler* assembler); |
| 103 | 102 |
| 104 // Generates code ro create a literal via |function_id|. | 103 // Generates code ro create a literal via |function_id|. |
| 105 void DoCreateLiteral(Runtime::FunctionId function_id, | 104 void DoCreateLiteral(Runtime::FunctionId function_id, |
| 106 compiler::InterpreterAssembler* assembler); | 105 InterpreterAssembler* assembler); |
| 107 | 106 |
| 108 // Generates code to perform delete via function_id. | 107 // Generates code to perform delete via function_id. |
| 109 void DoDelete(Runtime::FunctionId function_id, | 108 void DoDelete(Runtime::FunctionId function_id, |
| 110 compiler::InterpreterAssembler* assembler); | 109 InterpreterAssembler* assembler); |
| 111 | 110 |
| 112 // Generates code to perform a lookup slot load via |function_id|. | 111 // Generates code to perform a lookup slot load via |function_id|. |
| 113 void DoLoadLookupSlot(Runtime::FunctionId function_id, | 112 void DoLoadLookupSlot(Runtime::FunctionId function_id, |
| 114 compiler::InterpreterAssembler* assembler); | 113 InterpreterAssembler* assembler); |
| 115 | 114 |
| 116 // Generates code to perform a lookup slot store depending on |language_mode|. | 115 // Generates code to perform a lookup slot store depending on |language_mode|. |
| 117 void DoStoreLookupSlot(LanguageMode language_mode, | 116 void DoStoreLookupSlot(LanguageMode language_mode, |
| 118 compiler::InterpreterAssembler* assembler); | 117 InterpreterAssembler* assembler); |
| 119 | 118 |
| 120 bool IsDispatchTableInitialized(); | 119 bool IsDispatchTableInitialized(); |
| 121 | 120 |
| 122 static const int kDispatchTableSize = static_cast<int>(Bytecode::kLast) + 1; | 121 static const int kDispatchTableSize = static_cast<int>(Bytecode::kLast) + 1; |
| 123 | 122 |
| 124 Isolate* isolate_; | 123 Isolate* isolate_; |
| 125 Object* dispatch_table_[kDispatchTableSize]; | 124 Object* dispatch_table_[kDispatchTableSize]; |
| 126 | 125 |
| 127 DISALLOW_COPY_AND_ASSIGN(Interpreter); | 126 DISALLOW_COPY_AND_ASSIGN(Interpreter); |
| 128 }; | 127 }; |
| 129 | 128 |
| 130 } // namespace interpreter | 129 } // namespace interpreter |
| 131 } // namespace internal | 130 } // namespace internal |
| 132 } // namespace v8 | 131 } // namespace v8 |
| 133 | 132 |
| 134 #endif // V8_INTERPRETER_INTERPRETER_H_ | 133 #endif // V8_INTERPRETER_INTERPRETER_H_ |
| OLD | NEW |