Index: src/wasm/ast-decoder.cc |
diff --git a/src/wasm/ast-decoder.cc b/src/wasm/ast-decoder.cc |
index 390a67300a34a22640952dc5bc92339d341217f7..b45596eb59c473e75ff6a8d895e2baf9f7c87bf2 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_ && limit_ != start_) { |
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 (limit_ != start_) ? assigned : NULL; |
titzer
2016/06/10 07:40:00
You can just use ok().
|
} |
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--; |