--- a/js/src/wasm/WasmJS.cpp
+++ b/js/src/wasm/WasmJS.cpp
@@ -189,24 +189,24 @@ wasm::ReadI64Object(JSContext* cx, Handl
return false;
return true;
}
static bool
ThrowBadImportArg(JSContext* cx)
{
- JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_IMPORT_ARG);
+ JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_IMPORT_ARG);
return false;
}
static bool
ThrowBadImportType(JSContext* cx, const char* field, const char* str)
{
- JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_IMPORT_TYPE, field, str);
+ JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_IMPORT_TYPE, field, str);
return false;
}
static bool
GetProperty(JSContext* cx, HandleObject obj, const char* chars, MutableHandleValue v)
{
JSAtom* atom = AtomizeUTF8Chars(cx, chars, strlen(chars));
if (!atom)
@@ -234,18 +234,18 @@ GetImports(JSContext* cx,
uint32_t globalIndex = 0;
const GlobalDescVector& globals = metadata.globals;
for (const Import& import : imports) {
RootedValue v(cx);
if (!GetProperty(cx, importObj, import.module.get(), &v))
return false;
if (!v.isObject()) {
- JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_IMPORT_FIELD,
- import.module.get());
+ JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_IMPORT_FIELD,
+ import.module.get());
return false;
}
RootedObject obj(cx, &v.toObject());
if (!GetProperty(cx, obj, import.field.get(), &v))
return false;
switch (import.kind) {
@@ -388,18 +388,18 @@ wasm::Eval(JSContext* cx, Handle<TypedAr
MutableCompileArgs compileArgs = cx->new_<CompileArgs>();
if (!compileArgs || !compileArgs->initFromContext(cx, Move(scriptedCaller)))
return false;
UniqueChars error;
SharedModule module = CompileBuffer(*compileArgs, *bytecode, &error);
if (!module) {
if (error) {
- JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_WASM_COMPILE_ERROR,
- error.get());
+ JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr, JSMSG_WASM_COMPILE_ERROR,
+ error.get());
return false;
}
ReportOutOfMemory(cx);
return false;
}
Rooted<FunctionVector> funcs(cx, FunctionVector(cx));
RootedWasmTableObject table(cx);
@@ -418,17 +418,17 @@ static bool
ToNonWrappingUint32(JSContext* cx, HandleValue v, uint32_t max, const char* kind, const char* noun,
uint32_t* u32)
{
double dbl;
if (!ToInteger(cx, v, &dbl))
return false;
if (dbl < 0 || dbl > max) {
- JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_UINT32, kind, noun);
+ JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_UINT32, kind, noun);
return false;
}
*u32 = uint32_t(dbl);
MOZ_ASSERT(double(*u32) == dbl);
return true;
}
@@ -462,18 +462,18 @@ GetLimits(JSContext* cx, HandleObject ob
if (!GetProperty(cx, obj, obj, maximumId, &maxVal))
return false;
limits->maximum.emplace();
if (!ToNonWrappingUint32(cx, maxVal, maxMaximum, kind, "maximum size", limits->maximum.ptr()))
return false;
if (limits->initial > *limits->maximum) {
- JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_UINT32,
- kind, "maximum size");
+ JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_UINT32,
+ kind, "maximum size");
return false;
}
}
return true;
}
// ============================================================================
@@ -532,17 +532,17 @@ IsModuleObject(JSObject* obj, Module** m
static bool
GetModuleArg(JSContext* cx, CallArgs args, const char* name, Module** module)
{
if (!args.requireAtLeast(cx, name, 1))
return false;
if (!args[0].isObject() || !IsModuleObject(&args[0].toObject(), module)) {
- JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_MOD_ARG);
+ JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_MOD_ARG);
return false;
}
return true;
}
struct KindNames
{
@@ -833,17 +833,17 @@ GetBufferSource(JSContext* cx, JSObject*
if (!*bytecode)
return false;
JSObject* unwrapped = CheckedUnwrap(obj);
SharedMem<uint8_t*> dataPointer;
size_t byteLength;
if (!unwrapped || !IsBufferSource(unwrapped, &dataPointer, &byteLength)) {
- JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, errorNumber);
+ JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr, errorNumber);
return false;
}
if (!(*bytecode)->append(dataPointer.unwrap(), byteLength)) {
ReportOutOfMemory(cx);
return false;
}
@@ -874,34 +874,34 @@ WasmModuleObject::construct(JSContext* c
if (!ThrowIfNotConstructing(cx, callArgs, "Module"))
return false;
if (!callArgs.requireAtLeast(cx, "WebAssembly.Module", 1))
return false;
if (!callArgs[0].isObject()) {
- JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_BUF_ARG);
+ JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_BUF_ARG);
return false;
}
MutableBytes bytecode;
if (!GetBufferSource(cx, &callArgs[0].toObject(), JSMSG_WASM_BAD_BUF_ARG, &bytecode))
return false;
SharedCompileArgs compileArgs = InitCompileArgs(cx);
if (!compileArgs)
return false;
UniqueChars error;
SharedModule module = CompileBuffer(*compileArgs, *bytecode, &error);
if (!module) {
if (error) {
- JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_WASM_COMPILE_ERROR,
- error.get());
+ JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr, JSMSG_WASM_COMPILE_ERROR,
+ error.get());
return false;
}
ReportOutOfMemory(cx);
return false;
}
RootedObject proto(cx, &cx->global()->getPrototype(JSProto_WasmModule).toObject());
RootedObject moduleObj(cx, WasmModuleObject::create(cx, *module, proto));
@@ -1102,17 +1102,17 @@ WasmInstanceObject::construct(JSContext*
if (!ThrowIfNotConstructing(cx, args, "Instance"))
return false;
if (!args.requireAtLeast(cx, "WebAssembly.Instance", 1))
return false;
Module* module;
if (!args[0].isObject() || !IsModuleObject(&args[0].toObject(), &module)) {
- JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_MOD_ARG);
+ JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_MOD_ARG);
return false;
}
RootedObject importObj(cx);
if (!GetImportArg(cx, args, &importObj))
return false;
RootedWasmInstanceObject instanceObj(cx);
@@ -1350,17 +1350,17 @@ WasmMemoryObject::construct(JSContext* c
if (!ThrowIfNotConstructing(cx, args, "Memory"))
return false;
if (!args.requireAtLeast(cx, "WebAssembly.Memory", 1))
return false;
if (!args.get(0).isObject()) {
- JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_DESC_ARG, "memory");
+ JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_DESC_ARG, "memory");
return false;
}
RootedObject obj(cx, &args[0].toObject());
Limits limits;
if (!GetLimits(cx, obj, MaxMemoryInitialPages, MaxMemoryMaximumPages, "Memory", &limits))
return false;
@@ -1415,17 +1415,17 @@ WasmMemoryObject::growImpl(JSContext* cx
uint32_t delta;
if (!ToNonWrappingUint32(cx, args.get(0), UINT32_MAX, "Memory", "grow delta", &delta))
return false;
uint32_t ret = grow(memory, delta, cx);
if (ret == uint32_t(-1)) {
- JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_GROW, "memory");
+ JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_GROW, "memory");
return false;
}
args.rval().setInt32(ret);
return true;
}
/* static */ bool
@@ -1636,42 +1636,42 @@ WasmTableObject::construct(JSContext* cx
if (!ThrowIfNotConstructing(cx, args, "Table"))
return false;
if (!args.requireAtLeast(cx, "WebAssembly.Table", 1))
return false;
if (!args.get(0).isObject()) {
- JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_DESC_ARG, "table");
+ JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_DESC_ARG, "table");
return false;
}
RootedObject obj(cx, &args[0].toObject());
JSAtom* elementAtom = Atomize(cx, "element", strlen("element"));
if (!elementAtom)
return false;
RootedId elementId(cx, AtomToId(elementAtom));
RootedValue elementVal(cx);
if (!GetProperty(cx, obj, obj, elementId, &elementVal))
return false;
if (!elementVal.isString()) {
- JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_ELEMENT);
+ JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_ELEMENT);
return false;
}
JSLinearString* elementStr = elementVal.toString()->ensureLinear(cx);
if (!elementStr)
return false;
if (!StringEqualsAscii(elementStr, "anyfunc")) {
- JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_ELEMENT);
+ JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_ELEMENT);
return false;
}
Limits limits;
if (!GetLimits(cx, obj, MaxTableInitialLength, UINT32_MAX, "Table", &limits))
return false;
RootedWasmTableObject table(cx, WasmTableObject::create(cx, limits));
@@ -1754,17 +1754,17 @@ WasmTableObject::setImpl(JSContext* cx,
return false;
uint32_t index;
if (!ToNonWrappingUint32(cx, args.get(0), table.length() - 1, "Table", "set index", &index))
return false;
RootedFunction value(cx);
if (!IsExportedFunction(args[1], &value) && !args[1].isNull()) {
- JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_TABLE_VALUE);
+ JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_TABLE_VALUE);
return false;
}
if (value) {
RootedWasmInstanceObject instanceObj(cx, ExportedFunctionToInstanceObject(value));
uint32_t funcIndex = ExportedFunctionToFuncIndex(value);
#ifdef DEBUG
@@ -1801,17 +1801,17 @@ WasmTableObject::growImpl(JSContext* cx,
uint32_t delta;
if (!ToNonWrappingUint32(cx, args.get(0), UINT32_MAX, "Table", "grow delta", &delta))
return false;
uint32_t ret = table->table().grow(delta, cx);
if (ret == uint32_t(-1)) {
- JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_GROW, "table");
+ JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_GROW, "table");
return false;
}
args.rval().setInt32(ret);
return true;
}
/* static */ bool
@@ -1999,17 +1999,17 @@ EnsurePromiseSupport(JSContext* cx)
static bool
GetBufferSource(JSContext* cx, CallArgs callArgs, const char* name, MutableBytes* bytecode)
{
if (!callArgs.requireAtLeast(cx, name, 1))
return false;
if (!callArgs[0].isObject()) {
- JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_BUF_ARG);
+ JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_BUF_ARG);
return false;
}
return GetBufferSource(cx, &callArgs[0].toObject(), JSMSG_WASM_BAD_BUF_ARG, bytecode);
}
static bool
WebAssembly_compile(JSContext* cx, unsigned argc, Value* vp)
@@ -2040,17 +2040,17 @@ WebAssembly_compile(JSContext* cx, unsig
static bool
GetInstantiateArgs(JSContext* cx, CallArgs callArgs, MutableHandleObject firstArg,
MutableHandleObject importObj)
{
if (!callArgs.requireAtLeast(cx, "WebAssembly.instantiate", 1))
return false;
if (!callArgs[0].isObject()) {
- JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_BUF_MOD_ARG);
+ JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_BUF_MOD_ARG);
return false;
}
firstArg.set(&callArgs[0].toObject());
return GetImportArg(cx, callArgs, importObj);
}
@@ -2137,17 +2137,17 @@ EnsureStreamSupport(JSContext* cx)
}
return true;
}
static bool
RejectWithErrorNumber(JSContext* cx, uint32_t errorNumber, Handle<PromiseObject*> promise)
{
- JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, errorNumber);
+ JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr, errorNumber);
return RejectWithPendingException(cx, promise);
}
class CompileStreamTask : public PromiseHelperTask, public JS::StreamConsumer
{
enum StreamState { Env, Code, Tail, Closed };
typedef ExclusiveWaitableData<StreamState> ExclusiveStreamState;
--- a/js/src/wasm/WasmModule.cpp
+++ b/js/src/wasm/WasmModule.cpp
@@ -724,30 +724,30 @@ Module::initSegments(JSContext* cx,
for (const ElemSegment& seg : elemSegments_) {
uint32_t numElems = seg.elemCodeRangeIndices(tier).length();
uint32_t tableLength = tables[seg.tableIndex]->length();
uint32_t offset = EvaluateInitExpr(globalImports, seg.offset);
if (offset > tableLength || tableLength - offset < numElems) {
- JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_FIT,
- "elem", "table");
+ JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_FIT,
+ "elem", "table");
return false;
}
}
if (memoryObj) {
for (const DataSegment& seg : dataSegments_) {
uint32_t memoryLength = memoryObj->buffer().byteLength();
uint32_t offset = EvaluateInitExpr(globalImports, seg.offset);
if (offset > memoryLength || memoryLength - offset < seg.length) {
- JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_FIT,
- "data", "memory");
+ JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_FIT,
+ "data", "memory");
return false;
}
}
} else {
MOZ_ASSERT(dataSegments_.empty());
}
// Now that initialization can't fail partway through, write data/elem
@@ -827,18 +827,18 @@ Module::instantiateFunctions(JSContext*
continue;
uint32_t funcIndex = ExportedFunctionToFuncIndex(f);
Instance& instance = ExportedFunctionToInstance(f);
const FuncExport& funcExport = instance.metadata(tier).lookupFuncExport(funcIndex);
if (funcExport.sig() != metadata(tier).funcImports[i].sig()) {
const Import& import = FindImportForFuncImport(imports_, i);
- JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_IMPORT_SIG,
- import.module.get(), import.field.get());
+ JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_IMPORT_SIG,
+ import.module.get(), import.field.get());
return false;
}
}
return true;
}
static bool
@@ -848,22 +848,22 @@ CheckLimits(JSContext* cx, uint32_t decl
if (isAsmJS) {
MOZ_ASSERT(actualLength >= declaredMin);
MOZ_ASSERT(!declaredMax);
MOZ_ASSERT(actualLength == actualMax.value());
return true;
}
if (actualLength < declaredMin || actualLength > declaredMax.valueOr(UINT32_MAX)) {
- JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_IMP_SIZE, kind);
+ JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_IMP_SIZE, kind);
return false;
}
if ((actualMax && declaredMax && *actualMax > *declaredMax) || (!actualMax && declaredMax)) {
- JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_IMP_MAX, kind);
+ JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_IMP_MAX, kind);
return false;
}
return true;
}
// asm.js module instantiation supplies its own buffer, but for wasm, create and
// initialize the buffer if one is requested. Either way, the buffer is wrapped