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