| 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. |
| 11 // Do not include anything from src/compiler here! | 11 // Do not include anything from src/compiler here! |
| 12 #include "src/compilation-info.h" | 12 #include "src/compilation-info.h" |
| 13 #include "src/compiler.h" | 13 #include "src/compiler.h" |
| 14 #include "src/wasm/wasm-module.h" |
| 14 #include "src/wasm/wasm-opcodes.h" | 15 #include "src/wasm/wasm-opcodes.h" |
| 15 #include "src/wasm/wasm-result.h" | 16 #include "src/wasm/wasm-result.h" |
| 16 #include "src/zone/zone.h" | 17 #include "src/zone/zone.h" |
| 17 | 18 |
| 18 namespace v8 { | 19 namespace v8 { |
| 19 namespace internal { | 20 namespace internal { |
| 20 | 21 |
| 21 namespace compiler { | 22 namespace compiler { |
| 22 // Forward declarations for some compiler data structures. | 23 // Forward declarations for some compiler data structures. |
| 23 class Node; | 24 class Node; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 49 Zone* graph_zone() { return graph_zone_.get(); } | 50 Zone* graph_zone() { return graph_zone_.get(); } |
| 50 int index() const { return index_; } | 51 int index() const { return index_; } |
| 51 | 52 |
| 52 void ExecuteCompilation(); | 53 void ExecuteCompilation(); |
| 53 Handle<Code> FinishCompilation(); | 54 Handle<Code> FinishCompilation(); |
| 54 | 55 |
| 55 static Handle<Code> CompileWasmFunction(wasm::ErrorThrower* thrower, | 56 static Handle<Code> CompileWasmFunction(wasm::ErrorThrower* thrower, |
| 56 Isolate* isolate, | 57 Isolate* isolate, |
| 57 wasm::ModuleEnv* module_env, | 58 wasm::ModuleEnv* module_env, |
| 58 const wasm::WasmFunction* function) { | 59 const wasm::WasmFunction* function) { |
| 59 WasmCompilationUnit unit(thrower, isolate, module_env, function, 0); | 60 WasmCompilationUnit unit(thrower, isolate, module_env, function, |
| 61 function->func_index); |
| 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); |
| 68 Handle<FixedArray> PackProtectedInstructions() const; |
| 66 | 69 |
| 67 wasm::ErrorThrower* thrower_; | 70 wasm::ErrorThrower* thrower_; |
| 68 Isolate* isolate_; | 71 Isolate* isolate_; |
| 69 wasm::ModuleEnv* module_env_; | 72 wasm::ModuleEnv* module_env_; |
| 70 const wasm::WasmFunction* function_; | 73 const wasm::WasmFunction* function_; |
| 71 // The graph zone is deallocated at the end of ExecuteCompilation. | 74 // The graph zone is deallocated at the end of ExecuteCompilation. |
| 72 std::unique_ptr<Zone> graph_zone_; | 75 std::unique_ptr<Zone> graph_zone_; |
| 73 JSGraph* jsgraph_; | 76 JSGraph* jsgraph_; |
| 74 Zone compilation_zone_; | 77 Zone compilation_zone_; |
| 75 CompilationInfo info_; | 78 CompilationInfo info_; |
| 76 std::unique_ptr<CompilationJob> job_; | 79 std::unique_ptr<CompilationJob> job_; |
| 77 uint32_t index_; | 80 uint32_t index_; |
| 78 wasm::Result<wasm::DecodeStruct*> graph_construction_result_; | 81 wasm::Result<wasm::DecodeStruct*> graph_construction_result_; |
| 79 bool ok_; | 82 bool ok_; |
| 83 ProtectedInstructionList protected_instructions_; // Instructions that are |
| 84 // protected by the signal |
| 85 // handler. |
| 80 | 86 |
| 81 DISALLOW_COPY_AND_ASSIGN(WasmCompilationUnit); | 87 DISALLOW_COPY_AND_ASSIGN(WasmCompilationUnit); |
| 82 }; | 88 }; |
| 83 | 89 |
| 84 // Wraps a JS function, producing a code object that can be called from WASM. | 90 // Wraps a JS function, producing a code object that can be called from WASM. |
| 85 Handle<Code> CompileWasmToJSWrapper(Isolate* isolate, Handle<JSReceiver> target, | 91 Handle<Code> CompileWasmToJSWrapper(Isolate* isolate, Handle<JSReceiver> target, |
| 86 wasm::FunctionSig* sig, uint32_t index, | 92 wasm::FunctionSig* sig, uint32_t index, |
| 87 Handle<String> module_name, | 93 Handle<String> module_name, |
| 88 MaybeHandle<String> import_name); | 94 MaybeHandle<String> import_name); |
| 89 | 95 |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 } | 357 } |
| 352 | 358 |
| 353 int AddParameterNodes(Node** args, int pos, int param_count, | 359 int AddParameterNodes(Node** args, int pos, int param_count, |
| 354 wasm::FunctionSig* sig); | 360 wasm::FunctionSig* sig); |
| 355 }; | 361 }; |
| 356 } // namespace compiler | 362 } // namespace compiler |
| 357 } // namespace internal | 363 } // namespace internal |
| 358 } // namespace v8 | 364 } // namespace v8 |
| 359 | 365 |
| 360 #endif // V8_COMPILER_WASM_COMPILER_H_ | 366 #endif // V8_COMPILER_WASM_COMPILER_H_ |
| OLD | NEW |