| 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" |
| 11 #include "src/zone.h" | 11 #include "src/zone.h" |
| 12 | 12 |
| 13 namespace v8 { | 13 namespace v8 { |
| 14 namespace internal { | 14 namespace internal { |
| 15 | 15 |
| 16 namespace compiler { | 16 namespace compiler { |
| 17 // Forward declarations for some compiler data structures. | 17 // Forward declarations for some compiler data structures. |
| 18 class Node; | 18 class Node; |
| 19 class JSGraph; | 19 class JSGraph; |
| 20 class Graph; | 20 class Graph; |
| 21 class Operator; | 21 class Operator; |
| 22 class SourcePositionTable; | 22 class SourcePositionTable; |
| 23 class WasmCompilationUnit; |
| 23 } | 24 } |
| 24 | 25 |
| 25 namespace wasm { | 26 namespace wasm { |
| 26 // Forward declarations for some WASM data structures. | 27 // Forward declarations for some WASM data structures. |
| 27 struct ModuleEnv; | 28 struct ModuleEnv; |
| 28 struct WasmFunction; | 29 struct WasmFunction; |
| 29 class ErrorThrower; | 30 class ErrorThrower; |
| 30 | 31 |
| 31 // Expose {Node} and {Graph} opaquely as {wasm::TFNode} and {wasm::TFGraph}. | 32 // Expose {Node} and {Graph} opaquely as {wasm::TFNode} and {wasm::TFGraph}. |
| 32 typedef compiler::Node TFNode; | 33 typedef compiler::Node TFNode; |
| 33 typedef compiler::JSGraph TFGraph; | 34 typedef compiler::JSGraph TFGraph; |
| 34 } | 35 } |
| 35 | 36 |
| 36 namespace compiler { | 37 namespace compiler { |
| 37 // Compiles a single function, producing a code object. | 38 // Compiles a single function, producing a code object. |
| 38 Handle<Code> CompileWasmFunction(wasm::ErrorThrower& thrower, Isolate* isolate, | 39 Handle<Code> CompileWasmFunction(wasm::ErrorThrower* thrower, Isolate* isolate, |
| 39 wasm::ModuleEnv* module_env, | 40 wasm::ModuleEnv* module_env, |
| 40 const wasm::WasmFunction& function); | 41 const wasm::WasmFunction* function); |
| 41 | 42 |
| 42 // Wraps a JS function, producing a code object that can be called from WASM. | 43 // Wraps a JS function, producing a code object that can be called from WASM. |
| 43 Handle<Code> CompileWasmToJSWrapper(Isolate* isolate, wasm::ModuleEnv* module, | 44 Handle<Code> CompileWasmToJSWrapper(Isolate* isolate, wasm::ModuleEnv* module, |
| 44 Handle<JSFunction> function, | 45 Handle<JSFunction> function, |
| 45 wasm::FunctionSig* sig, | 46 wasm::FunctionSig* sig, |
| 46 wasm::WasmName module_name, | 47 wasm::WasmName module_name, |
| 47 wasm::WasmName function_name); | 48 wasm::WasmName function_name); |
| 48 | 49 |
| 49 // Wraps a given wasm code object, producing a JSFunction that can be called | 50 // Wraps a given wasm code object, producing a JSFunction that can be called |
| 50 // from JavaScript. | 51 // from JavaScript. |
| 51 Handle<JSFunction> CompileJSToWasmWrapper( | 52 Handle<JSFunction> CompileJSToWasmWrapper( |
| 52 Isolate* isolate, wasm::ModuleEnv* module, Handle<String> name, | 53 Isolate* isolate, wasm::ModuleEnv* module, Handle<String> name, |
| 53 Handle<Code> wasm_code, Handle<JSObject> module_object, uint32_t index); | 54 Handle<Code> wasm_code, Handle<JSObject> module_object, uint32_t index); |
| 54 | 55 |
| 56 WasmCompilationUnit* CreateWasmCompilationUnit( |
| 57 wasm::ErrorThrower* thrower, Isolate* isolate, wasm::ModuleEnv* module_env, |
| 58 const wasm::WasmFunction* function); |
| 59 |
| 60 void ExecuteCompilation(WasmCompilationUnit* unit); |
| 61 |
| 62 int GetIndexOfWasmCompilationUnit(WasmCompilationUnit* unit); |
| 63 |
| 64 Handle<Code> FinishCompilation(WasmCompilationUnit* unit); |
| 65 |
| 55 // Abstracts details of building TurboFan graph nodes for WASM to separate | 66 // Abstracts details of building TurboFan graph nodes for WASM to separate |
| 56 // the WASM decoder from the internal details of TurboFan. | 67 // the WASM decoder from the internal details of TurboFan. |
| 57 class WasmTrapHelper; | 68 class WasmTrapHelper; |
| 58 class WasmGraphBuilder { | 69 class WasmGraphBuilder { |
| 59 public: | 70 public: |
| 60 WasmGraphBuilder( | 71 WasmGraphBuilder( |
| 61 Zone* z, JSGraph* g, wasm::FunctionSig* function_signature, | 72 Zone* z, JSGraph* g, wasm::FunctionSig* function_signature, |
| 62 compiler::SourcePositionTable* source_position_table = nullptr); | 73 compiler::SourcePositionTable* source_position_table = nullptr); |
| 63 | 74 |
| 64 Node** Buffer(size_t count) { | 75 Node** Buffer(size_t count) { |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 Node** buf = Buffer(new_count); | 286 Node** buf = Buffer(new_count); |
| 276 if (buf != buffer) memcpy(buf, buffer, old_count * sizeof(Node*)); | 287 if (buf != buffer) memcpy(buf, buffer, old_count * sizeof(Node*)); |
| 277 return buf; | 288 return buf; |
| 278 } | 289 } |
| 279 }; | 290 }; |
| 280 } // namespace compiler | 291 } // namespace compiler |
| 281 } // namespace internal | 292 } // namespace internal |
| 282 } // namespace v8 | 293 } // namespace v8 |
| 283 | 294 |
| 284 #endif // V8_COMPILER_WASM_COMPILER_H_ | 295 #endif // V8_COMPILER_WASM_COMPILER_H_ |
| OLD | NEW |