Lines Matching refs:Decoder
14 #include "src/wasm/decoder.h"
15 #include "src/wasm/function-body-decoder-impl.h"
16 #include "src/wasm/function-body-decoder.h"
156 // Generic Wasm bytecode decoder with utilities for decoding operands,
158 class WasmDecoder : public Decoder {
162 : Decoder(start, end),
175 static bool DecodeLocals(Decoder* decoder, const FunctionSig* sig,
186 uint32_t entries = decoder->consume_u32v("local decls count");
187 if (decoder->failed()) return false;
190 while (entries-- > 0 && decoder->ok() && decoder->more()) {
191 uint32_t count = decoder->consume_u32v("local count");
192 if (decoder->failed()) return false;
195 decoder->error(decoder->pc() - 1, "local count too large");
198 byte code = decoder->consume_u8("local type");
199 if (decoder->failed()) return false;
228 decoder->error(decoder->pc() - 1, "invalid local type");
233 DCHECK(decoder->ok());
237 static BitVector* AnalyzeLoopAssignment(Decoder* decoder, const byte* pc,
239 if (pc >= decoder->end()) return nullptr;
245 while (pc < decoder->end() && decoder->ok()) {
253 length = OpcodeLength(decoder, pc);
258 LocalIndexOperand operand(decoder, pc);
271 length = OpcodeLength(decoder, pc);
277 return decoder->ok() ? assigned : nullptr;
416 static unsigned OpcodeLength(Decoder* decoder, const byte* pc) {
423 MemoryAccessOperand operand(decoder, pc, UINT32_MAX);
428 BreakDepthOperand operand(decoder, pc);
433 GlobalIndexOperand operand(decoder, pc);
438 CallFunctionOperand operand(decoder, pc);
442 CallIndirectOperand operand(decoder, pc);
450 BlockTypeOperand operand(decoder, pc);
458 LocalIndexOperand operand(decoder, pc);
462 BranchTableOperand operand(decoder, pc);
463 BranchTableIterator iterator(decoder, operand);
467 ImmI32Operand operand(decoder, pc);
471 ImmI64Operand operand(decoder, pc);
476 MemoryIndexOperand operand(decoder, pc);
484 byte simd_index = decoder->checked_read_u8(pc, 1, "simd_index");
501 decoder->error(pc, "invalid SIMD opcode");
513 // The full WASM decoder for bytecode. Verifies bytecode and, optionally,
1973 Decoder decoder(start, end);
1974 if (WasmDecoder::DecodeLocals(&decoder, nullptr, &decls->type_list)) {
1975 DCHECK(decoder.ok());
1976 decls->encoded_size = decoder.pc_offset();
1984 : Decoder(start, end) {
1997 WasmFullDecoder decoder(&zone, module, body);
1998 decoder.Decode();
1999 return decoder.toResult<DecodeStruct*>(nullptr);
2005 WasmFullDecoder decoder(&zone, builder, body);
2006 decoder.Decode();
2007 return decoder.toResult<DecodeStruct*>(nullptr);
2011 Decoder decoder(pc, end);
2012 return WasmDecoder::OpcodeLength(&decoder, pc);
2039 WasmFullDecoder decoder(&zone, module, body);
2080 unsigned length = WasmDecoder::OpcodeLength(&decoder, i.pc());
2137 if (decoder.Complete(i.pc(), operand)) {
2145 if (decoder.Complete(i.pc(), operand)) {
2157 return decoder.ok();
2162 Decoder decoder(start, end);
2163 return WasmDecoder::AnalyzeLoopAssignment(&decoder, start,