Chromium Code Reviews| 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 { | |
| 25 class Node; | |
| 26 } | |
| 27 | |
| 24 namespace interpreter { | 28 namespace interpreter { |
| 25 | 29 |
| 26 class InterpreterAssembler; | 30 class InterpreterAssembler; |
| 27 | 31 |
| 28 class Interpreter { | 32 class Interpreter { |
| 29 public: | 33 public: |
| 30 explicit Interpreter(Isolate* isolate); | 34 explicit Interpreter(Isolate* isolate); |
| 31 virtual ~Interpreter() {} | 35 virtual ~Interpreter() {} |
| 32 | 36 |
| 33 // Initializes the interpreter dispatch table. | 37 // Initializes the interpreter dispatch table. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 73 void DoBinaryOp(Runtime::FunctionId function_id, | 77 void DoBinaryOp(Runtime::FunctionId function_id, |
| 74 InterpreterAssembler* assembler); | 78 InterpreterAssembler* assembler); |
| 75 | 79 |
| 76 // Generates code to perform the count operations via |callable|. | 80 // Generates code to perform the count operations via |callable|. |
| 77 void DoCountOp(Callable callable, InterpreterAssembler* assembler); | 81 void DoCountOp(Callable callable, InterpreterAssembler* assembler); |
| 78 | 82 |
| 79 // Generates code to perform the comparison operation associated with | 83 // Generates code to perform the comparison operation associated with |
| 80 // |compare_op|. | 84 // |compare_op|. |
| 81 void DoCompareOp(Token::Value compare_op, InterpreterAssembler* assembler); | 85 void DoCompareOp(Token::Value compare_op, InterpreterAssembler* assembler); |
| 82 | 86 |
| 83 // Generates code to load a constant from the constant pool. | |
| 84 void DoLoadConstant(InterpreterAssembler* assembler); | |
| 85 | |
| 86 // Generates code to perform a global load via |ic|. | 87 // Generates code to perform a global load via |ic|. |
| 87 void DoLoadGlobal(Callable ic, InterpreterAssembler* assembler); | 88 void DoLdaGlobal(Callable ic, InterpreterAssembler* assembler); |
| 88 | 89 |
| 89 // Generates code to perform a global store via |ic|. | 90 // Generates code to perform a global store via |ic|. |
| 90 void DoStoreGlobal(Callable ic, InterpreterAssembler* assembler); | 91 void DoStaGlobal(Callable ic, InterpreterAssembler* assembler); |
| 91 | 92 |
| 92 // Generates code to perform a named property load via |ic|. | 93 // Generates code to perform a named property load via |ic|. |
| 93 void DoLoadIC(Callable ic, InterpreterAssembler* assembler); | 94 void DoLdaIC(Callable ic, InterpreterAssembler* assembler); |
| 94 | 95 |
| 95 // Generates code to perform a keyed property load via |ic|. | 96 // Generates code to perform a keyed property load via |ic|. |
| 96 void DoKeyedLoadIC(Callable ic, InterpreterAssembler* assembler); | 97 void DoKeyedLoadIC(Callable ic, InterpreterAssembler* assembler); |
| 97 | 98 |
| 98 // Generates code to perform a namedproperty store via |ic|. | 99 // Generates code to perform a named property store via |ic|. |
| 99 void DoStoreIC(Callable ic, InterpreterAssembler* assembler); | 100 void DoStaNamedProperty(Callable ic, InterpreterAssembler* assembler); |
| 100 | 101 |
| 101 // Generates code to perform a keyed property store via |ic|. | 102 // Generates code to perform a keyed property store via |ic|. |
| 102 void DoKeyedStoreIC(Callable ic, InterpreterAssembler* assembler); | 103 void DoStaKeyedProperty(Callable ic, InterpreterAssembler* assembler); |
| 103 | 104 |
| 104 // Generates code to perform a JS call. | 105 // Generates code to perform a JS call. |
| 105 void DoJSCall(InterpreterAssembler* assembler, TailCallMode tail_call_mode); | 106 void DoJSCall(InterpreterAssembler* assembler, TailCallMode tail_call_mode); |
| 106 | 107 |
| 107 // Generates code to perform a runtime call. | 108 // Generates code to perform a runtime call. |
| 108 void DoCallRuntimeCommon(InterpreterAssembler* assembler); | 109 void DoCallRuntimeCommon(InterpreterAssembler* assembler); |
| 109 | 110 |
| 110 // Generates code to perform a runtime call returning a pair. | 111 // Generates code to perform a runtime call returning a pair. |
| 111 void DoCallRuntimeForPairCommon(InterpreterAssembler* assembler); | 112 void DoCallRuntimeForPairCommon(InterpreterAssembler* assembler); |
| 112 | 113 |
| 113 // Generates code to perform a JS runtime call. | 114 // Generates code to perform a JS runtime call. |
| 114 void DoCallJSRuntimeCommon(InterpreterAssembler* assembler); | 115 void DoCallJSRuntimeCommon(InterpreterAssembler* assembler); |
| 115 | 116 |
| 116 // Generates code to perform a constructor call. | 117 // Generates code to perform a constructor call. |
| 117 void DoCallConstruct(InterpreterAssembler* assembler); | 118 void DoCallConstruct(InterpreterAssembler* assembler); |
| 118 | 119 |
| 119 // Generates code to perform a type conversion. | 120 // Generates code to perform a type conversion. |
| 120 void DoTypeConversionOp(Callable callable, InterpreterAssembler* assembler); | 121 void DoTypeConversionOp(Callable callable, InterpreterAssembler* assembler); |
| 121 | 122 |
| 122 // Generates code to perform delete via function_id. | 123 // Generates code to perform delete via function_id. |
| 123 void DoDelete(Runtime::FunctionId function_id, | 124 void DoDelete(Runtime::FunctionId function_id, |
| 124 InterpreterAssembler* assembler); | 125 InterpreterAssembler* assembler); |
| 125 | 126 |
| 126 // Generates code to perform a lookup slot load via |function_id|. | 127 // Generates code to perform a lookup slot load via |function_id|. |
| 127 void DoLoadLookupSlot(Runtime::FunctionId function_id, | 128 void DoLdaLookupSlot(Runtime::FunctionId function_id, |
| 128 InterpreterAssembler* assembler); | 129 InterpreterAssembler* assembler); |
| 129 | 130 |
| 130 // Generates code to perform a lookup slot store depending on |language_mode|. | 131 // Generates code to perform a lookup slot store depending on |language_mode|. |
| 131 void DoStoreLookupSlot(LanguageMode language_mode, | 132 void DoStaLookupSlot(LanguageMode language_mode, |
| 132 InterpreterAssembler* assembler); | 133 InterpreterAssembler* assembler); |
| 134 | |
| 135 // Helpers for fused bytecodes. These require the caller to add the | |
| 136 // Dispatch(). | |
|
rmcilroy
2016/05/17 15:49:33
I don't think it's necessary to mention the caller
oth
2016/05/18 20:22:25
Done.
| |
| 137 compiler::Node* BuildLoadUndefined(InterpreterAssembler* assembler); | |
| 138 compiler::Node* BuildLoadContextSlot(InterpreterAssembler* assembler); | |
| 139 compiler::Node* BuildLoadGlobal(Callable ic, InterpreterAssembler* assembler); | |
| 140 compiler::Node* BuildLoadNamedProperty(Callable ic, | |
| 141 InterpreterAssembler* assembler); | |
| 142 compiler::Node* BuildLoadKeyedProperty(Callable ic, | |
| 143 InterpreterAssembler* assembler); | |
| 133 | 144 |
| 134 uintptr_t GetDispatchCounter(Bytecode from, Bytecode to) const; | 145 uintptr_t GetDispatchCounter(Bytecode from, Bytecode to) const; |
| 135 | 146 |
| 136 // Get dispatch table index of bytecode. | 147 // Get dispatch table index of bytecode. |
| 137 static size_t GetDispatchTableIndex(Bytecode bytecode, | 148 static size_t GetDispatchTableIndex(Bytecode bytecode, |
| 138 OperandScale operand_scale); | 149 OperandScale operand_scale); |
| 139 | 150 |
| 140 bool IsDispatchTableInitialized(); | 151 bool IsDispatchTableInitialized(); |
| 141 | 152 |
| 142 static const int kNumberOfWideVariants = 3; | 153 static const int kNumberOfWideVariants = 3; |
| 143 static const int kDispatchTableSize = kNumberOfWideVariants * (kMaxUInt8 + 1); | 154 static const int kDispatchTableSize = kNumberOfWideVariants * (kMaxUInt8 + 1); |
| 144 static const int kNumberOfBytecodes = static_cast<int>(Bytecode::kLast) + 1; | 155 static const int kNumberOfBytecodes = static_cast<int>(Bytecode::kLast) + 1; |
| 145 | 156 |
| 146 Isolate* isolate_; | 157 Isolate* isolate_; |
| 147 Address dispatch_table_[kDispatchTableSize]; | 158 Address dispatch_table_[kDispatchTableSize]; |
| 148 v8::base::SmartArrayPointer<uintptr_t> bytecode_dispatch_counters_table_; | 159 v8::base::SmartArrayPointer<uintptr_t> bytecode_dispatch_counters_table_; |
| 149 | 160 |
| 150 DISALLOW_COPY_AND_ASSIGN(Interpreter); | 161 DISALLOW_COPY_AND_ASSIGN(Interpreter); |
| 151 }; | 162 }; |
| 152 | 163 |
| 153 } // namespace interpreter | 164 } // namespace interpreter |
| 154 } // namespace internal | 165 } // namespace internal |
| 155 } // namespace v8 | 166 } // namespace v8 |
| 156 | 167 |
| 157 #endif // V8_INTERPRETER_INTERPRETER_H_ | 168 #endif // V8_INTERPRETER_INTERPRETER_H_ |
| OLD | NEW |