| 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_COMPILER_WASM_COMPILER_H_ | 5 #ifndef V8_COMPILER_WASM_COMPILER_H_ |
| 6 #define V8_COMPILER_WASM_COMPILER_H_ | 6 #define V8_COMPILER_WASM_COMPILER_H_ |
| 7 | 7 |
| 8 // Clients of this interface shouldn't depend on lots of compiler internals. | 8 // Clients of this interface shouldn't depend on lots of compiler internals. |
| 9 // Do not include anything from src/compiler here! | 9 // Do not include anything from src/compiler here! |
| 10 #include "src/wasm/wasm-opcodes.h" | 10 #include "src/wasm/wasm-opcodes.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 wasm::ModuleEnv* module, | 48 wasm::ModuleEnv* module, |
| 49 Handle<String> name, | 49 Handle<String> name, |
| 50 Handle<Code> wasm_code, | 50 Handle<Code> wasm_code, |
| 51 uint32_t index); | 51 uint32_t index); |
| 52 | 52 |
| 53 // Abstracts details of building TurboFan graph nodes for WASM to separate | 53 // Abstracts details of building TurboFan graph nodes for WASM to separate |
| 54 // the WASM decoder from the internal details of TurboFan. | 54 // the WASM decoder from the internal details of TurboFan. |
| 55 class WasmTrapHelper; | 55 class WasmTrapHelper; |
| 56 class WasmGraphBuilder { | 56 class WasmGraphBuilder { |
| 57 public: | 57 public: |
| 58 WasmGraphBuilder(Zone* z, JSGraph* g); | 58 WasmGraphBuilder(Zone* z, JSGraph* g, wasm::FunctionSig* function_signature); |
| 59 | 59 |
| 60 Node** Buffer(size_t count) { | 60 Node** Buffer(size_t count) { |
| 61 if (count > cur_bufsize_) { | 61 if (count > cur_bufsize_) { |
| 62 size_t new_size = count + cur_bufsize_ + 5; | 62 size_t new_size = count + cur_bufsize_ + 5; |
| 63 cur_buffer_ = | 63 cur_buffer_ = |
| 64 reinterpret_cast<Node**>(zone_->New(new_size * sizeof(Node*))); | 64 reinterpret_cast<Node**>(zone_->New(new_size * sizeof(Node*))); |
| 65 cur_bufsize_ = new_size; | 65 cur_bufsize_ = new_size; |
| 66 } | 66 } |
| 67 return cur_buffer_; | 67 return cur_buffer_; |
| 68 } | 68 } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 | 125 |
| 126 Node* Control() { return *control_; } | 126 Node* Control() { return *control_; } |
| 127 Node* Effect() { return *effect_; } | 127 Node* Effect() { return *effect_; } |
| 128 | 128 |
| 129 void set_module(wasm::ModuleEnv* module) { this->module_ = module; } | 129 void set_module(wasm::ModuleEnv* module) { this->module_ = module; } |
| 130 | 130 |
| 131 void set_control_ptr(Node** control) { this->control_ = control; } | 131 void set_control_ptr(Node** control) { this->control_ = control; } |
| 132 | 132 |
| 133 void set_effect_ptr(Node** effect) { this->effect_ = effect; } | 133 void set_effect_ptr(Node** effect) { this->effect_ = effect; } |
| 134 | 134 |
| 135 wasm::FunctionSig* GetFunctionSignature() { return function_signature_; } |
| 136 |
| 135 private: | 137 private: |
| 136 static const int kDefaultBufferSize = 16; | 138 static const int kDefaultBufferSize = 16; |
| 137 friend class WasmTrapHelper; | 139 friend class WasmTrapHelper; |
| 138 | 140 |
| 139 Zone* zone_; | 141 Zone* zone_; |
| 140 JSGraph* jsgraph_; | 142 JSGraph* jsgraph_; |
| 141 wasm::ModuleEnv* module_; | 143 wasm::ModuleEnv* module_; |
| 142 Node* mem_buffer_; | 144 Node* mem_buffer_; |
| 143 Node* mem_size_; | 145 Node* mem_size_; |
| 144 Node* function_table_; | 146 Node* function_table_; |
| 145 Node** control_; | 147 Node** control_; |
| 146 Node** effect_; | 148 Node** effect_; |
| 147 Node** cur_buffer_; | 149 Node** cur_buffer_; |
| 148 size_t cur_bufsize_; | 150 size_t cur_bufsize_; |
| 149 Node* def_buffer_[kDefaultBufferSize]; | 151 Node* def_buffer_[kDefaultBufferSize]; |
| 150 | 152 |
| 151 WasmTrapHelper* trap_; | 153 WasmTrapHelper* trap_; |
| 154 wasm::FunctionSig* function_signature_; |
| 152 | 155 |
| 153 // Internal helper methods. | 156 // Internal helper methods. |
| 154 JSGraph* jsgraph() { return jsgraph_; } | 157 JSGraph* jsgraph() { return jsgraph_; } |
| 155 Graph* graph(); | 158 Graph* graph(); |
| 156 | 159 |
| 157 Node* String(const char* string); | 160 Node* String(const char* string); |
| 158 Node* MemBuffer(uint32_t offset); | 161 Node* MemBuffer(uint32_t offset); |
| 159 void BoundsCheckMem(MachineType memtype, Node* index, uint32_t offset); | 162 void BoundsCheckMem(MachineType memtype, Node* index, uint32_t offset); |
| 160 | 163 |
| 161 Node* BuildWasmCall(wasm::FunctionSig* sig, Node** args); | 164 Node* BuildWasmCall(wasm::FunctionSig* sig, Node** args); |
| 162 Node* BuildF32CopySign(Node* left, Node* right); | 165 Node* BuildF32CopySign(Node* left, Node* right); |
| 163 Node* BuildF64CopySign(Node* left, Node* right); | 166 Node* BuildF64CopySign(Node* left, Node* right); |
| 164 Node* BuildI32Ctz(Node* input); | 167 Node* BuildI32Ctz(Node* input); |
| 165 Node* BuildI32Popcnt(Node* input); | 168 Node* BuildI32Popcnt(Node* input); |
| 166 Node* BuildI64Ctz(Node* input); | 169 Node* BuildI64Ctz(Node* input); |
| 167 Node* BuildI64Popcnt(Node* input); | 170 Node* BuildI64Popcnt(Node* input); |
| 168 | 171 |
| 169 Node** Realloc(Node** buffer, size_t count) { | 172 Node** Realloc(Node** buffer, size_t count) { |
| 170 Node** buf = Buffer(count); | 173 Node** buf = Buffer(count); |
| 171 if (buf != buffer) memcpy(buf, buffer, count * sizeof(Node*)); | 174 if (buf != buffer) memcpy(buf, buffer, count * sizeof(Node*)); |
| 172 return buf; | 175 return buf; |
| 173 } | 176 } |
| 174 }; | 177 }; |
| 175 } // namespace compiler | 178 } // namespace compiler |
| 176 } // namespace internal | 179 } // namespace internal |
| 177 } // namespace v8 | 180 } // namespace v8 |
| 178 | 181 |
| 179 #endif // V8_COMPILER_WASM_COMPILER_H_ | 182 #endif // V8_COMPILER_WASM_COMPILER_H_ |
| OLD | NEW |