Chromium Code Reviews| 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/decoder.h" | 9 #include "src/wasm/decoder.h" |
| 10 #include "src/wasm/wasm-opcodes.h" | 10 #include "src/wasm/wasm-opcodes.h" |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 135 struct ImportIndexOperand { | 135 struct ImportIndexOperand { |
| 136 uint32_t index; | 136 uint32_t index; |
| 137 FunctionSig* sig; | 137 FunctionSig* sig; |
| 138 int length; | 138 int length; |
| 139 inline ImportIndexOperand(Decoder* decoder, const byte* pc) { | 139 inline ImportIndexOperand(Decoder* decoder, const byte* pc) { |
| 140 index = decoder->checked_read_u32v(pc, 1, &length, "import index"); | 140 index = decoder->checked_read_u32v(pc, 1, &length, "import index"); |
| 141 sig = nullptr; | 141 sig = nullptr; |
| 142 } | 142 } |
| 143 }; | 143 }; |
| 144 | 144 |
| 145 struct TableSwitchOperand { | 145 struct BranchTableOperand { |
| 146 uint32_t case_count; | |
| 147 uint32_t table_count; | 146 uint32_t table_count; |
| 148 const byte* table; | 147 const byte* table; |
| 149 int length; | 148 int length; |
| 150 inline TableSwitchOperand(Decoder* decoder, const byte* pc) { | 149 inline BranchTableOperand(Decoder* decoder, const byte* pc) { |
| 151 case_count = decoder->checked_read_u16(pc, 1, "expected #cases"); | 150 table_count = decoder->checked_read_u16(pc, 1, "expected #entries"); |
|
bradn
2016/03/03 18:08:23
I assume these are going to lebs in a later change
| |
| 152 table_count = decoder->checked_read_u16(pc, 3, "expected #entries"); | 151 length = 2 + table_count * 2; |
| 153 length = 4 + table_count * 2; | |
| 154 | 152 |
| 155 if (decoder->check(pc, 5, table_count * 2, "expected <table entries>")) { | 153 if (decoder->check(pc, 3, table_count * 2, "expected <table entries>")) { |
| 156 table = pc + 5; | 154 table = pc + 3; |
| 157 } else { | 155 } else { |
| 158 table = nullptr; | 156 table = nullptr; |
| 159 } | 157 } |
| 160 } | 158 } |
| 161 inline uint16_t read_entry(Decoder* decoder, int i) { | 159 inline uint16_t read_entry(Decoder* decoder, int i) { |
| 162 DCHECK(i >= 0 && static_cast<uint32_t>(i) < table_count); | 160 DCHECK(i >= 0 && static_cast<uint32_t>(i) < table_count); |
| 163 return table ? decoder->read_u16(table + i * sizeof(uint16_t)) : 0; | 161 return table ? decoder->read_u16(table + i * sizeof(uint16_t)) : 0; |
| 164 } | 162 } |
| 165 }; | 163 }; |
| 166 | 164 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 274 // Computes the length of the opcode at the given address. | 272 // Computes the length of the opcode at the given address. |
| 275 int OpcodeLength(const byte* pc, const byte* end); | 273 int OpcodeLength(const byte* pc, const byte* end); |
| 276 | 274 |
| 277 // Computes the arity (number of sub-nodes) of the opcode at the given address. | 275 // Computes the arity (number of sub-nodes) of the opcode at the given address. |
| 278 int OpcodeArity(FunctionEnv* env, const byte* pc, const byte* end); | 276 int OpcodeArity(FunctionEnv* env, const byte* pc, const byte* end); |
| 279 } // namespace wasm | 277 } // namespace wasm |
| 280 } // namespace internal | 278 } // namespace internal |
| 281 } // namespace v8 | 279 } // namespace v8 |
| 282 | 280 |
| 283 #endif // V8_WASM_AST_DECODER_H_ | 281 #endif // V8_WASM_AST_DECODER_H_ |
| OLD | NEW |