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

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

Issue 2345593003: [wasm] Master CL for Binary 0xC changes. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix test failures and TSAN races. Created 4 years, 2 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
« no previous file with comments | « src/wasm/wasm-debug.cc ('k') | src/wasm/wasm-interpreter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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_WASM_INTERPRETER_H_ 5 #ifndef V8_WASM_INTERPRETER_H_
6 #define V8_WASM_INTERPRETER_H_ 6 #define V8_WASM_INTERPRETER_H_
7 7
8 #include "src/wasm/wasm-opcodes.h" 8 #include "src/wasm/wasm-opcodes.h"
9 #include "src/zone/zone-containers.h" 9 #include "src/zone/zone-containers.h"
10 10
(...skipping 10 matching lines...) Expand all
21 struct WasmModuleInstance; 21 struct WasmModuleInstance;
22 class WasmInterpreterInternals; 22 class WasmInterpreterInternals;
23 23
24 typedef size_t pc_t; 24 typedef size_t pc_t;
25 typedef size_t sp_t; 25 typedef size_t sp_t;
26 typedef int32_t pcdiff_t; 26 typedef int32_t pcdiff_t;
27 typedef uint32_t spdiff_t; 27 typedef uint32_t spdiff_t;
28 28
29 const pc_t kInvalidPc = 0x80000000; 29 const pc_t kInvalidPc = 0x80000000;
30 30
31 // Visible for testing. A {ControlTransfer} helps the interpreter figure out 31 typedef ZoneMap<pc_t, pcdiff_t> ControlTransferMap;
32 // the target program counter and stack manipulations for a branch.
33 struct ControlTransfer {
34 enum StackAction { kNoAction, kPopAndRepush, kPushVoid };
35 pcdiff_t pcdiff; // adjustment to the program counter (positive or negative).
36 spdiff_t spdiff; // number of elements to pop off the stack.
37 StackAction action; // action to perform on the stack.
38 };
39 typedef ZoneMap<pc_t, ControlTransfer> ControlTransferMap;
40 32
41 // Macro for defining union members. 33 // Macro for defining union members.
42 #define FOREACH_UNION_MEMBER(V) \ 34 #define FOREACH_UNION_MEMBER(V) \
43 V(i32, kAstI32, int32_t) \ 35 V(i32, kAstI32, int32_t) \
44 V(u32, kAstI32, uint32_t) \ 36 V(u32, kAstI32, uint32_t) \
45 V(i64, kAstI64, int64_t) \ 37 V(i64, kAstI64, int64_t) \
46 V(u64, kAstI64, uint64_t) \ 38 V(u64, kAstI64, uint64_t) \
47 V(f32, kAstF32, float) \ 39 V(f32, kAstF32, float) \
48 V(f64, kAstF64, double) 40 V(f64, kAstF64, double)
49 41
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 virtual State Step() = 0; 117 virtual State Step() = 0;
126 virtual void Pause() = 0; 118 virtual void Pause() = 0;
127 virtual void Reset() = 0; 119 virtual void Reset() = 0;
128 virtual ~Thread() {} 120 virtual ~Thread() {}
129 121
130 // Stack inspection and modification. 122 // Stack inspection and modification.
131 virtual pc_t GetBreakpointPc() = 0; 123 virtual pc_t GetBreakpointPc() = 0;
132 virtual int GetFrameCount() = 0; 124 virtual int GetFrameCount() = 0;
133 virtual const WasmFrame* GetFrame(int index) = 0; 125 virtual const WasmFrame* GetFrame(int index) = 0;
134 virtual WasmFrame* GetMutableFrame(int index) = 0; 126 virtual WasmFrame* GetMutableFrame(int index) = 0;
135 virtual WasmVal GetReturnValue() = 0; 127 virtual WasmVal GetReturnValue(int index = 0) = 0;
136 128
137 // Thread-specific breakpoints. 129 // Thread-specific breakpoints.
138 bool SetBreakpoint(const WasmFunction* function, int pc, bool enabled); 130 bool SetBreakpoint(const WasmFunction* function, int pc, bool enabled);
139 bool GetBreakpoint(const WasmFunction* function, int pc); 131 bool GetBreakpoint(const WasmFunction* function, int pc);
140 }; 132 };
141 133
142 WasmInterpreter(WasmModuleInstance* instance, AccountingAllocator* allocator); 134 WasmInterpreter(WasmModuleInstance* instance, AccountingAllocator* allocator);
143 ~WasmInterpreter(); 135 ~WasmInterpreter();
144 136
145 //========================================================================== 137 //==========================================================================
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 //========================================================================== 174 //==========================================================================
183 // Testing functionality. 175 // Testing functionality.
184 //========================================================================== 176 //==========================================================================
185 // Manually adds a function to this interpreter, returning the index of the 177 // Manually adds a function to this interpreter, returning the index of the
186 // function. 178 // function.
187 int AddFunctionForTesting(const WasmFunction* function); 179 int AddFunctionForTesting(const WasmFunction* function);
188 // Manually adds code to the interpreter for the given function. 180 // Manually adds code to the interpreter for the given function.
189 bool SetFunctionCodeForTesting(const WasmFunction* function, 181 bool SetFunctionCodeForTesting(const WasmFunction* function,
190 const byte* start, const byte* end); 182 const byte* start, const byte* end);
191 183
192 // Computes the control targets for the given bytecode as {pc offset, sp 184 // Computes the control transfers for the given bytecode. Used internally in
193 // offset} 185 // the interpreter, but exposed for testing.
194 // pairs. Used internally in the interpreter, but exposed for testing.
195 static ControlTransferMap ComputeControlTransfersForTesting(Zone* zone, 186 static ControlTransferMap ComputeControlTransfersForTesting(Zone* zone,
196 const byte* start, 187 const byte* start,
197 const byte* end); 188 const byte* end);
198 189
199 private: 190 private:
200 Zone zone_; 191 Zone zone_;
201 WasmInterpreterInternals* internals_; 192 WasmInterpreterInternals* internals_;
202 }; 193 };
203 194
204 } // namespace wasm 195 } // namespace wasm
205 } // namespace internal 196 } // namespace internal
206 } // namespace v8 197 } // namespace v8
207 198
208 #endif // V8_WASM_INTERPRETER_H_ 199 #endif // V8_WASM_INTERPRETER_H_
OLDNEW
« no previous file with comments | « src/wasm/wasm-debug.cc ('k') | src/wasm/wasm-interpreter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698