| 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/compiler.h" | 10 #include "src/compiler.h" |
| 11 #include "src/wasm/wasm-opcodes.h" | 11 #include "src/wasm/wasm-opcodes.h" |
| 12 #include "src/wasm/wasm-result.h" |
| 12 #include "src/zone.h" | 13 #include "src/zone.h" |
| 13 | 14 |
| 14 namespace v8 { | 15 namespace v8 { |
| 15 namespace internal { | 16 namespace internal { |
| 16 | 17 |
| 17 namespace compiler { | 18 namespace compiler { |
| 18 // Forward declarations for some compiler data structures. | 19 // Forward declarations for some compiler data structures. |
| 19 class Node; | 20 class Node; |
| 20 class JSGraph; | 21 class JSGraph; |
| 21 class Graph; | 22 class Graph; |
| 22 class Operator; | 23 class Operator; |
| 23 class SourcePositionTable; | 24 class SourcePositionTable; |
| 24 } | 25 } // namespace compiler |
| 25 | 26 |
| 26 namespace wasm { | 27 namespace wasm { |
| 27 // Forward declarations for some WASM data structures. | 28 // Forward declarations for some WASM data structures. |
| 28 struct ModuleEnv; | 29 struct ModuleEnv; |
| 29 struct WasmFunction; | 30 struct WasmFunction; |
| 30 class ErrorThrower; | 31 class ErrorThrower; |
| 32 struct Tree; |
| 31 | 33 |
| 32 // Expose {Node} and {Graph} opaquely as {wasm::TFNode} and {wasm::TFGraph}. | 34 // Expose {Node} and {Graph} opaquely as {wasm::TFNode} and {wasm::TFGraph}. |
| 33 typedef compiler::Node TFNode; | 35 typedef compiler::Node TFNode; |
| 34 typedef compiler::JSGraph TFGraph; | 36 typedef compiler::JSGraph TFGraph; |
| 35 } | 37 } // namespace wasm |
| 36 | 38 |
| 37 namespace compiler { | 39 namespace compiler { |
| 38 class WasmCompilationUnit final { | 40 class WasmCompilationUnit final { |
| 39 public: | 41 public: |
| 40 WasmCompilationUnit(wasm::ErrorThrower* thrower, Isolate* isolate, | 42 WasmCompilationUnit(wasm::ErrorThrower* thrower, Isolate* isolate, |
| 41 wasm::ModuleEnv* module_env, | 43 wasm::ModuleEnv* module_env, |
| 42 const wasm::WasmFunction* function, uint32_t index); | 44 const wasm::WasmFunction* function, uint32_t index); |
| 43 | 45 |
| 44 Zone* graph_zone() { return graph_zone_.get(); } | 46 Zone* graph_zone() { return graph_zone_.get(); } |
| 45 int index() const { return index_; } | 47 int index() const { return index_; } |
| 46 | 48 |
| 47 void ExecuteCompilation(); | 49 void ExecuteCompilation(); |
| 48 Handle<Code> FinishCompilation(); | 50 Handle<Code> FinishCompilation(); |
| 49 | 51 |
| 50 static Handle<Code> CompileWasmFunction(wasm::ErrorThrower* thrower, | 52 static Handle<Code> CompileWasmFunction(wasm::ErrorThrower* thrower, |
| 51 Isolate* isolate, | 53 Isolate* isolate, |
| 52 wasm::ModuleEnv* module_env, | 54 wasm::ModuleEnv* module_env, |
| 53 const wasm::WasmFunction* function) { | 55 const wasm::WasmFunction* function) { |
| 54 WasmCompilationUnit unit(thrower, isolate, module_env, function, 0); | 56 WasmCompilationUnit unit(thrower, isolate, module_env, function, 0); |
| 55 unit.ExecuteCompilation(); | 57 unit.ExecuteCompilation(); |
| 56 return unit.FinishCompilation(); | 58 return unit.FinishCompilation(); |
| 57 } | 59 } |
| 58 | 60 |
| 59 private: | 61 private: |
| 62 SourcePositionTable* BuildGraphForWasmFunction(double* decode_ms); |
| 63 |
| 60 wasm::ErrorThrower* thrower_; | 64 wasm::ErrorThrower* thrower_; |
| 61 Isolate* isolate_; | 65 Isolate* isolate_; |
| 62 wasm::ModuleEnv* module_env_; | 66 wasm::ModuleEnv* module_env_; |
| 63 const wasm::WasmFunction* function_; | 67 const wasm::WasmFunction* function_; |
| 64 // The graph zone is deallocated at the end of ExecuteCompilation. | 68 // The graph zone is deallocated at the end of ExecuteCompilation. |
| 65 base::SmartPointer<Zone> graph_zone_; | 69 base::SmartPointer<Zone> graph_zone_; |
| 66 JSGraph* jsgraph_; | 70 JSGraph* jsgraph_; |
| 67 Zone compilation_zone_; | 71 Zone compilation_zone_; |
| 68 CompilationInfo info_; | 72 CompilationInfo info_; |
| 69 base::SmartPointer<CompilationJob> job_; | 73 base::SmartPointer<CompilationJob> job_; |
| 70 uint32_t index_; | 74 uint32_t index_; |
| 75 wasm::Result<wasm::Tree*> graph_construction_result_; |
| 71 bool ok_; | 76 bool ok_; |
| 72 }; | 77 }; |
| 73 | 78 |
| 74 // Wraps a JS function, producing a code object that can be called from WASM. | 79 // Wraps a JS function, producing a code object that can be called from WASM. |
| 75 Handle<Code> CompileWasmToJSWrapper(Isolate* isolate, wasm::ModuleEnv* module, | 80 Handle<Code> CompileWasmToJSWrapper(Isolate* isolate, wasm::ModuleEnv* module, |
| 76 Handle<JSFunction> function, | 81 Handle<JSFunction> function, |
| 77 wasm::FunctionSig* sig, | 82 wasm::FunctionSig* sig, |
| 78 wasm::WasmName module_name, | 83 wasm::WasmName module_name, |
| 79 wasm::WasmName function_name); | 84 wasm::WasmName function_name); |
| 80 | 85 |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 Node** buf = Buffer(new_count); | 348 Node** buf = Buffer(new_count); |
| 344 if (buf != buffer) memcpy(buf, buffer, old_count * sizeof(Node*)); | 349 if (buf != buffer) memcpy(buf, buffer, old_count * sizeof(Node*)); |
| 345 return buf; | 350 return buf; |
| 346 } | 351 } |
| 347 }; | 352 }; |
| 348 } // namespace compiler | 353 } // namespace compiler |
| 349 } // namespace internal | 354 } // namespace internal |
| 350 } // namespace v8 | 355 } // namespace v8 |
| 351 | 356 |
| 352 #endif // V8_COMPILER_WASM_COMPILER_H_ | 357 #endif // V8_COMPILER_WASM_COMPILER_H_ |
| OLD | NEW |