OLD | NEW |
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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 } val; | 49 } val; |
50 | 50 |
51 WasmVal() : type(kWasmStmt) {} | 51 WasmVal() : type(kWasmStmt) {} |
52 | 52 |
53 #define DECLARE_CONSTRUCTOR(field, localtype, ctype) \ | 53 #define DECLARE_CONSTRUCTOR(field, localtype, ctype) \ |
54 explicit WasmVal(ctype v) : type(localtype) { val.field = v; } | 54 explicit WasmVal(ctype v) : type(localtype) { val.field = v; } |
55 FOREACH_UNION_MEMBER(DECLARE_CONSTRUCTOR) | 55 FOREACH_UNION_MEMBER(DECLARE_CONSTRUCTOR) |
56 #undef DECLARE_CONSTRUCTOR | 56 #undef DECLARE_CONSTRUCTOR |
57 | 57 |
58 template <typename T> | 58 template <typename T> |
59 inline T to() { | 59 T to() { |
60 UNREACHABLE(); | |
61 } | |
62 | |
63 template <typename T> | |
64 inline T to_unchecked() { | |
65 UNREACHABLE(); | 60 UNREACHABLE(); |
66 } | 61 } |
67 }; | 62 }; |
68 | 63 |
69 #define DECLARE_CAST(field, localtype, ctype) \ | 64 #define DECLARE_CAST(field, localtype, ctype) \ |
70 template <> \ | 65 template <> \ |
71 inline ctype WasmVal::to_unchecked() { \ | |
72 return val.field; \ | |
73 } \ | |
74 template <> \ | |
75 inline ctype WasmVal::to() { \ | 66 inline ctype WasmVal::to() { \ |
76 CHECK_EQ(localtype, type); \ | 67 CHECK_EQ(localtype, type); \ |
77 return val.field; \ | 68 return val.field; \ |
78 } | 69 } |
79 FOREACH_UNION_MEMBER(DECLARE_CAST) | 70 FOREACH_UNION_MEMBER(DECLARE_CAST) |
80 #undef DECLARE_CAST | 71 #undef DECLARE_CAST |
81 | 72 |
| 73 template <> |
| 74 inline void WasmVal::to() { |
| 75 CHECK_EQ(kWasmStmt, type); |
| 76 } |
| 77 |
82 // Representation of frames within the interpreter. | 78 // Representation of frames within the interpreter. |
83 class WasmFrame { | 79 class WasmFrame { |
84 public: | 80 public: |
85 const WasmFunction* function() const { return function_; } | 81 const WasmFunction* function() const { return function_; } |
86 int pc() const { | 82 int pc() const { |
87 // TODO(wasm): Remove USE once we actually use them. | 83 // TODO(wasm): Remove USE once we actually use them. |
88 USE(fp_); | 84 USE(fp_); |
89 USE(sp_); | 85 USE(sp_); |
90 return pc_; | 86 return pc_; |
91 } | 87 } |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 private: | 203 private: |
208 Zone zone_; | 204 Zone zone_; |
209 WasmInterpreterInternals* internals_; | 205 WasmInterpreterInternals* internals_; |
210 }; | 206 }; |
211 | 207 |
212 } // namespace wasm | 208 } // namespace wasm |
213 } // namespace internal | 209 } // namespace internal |
214 } // namespace v8 | 210 } // namespace v8 |
215 | 211 |
216 #endif // V8_WASM_INTERPRETER_H_ | 212 #endif // V8_WASM_INTERPRETER_H_ |
OLD | NEW |