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/trap-handler/trap-handler.h" |
| 15 #include "src/wasm/wasm-module.h" |
14 #include "src/wasm/wasm-opcodes.h" | 16 #include "src/wasm/wasm-opcodes.h" |
15 #include "src/wasm/wasm-result.h" | 17 #include "src/wasm/wasm-result.h" |
16 #include "src/zone/zone.h" | 18 #include "src/zone/zone.h" |
17 | 19 |
18 namespace v8 { | 20 namespace v8 { |
19 namespace internal { | 21 namespace internal { |
20 | 22 |
21 namespace compiler { | 23 namespace compiler { |
22 // Forward declarations for some compiler data structures. | 24 // Forward declarations for some compiler data structures. |
23 class Node; | 25 class Node; |
(...skipping 27 matching lines...) Expand all Loading... |
51 Zone* graph_zone() { return graph_zone_.get(); } | 53 Zone* graph_zone() { return graph_zone_.get(); } |
52 int index() const { return index_; } | 54 int index() const { return index_; } |
53 | 55 |
54 void ExecuteCompilation(); | 56 void ExecuteCompilation(); |
55 Handle<Code> FinishCompilation(); | 57 Handle<Code> FinishCompilation(); |
56 | 58 |
57 static Handle<Code> CompileWasmFunction(wasm::ErrorThrower* thrower, | 59 static Handle<Code> CompileWasmFunction(wasm::ErrorThrower* thrower, |
58 Isolate* isolate, | 60 Isolate* isolate, |
59 wasm::ModuleBytesEnv* module_env, | 61 wasm::ModuleBytesEnv* module_env, |
60 const wasm::WasmFunction* function) { | 62 const wasm::WasmFunction* function) { |
61 WasmCompilationUnit unit(thrower, isolate, module_env, function, 0); | 63 WasmCompilationUnit unit(thrower, isolate, module_env, function, |
| 64 function->func_index); |
62 unit.ExecuteCompilation(); | 65 unit.ExecuteCompilation(); |
63 return unit.FinishCompilation(); | 66 return unit.FinishCompilation(); |
64 } | 67 } |
65 | 68 |
66 private: | 69 private: |
67 SourcePositionTable* BuildGraphForWasmFunction(double* decode_ms); | 70 SourcePositionTable* BuildGraphForWasmFunction(double* decode_ms); |
| 71 Handle<FixedArray> PackProtectedInstructions() const; |
68 | 72 |
69 wasm::ErrorThrower* thrower_; | 73 wasm::ErrorThrower* thrower_; |
70 Isolate* isolate_; | 74 Isolate* isolate_; |
71 wasm::ModuleBytesEnv* module_env_; | 75 wasm::ModuleBytesEnv* module_env_; |
72 const wasm::WasmFunction* function_; | 76 const wasm::WasmFunction* function_; |
73 // The graph zone is deallocated at the end of ExecuteCompilation. | 77 // The graph zone is deallocated at the end of ExecuteCompilation. |
74 std::unique_ptr<Zone> graph_zone_; | 78 std::unique_ptr<Zone> graph_zone_; |
75 JSGraph* jsgraph_; | 79 JSGraph* jsgraph_; |
76 Zone compilation_zone_; | 80 Zone compilation_zone_; |
77 CompilationInfo info_; | 81 CompilationInfo info_; |
78 std::unique_ptr<CompilationJob> job_; | 82 std::unique_ptr<CompilationJob> job_; |
79 uint32_t index_; | 83 uint32_t index_; |
80 wasm::Result<wasm::DecodeStruct*> graph_construction_result_; | 84 wasm::Result<wasm::DecodeStruct*> graph_construction_result_; |
81 bool ok_; | 85 bool ok_; |
| 86 ZoneVector<trap_handler::ProtectedInstructionData> |
| 87 protected_instructions_; // Instructions that are protected by the signal |
| 88 // handler. |
82 | 89 |
83 DISALLOW_COPY_AND_ASSIGN(WasmCompilationUnit); | 90 DISALLOW_COPY_AND_ASSIGN(WasmCompilationUnit); |
84 }; | 91 }; |
85 | 92 |
86 // 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. |
87 Handle<Code> CompileWasmToJSWrapper(Isolate* isolate, Handle<JSReceiver> target, | 94 Handle<Code> CompileWasmToJSWrapper(Isolate* isolate, Handle<JSReceiver> target, |
88 wasm::FunctionSig* sig, uint32_t index, | 95 wasm::FunctionSig* sig, uint32_t index, |
89 Handle<String> module_name, | 96 Handle<String> module_name, |
90 MaybeHandle<String> import_name); | 97 MaybeHandle<String> import_name); |
91 | 98 |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 } | 361 } |
355 | 362 |
356 int AddParameterNodes(Node** args, int pos, int param_count, | 363 int AddParameterNodes(Node** args, int pos, int param_count, |
357 wasm::FunctionSig* sig); | 364 wasm::FunctionSig* sig); |
358 }; | 365 }; |
359 } // namespace compiler | 366 } // namespace compiler |
360 } // namespace internal | 367 } // namespace internal |
361 } // namespace v8 | 368 } // namespace v8 |
362 | 369 |
363 #endif // V8_COMPILER_WASM_COMPILER_H_ | 370 #endif // V8_COMPILER_WASM_COMPILER_H_ |
OLD | NEW |