| 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_WASM_AST_DECODER_H_ | 5 #ifndef V8_WASM_AST_DECODER_H_ |
| 6 #define V8_WASM_AST_DECODER_H_ | 6 #define V8_WASM_AST_DECODER_H_ |
| 7 | 7 |
| 8 #include "src/signature.h" | 8 #include "src/signature.h" |
| 9 #include "src/wasm/wasm-opcodes.h" | 9 #include "src/wasm/wasm-opcodes.h" |
| 10 #include "src/wasm/wasm-result.h" | 10 #include "src/wasm/wasm-result.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 FunctionSig* sig; // signature of this function | 28 FunctionSig* sig; // signature of this function |
| 29 uint32_t local_int32_count; // number of int32 locals | 29 uint32_t local_int32_count; // number of int32 locals |
| 30 uint32_t local_int64_count; // number of int64 locals | 30 uint32_t local_int64_count; // number of int64 locals |
| 31 uint32_t local_float32_count; // number of float32 locals | 31 uint32_t local_float32_count; // number of float32 locals |
| 32 uint32_t local_float64_count; // number of float64 locals | 32 uint32_t local_float64_count; // number of float64 locals |
| 33 uint32_t total_locals; // sum of parameters and all locals | 33 uint32_t total_locals; // sum of parameters and all locals |
| 34 | 34 |
| 35 bool IsValidLocal(uint32_t index) { return index < total_locals; } | 35 bool IsValidLocal(uint32_t index) { return index < total_locals; } |
| 36 uint32_t GetLocalCount() { return total_locals; } | 36 uint32_t GetLocalCount() { return total_locals; } |
| 37 LocalType GetLocalType(uint32_t index) { | 37 LocalType GetLocalType(uint32_t index) { |
| 38 if (index < sig->parameter_count()) return sig->GetParam(index); | 38 if (index < static_cast<uint32_t>(sig->parameter_count())) { |
| 39 index -= sig->parameter_count(); | 39 return sig->GetParam(index); |
| 40 } |
| 41 index -= static_cast<uint32_t>(sig->parameter_count()); |
| 40 if (index < local_int32_count) return kAstI32; | 42 if (index < local_int32_count) return kAstI32; |
| 41 index -= local_int32_count; | 43 index -= local_int32_count; |
| 42 if (index < local_int64_count) return kAstI64; | 44 if (index < local_int64_count) return kAstI64; |
| 43 index -= local_int64_count; | 45 index -= local_int64_count; |
| 44 if (index < local_float32_count) return kAstF32; | 46 if (index < local_float32_count) return kAstF32; |
| 45 index -= local_float32_count; | 47 index -= local_float32_count; |
| 46 if (index < local_float64_count) return kAstF64; | 48 if (index < local_float64_count) return kAstF64; |
| 47 return kAstStmt; | 49 return kAstStmt; |
| 48 } | 50 } |
| 49 | 51 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 // Computes the length of the opcode at the given address. | 107 // Computes the length of the opcode at the given address. |
| 106 int OpcodeLength(const byte* pc); | 108 int OpcodeLength(const byte* pc); |
| 107 | 109 |
| 108 // Computes the arity (number of sub-nodes) of the opcode at the given address. | 110 // Computes the arity (number of sub-nodes) of the opcode at the given address. |
| 109 int OpcodeArity(FunctionEnv* env, const byte* pc); | 111 int OpcodeArity(FunctionEnv* env, const byte* pc); |
| 110 } // namespace wasm | 112 } // namespace wasm |
| 111 } // namespace internal | 113 } // namespace internal |
| 112 } // namespace v8 | 114 } // namespace v8 |
| 113 | 115 |
| 114 #endif // V8_WASM_AST_DECODER_H_ | 116 #endif // V8_WASM_AST_DECODER_H_ |
| OLD | NEW |