Chromium Code Reviews| Index: src/wasm/ast-decoder.cc |
| diff --git a/src/wasm/ast-decoder.cc b/src/wasm/ast-decoder.cc |
| index 390a67300a34a22640952dc5bc92339d341217f7..e98d26dc70a7320074eb60c82632c0897e75516a 100644 |
| --- a/src/wasm/ast-decoder.cc |
| +++ b/src/wasm/ast-decoder.cc |
| @@ -238,7 +238,7 @@ class WasmDecoder : public Decoder { |
| return true; |
| } |
| - int OpcodeArity(const byte* pc) { |
| + unsigned OpcodeArity(const byte* pc) { |
| #define DECLARE_ARITY(name, ...) \ |
| static const LocalType kTypes_##name[] = {__VA_ARGS__}; \ |
| static const int kArity_##name = \ |
| @@ -319,7 +319,7 @@ class WasmDecoder : public Decoder { |
| } |
| } |
| - int OpcodeLength(const byte* pc) { |
| + unsigned OpcodeLength(const byte* pc) { |
| switch (static_cast<WasmOpcode>(*pc)) { |
| #define DECLARE_OPCODE_CASE(name, opcode, sig) case kExpr##name: |
| FOREACH_LOAD_MEM_OPCODE(DECLARE_OPCODE_CASE) |
| @@ -563,7 +563,7 @@ class SR_WasmDecoder : public WasmDecoder { |
| } |
| } |
| // Decode local declarations, if any. |
| - int length; |
| + unsigned length; |
| uint32_t entries = consume_u32v(&length, "local decls count"); |
| while (entries-- > 0 && pc_ < limit_) { |
| uint32_t count = consume_u32v(&length, "local count"); |
| @@ -601,7 +601,7 @@ class SR_WasmDecoder : public WasmDecoder { |
| if (pc_ >= limit_) return; // Nothing to do. |
| while (true) { // decoding loop. |
| - int len = 1; |
| + unsigned len = 1; |
| WasmOpcode opcode = static_cast<WasmOpcode>(*pc_); |
| TRACE(" @%-6d #%02x:%-20s|", startrel(pc_), opcode, |
| WasmOpcodes::ShortOpcodeName(opcode)); |
| @@ -1435,9 +1435,9 @@ class SR_WasmDecoder : public WasmDecoder { |
| new (zone_) BitVector(static_cast<int>(local_type_vec_.size()), zone_); |
| int depth = 0; |
| // Iteratively process all AST nodes nested inside the loop. |
| - while (pc < limit_) { |
| + while (pc < limit_ && ok()) { |
| WasmOpcode opcode = static_cast<WasmOpcode>(*pc); |
| - int length = 1; |
| + unsigned length = 1; |
| switch (opcode) { |
| case kExprLoop: |
| case kExprIf: |
| @@ -1465,7 +1465,7 @@ class SR_WasmDecoder : public WasmDecoder { |
| if (depth <= 0) break; |
| pc += length; |
| } |
| - return assigned; |
| + return ok() ? assigned : NULL; |
|
bradnelson
2016/06/24 18:40:47
nullptr
|
| } |
| inline wasm::WasmCodePosition position() { |
| @@ -1515,12 +1515,12 @@ std::ostream& operator<<(std::ostream& os, const Tree& tree) { |
| return os; |
| } |
| -int OpcodeLength(const byte* pc, const byte* end) { |
| +unsigned OpcodeLength(const byte* pc, const byte* end) { |
| WasmDecoder decoder(nullptr, nullptr, pc, end); |
| return decoder.OpcodeLength(pc); |
| } |
| -int OpcodeArity(const byte* pc, const byte* end) { |
| +unsigned OpcodeArity(const byte* pc, const byte* end) { |
| WasmDecoder decoder(nullptr, nullptr, pc, end); |
| return decoder.OpcodeArity(pc); |
| } |
| @@ -1564,7 +1564,7 @@ void PrintAst(base::AccountingAllocator* allocator, FunctionBody& body) { |
| os << "// body: \n"; |
| int control_depth = 0; |
| while (pc < body.end) { |
| - size_t length = decoder.OpcodeLength(pc); |
| + unsigned length = decoder.OpcodeLength(pc); |
| WasmOpcode opcode = static_cast<WasmOpcode>(*pc); |
| if (opcode == kExprElse) control_depth--; |