| 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 30 matching lines...) Expand all Loading... |
| 41 | 41 |
| 42 // Expose {Node} and {Graph} opaquely as {wasm::TFNode} and {wasm::TFGraph}. | 42 // Expose {Node} and {Graph} opaquely as {wasm::TFNode} and {wasm::TFGraph}. |
| 43 typedef compiler::Node TFNode; | 43 typedef compiler::Node TFNode; |
| 44 typedef compiler::JSGraph TFGraph; | 44 typedef compiler::JSGraph TFGraph; |
| 45 } // namespace wasm | 45 } // namespace wasm |
| 46 | 46 |
| 47 namespace compiler { | 47 namespace compiler { |
| 48 class WasmCompilationUnit final { | 48 class WasmCompilationUnit final { |
| 49 public: | 49 public: |
| 50 WasmCompilationUnit(Isolate* isolate, wasm::ModuleBytesEnv* module_env, | 50 WasmCompilationUnit(Isolate* isolate, wasm::ModuleBytesEnv* module_env, |
| 51 const wasm::WasmFunction* function); | 51 const wasm::WasmFunction* function, bool is_sync = true); |
| 52 WasmCompilationUnit(Isolate* isolate, wasm::ModuleEnv* module_env, | 52 WasmCompilationUnit(Isolate* isolate, wasm::ModuleEnv* module_env, |
| 53 wasm::FunctionBody body, wasm::WasmName name, int index); | 53 wasm::FunctionBody body, wasm::WasmName name, int index, |
| 54 bool is_sync = true); |
| 54 | 55 |
| 55 Zone* graph_zone() { return graph_zone_.get(); } | 56 Zone* graph_zone() { return graph_zone_.get(); } |
| 56 int func_index() const { return func_index_; } | 57 int func_index() const { return func_index_; } |
| 57 | 58 |
| 58 void InitializeHandles(); | 59 void InitializeHandles(); |
| 59 void ExecuteCompilation(); | 60 void ExecuteCompilation(); |
| 60 Handle<Code> FinishCompilation(wasm::ErrorThrower* thrower); | 61 Handle<Code> FinishCompilation(wasm::ErrorThrower* thrower); |
| 61 | 62 |
| 62 static Handle<Code> CompileWasmFunction(wasm::ErrorThrower* thrower, | 63 static Handle<Code> CompileWasmFunction(wasm::ErrorThrower* thrower, |
| 63 Isolate* isolate, | 64 Isolate* isolate, |
| 64 wasm::ModuleBytesEnv* module_env, | 65 wasm::ModuleBytesEnv* module_env, |
| 65 const wasm::WasmFunction* function); | 66 const wasm::WasmFunction* function); |
| 66 | 67 |
| 67 private: | 68 private: |
| 68 SourcePositionTable* BuildGraphForWasmFunction(double* decode_ms); | 69 SourcePositionTable* BuildGraphForWasmFunction(double* decode_ms); |
| 69 | 70 |
| 70 Isolate* isolate_; | 71 Isolate* isolate_; |
| 71 wasm::ModuleEnv* module_env_; | 72 wasm::ModuleEnv* module_env_; |
| 72 wasm::FunctionBody func_body_; | 73 wasm::FunctionBody func_body_; |
| 73 wasm::WasmName func_name_; | 74 wasm::WasmName func_name_; |
| 75 bool is_sync_; |
| 74 // The graph zone is deallocated at the end of ExecuteCompilation. | 76 // The graph zone is deallocated at the end of ExecuteCompilation. |
| 75 std::unique_ptr<Zone> graph_zone_; | 77 std::unique_ptr<Zone> graph_zone_; |
| 76 JSGraph* jsgraph_; | 78 JSGraph* jsgraph_; |
| 77 Zone compilation_zone_; | 79 Zone compilation_zone_; |
| 78 CompilationInfo info_; | 80 CompilationInfo info_; |
| 79 std::unique_ptr<CompilationJob> job_; | 81 std::unique_ptr<CompilationJob> job_; |
| 80 int func_index_; | 82 int func_index_; |
| 81 wasm::Result<wasm::DecodeStruct*> graph_construction_result_; | 83 wasm::Result<wasm::DecodeStruct*> graph_construction_result_; |
| 82 bool ok_ = true; | 84 bool ok_ = true; |
| 83 #if DEBUG | 85 #if DEBUG |
| 84 bool handles_initialized_ = false; | 86 bool handles_initialized_ = false; |
| 85 #endif // DEBUG | 87 #endif // DEBUG |
| 86 ZoneVector<trap_handler::ProtectedInstructionData> | 88 ZoneVector<trap_handler::ProtectedInstructionData> |
| 87 protected_instructions_; // Instructions that are protected by the signal | 89 protected_instructions_; // Instructions that are protected by the signal |
| 88 // handler. | 90 // handler. |
| 89 | 91 |
| 92 void ExecuteCompilationInternal(); |
| 93 |
| 90 DISALLOW_COPY_AND_ASSIGN(WasmCompilationUnit); | 94 DISALLOW_COPY_AND_ASSIGN(WasmCompilationUnit); |
| 91 }; | 95 }; |
| 92 | 96 |
| 93 // Wraps a JS function, producing a code object that can be called from WASM. | 97 // Wraps a JS function, producing a code object that can be called from WASM. |
| 94 Handle<Code> CompileWasmToJSWrapper(Isolate* isolate, Handle<JSReceiver> target, | 98 Handle<Code> CompileWasmToJSWrapper(Isolate* isolate, Handle<JSReceiver> target, |
| 95 wasm::FunctionSig* sig, uint32_t index, | 99 wasm::FunctionSig* sig, uint32_t index, |
| 96 Handle<String> module_name, | 100 Handle<String> module_name, |
| 97 MaybeHandle<String> import_name, | 101 MaybeHandle<String> import_name, |
| 98 wasm::ModuleOrigin origin); | 102 wasm::ModuleOrigin origin); |
| 99 | 103 |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 } | 405 } |
| 402 | 406 |
| 403 int AddParameterNodes(Node** args, int pos, int param_count, | 407 int AddParameterNodes(Node** args, int pos, int param_count, |
| 404 wasm::FunctionSig* sig); | 408 wasm::FunctionSig* sig); |
| 405 }; | 409 }; |
| 406 } // namespace compiler | 410 } // namespace compiler |
| 407 } // namespace internal | 411 } // namespace internal |
| 408 } // namespace v8 | 412 } // namespace v8 |
| 409 | 413 |
| 410 #endif // V8_COMPILER_WASM_COMPILER_H_ | 414 #endif // V8_COMPILER_WASM_COMPILER_H_ |
| OLD | NEW |