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