зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1305097: Enhance error reporting from the ToAST transformation; r=luke
This commit is contained in:
Родитель
8bd74b039e
Коммит
31ba17fbcb
|
@ -40,6 +40,7 @@ Decoder::fail(const char* msg, ...) {
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Decoder::fail(UniqueChars msg) {
|
Decoder::fail(UniqueChars msg) {
|
||||||
|
MOZ_ASSERT(error_);
|
||||||
UniqueChars strWithOffset(JS_smprintf("at offset %zu: %s", currentOffset(), msg.get()));
|
UniqueChars strWithOffset(JS_smprintf("at offset %zu: %s", currentOffset(), msg.get()));
|
||||||
if (!strWithOffset)
|
if (!strWithOffset)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -770,7 +770,7 @@ class Decoder
|
||||||
static const size_t ExprLimit = 2 * UINT8_MAX - 1;
|
static const size_t ExprLimit = 2 * UINT8_MAX - 1;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Decoder(const uint8_t* begin, const uint8_t* end, UniqueChars* error = nullptr)
|
Decoder(const uint8_t* begin, const uint8_t* end, UniqueChars* error)
|
||||||
: beg_(begin),
|
: beg_(begin),
|
||||||
end_(end),
|
end_(end),
|
||||||
cur_(begin),
|
cur_(begin),
|
||||||
|
|
|
@ -46,16 +46,20 @@ struct AstDecodeStackItem
|
||||||
ExprType type;
|
ExprType type;
|
||||||
|
|
||||||
explicit AstDecodeStackItem()
|
explicit AstDecodeStackItem()
|
||||||
: expr(nullptr),
|
: expr(nullptr),
|
||||||
terminationKind(AstDecodeTerminationKind::Unknown),
|
terminationKind(AstDecodeTerminationKind::Unknown),
|
||||||
type(ExprType::Limit) {}
|
type(ExprType::Limit)
|
||||||
explicit AstDecodeStackItem(AstDecodeTerminationKind terminationKind,
|
{}
|
||||||
ExprType type)
|
explicit AstDecodeStackItem(AstDecodeTerminationKind terminationKind, ExprType type)
|
||||||
: expr(nullptr), terminationKind(terminationKind), type(type) {}
|
: expr(nullptr),
|
||||||
|
terminationKind(terminationKind),
|
||||||
|
type(type)
|
||||||
|
{}
|
||||||
explicit AstDecodeStackItem(AstExpr* expr)
|
explicit AstDecodeStackItem(AstExpr* expr)
|
||||||
: expr(expr),
|
: expr(expr),
|
||||||
terminationKind(AstDecodeTerminationKind::Unknown),
|
terminationKind(AstDecodeTerminationKind::Unknown),
|
||||||
type(ExprType::Limit) {}
|
type(ExprType::Limit)
|
||||||
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
// We don't define a Value type because ExprIter doesn't push void values, which
|
// We don't define a Value type because ExprIter doesn't push void values, which
|
||||||
|
@ -97,7 +101,8 @@ class AstDecodeContext
|
||||||
ExprType retType_;
|
ExprType retType_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AstDecodeContext(JSContext* cx, LifoAlloc& lifo, Decoder& d, AstModule& module, bool generateNames)
|
AstDecodeContext(JSContext* cx, LifoAlloc& lifo, Decoder& d, AstModule& module,
|
||||||
|
bool generateNames)
|
||||||
: cx(cx),
|
: cx(cx),
|
||||||
lifo(lifo),
|
lifo(lifo),
|
||||||
d(d),
|
d(d),
|
||||||
|
@ -1469,7 +1474,6 @@ AstDecodeFunctionSection(AstDecodeContext& c)
|
||||||
if (numDecls > MaxFuncs)
|
if (numDecls > MaxFuncs)
|
||||||
return c.d.fail("too many functions");
|
return c.d.fail("too many functions");
|
||||||
|
|
||||||
|
|
||||||
if (!c.funcSigs().resize(numDecls))
|
if (!c.funcSigs().resize(numDecls))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -2147,6 +2151,8 @@ wasm::BinaryToAst(JSContext* cx, const uint8_t* bytes, uint32_t length,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MOZ_ASSERT(!error, "unreported error in decoding");
|
||||||
|
|
||||||
*module = result;
|
*module = result;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,8 @@ namespace js {
|
||||||
namespace wasm {
|
namespace wasm {
|
||||||
|
|
||||||
bool
|
bool
|
||||||
BinaryToAst(JSContext* cx, const uint8_t* bytes, uint32_t length, LifoAlloc& lifo, AstModule** module);
|
BinaryToAst(JSContext* cx, const uint8_t* bytes, uint32_t length, LifoAlloc& lifo,
|
||||||
|
AstModule** module);
|
||||||
|
|
||||||
} // end wasm namespace
|
} // end wasm namespace
|
||||||
} // end js namespace
|
} // end js namespace
|
||||||
|
|
|
@ -129,7 +129,8 @@ struct WasmPrintContext
|
||||||
uint32_t currentFuncIndex;
|
uint32_t currentFuncIndex;
|
||||||
PrintOperatorPrecedence currentPrecedence;
|
PrintOperatorPrecedence currentPrecedence;
|
||||||
|
|
||||||
WasmPrintContext(JSContext* cx, AstModule* module, WasmPrintBuffer& buffer, const ExperimentalTextFormatting& f, GeneratedSourceMap* wasmSourceMap_)
|
WasmPrintContext(JSContext* cx, AstModule* module, WasmPrintBuffer& buffer,
|
||||||
|
const ExperimentalTextFormatting& f, GeneratedSourceMap* wasmSourceMap_)
|
||||||
: cx(cx),
|
: cx(cx),
|
||||||
module(module),
|
module(module),
|
||||||
buffer(buffer),
|
buffer(buffer),
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
// |jit-test| test-also-wasm-baseline
|
// |jit-test| test-also-wasm-baseline
|
||||||
load(libdir + "wasm.js");
|
load(libdir + "wasm.js");
|
||||||
|
|
||||||
|
assertErrorMessage(() => wasmBinaryToText(wasmTextToBinary(`(module (func (result i32) (f32.const 13.37)))`), 'experimental'), WebAssembly.CompileError, /type mismatch/);
|
||||||
|
|
||||||
function runTest(code, expected) {
|
function runTest(code, expected) {
|
||||||
var binary = wasmTextToBinary(code);
|
var binary = wasmTextToBinary(code);
|
||||||
var s = wasmBinaryToText(binary, "experimental");
|
var s = wasmBinaryToText(binary, "experimental");
|
||||||
|
|
|
@ -9,6 +9,8 @@ try {
|
||||||
}
|
}
|
||||||
assertEq(caught, true);
|
assertEq(caught, true);
|
||||||
|
|
||||||
|
assertErrorMessage(() => wasmBinaryToText(wasmTextToBinary(`(module (func (result i32) (f32.const 13.37)))`)), WebAssembly.CompileError, /type mismatch/);
|
||||||
|
|
||||||
function runTest(code) {
|
function runTest(code) {
|
||||||
var expected = wasmTextToBinary(code);
|
var expected = wasmTextToBinary(code);
|
||||||
var s = wasmBinaryToText(expected);
|
var s = wasmBinaryToText(expected);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче