Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/compiler/wasm-compiler.h

Issue 1890803002: [wasm] Generate source position information (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@wasm-throw-error
Patch Set: some doc and fixes Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/wasm/wasm-opcodes.h" 10 #include "src/wasm/wasm-opcodes.h"
11 #include "src/zone.h" 11 #include "src/zone.h"
12 12
13 namespace v8 { 13 namespace v8 {
14 namespace internal { 14 namespace internal {
15 15
16 namespace compiler { 16 namespace compiler {
17 // Forward declarations for some compiler data structures. 17 // Forward declarations for some compiler data structures.
18 class Node; 18 class Node;
19 class JSGraph; 19 class JSGraph;
20 class Graph; 20 class Graph;
21 class SourcePositionTable;
22 class SourcePositionScope;
21 } 23 }
22 24
23 namespace wasm { 25 namespace wasm {
24 // Forward declarations for some WASM data structures. 26 // Forward declarations for some WASM data structures.
25 struct ModuleEnv; 27 struct ModuleEnv;
26 struct WasmFunction; 28 struct WasmFunction;
27 class ErrorThrower; 29 class ErrorThrower;
28 30
29 // Expose {Node} and {Graph} opaquely as {wasm::TFNode} and {wasm::TFGraph}. 31 // Expose {Node} and {Graph} opaquely as {wasm::TFNode} and {wasm::TFGraph}.
30 typedef compiler::Node TFNode; 32 typedef compiler::Node TFNode;
(...skipping 17 matching lines...) Expand all
48 // from JavaScript. 50 // from JavaScript.
49 Handle<JSFunction> CompileJSToWasmWrapper( 51 Handle<JSFunction> CompileJSToWasmWrapper(
50 Isolate* isolate, wasm::ModuleEnv* module, Handle<String> name, 52 Isolate* isolate, wasm::ModuleEnv* module, Handle<String> name,
51 Handle<Code> wasm_code, Handle<JSObject> module_object, uint32_t index); 53 Handle<Code> wasm_code, Handle<JSObject> module_object, uint32_t index);
52 54
53 // Abstracts details of building TurboFan graph nodes for WASM to separate 55 // Abstracts details of building TurboFan graph nodes for WASM to separate
54 // the WASM decoder from the internal details of TurboFan. 56 // the WASM decoder from the internal details of TurboFan.
55 class WasmTrapHelper; 57 class WasmTrapHelper;
56 class WasmGraphBuilder { 58 class WasmGraphBuilder {
57 public: 59 public:
58 WasmGraphBuilder(Zone* z, JSGraph* g, wasm::FunctionSig* function_signature); 60 WasmGraphBuilder(
61 Zone* z, JSGraph* g, wasm::FunctionSig* function_signature,
62 compiler::SourcePositionTable* source_position_table = nullptr);
63
64 ~WasmGraphBuilder() {
65 // check that Enter- / LeaveSourcePositionScope is balanced
66 DCHECK_NULL(source_position_scope_);
67 }
59 68
60 Node** Buffer(size_t count) { 69 Node** Buffer(size_t count) {
61 if (count > cur_bufsize_) { 70 if (count > cur_bufsize_) {
62 size_t new_size = count + cur_bufsize_ + 5; 71 size_t new_size = count + cur_bufsize_ + 5;
63 cur_buffer_ = 72 cur_buffer_ =
64 reinterpret_cast<Node**>(zone_->New(new_size * sizeof(Node*))); 73 reinterpret_cast<Node**>(zone_->New(new_size * sizeof(Node*)));
65 cur_bufsize_ = new_size; 74 cur_bufsize_ = new_size;
66 } 75 }
67 return cur_buffer_; 76 return cur_buffer_;
68 } 77 }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 void set_module(wasm::ModuleEnv* module) { this->module_ = module; } 143 void set_module(wasm::ModuleEnv* module) { this->module_ = module; }
135 144
136 void set_control_ptr(Node** control) { this->control_ = control; } 145 void set_control_ptr(Node** control) { this->control_ = control; }
137 146
138 void set_effect_ptr(Node** effect) { this->effect_ = effect; } 147 void set_effect_ptr(Node** effect) { this->effect_ = effect; }
139 148
140 wasm::FunctionSig* GetFunctionSignature() { return function_signature_; } 149 wasm::FunctionSig* GetFunctionSignature() { return function_signature_; }
141 150
142 void Int64LoweringForTesting(); 151 void Int64LoweringForTesting();
143 152
153 // Register a graph decorator to assign source positions to nodes (in
titzer 2016/04/18 11:03:51 I don't think we should add scoping for this. I th
Clemens Hammacher 2016/04/18 11:18:10 What about step-through debugging? Wouldn't that r
154 // source_position_table_). Only has an effect if source_position_table_ is
155 // non-null. Ensure to call LeaveSourcePositionScope afterwards.
156 void EnterSourcePositionScope();
157 void LeaveSourcePositionScope();
158
159 // Set current source position, such that all nodes created after this call
160 // get the respecitve position assigned. This only has an effect if
161 // source_position_table_ is non-null and EnterSourcePositionScope was called
162 // before.
163 void SetCurrentSourcePosition(int position);
164
144 private: 165 private:
145 static const int kDefaultBufferSize = 16; 166 static const int kDefaultBufferSize = 16;
146 friend class WasmTrapHelper; 167 friend class WasmTrapHelper;
147 168
148 Zone* zone_; 169 Zone* zone_;
149 JSGraph* jsgraph_; 170 JSGraph* jsgraph_;
150 wasm::ModuleEnv* module_; 171 wasm::ModuleEnv* module_;
151 Node* mem_buffer_; 172 Node* mem_buffer_;
152 Node* mem_size_; 173 Node* mem_size_;
153 Node* function_table_; 174 Node* function_table_;
154 Node** control_; 175 Node** control_;
155 Node** effect_; 176 Node** effect_;
156 Node** cur_buffer_; 177 Node** cur_buffer_;
157 size_t cur_bufsize_; 178 size_t cur_bufsize_;
158 Node* def_buffer_[kDefaultBufferSize]; 179 Node* def_buffer_[kDefaultBufferSize];
159 180
160 WasmTrapHelper* trap_; 181 WasmTrapHelper* trap_;
161 wasm::FunctionSig* function_signature_; 182 wasm::FunctionSig* function_signature_;
162 183
184 compiler::SourcePositionTable* source_position_table_ = nullptr;
185 compiler::SourcePositionScope* source_position_scope_ = nullptr;
186
163 // Internal helper methods. 187 // Internal helper methods.
164 JSGraph* jsgraph() { return jsgraph_; } 188 JSGraph* jsgraph() { return jsgraph_; }
165 Graph* graph(); 189 Graph* graph();
166 190
167 Node* String(const char* string); 191 Node* String(const char* string);
168 Node* MemBuffer(uint32_t offset); 192 Node* MemBuffer(uint32_t offset);
169 void BoundsCheckMem(MachineType memtype, Node* index, uint32_t offset); 193 void BoundsCheckMem(MachineType memtype, Node* index, uint32_t offset);
170 194
171 Node* MaskShiftCount32(Node* node); 195 Node* MaskShiftCount32(Node* node);
172 Node* MaskShiftCount64(Node* node); 196 Node* MaskShiftCount64(Node* node);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 Node** buf = Buffer(new_count); 273 Node** buf = Buffer(new_count);
250 if (buf != buffer) memcpy(buf, buffer, old_count * sizeof(Node*)); 274 if (buf != buffer) memcpy(buf, buffer, old_count * sizeof(Node*));
251 return buf; 275 return buf;
252 } 276 }
253 }; 277 };
254 } // namespace compiler 278 } // namespace compiler
255 } // namespace internal 279 } // namespace internal
256 } // namespace v8 280 } // namespace v8
257 281
258 #endif // V8_COMPILER_WASM_COMPILER_H_ 282 #endif // V8_COMPILER_WASM_COMPILER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698