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 #include <memory> | 8 #include <memory> |
9 | 9 |
10 // Clients of this interface shouldn't depend on lots of compiler internals. | 10 // Clients of this interface shouldn't depend on lots of compiler internals. |
(...skipping 11 matching lines...) Expand all Loading... |
22 // Forward declarations for some compiler data structures. | 22 // Forward declarations for some compiler data structures. |
23 class Node; | 23 class Node; |
24 class JSGraph; | 24 class JSGraph; |
25 class Graph; | 25 class Graph; |
26 class Operator; | 26 class Operator; |
27 class SourcePositionTable; | 27 class SourcePositionTable; |
28 } // namespace compiler | 28 } // namespace compiler |
29 | 29 |
30 namespace wasm { | 30 namespace wasm { |
31 // Forward declarations for some WASM data structures. | 31 // Forward declarations for some WASM data structures. |
| 32 struct ModuleBytesEnv; |
32 struct ModuleEnv; | 33 struct ModuleEnv; |
33 struct WasmFunction; | 34 struct WasmFunction; |
| 35 struct WasmModule; |
34 class ErrorThrower; | 36 class ErrorThrower; |
35 struct DecodeStruct; | 37 struct DecodeStruct; |
36 | 38 |
37 // Expose {Node} and {Graph} opaquely as {wasm::TFNode} and {wasm::TFGraph}. | 39 // Expose {Node} and {Graph} opaquely as {wasm::TFNode} and {wasm::TFGraph}. |
38 typedef compiler::Node TFNode; | 40 typedef compiler::Node TFNode; |
39 typedef compiler::JSGraph TFGraph; | 41 typedef compiler::JSGraph TFGraph; |
40 } // namespace wasm | 42 } // namespace wasm |
41 | 43 |
42 namespace compiler { | 44 namespace compiler { |
43 class WasmCompilationUnit final { | 45 class WasmCompilationUnit final { |
44 public: | 46 public: |
45 WasmCompilationUnit(wasm::ErrorThrower* thrower, Isolate* isolate, | 47 WasmCompilationUnit(wasm::ErrorThrower* thrower, Isolate* isolate, |
46 wasm::ModuleEnv* module_env, | 48 wasm::ModuleBytesEnv* module_env, |
47 const wasm::WasmFunction* function, uint32_t index); | 49 const wasm::WasmFunction* function, uint32_t index); |
48 | 50 |
49 Zone* graph_zone() { return graph_zone_.get(); } | 51 Zone* graph_zone() { return graph_zone_.get(); } |
50 int index() const { return index_; } | 52 int index() const { return index_; } |
51 | 53 |
52 void ExecuteCompilation(); | 54 void ExecuteCompilation(); |
53 Handle<Code> FinishCompilation(); | 55 Handle<Code> FinishCompilation(); |
54 | 56 |
55 static Handle<Code> CompileWasmFunction(wasm::ErrorThrower* thrower, | 57 static Handle<Code> CompileWasmFunction(wasm::ErrorThrower* thrower, |
56 Isolate* isolate, | 58 Isolate* isolate, |
57 wasm::ModuleEnv* module_env, | 59 wasm::ModuleBytesEnv* module_env, |
58 const wasm::WasmFunction* function) { | 60 const wasm::WasmFunction* function) { |
59 WasmCompilationUnit unit(thrower, isolate, module_env, function, 0); | 61 WasmCompilationUnit unit(thrower, isolate, module_env, function, 0); |
60 unit.ExecuteCompilation(); | 62 unit.ExecuteCompilation(); |
61 return unit.FinishCompilation(); | 63 return unit.FinishCompilation(); |
62 } | 64 } |
63 | 65 |
64 private: | 66 private: |
65 SourcePositionTable* BuildGraphForWasmFunction(double* decode_ms); | 67 SourcePositionTable* BuildGraphForWasmFunction(double* decode_ms); |
66 | 68 |
67 wasm::ErrorThrower* thrower_; | 69 wasm::ErrorThrower* thrower_; |
68 Isolate* isolate_; | 70 Isolate* isolate_; |
69 wasm::ModuleEnv* module_env_; | 71 wasm::ModuleBytesEnv* module_env_; |
70 const wasm::WasmFunction* function_; | 72 const wasm::WasmFunction* function_; |
71 // The graph zone is deallocated at the end of ExecuteCompilation. | 73 // The graph zone is deallocated at the end of ExecuteCompilation. |
72 std::unique_ptr<Zone> graph_zone_; | 74 std::unique_ptr<Zone> graph_zone_; |
73 JSGraph* jsgraph_; | 75 JSGraph* jsgraph_; |
74 Zone compilation_zone_; | 76 Zone compilation_zone_; |
75 CompilationInfo info_; | 77 CompilationInfo info_; |
76 std::unique_ptr<CompilationJob> job_; | 78 std::unique_ptr<CompilationJob> job_; |
77 uint32_t index_; | 79 uint32_t index_; |
78 wasm::Result<wasm::DecodeStruct*> graph_construction_result_; | 80 wasm::Result<wasm::DecodeStruct*> graph_construction_result_; |
79 bool ok_; | 81 bool ok_; |
80 | 82 |
81 DISALLOW_COPY_AND_ASSIGN(WasmCompilationUnit); | 83 DISALLOW_COPY_AND_ASSIGN(WasmCompilationUnit); |
82 }; | 84 }; |
83 | 85 |
84 // Wraps a JS function, producing a code object that can be called from WASM. | 86 // Wraps a JS function, producing a code object that can be called from WASM. |
85 Handle<Code> CompileWasmToJSWrapper(Isolate* isolate, Handle<JSReceiver> target, | 87 Handle<Code> CompileWasmToJSWrapper(Isolate* isolate, Handle<JSReceiver> target, |
86 wasm::FunctionSig* sig, uint32_t index, | 88 wasm::FunctionSig* sig, uint32_t index, |
87 Handle<String> module_name, | 89 Handle<String> module_name, |
88 MaybeHandle<String> import_name); | 90 MaybeHandle<String> import_name); |
89 | 91 |
90 // Wraps a given wasm code object, producing a code object. | 92 // Wraps a given wasm code object, producing a code object. |
91 Handle<Code> CompileJSToWasmWrapper(Isolate* isolate, wasm::ModuleEnv* module, | 93 Handle<Code> CompileJSToWasmWrapper(Isolate* isolate, |
| 94 const wasm::WasmModule* module, |
92 Handle<Code> wasm_code, uint32_t index); | 95 Handle<Code> wasm_code, uint32_t index); |
93 | 96 |
94 // Abstracts details of building TurboFan graph nodes for WASM to separate | 97 // Abstracts details of building TurboFan graph nodes for WASM to separate |
95 // the WASM decoder from the internal details of TurboFan. | 98 // the WASM decoder from the internal details of TurboFan. |
96 class WasmTrapHelper; | 99 class WasmTrapHelper; |
97 typedef ZoneVector<Node*> NodeVector; | 100 typedef ZoneVector<Node*> NodeVector; |
98 class WasmGraphBuilder { | 101 class WasmGraphBuilder { |
99 public: | 102 public: |
100 WasmGraphBuilder( | 103 WasmGraphBuilder( |
101 Zone* z, JSGraph* g, wasm::FunctionSig* function_signature, | 104 Zone* z, JSGraph* g, wasm::FunctionSig* function_signature, |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 } | 354 } |
352 | 355 |
353 int AddParameterNodes(Node** args, int pos, int param_count, | 356 int AddParameterNodes(Node** args, int pos, int param_count, |
354 wasm::FunctionSig* sig); | 357 wasm::FunctionSig* sig); |
355 }; | 358 }; |
356 } // namespace compiler | 359 } // namespace compiler |
357 } // namespace internal | 360 } // namespace internal |
358 } // namespace v8 | 361 } // namespace v8 |
359 | 362 |
360 #endif // V8_COMPILER_WASM_COMPILER_H_ | 363 #endif // V8_COMPILER_WASM_COMPILER_H_ |
OLD | NEW |