From 9f3e30f71b2d6af5283e1895fe14d6fe2f41eb7e Mon Sep 17 00:00:00 2001 From: Roy Tam Date: Tue, 29 Jan 2019 10:29:22 +0800 Subject: [PATCH] import changes from rmottola/Arctic-Fox: - change some pointer style, or patches do not apply (0de8fac13) - Bug 1137523 - Unprefix most js_* functions. (16507a434) --- dom/bindings/BindingUtils.cpp | 2 +- dom/bindings/Codegen.py | 2 +- dom/bindings/DOMJSProxyHandler.cpp | 4 +- dom/indexedDB/IDBObjectStore.cpp | 2 +- dom/plugins/base/nsJSNPRuntime.cpp | 2 +- dom/system/OSFileConstants.cpp | 4 +- dom/workers/WorkerScope.cpp | 2 +- js/ipc/JavaScriptLogging.h | 2 +- js/ipc/WrapperAnswer.cpp | 6 +- js/public/Proxy.h | 6 +- js/src/asmjs/AsmJSLink.cpp | 8 +- js/src/asmjs/AsmJSModule.cpp | 12 +- js/src/asmjs/AsmJSValidate.cpp | 2 +- js/src/builtin/AtomicsObject.cpp | 8 +- js/src/builtin/AtomicsObject.h | 6 +- js/src/builtin/Eval.cpp | 4 +- js/src/builtin/Intl.cpp | 40 ++-- js/src/builtin/Intl.h | 10 +- js/src/builtin/MapObject.cpp | 30 +-- js/src/builtin/MapObject.h | 12 +- js/src/builtin/Object.cpp | 20 +- js/src/builtin/RegExp.cpp | 4 +- js/src/builtin/RegExp.h | 12 +- js/src/builtin/SIMD.cpp | 14 +- js/src/builtin/SIMD.h | 6 +- js/src/builtin/SymbolObject.cpp | 4 +- js/src/builtin/SymbolObject.h | 6 +- js/src/builtin/TestingFunctions.cpp | 6 +- js/src/builtin/TypedObject.cpp | 92 ++++---- js/src/builtin/TypedObject.h | 8 +- js/src/builtin/WeakSetObject.cpp | 6 +- js/src/builtin/WeakSetObject.h | 6 +- js/src/ctypes/CTypes.cpp | 10 +- js/src/frontend/BytecodeCompiler.cpp | 2 +- js/src/frontend/BytecodeEmitter.cpp | 8 +- js/src/frontend/NameFunctions.cpp | 2 +- js/src/frontend/ParseMaps.cpp | 2 +- js/src/frontend/ParseNode.cpp | 2 +- js/src/frontend/Parser.cpp | 6 +- js/src/frontend/TokenStream.cpp | 6 +- js/src/gc/Marking.cpp | 2 +- js/src/gc/Zone.h | 2 +- js/src/irregexp/RegExpInterpreter.cpp | 4 +- js/src/jit/BaselineIC.cpp | 30 +-- js/src/jit/Ion.cpp | 4 +- js/src/jit/IonAnalysis.cpp | 2 +- js/src/jit/IonBuilder.cpp | 4 +- js/src/jit/JitFrames.cpp | 2 +- js/src/jit/Linker.h | 4 +- js/src/jit/MCallOptimize.cpp | 16 +- js/src/jit/MacroAssembler.cpp | 6 +- js/src/jit/arm/Simulator-arm.h | 2 +- js/src/jit/mips/Simulator-mips.h | 2 +- js/src/jsalloc.cpp | 2 +- js/src/jsapi.cpp | 72 +++--- js/src/jsarray.cpp | 34 +-- js/src/jsarray.h | 19 +- js/src/jsatom.cpp | 8 +- js/src/jsbool.cpp | 6 +- js/src/jsbool.h | 8 +- js/src/jscntxt.cpp | 81 ++++--- js/src/jscntxt.h | 43 ++-- js/src/jscntxtinlines.h | 4 +- js/src/jsdate.cpp | 18 +- js/src/jsdate.h | 10 +- js/src/jsdtoa.cpp | 4 +- js/src/jsdtoa.h | 12 +- js/src/jsexn.cpp | 26 +-- js/src/jsexn.h | 13 +- js/src/jsfriendapi.cpp | 14 +- js/src/jsfriendapi.h | 43 ++-- js/src/jsfun.cpp | 52 ++--- js/src/jsfun.h | 14 +- js/src/jsgc.cpp | 8 +- js/src/jsgc.h | 14 +- js/src/jsgcinlines.h | 40 ++-- js/src/jsiter.cpp | 14 +- js/src/jsiter.h | 12 +- js/src/jsmath.cpp | 2 +- js/src/jsmath.h | 6 +- js/src/jsnum.cpp | 40 ++-- js/src/jsnum.h | 20 +- js/src/jsobj.cpp | 66 +++--- js/src/jsobj.h | 15 +- js/src/jsobjinlines.h | 19 +- js/src/json.cpp | 12 +- js/src/json.h | 9 +- js/src/jsopcode.cpp | 93 ++------ js/src/jsopcode.h | 25 +-- js/src/jspropertytree.cpp | 4 +- js/src/jsprototypes.h | 108 ++++----- js/src/jspubtd.h | 5 +- js/src/jsreflect.cpp | 8 +- js/src/jsscript.cpp | 18 +- js/src/jsscript.h | 12 +- js/src/jsstr.cpp | 56 ++--- js/src/jsstr.h | 45 ++-- js/src/jswatchpoint.cpp | 2 +- js/src/jsweakmap.cpp | 10 +- js/src/jsweakmap.h | 6 +- js/src/perf/jsperf.cpp | 6 +- js/src/proxy/BaseProxyHandler.cpp | 6 +- js/src/proxy/DeadObjectProxy.cpp | 28 +-- js/src/proxy/Proxy.cpp | 6 +- js/src/proxy/ScriptedDirectProxyHandler.cpp | 80 +++---- js/src/proxy/ScriptedIndirectProxyHandler.cpp | 6 +- js/src/proxy/SecurityWrapper.cpp | 14 +- js/src/proxy/Wrapper.cpp | 2 +- js/src/shell/js.cpp | 30 +-- js/src/shell/jsheaptools.cpp | 4 +- js/src/vm/ArrayBufferObject.cpp | 30 +-- js/src/vm/ArrayBufferObject.h | 3 + js/src/vm/BooleanObject.h | 2 +- js/src/vm/CharacterEncoding.cpp | 8 +- js/src/vm/Debugger.cpp | 210 +++++++++--------- js/src/vm/DebuggerMemory.cpp | 16 +- js/src/vm/ErrorObject.h | 10 +- js/src/vm/ForOfIterator.cpp | 2 +- js/src/vm/GlobalObject.cpp | 12 +- js/src/vm/GlobalObject.h | 10 +- js/src/vm/HelperThreads.cpp | 6 +- js/src/vm/Interpreter-inl.h | 10 +- js/src/vm/Interpreter.cpp | 14 +- js/src/vm/Interpreter.h | 4 +- js/src/vm/JSONParser.cpp | 2 +- js/src/vm/NativeObject-inl.h | 2 +- js/src/vm/NativeObject.cpp | 22 +- js/src/vm/NumberObject.h | 2 +- js/src/vm/RegExpObject.cpp | 6 +- js/src/vm/RegExpStatics.h | 4 +- js/src/vm/Runtime.cpp | 10 +- js/src/vm/Runtime.h | 23 +- js/src/vm/SavedStacks.cpp | 8 +- js/src/vm/ScopeObject.cpp | 18 +- js/src/vm/ScopeObject.h | 7 +- js/src/vm/SelfHosting.cpp | 12 +- js/src/vm/Shape-inl.h | 4 +- js/src/vm/Shape.cpp | 20 +- js/src/vm/SharedArrayObject.cpp | 6 +- js/src/vm/SharedTypedArrayObject.cpp | 20 +- js/src/vm/Stack-inl.h | 2 +- js/src/vm/String-inl.h | 2 +- js/src/vm/StringBuffer.cpp | 2 +- js/src/vm/StringObject.h | 2 +- js/src/vm/StructuredClone.cpp | 48 ++-- js/src/vm/Symbol.cpp | 4 +- js/src/vm/TypeInference-inl.h | 2 +- js/src/vm/TypeInference.cpp | 6 +- js/src/vm/TypedArrayCommon.h | 12 +- js/src/vm/TypedArrayObject.cpp | 42 ++-- js/src/vm/TypedArrayObject.h | 3 + js/src/vm/Xdr.cpp | 6 +- js/xpconnect/wrappers/XrayWrapper.cpp | 4 +- js/xpconnect/wrappers/XrayWrapper.h | 8 +- 154 files changed, 1181 insertions(+), 1265 deletions(-) diff --git a/dom/bindings/BindingUtils.cpp b/dom/bindings/BindingUtils.cpp index 26fbb9d963..11d59c5160 100644 --- a/dom/bindings/BindingUtils.cpp +++ b/dom/bindings/BindingUtils.cpp @@ -425,7 +425,7 @@ InterfaceObjectToString(JSContext* cx, unsigned argc, JS::Value *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); if (!args.thisv().isObject()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx, js::GetErrorMessage, nullptr, JSMSG_CANT_CONVERT_TO, "null", "object"); return false; } diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py index d72be220e3..8b6a916fed 100644 --- a/dom/bindings/Codegen.py +++ b/dom/bindings/Codegen.py @@ -10237,7 +10237,7 @@ class CGDOMJSProxyHandler_defineProperty(ClassMethod): "if (hasUnforgeable) {\n" " *defined = true;\n" " bool unused;\n" - " return js_DefineOwnProperty(cx, ${holder}, id, desc, &unused);\n" + " return js::DefineOwnProperty(cx, ${holder}, id, desc, &unused);\n" "}\n") set += CallOnUnforgeableHolder(self.descriptor, defineOnUnforgeable, diff --git a/dom/bindings/DOMJSProxyHandler.cpp b/dom/bindings/DOMJSProxyHandler.cpp index e121ff65ce..0ada91f282 100644 --- a/dom/bindings/DOMJSProxyHandler.cpp +++ b/dom/bindings/DOMJSProxyHandler.cpp @@ -201,7 +201,7 @@ DOMProxyHandler::defineProperty(JSContext* cx, JS::Handle proxy, JS:: return JS_ReportErrorFlagsAndNumber(cx, JSREPORT_WARNING | JSREPORT_STRICT | JSREPORT_STRICT_MODE_ERROR, - js_GetErrorMessage, nullptr, + js::GetErrorMessage, nullptr, JSMSG_GETTER_ONLY); } @@ -215,7 +215,7 @@ DOMProxyHandler::defineProperty(JSContext* cx, JS::Handle proxy, JS:: } bool dummy; - return js_DefineOwnProperty(cx, expando, id, desc, &dummy); + return js::DefineOwnProperty(cx, expando, id, desc, &dummy); } bool diff --git a/dom/indexedDB/IDBObjectStore.cpp b/dom/indexedDB/IDBObjectStore.cpp index 332e284200..9f2719aecb 100644 --- a/dom/indexedDB/IDBObjectStore.cpp +++ b/dom/indexedDB/IDBObjectStore.cpp @@ -223,7 +223,7 @@ StructuredCloneWriteCallback(JSContext* aCx, if (JS_GetClass(aObj) == IDBObjectStore::DummyPropClass()) { MOZ_ASSERT(!cloneWriteInfo->mOffsetToKeyProp); - cloneWriteInfo->mOffsetToKeyProp = js_GetSCOffset(aWriter); + cloneWriteInfo->mOffsetToKeyProp = js::GetSCOffset(aWriter); uint64_t value = 0; // Omit endian swap diff --git a/dom/plugins/base/nsJSNPRuntime.cpp b/dom/plugins/base/nsJSNPRuntime.cpp index b4eef4860f..d9f23af72e 100644 --- a/dom/plugins/base/nsJSNPRuntime.cpp +++ b/dom/plugins/base/nsJSNPRuntime.cpp @@ -1744,7 +1744,7 @@ NPObjWrapper_Convert(JSContext *cx, JS::Handle obj, JSType hint, JS:: return true; } - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_CANT_CONVERT_TO, + JS_ReportErrorNumber(cx, js::GetErrorMessage, nullptr, JSMSG_CANT_CONVERT_TO, JS_GetClass(obj)->name, hint == JSTYPE_VOID ? "primitive type" diff --git a/dom/system/OSFileConstants.cpp b/dom/system/OSFileConstants.cpp index 4953f1f8d4..3b21739f3b 100644 --- a/dom/system/OSFileConstants.cpp +++ b/dom/system/OSFileConstants.cpp @@ -803,7 +803,7 @@ JSObject *GetOrCreateObjectProperty(JSContext *cx, JS::Handle aObject return &val.toObject(); } - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx, js::GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE, aProperty, "not an object"); return nullptr; } @@ -840,7 +840,7 @@ bool DefineOSFileConstants(JSContext *cx, JS::Handle global) // |gInitialized == true| but |gPaths == nullptr|. We cannot // |MOZ_ASSERT| this, as this would kill precompile_cache.js, // so we simply return an error. - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx, js::GetErrorMessage, nullptr, JSMSG_CANT_OPEN, "OSFileConstants", "initialization has failed"); return false; } diff --git a/dom/workers/WorkerScope.cpp b/dom/workers/WorkerScope.cpp index 529f303838..003e13bef3 100644 --- a/dom/workers/WorkerScope.cpp +++ b/dom/workers/WorkerScope.cpp @@ -457,7 +457,7 @@ ServiceWorkerGlobalScope::Clients() bool GetterOnlyJSNative(JSContext* aCx, unsigned aArgc, JS::Value* aVp) { - JS_ReportErrorNumber(aCx, js_GetErrorMessage, nullptr, JSMSG_GETTER_ONLY); + JS_ReportErrorNumber(aCx, js::GetErrorMessage, nullptr, JSMSG_GETTER_ONLY); return false; } diff --git a/js/ipc/JavaScriptLogging.h b/js/ipc/JavaScriptLogging.h index 13a965e9c1..5348c90033 100644 --- a/js/ipc/JavaScriptLogging.h +++ b/js/ipc/JavaScriptLogging.h @@ -106,7 +106,7 @@ class Logging obj = shared->objects_.find(id); if (obj) { JSAutoCompartment ac(cx, obj); - objDesc = js_ObjectClassName(cx, obj); + objDesc = js::ObjectClassName(cx, obj); } else { objDesc = ""; } diff --git a/js/ipc/WrapperAnswer.cpp b/js/ipc/WrapperAnswer.cpp index e8c5c6fd32..46ddfe7635 100644 --- a/js/ipc/WrapperAnswer.cpp +++ b/js/ipc/WrapperAnswer.cpp @@ -180,7 +180,7 @@ WrapperAnswer::RecvDefineProperty(const ObjectId& objId, const JSIDVariant& idVa return fail(cx, rs); bool ignored; - if (!js_DefineOwnProperty(cx, obj, id, desc, &ignored)) + if (!js::DefineOwnProperty(cx, obj, id, desc, &ignored)) return fail(cx, rs); return ok(rs); @@ -513,7 +513,7 @@ WrapperAnswer::RecvObjectClassIs(const ObjectId& objId, const uint32_t& classVal LOG("%s.objectClassIs()", ReceiverObj(objId)); - *result = js_ObjectClassIs(cx, obj, (js::ESClassValue)classValue); + *result = js::ObjectClassIs(cx, obj, (js::ESClassValue)classValue); return true; } @@ -533,7 +533,7 @@ WrapperAnswer::RecvClassName(const ObjectId& objId, nsString* name) LOG("%s.className()", ReceiverObj(objId)); - *name = NS_ConvertASCIItoUTF16(js_ObjectClassName(cx, obj)); + *name = NS_ConvertASCIItoUTF16(js::ObjectClassName(cx, obj)); return true; } diff --git a/js/public/Proxy.h b/js/public/Proxy.h index 0cafae92d6..49c977cd36 100644 --- a/js/public/Proxy.h +++ b/js/public/Proxy.h @@ -675,9 +675,9 @@ inline void assertEnteredPolicy(JSContext* cx, JSObject* obj, jsid id, {} #endif +extern JS_FRIEND_API(JSObject*) +InitProxyClass(JSContext *cx, JS::HandleObject obj); + } /* namespace js */ -extern JS_FRIEND_API(JSObject*) -js_InitProxyClass(JSContext* cx, JS::HandleObject obj); - #endif /* js_Proxy_h */ diff --git a/js/src/asmjs/AsmJSLink.cpp b/js/src/asmjs/AsmJSLink.cpp index ddc649e0da..9ae32f676d 100644 --- a/js/src/asmjs/AsmJSLink.cpp +++ b/js/src/asmjs/AsmJSLink.cpp @@ -73,7 +73,7 @@ CloneModule(JSContext* cx, MutableHandle moduleObj) static bool LinkFail(JSContext* cx, const char* str) { - JS_ReportErrorFlagsAndNumber(cx, JSREPORT_WARNING, js_GetErrorMessage, + JS_ReportErrorFlagsAndNumber(cx, JSREPORT_WARNING, GetErrorMessage, nullptr, JSMSG_USE_ASM_LINK_FAIL, str); return false; } @@ -252,7 +252,7 @@ ValidateByteLength(JSContext* cx, HandleValue globalVal) RootedFunction fun(cx, &v.toObject().as()); RootedValue boundTarget(cx, ObjectValue(*fun->getBoundFunctionTarget())); - if (!IsNativeFunction(boundTarget, js_fun_call)) + if (!IsNativeFunction(boundTarget, fun_call)) return LinkFail(cx, "bound target of byteLength must be Function.prototype.call"); RootedValue boundThis(cx, fun->getBoundFunctionThis()); @@ -736,7 +736,7 @@ CallAsmJS(JSContext* cx, unsigned argc, Value* vp) // since these can technically pop out anywhere and the full fix may // actually OOM when trying to allocate the PROT_NONE memory. if (module.hasDetachedHeap()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_OUT_OF_MEMORY); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_OUT_OF_MEMORY); return false; } @@ -1235,7 +1235,7 @@ js::IsAsmJSModuleLoadedFromCache(JSContext* cx, unsigned argc, Value* vp) JSFunction* fun; if (!args.hasDefined(0) || !IsMaybeWrappedNativeFunction(args[0], LinkAsmJS, &fun)) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_USE_ASM_TYPE_FAIL, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_USE_ASM_TYPE_FAIL, "argument passed to isAsmJSModuleLoadedFromCache is not a " "validated asm.js module"); return false; diff --git a/js/src/asmjs/AsmJSModule.cpp b/js/src/asmjs/AsmJSModule.cpp index fb4dd69f16..157deb3e6e 100644 --- a/js/src/asmjs/AsmJSModule.cpp +++ b/js/src/asmjs/AsmJSModule.cpp @@ -65,7 +65,7 @@ AllocateExecutableMemory(ExclusiveContext* cx, size_t bytes) #endif void* p = AllocateExecutableMemory(nullptr, bytes, permissions, "asm-js-code", AsmJSPageSize); if (!p) - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return (uint8_t*)p; } @@ -455,7 +455,7 @@ static void AsmJSReportOverRecursed() { JSContext* cx = JSRuntime::innermostAsmJSActivation()->cx(); - js_ReportOverRecursed(cx); + ReportOverRecursed(cx); } static void @@ -463,14 +463,14 @@ OnDetached() { // See hasDetachedHeap comment in LinkAsmJS. JSContext* cx = JSRuntime::innermostAsmJSActivation()->cx(); - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_OUT_OF_MEMORY); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_OUT_OF_MEMORY); } static void OnOutOfBounds() { JSContext* cx = JSRuntime::innermostAsmJSActivation()->cx(); - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_BAD_INDEX); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_BAD_INDEX); } static bool @@ -1669,7 +1669,7 @@ AsmJSModule::setProfilingEnabled(JSContext* cx, bool enabled) // we cannot malloc. if (enabled) { if (!profilingLabels_.resize(names_.length())) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return false; } const char* filename = scriptSource_->filename(); @@ -1684,7 +1684,7 @@ AsmJSModule::setProfilingEnabled(JSContext* cx, bool enabled) ? JS_smprintf("%s (%s:%u)", name->latin1Chars(nogc), filename, lineno) : JS_smprintf("%hs (%s:%u)", name->twoByteChars(nogc), filename, lineno)); if (!label) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return false; } profilingLabels_[cr.functionNameIndex()].reset(label.get()); diff --git a/js/src/asmjs/AsmJSValidate.cpp b/js/src/asmjs/AsmJSValidate.cpp index 46972f348e..7bdf9a8fc4 100644 --- a/js/src/asmjs/AsmJSValidate.cpp +++ b/js/src/asmjs/AsmJSValidate.cpp @@ -1482,7 +1482,7 @@ class MOZ_STACK_CLASS ModuleCompiler errorString_.get()); } if (errorOverRecursed_) - js_ReportOverRecursed(cx_); + ReportOverRecursed(cx_); } bool init() { diff --git a/js/src/builtin/AtomicsObject.cpp b/js/src/builtin/AtomicsObject.cpp index ecf290e7b1..81ce76fd65 100644 --- a/js/src/builtin/AtomicsObject.cpp +++ b/js/src/builtin/AtomicsObject.cpp @@ -154,7 +154,7 @@ const Class AtomicsObject::class_ = { static bool ReportBadArrayType(JSContext* cx) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_ATOMICS_BAD_ARRAY); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_ATOMICS_BAD_ARRAY); return false; } @@ -1080,7 +1080,7 @@ js::FutexRuntime::wait(JSContext* cx, double timeout_ms, AtomicsObject::FutexWai // See explanation below. if (state_ == WaitingInterrupted) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_ATOMICS_WAIT_NOT_ALLOWED); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_ATOMICS_WAIT_NOT_ALLOWED); return false; } @@ -1089,7 +1089,7 @@ js::FutexRuntime::wait(JSContext* cx, double timeout_ms, AtomicsObject::FutexWai // Reject the timeout if it is not exactly representable. 2e50 ms = 2e53 us = 6e39 years. if (timed && timeout_ms > 2e50) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_ATOMICS_TOO_LONG); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_ATOMICS_TOO_LONG); return false; } @@ -1262,7 +1262,7 @@ AtomicsObject::initClass(JSContext* cx, Handle global) } JSObject* -js_InitAtomicsClass(JSContext* cx, HandleObject obj) +js::InitAtomicsClass(JSContext* cx, HandleObject obj) { MOZ_ASSERT(obj->is()); Rooted global(cx, &obj->as()); diff --git a/js/src/builtin/AtomicsObject.h b/js/src/builtin/AtomicsObject.h index 31e3c6a208..768225459f 100644 --- a/js/src/builtin/AtomicsObject.h +++ b/js/src/builtin/AtomicsObject.h @@ -123,9 +123,9 @@ public: #endif }; +JSObject* +InitAtomicsClass(JSContext* cx, HandleObject obj); + } /* namespace js */ -JSObject* -js_InitAtomicsClass(JSContext* cx, js::HandleObject obj); - #endif /* builtin_AtomicsObject_h */ diff --git a/js/src/builtin/Eval.cpp b/js/src/builtin/Eval.cpp index a1e8f2379d..1b087cd2fa 100644 --- a/js/src/builtin/Eval.cpp +++ b/js/src/builtin/Eval.cpp @@ -234,7 +234,7 @@ EvalKernel(JSContext* cx, const CallArgs& args, EvalType evalType, AbstractFrame Rooted scopeObjGlobal(cx, &scopeobj->global()); if (!GlobalObject::isRuntimeCodeGenEnabled(cx, scopeObjGlobal)) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_CSP_BLOCKED_EVAL); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CSP_BLOCKED_EVAL); return false; } @@ -358,7 +358,7 @@ js::DirectEvalStringFromIon(JSContext* cx, Rooted scopeObjGlobal(cx, &scopeobj->global()); if (!GlobalObject::isRuntimeCodeGenEnabled(cx, scopeObjGlobal)) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_CSP_BLOCKED_EVAL); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CSP_BLOCKED_EVAL); return false; } diff --git a/js/src/builtin/Intl.cpp b/js/src/builtin/Intl.cpp index 3efaad5fc4..32c44c1f3b 100644 --- a/js/src/builtin/Intl.cpp +++ b/js/src/builtin/Intl.cpp @@ -769,14 +769,14 @@ js::intl_availableCollations(JSContext* cx, unsigned argc, Value* vp) UErrorCode status = U_ZERO_ERROR; UEnumeration* values = ucol_getKeywordValuesForLocale("co", locale.ptr(), false, &status); if (U_FAILURE(status)) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INTERNAL_INTL_ERROR); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INTERNAL_INTL_ERROR); return false; } ScopedICUObject toClose(values, uenum_close); uint32_t count = uenum_count(values, &status); if (U_FAILURE(status)) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INTERNAL_INTL_ERROR); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INTERNAL_INTL_ERROR); return false; } @@ -788,7 +788,7 @@ js::intl_availableCollations(JSContext* cx, unsigned argc, Value* vp) for (uint32_t i = 0; i < count; i++) { const char* collation = uenum_next(values, nullptr, &status); if (U_FAILURE(status)) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INTERNAL_INTL_ERROR); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INTERNAL_INTL_ERROR); return false; } @@ -938,7 +938,7 @@ NewUCollator(JSContext* cx, HandleObject collator) UErrorCode status = U_ZERO_ERROR; UCollator* coll = ucol_open(icuLocale(locale.ptr()), &status); if (U_FAILURE(status)) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INTERNAL_INTL_ERROR); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INTERNAL_INTL_ERROR); return nullptr; } @@ -950,7 +950,7 @@ NewUCollator(JSContext* cx, HandleObject collator) ucol_setAttribute(coll, UCOL_CASE_FIRST, uCaseFirst, &status); if (U_FAILURE(status)) { ucol_close(coll); - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INTERNAL_INTL_ERROR); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INTERNAL_INTL_ERROR); return nullptr; } @@ -1266,7 +1266,7 @@ js::intl_numberingSystem(JSContext* cx, unsigned argc, Value* vp) UErrorCode status = U_ZERO_ERROR; NumberingSystem* numbers = NumberingSystem::createInstance(ulocale, status); if (U_FAILURE(status)) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INTERNAL_INTL_ERROR); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INTERNAL_INTL_ERROR); return false; } const char* name = numbers->getName(); @@ -1397,7 +1397,7 @@ NewUNumberFormat(JSContext* cx, HandleObject numberFormat) UErrorCode status = U_ZERO_ERROR; UNumberFormat* nf = unum_open(uStyle, nullptr, 0, icuLocale(locale.ptr()), nullptr, &status); if (U_FAILURE(status)) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INTERNAL_INTL_ERROR); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INTERNAL_INTL_ERROR); return nullptr; } ScopedICUObject toClose(nf, unum_close); @@ -1405,7 +1405,7 @@ NewUNumberFormat(JSContext* cx, HandleObject numberFormat) if (uCurrency) { unum_setTextAttribute(nf, UNUM_CURRENCY_CODE, uCurrency, 3, &status); if (U_FAILURE(status)) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INTERNAL_INTL_ERROR); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INTERNAL_INTL_ERROR); return nullptr; } } @@ -1444,7 +1444,7 @@ intl_FormatNumber(JSContext* cx, UNumberFormat* nf, double x, MutableHandleValue unum_formatDouble(nf, x, Char16ToUChar(chars.begin()), size, nullptr, &status); } if (U_FAILURE(status)) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INTERNAL_INTL_ERROR); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INTERNAL_INTL_ERROR); return false; } @@ -1743,7 +1743,7 @@ js::intl_availableCalendars(JSContext* cx, unsigned argc, Value* vp) UCalendar* cal = ucal_open(nullptr, 0, locale.ptr(), UCAL_DEFAULT, &status); const char* calendar = ucal_getType(cal, &status); if (U_FAILURE(status)) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INTERNAL_INTL_ERROR); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INTERNAL_INTL_ERROR); return false; } ucal_close(cal); @@ -1757,21 +1757,21 @@ js::intl_availableCalendars(JSContext* cx, unsigned argc, Value* vp) // Now get the calendars that "would make a difference", i.e., not the default. UEnumeration* values = ucal_getKeywordValuesForLocale("ca", locale.ptr(), false, &status); if (U_FAILURE(status)) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INTERNAL_INTL_ERROR); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INTERNAL_INTL_ERROR); return false; } ScopedICUObject toClose(values, uenum_close); uint32_t count = uenum_count(values, &status); if (U_FAILURE(status)) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INTERNAL_INTL_ERROR); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INTERNAL_INTL_ERROR); return false; } for (; count > 0; count--) { calendar = uenum_next(values, nullptr, &status); if (U_FAILURE(status)) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INTERNAL_INTL_ERROR); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INTERNAL_INTL_ERROR); return false; } @@ -1813,7 +1813,7 @@ js::intl_patternForSkeleton(JSContext* cx, unsigned argc, Value* vp) UErrorCode status = U_ZERO_ERROR; UDateTimePatternGenerator* gen = udatpg_open(icuLocale(locale.ptr()), &status); if (U_FAILURE(status)) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INTERNAL_INTL_ERROR); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INTERNAL_INTL_ERROR); return false; } ScopedICUObject toClose(gen, udatpg_close); @@ -1821,7 +1821,7 @@ js::intl_patternForSkeleton(JSContext* cx, unsigned argc, Value* vp) int32_t size = udatpg_getBestPattern(gen, Char16ToUChar(skeletonChars.start().get()), skeletonLen, nullptr, 0, &status); if (U_FAILURE(status) && status != U_BUFFER_OVERFLOW_ERROR) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INTERNAL_INTL_ERROR); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INTERNAL_INTL_ERROR); return false; } ScopedJSFreePtr pattern(cx->pod_malloc(size + 1)); @@ -1832,7 +1832,7 @@ js::intl_patternForSkeleton(JSContext* cx, unsigned argc, Value* vp) udatpg_getBestPattern(gen, Char16ToUChar(skeletonChars.start().get()), skeletonLen, pattern, size, &status); if (U_FAILURE(status)) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INTERNAL_INTL_ERROR); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INTERNAL_INTL_ERROR); return false; } @@ -1912,7 +1912,7 @@ NewUDateFormat(JSContext* cx, HandleObject dateTimeFormat) udat_open(UDAT_PATTERN, UDAT_PATTERN, icuLocale(locale.ptr()), uTimeZone, uTimeZoneLength, uPattern, uPatternLength, &status); if (U_FAILURE(status)) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INTERNAL_INTL_ERROR); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INTERNAL_INTL_ERROR); return nullptr; } @@ -1930,7 +1930,7 @@ static bool intl_FormatDateTime(JSContext* cx, UDateFormat* df, double x, MutableHandleValue result) { if (!IsFinite(x)) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_DATE_NOT_FINITE); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_DATE_NOT_FINITE); return false; } @@ -1947,7 +1947,7 @@ intl_FormatDateTime(JSContext* cx, UDateFormat* df, double x, MutableHandleValue udat_format(df, x, Char16ToUChar(chars.begin()), size, nullptr, &status); } if (U_FAILURE(status)) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INTERNAL_INTL_ERROR); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INTERNAL_INTL_ERROR); return false; } @@ -2032,7 +2032,7 @@ static const JSFunctionSpec intl_static_methods[] = { * Spec: ECMAScript Internationalization API Specification, 8.0, 8.1 */ JSObject* -js_InitIntlClass(JSContext* cx, HandleObject obj) +js::InitIntlClass(JSContext *cx, HandleObject obj) { MOZ_ASSERT(obj->is()); Rooted global(cx, &obj->as()); diff --git a/js/src/builtin/Intl.h b/js/src/builtin/Intl.h index 84b92d77fe..d3690b1bb5 100644 --- a/js/src/builtin/Intl.h +++ b/js/src/builtin/Intl.h @@ -10,6 +10,8 @@ #include "NamespaceImports.h" #include "unicode/utypes.h" +namespace js { + /* * The Intl module specified by standard ECMA-402, * ECMAScript Internationalization API Specification. @@ -20,9 +22,7 @@ * Spec: ECMAScript Internationalization API Specification, 8.0, 8.1 */ extern JSObject* -js_InitIntlClass(JSContext* cx, js::HandleObject obj); - -namespace js { +InitIntlClass(JSContext *cx, HandleObject obj); /* * The following functions are for use by self-hosted code. @@ -39,7 +39,7 @@ namespace js { * Usage: collator = intl_Collator(locales, options) */ extern bool -intl_Collator(JSContext* cx, unsigned argc, Value* vp); +intl_Collator(JSContext *cx, unsigned argc, Value *vp); /** * Returns an object indicating the supported locales for collation @@ -50,7 +50,7 @@ intl_Collator(JSContext* cx, unsigned argc, Value* vp); * Usage: availableLocales = intl_Collator_availableLocales() */ extern bool -intl_Collator_availableLocales(JSContext* cx, unsigned argc, Value* vp); +intl_Collator_availableLocales(JSContext *cx, unsigned argc, Value* vp); /** * Returns an array with the collation type identifiers per Unicode diff --git a/js/src/builtin/MapObject.cpp b/js/src/builtin/MapObject.cpp index 07d4e795fa..99eac8c4f5 100644 --- a/js/src/builtin/MapObject.cpp +++ b/js/src/builtin/MapObject.cpp @@ -1194,7 +1194,7 @@ MapObject::set(JSContext* cx, HandleObject obj, HandleValue k, HandleValue v) RelocatableValue rval(v); if (!map->put(key, rval)) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return false; } WriteBarrierPost(cx->runtime(), map, key.get()); @@ -1211,7 +1211,7 @@ MapObject::create(JSContext* cx) ValueMap* map = cx->new_(cx->runtime()); if (!map || !map->init()) { js_delete(map); - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return nullptr; } @@ -1266,7 +1266,7 @@ MapObject::construct(JSContext* cx, unsigned argc, Value* vp) if (done) break; if (!pairVal.isObject()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INVALID_MAP_ITERABLE, "Map"); return false; } @@ -1289,7 +1289,7 @@ MapObject::construct(JSContext* cx, unsigned argc, Value* vp) RelocatableValue rval(val); if (!map->put(hkey, rval)) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return false; } WriteBarrierPost(cx->runtime(), map, key); @@ -1446,7 +1446,7 @@ MapObject::set_impl(JSContext* cx, const CallArgs& args) ARG0_KEY(cx, args, key); RelocatableValue rval(args.get(1)); if (!map.put(key, rval)) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return false; } WriteBarrierPost(cx->runtime(), &map, key.get()); @@ -1479,7 +1479,7 @@ MapObject::delete_impl(JSContext* cx, const CallArgs& args) ARG0_KEY(cx, args, key); bool found; if (!map.remove(key, &found)) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return false; } args.rval().setBoolean(found); @@ -1570,14 +1570,14 @@ MapObject::clear(JSContext* cx, HandleObject obj) MOZ_ASSERT(MapObject::is(obj)); ValueMap& map = extract(obj); if (!map.clear()) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return false; } return true; } JSObject* -js_InitMapClass(JSContext* cx, HandleObject obj) +js::InitMapClass(JSContext* cx, HandleObject obj) { return MapObject::initClass(cx, obj); } @@ -1836,7 +1836,7 @@ SetObject::add(JSContext* cx, HandleObject obj, HandleValue k) return false; if (!set->put(key)) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return false; } WriteBarrierPost(cx->runtime(), set, key.get()); @@ -1853,7 +1853,7 @@ SetObject::create(JSContext* cx) ValueSet* set = cx->new_(cx->runtime()); if (!set || !set->init()) { js_delete(set); - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return nullptr; } obj->setPrivate(set); @@ -1921,7 +1921,7 @@ SetObject::construct(JSContext* cx, unsigned argc, Value* vp) if (!key.setValue(cx, keyVal)) return false; if (!set->put(key)) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return false; } WriteBarrierPost(cx->runtime(), set, keyVal); @@ -2002,7 +2002,7 @@ SetObject::add_impl(JSContext* cx, const CallArgs& args) ValueSet& set = extract(args); ARG0_KEY(cx, args, key); if (!set.put(key)) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return false; } WriteBarrierPost(cx->runtime(), &set, key.get()); @@ -2026,7 +2026,7 @@ SetObject::delete_impl(JSContext* cx, const CallArgs& args) ARG0_KEY(cx, args, key); bool found; if (!set.remove(key, &found)) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return false; } args.rval().setBoolean(found); @@ -2083,7 +2083,7 @@ SetObject::clear_impl(JSContext* cx, const CallArgs& args) { Rooted setobj(cx, &args.thisv().toObject().as()); if (!setobj->getData()->clear()) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return false; } args.rval().setUndefined(); @@ -2098,7 +2098,7 @@ SetObject::clear(JSContext* cx, unsigned argc, Value* vp) } JSObject* -js_InitSetClass(JSContext* cx, HandleObject obj) +js::InitSetClass(JSContext* cx, HandleObject obj) { return SetObject::initClass(cx, obj); } diff --git a/js/src/builtin/MapObject.h b/js/src/builtin/MapObject.h index 877a4b0429..6060569570 100644 --- a/js/src/builtin/MapObject.h +++ b/js/src/builtin/MapObject.h @@ -182,12 +182,12 @@ class SetObject : public NativeObject { extern bool InitSelfHostingCollectionIteratorFunctions(JSContext* cx, js::HandleObject obj); +extern JSObject* +InitMapClass(JSContext* cx, HandleObject obj); + +extern JSObject* +InitSetClass(JSContext* cx, HandleObject obj); + } /* namespace js */ -extern JSObject* -js_InitMapClass(JSContext* cx, js::HandleObject obj); - -extern JSObject* -js_InitSetClass(JSContext* cx, js::HandleObject obj); - #endif /* builtin_MapObject_h */ diff --git a/js/src/builtin/Object.cpp b/js/src/builtin/Object.cpp index d5a25584f7..6e5d89322b 100644 --- a/js/src/builtin/Object.cpp +++ b/js/src/builtin/Object.cpp @@ -235,7 +235,7 @@ js::ObjectToSource(JSContext* cx, HandleObject obj) ? !IsIdentifier(JSID_TO_ATOM(id)) : JSID_TO_INT(id) < 0) { - idstr = js_QuoteString(cx, idstr, char16_t('\'')); + idstr = QuoteString(cx, idstr, char16_t('\'')); if (!idstr) return nullptr; } @@ -419,21 +419,21 @@ obj_setPrototypeOf(JSContext* cx, unsigned argc, Value* vp) return false; if (args.length() < 2) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, "Object.setPrototypeOf", "1", ""); return false; } /* Step 1-2. */ if (args[0].isNullOrUndefined()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_CANT_CONVERT_TO, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CANT_CONVERT_TO, args[0].isNull() ? "null" : "undefined", "object"); return false; } /* Step 3. */ if (!args[1].isObjectOrNull()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_NOT_EXPECTED_TYPE, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NOT_EXPECTED_TYPE, "Object.setPrototypeOf", "an object or null", InformalValueTypeName(args[1])); return false; } @@ -458,7 +458,7 @@ obj_setPrototypeOf(JSContext* cx, unsigned argc, Value* vp) args[0], NullPtr())); if (!bytes) return false; - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_SETPROTOTYPEOF_FAIL, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_SETPROTOTYPEOF_FAIL, bytes.get()); return false; } @@ -505,7 +505,7 @@ obj_watch(JSContext* cx, unsigned argc, Value* vp) return false; if (args.length() <= 1) { - js_ReportMissingArg(cx, args.calleev(), 1); + ReportMissingArg(cx, args.calleev(), 1); return false; } @@ -667,7 +667,7 @@ js::obj_create(JSContext* cx, unsigned argc, Value* vp) // Step 1. if (args.length() == 0) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, "Object.create", "0", "s"); return false; } @@ -677,7 +677,7 @@ js::obj_create(JSContext* cx, unsigned argc, Value* vp) char* bytes = DecompileValueGenerator(cx, JSDVG_SEARCH_STACK, v, NullPtr()); if (!bytes) return false; - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE, bytes, "not an object or null"); js_free(bytes); return false; @@ -855,7 +855,7 @@ obj_defineProperties(JSContext* cx, unsigned argc, Value* vp) /* Step 2. */ if (args.length() < 2) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, "Object.defineProperties", "0", "s"); return false; } @@ -907,7 +907,7 @@ obj_preventExtensions(JSContext* cx, unsigned argc, Value* vp) // Step 4. if (!status) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_CANT_CHANGE_EXTENSIBILITY); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CANT_CHANGE_EXTENSIBILITY); return false; } diff --git a/js/src/builtin/RegExp.cpp b/js/src/builtin/RegExp.cpp index eabb400531..eb03220465 100644 --- a/js/src/builtin/RegExp.cpp +++ b/js/src/builtin/RegExp.cpp @@ -168,7 +168,7 @@ CompileRegExpObject(JSContext* cx, RegExpObjectBuilder& builder, * the second argument must be undefined. Otherwise, throw a TypeError. */ if (args.hasDefined(1) && creationMode == CreateForCompile) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_NEWREGEXP_FLAGGED); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NEWREGEXP_FLAGGED); return false; } @@ -565,7 +565,7 @@ static const JSPropertySpec regexp_static_props[] = { }; JSObject* -js_InitRegExpClass(JSContext* cx, HandleObject obj) +js::InitRegExpClass(JSContext *cx, HandleObject obj) { MOZ_ASSERT(obj->isNative()); diff --git a/js/src/builtin/RegExp.h b/js/src/builtin/RegExp.h index d067cb9228..35ad476576 100644 --- a/js/src/builtin/RegExp.h +++ b/js/src/builtin/RegExp.h @@ -9,12 +9,6 @@ #include "vm/RegExpObject.h" -JSObject* -js_InitRegExpClass(JSContext* cx, js::HandleObject obj); - -bool -regexp_flags(JSContext* cx, unsigned argc, JS::Value* vp); - /* * The following builtin natives are extern'd for pointer comparison in * other parts of the engine. @@ -22,6 +16,12 @@ regexp_flags(JSContext* cx, unsigned argc, JS::Value* vp); namespace js { +bool +regexp_flags(JSContext *cx, unsigned argc, JS::Value *vp); + +JSObject * +InitRegExpClass(JSContext *cx, HandleObject obj); + // Whether RegExp statics should be updated with the input and results of a // regular expression execution. enum RegExpStaticsUpdate { UpdateRegExpStatics, DontUpdateRegExpStatics }; diff --git a/js/src/builtin/SIMD.cpp b/js/src/builtin/SIMD.cpp index 9eb008c909..1e0eed8a4f 100644 --- a/js/src/builtin/SIMD.cpp +++ b/js/src/builtin/SIMD.cpp @@ -74,7 +74,7 @@ js::ToSimdConstant(JSContext* cx, HandleValue v, jit::SimdConstant* out) { typedef typename V::Elem Elem; if (!IsVectorObject(v)) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_SIMD_NOT_A_VECTOR); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_SIMD_NOT_A_VECTOR); return false; } @@ -101,7 +101,7 @@ static bool GetSimdLane(JSContext* cx, unsigned argc, Value* vp) CallArgs args = CallArgsFromVp(argc, vp); if (!IsVectorObject(args.thisv())) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO, SimdTypeDescr::class_.name, laneNames[lane], InformalValueTypeName(args.thisv())); return false; @@ -138,7 +138,7 @@ static bool SignMask(JSContext* cx, unsigned argc, Value* vp) CallArgs args = CallArgsFromVp(argc, vp); if (!args.thisv().isObject() || !args.thisv().toObject().is()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO, SimdTypeDescr::class_.name, "signMask", InformalValueTypeName(args.thisv())); return false; @@ -147,7 +147,7 @@ static bool SignMask(JSContext* cx, unsigned argc, Value* vp) TypedObject& typedObj = args.thisv().toObject().as(); TypeDescr& descr = typedObj.typeDescr(); if (descr.kind() != type::Simd || descr.as().type() != SimdType::type) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO, SimdTypeDescr::class_.name, "signMask", InformalValueTypeName(args.thisv())); return false; @@ -486,7 +486,7 @@ SIMDObject::initClass(JSContext* cx, Handle global) } JSObject* -js_InitSIMDClass(JSContext* cx, HandleObject obj) +js::InitSIMDClass(JSContext *cx, HandleObject obj) { MOZ_ASSERT(obj->is()); Rooted global(cx, &obj->as()); @@ -644,7 +644,7 @@ struct ShiftRightLogical { static inline bool ErrorBadArgs(JSContext* cx) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_TYPED_ARRAY_BAD_ARGS); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_TYPED_ARRAY_BAD_ARGS); return false; } @@ -1037,7 +1037,7 @@ TypedArrayFromArgs(JSContext* cx, const CallArgs& args, (uint32_t(*byteStart) + NumElem * sizeof(VElem)) > AnyTypedArrayByteLength(typedArray)) { // Keep in sync with AsmJS OnOutOfBounds function. - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_BAD_INDEX); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_BAD_INDEX); return false; } diff --git a/js/src/builtin/SIMD.h b/js/src/builtin/SIMD.h index 4b883daf7a..61767d4977 100644 --- a/js/src/builtin/SIMD.h +++ b/js/src/builtin/SIMD.h @@ -360,9 +360,9 @@ simd_int32x4_##Name(JSContext* cx, unsigned argc, Value* vp); INT32X4_FUNCTION_LIST(DECLARE_SIMD_INT32x4_FUNCTION) #undef DECLARE_SIMD_INT32x4_FUNCTION +JSObject* +InitSIMDClass(JSContext *cx, HandleObject obj); + } /* namespace js */ -JSObject* -js_InitSIMDClass(JSContext* cx, js::HandleObject obj); - #endif /* builtin_SIMD_h */ diff --git a/js/src/builtin/SymbolObject.cpp b/js/src/builtin/SymbolObject.cpp index dfc1a2f0be..ceb09ec223 100644 --- a/js/src/builtin/SymbolObject.cpp +++ b/js/src/builtin/SymbolObject.cpp @@ -103,7 +103,7 @@ SymbolObject::construct(JSContext* cx, unsigned argc, Value* vp) // yet, so just throw a TypeError. CallArgs args = CallArgsFromVp(argc, vp); if (args.isConstructing()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_NOT_CONSTRUCTOR, "Symbol"); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NOT_CONSTRUCTOR, "Symbol"); return false; } @@ -230,7 +230,7 @@ SymbolObject::valueOf(JSContext* cx, unsigned argc, Value* vp) } JSObject* -js_InitSymbolClass(JSContext* cx, HandleObject obj) +js::InitSymbolClass(JSContext* cx, HandleObject obj) { return SymbolObject::initClass(cx, obj); } diff --git a/js/src/builtin/SymbolObject.h b/js/src/builtin/SymbolObject.h index 7ca4b80534..6efffa017e 100644 --- a/js/src/builtin/SymbolObject.h +++ b/js/src/builtin/SymbolObject.h @@ -58,9 +58,9 @@ class SymbolObject : public NativeObject static const JSFunctionSpec staticMethods[]; }; +extern JSObject* +InitSymbolClass(JSContext* cx, HandleObject obj); + } /* namespace js */ -extern JSObject* -js_InitSymbolClass(JSContext* cx, js::HandleObject obj); - #endif /* builtin_SymbolObject_h */ diff --git a/js/src/builtin/TestingFunctions.cpp b/js/src/builtin/TestingFunctions.cpp index dac0685ad1..f4f9361345 100644 --- a/js/src/builtin/TestingFunctions.cpp +++ b/js/src/builtin/TestingFunctions.cpp @@ -747,7 +747,7 @@ NondeterministicGetWeakMapKeys(JSContext* cx, unsigned argc, jsval* vp) return false; } if (!args[0].isObject()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_NOT_EXPECTED_TYPE, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NOT_EXPECTED_TYPE, "nondeterministicGetWeakMapKeys", "WeakMap", InformalValueTypeName(args[0])); return false; @@ -757,7 +757,7 @@ NondeterministicGetWeakMapKeys(JSContext* cx, unsigned argc, jsval* vp) if (!JS_NondeterministicGetWeakMapKeys(cx, mapObj, &arr)) return false; if (!arr) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_NOT_EXPECTED_TYPE, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NOT_EXPECTED_TYPE, "nondeterministicGetWeakMapKeys", "WeakMap", args[0].toObject().getClass()->name); return false; @@ -2114,7 +2114,7 @@ FindPath(JSContext* cx, unsigned argc, jsval* vp) { CallArgs args = CallArgsFromVp(argc, vp); if (argc < 2) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_MORE_ARGS_NEEDED, + JS_ReportErrorNumber(cx, GetErrorMessage, NULL, JSMSG_MORE_ARGS_NEEDED, "findPath", "1", ""); return false; } diff --git a/js/src/builtin/TypedObject.cpp b/js/src/builtin/TypedObject.cpp index 2abbcd3593..0c2fbd7204 100644 --- a/js/src/builtin/TypedObject.cpp +++ b/js/src/builtin/TypedObject.cpp @@ -48,7 +48,7 @@ static const JSFunctionSpec TypedObjectMethods[] = { static void ReportCannotConvertTo(JSContext* cx, HandleValue fromValue, const char* toType) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_CANT_CONVERT_TO, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CANT_CONVERT_TO, InformalValueTypeName(fromValue), toType); } @@ -185,7 +185,7 @@ GetPrototype(JSContext* cx, HandleObject obj) return nullptr; } if (!prototypeVal.isObject()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INVALID_PROTOTYPE); return nullptr; } @@ -268,7 +268,7 @@ ScalarTypeDescr::call(JSContext* cx, unsigned argc, Value* vp) { CallArgs args = CallArgsFromVp(argc, vp); if (args.length() < 1) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, args.callee().getClass()->name, "0", "s"); return false; } @@ -372,7 +372,7 @@ js::ReferenceTypeDescr::call(JSContext* cx, unsigned argc, Value* vp) Rooted descr(cx, &args.callee().as()); if (args.length() < 1) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, descr->typeName(), "0", "s"); return false; @@ -644,7 +644,7 @@ ArrayMetaTypeDescr::construct(JSContext* cx, unsigned argc, Value* vp) CallArgs args = CallArgsFromVp(argc, vp); if (!args.isConstructing()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NOT_FUNCTION, "ArrayType"); return false; } @@ -653,7 +653,7 @@ ArrayMetaTypeDescr::construct(JSContext* cx, unsigned argc, Value* vp) // Expect two arguments. The first is a type object, the second is a length. if (args.length() < 2) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, "ArrayType", "1", ""); return false; } @@ -675,7 +675,7 @@ ArrayMetaTypeDescr::construct(JSContext* cx, unsigned argc, Value* vp) // Compute the byte size. CheckedInt32 size = CheckedInt32(elementType->size()) * length; if (!size.isValid()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_TYPEDOBJECT_TOO_BIG); return false; } @@ -787,7 +787,7 @@ StructMetaTypeDescr::create(JSContext* cx, return nullptr; if (!stringBuffer.append("new StructType({")) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return nullptr; } @@ -818,11 +818,11 @@ StructMetaTypeDescr::create(JSContext* cx, // Collect field name and type object RootedValue fieldName(cx, IdToValue(id)); if (!fieldNames.append(fieldName)) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return nullptr; } if (!fieldTypeObjs.append(ObjectValue(*fieldType))) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return nullptr; } @@ -835,19 +835,19 @@ StructMetaTypeDescr::create(JSContext* cx, // Append "f:Type" to the string repr if (i > 0 && !stringBuffer.append(", ")) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return nullptr; } if (!stringBuffer.append(JSID_TO_ATOM(id))) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return nullptr; } if (!stringBuffer.append(": ")) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return nullptr; } if (!stringBuffer.append(&fieldType->stringRepr())) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return nullptr; } @@ -855,13 +855,13 @@ StructMetaTypeDescr::create(JSContext* cx, // the field's alignment. CheckedInt32 offset = roundUpToAlignment(sizeSoFar, fieldType->alignment()); if (!offset.isValid()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_TYPEDOBJECT_TOO_BIG); return nullptr; } MOZ_ASSERT(offset.value() >= 0); if (!fieldOffsets.append(Int32Value(offset.value()))) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return nullptr; } @@ -876,7 +876,7 @@ StructMetaTypeDescr::create(JSContext* cx, // Add space for this field to the total struct size. sizeSoFar = offset + fieldType->size(); if (!sizeSoFar.isValid()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_TYPEDOBJECT_TOO_BIG); return nullptr; } @@ -891,7 +891,7 @@ StructMetaTypeDescr::create(JSContext* cx, // Complete string representation. if (!stringBuffer.append("})")) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return nullptr; } RootedAtom stringRepr(cx, stringBuffer.finishAtom()); @@ -901,7 +901,7 @@ StructMetaTypeDescr::create(JSContext* cx, // Adjust the total size to be a multiple of the final alignment. CheckedInt32 totalSize = roundUpToAlignment(sizeSoFar, alignment); if (!totalSize.isValid()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_TYPEDOBJECT_TOO_BIG); return nullptr; } @@ -1002,7 +1002,7 @@ StructMetaTypeDescr::construct(JSContext* cx, unsigned int argc, Value* vp) CallArgs args = CallArgsFromVp(argc, vp); if (!args.isConstructing()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NOT_FUNCTION, "StructType"); return false; } @@ -1017,7 +1017,7 @@ StructMetaTypeDescr::construct(JSContext* cx, unsigned int argc, Value* vp) return true; } - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_TYPEDOBJECT_STRUCTTYPE_BAD_ARGS); return false; } @@ -1333,25 +1333,13 @@ GlobalObject::initTypedObjectModule(JSContext* cx, Handle global) } JSObject* -js_InitTypedObjectModuleObject(JSContext* cx, HandleObject obj) +js::InitTypedObjectModuleObject(JSContext* cx, HandleObject obj) { MOZ_ASSERT(obj->is()); Rooted global(cx, &obj->as()); return global->getOrCreateTypedObjectModule(cx); } -JSObject* -js_InitTypedObjectDummy(JSContext* cx, HandleObject obj) -{ - /* - * This function is entered into the jsprototypes.h table - * as the initializer for `TypedObject`. It should not - * be executed via the `standard_class_atoms` mechanism. - */ - - MOZ_CRASH("shouldn't be initializing TypedObject via the JSProtoKey initializer mechanism"); -} - /****************************************************************************** * Typed objects */ @@ -1633,7 +1621,7 @@ ReportTypedObjTypeError(JSContext* cx, if (!typeReprStr) return false; - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, errorNumber, typeReprStr); JS_free(cx, (void*) typeReprStr); @@ -1700,7 +1688,7 @@ TypedObject::obj_lookupProperty(JSContext* cx, HandleObject obj, HandleId id, case type::Array: { uint32_t index; - if (js_IdIsIndex(id, &index)) + if (IdIsIndex(id, &index)) return obj_lookupElement(cx, obj, index, objp, propp); if (JSID_IS_ATOM(id, cx->names().length)) { @@ -1758,7 +1746,7 @@ ReportPropertyError(JSContext* cx, if (!propName) return false; - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, errorNumber, propName); JS_free(cx, propName); @@ -1790,7 +1778,7 @@ TypedObject::obj_hasProperty(JSContext* cx, HandleObject obj, HandleId id, bool* } uint32_t index; // Elements are not inherited from the prototype. - if (js_IdIsIndex(id, &index)) { + if (IdIsIndex(id, &index)) { *foundp = (index < uint32_t(typedObj->length())); return true; } @@ -1822,7 +1810,7 @@ TypedObject::obj_getProperty(JSContext* cx, HandleObject obj, HandleObject recei // Dispatch elements to obj_getElement: uint32_t index; - if (js_IdIsIndex(id, &index)) + if (IdIsIndex(id, &index)) return obj_getElement(cx, obj, receiver, index, vp); // Handle everything else here: @@ -1839,7 +1827,7 @@ TypedObject::obj_getProperty(JSContext* cx, HandleObject obj, HandleObject recei if (JSID_IS_ATOM(id, cx->names().length)) { if (!typedObj->isAttached()) { JS_ReportErrorNumber( - cx, js_GetErrorMessage, + cx, GetErrorMessage, nullptr, JSMSG_TYPEDOBJECT_HANDLE_UNATTACHED); return false; } @@ -1934,7 +1922,7 @@ TypedObject::obj_setProperty(JSContext* cx, HandleObject obj, HandleObject recei case type::Array: { if (JSID_IS_ATOM(id, cx->names().length)) { if (obj == receiver) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CANT_REDEFINE_ARRAY_LENGTH); return false; } @@ -1942,12 +1930,12 @@ TypedObject::obj_setProperty(JSContext* cx, HandleObject obj, HandleObject recei } uint32_t index; - if (js_IdIsIndex(id, &index)) { + if (IdIsIndex(id, &index)) { if (obj != receiver) return SetPropertyByDefining(cx, obj, receiver, id, vp, strict, false); if (index >= uint32_t(typedObj->length())) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_TYPEDOBJECT_BINARYARRAY_BAD_INDEX); return false; } @@ -1986,7 +1974,7 @@ TypedObject::obj_getOwnPropertyDescriptor(JSContext* cx, HandleObject obj, Handl { Rooted typedObj(cx, &obj->as()); if (!typedObj->isAttached()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_TYPEDOBJECT_HANDLE_UNATTACHED); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_TYPEDOBJECT_HANDLE_UNATTACHED); return false; } @@ -2000,7 +1988,7 @@ TypedObject::obj_getOwnPropertyDescriptor(JSContext* cx, HandleObject obj, Handl case type::Array: { uint32_t index; - if (js_IdIsIndex(id, &index)) { + if (IdIsIndex(id, &index)) { if (!obj_getArrayElement(cx, typedObj, descr, index, desc.value())) return false; desc.setAttributes(JSPROP_ENUMERATE | JSPROP_PERMANENT); @@ -2052,7 +2040,7 @@ IsOwnId(JSContext* cx, HandleObject obj, HandleId id) return false; case type::Array: - return js_IdIsIndex(id, &index) || JSID_IS_ATOM(id, cx->names().length); + return IdIsIndex(id, &index) || JSID_IS_ATOM(id, cx->names().length); case type::Struct: size_t index; @@ -2274,7 +2262,7 @@ LazyArrayBufferTable::addBuffer(JSContext* cx, InlineTransparentTypedObject* obj { MOZ_ASSERT(!map.has(obj)); if (!map.put(obj, buffer)) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return false; } @@ -2428,7 +2416,7 @@ TypedObject::construct(JSContext* cx, unsigned int argc, Value* vp) buffer = &args[0].toObject().as(); if (callee->opaque() || buffer->isNeutered()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_TYPEDOBJECT_BAD_ARGS); return false; } @@ -2436,7 +2424,7 @@ TypedObject::construct(JSContext* cx, unsigned int argc, Value* vp) int32_t offset; if (args.length() >= 2 && !args[1].isUndefined()) { if (!args[1].isInt32()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_TYPEDOBJECT_BAD_ARGS); return false; } @@ -2447,7 +2435,7 @@ TypedObject::construct(JSContext* cx, unsigned int argc, Value* vp) } if (args.length() >= 3 && !args[2].isUndefined()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_TYPEDOBJECT_BAD_ARGS); return false; } @@ -2455,7 +2443,7 @@ TypedObject::construct(JSContext* cx, unsigned int argc, Value* vp) if (!CheckOffset(offset, callee->size(), callee->alignment(), buffer->byteLength())) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_TYPEDOBJECT_BAD_ARGS); return false; } @@ -2486,7 +2474,7 @@ TypedObject::construct(JSContext* cx, unsigned int argc, Value* vp) } // Something bogus. - JS_ReportErrorNumber(cx, js_GetErrorMessage, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_TYPEDOBJECT_BAD_ARGS); return false; } diff --git a/js/src/builtin/TypedObject.h b/js/src/builtin/TypedObject.h index 7b634b687b..32ec2f5fde 100644 --- a/js/src/builtin/TypedObject.h +++ b/js/src/builtin/TypedObject.h @@ -39,7 +39,7 @@ * Currently, all "globals" related to typed objects are packaged * within a single "module" object `TypedObject`. This module has its * own js::Class and when that class is initialized, we also create - * and define all other values (in `js_InitTypedObjectModuleClass()`). + * and define all other values (in `js::InitTypedObjectModuleClass()`). * * - Type objects, meta type objects, and type representations: * @@ -1042,10 +1042,10 @@ class LazyArrayBufferTable size_t sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf); }; -} // namespace js - JSObject* -js_InitTypedObjectModuleObject(JSContext* cx, JS::HandleObject obj); +InitTypedObjectModuleObject(JSContext* cx, JS::HandleObject obj); + +} // namespace js template <> inline bool diff --git a/js/src/builtin/WeakSetObject.cpp b/js/src/builtin/WeakSetObject.cpp index 497fec1016..a365452382 100644 --- a/js/src/builtin/WeakSetObject.cpp +++ b/js/src/builtin/WeakSetObject.cpp @@ -86,7 +86,7 @@ WeakSetObject::construct(JSContext* cx, unsigned argc, Value* vp) CallArgs args = CallArgsFromVp(argc, vp); if (!args.isConstructing()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_NOT_FUNCTION, "WeakSet"); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NOT_FUNCTION, "WeakSet"); return false; } @@ -126,7 +126,7 @@ WeakSetObject::construct(JSContext* cx, unsigned argc, Value* vp) char *bytes = DecompileValueGenerator(cx, JSDVG_SEARCH_STACK, keyVal, NullPtr()); if (!bytes) return false; - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_NOT_NONNULL_OBJECT, bytes); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NOT_NONNULL_OBJECT, bytes); return false; } @@ -153,7 +153,7 @@ WeakSetObject::construct(JSContext* cx, unsigned argc, Value* vp) JSObject* -js_InitWeakSetClass(JSContext* cx, HandleObject obj) +js::InitWeakSetClass(JSContext* cx, HandleObject obj) { return WeakSetObject::initClass(cx, obj); } diff --git a/js/src/builtin/WeakSetObject.h b/js/src/builtin/WeakSetObject.h index a55157bf19..308b67e67f 100644 --- a/js/src/builtin/WeakSetObject.h +++ b/js/src/builtin/WeakSetObject.h @@ -27,9 +27,9 @@ class WeakSetObject : public NativeObject static bool construct(JSContext* cx, unsigned argc, Value* vp); }; +extern JSObject* +InitWeakSetClass(JSContext* cx, HandleObject obj); + } // namespace js -extern JSObject* -js_InitWeakSetClass(JSContext* cx, js::HandleObject obj); - #endif /* builtin_WeakSetObject_h */ diff --git a/js/src/ctypes/CTypes.cpp b/js/src/ctypes/CTypes.cpp index b0f9187ade..be66884728 100644 --- a/js/src/ctypes/CTypes.cpp +++ b/js/src/ctypes/CTypes.cpp @@ -89,7 +89,7 @@ GetDeflatedUTF8StringLength(JSContext* maybecx, const CharT* chars, if (maybecx) { js::gc::AutoSuppressGC suppress(maybecx); JS_snprintf(buffer, 10, "0x%x", c); - JS_ReportErrorFlagsAndNumber(maybecx, JSREPORT_ERROR, js_GetErrorMessage, + JS_ReportErrorFlagsAndNumber(maybecx, JSREPORT_ERROR, GetErrorMessage, nullptr, JSMSG_BAD_SURROGATE_CHAR, buffer); } return (size_t) -1; @@ -151,7 +151,7 @@ DeflateStringToUTF8Buffer(JSContext* maybecx, const CharT* src, size_t srclen, *dst++ = (char) v; utf8Len = 1; } else { - utf8Len = js_OneUcs4ToUtf8Char(utf8buf, v); + utf8Len = js::OneUcs4ToUtf8Char(utf8buf, v); if (utf8Len > dstlen) goto bufferTooSmall; for (i = 0; i < utf8Len; i++) @@ -173,7 +173,7 @@ bufferTooSmall: *dstlenp = (origDstlen - dstlen); if (maybecx) { js::gc::AutoSuppressGC suppress(maybecx); - JS_ReportErrorNumber(maybecx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(maybecx, GetErrorMessage, nullptr, JSMSG_BUFFER_TOO_SMALL); } return false; @@ -749,8 +749,8 @@ static const JSPropertySpec sFunctionProps[] = { }; static const JSFunctionSpec sFunctionInstanceFunctions[] = { - JS_FN("call", js_fun_call, 1, CDATAFN_FLAGS), - JS_FN("apply", js_fun_apply, 2, CDATAFN_FLAGS), + JS_FN("call", js::fun_call, 1, CDATAFN_FLAGS), + JS_FN("apply", js::fun_apply, 2, CDATAFN_FLAGS), JS_FS_END }; diff --git a/js/src/frontend/BytecodeCompiler.cpp b/js/src/frontend/BytecodeCompiler.cpp index b32438bffb..6fabccde43 100644 --- a/js/src/frontend/BytecodeCompiler.cpp +++ b/js/src/frontend/BytecodeCompiler.cpp @@ -34,7 +34,7 @@ CheckLength(ExclusiveContext* cx, SourceBufferHolder& srcBuf) // is using size_t internally already. if (srcBuf.length() > UINT32_MAX) { if (cx->isJSContext()) - JS_ReportErrorNumber(cx->asJSContext(), js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx->asJSContext(), GetErrorMessage, nullptr, JSMSG_SOURCE_TOO_LONG); return false; } diff --git a/js/src/frontend/BytecodeEmitter.cpp b/js/src/frontend/BytecodeEmitter.cpp index 0cae65d56a..087acaa101 100644 --- a/js/src/frontend/BytecodeEmitter.cpp +++ b/js/src/frontend/BytecodeEmitter.cpp @@ -209,7 +209,7 @@ EmitCheck(ExclusiveContext* cx, BytecodeEmitter* bce, ptrdiff_t delta) jsbytecode dummy = 0; if (!bce->code().appendN(dummy, delta)) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return -1; } return offset; @@ -2821,7 +2821,7 @@ EmitSwitch(ExclusiveContext* cx, BytecodeEmitter* bce, ParseNode* pn) intmap_bitlen = JS_BIT(16); intmap = cx->pod_malloc(JS_BIT(16) / JS_BITMAP_NBITS); if (!intmap) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return false; } } @@ -7410,7 +7410,7 @@ AllocSrcNote(ExclusiveContext* cx, SrcNotesVector& notes) jssrcnote dummy = 0; if (!notes.append(dummy)) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return -1; } return notes.length() - 1; @@ -7544,7 +7544,7 @@ SetSrcNoteOffset(ExclusiveContext* cx, BytecodeEmitter* bce, unsigned index, uns !(sn = notes.insert(sn, dummy)) || !(sn = notes.insert(sn, dummy))) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return false; } } diff --git a/js/src/frontend/NameFunctions.cpp b/js/src/frontend/NameFunctions.cpp index e7ed644cb5..6b85c00383 100644 --- a/js/src/frontend/NameFunctions.cpp +++ b/js/src/frontend/NameFunctions.cpp @@ -48,7 +48,7 @@ class NameResolver return buf->append('.') && buf->append(name); /* Quote the string as needed. */ - JSString* source = js_QuoteString(cx, name, '"'); + JSString* source = QuoteString(cx, name, '"'); return source && buf->append('[') && buf->append(source) && buf->append(']'); } diff --git a/js/src/frontend/ParseMaps.cpp b/js/src/frontend/ParseMaps.cpp index 2b67b1402b..bb33797c1b 100644 --- a/js/src/frontend/ParseMaps.cpp +++ b/js/src/frontend/ParseMaps.cpp @@ -62,7 +62,7 @@ DefinitionList::allocNode(ExclusiveContext* cx, LifoAlloc& alloc, uintptr_t head { Node* result = alloc.new_(head, tail); if (!result) - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return result; } diff --git a/js/src/frontend/ParseNode.cpp b/js/src/frontend/ParseNode.cpp index d0030b6914..af3b66fe54 100644 --- a/js/src/frontend/ParseNode.cpp +++ b/js/src/frontend/ParseNode.cpp @@ -571,7 +571,7 @@ ParseNodeAllocator::allocNode() void* p = alloc.alloc(sizeof (ParseNode)); if (!p) - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return p; } diff --git a/js/src/frontend/Parser.cpp b/js/src/frontend/Parser.cpp index ec4cef36ca..21a7f0ad94 100644 --- a/js/src/frontend/Parser.cpp +++ b/js/src/frontend/Parser.cpp @@ -398,7 +398,7 @@ ParseContext::generateFunctionBindings(ExclusiveContext* cx, Token uint32_t count = args_.length() + vars_.length() + bodyLevelLexicals_.length(); Binding* packedBindings = alloc.newArrayUninitialized(count); if (!packedBindings) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return false; } @@ -579,7 +579,7 @@ Parser::newObjectBox(NativeObject* obj) ObjectBox* objbox = alloc.new_(obj, traceListHead); if (!objbox) { - js_ReportOutOfMemory(context); + ReportOutOfMemory(context); return nullptr; } @@ -676,7 +676,7 @@ Parser::newFunctionBox(Node fn, JSFunction* fun, ParseContextisNative()); for (uint32_t i = start; i < (start + nslots); ++i) { - trc->setTracingDetails(js_GetObjectSlotName, obj, i); + trc->setTracingDetails(GetObjectSlotName, obj, i); MarkValueInternal(trc, obj->getSlotRef(i).unsafeGet()); } } diff --git a/js/src/gc/Zone.h b/js/src/gc/Zone.h index c01cf8b91d..fa09e0b05a 100644 --- a/js/src/gc/Zone.h +++ b/js/src/gc/Zone.h @@ -136,7 +136,7 @@ struct Zone : public JS::shadow::Zone, void* onOutOfMemory(void* p, size_t nbytes) { return runtimeFromMainThread()->onOutOfMemory(p, nbytes); } - void reportAllocationOverflow() { js_ReportAllocationOverflow(nullptr); } + void reportAllocationOverflow() { js::ReportAllocationOverflow(nullptr); } void beginSweepTypes(js::FreeOp* fop, bool releaseTypes); diff --git a/js/src/irregexp/RegExpInterpreter.cpp b/js/src/irregexp/RegExpInterpreter.cpp index ca7d8f10d7..2a4bfb20a6 100644 --- a/js/src/irregexp/RegExpInterpreter.cpp +++ b/js/src/irregexp/RegExpInterpreter.cpp @@ -49,7 +49,7 @@ class MOZ_STACK_CLASS RegExpStackCursor bool init() { if (!stack.init()) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return false; } cursor = base(); @@ -61,7 +61,7 @@ class MOZ_STACK_CLASS RegExpStackCursor if (cursor >= stack.limit()) { int32_t pos = position(); if (!stack.grow()) { - js_ReportOverRecursed(cx); + ReportOverRecursed(cx); return false; } setPosition(pos); diff --git a/js/src/jit/BaselineIC.cpp b/js/src/jit/BaselineIC.cpp index f0fd95408c..938ea51098 100644 --- a/js/src/jit/BaselineIC.cpp +++ b/js/src/jit/BaselineIC.cpp @@ -1093,7 +1093,7 @@ ICTypeMonitor_Fallback::addMonitorStubForValue(JSContext* cx, JSScript* script, ICStub* stub = existingStub ? compiler.updateStub() : compiler.getStub(compiler.getStubSpace(script)); if (!stub) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return false; } @@ -1120,7 +1120,7 @@ ICTypeMonitor_Fallback::addMonitorStubForValue(JSContext* cx, JSScript* script, ICTypeMonitor_SingleObject::Compiler compiler(cx, obj); ICStub* stub = compiler.getStub(compiler.getStubSpace(script)); if (!stub) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return false; } @@ -1144,7 +1144,7 @@ ICTypeMonitor_Fallback::addMonitorStubForValue(JSContext* cx, JSScript* script, ICTypeMonitor_ObjectGroup::Compiler compiler(cx, group); ICStub* stub = compiler.getStub(compiler.getStubSpace(script)); if (!stub) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return false; } @@ -9110,7 +9110,7 @@ GetTemplateObjectForNative(JSContext* cx, HandleScript script, jsbytecode* pc, // Check for natives to which template objects can be attached. This is // done to provide templates to Ion for inlining these natives later on. - if (native == js_Array) { + if (native == ArrayConstructor) { // Note: the template array won't be used if its length is inaccurately // computed here. (We allocate here because compilation may occur on a // separate thread where allocation is impossible.) @@ -9167,7 +9167,7 @@ GetTemplateObjectForNative(JSContext* cx, HandleScript script, jsbytecode* pc, return true; } - if (native == js_String) { + if (native == StringConstructor) { RootedString emptyString(cx, cx->runtime()->emptyString); res.set(StringObject::create(cx, emptyString, TenuredObject)); return !!res; @@ -9416,7 +9416,7 @@ TryAttachCallStub(JSContext* cx, ICCall_Fallback* stub, HandleScript script, jsb // Check for JSOP_FUNAPPLY if (op == JSOP_FUNAPPLY) { - if (fun->native() == js_fun_apply) + if (fun->native() == fun_apply) return TryAttachFunApplyStub(cx, stub, script, pc, thisv, argc, vp + 2, handled); // Don't try to attach a "regular" optimized call stubs for FUNAPPLY ops, @@ -9424,7 +9424,7 @@ TryAttachCallStub(JSContext* cx, ICCall_Fallback* stub, HandleScript script, jsb return true; } - if (op == JSOP_FUNCALL && fun->native() == js_fun_call) { + if (op == JSOP_FUNCALL && fun->native() == fun_call) { if (!TryAttachFunCallStub(cx, stub, script, pc, thisv, handled)) return false; if (*handled) @@ -9853,7 +9853,7 @@ ICCallStubCompiler::guardFunApply(MacroAssembler& masm, GeneralRegisterSet regs, // Stack now confirmed to be like: // [..., CalleeV, ThisV, Arg0V, MagicValue(Arguments), ] - // Load the callee, ensure that it's js_fun_apply + // Load the callee, ensure that it's fun_apply ValueOperand val = regs.takeAnyValue(); Address calleeSlot(BaselineStackReg, ICStackValueOffset + (3 * sizeof(Value))); masm.loadValue(calleeSlot, val); @@ -9865,7 +9865,7 @@ ICCallStubCompiler::guardFunApply(MacroAssembler& masm, GeneralRegisterSet regs, failure); masm.loadPtr(Address(callee, JSFunction::offsetOfNativeOrScript()), callee); - masm.branchPtr(Assembler::NotEqual, callee, ImmPtr(js_fun_apply), failure); + masm.branchPtr(Assembler::NotEqual, callee, ImmPtr(fun_apply), failure); // Load the |thisv|, ensure that it's a scripted function with a valid baseline or ion // script, or a native function. @@ -10693,7 +10693,7 @@ ICCall_ScriptedApplyArray::Compiler::generateStubCode(MacroAssembler& masm) // Stack now looks like: // BaselineFrameReg -------------------. // v - // [..., js_fun_apply, TargetV, TargetThisV, ArgsArrayV, StubFrameHeader] + // [..., fun_apply, TargetV, TargetThisV, ArgsArrayV, StubFrameHeader] // Push all array elements onto the stack: Address arrayVal(BaselineFrameReg, STUB_FRAME_SIZE); @@ -10702,7 +10702,7 @@ ICCall_ScriptedApplyArray::Compiler::generateStubCode(MacroAssembler& masm) // Stack now looks like: // BaselineFrameReg -------------------. // v - // [..., js_fun_apply, TargetV, TargetThisV, ArgsArrayV, StubFrameHeader, + // [..., fun_apply, TargetV, TargetThisV, ArgsArrayV, StubFrameHeader, // PushedArgN, ..., PushedArg0] // Can't fail after this, so it's ok to clobber argcReg. @@ -10793,7 +10793,7 @@ ICCall_ScriptedApplyArguments::Compiler::generateStubCode(MacroAssembler& masm) // // Stack now looks like: - // [..., js_fun_apply, TargetV, TargetThisV, MagicArgsV, StubFrameHeader] + // [..., fun_apply, TargetV, TargetThisV, MagicArgsV, StubFrameHeader] // Push all arguments supplied to caller function onto the stack. pushCallerArguments(masm, regs); @@ -10801,7 +10801,7 @@ ICCall_ScriptedApplyArguments::Compiler::generateStubCode(MacroAssembler& masm) // Stack now looks like: // BaselineFrameReg -------------------. // v - // [..., js_fun_apply, TargetV, TargetThisV, MagicArgsV, StubFrameHeader, + // [..., fun_apply, TargetV, TargetThisV, MagicArgsV, StubFrameHeader, // PushedArgN, ..., PushedArg0] // Can't fail after this, so it's ok to clobber argcReg. @@ -10874,14 +10874,14 @@ ICCall_ScriptedFunCall::Compiler::generateStubCode(MacroAssembler& masm) masm.loadValue(calleeSlot, R1); regs.take(R1); - // Ensure callee is js_fun_call. + // Ensure callee is fun_call. masm.branchTestObject(Assembler::NotEqual, R1, &failure); Register callee = masm.extractObject(R1, ExtractTemp0); masm.branchTestObjClass(Assembler::NotEqual, callee, regs.getAny(), &JSFunction::class_, &failure); masm.loadPtr(Address(callee, JSFunction::offsetOfNativeOrScript()), callee); - masm.branchPtr(Assembler::NotEqual, callee, ImmPtr(js_fun_call), &failure); + masm.branchPtr(Assembler::NotEqual, callee, ImmPtr(fun_call), &failure); // Ensure |this| is a scripted function with JIT code. BaseIndex thisSlot(BaselineStackReg, argcReg, TimesEight, ICStackValueOffset); diff --git a/js/src/jit/Ion.cpp b/js/src/jit/Ion.cpp index 4ac94898e7..1c57817adf 100644 --- a/js/src/jit/Ion.cpp +++ b/js/src/jit/Ion.cpp @@ -747,7 +747,7 @@ IonScript::New(JSContext* cx, RecompileInfo recompileInfo, if (snapshotsListSize >= MAX_BUFFER_SIZE || (bailoutEntries >= MAX_BUFFER_SIZE / sizeof(uint32_t))) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return nullptr; } @@ -2115,7 +2115,7 @@ Compile(JSContext* cx, HandleScript script, BaselineFrame* osrFrame, jsbytecode* return Method_CantCompile; if (reason == AbortReason_Alloc) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return Method_Error; } diff --git a/js/src/jit/IonAnalysis.cpp b/js/src/jit/IonAnalysis.cpp index d589a5468e..ddacbc0347 100644 --- a/js/src/jit/IonAnalysis.cpp +++ b/js/src/jit/IonAnalysis.cpp @@ -3287,7 +3287,7 @@ jit::AnalyzeNewScriptDefiniteProperties(JSContext* cx, JSFunction* fun, CompilerConstraintList* constraints = NewCompilerConstraintList(temp); if (!constraints) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return false; } diff --git a/js/src/jit/IonBuilder.cpp b/js/src/jit/IonBuilder.cpp index 58e7efaeda..1fa196fef3 100644 --- a/js/src/jit/IonBuilder.cpp +++ b/js/src/jit/IonBuilder.cpp @@ -5715,7 +5715,7 @@ IonBuilder::jsop_funcall(uint32_t argc) // If |Function.prototype.call| may be overridden, don't optimize callsite. TemporaryTypeSet* calleeTypes = current->peek(calleeDepth)->resultTypeSet(); JSFunction* native = getSingleCallTarget(calleeTypes); - if (!native || !native->isNative() || native->native() != &js_fun_call) { + if (!native || !native->isNative() || native->native() != &fun_call) { CallInfo callInfo(alloc(), false); if (!callInfo.init(current, argc)) return false; @@ -5798,7 +5798,7 @@ IonBuilder::jsop_funapply(uint32_t argc) } if ((!native || !native->isNative() || - native->native() != js_fun_apply) && + native->native() != fun_apply) && info().analysisMode() != Analysis_DefiniteProperties) { return abort("fun.apply speculation failed"); diff --git a/js/src/jit/JitFrames.cpp b/js/src/jit/JitFrames.cpp index 70a2f0a8bd..0a405e507d 100644 --- a/js/src/jit/JitFrames.cpp +++ b/js/src/jit/JitFrames.cpp @@ -896,7 +896,7 @@ HandleException(ResumeFromException* rfe) if (overrecursed) { // We hit an overrecursion error during bailout. Report it now. - js_ReportOverRecursed(cx); + ReportOverRecursed(cx); } } diff --git a/js/src/jit/Linker.h b/js/src/jit/Linker.h index 9f73e7e7bb..810ee1cecf 100644 --- a/js/src/jit/Linker.h +++ b/js/src/jit/Linker.h @@ -23,8 +23,8 @@ class Linker { MacroAssembler& masm; - JitCode* fail(JSContext* cx) { - js_ReportOutOfMemory(cx); + JitCode *fail(JSContext *cx) { + ReportOutOfMemory(cx); return nullptr; } diff --git a/js/src/jit/MCallOptimize.cpp b/js/src/jit/MCallOptimize.cpp index 775d7a3c96..d67b1aacfe 100644 --- a/js/src/jit/MCallOptimize.cpp +++ b/js/src/jit/MCallOptimize.cpp @@ -64,7 +64,7 @@ IonBuilder::inlineNativeCall(CallInfo& callInfo, JSFunction* target) } // Array natives. - if (native == js_Array) + if (native == ArrayConstructor) return inlineArray(callInfo); if (native == js::array_pop) return inlineArrayPopShift(callInfo, MArrayPopShift::Pop); @@ -150,15 +150,15 @@ IonBuilder::inlineNativeCall(CallInfo& callInfo, JSFunction* target) return inlineMathFunction(callInfo, MMathFunction::Cbrt); // String natives. - if (native == js_String) + if (native == StringConstructor) return inlineStringObject(callInfo); - if (native == js::str_split) + if (native == str_split) return inlineStringSplit(callInfo); - if (native == js_str_charCodeAt) + if (native == str_charCodeAt) return inlineStrCharCodeAt(callInfo); - if (native == js::str_fromCharCode) + if (native == str_fromCharCode) return inlineStrFromCharCode(callInfo); - if (native == js_str_charAt) + if (native == str_charAt) return inlineStrCharAt(callInfo); if (native == str_replace) return inlineStrReplace(callInfo); @@ -448,7 +448,7 @@ IonBuilder::inlineArray(CallInfo& callInfo) uint32_t initLength = 0; AllocatingBehaviour allocating = NewArray_Unallocating; - JSObject* templateObject = inspector->getTemplateObjectForNative(pc, js_Array); + JSObject* templateObject = inspector->getTemplateObjectForNative(pc, ArrayConstructor); if (!templateObject) { trackOptimizationOutcome(TrackedOutcome::CantInlineNativeNoTemplateObj); return InliningStatus_NotInlined; @@ -1425,7 +1425,7 @@ IonBuilder::inlineStringObject(CallInfo& callInfo) if (callInfo.getArg(0)->mightBeType(MIRType_Object)) return InliningStatus_NotInlined; - JSObject* templateObj = inspector->getTemplateObjectForNative(pc, js_String); + JSObject* templateObj = inspector->getTemplateObjectForNative(pc, StringConstructor); if (!templateObj) return InliningStatus_NotInlined; MOZ_ASSERT(templateObj->is()); diff --git a/js/src/jit/MacroAssembler.cpp b/js/src/jit/MacroAssembler.cpp index 9e8497d7f2..2fa62cb511 100644 --- a/js/src/jit/MacroAssembler.cpp +++ b/js/src/jit/MacroAssembler.cpp @@ -1372,9 +1372,9 @@ MacroAssembler::linkExitFrame() } static void -ReportOverRecursed(JSContext* cx) +BailoutReportOverRecursed(JSContext* cx) { - js_ReportOverRecursed(cx); + ReportOverRecursed(cx); } void @@ -1400,7 +1400,7 @@ MacroAssembler::generateBailoutTail(Register scratch, Register bailoutInfo) loadJSContext(ReturnReg); setupUnalignedABICall(1, scratch); passABIArg(ReturnReg); - callWithABI(JS_FUNC_TO_DATA_PTR(void*, ReportOverRecursed)); + callWithABI(JS_FUNC_TO_DATA_PTR(void*, BailoutReportOverRecursed)); jump(exceptionLabel()); } diff --git a/js/src/jit/arm/Simulator-arm.h b/js/src/jit/arm/Simulator-arm.h index 36939d2929..1510ad0121 100644 --- a/js/src/jit/arm/Simulator-arm.h +++ b/js/src/jit/arm/Simulator-arm.h @@ -433,7 +433,7 @@ class Simulator #define JS_CHECK_SIMULATOR_RECURSION_WITH_EXTRA(cx, extra, onerror) \ JS_BEGIN_MACRO \ if (cx->runtime()->simulator()->overRecursedWithExtra(extra)) { \ - js_ReportOverRecursed(cx); \ + js::ReportOverRecursed(cx); \ onerror; \ } \ JS_END_MACRO diff --git a/js/src/jit/mips/Simulator-mips.h b/js/src/jit/mips/Simulator-mips.h index 72d4b8ca21..2eba056fef 100644 --- a/js/src/jit/mips/Simulator-mips.h +++ b/js/src/jit/mips/Simulator-mips.h @@ -408,7 +408,7 @@ class Simulator { #define JS_CHECK_SIMULATOR_RECURSION_WITH_EXTRA(cx, extra, onerror) \ JS_BEGIN_MACRO \ if (cx->mainThread().simulator()->overRecursedWithExtra(extra)) { \ - js_ReportOverRecursed(cx); \ + js::ReportOverRecursed(cx); \ onerror; \ } \ JS_END_MACRO diff --git a/js/src/jsalloc.cpp b/js/src/jsalloc.cpp index 2ea128fe3d..e8e135e458 100644 --- a/js/src/jsalloc.cpp +++ b/js/src/jsalloc.cpp @@ -19,5 +19,5 @@ TempAllocPolicy::onOutOfMemory(void* p, size_t nbytes) void TempAllocPolicy::reportAllocOverflow() const { - js_ReportAllocationOverflow(static_cast(cx_)); + ReportAllocationOverflow(static_cast(cx_)); } diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp index 987d462da2..210c9b48a7 100644 --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -121,7 +121,7 @@ JS::CallArgs::requireAtLeast(JSContext* cx, const char* fnname, unsigned require if (length() < required) { char numArgsStr[40]; JS_snprintf(numArgsStr, sizeof numArgsStr, "%u", required - 1); - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, fnname, numArgsStr, required == 2 ? "" : "s"); return false; } @@ -269,7 +269,7 @@ JS_ConvertArgumentsVA(JSContext *cx, const CallArgs &args, const char *format, v JS_snprintf(numBuf, sizeof numBuf, "%u", args.length()); JSAutoByteString funNameBytes; if (const char *name = GetFunctionNameBytes(cx, fun, &funNameBytes)) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, name, numBuf, (args.length() == 1) ? "" : "s"); } @@ -336,7 +336,7 @@ JS_ConvertArgumentsVA(JSContext *cx, const CallArgs &args, const char *format, v case '*': break; default: - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_BAD_CHAR, format); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_BAD_CHAR, format); return false; } } @@ -391,7 +391,7 @@ JS_ConvertValue(JSContext *cx, HandleValue value, JSType type, MutableHandleValu default: { char numBuf[12]; JS_snprintf(numBuf, sizeof numBuf, "%d", (int)type); - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_BAD_TYPE, numBuf); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_BAD_TYPE, numBuf); ok = false; break; } @@ -1801,8 +1801,8 @@ JS_InitClass(JSContext* cx, HandleObject obj, HandleObject parent_proto, AssertHeapIsIdle(cx); CHECK_REQUEST(cx); assertSameCompartment(cx, obj, parent_proto); - return js_InitClass(cx, obj, parent_proto, Valueify(clasp), constructor, - nargs, ps, fs, static_ps, static_fs); + return InitClass(cx, obj, parent_proto, Valueify(clasp), constructor, + nargs, ps, fs, static_ps, static_fs); } JS_PUBLIC_API(bool) @@ -1934,7 +1934,7 @@ JS_GetConstructor(JSContext* cx, HandleObject proto) if (!GetProperty(cx, proto, proto, cx->names().constructor, &cval)) return nullptr; if (!IsFunctionObject(cval)) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_NO_CONSTRUCTOR, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NO_CONSTRUCTOR, proto->getClass()->name); return nullptr; } @@ -3335,17 +3335,17 @@ CloneFunctionObject(JSContext* cx, HandleObject funobj, HandleObject dynamicScop } if (!IsFunctionCloneable(fun, dynamicScope)) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_BAD_CLONE_FUNOBJ_SCOPE); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_BAD_CLONE_FUNOBJ_SCOPE); return nullptr; } if (fun->isBoundFunction()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_CANT_CLONE_OBJECT); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CANT_CLONE_OBJECT); return nullptr; } if (fun->isNative() && IsAsmJSModuleNative(fun->native())) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_CANT_CLONE_OBJECT); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CANT_CLONE_OBJECT); return nullptr; } @@ -3438,7 +3438,7 @@ JS_PUBLIC_API(JSObject*) JS_BindCallable(JSContext* cx, HandleObject target, HandleObject newThis) { RootedValue thisArg(cx, ObjectValue(*newThis)); - return js_fun_bind(cx, target, thisArg, nullptr, 0); + return fun_bind(cx, target, thisArg, nullptr, 0); } static bool @@ -3451,7 +3451,7 @@ js_generic_native_method_dispatcher(JSContext* cx, unsigned argc, Value* vp) MOZ_ASSERT((fs->flags & JSFUN_GENERIC_NATIVE) != 0); if (argc < 1) { - js_ReportMissingArg(cx, args.calleev(), 0); + ReportMissingArg(cx, args.calleev(), 0); return false; } @@ -3612,7 +3612,7 @@ struct AutoLastFrameCheck if (cx->isExceptionPending() && !JS_IsRunning(cx) && (!cx->options().dontReportUncaught() && !cx->options().autoJSAPIOwnsErrorReporting())) { - js_ReportUncaughtException(cx); + ReportUncaughtException(cx); } } @@ -3697,7 +3697,7 @@ AutoFile::open(JSContext* cx, const char* filename) } else { fp_ = fopen(filename, "r"); if (!fp_) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_CANT_OPEN, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CANT_OPEN, filename, "No such file or directory"); return false; } @@ -4455,8 +4455,8 @@ JS_NewHelper(JSContext* cx, HandleObject ctor, const JS::HandleValueArray& input * API is asking for an object, so we report an error. */ JSAutoByteString bytes; - if (js_ValueToPrintable(cx, args.rval(), &bytes)) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_BAD_NEW_RESULT, + if (ValueToPrintable(cx, args.rval(), &bytes)) { + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_BAD_NEW_RESULT, bytes.ptr()); } return nullptr; @@ -4849,7 +4849,7 @@ JS_DecodeBytes(JSContext* cx, const char* src, size_t srclen, char16_t* dst, siz CopyAndInflateChars(dst, src, dstlen); AutoSuppressGC suppress(cx); - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_BUFFER_TOO_SMALL); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_BUFFER_TOO_SMALL); return false; } @@ -5031,7 +5031,7 @@ JS_Stringify(JSContext* cx, MutableHandleValue vp, HandleObject replacer, StringBuffer sb(cx); if (!sb.ensureTwoByteChars()) return false; - if (!js_Stringify(cx, vp, replacer, space, sb)) + if (!Stringify(cx, vp, replacer, space, sb)) return false; if (sb.empty() && !sb.append(cx->names().null)) return false; @@ -5085,7 +5085,7 @@ JS_ReportError(JSContext* cx, const char* format, ...) AssertHeapIsIdle(cx); va_start(ap, format); - js_ReportErrorVA(cx, JSREPORT_ERROR, format, ap); + ReportErrorVA(cx, JSREPORT_ERROR, format, ap); va_end(ap); } @@ -5105,8 +5105,8 @@ JS_ReportErrorNumberVA(JSContext* cx, JSErrorCallback errorCallback, va_list ap) { AssertHeapIsIdle(cx); - js_ReportErrorNumberVA(cx, JSREPORT_ERROR, errorCallback, userRef, - errorNumber, ArgumentsAreASCII, ap); + ReportErrorNumberVA(cx, JSREPORT_ERROR, errorCallback, userRef, + errorNumber, ArgumentsAreASCII, ap); } JS_PUBLIC_API(void) @@ -5117,8 +5117,8 @@ JS_ReportErrorNumberUC(JSContext* cx, JSErrorCallback errorCallback, AssertHeapIsIdle(cx); va_start(ap, errorNumber); - js_ReportErrorNumberVA(cx, JSREPORT_ERROR, errorCallback, userRef, - errorNumber, ArgumentsAreUnicode, ap); + ReportErrorNumberVA(cx, JSREPORT_ERROR, errorCallback, userRef, + errorNumber, ArgumentsAreUnicode, ap); va_end(ap); } @@ -5128,8 +5128,8 @@ JS_ReportErrorNumberUCArray(JSContext* cx, JSErrorCallback errorCallback, const char16_t** args) { AssertHeapIsIdle(cx); - js_ReportErrorNumberUCArray(cx, JSREPORT_ERROR, errorCallback, userRef, - errorNumber, args); + ReportErrorNumberUCArray(cx, JSREPORT_ERROR, errorCallback, userRef, + errorNumber, args); } JS_PUBLIC_API(bool) @@ -5140,7 +5140,7 @@ JS_ReportWarning(JSContext* cx, const char* format, ...) AssertHeapIsIdle(cx); va_start(ap, format); - ok = js_ReportErrorVA(cx, JSREPORT_WARNING, format, ap); + ok = ReportErrorVA(cx, JSREPORT_WARNING, format, ap); va_end(ap); return ok; } @@ -5155,8 +5155,8 @@ JS_ReportErrorFlagsAndNumber(JSContext* cx, unsigned flags, AssertHeapIsIdle(cx); va_start(ap, errorNumber); - ok = js_ReportErrorNumberVA(cx, flags, errorCallback, userRef, - errorNumber, ArgumentsAreASCII, ap); + ok = ReportErrorNumberVA(cx, flags, errorCallback, userRef, + errorNumber, ArgumentsAreASCII, ap); va_end(ap); return ok; } @@ -5171,8 +5171,8 @@ JS_ReportErrorFlagsAndNumberUC(JSContext* cx, unsigned flags, AssertHeapIsIdle(cx); va_start(ap, errorNumber); - ok = js_ReportErrorNumberVA(cx, flags, errorCallback, userRef, - errorNumber, ArgumentsAreUnicode, ap); + ok = ReportErrorNumberVA(cx, flags, errorCallback, userRef, + errorNumber, ArgumentsAreUnicode, ap); va_end(ap); return ok; } @@ -5180,13 +5180,13 @@ JS_ReportErrorFlagsAndNumberUC(JSContext* cx, unsigned flags, JS_PUBLIC_API(void) JS_ReportOutOfMemory(JSContext* cx) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); } JS_PUBLIC_API(void) JS_ReportAllocationOverflow(JSContext* cx) { - js_ReportAllocationOverflow(cx); + ReportAllocationOverflow(cx); } JS_PUBLIC_API(JSErrorReporter) @@ -5215,7 +5215,7 @@ JS_NewDateObject(JSContext* cx, int year, int mon, int mday, int hour, int min, { AssertHeapIsIdle(cx); CHECK_REQUEST(cx); - return js_NewDateObject(cx, year, mon, mday, hour, min, sec); + return NewDateObject(cx, year, mon, mday, hour, min, sec); } JS_PUBLIC_API(JSObject*) @@ -5223,7 +5223,7 @@ JS_NewDateObjectMsec(JSContext* cx, double msec) { AssertHeapIsIdle(cx); CHECK_REQUEST(cx); - return js_NewDateObjectMsec(cx, msec); + return NewDateObjectMsec(cx, msec); } JS_PUBLIC_API(bool) @@ -5467,7 +5467,7 @@ JS_ReportPendingException(JSContext* cx) CHECK_REQUEST(cx); // This can only fail due to oom. - bool ok = js_ReportUncaughtException(cx); + bool ok = ReportUncaughtException(cx); MOZ_ASSERT(!cx->isExceptionPending()); return ok; } @@ -5561,7 +5561,7 @@ JS_ErrorFromException(JSContext* cx, HandleObject obj) AssertHeapIsIdle(cx); CHECK_REQUEST(cx); assertSameCompartment(cx, obj); - return js_ErrorFromException(cx, obj); + return ErrorFromException(cx, obj); } JS_PUBLIC_API(bool) diff --git a/js/src/jsarray.cpp b/js/src/jsarray.cpp index 7b33cd905c..542f2344c8 100644 --- a/js/src/jsarray.cpp +++ b/js/src/jsarray.cpp @@ -340,7 +340,7 @@ SetArrayElement(JSContext* cx, HandleObject obj, double index, HandleValue v) break; uint32_t idx = uint32_t(index); if (idx >= arr->length() && !arr->lengthIsWritable()) { - JS_ReportErrorFlagsAndNumber(cx, JSREPORT_ERROR, js_GetErrorMessage, nullptr, + JS_ReportErrorFlagsAndNumber(cx, JSREPORT_ERROR, GetErrorMessage, nullptr, JSMSG_CANT_REDEFINE_ARRAY_LENGTH); return false; } @@ -499,7 +499,7 @@ js::CanonicalizeArrayLengthValue(JSContext* cx, HandleValue v, uint32_t* newLen) if (d == *newLen) return true; - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_BAD_ARRAY_LENGTH); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_BAD_ARRAY_LENGTH); return false; } @@ -553,7 +553,7 @@ js::ArraySetLength(JSContext* cx, Handle arr, HandleId id, return true; if (setterIsStrict) { - return JS_ReportErrorFlagsAndNumber(cx, JSREPORT_ERROR, js_GetErrorMessage, nullptr, + return JS_ReportErrorFlagsAndNumber(cx, JSREPORT_ERROR, GetErrorMessage, nullptr, JSMSG_CANT_REDEFINE_ARRAY_LENGTH); } @@ -659,7 +659,7 @@ js::ArraySetLength(JSContext* cx, Handle arr, HandleId id, return false; uint32_t index; - if (!js_IdIsIndex(props[i], &index)) + if (!IdIsIndex(props[i], &index)) continue; if (index >= newLen && index < oldLen) { @@ -783,7 +783,7 @@ js::WouldDefinePastNonwritableLength(ExclusiveContext* cx, return true; // XXX include the index and maybe array length in the error message - return JS_ReportErrorFlagsAndNumber(ncx, flags, js_GetErrorMessage, nullptr, + return JS_ReportErrorFlagsAndNumber(ncx, flags, GetErrorMessage, nullptr, JSMSG_CANT_DEFINE_PAST_ARRAY_LENGTH); } @@ -793,7 +793,7 @@ array_addProperty(JSContext* cx, HandleObject obj, HandleId id, MutableHandleVal Rooted arr(cx, &obj->as()); uint32_t index; - if (!js_IdIsIndex(id, &index)) + if (!IdIsIndex(id, &index)) return true; uint32_t length = arr->length(); @@ -1073,7 +1073,7 @@ js::ArrayJoin(JSContext* cx, HandleObject obj, HandleLinearString sepstr, uint32 size_t seplen = sepstr->length(); CheckedInt res = CheckedInt(seplen) * (length - 1); if (length > 0 && !res.isValid()) { - js_ReportAllocationOverflow(cx); + ReportAllocationOverflow(cx); return nullptr; } @@ -1873,7 +1873,7 @@ js::array_sort(JSContext* cx, unsigned argc, Value* vp) if (args.hasDefined(0)) { if (args[0].isPrimitive()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_BAD_SORT_ARG); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_BAD_SORT_ARG); return false; } fval = args[0]; /* non-default compare function */ @@ -1902,7 +1902,7 @@ js::array_sort(JSContext* cx, unsigned argc, Value* vp) */ #if JS_BITS_PER_WORD == 32 if (size_t(len) > size_t(-1) / (2 * sizeof(Value))) { - js_ReportAllocationOverflow(cx); + ReportAllocationOverflow(cx); return false; } #endif @@ -2973,7 +2973,7 @@ array_filter(JSContext* cx, unsigned argc, Value* vp) /* Step 4. */ if (args.length() == 0) { - js_ReportMissingArg(cx, args.calleev(), 0); + ReportMissingArg(cx, args.calleev(), 0); return false; } RootedObject callable(cx, ValueToCallable(cx, args[0], args.length() - 1)); @@ -3061,7 +3061,7 @@ IsArrayConstructor(const Value& v) return v.isObject() && v.toObject().is() && v.toObject().as().isNative() && - v.toObject().as().native() == js_Array; + v.toObject().as().native() == ArrayConstructor; } static bool @@ -3189,7 +3189,7 @@ static const JSFunctionSpec array_static_methods[] = { /* ES5 15.4.2 */ bool -js_Array(JSContext* cx, unsigned argc, Value* vp) +js::ArrayConstructor(JSContext* cx, unsigned argc, Value* vp) { CallArgs args = CallArgsFromVp(argc, vp); RootedObjectGroup group(cx, ObjectGroup::callingAllocationSiteGroup(cx, JSProto_Array)); @@ -3203,7 +3203,7 @@ js_Array(JSContext* cx, unsigned argc, Value* vp) if (args[0].isInt32()) { int32_t i = args[0].toInt32(); if (i < 0) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_BAD_ARRAY_LENGTH); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_BAD_ARRAY_LENGTH); return false; } length = uint32_t(i); @@ -3211,7 +3211,7 @@ js_Array(JSContext* cx, unsigned argc, Value* vp) double d = args[0].toDouble(); length = ToUint32(d); if (d != double(length)) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_BAD_ARRAY_LENGTH); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_BAD_ARRAY_LENGTH); return false; } } @@ -3235,7 +3235,7 @@ ArrayObject* js::ArrayConstructorOneArg(JSContext* cx, HandleObjectGroup group, int32_t lengthInt) { if (lengthInt < 0) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_BAD_ARRAY_LENGTH); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_BAD_ARRAY_LENGTH); return nullptr; } @@ -3333,7 +3333,7 @@ const Class ArrayObject::class_ = { nullptr, /* construct */ nullptr, /* trace */ { - GenericCreateConstructor, + GenericCreateConstructor, CreateArrayPrototype, array_static_methods, array_methods, @@ -3610,7 +3610,7 @@ js::NewDenseCopyOnWriteArray(JSContext* cx, HandleArrayObject templateObject, gc #ifdef DEBUG bool -js_ArrayInfo(JSContext* cx, unsigned argc, Value* vp) +js::ArrayInfo(JSContext* cx, unsigned argc, Value* vp) { CallArgs args = CallArgsFromVp(argc, vp); JSObject* obj; diff --git a/js/src/jsarray.h b/js/src/jsarray.h index 4e471df77c..d84cfb48e6 100644 --- a/js/src/jsarray.h +++ b/js/src/jsarray.h @@ -15,10 +15,9 @@ namespace js { /* 2^32-2, inclusive */ const uint32_t MAX_ARRAY_INDEX = 4294967294u; -} inline bool -js_IdIsIndex(jsid id, uint32_t* indexp) +IdIsIndex(jsid id, uint32_t* indexp) { if (JSID_IS_INT(id)) { int32_t i = JSID_TO_INT(id); @@ -33,10 +32,8 @@ js_IdIsIndex(jsid id, uint32_t* indexp) return js::StringIsArrayIndex(JSID_TO_ATOM(id), indexp); } -extern bool -js_InitContextBusyArrayTable(JSContext* cx); - -namespace js { +extern JSObject * +InitArrayClass(JSContext *cx, js::HandleObject obj); class ArrayObject; @@ -128,7 +125,7 @@ ObjectMayHaveExtraIndexedProperties(JSObject* obj); * Copy 'length' elements from aobj to vp. * * This function assumes 'length' is effectively the result of calling - * js_GetLengthProperty on aobj. vp must point to rooted memory. + * GetLengthProperty on aobj. vp must point to rooted memory. */ extern bool GetElements(JSContext* cx, HandleObject aobj, uint32_t length, js::Value* vp); @@ -192,15 +189,15 @@ NewbornArrayPush(JSContext* cx, HandleObject obj, const Value& v); extern ArrayObject* ArrayConstructorOneArg(JSContext* cx, HandleObjectGroup group, int32_t lengthInt); -} /* namespace js */ - #ifdef DEBUG extern bool -js_ArrayInfo(JSContext* cx, unsigned argc, js::Value* vp); +ArrayInfo(JSContext* cx, unsigned argc, Value* vp); #endif /* Array constructor native. Exposed only so the JIT can know its address. */ bool -js_Array(JSContext* cx, unsigned argc, js::Value* vp); +ArrayConstructor(JSContext* cx, unsigned argc, Value* vp); + +} /* namespace js */ #endif /* jsarray_h */ diff --git a/js/src/jsatom.cpp b/js/src/jsatom.cpp index 0087ec61bb..0b67ce95c8 100644 --- a/js/src/jsatom.cpp +++ b/js/src/jsatom.cpp @@ -39,7 +39,7 @@ using mozilla::RangedPtr; const char* js::AtomToPrintableString(ExclusiveContext* cx, JSAtom* atom, JSAutoByteString* bytes) { - JSString* str = js_QuoteString(cx, atom, 0); + JSString* str = QuoteString(cx, atom, 0); if (!str) return nullptr; return bytes->encodeLatin1(cx, str); @@ -161,7 +161,7 @@ JSRuntime::initializeAtoms(JSContext* cx) for (size_t i = 0; i < JS::WellKnownSymbolLimit; i++) { JS::Symbol* symbol = JS::Symbol::new_(cx, JS::SymbolCode(i), descriptions[i]); if (!symbol) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return false; } symbols[i].init(symbol); @@ -341,7 +341,7 @@ AtomizeAndCopyChars(ExclusiveContext* cx, const CharT* tbchars, size_t length, I // Grudgingly forgo last-ditch GC. The alternative would be to release // the lock, manually GC here, and retry from the top. If you fix this, // please also fix or comment the similar case in Symbol::new_. - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return nullptr; } @@ -351,7 +351,7 @@ AtomizeAndCopyChars(ExclusiveContext* cx, const CharT* tbchars, size_t length, I // since then can't GC; therefore the atoms table has not been modified and // p is still valid. if (!atoms.add(p, AtomStateEntry(atom, bool(ib)))) { - js_ReportOutOfMemory(cx); /* SystemAllocPolicy does not report OOM. */ + ReportOutOfMemory(cx); /* SystemAllocPolicy does not report OOM. */ return nullptr; } diff --git a/js/src/jsbool.cpp b/js/src/jsbool.cpp index 5f4408dd19..b5cd8ad404 100644 --- a/js/src/jsbool.cpp +++ b/js/src/jsbool.cpp @@ -70,7 +70,7 @@ bool_toString_impl(JSContext* cx, const CallArgs& args) MOZ_ASSERT(IsBoolean(thisv)); bool b = thisv.isBoolean() ? thisv.toBoolean() : thisv.toObject().as().unbox(); - args.rval().setString(js_BooleanToString(cx, b)); + args.rval().setString(BooleanToString(cx, b)); return true; } @@ -127,7 +127,7 @@ Boolean(JSContext* cx, unsigned argc, Value* vp) } JSObject* -js_InitBooleanClass(JSContext* cx, HandleObject obj) +js::InitBooleanClass(JSContext* cx, HandleObject obj) { MOZ_ASSERT(obj->isNative()); @@ -155,7 +155,7 @@ js_InitBooleanClass(JSContext* cx, HandleObject obj) } JSString* -js_BooleanToString(ExclusiveContext* cx, bool b) +js::BooleanToString(ExclusiveContext* cx, bool b) { return b ? cx->names().true_ : cx->names().false_; } diff --git a/js/src/jsbool.h b/js/src/jsbool.h index 21f9c67f30..4d94d6a1c9 100644 --- a/js/src/jsbool.h +++ b/js/src/jsbool.h @@ -13,10 +13,14 @@ #include "NamespaceImports.h" +namespace js { + extern JSObject* -js_InitBooleanClass(JSContext* cx, js::HandleObject obj); +InitBooleanClass(JSContext* cx, js::HandleObject obj); extern JSString* -js_BooleanToString(js::ExclusiveContext* cx, bool b); +BooleanToString(js::ExclusiveContext* cx, bool b); + +} #endif /* jsbool_h */ diff --git a/js/src/jscntxt.cpp b/js/src/jscntxt.cpp index 93eae5ce5c..e43316c9a2 100644 --- a/js/src/jscntxt.cpp +++ b/js/src/jscntxt.cpp @@ -219,14 +219,14 @@ ReportError(JSContext* cx, const char* message, JSErrorReport* reportp, * on the error report, and exception-aware hosts should ignore it. */ MOZ_ASSERT(reportp); - if ((!callback || callback == js_GetErrorMessage) && + if ((!callback || callback == GetErrorMessage) && reportp->errorNumber == JSMSG_UNCAUGHT_EXCEPTION) { reportp->flags |= JSREPORT_EXCEPTION; } if (cx->options().autoJSAPIOwnsErrorReporting() || JS_IsRunning(cx)) { - if (js_ErrorToException(cx, message, reportp, callback, userRef)) { + if (ErrorToException(cx, message, reportp, callback, userRef)) { return; } @@ -242,9 +242,8 @@ ReportError(JSContext* cx, const char* message, JSErrorReport* reportp, /* * Call the error reporter only if an exception wasn't raised. */ - if (message) { + if (message) CallErrorReporter(cx, message, reportp); - } } /* @@ -273,11 +272,11 @@ PopulateReportBlame(JSContext* cx, JSErrorReport* report) * throw the static atom "out of memory". If code is not running, call the * error reporter directly. * - * Furthermore, callers of js_ReportOutOfMemory (viz., malloc) assume a GC does + * Furthermore, callers of ReportOutOfMemory (viz., malloc) assume a GC does * not occur, so GC must be avoided or suppressed. */ void -js_ReportOutOfMemory(ExclusiveContext* cxArg) +js::ReportOutOfMemory(ExclusiveContext* cxArg) { #ifdef JS_MORE_DETERMINISTIC /* @@ -285,7 +284,7 @@ js_ReportOutOfMemory(ExclusiveContext* cxArg) * (e.g. interpreter vs JIT). In more-deterministic builds, print to stderr * so that the fuzzers can detect this. */ - fprintf(stderr, "js_ReportOutOfMemory called\n"); + fprintf(stderr, "ReportOutOfMemory called\n"); #endif if (!cxArg->isJSContext()) @@ -306,7 +305,7 @@ js_ReportOutOfMemory(ExclusiveContext* cxArg) } /* Get the message for this error, but we don't expand any arguments. */ - const JSErrorFormatString* efs = js_GetErrorMessage(nullptr, JSMSG_OUT_OF_MEMORY); + const JSErrorFormatString* efs = GetErrorMessage(nullptr, JSMSG_OUT_OF_MEMORY); const char* msg = efs ? efs->format : "Out of memory"; /* Fill out the report, but don't do anything that requires allocation. */ @@ -334,7 +333,7 @@ js_ReportOutOfMemory(ExclusiveContext* cxArg) } JS_FRIEND_API(void) -js_ReportOverRecursed(JSContext* maybecx) +js::ReportOverRecursed(JSContext* maybecx) { #ifdef JS_MORE_DETERMINISTIC /* @@ -345,25 +344,25 @@ js_ReportOverRecursed(JSContext* maybecx) * stack depth which is useful for external testing programs * like fuzzers. */ - fprintf(stderr, "js_ReportOverRecursed called\n"); + fprintf(stderr, "ReportOverRecursed called\n"); #endif if (maybecx) { - JS_ReportErrorNumber(maybecx, js_GetErrorMessage, nullptr, JSMSG_OVER_RECURSED); + JS_ReportErrorNumber(maybecx, GetErrorMessage, nullptr, JSMSG_OVER_RECURSED); maybecx->overRecursed_ = true; } } void -js_ReportOverRecursed(ExclusiveContext* cx) +js::ReportOverRecursed(ExclusiveContext* cx) { if (cx->isJSContext()) - js_ReportOverRecursed(cx->asJSContext()); + ReportOverRecursed(cx->asJSContext()); else cx->addPendingOverRecursed(); } void -js_ReportAllocationOverflow(ExclusiveContext* cxArg) +js::ReportAllocationOverflow(ExclusiveContext* cxArg) { if (!cxArg) return; @@ -373,7 +372,7 @@ js_ReportAllocationOverflow(ExclusiveContext* cxArg) JSContext* cx = cxArg->asJSContext(); AutoSuppressGC suppressGC(cx); - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_ALLOC_OVERFLOW); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_ALLOC_OVERFLOW); } /* @@ -413,7 +412,7 @@ checkReportFlags(JSContext* cx, unsigned* flags) } bool -js_ReportErrorVA(JSContext* cx, unsigned flags, const char* format, va_list ap) +js::ReportErrorVA(JSContext* cx, unsigned flags, const char* format, va_list ap) { char* message; char16_t* ucmessage; @@ -556,10 +555,10 @@ js::PrintError(JSContext* cx, FILE* file, const char* message, JSErrorReport* re * Returns true if the expansion succeeds (can fail if out of memory). */ bool -js_ExpandErrorArguments(ExclusiveContext* cx, JSErrorCallback callback, - void* userRef, const unsigned errorNumber, - char** messagep, JSErrorReport* reportp, - ErrorArgumentsType argumentsType, va_list ap) +js::ExpandErrorArguments(ExclusiveContext* cx, JSErrorCallback callback, + void* userRef, const unsigned errorNumber, + char** messagep, JSErrorReport* reportp, + ErrorArgumentsType argumentsType, va_list ap) { const JSErrorFormatString* efs; int i; @@ -569,7 +568,7 @@ js_ExpandErrorArguments(ExclusiveContext* cx, JSErrorCallback callback, *messagep = nullptr; if (!callback) - callback = js_GetErrorMessage; + callback = GetErrorMessage; { AutoSuppressGC suppressGC(cx); @@ -721,9 +720,9 @@ error: } bool -js_ReportErrorNumberVA(JSContext* cx, unsigned flags, JSErrorCallback callback, - void* userRef, const unsigned errorNumber, - ErrorArgumentsType argumentsType, va_list ap) +js::ReportErrorNumberVA(JSContext* cx, unsigned flags, JSErrorCallback callback, + void* userRef, const unsigned errorNumber, + ErrorArgumentsType argumentsType, va_list ap) { JSErrorReport report; char* message; @@ -737,8 +736,8 @@ js_ReportErrorNumberVA(JSContext* cx, unsigned flags, JSErrorCallback callback, report.errorNumber = errorNumber; PopulateReportBlame(cx, &report); - if (!js_ExpandErrorArguments(cx, callback, userRef, errorNumber, - &message, &report, argumentsType, ap)) { + if (!ExpandErrorArguments(cx, callback, userRef, errorNumber, + &message, &report, argumentsType, ap)) { return false; } @@ -763,9 +762,9 @@ js_ReportErrorNumberVA(JSContext* cx, unsigned flags, JSErrorCallback callback, } bool -js_ReportErrorNumberUCArray(JSContext* cx, unsigned flags, JSErrorCallback callback, - void* userRef, const unsigned errorNumber, - const char16_t** args) +js::ReportErrorNumberUCArray(JSContext* cx, unsigned flags, JSErrorCallback callback, + void* userRef, const unsigned errorNumber, + const char16_t** args) { if (checkReportFlags(cx, &flags)) return true; @@ -779,8 +778,8 @@ js_ReportErrorNumberUCArray(JSContext* cx, unsigned flags, JSErrorCallback callb char* message; va_list dummy; - if (!js_ExpandErrorArguments(cx, callback, userRef, errorNumber, - &message, &report, ArgumentsAreUnicode, dummy)) { + if (!ExpandErrorArguments(cx, callback, userRef, errorNumber, + &message, &report, ArgumentsAreUnicode, dummy)) { return false; } @@ -803,13 +802,13 @@ js::CallErrorReporter(JSContext* cx, const char* message, JSErrorReport* reportp } void -js_ReportIsNotDefined(JSContext* cx, const char* name) +js::ReportIsNotDefined(JSContext* cx, const char* name) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_NOT_DEFINED, name); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NOT_DEFINED, name); } bool -js_ReportIsNullOrUndefined(JSContext* cx, int spindex, HandleValue v, +js::ReportIsNullOrUndefined(JSContext* cx, int spindex, HandleValue v, HandleString fallback) { char* bytes; @@ -822,18 +821,18 @@ js_ReportIsNullOrUndefined(JSContext* cx, int spindex, HandleValue v, if (strcmp(bytes, js_undefined_str) == 0 || strcmp(bytes, js_null_str) == 0) { ok = JS_ReportErrorFlagsAndNumber(cx, JSREPORT_ERROR, - js_GetErrorMessage, nullptr, + GetErrorMessage, nullptr, JSMSG_NO_PROPERTIES, bytes, nullptr, nullptr); } else if (v.isUndefined()) { ok = JS_ReportErrorFlagsAndNumber(cx, JSREPORT_ERROR, - js_GetErrorMessage, nullptr, + GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE, bytes, js_undefined_str, nullptr); } else { MOZ_ASSERT(v.isNull()); ok = JS_ReportErrorFlagsAndNumber(cx, JSREPORT_ERROR, - js_GetErrorMessage, nullptr, + GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE, bytes, js_null_str, nullptr); } @@ -843,7 +842,7 @@ js_ReportIsNullOrUndefined(JSContext* cx, int spindex, HandleValue v, } void -js_ReportMissingArg(JSContext* cx, HandleValue v, unsigned arg) +js::ReportMissingArg(JSContext* cx, HandleValue v, unsigned arg) { char argbuf[11]; char* bytes; @@ -858,7 +857,7 @@ js_ReportMissingArg(JSContext* cx, HandleValue v, unsigned arg) if (!bytes) return; } - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_MISSING_FUN_ARG, argbuf, bytes ? bytes : ""); js_free(bytes); @@ -878,7 +877,7 @@ js::ReportValueErrorFlags(JSContext* cx, unsigned flags, const unsigned errorNum if (!bytes) return false; - ok = JS_ReportErrorFlagsAndNumber(cx, flags, js_GetErrorMessage, + ok = JS_ReportErrorFlagsAndNumber(cx, flags, GetErrorMessage, nullptr, errorNumber, bytes, arg1, arg2); js_free(bytes); @@ -893,7 +892,7 @@ const JSErrorFormatString js_ErrorFormatString[JSErr_Limit] = { }; JS_FRIEND_API(const JSErrorFormatString*) -js_GetErrorMessage(void* userRef, const unsigned errorNumber) +js::GetErrorMessage(void* userRef, const unsigned errorNumber) { if (errorNumber > 0 && errorNumber < JSErr_Limit) return &js_ErrorFormatString[errorNumber]; diff --git a/js/src/jscntxt.h b/js/src/jscntxt.h index 7bb8887683..8917b21dde 100644 --- a/js/src/jscntxt.h +++ b/js/src/jscntxt.h @@ -177,7 +177,7 @@ class ExclusiveContext : public ContextFriendFields, } void reportAllocationOverflow() { - js_ReportAllocationOverflow(this); + js::ReportAllocationOverflow(this); } // Accessors for immutable runtime data. @@ -298,7 +298,7 @@ struct JSContext : public js::ExclusiveContext, friend class js::ExclusiveContext; friend class JS::AutoSaveExceptionState; friend class js::jit::DebugModeOSRVolatileJitFrameIterator; - friend void js_ReportOverRecursed(JSContext*); + friend void js::ReportOverRecursed(JSContext*); private: /* Exception state -- the exception member is a GC root by definition. */ @@ -309,7 +309,7 @@ struct JSContext : public js::ExclusiveContext, JS::ContextOptions options_; // True if the exception currently being thrown is by result of - // js_ReportOverRecursed. See Debugger::slowPathOnExceptionUnwind. + // ReportOverRecursed. See Debugger::slowPathOnExceptionUnwind. bool overRecursed_; // True if propagating a forced return from an interrupt handler during @@ -564,30 +564,26 @@ enum ErrorArgumentsType { JSFunction* SelfHostedFunction(JSContext* cx, HandlePropertyName propName); -} /* namespace js */ - #ifdef va_start extern bool -js_ReportErrorVA(JSContext* cx, unsigned flags, const char* format, va_list ap); +ReportErrorVA(JSContext* cx, unsigned flags, const char* format, va_list ap); extern bool -js_ReportErrorNumberVA(JSContext* cx, unsigned flags, JSErrorCallback callback, - void* userRef, const unsigned errorNumber, - js::ErrorArgumentsType argumentsType, va_list ap); +ReportErrorNumberVA(JSContext* cx, unsigned flags, JSErrorCallback callback, + void* userRef, const unsigned errorNumber, + ErrorArgumentsType argumentsType, va_list ap); extern bool -js_ReportErrorNumberUCArray(JSContext* cx, unsigned flags, JSErrorCallback callback, - void* userRef, const unsigned errorNumber, - const char16_t** args); +ReportErrorNumberUCArray(JSContext* cx, unsigned flags, JSErrorCallback callback, + void* userRef, const unsigned errorNumber, + const char16_t** args); #endif extern bool -js_ExpandErrorArguments(js::ExclusiveContext* cx, JSErrorCallback callback, - void* userRef, const unsigned errorNumber, - char** message, JSErrorReport* reportp, - js::ErrorArgumentsType argumentsType, va_list ap); - -namespace js { +ExpandErrorArguments(ExclusiveContext* cx, JSErrorCallback callback, + void* userRef, const unsigned errorNumber, + char** message, JSErrorReport* reportp, + ErrorArgumentsType argumentsType, va_list ap); /* |callee| requires a usage string provided by JS_DefineFunctionsWithHelp. */ extern void @@ -609,22 +605,17 @@ PrintError(JSContext* cx, FILE* file, const char* message, JSErrorReport* report void CallErrorReporter(JSContext* cx, const char* message, JSErrorReport* report); -} /* namespace js */ - extern void -js_ReportIsNotDefined(JSContext* cx, const char* name); +ReportIsNotDefined(JSContext* cx, const char* name); /* * Report an attempt to access the property of a null or undefined value (v). */ extern bool -js_ReportIsNullOrUndefined(JSContext* cx, int spindex, js::HandleValue v, - js::HandleString fallback); +ReportIsNullOrUndefined(JSContext* cx, int spindex, HandleValue v, HandleString fallback); extern void -js_ReportMissingArg(JSContext* cx, js::HandleValue v, unsigned arg); - -namespace js { +ReportMissingArg(JSContext* cx, js::HandleValue v, unsigned arg); /* * Report error using js_DecompileValueGenerator(cx, spindex, v, fallback) as diff --git a/js/src/jscntxtinlines.h b/js/src/jscntxtinlines.h index 6f39b2b4e8..395587cfef 100644 --- a/js/src/jscntxtinlines.h +++ b/js/src/jscntxtinlines.h @@ -338,7 +338,7 @@ CallSetter(JSContext* cx, HandleObject obj, HandleId id, StrictPropertyOp op, un } if (attrs & JSPROP_GETTER) - return js_ReportGetterOnlyAssignment(cx, strict); + return ReportGetterOnlyAssignment(cx, strict); if (!op) return true; @@ -373,7 +373,7 @@ inline void JSContext::setPendingException(js::Value v) { MOZ_ASSERT(!IsPoisonedValue(v)); - // overRecursed_ is set after the fact by js_ReportOverRecursed. + // overRecursed_ is set after the fact by ReportOverRecursed. this->overRecursed_ = false; this->throwing = true; this->unwrappedException_ = v; diff --git a/js/src/jsdate.cpp b/js/src/jsdate.cpp index bfe8d47bcf..73ee6f21bc 100644 --- a/js/src/jsdate.cpp +++ b/js/src/jsdate.cpp @@ -2428,7 +2428,7 @@ date_toISOString_impl(JSContext* cx, const CallArgs& args) { double utctime = args.thisv().toObject().as().UTCTime().toNumber(); if (!IsFinite(utctime)) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INVALID_DATE); + JS_ReportErrorNumber(cx, js::GetErrorMessage, nullptr, JSMSG_INVALID_DATE); return false; } @@ -2483,7 +2483,7 @@ date_toJSON(JSContext* cx, unsigned argc, Value* vp) /* Step 5. */ if (!IsCallable(toISO)) { - JS_ReportErrorFlagsAndNumber(cx, JSREPORT_ERROR, js_GetErrorMessage, nullptr, + JS_ReportErrorFlagsAndNumber(cx, JSREPORT_ERROR, js::GetErrorMessage, nullptr, JSMSG_BAD_TOISOSTRING_PROP); return false; } @@ -2956,7 +2956,7 @@ static const JSFunctionSpec date_methods[] = { }; bool -js_Date(JSContext* cx, unsigned argc, Value* vp) +js::DateConstructor(JSContext* cx, unsigned argc, Value* vp) { CallArgs args = CallArgsFromVp(argc, vp); @@ -3008,7 +3008,7 @@ js_Date(JSContext* cx, unsigned argc, Value* vp) d = msec_time; } - JSObject* obj = js_NewDateObjectMsec(cx, d); + JSObject* obj = NewDateObjectMsec(cx, d); if (!obj) return false; @@ -3050,7 +3050,7 @@ const Class DateObject::class_ = { nullptr, /* construct */ nullptr, /* trace */ { - GenericCreateConstructor, + GenericCreateConstructor, GenericCreatePrototype, date_static_methods, date_methods, @@ -3060,7 +3060,7 @@ const Class DateObject::class_ = { }; JS_FRIEND_API(JSObject*) -js_NewDateObjectMsec(JSContext* cx, double msec_time) +js::NewDateObjectMsec(JSContext *cx, double msec_time) { JSObject* obj = NewBuiltinClassInstance(cx, &DateObject::class_); if (!obj) @@ -3070,12 +3070,12 @@ js_NewDateObjectMsec(JSContext* cx, double msec_time) } JS_FRIEND_API(JSObject*) -js_NewDateObject(JSContext* cx, int year, int mon, int mday, - int hour, int min, int sec) +js::NewDateObject(JSContext *cx, int year, int mon, int mday, + int hour, int min, int sec) { MOZ_ASSERT(mon < 12); double msec_time = date_msecFromDate(year, mon, mday, hour, min, sec, 0); - return js_NewDateObjectMsec(cx, UTC(msec_time, &cx->runtime()->dateTimeInfo)); + return NewDateObjectMsec(cx, UTC(msec_time, &cx->runtime()->dateTimeInfo)); } JS_FRIEND_API(bool) diff --git a/js/src/jsdate.h b/js/src/jsdate.h index b0a5bf1177..37b4f51e39 100644 --- a/js/src/jsdate.h +++ b/js/src/jsdate.h @@ -16,6 +16,8 @@ #include "js/RootingAPI.h" #include "js/TypeDecls.h" +namespace js { + /* * These functions provide a C interface to the date/time object */ @@ -25,7 +27,7 @@ * since the epoch. */ extern JS_FRIEND_API(JSObject*) -js_NewDateObjectMsec(JSContext* cx, double msec_time); +NewDateObjectMsec(JSContext *cx, double msec_time); /* * Construct a new Date Object from an exploded local time value. @@ -35,14 +37,12 @@ js_NewDateObjectMsec(JSContext* cx, double msec_time); * in 1995). */ extern JS_FRIEND_API(JSObject*) -js_NewDateObject(JSContext* cx, int year, int mon, int mday, +NewDateObject(JSContext *cx, int year, int mon, int mday, int hour, int min, int sec); /* Date constructor native. Exposed only so the JIT can know its address. */ bool -js_Date(JSContext* cx, unsigned argc, JS::Value* vp); - -namespace js { +DateConstructor(JSContext *cx, unsigned argc, JS::Value* vp); /* Date methods exposed so they can be installed in the self-hosting global. */ bool diff --git a/js/src/jsdtoa.cpp b/js/src/jsdtoa.cpp index 90e7f52859..d619395c54 100644 --- a/js/src/jsdtoa.cpp +++ b/js/src/jsdtoa.cpp @@ -499,13 +499,13 @@ js_dtobasestr(DtoaState* state, int base, double dinput) } DtoaState* -js_NewDtoaState() +js::NewDtoaState() { return newdtoa(); } void -js_DestroyDtoaState(DtoaState* state) +js::DestroyDtoaState(DtoaState* state) { destroydtoa(state); } diff --git a/js/src/jsdtoa.h b/js/src/jsdtoa.h index 6928911e23..2970ec17dd 100644 --- a/js/src/jsdtoa.h +++ b/js/src/jsdtoa.h @@ -16,11 +16,15 @@ struct DtoaState; -DtoaState* -js_NewDtoaState(); +namespace js { -void -js_DestroyDtoaState(DtoaState* state); +extern DtoaState* +NewDtoaState(); + +extern void +DestroyDtoaState(DtoaState* state); + +} // namespace js /* * js_strtod_harder() returns as a double-precision floating-point number the diff --git a/js/src/jsexn.cpp b/js/src/jsexn.cpp index 7e761712e0..d6b1b70be7 100644 --- a/js/src/jsexn.cpp +++ b/js/src/jsexn.cpp @@ -336,7 +336,7 @@ exn_finalize(FreeOp* fop, JSObject* obj) } JSErrorReport* -js_ErrorFromException(JSContext* cx, HandleObject objArg) +js::ErrorFromException(JSContext* cx, HandleObject objArg) { // It's ok to UncheckedUnwrap here, since all we do is get the // JSErrorReport, and consumers are careful with the information they get @@ -543,8 +543,8 @@ js::GetErrorTypeName(JSRuntime* rt, int16_t exnType) } bool -js_ErrorToException(JSContext* cx, const char* message, JSErrorReport* reportp, - JSErrorCallback callback, void* userRef) +js::ErrorToException(JSContext* cx, const char* message, JSErrorReport* reportp, + JSErrorCallback callback, void* userRef) { // Tell our caller to report immediately if this report is just a warning. MOZ_ASSERT(reportp); @@ -554,7 +554,7 @@ js_ErrorToException(JSContext* cx, const char* message, JSErrorReport* reportp, // Find the exception index associated with this error. JSErrNum errorNumber = static_cast(reportp->errorNumber); if (!callback) - callback = js_GetErrorMessage; + callback = GetErrorMessage; const JSErrorFormatString* errorString = callback(userRef, errorNumber); JSExnType exnType = errorString ? static_cast(errorString->exnType) : JSEXN_NONE; MOZ_ASSERT(exnType < JSEXN_LIMIT); @@ -652,7 +652,7 @@ js::ErrorReportToString(JSContext* cx, JSErrorReport* reportp) } bool -js_ReportUncaughtException(JSContext* cx) +js::ReportUncaughtException(JSContext* cx) { if (!cx->isExceptionPending()) return true; @@ -693,7 +693,7 @@ ErrorReport::~ErrorReport() js_free(ownedMessage); if (ownedReport.messageArgs) { /* - * js_ExpandErrorArguments owns its messageArgs only if it had to + * ExpandErrorArguments owns its messageArgs only if it had to * inflate the arguments (from regular |char*|s), which is always in * our case. */ @@ -716,7 +716,7 @@ ErrorReport::init(JSContext* cx, HandleValue exn) */ if (exn.isObject()) { exnObject = &exn.toObject(); - reportp = js_ErrorFromException(cx, exnObject); + reportp = ErrorFromException(cx, exnObject); JSCompartment* comp = exnObject->compartment(); JSAddonId* addonId = comp->addonId; @@ -746,7 +746,7 @@ ErrorReport::init(JSContext* cx, HandleValue exn) if (!str) cx->clearPendingException(); - // If js_ErrorFromException didn't get us a JSErrorReport, then the object + // If ErrorFromException didn't get us a JSErrorReport, then the object // was not an ErrorObject, security-wrapped or otherwise. However, it might // still quack like one. Give duck-typing a chance. We start by looking for // "filename" (all lowercase), since that's where DOMExceptions store their @@ -848,7 +848,7 @@ ErrorReport::init(JSContext* cx, HandleValue exn) if (!reportp) { // This is basically an inlined version of // - // JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, + // JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, // JSMSG_UNCAUGHT_EXCEPTION, message_); // // but without the reporting bits. Instead it just puts all @@ -892,9 +892,9 @@ ErrorReport::populateUncaughtExceptionReportVA(JSContext* cx, va_list ap) ownedReport.isMuted = iter.mutedErrors(); } - if (!js_ExpandErrorArguments(cx, js_GetErrorMessage, nullptr, - JSMSG_UNCAUGHT_EXCEPTION, &ownedMessage, - &ownedReport, ArgumentsAreASCII, ap)) { + if (!ExpandErrorArguments(cx, GetErrorMessage, nullptr, + JSMSG_UNCAUGHT_EXCEPTION, &ownedMessage, + &ownedReport, ArgumentsAreASCII, ap)) { return false; } @@ -905,7 +905,7 @@ ErrorReport::populateUncaughtExceptionReportVA(JSContext* cx, va_list ap) } JSObject* -js_CopyErrorObject(JSContext* cx, Handle err) +js::CopyErrorObject(JSContext* cx, Handle err) { js::ScopedJSFreePtr copyReport; if (JSErrorReport* errorReport = err->getErrorReport()) { diff --git a/js/src/jsexn.h b/js/src/jsexn.h index 376a191deb..ceed998ab9 100644 --- a/js/src/jsexn.h +++ b/js/src/jsexn.h @@ -22,7 +22,6 @@ CopyErrorReport(JSContext* cx, JSErrorReport* report); JSString* ComputeStackString(JSContext* cx); -} /* * Given a JSErrorReport, check to see if there is an exception associated with @@ -51,8 +50,8 @@ ComputeStackString(JSContext* cx); * unless the caller decides to call CallErrorReporter explicitly. */ extern bool -js_ErrorToException(JSContext* cx, const char* message, JSErrorReport* reportp, - JSErrorCallback callback, void* userRef); +ErrorToException(JSContext* cx, const char* message, JSErrorReport* reportp, + JSErrorCallback callback, void* userRef); /* * Called if a JS API call to js_Execute or js_InternalCall fails; calls the @@ -71,10 +70,10 @@ js_ErrorToException(JSContext* cx, const char* message, JSErrorReport* reportp, * this flag. */ extern bool -js_ReportUncaughtException(JSContext* cx); +ReportUncaughtException(JSContext* cx); extern JSErrorReport* -js_ErrorFromException(JSContext* cx, js::HandleObject obj); +ErrorFromException(JSContext* cx, HandleObject obj); /* * Make a copy of errobj parented to cx's compartment's global. @@ -84,7 +83,7 @@ js_ErrorFromException(JSContext* cx, js::HandleObject obj); * prototype objects (errobj->getPrivate() must not be nullptr). */ extern JSObject* -js_CopyErrorObject(JSContext* cx, JS::Handle errobj); +CopyErrorObject(JSContext* cx, JS::Handle errobj); static_assert(JSEXN_ERR == 0 && JSProto_Error + JSEXN_INTERNALERR == JSProto_InternalError && @@ -130,4 +129,6 @@ class AutoClearPendingException } }; +} // namespace js + #endif /* jsexn_h */ diff --git a/js/src/jsfriendapi.cpp b/js/src/jsfriendapi.cpp index f9e773b193..32713eb664 100644 --- a/js/src/jsfriendapi.cpp +++ b/js/src/jsfriendapi.cpp @@ -252,13 +252,13 @@ JS_DefineFunctionsWithHelp(JSContext* cx, HandleObject obj, const JSFunctionSpec } JS_FRIEND_API(bool) -js_ObjectClassIs(JSContext* cx, HandleObject obj, ESClassValue classValue) +js::ObjectClassIs(JSContext* cx, HandleObject obj, ESClassValue classValue) { return ObjectClassIs(obj, classValue, cx); } JS_FRIEND_API(const char*) -js_ObjectClassName(JSContext* cx, HandleObject obj) +js::ObjectClassName(JSContext* cx, HandleObject obj) { return GetObjectClassName(cx, obj); } @@ -1168,12 +1168,12 @@ js::GetObjectMetadata(JSObject* obj) } JS_FRIEND_API(bool) -js_DefineOwnProperty(JSContext* cx, JSObject* objArg, jsid idArg, - JS::Handle descriptor, bool* bp) +js::DefineOwnProperty(JSContext* cx, JSObject* objArg, jsid idArg, + JS::Handle descriptor, bool* bp) { RootedObject obj(cx, objArg); RootedId id(cx, idArg); - js::AssertHeapIsIdle(cx); + AssertHeapIsIdle(cx); CHECK_REQUEST(cx); assertSameCompartment(cx, obj, id, descriptor.value()); if (descriptor.hasGetterObject()) @@ -1185,9 +1185,9 @@ js_DefineOwnProperty(JSContext* cx, JSObject* objArg, jsid idArg, } JS_FRIEND_API(bool) -js_ReportIsNotFunction(JSContext* cx, JS::HandleValue v) +js::ReportIsNotFunction(JSContext* cx, HandleValue v) { - return ReportIsNotFunction(cx, v); + return ReportIsNotFunction(cx, v, -1); } JS_FRIEND_API(void) diff --git a/js/src/jsfriendapi.h b/js/src/jsfriendapi.h index c06d0db93a..c355253d53 100644 --- a/js/src/jsfriendapi.h +++ b/js/src/jsfriendapi.h @@ -121,16 +121,16 @@ JS_CloneObject(JSContext* cx, JS::HandleObject obj, JS::HandleObject proto, extern JS_FRIEND_API(JSString*) JS_BasicObjectToString(JSContext* cx, JS::HandleObject obj); -JS_FRIEND_API(void) -js_ReportOverRecursed(JSContext* maybecx); +namespace js { JS_FRIEND_API(bool) -js_ObjectClassIs(JSContext* cx, JS::HandleObject obj, js::ESClassValue classValue); +ObjectClassIs(JSContext* cx, JS::HandleObject obj, ESClassValue classValue); JS_FRIEND_API(const char*) -js_ObjectClassName(JSContext* cx, JS::HandleObject obj); +ObjectClassName(JSContext* cx, JS::HandleObject obj); -namespace js { +JS_FRIEND_API(void) +ReportOverRecursed(JSContext* maybecx); JS_FRIEND_API(bool) AddRawValueRoot(JSContext* cx, JS::Value* vp, const char* name); @@ -952,7 +952,7 @@ GetNativeStackLimit(JSContext* cx, int extraAllowance = 0) JS_BEGIN_MACRO \ int stackDummy_; \ if (!JS_CHECK_STACK_SIZE(limit, &stackDummy_)) { \ - js_ReportOverRecursed(cx); \ + js::ReportOverRecursed(cx); \ onerror; \ } \ JS_END_MACRO @@ -978,7 +978,7 @@ GetNativeStackLimit(JSContext* cx, int extraAllowance = 0) #define JS_CHECK_RECURSION_WITH_SP(cx, sp, onerror) \ JS_BEGIN_MACRO \ if (!JS_CHECK_STACK_SIZE(js::GetNativeStackLimit(cx), sp)) { \ - js_ReportOverRecursed(cx); \ + js::ReportOverRecursed(cx); \ onerror; \ } \ JS_END_MACRO @@ -1210,11 +1210,11 @@ typedef enum JSErrNum { JSErr_Limit } JSErrNum; -extern JS_FRIEND_API(const JSErrorFormatString*) -js_GetErrorMessage(void* userRef, const unsigned errorNumber); - namespace js { +extern JS_FRIEND_API(const JSErrorFormatString*) +GetErrorMessage(void* userRef, const unsigned errorNumber); + // AutoStableStringChars is here so we can use it in ErrorReport. It // should get moved out of here if we can manage it. See bug 1040316. @@ -1350,15 +1350,10 @@ struct MOZ_STACK_CLASS JS_FRIEND_API(ErrorReport) bool ownsMessageAndReport; }; -} /* namespace js */ - - -/* Implemented in jsclone.cpp. */ - +/* Implemented in vm/StructuredClone.cpp. */ extern JS_FRIEND_API(uint64_t) -js_GetSCOffset(JSStructuredCloneWriter* writer); +GetSCOffset(JSStructuredCloneWriter *writer); -namespace js { namespace Scalar { /* Scalar types which can appear in typed arrays and typed objects. The enum @@ -2615,15 +2610,15 @@ GetSavedFramePrincipals(JS::HandleObject savedFrame); extern JS_FRIEND_API(JSObject*) GetFirstSubsumedSavedFrame(JSContext* cx, JS::HandleObject savedFrame); +extern JS_FRIEND_API(bool) +ReportIsNotFunction(JSContext* cx, JS::HandleValue v); + +extern JS_FRIEND_API(bool) +DefineOwnProperty(JSContext* cx, JSObject* objArg, jsid idArg, + JS::Handle descriptor, bool* bp); + } /* namespace js */ -extern JS_FRIEND_API(bool) -js_DefineOwnProperty(JSContext* cx, JSObject* objArg, jsid idArg, - JS::Handle descriptor, bool* bp); - -extern JS_FRIEND_API(bool) -js_ReportIsNotFunction(JSContext* cx, JS::HandleValue v); - extern JS_FRIEND_API(void) JS_StoreObjectPostBarrierCallback(JSContext* cx, void (*callback)(JSTracer* trc, JSObject* key, void* data), diff --git a/js/src/jsfun.cpp b/js/src/jsfun.cpp index 0e34f6e535..5907d60f30 100644 --- a/js/src/jsfun.cpp +++ b/js/src/jsfun.cpp @@ -104,7 +104,7 @@ AdvanceToActiveCallLinear(JSContext* cx, NonBuiltinScriptFrameIter& iter, Handle static void ThrowTypeErrorBehavior(JSContext* cx) { - JS_ReportErrorFlagsAndNumber(cx, JSREPORT_ERROR, js_GetErrorMessage, nullptr, + JS_ReportErrorFlagsAndNumber(cx, JSREPORT_ERROR, GetErrorMessage, nullptr, JSMSG_THROW_TYPE_ERROR); } @@ -130,7 +130,7 @@ ArgumentsRestrictions(JSContext* cx, HandleFunction fun) // Otherwise emit a strict warning about |f.arguments| to discourage use of // this non-standard, performance-harmful feature. - if (!JS_ReportErrorFlagsAndNumber(cx, JSREPORT_WARNING | JSREPORT_STRICT, js_GetErrorMessage, + if (!JS_ReportErrorFlagsAndNumber(cx, JSREPORT_WARNING | JSREPORT_STRICT, GetErrorMessage, nullptr, JSMSG_DEPRECATED_USAGE, js_arguments_str)) { return false; @@ -219,7 +219,7 @@ CallerRestrictions(JSContext* cx, HandleFunction fun) // Otherwise emit a strict warning about |f.caller| to discourage use of // this non-standard, performance-harmful feature. - if (!JS_ReportErrorFlagsAndNumber(cx, JSREPORT_WARNING | JSREPORT_STRICT, js_GetErrorMessage, + if (!JS_ReportErrorFlagsAndNumber(cx, JSREPORT_WARNING | JSREPORT_STRICT, GetErrorMessage, nullptr, JSMSG_DEPRECATED_USAGE, js_caller_str)) { return false; @@ -272,7 +272,7 @@ CallerGetterImpl(JSContext* cx, const CallArgs& args) MOZ_ASSERT(!callerFun->isBuiltin(), "non-builtin iterator returned a builtin?"); if (callerFun->strict()) { - JS_ReportErrorFlagsAndNumber(cx, JSREPORT_ERROR, js_GetErrorMessage, nullptr, + JS_ReportErrorFlagsAndNumber(cx, JSREPORT_ERROR, GetErrorMessage, nullptr, JSMSG_CALLER_IS_STRICT); return false; } @@ -334,7 +334,7 @@ CallerSetterImpl(JSContext* cx, const CallArgs& args) MOZ_ASSERT(!callerFun->isBuiltin(), "non-builtin iterator returned a builtin?"); if (callerFun->strict()) { - JS_ReportErrorFlagsAndNumber(cx, JSREPORT_ERROR, js_GetErrorMessage, nullptr, + JS_ReportErrorFlagsAndNumber(cx, JSREPORT_ERROR, GetErrorMessage, nullptr, JSMSG_CALLER_IS_STRICT); return false; } @@ -532,7 +532,7 @@ js::XDRInterpretedFunction(XDRState* xdr, HandleObject enclosingScope, Han if (!fun->isInterpreted()) { JSAutoByteString funNameBytes; if (const char* name = GetFunctionNameBytes(cx, fun, &funNameBytes)) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NOT_SCRIPTED_FUNCTION, name); } return false; @@ -965,7 +965,7 @@ CreateFunctionPrototype(JSContext* cx, JSProtoKey key) if (!throwTypeError || !PreventExtensions(cx, throwTypeError, &succeeded)) return nullptr; if (!succeeded) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_CANT_CHANGE_EXTENSIBILITY); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CANT_CHANGE_EXTENSIBILITY); return nullptr; } @@ -1264,7 +1264,7 @@ fun_toStringHelper(JSContext* cx, HandleObject obj, unsigned indent) if (!obj->is()) { if (obj->is()) return Proxy::fun_toString(cx, obj, indent); - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO, js_Function_str, js_toString_str, "object"); @@ -1323,7 +1323,7 @@ fun_toSource(JSContext* cx, unsigned argc, Value* vp) #endif bool -js_fun_call(JSContext* cx, unsigned argc, Value* vp) +js::fun_call(JSContext* cx, unsigned argc, Value* vp) { CallArgs args = CallArgsFromVp(argc, vp); @@ -1347,7 +1347,7 @@ js_fun_call(JSContext* cx, unsigned argc, Value* vp) // ES5 15.3.4.3 bool -js_fun_apply(JSContext* cx, unsigned argc, Value* vp) +js::fun_apply(JSContext* cx, unsigned argc, Value* vp) { CallArgs args = CallArgsFromVp(argc, vp); @@ -1360,7 +1360,7 @@ js_fun_apply(JSContext* cx, unsigned argc, Value* vp) // Step 2. if (args.length() < 2 || args[1].isNullOrUndefined()) - return js_fun_call(cx, (args.length() > 0) ? 1 : 0, vp); + return fun_call(cx, (args.length() > 0) ? 1 : 0, vp); InvokeArgs args2(cx); @@ -1383,7 +1383,7 @@ js_fun_apply(JSContext* cx, unsigned argc, Value* vp) } else { // Step 3. if (!args[1].isObject()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_BAD_APPLY_ARGS, js_apply_str); return false; } @@ -1397,7 +1397,7 @@ js_fun_apply(JSContext* cx, unsigned argc, Value* vp) // Step 6. if (length > ARGS_LENGTH_MAX) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_TOO_MANY_FUN_APPLY_ARGS); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_TOO_MANY_FUN_APPLY_ARGS); return false; } @@ -1665,7 +1665,7 @@ js::CallOrConstructBoundFunction(JSContext* cx, unsigned argc, Value* vp) unsigned argslen = fun->getBoundFunctionArgumentCount(); if (args.length() + argslen > ARGS_LENGTH_MAX) { - js_ReportAllocationOverflow(cx); + ReportAllocationOverflow(cx); return false; } @@ -1738,7 +1738,7 @@ js::fun_bind(JSContext* cx, unsigned argc, Value* vp) // Steps 4-14. RootedValue thisArg(cx, args.length() >= 1 ? args[0] : UndefinedValue()); RootedObject target(cx, &thisv.toObject()); - JSObject* boundFunction = js_fun_bind(cx, target, thisArg, boundArgs, argslen); + JSObject* boundFunction = fun_bind(cx, target, thisArg, boundArgs, argslen); if (!boundFunction) return false; @@ -1748,8 +1748,8 @@ js::fun_bind(JSContext* cx, unsigned argc, Value* vp) } JSObject* -js_fun_bind(JSContext* cx, HandleObject target, HandleValue thisArg, - Value* boundArgs, unsigned argslen) +js::fun_bind(JSContext* cx, HandleObject target, HandleValue thisArg, + Value* boundArgs, unsigned argslen) { double length = 0.0; // Try to avoid invoking the resolve hook. @@ -1835,7 +1835,7 @@ js_fun_bind(JSContext* cx, HandleObject target, HandleValue thisArg, static bool OnBadFormal(JSContext* cx) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_BAD_FORMAL); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_BAD_FORMAL); return false; } @@ -1844,8 +1844,8 @@ const JSFunctionSpec js::function_methods[] = { JS_FN(js_toSource_str, fun_toSource, 0,0), #endif JS_FN(js_toString_str, fun_toString, 0,0), - JS_FN(js_apply_str, js_fun_apply, 2,0), - JS_FN(js_call_str, js_fun_call, 1,0), + JS_FN(js_apply_str, fun_apply, 2,0), + JS_FN(js_call_str, fun_call, 1,0), JS_FN("bind", fun_bind, 1,0), JS_FN("isGenerator", fun_isGenerator,0,0), JS_FS_END @@ -1860,7 +1860,7 @@ FunctionConstructor(JSContext* cx, unsigned argc, Value* vp, GeneratorKind gener /* Block this call if security callbacks forbid it. */ Rooted global(cx, &args.callee().global()); if (!GlobalObject::isRuntimeCodeGenEnabled(cx, global)) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_CSP_BLOCKED_FUNCTION); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CSP_BLOCKED_FUNCTION); return false; } @@ -1922,7 +1922,7 @@ FunctionConstructor(JSContext* cx, unsigned argc, Value* vp, GeneratorKind gener size_t old_args_length = args_length; args_length = old_args_length + arg->length(); if (args_length < old_args_length) { - js_ReportAllocationOverflow(cx); + ReportAllocationOverflow(cx); return false; } } @@ -1932,7 +1932,7 @@ FunctionConstructor(JSContext* cx, unsigned argc, Value* vp, GeneratorKind gener args_length = old_args_length + n - 1; if (args_length < old_args_length || args_length >= ~(size_t)0 / sizeof(char16_t)) { - js_ReportAllocationOverflow(cx); + ReportAllocationOverflow(cx); return false; } @@ -1944,7 +1944,7 @@ FunctionConstructor(JSContext* cx, unsigned argc, Value* vp, GeneratorKind gener LifoAllocScope las(&cx->tempLifoAlloc()); char16_t* cp = cx->tempLifoAlloc().newArray(args_length + 1); if (!cp) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return false; } ConstTwoByteChars collected_args(cp, args_length + 1); @@ -2362,7 +2362,7 @@ js::ReportIncompatibleMethod(JSContext* cx, CallReceiver call, const Class* clas if (JSFunction* fun = ReportIfNotFunction(cx, call.calleev())) { JSAutoByteString funNameBytes; if (const char* funName = GetFunctionNameBytes(cx, fun, &funNameBytes)) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO, clasp->name, funName, InformalValueTypeName(thisv)); } } @@ -2374,7 +2374,7 @@ js::ReportIncompatible(JSContext* cx, CallReceiver call) if (JSFunction* fun = ReportIfNotFunction(cx, call.calleev())) { JSAutoByteString funNameBytes; if (const char* funName = GetFunctionNameBytes(cx, fun, &funNameBytes)) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_METHOD, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_METHOD, funName, "method", InformalValueTypeName(call.thisv())); } } diff --git a/js/src/jsfun.h b/js/src/jsfun.h index 2dd82a139c..e4dbbfd396 100644 --- a/js/src/jsfun.h +++ b/js/src/jsfun.h @@ -696,17 +696,17 @@ CallOrConstructBoundFunction(JSContext*, unsigned, js::Value*); extern const JSFunctionSpec function_methods[]; -} /* namespace js */ +extern bool +fun_apply(JSContext* cx, unsigned argc, Value* vp); extern bool -js_fun_apply(JSContext* cx, unsigned argc, js::Value* vp); - -extern bool -js_fun_call(JSContext* cx, unsigned argc, js::Value* vp); +fun_call(JSContext* cx, unsigned argc, Value* vp); extern JSObject* -js_fun_bind(JSContext* cx, js::HandleObject target, js::HandleValue thisArg, - js::Value* boundArgs, unsigned argslen); +fun_bind(JSContext* cx, HandleObject target, HandleValue thisArg, + Value* boundArgs, unsigned argslen); + +} /* namespace js */ #ifdef DEBUG namespace JS { diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp index ce0820af7d..ef8e09a20f 100644 --- a/js/src/jsgc.cpp +++ b/js/src/jsgc.cpp @@ -2986,7 +2986,7 @@ GCRuntime::refillFreeListFromMainThread(JSContext* cx, AllocKind thingKind) // We are really just totally out of memory. MOZ_ASSERT(allowGC, "A fallible allocation must not report OOM on failure."); - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return nullptr; } @@ -3010,7 +3010,7 @@ GCRuntime::refillFreeListOffMainThread(ExclusiveContext* cx, AllocKind thingKind if (thing) return thing; - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return nullptr; } @@ -6512,12 +6512,12 @@ js::NewCompartment(JSContext* cx, Zone* zone, JSPrincipals* principals, AutoLockGC lock(rt); if (!zone->compartments.append(compartment.get())) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return nullptr; } if (zoneHolder && !rt->gc.zones.append(zone)) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return nullptr; } diff --git a/js/src/jsgc.h b/js/src/jsgc.h index d21d052143..737f35aa8f 100644 --- a/js/src/jsgc.h +++ b/js/src/jsgc.h @@ -853,15 +853,11 @@ const size_t MAX_EMPTY_CHUNK_AGE = 4; } /* namespace gc */ -} /* namespace js */ - extern bool -js_InitGC(JSRuntime* rt, uint32_t maxbytes); +InitGC(JSRuntime* rt, uint32_t maxbytes); extern void -js_FinishGC(JSRuntime* rt); - -namespace js { +FinishGC(JSRuntime* rt); class InterpreterFrame; @@ -1111,12 +1107,8 @@ extern void IterateScripts(JSRuntime* rt, JSCompartment* compartment, void* data, IterateScriptCallback scriptCallback); -} /* namespace js */ - extern void -js_FinalizeStringRT(JSRuntime* rt, JSString* str); - -namespace js { +FinalizeStringRT(JSRuntime* rt, JSString* str); JSCompartment* NewCompartment(JSContext* cx, JS::Zone* zone, JSPrincipals* principals, diff --git a/js/src/jsgcinlines.h b/js/src/jsgcinlines.h index 3b357730d4..306e96ccc6 100644 --- a/js/src/jsgcinlines.h +++ b/js/src/jsgcinlines.h @@ -474,7 +474,7 @@ CheckAllocatorState(ExclusiveContext* cx, AllocKind kind) // For testing out of memory conditions if (!PossiblyFail()) { - js_ReportOutOfMemory(ncx); + ReportOutOfMemory(ncx); return false; } @@ -676,25 +676,25 @@ NewGCAccessorShape(ExclusiveContext* cx) return gc::AllocateNonObject(cx); } +inline JSScript* +NewGCScript(ExclusiveContext* cx) +{ + return gc::AllocateNonObject(cx); +} + +inline LazyScript* +NewGCLazyScript(ExclusiveContext* cx) +{ + return gc::AllocateNonObject(cx); +} + +template +inline BaseShape* +NewGCBaseShape(ExclusiveContext* cx) +{ + return gc::AllocateNonObject(cx); +} + } /* namespace js */ -inline JSScript* -js_NewGCScript(js::ExclusiveContext* cx) -{ - return js::gc::AllocateNonObject(cx); -} - -inline js::LazyScript* -js_NewGCLazyScript(js::ExclusiveContext* cx) -{ - return js::gc::AllocateNonObject(cx); -} - -template -inline js::BaseShape* -js_NewGCBaseShape(js::ExclusiveContext* cx) -{ - return js::gc::AllocateNonObject(cx); -} - #endif /* jsgcinlines_h */ diff --git a/js/src/jsiter.cpp b/js/src/jsiter.cpp index 84b428eb84..6192a0d967 100644 --- a/js/src/jsiter.cpp +++ b/js/src/jsiter.cpp @@ -140,8 +140,8 @@ static bool SortComparatorIntegerIds(jsid a, jsid b, bool* lessOrEqualp) { uint32_t indexA, indexB; - MOZ_ALWAYS_TRUE(js_IdIsIndex(a, &indexA)); - MOZ_ALWAYS_TRUE(js_IdIsIndex(b, &indexB)); + MOZ_ALWAYS_TRUE(IdIsIndex(a, &indexA)); + MOZ_ALWAYS_TRUE(IdIsIndex(b, &indexB)); *lessOrEqualp = (indexA <= indexB); return true; } @@ -186,7 +186,7 @@ EnumerateNativeProperties(JSContext* cx, HandleNativeObject pobj, unsigned flags Shape& shape = r.front(); jsid id = shape.propid(); uint32_t dummy; - if (js_IdIsIndex(id, &dummy)) { + if (IdIsIndex(id, &dummy)) { if (!Enumerate(cx, pobj, id, shape.enumerable(), flags, ht, props)) return false; } @@ -223,7 +223,7 @@ EnumerateNativeProperties(JSContext* cx, HandleNativeObject pobj, unsigned flags } uint32_t dummy; - if (isIndexed && js_IdIsIndex(id, &dummy)) + if (isIndexed && IdIsIndex(id, &dummy)) continue; if (!Enumerate(cx, pobj, id, shape.enumerable(), flags, ht, props)) @@ -928,7 +928,7 @@ js::IteratorConstructor(JSContext* cx, unsigned argc, Value* vp) { CallArgs args = CallArgsFromVp(argc, vp); if (args.length() == 0) { - js_ReportMissingArg(cx, args.calleev(), 0); + ReportMissingArg(cx, args.calleev(), 0); return false; } @@ -1498,7 +1498,7 @@ GlobalObject::initStringIteratorProto(JSContext* cx, Handle globa } JSObject* -js_InitLegacyIteratorClass(JSContext* cx, HandleObject obj) +js::InitLegacyIteratorClass(JSContext* cx, HandleObject obj) { Handle global = obj.as(); @@ -1536,7 +1536,7 @@ js_InitLegacyIteratorClass(JSContext* cx, HandleObject obj) } JSObject* -js_InitStopIterationClass(JSContext* cx, HandleObject obj) +js::InitStopIterationClass(JSContext* cx, HandleObject obj) { Handle global = obj.as(); if (!global->getPrototype(JSProto_StopIteration).isObject()) { diff --git a/js/src/jsiter.h b/js/src/jsiter.h index 464f9e2020..a9adeaf0bb 100644 --- a/js/src/jsiter.h +++ b/js/src/jsiter.h @@ -212,12 +212,12 @@ ThrowStopIteration(JSContext* cx); extern JSObject* CreateItrResultObject(JSContext* cx, HandleValue value, bool done); +extern JSObject* +InitLegacyIteratorClass(JSContext* cx, HandleObject obj); + +extern JSObject* +InitStopIterationClass(JSContext* cx, HandleObject obj); + } /* namespace js */ -extern JSObject* -js_InitLegacyIteratorClass(JSContext* cx, js::HandleObject obj); - -extern JSObject* -js_InitStopIterationClass(JSContext* cx, js::HandleObject obj); - #endif /* jsiter_h */ diff --git a/js/src/jsmath.cpp b/js/src/jsmath.cpp index cadf8e871b..ac9a130ab3 100644 --- a/js/src/jsmath.cpp +++ b/js/src/jsmath.cpp @@ -1607,7 +1607,7 @@ static const JSFunctionSpec math_static_methods[] = { }; JSObject* -js_InitMathClass(JSContext* cx, HandleObject obj) +js::InitMathClass(JSContext* cx, HandleObject obj) { RootedObject proto(cx, obj->as().getOrCreateObjectPrototype(cx)); if (!proto) diff --git a/js/src/jsmath.h b/js/src/jsmath.h index d15777193f..5f63df5675 100644 --- a/js/src/jsmath.h +++ b/js/src/jsmath.h @@ -83,16 +83,12 @@ class MathCache size_t sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf); }; -} /* namespace js */ - /* * JS math functions. */ extern JSObject* -js_InitMathClass(JSContext* cx, js::HandleObject obj); - -namespace js { +InitMathClass(JSContext* cx, HandleObject obj); extern void random_initState(uint64_t* rngState); diff --git a/js/src/jsnum.cpp b/js/src/jsnum.cpp index 1628a70ae4..feb895346d 100644 --- a/js/src/jsnum.cpp +++ b/js/src/jsnum.cpp @@ -81,7 +81,7 @@ ComputeAccurateDecimalInteger(ExclusiveContext* cx, const CharT* start, const Ch int err = 0; *dp = js_strtod_harder(cx->dtoaState(), cstr, &estr, &err); if (err == JS_DTOA_ENOMEM) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return false; } @@ -681,8 +681,8 @@ Int32ToCString(ToCStringBuf* cbuf, int32_t i, size_t* len, int base = 10) } template -static JSString * JS_FASTCALL -js_NumberToStringWithBase(ExclusiveContext* cx, double d, int base); +static JSString * +NumberToStringWithBase(ExclusiveContext* cx, double d, int base); MOZ_ALWAYS_INLINE bool num_toString_impl(JSContext* cx, const CallArgs& args) @@ -698,13 +698,13 @@ num_toString_impl(JSContext* cx, const CallArgs& args) return false; if (d2 < 2 || d2 > 36) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_BAD_RADIX); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_BAD_RADIX); return false; } base = int32_t(d2); } - JSString* str = js_NumberToStringWithBase(cx, d, base); + JSString* str = NumberToStringWithBase(cx, d, base); if (!str) { JS_ReportOutOfMemory(cx); return false; @@ -714,7 +714,7 @@ num_toString_impl(JSContext* cx, const CallArgs& args) } bool -js_num_toString(JSContext* cx, unsigned argc, Value* vp) +js::num_toString(JSContext* cx, unsigned argc, Value* vp) { CallArgs args = CallArgsFromVp(argc, vp); return CallNonGenericMethod(cx, args); @@ -728,7 +728,7 @@ num_toLocaleString_impl(JSContext* cx, const CallArgs& args) double d = Extract(args.thisv()); - Rooted str(cx, js_NumberToStringWithBase(cx, d, 10)); + RootedString str(cx, NumberToStringWithBase(cx, d, 10)); if (!str) { JS_ReportOutOfMemory(cx); return false; @@ -864,7 +864,7 @@ num_valueOf_impl(JSContext* cx, const CallArgs& args) } bool -js_num_valueOf(JSContext* cx, unsigned argc, Value* vp) +js::num_valueOf(JSContext* cx, unsigned argc, Value* vp) { CallArgs args = CallArgsFromVp(argc, vp); return CallNonGenericMethod(cx, args); @@ -886,7 +886,7 @@ ComputePrecisionInRange(JSContext* cx, int minPrecision, int maxPrecision, Handl ToCStringBuf cbuf; if (char* numStr = NumberToCString(cx, &cbuf, prec, 10)) - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_PRECISION_RANGE, numStr); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_PRECISION_RANGE, numStr); return false; } @@ -967,7 +967,7 @@ num_toPrecision_impl(JSContext* cx, const CallArgs& args) double d = Extract(args.thisv()); if (!args.hasDefined(0)) { - JSString* str = js_NumberToStringWithBase(cx, d, 10); + JSString* str = NumberToStringWithBase(cx, d, 10); if (!str) { JS_ReportOutOfMemory(cx); return false; @@ -994,13 +994,13 @@ static const JSFunctionSpec number_methods[] = { #if JS_HAS_TOSOURCE JS_FN(js_toSource_str, num_toSource, 0, 0), #endif - JS_FN(js_toString_str, js_num_toString, 1, 0), + JS_FN(js_toString_str, num_toString, 1, 0), #if EXPOSE_INTL_API JS_SELF_HOSTED_FN(js_toLocaleString_str, "Number_toLocaleString", 0,0), #else JS_FN(js_toLocaleString_str, num_toLocaleString, 0,0), #endif - JS_FN(js_valueOf_str, js_num_valueOf, 0, 0), + JS_FN(js_valueOf_str, num_valueOf, 0, 0), JS_FN("toFixed", num_toFixed, 1, 0), JS_FN("toExponential", num_toExponential, 1, 0), JS_FN("toPrecision", num_toPrecision, 1, 0), @@ -1166,7 +1166,7 @@ js::FinishRuntimeNumberState(JSRuntime* rt) #endif JSObject* -js_InitNumberClass(JSContext* cx, HandleObject obj) +js::InitNumberClass(JSContext* cx, HandleObject obj) { MOZ_ASSERT(obj->isNative()); @@ -1260,8 +1260,8 @@ js::NumberToCString(JSContext* cx, ToCStringBuf* cbuf, double d, int base/* = 10 } template -static JSString * JS_FASTCALL -js_NumberToStringWithBase(ExclusiveContext* cx, double d, int base) +static JSString * +NumberToStringWithBase(ExclusiveContext* cx, double d, int base) { ToCStringBuf cbuf; char* numStr; @@ -1300,7 +1300,7 @@ js_NumberToStringWithBase(ExclusiveContext* cx, double d, int base) numStr = FracNumberToCString(cx, &cbuf, d, base); if (!numStr) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return nullptr; } MOZ_ASSERT_IF(base == 10, @@ -1319,7 +1319,7 @@ template JSString* js::NumberToString(ExclusiveContext* cx, double d) { - return js_NumberToStringWithBase(cx, d, 10); + return NumberToStringWithBase(cx, d, 10); } template JSString* @@ -1341,7 +1341,7 @@ js::NumberToAtom(ExclusiveContext* cx, double d) ToCStringBuf cbuf; char* numStr = FracNumberToCString(cx, &cbuf, d); if (!numStr) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return nullptr; } MOZ_ASSERT(!cbuf.dbuf && numStr >= cbuf.sbuf && numStr < cbuf.sbuf + cbuf.sbufSize); @@ -1359,7 +1359,7 @@ js::NumberToAtom(ExclusiveContext* cx, double d) JSFlatString* js::NumberToString(JSContext* cx, double d) { - if (JSString* str = js_NumberToStringWithBase(cx, d, 10)) + if (JSString* str = NumberToStringWithBase(cx, d, 10)) return &str->asFlat(); return nullptr; } @@ -1523,7 +1523,7 @@ js::ToNumberSlow(ExclusiveContext* cx, Value v, double* out) } if (v.isSymbol()) { if (cx->isJSContext()) { - JS_ReportErrorNumber(cx->asJSContext(), js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx->asJSContext(), GetErrorMessage, nullptr, JSMSG_SYMBOL_TO_NUMBER); } return false; diff --git a/js/src/jsnum.h b/js/src/jsnum.h index d0ed462c3d..aefe15f2ab 100644 --- a/js/src/jsnum.h +++ b/js/src/jsnum.h @@ -41,11 +41,11 @@ extern void FinishRuntimeNumberState(JSRuntime* rt); #endif -} /* namespace js */ - /* Initialize the Number class, returning its prototype object. */ extern JSObject* -js_InitNumberClass(JSContext* cx, js::HandleObject obj); +InitNumberClass(JSContext* cx, HandleObject obj); + +} /* namespace js */ /* * String constants for global function names, used in jsapi.c and jsnum.c. @@ -116,7 +116,7 @@ struct ToCStringBuf * Convert a number to a C string. When base==10, this function implements * ToString() as specified by ECMA-262-5 section 9.8.1. It handles integral * values cheaply. Return nullptr if we ran out of memory. See also - * js_NumberToCString(). + * NumberToCString(). */ extern char* NumberToCString(JSContext* cx, ToCStringBuf* cbuf, double d, int base = 10); @@ -202,14 +202,14 @@ extern bool js_strtod(js::ExclusiveContext* cx, const CharT* begin, const CharT* end, const CharT** dEnd, double* d); -extern bool -js_num_toString(JSContext* cx, unsigned argc, js::Value* vp); - -extern bool -js_num_valueOf(JSContext* cx, unsigned argc, js::Value* vp); - namespace js { +extern bool +num_toString(JSContext* cx, unsigned argc, Value* vp); + +extern bool +num_valueOf(JSContext* cx, unsigned argc, Value* vp); + static MOZ_ALWAYS_INLINE bool ValueFitsInInt32(const Value& v, int32_t* pi) { diff --git a/js/src/jsobj.cpp b/js/src/jsobj.cpp index 298ce134fb..5aaccf24ad 100644 --- a/js/src/jsobj.cpp +++ b/js/src/jsobj.cpp @@ -75,7 +75,7 @@ JS_FRIEND_API(JSObject*) JS_ObjectToInnerObject(JSContext* cx, HandleObject obj) { if (!obj) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INACTIVE); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INACTIVE); return nullptr; } return GetInnerObject(obj); @@ -96,7 +96,7 @@ js::NonNullObject(JSContext* cx, const Value& v) char *bytes = DecompileValueGenerator(cx, JSDVG_SEARCH_STACK, value, NullPtr()); if (!bytes) return nullptr; - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_NOT_NONNULL_OBJECT, bytes); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NOT_NONNULL_OBJECT, bytes); return nullptr; } return &v.toObject(); @@ -241,7 +241,7 @@ js::GetFirstArgumentAsObject(JSContext* cx, const CallArgs& args, const char* me MutableHandleObject objp) { if (args.length() == 0) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, method, "0", "s"); return false; } @@ -251,7 +251,7 @@ js::GetFirstArgumentAsObject(JSContext* cx, const CallArgs& args, const char* me char* bytes = DecompileValueGenerator(cx, JSDVG_SEARCH_STACK, v, NullPtr()); if (!bytes) return false; - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE, bytes, "not an object"); js_free(bytes); return false; @@ -287,7 +287,7 @@ PropDesc::initialize(JSContext* cx, const Value& origval, bool checkAccessors) char *bytes = DecompileValueGenerator(cx, JSDVG_SEARCH_STACK, v, NullPtr()); if (!bytes) return false; - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_NOT_NONNULL_OBJECT, bytes); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NOT_NONNULL_OBJECT, bytes); return false; } RootedObject desc(cx, &v.toObject()); @@ -370,7 +370,7 @@ PropDesc::initialize(JSContext* cx, const Value& origval, bool checkAccessors) /* 8.10.7 step 9 */ if ((hasGet() || hasSet()) && (hasValue() || hasWritable())) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INVALID_DESCRIPTOR); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INVALID_DESCRIPTOR); return false; } @@ -425,7 +425,7 @@ js::Throw(JSContext* cx, jsid id, unsigned errorNumber) JSAutoByteString bytes(cx, idstr); if (!bytes) return false; - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, errorNumber, bytes.ptr()); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, errorNumber, bytes.ptr()); return false; } @@ -439,7 +439,7 @@ js::Throw(JSContext* cx, JSObject* obj, unsigned errorNumber) nullptr, nullptr); } else { MOZ_ASSERT(js_ErrorFormatString[errorNumber].argCount == 0); - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, errorNumber); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, errorNumber); } return false; } @@ -824,7 +824,7 @@ DefinePropertyOnArray(JSContext* cx, Handle arr, HandleId id, cons /* Step 3. */ uint32_t index; - if (js_IdIsIndex(id, &index)) { + if (IdIsIndex(id, &index)) { /* Step 3b. */ uint32_t oldLen = arr->length(); @@ -993,7 +993,7 @@ js::SetIntegrityLevel(JSContext* cx, HandleObject obj, IntegrityLevel level) if (!PreventExtensions(cx, obj, &status)) return false; if (!status) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_CANT_CHANGE_EXTENSIBILITY); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CANT_CHANGE_EXTENSIBILITY); return false; } @@ -1776,7 +1776,7 @@ JSObject* js::CloneObject(JSContext* cx, HandleObject obj, Handle proto, HandleObject parent) { if (!obj->isNative() && !obj->is()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CANT_CLONE_OBJECT); return nullptr; } @@ -1788,7 +1788,7 @@ js::CloneObject(JSContext* cx, HandleObject obj, Handle proto, return nullptr; if (clone->is() && (obj->compartment() != clone->compartment())) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CANT_CLONE_OBJECT); return nullptr; } @@ -2433,7 +2433,7 @@ DefineConstructorAndPrototype(JSContext* cx, HandleObject obj, JSProtoKey key, H * passed null for proto; and * * 2. NewObject tolerating no default prototype (null proto slot value) - * due to this js_InitClass call coming from js_InitFunctionClass on an + * due to this js::InitClass call coming from js::InitFunctionClass on an * otherwise-uninitialized global. * * 3. NewObject allocating a JSFunction-sized GC-thing when clasp is @@ -2546,11 +2546,11 @@ bad: } NativeObject* -js_InitClass(JSContext* cx, HandleObject obj, HandleObject protoProto_, - const Class* clasp, Native constructor, unsigned nargs, - const JSPropertySpec* ps, const JSFunctionSpec* fs, - const JSPropertySpec* static_ps, const JSFunctionSpec* static_fs, - NativeObject** ctorp, AllocKind ctorKind) +js::InitClass(JSContext *cx, HandleObject obj, HandleObject protoProto_, + const Class* clasp, Native constructor, unsigned nargs, + const JSPropertySpec *ps, const JSFunctionSpec *fs, + const JSPropertySpec *static_ps, const JSFunctionSpec *static_fs, + NativeObject **ctorp, AllocKind ctorKind) { RootedObject protoProto(cx, protoProto_); @@ -2570,7 +2570,7 @@ js_InitClass(JSContext* cx, HandleObject obj, HandleObject protoProto_, * * When initializing a standard class (other than Object), if protoProto is * null, default to Object.prototype. The engine's internal uses of - * js_InitClass depend on this nicety. + * js::InitClass depend on this nicety. */ JSProtoKey key = JSCLASS_CACHED_PROTO_KEY(clasp); if (key != JSProto_Null && @@ -3080,7 +3080,7 @@ js::SetPrototype(JSContext* cx, HandleObject obj, HandleObject proto, bool* succ * have a mutable [[Prototype]]. */ if (obj->is()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_SETPROTOTYPEOF_FAIL, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_SETPROTOTYPEOF_FAIL, "incompatible ArrayBuffer"); return false; } @@ -3089,7 +3089,7 @@ js::SetPrototype(JSContext* cx, HandleObject obj, HandleObject proto, bool* succ * Disallow mutating the [[Prototype]] on Typed Objects, per the spec. */ if (obj->is()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_SETPROTOTYPEOF_FAIL, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_SETPROTOTYPEOF_FAIL, "incompatible TypedObject"); return false; } @@ -3099,7 +3099,7 @@ js::SetPrototype(JSContext* cx, HandleObject obj, HandleObject proto, bool* succ * for flash-related security reasons. */ if (!strcmp(obj->getClass()->name, "Location")) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_SETPROTOTYPEOF_FAIL, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_SETPROTOTYPEOF_FAIL, "incompatible Location object"); return false; } @@ -3313,7 +3313,7 @@ js::WatchGuts(JSContext* cx, JS::HandleObject origObj, JS::HandleId id, JS::Hand if (!wpmap) { wpmap = cx->runtime()->new_(); if (!wpmap || !wpmap->init()) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return false; } cx->compartment()->watchpointMap = wpmap; @@ -3340,7 +3340,7 @@ js::WatchProperty(JSContext* cx, HandleObject obj, HandleId id, HandleObject cal return op(cx, obj, id, callable); if (!obj->isNative() || IsAnyTypedArray(obj)) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_CANT_WATCH, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CANT_WATCH, obj->getClass()->name); return false; } @@ -3433,7 +3433,7 @@ JS::OrdinaryToPrimitive(JSContext* cx, HandleObject obj, JSType hint, MutableHan /* Optimize (new String(...)).toString(). */ if (clasp == &StringObject::class_) { StringObject* nobj = &obj->as(); - if (ClassMethodIsNative(cx, nobj, &StringObject::class_, id, js_str_toString)) { + if (ClassMethodIsNative(cx, nobj, &StringObject::class_, id, str_toString)) { vp.setString(nobj->unbox()); return true; } @@ -3455,7 +3455,7 @@ JS::OrdinaryToPrimitive(JSContext* cx, HandleObject obj, JSType hint, MutableHan if (clasp == &StringObject::class_) { id = NameToId(cx->names().valueOf); StringObject* nobj = &obj->as(); - if (ClassMethodIsNative(cx, nobj, &StringObject::class_, id, js_str_toString)) { + if (ClassMethodIsNative(cx, nobj, &StringObject::class_, id, str_toString)) { vp.setString(nobj->unbox()); return true; } @@ -3465,7 +3465,7 @@ JS::OrdinaryToPrimitive(JSContext* cx, HandleObject obj, JSType hint, MutableHan if (clasp == &NumberObject::class_) { id = NameToId(cx->names().valueOf); NumberObject* nobj = &obj->as(); - if (ClassMethodIsNative(cx, nobj, &NumberObject::class_, id, js_num_valueOf)) { + if (ClassMethodIsNative(cx, nobj, &NumberObject::class_, id, num_valueOf)) { vp.setNumber(nobj->unbox()); return true; } @@ -3576,9 +3576,9 @@ js::ToObjectSlow(JSContext* cx, JS::HandleValue val, bool reportScanStack) if (val.isNullOrUndefined()) { if (reportScanStack) { - js_ReportIsNullOrUndefined(cx, JSDVG_SEARCH_STACK, val, NullPtr()); + ReportIsNullOrUndefined(cx, JSDVG_SEARCH_STACK, val, NullPtr()); } else { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_CANT_CONVERT_TO, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CANT_CONVERT_TO, val.isNull() ? "null" : "undefined", "object"); } return nullptr; @@ -3588,9 +3588,9 @@ js::ToObjectSlow(JSContext* cx, JS::HandleValue val, bool reportScanStack) } void -js_GetObjectSlotName(JSTracer* trc, char* buf, size_t bufsize) +js::GetObjectSlotName(JSTracer *trc, char *buf, size_t bufsize) { - MOZ_ASSERT(trc->debugPrinter() == js_GetObjectSlotName); + MOZ_ASSERT(trc->debugPrinter() == GetObjectSlotName); JSObject* obj = (JSObject*)trc->debugPrintArg(); uint32_t slot = uint32_t(trc->debugPrintIndex()); @@ -3656,13 +3656,13 @@ js_GetObjectSlotName(JSTracer* trc, char* buf, size_t bufsize) } bool -js_ReportGetterOnlyAssignment(JSContext* cx, bool strict) +js::ReportGetterOnlyAssignment(JSContext* cx, bool strict) { return JS_ReportErrorFlagsAndNumber(cx, strict ? JSREPORT_ERROR : JSREPORT_WARNING | JSREPORT_STRICT, - js_GetErrorMessage, nullptr, + GetErrorMessage, nullptr, JSMSG_GETTER_ONLY); } diff --git a/js/src/jsobj.h b/js/src/jsobj.h index 06b3bf82e9..97d21e85c1 100644 --- a/js/src/jsobj.h +++ b/js/src/jsobj.h @@ -1190,12 +1190,12 @@ LookupNameUnqualified(JSContext* cx, HandlePropertyName name, HandleObject scope } -extern JSObject* -js_FindVariableScope(JSContext* cx, JSFunction** funp); - namespace js { +extern JSObject* +FindVariableScope(JSContext* cx, JSFunction** funp); + bool LookupPropertyPure(ExclusiveContext* cx, JSObject* obj, jsid id, JSObject** objp, Shape** propp); @@ -1245,16 +1245,11 @@ XDRObjectLiteral(XDRState* xdr, MutableHandleNativeObject obj); extern JSObject* CloneObjectLiteral(JSContext* cx, HandleObject parent, HandleObject srcObj); -} /* namespace js */ - extern void -js_GetObjectSlotName(JSTracer* trc, char* buf, size_t bufsize); +GetObjectSlotName(JSTracer* trc, char* buf, size_t bufsize); extern bool -js_ReportGetterOnlyAssignment(JSContext* cx, bool strict); - - -namespace js { +ReportGetterOnlyAssignment(JSContext* cx, bool strict); extern JSObject* NonNullObject(JSContext* cx, const Value& v); diff --git a/js/src/jsobjinlines.h b/js/src/jsobjinlines.h index 14eef2e2eb..9d831e7f12 100644 --- a/js/src/jsobjinlines.h +++ b/js/src/jsobjinlines.h @@ -413,7 +413,7 @@ ToPrimitive(JSContext* cx, MutableHandleValue vp) if (obj->is()) { jsid id = NameToId(cx->names().valueOf); StringObject* nobj = &obj->as(); - if (ClassMethodIsNative(cx, nobj, &StringObject::class_, id, js_str_toString)) { + if (ClassMethodIsNative(cx, nobj, &StringObject::class_, id, str_toString)) { vp.setString(nobj->unbox()); return true; } @@ -423,7 +423,7 @@ ToPrimitive(JSContext* cx, MutableHandleValue vp) if (obj->is()) { jsid id = NameToId(cx->names().valueOf); NumberObject* nobj = &obj->as(); - if (ClassMethodIsNative(cx, nobj, &NumberObject::class_, id, js_num_valueOf)) { + if (ClassMethodIsNative(cx, nobj, &NumberObject::class_, id, num_valueOf)) { vp.setNumber(nobj->unbox()); return true; } @@ -785,14 +785,15 @@ ApplyAttributes(unsigned attrs, bool enumerable, bool writable, bool configurabl return attrs; } -} /* namespace js */ extern js::NativeObject* -js_InitClass(JSContext* cx, js::HandleObject obj, js::HandleObject parent_proto, - const js::Class* clasp, JSNative constructor, unsigned nargs, - const JSPropertySpec* ps, const JSFunctionSpec* fs, - const JSPropertySpec* static_ps, const JSFunctionSpec* static_fs, - js::NativeObject** ctorp = nullptr, - js::gc::AllocKind ctorKind = JSFunction::FinalizeKind); +InitClass(JSContext* cx, js::HandleObject obj, HandleObject parent_proto, + const Class* clasp, JSNative constructor, unsigned nargs, + const JSPropertySpec* ps, const JSFunctionSpec* fs, + const JSPropertySpec* static_ps, const JSFunctionSpec* static_fs, + NativeObject** ctorp = nullptr, + gc::AllocKind ctorKind = JSFunction::FinalizeKind); + +} /* namespace js */ #endif /* jsobjinlines_h */ diff --git a/js/src/json.cpp b/js/src/json.cpp index 8034f5b80c..35fb2df7cf 100644 --- a/js/src/json.cpp +++ b/js/src/json.cpp @@ -309,7 +309,7 @@ JO(JSContext* cx, HandleObject obj, StringifyContext* scx) if (!detect.init()) return false; if (detect.foundCycle()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_JSON_CYCLIC_VALUE, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_JSON_CYCLIC_VALUE, js_object_str); return false; } @@ -400,7 +400,7 @@ JA(JSContext* cx, HandleObject obj, StringifyContext* scx) if (!detect.init()) return false; if (detect.foundCycle()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_JSON_CYCLIC_VALUE, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_JSON_CYCLIC_VALUE, js_object_str); return false; } @@ -517,8 +517,8 @@ Str(JSContext* cx, const Value& v, StringifyContext* scx) /* ES5 15.12.3. */ bool -js_Stringify(JSContext* cx, MutableHandleValue vp, JSObject* replacer_, Value space_, - StringBuffer& sb) +js::Stringify(JSContext* cx, MutableHandleValue vp, JSObject* replacer_, Value space_, + StringBuffer& sb) { RootedObject replacer(cx, replacer_); RootedValue space(cx, space_); @@ -861,7 +861,7 @@ json_stringify(JSContext* cx, unsigned argc, Value* vp) RootedValue space(cx, args.get(2)); StringBuffer sb(cx); - if (!js_Stringify(cx, &value, replacer, space, sb)) + if (!Stringify(cx, &value, replacer, space, sb)) return false; // XXX This can never happen to nsJSON.cpp, but the JSON object @@ -889,7 +889,7 @@ static const JSFunctionSpec json_static_methods[] = { }; JSObject* -js_InitJSONClass(JSContext* cx, HandleObject obj) +js::InitJSONClass(JSContext* cx, HandleObject obj) { Rooted global(cx, &obj->as()); diff --git a/js/src/json.h b/js/src/json.h index 072dfd947a..51fc9c5b69 100644 --- a/js/src/json.h +++ b/js/src/json.h @@ -15,16 +15,13 @@ namespace js { class StringBuffer; -} extern JSObject* -js_InitJSONClass(JSContext* cx, js::HandleObject obj); +InitJSONClass(JSContext* cx, HandleObject obj); extern bool -js_Stringify(JSContext* cx, js::MutableHandleValue vp, JSObject* replacer, - js::Value space, js::StringBuffer& sb); - -namespace js { +Stringify(JSContext* cx, js::MutableHandleValue vp, JSObject* replacer, + Value space, StringBuffer& sb); template extern bool diff --git a/js/src/jsopcode.cpp b/js/src/jsopcode.cpp index cfa47bda6f..a275922188 100644 --- a/js/src/jsopcode.cpp +++ b/js/src/jsopcode.cpp @@ -73,7 +73,7 @@ static const char * const CodeToken[] = { }; /* - * Array of JS bytecode names used by PC count JSON, DEBUG-only js_Disassemble + * Array of JS bytecode names used by PC count JSON, DEBUG-only Disassemble * and JIT debug spew. */ const char * const js_CodeName[] = { @@ -87,7 +87,7 @@ const char * const js_CodeName[] = { #define COUNTS_LEN 16 size_t -js_GetVariableBytecodeLength(jsbytecode* pc) +js::GetVariableBytecodeLength(jsbytecode* pc) { JSOp op = JSOp(*pc); MOZ_ASSERT(js_CodeSpec[op].length == -1); @@ -235,7 +235,7 @@ js::DumpIonScriptCounts(Sprinter* sp, jit::IonScriptCounts* ionCounts) } void -js_DumpPCCounts(JSContext* cx, HandleScript script, js::Sprinter* sp) +js::DumpPCCounts(JSContext* cx, HandleScript script, Sprinter* sp) { MOZ_ASSERT(script->hasScriptCounts()); @@ -245,7 +245,7 @@ js_DumpPCCounts(JSContext* cx, HandleScript script, js::Sprinter* sp) JSOp op = JSOp(*pc); jsbytecode* next = GetNextPc(pc); - if (!js_Disassemble1(cx, script, pc, script->pcToOffset(pc), true, sp)) + if (!Disassemble1(cx, script, pc, script->pcToOffset(pc), true, sp)) return; size_t total = PCCounts::numCounts(op); @@ -290,7 +290,7 @@ js::DumpCompartmentPCCounts(JSContext* cx) return; fprintf(stdout, "--- SCRIPT %s:%d ---\n", script->filename(), (int) script->lineno()); - js_DumpPCCounts(cx, script, &sprinter); + DumpPCCounts(cx, script, &sprinter); fputs(sprinter.string(), stdout); fprintf(stdout, "--- END SCRIPT %s:%d ---\n", script->filename(), (int) script->lineno()); } @@ -425,7 +425,7 @@ class BytecodeParser void reportOOM() { allocScope_.releaseEarly(); - js_ReportOutOfMemory(cx_); + ReportOutOfMemory(cx_); } uint32_t numSlots() { @@ -717,9 +717,9 @@ js::ReconstructStackDepth(JSContext* cx, JSScript* script, jsbytecode* pc, uint3 * current line. If showAll is true, include the source note type and the * entry stack depth. */ -JS_FRIEND_API(bool) -js_DisassembleAtPC(JSContext* cx, JSScript* scriptArg, bool lines, - jsbytecode* pc, bool showAll, Sprinter* sp) +static bool +DisassembleAtPC(JSContext* cx, JSScript* scriptArg, bool lines, + jsbytecode* pc, bool showAll, Sprinter* sp) { RootedScript script(cx, scriptArg); BytecodeParser parser(cx, script); @@ -763,7 +763,7 @@ js_DisassembleAtPC(JSContext* cx, JSScript* scriptArg, bool lines, sp->put(" "); } if (showAll) { - jssrcnote* sn = js_GetSrcNote(cx, script, next); + jssrcnote* sn = GetSrcNote(cx, script, next); if (sn) { MOZ_ASSERT(!SN_IS_TERMINATOR(sn)); jssrcnote* next = SN_NEXT(sn); @@ -781,7 +781,7 @@ js_DisassembleAtPC(JSContext* cx, JSScript* scriptArg, bool lines, else Sprint(sp, " "); } - len = js_Disassemble1(cx, script, next, script->pcToOffset(next), lines, sp); + len = Disassemble1(cx, script, next, script->pcToOffset(next), lines, sp); if (!len) return false; next += len; @@ -790,56 +790,9 @@ js_DisassembleAtPC(JSContext* cx, JSScript* scriptArg, bool lines, } bool -js_Disassemble(JSContext* cx, HandleScript script, bool lines, Sprinter* sp) +js::Disassemble(JSContext* cx, HandleScript script, bool lines, Sprinter* sp) { - return js_DisassembleAtPC(cx, script, lines, nullptr, false, sp); -} - -JS_FRIEND_API(bool) -js_DumpPC(JSContext* cx) -{ - js::gc::AutoSuppressGC suppressGC(cx); - Sprinter sprinter(cx); - if (!sprinter.init()) - return false; - ScriptFrameIter iter(cx); - if (iter.done()) { - fprintf(stdout, "Empty stack.\n"); - return true; - } - RootedScript script(cx, iter.script()); - bool ok = js_DisassembleAtPC(cx, script, true, iter.pc(), false, &sprinter); - fprintf(stdout, "%s", sprinter.string()); - return ok; -} - -JS_FRIEND_API(bool) -js_DumpScript(JSContext* cx, JSScript* scriptArg) -{ - js::gc::AutoSuppressGC suppressGC(cx); - Sprinter sprinter(cx); - if (!sprinter.init()) - return false; - RootedScript script(cx, scriptArg); - bool ok = js_Disassemble(cx, script, true, &sprinter); - fprintf(stdout, "%s", sprinter.string()); - return ok; -} - -/* - * Useful to debug ReconstructPCStack. - */ -JS_FRIEND_API(bool) -js_DumpScriptDepth(JSContext* cx, JSScript* scriptArg, jsbytecode* pc) -{ - js::gc::AutoSuppressGC suppressGC(cx); - Sprinter sprinter(cx); - if (!sprinter.init()) - return false; - RootedScript script(cx, scriptArg); - bool ok = js_DisassembleAtPC(cx, script, true, pc, true, &sprinter); - fprintf(stdout, "%s", sprinter.string()); - return ok; + return DisassembleAtPC(cx, script, lines, nullptr, false, sp); } static char* @@ -923,19 +876,19 @@ ToDisassemblySource(JSContext* cx, HandleValue v, JSAutoByteString* bytes) } } - return !!js_ValueToPrintable(cx, v, bytes, true); + return !!ValueToPrintable(cx, v, bytes, true); } unsigned -js_Disassemble1(JSContext* cx, HandleScript script, jsbytecode* pc, - unsigned loc, bool lines, Sprinter* sp) +js::Disassemble1(JSContext* cx, HandleScript script, jsbytecode* pc, + unsigned loc, bool lines, Sprinter* sp) { JSOp op = (JSOp)*pc; if (op >= JSOP_LIMIT) { char numBuf1[12], numBuf2[12]; JS_snprintf(numBuf1, sizeof numBuf1, "%d", op); JS_snprintf(numBuf2, sizeof numBuf2, "%d", JSOP_LIMIT); - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_BYTECODE_TOO_BIG, numBuf1, numBuf2); return 0; } @@ -1089,7 +1042,7 @@ js_Disassemble1(JSContext* cx, HandleScript script, jsbytecode* pc, default: { char numBuf[12]; JS_snprintf(numBuf, sizeof numBuf, "%lx", (unsigned long) cs->format); - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_UNKNOWN_FORMAT, numBuf); return 0; } @@ -1295,7 +1248,7 @@ Sprinter::reportOutOfMemory() if (reportedOOM) return; if (context) - js_ReportOutOfMemory(context); + ReportOutOfMemory(context); reportedOOM = true; } @@ -1417,7 +1370,7 @@ QuoteString(Sprinter* sp, JSString* str, char16_t quote) } JSString* -js_QuoteString(ExclusiveContext* cx, JSString* str, char16_t quote) +js::QuoteString(ExclusiveContext* cx, JSString* str, char16_t quote) { Sprinter sprinter(cx); if (!sprinter.init()) @@ -1509,7 +1462,7 @@ ExpressionDecompiler::decompilePC(jsbytecode* pc) // Handle simple cases of binary and unary operators. switch (js_CodeSpec[op].nuses) { case 2: { - jssrcnote* sn = js_GetSrcNote(cx, script, pc); + jssrcnote* sn = GetSrcNote(cx, script, pc); if (!sn || SN_TYPE(sn) != SRC_ASSIGNOP) return write("(") && decompilePCForStackOperand(pc, -2) && @@ -2145,7 +2098,7 @@ js::GetPCCountScriptSummary(JSContext* cx, size_t index) JSRuntime* rt = cx->runtime(); if (!rt->scriptAndCountsVector || index >= rt->scriptAndCountsVector->length()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_BUFFER_TOO_SMALL); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_BUFFER_TOO_SMALL); return nullptr; } @@ -2398,7 +2351,7 @@ js::GetPCCountScriptContents(JSContext* cx, size_t index) JSRuntime* rt = cx->runtime(); if (!rt->scriptAndCountsVector || index >= rt->scriptAndCountsVector->length()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_BUFFER_TOO_SMALL); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_BUFFER_TOO_SMALL); return nullptr; } diff --git a/js/src/jsopcode.h b/js/src/jsopcode.h index 02bca71e43..85b314a6f4 100644 --- a/js/src/jsopcode.h +++ b/js/src/jsopcode.h @@ -392,15 +392,15 @@ JOF_OPTYPE(JSOp op) #pragma warning(disable:4100) #endif +namespace js { + /* * Return a GC'ed string containing the chars in str, with any non-printing * chars or quotes (' or " as specified by the quote argument) escaped, and * with the quote character at the beginning and end of the result string. */ extern JSString* -js_QuoteString(js::ExclusiveContext* cx, JSString* str, char16_t quote); - -namespace js { +QuoteString(ExclusiveContext* cx, JSString* str, char16_t quote); static inline bool IsJumpOpcode(JSOp op) @@ -535,13 +535,13 @@ ReconstructStackDepth(JSContext* cx, JSScript* script, jsbytecode* pc, uint32_t* #define JSDVG_IGNORE_STACK 0 #define JSDVG_SEARCH_STACK 1 +namespace js { + /* * Get the length of variable-length bytecode like JSOP_TABLESWITCH. */ extern size_t -js_GetVariableBytecodeLength(jsbytecode* pc); - -namespace js { +GetVariableBytecodeLength(jsbytecode* pc); /* * Find the source expression that resulted in v, and return a newly allocated @@ -676,7 +676,7 @@ GetBytecodeLength(jsbytecode* pc) if (js_CodeSpec[op].length != -1) return js_CodeSpec[op].length; - return js_GetVariableBytecodeLength(pc); + return GetVariableBytecodeLength(pc); } static inline bool @@ -985,25 +985,22 @@ GetNextPc(jsbytecode* pc) return pc + GetBytecodeLength(pc); } -} /* namespace js */ - #if defined(DEBUG) /* * Disassemblers, for debugging only. */ bool -js_Disassemble(JSContext* cx, JS::Handle script, bool lines, js::Sprinter* sp); +Disassemble(JSContext* cx, JS::Handle script, bool lines, Sprinter* sp); unsigned -js_Disassemble1(JSContext* cx, JS::Handle script, jsbytecode* pc, unsigned loc, - bool lines, js::Sprinter* sp); +Disassemble1(JSContext* cx, JS::Handle script, jsbytecode* pc, unsigned loc, + bool lines, Sprinter* sp); #endif void -js_DumpPCCounts(JSContext* cx, JS::Handle script, js::Sprinter* sp); +DumpPCCounts(JSContext* cx, JS::Handle script, Sprinter* sp); -namespace js { namespace jit { struct IonScriptCounts; } void DumpIonScriptCounts(js::Sprinter* sp, jit::IonScriptCounts* ionCounts); diff --git a/js/src/jspropertytree.cpp b/js/src/jspropertytree.cpp index 0b5c86af51..60999b5418 100644 --- a/js/src/jspropertytree.cpp +++ b/js/src/jspropertytree.cpp @@ -73,7 +73,7 @@ PropertyTree::insertChild(ExclusiveContext* cx, Shape* parent, Shape* child) KidsHash* hash = HashChildren(shape, child); if (!hash) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return false; } kidp->setHash(hash); @@ -82,7 +82,7 @@ PropertyTree::insertChild(ExclusiveContext* cx, Shape* parent, Shape* child) } if (!kidp->toHash()->putNew(StackShape(child), child)) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return false; } diff --git a/js/src/jsprototypes.h b/js/src/jsprototypes.h index 1f9fd97e3a..d0a5a24ff3 100644 --- a/js/src/jsprototypes.h +++ b/js/src/jsprototypes.h @@ -57,60 +57,60 @@ #endif #define JS_FOR_PROTOTYPES(real,imaginary) \ - imaginary(Null, 0, js_InitNullClass, dummy) \ - real(Object, 1, js_InitViaClassSpec, OCLASP(Plain)) \ - real(Function, 2, js_InitViaClassSpec, &JSFunction::class_) \ - real(Array, 3, js_InitViaClassSpec, OCLASP(Array)) \ - real(Boolean, 4, js_InitBooleanClass, OCLASP(Boolean)) \ - real(JSON, 5, js_InitJSONClass, CLASP(JSON)) \ - real(Date, 6, js_InitViaClassSpec, OCLASP(Date)) \ - real(Math, 7, js_InitMathClass, CLASP(Math)) \ - real(Number, 8, js_InitNumberClass, OCLASP(Number)) \ - real(String, 9, js_InitStringClass, OCLASP(String)) \ - real(RegExp, 10, js_InitRegExpClass, OCLASP(RegExp)) \ - real(Error, 11, js_InitViaClassSpec, ERROR_CLASP(JSEXN_ERR)) \ - real(InternalError, 12, js_InitViaClassSpec, ERROR_CLASP(JSEXN_INTERNALERR)) \ - real(EvalError, 13, js_InitViaClassSpec, ERROR_CLASP(JSEXN_EVALERR)) \ - real(RangeError, 14, js_InitViaClassSpec, ERROR_CLASP(JSEXN_RANGEERR)) \ - real(ReferenceError, 15, js_InitViaClassSpec, ERROR_CLASP(JSEXN_REFERENCEERR)) \ - real(SyntaxError, 16, js_InitViaClassSpec, ERROR_CLASP(JSEXN_SYNTAXERR)) \ - real(TypeError, 17, js_InitViaClassSpec, ERROR_CLASP(JSEXN_TYPEERR)) \ - real(URIError, 18, js_InitViaClassSpec, ERROR_CLASP(JSEXN_URIERR)) \ - real(Iterator, 19, js_InitLegacyIteratorClass,OCLASP(PropertyIterator)) \ - real(StopIteration, 20, js_InitStopIterationClass, OCLASP(StopIteration)) \ - real(ArrayBuffer, 21, js_InitArrayBufferClass, &js::ArrayBufferObject::protoClass) \ - real(Int8Array, 22, js_InitViaClassSpec, TYPED_ARRAY_CLASP(Int8)) \ - real(Uint8Array, 23, js_InitViaClassSpec, TYPED_ARRAY_CLASP(Uint8)) \ - real(Int16Array, 24, js_InitViaClassSpec, TYPED_ARRAY_CLASP(Int16)) \ - real(Uint16Array, 25, js_InitViaClassSpec, TYPED_ARRAY_CLASP(Uint16)) \ - real(Int32Array, 26, js_InitViaClassSpec, TYPED_ARRAY_CLASP(Int32)) \ - real(Uint32Array, 27, js_InitViaClassSpec, TYPED_ARRAY_CLASP(Uint32)) \ - real(Float32Array, 28, js_InitViaClassSpec, TYPED_ARRAY_CLASP(Float32)) \ - real(Float64Array, 29, js_InitViaClassSpec, TYPED_ARRAY_CLASP(Float64)) \ - real(Uint8ClampedArray, 30, js_InitViaClassSpec, TYPED_ARRAY_CLASP(Uint8Clamped)) \ - real(Proxy, 31, js_InitProxyClass, OCLASP(Proxy)) \ - real(WeakMap, 32, js_InitWeakMapClass, OCLASP(WeakMap)) \ - real(Map, 33, js_InitMapClass, OCLASP(Map)) \ - real(Set, 34, js_InitSetClass, OCLASP(Set)) \ - real(DataView, 35, js_InitDataViewClass, OCLASP(DataView)) \ - real(Symbol, 36, js_InitSymbolClass, OCLASP(Symbol)) \ -IF_SAB(real,imaginary)(SharedArrayBuffer, 37, js_InitSharedArrayBufferClass, &js::SharedArrayBufferObject::protoClass) \ -IF_INTL(real,imaginary) (Intl, 38, js_InitIntlClass, CLASP(Intl)) \ -IF_BDATA(real,imaginary)(TypedObject, 39, js_InitTypedObjectModuleObject, OCLASP(TypedObjectModule)) \ - real(SavedFrame, 40, js_InitViaClassSpec, &js::SavedFrame::class_) \ -IF_BDATA(real,imaginary)(SIMD, 41, js_InitSIMDClass, OCLASP(SIMD)) \ - real(WeakSet, 42, js_InitWeakSetClass, OCLASP(WeakSet)) \ -IF_SAB(real,imaginary)(SharedInt8Array, 43, js_InitViaClassSpec, SHARED_TYPED_ARRAY_CLASP(Int8)) \ -IF_SAB(real,imaginary)(SharedUint8Array, 44, js_InitViaClassSpec, SHARED_TYPED_ARRAY_CLASP(Uint8)) \ -IF_SAB(real,imaginary)(SharedInt16Array, 45, js_InitViaClassSpec, SHARED_TYPED_ARRAY_CLASP(Int16)) \ -IF_SAB(real,imaginary)(SharedUint16Array, 46, js_InitViaClassSpec, SHARED_TYPED_ARRAY_CLASP(Uint16)) \ -IF_SAB(real,imaginary)(SharedInt32Array, 47, js_InitViaClassSpec, SHARED_TYPED_ARRAY_CLASP(Int32)) \ -IF_SAB(real,imaginary)(SharedUint32Array, 48, js_InitViaClassSpec, SHARED_TYPED_ARRAY_CLASP(Uint32)) \ -IF_SAB(real,imaginary)(SharedFloat32Array, 49, js_InitViaClassSpec, SHARED_TYPED_ARRAY_CLASP(Float32)) \ -IF_SAB(real,imaginary)(SharedFloat64Array, 50, js_InitViaClassSpec, SHARED_TYPED_ARRAY_CLASP(Float64)) \ -IF_SAB(real,imaginary)(SharedUint8ClampedArray, 51, js_InitViaClassSpec, SHARED_TYPED_ARRAY_CLASP(Uint8Clamped)) \ - real(TypedArray, 52, js_InitViaClassSpec, &js::TypedArrayObject::sharedTypedArrayPrototypeClass) \ -IF_SAB(real,imaginary)(Atomics, 53, js_InitAtomicsClass, OCLASP(Atomics)) \ + imaginary(Null, 0, InitNullClass, dummy) \ + real(Object, 1, InitViaClassSpec, OCLASP(Plain)) \ + real(Function, 2, InitViaClassSpec, &JSFunction::class_) \ + real(Array, 3, InitViaClassSpec, OCLASP(Array)) \ + real(Boolean, 4, InitBooleanClass, OCLASP(Boolean)) \ + real(JSON, 5, InitJSONClass, CLASP(JSON)) \ + real(Date, 6, InitViaClassSpec, OCLASP(Date)) \ + real(Math, 7, InitMathClass, CLASP(Math)) \ + real(Number, 8, InitNumberClass, OCLASP(Number)) \ + real(String, 9, InitStringClass, OCLASP(String)) \ + real(RegExp, 10, InitRegExpClass, OCLASP(RegExp)) \ + real(Error, 11, InitViaClassSpec, ERROR_CLASP(JSEXN_ERR)) \ + real(InternalError, 12, InitViaClassSpec, ERROR_CLASP(JSEXN_INTERNALERR)) \ + real(EvalError, 13, InitViaClassSpec, ERROR_CLASP(JSEXN_EVALERR)) \ + real(RangeError, 14, InitViaClassSpec, ERROR_CLASP(JSEXN_RANGEERR)) \ + real(ReferenceError, 15, InitViaClassSpec, ERROR_CLASP(JSEXN_REFERENCEERR)) \ + real(SyntaxError, 16, InitViaClassSpec, ERROR_CLASP(JSEXN_SYNTAXERR)) \ + real(TypeError, 17, InitViaClassSpec, ERROR_CLASP(JSEXN_TYPEERR)) \ + real(URIError, 18, InitViaClassSpec, ERROR_CLASP(JSEXN_URIERR)) \ + real(Iterator, 19, InitLegacyIteratorClass,OCLASP(PropertyIterator)) \ + real(StopIteration, 20, InitStopIterationClass, OCLASP(StopIteration)) \ + real(ArrayBuffer, 21, InitArrayBufferClass, &js::ArrayBufferObject::protoClass) \ + real(Int8Array, 22, InitViaClassSpec, TYPED_ARRAY_CLASP(Int8)) \ + real(Uint8Array, 23, InitViaClassSpec, TYPED_ARRAY_CLASP(Uint8)) \ + real(Int16Array, 24, InitViaClassSpec, TYPED_ARRAY_CLASP(Int16)) \ + real(Uint16Array, 25, InitViaClassSpec, TYPED_ARRAY_CLASP(Uint16)) \ + real(Int32Array, 26, InitViaClassSpec, TYPED_ARRAY_CLASP(Int32)) \ + real(Uint32Array, 27, InitViaClassSpec, TYPED_ARRAY_CLASP(Uint32)) \ + real(Float32Array, 28, InitViaClassSpec, TYPED_ARRAY_CLASP(Float32)) \ + real(Float64Array, 29, InitViaClassSpec, TYPED_ARRAY_CLASP(Float64)) \ + real(Uint8ClampedArray, 30, InitViaClassSpec, TYPED_ARRAY_CLASP(Uint8Clamped)) \ + real(Proxy, 31, InitProxyClass, OCLASP(Proxy)) \ + real(WeakMap, 32, InitWeakMapClass, OCLASP(WeakMap)) \ + real(Map, 33, InitMapClass, OCLASP(Map)) \ + real(Set, 34, InitSetClass, OCLASP(Set)) \ + real(DataView, 35, InitDataViewClass, OCLASP(DataView)) \ + real(Symbol, 36, InitSymbolClass, OCLASP(Symbol)) \ +IF_SAB(real,imaginary)(SharedArrayBuffer, 37, InitSharedArrayBufferClass, &js::SharedArrayBufferObject::protoClass) \ +IF_INTL(real,imaginary) (Intl, 38, InitIntlClass, CLASP(Intl)) \ +IF_BDATA(real,imaginary)(TypedObject, 39, InitTypedObjectModuleObject, OCLASP(TypedObjectModule)) \ + real(SavedFrame, 40, InitViaClassSpec, &js::SavedFrame::class_) \ +IF_BDATA(real,imaginary)(SIMD, 41, InitSIMDClass, OCLASP(SIMD)) \ + real(WeakSet, 42, InitWeakSetClass, OCLASP(WeakSet)) \ +IF_SAB(real,imaginary)(SharedInt8Array, 43, InitViaClassSpec, SHARED_TYPED_ARRAY_CLASP(Int8)) \ +IF_SAB(real,imaginary)(SharedUint8Array, 44, InitViaClassSpec, SHARED_TYPED_ARRAY_CLASP(Uint8)) \ +IF_SAB(real,imaginary)(SharedInt16Array, 45, InitViaClassSpec, SHARED_TYPED_ARRAY_CLASP(Int16)) \ +IF_SAB(real,imaginary)(SharedUint16Array, 46, InitViaClassSpec, SHARED_TYPED_ARRAY_CLASP(Uint16)) \ +IF_SAB(real,imaginary)(SharedInt32Array, 47, InitViaClassSpec, SHARED_TYPED_ARRAY_CLASP(Int32)) \ +IF_SAB(real,imaginary)(SharedUint32Array, 48, InitViaClassSpec, SHARED_TYPED_ARRAY_CLASP(Uint32)) \ +IF_SAB(real,imaginary)(SharedFloat32Array, 49, InitViaClassSpec, SHARED_TYPED_ARRAY_CLASP(Float32)) \ +IF_SAB(real,imaginary)(SharedFloat64Array, 50, InitViaClassSpec, SHARED_TYPED_ARRAY_CLASP(Float64)) \ +IF_SAB(real,imaginary)(SharedUint8ClampedArray, 51, InitViaClassSpec, SHARED_TYPED_ARRAY_CLASP(Uint8Clamped)) \ + real(TypedArray, 52, InitViaClassSpec, &js::TypedArrayObject::sharedTypedArrayPrototypeClass) \ +IF_SAB(real,imaginary)(Atomics, 53, InitAtomicsClass, OCLASP(Atomics)) \ diff --git a/js/src/jspubtd.h b/js/src/jspubtd.h index 59909a194c..2a61f31f86 100644 --- a/js/src/jspubtd.h +++ b/js/src/jspubtd.h @@ -119,9 +119,10 @@ typedef JSConstScalarSpec JSConstIntegerSpec; typedef void (* JSTraceDataOp)(JSTracer* trc, void* data); -void js_FinishGC(JSRuntime* rt); - namespace js { + +void FinishGC(JSRuntime* rt); + namespace gc { class StoreBuffer; void MarkPersistentRootedChains(JSTracer*); diff --git a/js/src/jsreflect.cpp b/js/src/jsreflect.cpp index f81f60fc96..be04db1ef1 100644 --- a/js/src/jsreflect.cpp +++ b/js/src/jsreflect.cpp @@ -113,7 +113,7 @@ typedef AutoValueVector NodeVector; JS_BEGIN_MACRO \ MOZ_ASSERT(expr); \ if (!(expr)) { \ - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_BAD_PARSE_NODE); \ + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_BAD_PARSE_NODE); \ return false; \ } \ JS_END_MACRO @@ -121,7 +121,7 @@ typedef AutoValueVector NodeVector; #define LOCAL_NOT_REACHED(expr) \ JS_BEGIN_MACRO \ MOZ_ASSERT(false); \ - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_BAD_PARSE_NODE); \ + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_BAD_PARSE_NODE); \ return false; \ JS_END_MACRO @@ -726,7 +726,7 @@ NodeBuilder::newArray(NodeVector& elts, MutableHandleValue dst) { const size_t len = elts.length(); if (len > UINT32_MAX) { - js_ReportAllocationOverflow(cx); + ReportAllocationOverflow(cx); return false; } RootedObject array(cx, NewDenseFullyAllocatedArray(cx, uint32_t(len))); @@ -3586,7 +3586,7 @@ reflect_parse(JSContext* cx, uint32_t argc, jsval* vp) CallArgs args = CallArgsFromVp(argc, vp); if (args.length() < 1) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, "Reflect.parse", "0", "s"); return false; } diff --git a/js/src/jsscript.cpp b/js/src/jsscript.cpp index 1d163ebdd6..f56ac9f30f 100644 --- a/js/src/jsscript.cpp +++ b/js/src/jsscript.cpp @@ -2067,7 +2067,7 @@ ScriptSource::setDisplayURL(ExclusiveContext* cx, const char16_t* displayURL) if (hasDisplayURL()) { if (cx->isJSContext() && !JS_ReportErrorFlagsAndNumber(cx->asJSContext(), JSREPORT_WARNING, - js_GetErrorMessage, nullptr, + GetErrorMessage, nullptr, JSMSG_ALREADY_HAS_PRAGMA, filename_.get(), "//# sourceURL")) { @@ -2172,7 +2172,7 @@ SaveSharedScriptData(ExclusiveContext* cx, Handle script, SharedScrip script->setCode(nullptr); script->atoms = nullptr; js_free(ssd); - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return false; } } @@ -2383,7 +2383,7 @@ JSScript::Create(ExclusiveContext* cx, HandleObject enclosingScope, bool savedCa { MOZ_ASSERT(bufStart <= bufEnd); - RootedScript script(cx, js_NewGCScript(cx)); + RootedScript script(cx, NewGCScript(cx)); if (!script) return nullptr; @@ -2408,7 +2408,7 @@ JSScript::Create(ExclusiveContext* cx, HandleObject enclosingScope, bool savedCa if (staticLevel > UINT16_MAX) { if (cx->isJSContext()) { JS_ReportErrorNumber(cx->asJSContext(), - js_GetErrorMessage, nullptr, JSMSG_TOO_DEEP, js_function_str); + GetErrorMessage, nullptr, JSMSG_TOO_DEEP, js_function_str); } return nullptr; } @@ -2782,7 +2782,7 @@ js::GetSrcNote(GSNCache& cache, JSScript* script, jsbytecode* pc) } jssrcnote* -js_GetSrcNote(JSContext* cx, JSScript* script, jsbytecode* pc) +js::GetSrcNote(JSContext* cx, JSScript* script, jsbytecode* pc) { return GetSrcNote(cx->runtime()->gsnCache, script, pc); } @@ -2841,7 +2841,7 @@ js::PCToLineNumber(JSScript* script, jsbytecode* pc, unsigned* columnp) } jsbytecode* -js_LineNumberToPC(JSScript* script, unsigned target) +js::LineNumberToPC(JSScript* script, unsigned target) { ptrdiff_t offset = 0; ptrdiff_t best = -1; @@ -2876,7 +2876,7 @@ out: } JS_FRIEND_API(unsigned) -js_GetScriptLineExtent(JSScript* script) +js::GetScriptLineExtent(JSScript* script) { unsigned lineno = script->lineno(); unsigned maxLineNo = lineno; @@ -3325,7 +3325,7 @@ JSScript::getOrCreateBreakpointSite(JSContext* cx, jsbytecode* pc) if (!site) { site = cx->runtime()->new_(this, pc); if (!site) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return nullptr; } debug->numSites++; @@ -3761,7 +3761,7 @@ LazyScript::CreateRaw(ExclusiveContext* cx, HandleFunction fun, if (bytes && !table) return nullptr; - LazyScript* res = js_NewGCLazyScript(cx); + LazyScript* res = NewGCLazyScript(cx); if (!res) return nullptr; diff --git a/js/src/jsscript.h b/js/src/jsscript.h index c182d48ab6..a1155dc422 100644 --- a/js/src/jsscript.h +++ b/js/src/jsscript.h @@ -747,7 +747,7 @@ GeneratorKindFromBits(unsigned val) { /* * NB: after a successful XDR_DECODE, XDRScript callers must do any required * subsequent set-up of owning function or script object and then call - * js_CallNewScriptHook. + * CallNewScriptHook. */ template bool @@ -2127,16 +2127,16 @@ struct GSNCache; jssrcnote* GetSrcNote(GSNCache& cache, JSScript* script, jsbytecode* pc); -} /* namespace js */ - extern jssrcnote* -js_GetSrcNote(JSContext* cx, JSScript* script, jsbytecode* pc); +GetSrcNote(JSContext* cx, JSScript* script, jsbytecode* pc); extern jsbytecode* -js_LineNumberToPC(JSScript* script, unsigned lineno); +LineNumberToPC(JSScript* script, unsigned lineno); extern JS_FRIEND_API(unsigned) -js_GetScriptLineExtent(JSScript* script); +GetScriptLineExtent(JSScript* script); + +} /* namespace js */ namespace js { diff --git a/js/src/jsstr.cpp b/js/src/jsstr.cpp index d80f405310..5c6ba90a5e 100644 --- a/js/src/jsstr.cpp +++ b/js/src/jsstr.cpp @@ -446,14 +446,14 @@ ThisToStringForStringProto(JSContext* cx, CallReceiver call) if (obj->is()) { StringObject* nobj = &obj->as(); Rooted id(cx, NameToId(cx->names().toString)); - if (ClassMethodIsNative(cx, nobj, &StringObject::class_, id, js_str_toString)) { + if (ClassMethodIsNative(cx, nobj, &StringObject::class_, id, str_toString)) { JSString* str = nobj->unbox(); call.setThis(StringValue(str)); return str; } } } else if (call.thisv().isNullOrUndefined()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_CANT_CONVERT_TO, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CANT_CONVERT_TO, call.thisv().isNull() ? "null" : "undefined", "object"); return nullptr; } @@ -483,7 +483,7 @@ str_toSource_impl(JSContext* cx, const CallArgs& args) if (!str) return false; - str = js_QuoteString(cx, str, '"'); + str = QuoteString(cx, str, '"'); if (!str) return false; @@ -519,7 +519,7 @@ str_toString_impl(JSContext* cx, const CallArgs& args) } bool -js_str_toString(JSContext* cx, unsigned argc, Value* vp) +js::str_toString(JSContext* cx, unsigned argc, Value* vp) { CallArgs args = CallArgsFromVp(argc, vp); return CallNonGenericMethod(cx, args); @@ -901,7 +901,7 @@ str_normalize(JSContext* cx, unsigned argc, Value* vp) } else if (formStr == cx->names().NFKD) { form = UNORM_NFKD; } else { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INVALID_NORMALIZE_FORM); return false; } @@ -950,7 +950,7 @@ str_normalize(JSContext* cx, unsigned argc, Value* vp) #endif bool -js_str_charAt(JSContext* cx, unsigned argc, Value* vp) +js::str_charAt(JSContext* cx, unsigned argc, Value* vp) { CallArgs args = CallArgsFromVp(argc, vp); @@ -1016,7 +1016,7 @@ out_of_range: } bool -js_str_charCodeAt(JSContext* cx, unsigned argc, Value* vp) +js::str_charCodeAt(JSContext* cx, unsigned argc, Value* vp) { CallArgs args = CallArgsFromVp(argc, vp); RootedString str(cx); @@ -1740,7 +1740,7 @@ js::str_startsWith(JSContext* cx, unsigned argc, Value* vp) // Step 4 if (args.get(0).isObject() && IsObjectWithClass(args[0], ESClass_RegExp, cx)) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INVALID_ARG_TYPE, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INVALID_ARG_TYPE, "first", "", "Regular Expression"); return false; } @@ -1801,7 +1801,7 @@ str_endsWith(JSContext* cx, unsigned argc, Value* vp) // Step 4 if (args.get(0).isObject() && IsObjectWithClass(args[0], ESClass_RegExp, cx)) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INVALID_ARG_TYPE, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INVALID_ARG_TYPE, "first", "", "Regular Expression"); return false; } @@ -2659,7 +2659,7 @@ FindReplaceLengthString(JSContext* cx, RegExpStatics* res, ReplaceData& rdata, s } if (!replen.isValid()) { - js_ReportAllocationOverflow(cx); + ReportAllocationOverflow(cx); return false; } @@ -2822,7 +2822,7 @@ ReplaceRegExp(JSContext* cx, RegExpStatics* res, ReplaceData& rdata) newlen += leftlen; newlen += replen; if (!newlen.isValid()) { - js_ReportAllocationOverflow(cx); + ReportAllocationOverflow(cx); return false; } @@ -3943,12 +3943,12 @@ static const JSFunctionSpec string_methods[] = { #endif /* Java-like methods. */ - JS_FN(js_toString_str, js_str_toString, 0,0), - JS_FN(js_valueOf_str, js_str_toString, 0,0), + JS_FN(js_toString_str, str_toString, 0,0), + JS_FN(js_valueOf_str, str_toString, 0,0), JS_FN("toLowerCase", str_toLowerCase, 0,JSFUN_GENERIC_NATIVE), JS_FN("toUpperCase", str_toUpperCase, 0,JSFUN_GENERIC_NATIVE), - JS_FN("charAt", js_str_charAt, 1,JSFUN_GENERIC_NATIVE), - JS_FN("charCodeAt", js_str_charCodeAt, 1,JSFUN_GENERIC_NATIVE), + JS_FN("charAt", str_charAt, 1,JSFUN_GENERIC_NATIVE), + JS_FN("charCodeAt", str_charCodeAt, 1,JSFUN_GENERIC_NATIVE), JS_SELF_HOSTED_FN("substring", "String_substring", 2,0), JS_SELF_HOSTED_FN("codePointAt", "String_codePointAt", 1,0), JS_FN("includes", str_includes, 1,JSFUN_GENERIC_NATIVE), @@ -4004,7 +4004,7 @@ static const JSFunctionSpec string_methods[] = { // ES6 rev 27 (2014 Aug 24) 21.1.1 bool -js_String(JSContext* cx, unsigned argc, Value* vp) +js::StringConstructor(JSContext* cx, unsigned argc, Value* vp) { CallArgs args = CallArgsFromVp(argc, vp); @@ -4112,7 +4112,7 @@ StringObject::assignInitialShape(ExclusiveContext* cx, Handle obj } JSObject* -js_InitStringClass(JSContext* cx, HandleObject obj) +js::InitStringClass(JSContext* cx, HandleObject obj) { MOZ_ASSERT(obj->isNative()); @@ -4125,7 +4125,7 @@ js_InitStringClass(JSContext* cx, HandleObject obj) /* Now create the String function. */ RootedFunction ctor(cx); - ctor = global->createConstructor(cx, js_String, cx->names().String, 1); + ctor = global->createConstructor(cx, StringConstructor, cx->names().String, 1); if (!ctor) return nullptr; @@ -4152,7 +4152,7 @@ js_InitStringClass(JSContext* cx, HandleObject obj) } const char* -js_ValueToPrintable(JSContext* cx, const Value& vArg, JSAutoByteString* bytes, bool asSource) +js::ValueToPrintable(JSContext* cx, const Value& vArg, JSAutoByteString* bytes, bool asSource) { RootedValue v(cx, vArg); JSString* str; @@ -4162,7 +4162,7 @@ js_ValueToPrintable(JSContext* cx, const Value& vArg, JSAutoByteString* bytes, b str = ToString(cx, v); if (!str) return nullptr; - str = js_QuoteString(cx, str, 0); + str = QuoteString(cx, str, 0); if (!str) return nullptr; return bytes->encodeLatin1(cx, str); @@ -4193,12 +4193,12 @@ js::ToStringSlow(ExclusiveContext* cx, typename MaybeRooted::Han } else if (v.isDouble()) { str = NumberToString(cx, v.toDouble()); } else if (v.isBoolean()) { - str = js_BooleanToString(cx, v.toBoolean()); + str = BooleanToString(cx, v.toBoolean()); } else if (v.isNull()) { str = cx->names().null; } else if (v.isSymbol()) { if (cx->shouldBeJSContext() && allowGC) { - JS_ReportErrorNumber(cx->asJSContext(), js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx->asJSContext(), GetErrorMessage, nullptr, JSMSG_SYMBOL_TO_STRING); } return nullptr; @@ -4285,7 +4285,7 @@ js::ValueToSource(JSContext* cx, HandleValue v) JSString* js::StringToSource(JSContext* cx, JSString* str) { - return js_QuoteString(cx, str, '"'); + return QuoteString(cx, str, '"'); } bool @@ -4521,7 +4521,7 @@ js::DeflateStringToBuffer(JSContext* maybecx, const CharT* src, size_t srclen, dst[i] = char(src[i]); if (maybecx) { AutoSuppressGC suppress(maybecx); - JS_ReportErrorNumber(maybecx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(maybecx, GetErrorMessage, nullptr, JSMSG_BUFFER_TOO_SMALL); } return false; @@ -4730,7 +4730,7 @@ Encode(StringBuffer& sb, const CharT* chars, size_t length, v = ((c - 0xD800) << 10) + (c2 - 0xDC00) + 0x10000; } uint8_t utf8buf[4]; - size_t L = js_OneUcs4ToUtf8Char(utf8buf, v); + size_t L = OneUcs4ToUtf8Char(utf8buf, v); for (size_t j = 0; j < L; j++) { hexBuf[1] = HexDigits[utf8buf[j] >> 4]; hexBuf[2] = HexDigits[utf8buf[j] & 0xf]; @@ -4770,7 +4770,7 @@ Encode(JSContext* cx, HandleLinearString str, const bool* unescapedSet, return false; if (res == Encode_BadUri) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_BAD_URI, nullptr); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_BAD_URI, nullptr); return false; } @@ -4880,7 +4880,7 @@ Decode(JSContext* cx, HandleLinearString str, const bool* reservedSet, MutableHa return false; if (res == Decode_BadUri) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_BAD_URI); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_BAD_URI); return false; } @@ -4937,7 +4937,7 @@ str_encodeURI_Component(JSContext* cx, unsigned argc, Value* vp) * least 4 bytes long. Return the number of UTF-8 bytes of data written. */ int -js_OneUcs4ToUtf8Char(uint8_t* utf8Buffer, uint32_t ucs4Char) +js::OneUcs4ToUtf8Char(uint8_t* utf8Buffer, uint32_t ucs4Char) { int utf8Length = 1; diff --git a/js/src/jsstr.h b/js/src/jsstr.h index afeba7c04c..748b3ff18d 100644 --- a/js/src/jsstr.h +++ b/js/src/jsstr.h @@ -98,17 +98,6 @@ struct JSSubString { #define JS7_UNHEX(c) (unsigned)(JS7_ISDEC(c) ? (c) - '0' : 10 + tolower(c) - 'a') #define JS7_ISLET(c) (mozilla::IsAsciiAlpha(c)) -/* Initialize the String class, returning its prototype object. */ -extern JSObject* -js_InitStringClass(JSContext* cx, js::HandleObject obj); - -/* - * Convert a value to a printable C string. - */ -extern const char* -js_ValueToPrintable(JSContext* cx, const js::Value&, - JSAutoByteString* bytes, bool asSource = false); - extern size_t js_strlen(const char16_t* s); @@ -127,6 +116,16 @@ js_strncpy(char16_t* dst, const char16_t* src, size_t nelem) namespace js { +/* Initialize the String class, returning its prototype object. */ +extern JSObject * +InitStringClass(JSContext *cx, HandleObject obj); + +/* + * Convert a value to a printable C string. + */ +extern const char * +ValueToPrintable(JSContext *cx, const Value &, JSAutoByteString *bytes, bool asSource = false); + extern mozilla::UniquePtr DuplicateString(ExclusiveContext* cx, const char* s); @@ -328,31 +327,23 @@ str_toLowerCase(JSContext* cx, unsigned argc, Value* vp); extern bool str_toUpperCase(JSContext* cx, unsigned argc, Value* vp); -} /* namespace js */ +extern bool +str_toString(JSContext* cx, unsigned argc, Value* vp); extern bool -js_str_toString(JSContext* cx, unsigned argc, js::Value* vp); - -extern bool -js_str_charAt(JSContext* cx, unsigned argc, js::Value* vp); - -namespace js { +str_charAt(JSContext* cx, unsigned argc, Value* vp); extern bool str_charCodeAt_impl(JSContext* cx, HandleString string, HandleValue index, MutableHandleValue res); -} /* namespace js */ - extern bool -js_str_charCodeAt(JSContext* cx, unsigned argc, js::Value* vp); +str_charCodeAt(JSContext* cx, unsigned argc, Value* vp); /* * Convert one UCS-4 char and write it into a UTF-8 buffer, which must be at * least 6 bytes long. Return the number of UTF-8 bytes of data written. */ extern int -js_OneUcs4ToUtf8Char(uint8_t* utf8Buffer, uint32_t ucs4Char); - -namespace js { +OneUcs4ToUtf8Char(uint8_t* utf8Buffer, uint32_t ucs4Char); extern size_t PutEscapedStringImpl(char* buffer, size_t size, FILE* fp, JSLinearString* str, uint32_t quote); @@ -432,9 +423,9 @@ bool str_replace_string_raw(JSContext* cx, HandleString string, HandleString pattern, HandleString replacement, MutableHandleValue rval); +extern bool +StringConstructor(JSContext* cx, unsigned argc, Value* vp); + } /* namespace js */ -extern bool -js_String(JSContext* cx, unsigned argc, js::Value* vp); - #endif /* jsstr_h */ diff --git a/js/src/jswatchpoint.cpp b/js/src/jswatchpoint.cpp index 1861204c8a..6e5276d8a1 100644 --- a/js/src/jswatchpoint.cpp +++ b/js/src/jswatchpoint.cpp @@ -68,7 +68,7 @@ WatchpointMap::watch(JSContext* cx, HandleObject obj, HandleId id, Watchpoint w(handler, closure, false); if (!map.put(WatchKey(obj, id), w)) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return false; } /* diff --git a/js/src/jsweakmap.cpp b/js/src/jsweakmap.cpp index 61b49d6bd3..02488fc562 100644 --- a/js/src/jsweakmap.cpp +++ b/js/src/jsweakmap.cpp @@ -329,7 +329,7 @@ TryPreserveReflector(JSContext* cx, HandleObject obj) { MOZ_ASSERT(cx->runtime()->preserveWrapperCallback); if (!cx->runtime()->preserveWrapperCallback(cx, obj)) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_BAD_WEAKMAP_KEY); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_BAD_WEAKMAP_KEY); return false; } } @@ -391,7 +391,7 @@ WeakMap_set_impl(JSContext* cx, const CallArgs& args) char *bytes = DecompileValueGenerator(cx, JSDVG_SEARCH_STACK, args.get(0), NullPtr()); if (!bytes) return false; - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_NOT_NONNULL_OBJECT, bytes); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NOT_NONNULL_OBJECT, bytes); return false; } @@ -552,7 +552,7 @@ WeakMap_construct(JSContext* cx, unsigned argc, Value* vp) // Step 12f. if (!pairVal.isObject()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INVALID_MAP_ITERABLE, "WeakMap"); return false; } @@ -575,7 +575,7 @@ WeakMap_construct(JSContext* cx, unsigned argc, Value* vp) char *bytes = DecompileValueGenerator(cx, JSDVG_SEARCH_STACK, keyVal, NullPtr()); if (!bytes) return false; - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_NOT_NONNULL_OBJECT, bytes); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NOT_NONNULL_OBJECT, bytes); return false; } @@ -658,7 +658,7 @@ InitWeakMapClass(JSContext* cx, HandleObject obj, bool defineMembers) } JSObject* -js_InitWeakMapClass(JSContext* cx, HandleObject obj) +js::InitWeakMapClass(JSContext *cx, HandleObject obj) { return InitWeakMapClass(cx, obj, true); } diff --git a/js/src/jsweakmap.h b/js/src/jsweakmap.h index e0795291e6..307896f089 100644 --- a/js/src/jsweakmap.h +++ b/js/src/jsweakmap.h @@ -322,9 +322,9 @@ WeakMap_delete(JSContext* cx, unsigned argc, Value* vp); extern bool WeakMap_clear(JSContext* cx, unsigned argc, Value* vp); +extern JSObject* +InitWeakMapClass(JSContext* cx, HandleObject obj); + } /* namespace js */ -extern JSObject* -js_InitWeakMapClass(JSContext* cx, js::HandleObject obj); - #endif /* jsweakmap_h */ diff --git a/js/src/perf/jsperf.cpp b/js/src/perf/jsperf.cpp index 47e5b454ce..6e12c9db20 100644 --- a/js/src/perf/jsperf.cpp +++ b/js/src/perf/jsperf.cpp @@ -174,7 +174,7 @@ pm_construct(JSContext* cx, unsigned argc, jsval* vp) uint32_t mask; if (!args.hasDefined(0)) { - js_ReportMissingArg(cx, args.calleev(), 0); + ReportMissingArg(cx, args.calleev(), 0); return false; } if (!JS::ToUint32(cx, args[0], &mask)) @@ -213,7 +213,7 @@ GetPM(JSContext* cx, JS::HandleValue value, const char* fname) char *bytes = DecompileValueGenerator(cx, JSDVG_SEARCH_STACK, value, NullPtr()); if (!bytes) return nullptr; - JS_ReportErrorNumber(cx, js_GetErrorMessage, 0, JSMSG_NOT_NONNULL_OBJECT, bytes); + JS_ReportErrorNumber(cx, GetErrorMessage, 0, JSMSG_NOT_NONNULL_OBJECT, bytes); return nullptr; } RootedObject obj(cx, &value.toObject()); @@ -224,7 +224,7 @@ GetPM(JSContext* cx, JS::HandleValue value, const char* fname) // JS_GetInstancePrivate only sets an exception if its last argument // is nonzero, so we have to do it by hand. - JS_ReportErrorNumber(cx, js_GetErrorMessage, 0, JSMSG_INCOMPATIBLE_PROTO, + JS_ReportErrorNumber(cx, GetErrorMessage, 0, JSMSG_INCOMPATIBLE_PROTO, pm_class.name, fname, JS_GetClass(obj)->name); return nullptr; } diff --git a/js/src/proxy/BaseProxyHandler.cpp b/js/src/proxy/BaseProxyHandler.cpp index 5612737a3d..ad85874bd4 100644 --- a/js/src/proxy/BaseProxyHandler.cpp +++ b/js/src/proxy/BaseProxyHandler.cpp @@ -147,7 +147,7 @@ BaseProxyHandler::set(JSContext* cx, HandleObject proxy, HandleObject receiver, if (ownDesc.hasSetterObject()) setter = ownDesc.setterObject(); if (!setter) - return js_ReportGetterOnlyAssignment(cx, strict); + return ReportGetterOnlyAssignment(cx, strict); RootedValue setterValue(cx, ObjectValue(*setter)); return InvokeGetterOrSetter(cx, receiver, setterValue, 1, vp.address(), vp); } @@ -350,7 +350,7 @@ BaseProxyHandler::setPrototypeOf(JSContext* cx, HandleObject, HandleObject, bool // Disallow sets of protos on proxies with lazy protos, but no hook. // This keeps us away from the footgun of having the first proto set opt // you out of having dynamic protos altogether. - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_SETPROTOTYPEOF_FAIL, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_SETPROTOTYPEOF_FAIL, "incompatible Proxy"); return false; } @@ -365,7 +365,7 @@ BaseProxyHandler::setImmutablePrototype(JSContext* cx, HandleObject proxy, bool* bool BaseProxyHandler::watch(JSContext* cx, HandleObject proxy, HandleId id, HandleObject callable) const { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_CANT_WATCH, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CANT_WATCH, proxy->getClass()->name); return false; } diff --git a/js/src/proxy/DeadObjectProxy.cpp b/js/src/proxy/DeadObjectProxy.cpp index 1dedac21b9..52274c784a 100644 --- a/js/src/proxy/DeadObjectProxy.cpp +++ b/js/src/proxy/DeadObjectProxy.cpp @@ -18,7 +18,7 @@ bool DeadObjectProxy::getPropertyDescriptor(JSContext* cx, HandleObject wrapper, HandleId id, MutableHandle desc) const { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_DEAD_OBJECT); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_DEAD_OBJECT); return false; } @@ -26,7 +26,7 @@ bool DeadObjectProxy::getOwnPropertyDescriptor(JSContext* cx, HandleObject wrapper, HandleId id, MutableHandle desc) const { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_DEAD_OBJECT); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_DEAD_OBJECT); return false; } @@ -34,7 +34,7 @@ bool DeadObjectProxy::defineProperty(JSContext* cx, HandleObject wrapper, HandleId id, MutableHandle desc) const { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_DEAD_OBJECT); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_DEAD_OBJECT); return false; } @@ -42,21 +42,21 @@ bool DeadObjectProxy::ownPropertyKeys(JSContext* cx, HandleObject wrapper, AutoIdVector& props) const { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_DEAD_OBJECT); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_DEAD_OBJECT); return false; } bool DeadObjectProxy::delete_(JSContext* cx, HandleObject wrapper, HandleId id, bool* bp) const { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_DEAD_OBJECT); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_DEAD_OBJECT); return false; } bool DeadObjectProxy::enumerate(JSContext* cx, HandleObject wrapper, MutableHandleObject objp) const { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_DEAD_OBJECT); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_DEAD_OBJECT); return false; } @@ -70,7 +70,7 @@ DeadObjectProxy::getPrototypeOf(JSContext* cx, HandleObject proxy, MutableHandle bool DeadObjectProxy::preventExtensions(JSContext* cx, HandleObject proxy, bool* succeeded) const { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_DEAD_OBJECT); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_DEAD_OBJECT); return false; } @@ -86,14 +86,14 @@ DeadObjectProxy::isExtensible(JSContext* cx, HandleObject proxy, bool* extensibl bool DeadObjectProxy::call(JSContext* cx, HandleObject wrapper, const CallArgs& args) const { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_DEAD_OBJECT); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_DEAD_OBJECT); return false; } bool DeadObjectProxy::construct(JSContext* cx, HandleObject wrapper, const CallArgs& args) const { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_DEAD_OBJECT); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_DEAD_OBJECT); return false; } @@ -101,7 +101,7 @@ bool DeadObjectProxy::nativeCall(JSContext* cx, IsAcceptableThis test, NativeImpl impl, const CallArgs& args) const { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_DEAD_OBJECT); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_DEAD_OBJECT); return false; } @@ -109,14 +109,14 @@ bool DeadObjectProxy::hasInstance(JSContext* cx, HandleObject proxy, MutableHandleValue v, bool* bp) const { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_DEAD_OBJECT); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_DEAD_OBJECT); return false; } bool DeadObjectProxy::objectClassIs(HandleObject obj, ESClassValue classValue, JSContext* cx) const { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_DEAD_OBJECT); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_DEAD_OBJECT); return false; } @@ -135,7 +135,7 @@ DeadObjectProxy::fun_toString(JSContext* cx, HandleObject proxy, unsigned indent bool DeadObjectProxy::regexp_toShared(JSContext* cx, HandleObject proxy, RegExpGuard* g) const { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_DEAD_OBJECT); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_DEAD_OBJECT); return false; } @@ -143,7 +143,7 @@ bool DeadObjectProxy::defaultValue(JSContext* cx, HandleObject obj, JSType hint, MutableHandleValue vp) const { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_DEAD_OBJECT); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_DEAD_OBJECT); return false; } diff --git a/js/src/proxy/Proxy.cpp b/js/src/proxy/Proxy.cpp index 1f06825a98..108d11e35f 100644 --- a/js/src/proxy/Proxy.cpp +++ b/js/src/proxy/Proxy.cpp @@ -35,7 +35,7 @@ js::AutoEnterPolicy::reportErrorIfExceptionIsNotPending(JSContext* cx, jsid id) return; if (JSID_IS_VOID(id)) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_OBJECT_ACCESS_DENIED); } else { RootedValue idVal(cx, IdToValue(id)); @@ -48,7 +48,7 @@ js::AutoEnterPolicy::reportErrorIfExceptionIsNotPending(JSContext* cx, jsid id) if (str->ensureFlat(cx) && chars.initTwoByte(cx, str)) prop = chars.twoByteChars(); - JS_ReportErrorNumberUC(cx, js_GetErrorMessage, nullptr, JSMSG_PROPERTY_ACCESS_DENIED, + JS_ReportErrorNumberUC(cx, GetErrorMessage, nullptr, JSMSG_PROPERTY_ACCESS_DENIED, prop); } } @@ -755,7 +755,7 @@ ProxyObject::renew(JSContext* cx, const BaseProxyHandler* handler, Value priv) } JS_FRIEND_API(JSObject*) -js_InitProxyClass(JSContext* cx, HandleObject obj) +js::InitProxyClass(JSContext* cx, HandleObject obj) { static const JSFunctionSpec static_methods[] = { JS_FN("create", proxy_create, 2, 0), diff --git a/js/src/proxy/ScriptedDirectProxyHandler.cpp b/js/src/proxy/ScriptedDirectProxyHandler.cpp index fc0af8deb5..edc0349e77 100644 --- a/js/src/proxy/ScriptedDirectProxyHandler.cpp +++ b/js/src/proxy/ScriptedDirectProxyHandler.cpp @@ -207,7 +207,7 @@ ArrayToIdVector(JSContext* cx, HandleObject proxy, HandleObject target, HandleVa if (!IsExtensible(cx, target, &extensible)) return false; if (!extensible && !isFixed) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_CANT_REPORT_NEW); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CANT_REPORT_NEW); return false; } @@ -240,7 +240,7 @@ ArrayToIdVector(JSContext* cx, HandleObject proxy, HandleObject target, HandleVa if (!IsSealed(cx, target, id, &sealed)) return false; if (sealed) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_CANT_SKIP_NC); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CANT_SKIP_NC); return false; } @@ -254,7 +254,7 @@ ArrayToIdVector(JSContext* cx, HandleObject proxy, HandleObject target, HandleVa if (!IsExtensible(cx, target, &extensible)) return false; if (!extensible && isFixed) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_CANT_REPORT_E_AS_NE); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CANT_REPORT_E_AS_NE); return false; } } @@ -272,7 +272,7 @@ ScriptedDirectProxyHandler::getPrototypeOf(JSContext* cx, HandleObject proxy, RootedObject target(cx, proxy->as().target()); // Though handler is used elsewhere, spec mandates that both get set to null. if (!target) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_PROXY_REVOKED); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_PROXY_REVOKED); return false; } @@ -285,7 +285,7 @@ ScriptedDirectProxyHandler::setPrototypeOf(JSContext* cx, HandleObject proxy, { RootedObject target(cx, proxy->as().target()); if (!target) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_PROXY_REVOKED); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_PROXY_REVOKED); return false; } @@ -300,7 +300,7 @@ ScriptedDirectProxyHandler::setImmutablePrototype(JSContext* cx, HandleObject pr { RootedObject target(cx, proxy->as().target()); if (!target) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_PROXY_REVOKED); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_PROXY_REVOKED); return false; } @@ -315,7 +315,7 @@ ScriptedDirectProxyHandler::preventExtensions(JSContext* cx, HandleObject proxy, // Steps 1-3. RootedObject handler(cx, GetDirectProxyHandlerObject(proxy)); if (!handler) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_PROXY_REVOKED); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_PROXY_REVOKED); return false; } @@ -348,7 +348,7 @@ ScriptedDirectProxyHandler::preventExtensions(JSContext* cx, HandleObject proxy, if (!IsExtensible(cx, target, &extensible)) return false; if (extensible) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_CANT_REPORT_AS_NON_EXTENSIBLE); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CANT_REPORT_AS_NON_EXTENSIBLE); return false; } } @@ -367,7 +367,7 @@ ScriptedDirectProxyHandler::isExtensible(JSContext* cx, HandleObject proxy, bool // step 2 if (!handler) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_PROXY_REVOKED); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_PROXY_REVOKED); return false; } @@ -401,7 +401,7 @@ ScriptedDirectProxyHandler::isExtensible(JSContext* cx, HandleObject proxy, bool // step 12 if (targetResult != booleanTrapResult) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_PROXY_EXTENSIBILITY); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_PROXY_EXTENSIBILITY); return false; } @@ -442,7 +442,7 @@ ScriptedDirectProxyHandler::getOwnPropertyDescriptor(JSContext* cx, HandleObject // step 3 if (!handler) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_PROXY_REVOKED); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_PROXY_REVOKED); return false; } @@ -473,7 +473,7 @@ ScriptedDirectProxyHandler::getOwnPropertyDescriptor(JSContext* cx, HandleObject // step 10 if (!trapResult.isUndefined() && !trapResult.isObject()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_PROXY_GETOWN_OBJORUNDEF); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_PROXY_GETOWN_OBJORUNDEF); return false; } @@ -492,7 +492,7 @@ ScriptedDirectProxyHandler::getOwnPropertyDescriptor(JSContext* cx, HandleObject // substep b if (targetDesc.isPermanent()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_CANT_REPORT_NC_AS_NE); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CANT_REPORT_NC_AS_NE); return false; } @@ -501,7 +501,7 @@ ScriptedDirectProxyHandler::getOwnPropertyDescriptor(JSContext* cx, HandleObject if (!IsExtensible(cx, target, &extensibleTarget)) return false; if (!extensibleTarget) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_CANT_REPORT_E_AS_NE); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CANT_REPORT_E_AS_NE); return false; } @@ -530,19 +530,19 @@ ScriptedDirectProxyHandler::getOwnPropertyDescriptor(JSContext* cx, HandleObject // step 20 if (!valid) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_CANT_REPORT_INVALID); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CANT_REPORT_INVALID); return false; } // step 21 if (!resultDesc.configurable()) { if (!targetDesc.object()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_CANT_REPORT_NE_AS_NC); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CANT_REPORT_NE_AS_NC); return false; } if (!targetDesc.isPermanent()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_CANT_REPORT_C_AS_NC); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CANT_REPORT_C_AS_NC); return false; } } @@ -562,7 +562,7 @@ ScriptedDirectProxyHandler::defineProperty(JSContext* cx, HandleObject proxy, Ha // step 3 if (!handler) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_PROXY_REVOKED); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_PROXY_REVOKED); return false; } @@ -614,12 +614,12 @@ ScriptedDirectProxyHandler::defineProperty(JSContext* cx, HandleObject proxy, Ha if (!targetDesc.object()) { // step 20a if (!extensibleTarget) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_CANT_DEFINE_NEW); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CANT_DEFINE_NEW); return false; } // step 20b if (settingConfigFalse) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_CANT_DEFINE_NE_AS_NC); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CANT_DEFINE_NE_AS_NC); return false; } } else { @@ -630,7 +630,7 @@ ScriptedDirectProxyHandler::defineProperty(JSContext* cx, HandleObject proxy, Ha if (!ValidatePropertyDescriptor(cx, extensibleTarget, pd, targetDesc, &valid)) return false; if (!valid || (settingConfigFalse && !targetDesc.isPermanent())) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_CANT_DEFINE_INVALID); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CANT_DEFINE_INVALID); return false; } } @@ -651,7 +651,7 @@ ScriptedDirectProxyHandler::ownPropertyKeys(JSContext* cx, HandleObject proxy, // step 2 if (!handler) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_PROXY_REVOKED); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_PROXY_REVOKED); return false; } @@ -697,7 +697,7 @@ ScriptedDirectProxyHandler::delete_(JSContext* cx, HandleObject proxy, HandleId // step 3 if (!handler) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_PROXY_REVOKED); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_PROXY_REVOKED); return false; } @@ -759,7 +759,7 @@ ScriptedDirectProxyHandler::enumerate(JSContext* cx, HandleObject proxy, // step 2 if (!handler) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_PROXY_REVOKED); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_PROXY_REVOKED); return false; } @@ -804,7 +804,7 @@ ScriptedDirectProxyHandler::has(JSContext* cx, HandleObject proxy, HandleId id, // step 3 if (!handler) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_PROXY_REVOKED); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_PROXY_REVOKED); return false; } @@ -843,7 +843,7 @@ ScriptedDirectProxyHandler::has(JSContext* cx, HandleObject proxy, HandleId id, if (desc.object()) { if (desc.isPermanent()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_CANT_REPORT_NC_AS_NE); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CANT_REPORT_NC_AS_NE); return false; } @@ -851,7 +851,7 @@ ScriptedDirectProxyHandler::has(JSContext* cx, HandleObject proxy, HandleId id, if (!IsExtensible(cx, target, &extensible)) return false; if (!extensible) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_CANT_REPORT_E_AS_NE); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CANT_REPORT_E_AS_NE); return false; } } @@ -872,7 +872,7 @@ ScriptedDirectProxyHandler::get(JSContext* cx, HandleObject proxy, HandleObject // step 3 if (!handler) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_PROXY_REVOKED); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_PROXY_REVOKED); return false; } @@ -913,14 +913,14 @@ ScriptedDirectProxyHandler::get(JSContext* cx, HandleObject proxy, HandleObject if (!SameValue(cx, trapResult, desc.value(), &same)) return false; if (!same) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_MUST_REPORT_SAME_VALUE); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_MUST_REPORT_SAME_VALUE); return false; } } if (IsAccessorDescriptor(desc) && desc.isPermanent() && !desc.hasGetterObject()) { if (!trapResult.isUndefined()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_MUST_REPORT_UNDEFINED); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_MUST_REPORT_UNDEFINED); return false; } } @@ -941,7 +941,7 @@ ScriptedDirectProxyHandler::set(JSContext* cx, HandleObject proxy, HandleObject // step 3 if (!handler) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_PROXY_REVOKED); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_PROXY_REVOKED); return false; } @@ -987,13 +987,13 @@ ScriptedDirectProxyHandler::set(JSContext* cx, HandleObject proxy, HandleObject if (!SameValue(cx, vp, desc.value(), &same)) return false; if (!same) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_CANT_SET_NW_NC); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CANT_SET_NW_NC); return false; } } if (IsAccessorDescriptor(desc) && desc.isPermanent() && !desc.hasSetterObject()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_CANT_SET_WO_SETTER); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CANT_SET_WO_SETTER); return false; } } @@ -1014,7 +1014,7 @@ ScriptedDirectProxyHandler::call(JSContext* cx, HandleObject proxy, const CallAr // step 2 if (!handler) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_PROXY_REVOKED); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_PROXY_REVOKED); return false; } @@ -1055,7 +1055,7 @@ ScriptedDirectProxyHandler::construct(JSContext* cx, HandleObject proxy, const C // step 2 if (!handler) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_PROXY_REVOKED); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_PROXY_REVOKED); return false; } @@ -1088,7 +1088,7 @@ ScriptedDirectProxyHandler::construct(JSContext* cx, HandleObject proxy, const C // step 10 if (!args.rval().isObject()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_PROXY_CONSTRUCT_OBJECT); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_PROXY_CONSTRUCT_OBJECT); return false; } return true; @@ -1108,7 +1108,7 @@ ScriptedDirectProxyHandler::hasInstance(JSContext* cx, HandleObject proxy, Mutab { RootedObject handler(cx, GetDirectProxyHandlerObject(proxy)); if (!handler) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_PROXY_REVOKED); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_PROXY_REVOKED); return false; } @@ -1149,7 +1149,7 @@ JSString* ScriptedDirectProxyHandler::fun_toString(JSContext* cx, HandleObject proxy, unsigned indent) const { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO, js_Function_str, js_toString_str, "object"); return nullptr; } @@ -1193,7 +1193,7 @@ static bool NewScriptedProxy(JSContext* cx, CallArgs& args, const char* callerName) { if (args.length() < 2) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, callerName, "1", "s"); return false; } @@ -1227,7 +1227,7 @@ js::proxy(JSContext* cx, unsigned argc, Value* vp) CallArgs args = CallArgsFromVp(argc, vp); if (!args.isConstructing()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_NOT_FUNCTION, "Proxy"); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NOT_FUNCTION, "Proxy"); return false; } diff --git a/js/src/proxy/ScriptedIndirectProxyHandler.cpp b/js/src/proxy/ScriptedIndirectProxyHandler.cpp index c883c2d577..c2bac46bd8 100644 --- a/js/src/proxy/ScriptedIndirectProxyHandler.cpp +++ b/js/src/proxy/ScriptedIndirectProxyHandler.cpp @@ -358,7 +358,7 @@ ScriptedIndirectProxyHandler::fun_toString(JSContext* cx, HandleObject proxy, un { assertEnteredPolicy(cx, proxy, JSID_VOID, GET); if (!proxy->isCallable()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO, js_Function_str, js_toString_str, "object"); @@ -399,7 +399,7 @@ js::proxy_create(JSContext* cx, unsigned argc, Value* vp) { CallArgs args = CallArgsFromVp(argc, vp); if (args.length() < 1) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, "create", "0", "s"); return false; } @@ -431,7 +431,7 @@ js::proxy_createFunction(JSContext* cx, unsigned argc, Value* vp) { CallArgs args = CallArgsFromVp(argc, vp); if (args.length() < 2) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, "createFunction", "1", ""); return false; } diff --git a/js/src/proxy/SecurityWrapper.cpp b/js/src/proxy/SecurityWrapper.cpp index 8a2d477a15..d27d2cc41c 100644 --- a/js/src/proxy/SecurityWrapper.cpp +++ b/js/src/proxy/SecurityWrapper.cpp @@ -16,7 +16,7 @@ bool SecurityWrapper::enter(JSContext* cx, HandleObject wrapper, HandleId id, Wrapper::Action act, bool* bp) const { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_UNWRAP_DENIED); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_UNWRAP_DENIED); *bp = false; return false; } @@ -26,7 +26,7 @@ bool SecurityWrapper::nativeCall(JSContext* cx, IsAcceptableThis test, NativeImpl impl, const CallArgs& args) const { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_UNWRAP_DENIED); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_UNWRAP_DENIED); return false; } @@ -35,7 +35,7 @@ bool SecurityWrapper::setPrototypeOf(JSContext* cx, HandleObject wrapper, HandleObject proto, bool* bp) const { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_UNWRAP_DENIED); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_UNWRAP_DENIED); return false; } @@ -44,7 +44,7 @@ bool SecurityWrapper::setImmutablePrototype(JSContext* cx, HandleObject wrapper, bool* succeeded) const { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_UNWRAP_DENIED); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_UNWRAP_DENIED); return false; } @@ -116,7 +116,7 @@ SecurityWrapper::defineProperty(JSContext* cx, HandleObject wrapper, const char16_t* prop = nullptr; if (str->ensureFlat(cx) && chars.initTwoByte(cx, str)) prop = chars.twoByteChars(); - JS_ReportErrorNumberUC(cx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumberUC(cx, GetErrorMessage, nullptr, JSMSG_ACCESSOR_DEF_DENIED, prop); return false; } @@ -129,7 +129,7 @@ bool SecurityWrapper::watch(JSContext* cx, HandleObject proxy, HandleId id, HandleObject callable) const { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_UNWRAP_DENIED); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_UNWRAP_DENIED); return false; } @@ -138,7 +138,7 @@ bool SecurityWrapper::unwatch(JSContext* cx, HandleObject proxy, HandleId id) const { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_UNWRAP_DENIED); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_UNWRAP_DENIED); return false; } diff --git a/js/src/proxy/Wrapper.cpp b/js/src/proxy/Wrapper.cpp index fed088b31e..ab09c756bd 100644 --- a/js/src/proxy/Wrapper.cpp +++ b/js/src/proxy/Wrapper.cpp @@ -147,7 +147,7 @@ ErrorCopier::~ErrorCopier() cx->clearPendingException(); ac.reset(); Rooted errObj(cx, &exc.toObject().as()); - JSObject* copyobj = js_CopyErrorObject(cx, errObj); + JSObject* copyobj = CopyErrorObject(cx, errObj); if (copyobj) cx->setPendingException(ObjectValue(*copyobj)); } diff --git a/js/src/shell/js.cpp b/js/src/shell/js.cpp index 28ed1f4ac3..46003d5d66 100644 --- a/js/src/shell/js.cpp +++ b/js/src/shell/js.cpp @@ -734,7 +734,7 @@ CreateMappedArrayBuffer(JSContext* cx, unsigned argc, Value* vp) return false; sizeGiven = true; if (offset > size) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_ARG_INDEX_OUT_OF_RANGE, "2"); return false; } @@ -755,7 +755,7 @@ CreateMappedArrayBuffer(JSContext* cx, unsigned argc, Value* vp) return false; } if (st.st_size < off_t(offset)) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_ARG_INDEX_OUT_OF_RANGE, "2"); return false; } @@ -1202,7 +1202,7 @@ Evaluate(JSContext* cx, unsigned argc, jsval* vp) return false; } if (!global || !(JS_GetClass(global)->flags & JSCLASS_IS_GLOBAL)) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE, "\"global\" passed to evaluate()", "not a global object"); return false; } @@ -2002,7 +2002,7 @@ LineToPC(JSContext* cx, unsigned argc, jsval* vp) if (!ToUint32(cx, args.get(lineArg), &lineno)) return false; - jsbytecode* pc = js_LineNumberToPC(script, lineno); + jsbytecode* pc = LineNumberToPC(script, lineno); if (!pc) return false; args.rval().setInt32(script->pcToOffset(pc)); @@ -2230,7 +2230,7 @@ DisassembleScript(JSContext* cx, HandleScript script, HandleFunction fun, bool l Sprint(sp, "\n"); } - if (!js_Disassemble(cx, script, lines, sp)) + if (!Disassemble(cx, script, lines, sp)) return false; SrcNotes(cx, script, sp); TryNotes(cx, script, sp); @@ -2300,7 +2300,7 @@ DisassembleToSprinter(JSContext* cx, unsigned argc, jsval* vp, Sprinter* sprinte RootedScript script(cx, GetTopScript(cx)); if (script) { JSAutoCompartment ac(cx, script); - if (!js_Disassemble(cx, script, p.lines, sprinter)) + if (!Disassemble(cx, script, p.lines, sprinter)) return false; SrcNotes(cx, script, sprinter); TryNotes(cx, script, sprinter); @@ -2482,7 +2482,7 @@ DisassWithSrc(JSContext* cx, unsigned argc, jsval* vp) } } - len = js_Disassemble1(cx, script, pc, script->pcToOffset(pc), true, &sprinter); + len = Disassemble1(cx, script, pc, script->pcToOffset(pc), true, &sprinter); if (!len) { ok = false; goto bail; @@ -2565,7 +2565,7 @@ Clone(JSContext* cx, unsigned argc, jsval* vp) if (funobj->compartment() != cx->compartment()) { JSFunction* fun = &funobj->as(); if (fun->hasScript() && fun->nonLazyScript()->compileAndGo()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE, "function", "compile-and-go"); return false; } @@ -2599,7 +2599,7 @@ GetSLX(JSContext* cx, unsigned argc, jsval* vp) script = ValueToScript(cx, args.get(0)); if (!script) return false; - args.rval().setInt32(js_GetScriptLineExtent(script)); + args.rval().setInt32(GetScriptLineExtent(script)); return true; } @@ -3238,7 +3238,7 @@ Compile(JSContext* cx, unsigned argc, jsval* vp) { CallArgs args = CallArgsFromVp(argc, vp); if (args.length() < 1) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, "compile", "0", "s"); return false; } @@ -3278,7 +3278,7 @@ Parse(JSContext* cx, unsigned argc, jsval* vp) CallArgs args = CallArgsFromVp(argc, vp); if (args.length() < 1) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, "parse", "0", "s"); return false; } @@ -3327,7 +3327,7 @@ SyntaxParse(JSContext* cx, unsigned argc, jsval* vp) CallArgs args = CallArgsFromVp(argc, vp); if (args.length() < 1) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, "parse", "0", "s"); return false; } @@ -3466,7 +3466,7 @@ OffThreadCompileScript(JSContext* cx, unsigned argc, jsval* vp) CallArgs args = CallArgsFromVp(argc, vp); if (args.length() < 1) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, "offThreadCompileScript", "0", "s"); return false; } @@ -4717,7 +4717,7 @@ static const JSFunctionSpecWithHelp shell_functions[] = { " Get the shape of obj (an implementation detail)."), #ifdef DEBUG - JS_FN_HELP("arrayInfo", js_ArrayInfo, 1, 0, + JS_FN_HELP("arrayInfo", ArrayInfo, 1, 0, "arrayInfo(a1, a2, ...)", " Report statistics about arrays."), #endif @@ -5350,7 +5350,7 @@ dom_constructor(JSContext* cx, unsigned argc, JS::Value* vp) return false; if (!protov.isObject()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_BAD_PROTOTYPE, "FakeDOMObject"); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_BAD_PROTOTYPE, "FakeDOMObject"); return false; } diff --git a/js/src/shell/jsheaptools.cpp b/js/src/shell/jsheaptools.cpp index 8c6d9797df..87fc530aa0 100644 --- a/js/src/shell/jsheaptools.cpp +++ b/js/src/shell/jsheaptools.cpp @@ -546,14 +546,14 @@ FindReferences(JSContext* cx, unsigned argc, jsval* vp) { CallArgs args = CallArgsFromVp(argc, vp); if (args.length() < 1) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, "findReferences", "0", "s"); return false; } RootedValue target(cx, args[0]); if (!target.isObject()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE, "argument", "not an object"); return false; } diff --git a/js/src/vm/ArrayBufferObject.cpp b/js/src/vm/ArrayBufferObject.cpp index 24f0b1a141..fbc6f8511e 100644 --- a/js/src/vm/ArrayBufferObject.cpp +++ b/js/src/vm/ArrayBufferObject.cpp @@ -284,7 +284,7 @@ TransferAsmJSMappedBuffer(JSContext* cx, const CallArgs& args, Handleis()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_TYPED_ARRAY_BAD_ARGS); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_TYPED_ARRAY_BAD_ARGS); return false; } oldBuffer = &unwrapped->as(); } if (oldBuffer->isNeutered()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_TYPED_ARRAY_DETACHED); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_TYPED_ARRAY_DETACHED); return false; } @@ -382,7 +382,7 @@ ArrayBufferObject::fun_transfer(JSContext* cx, unsigned argc, Value* vp) if (!ToInt32(cx, newByteLengthArg, &i32)) return false; if (i32 < 0) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_BAD_ARRAY_LENGTH); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_BAD_ARRAY_LENGTH); return false; } newByteLength = size_t(i32); @@ -467,7 +467,7 @@ ArrayBufferObject::class_constructor(JSContext* cx, unsigned argc, Value* vp) * as an integer value; if someone actually ever complains (validly), then we * can fix. */ - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_BAD_ARRAY_LENGTH); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_BAD_ARRAY_LENGTH); return false; } @@ -483,7 +483,7 @@ AllocateArrayBufferContents(JSContext* cx, uint32_t nbytes) { uint8_t* p = cx->runtime()->pod_callocCanGC(nbytes); if (!p) - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return ArrayBufferObject::BufferContents::create(p); } @@ -845,7 +845,7 @@ ArrayBufferObject::createSlice(JSContext* cx, Handle arrayBu { uint32_t bufLength = arrayBuffer->byteLength(); if (begin > bufLength || end > bufLength || begin > end) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_TYPE_ERR_BAD_ARGS); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_TYPE_ERR_BAD_ARGS); return nullptr; } @@ -1387,13 +1387,13 @@ JS_StealArrayBufferContents(JSContext* cx, HandleObject objArg) return nullptr; if (!obj->is()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_TYPED_ARRAY_BAD_ARGS); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_TYPED_ARRAY_BAD_ARGS); return nullptr; } Rooted buffer(cx, &obj->as()); if (buffer->isNeutered()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_TYPED_ARRAY_DETACHED); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_TYPED_ARRAY_DETACHED); return nullptr; } @@ -1525,7 +1525,7 @@ js::GetArrayBufferLengthAndData(JSObject* obj, uint32_t* length, uint8_t** data) } JSObject* -js_InitArrayBufferClass(JSContext* cx, HandleObject obj) +js::InitArrayBufferClass(JSContext *cx, HandleObject obj) { Rooted global(cx, cx->compartment()->maybeGlobal()); if (global->isStandardClassResolved(JSProto_ArrayBuffer)) diff --git a/js/src/vm/ArrayBufferObject.h b/js/src/vm/ArrayBufferObject.h index 7919b95374..9db120c453 100644 --- a/js/src/vm/ArrayBufferObject.h +++ b/js/src/vm/ArrayBufferObject.h @@ -536,6 +536,9 @@ class InnerViewTable size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf); }; +extern JSObject * +InitArrayBufferClass(JSContext *cx, HandleObject obj); + } // namespace js template <> diff --git a/js/src/vm/BooleanObject.h b/js/src/vm/BooleanObject.h index 672f64473f..81e38bf3b1 100644 --- a/js/src/vm/BooleanObject.h +++ b/js/src/vm/BooleanObject.h @@ -40,7 +40,7 @@ class BooleanObject : public NativeObject /* For access to init, as Boolean.prototype is special. */ friend JSObject* - ::js_InitBooleanClass(JSContext* cx, js::HandleObject global); + js::InitBooleanClass(JSContext *cx, js::HandleObject global); }; } // namespace js diff --git a/js/src/vm/CharacterEncoding.cpp b/js/src/vm/CharacterEncoding.cpp index abedfd3dc8..1ffaf8e045 100644 --- a/js/src/vm/CharacterEncoding.cpp +++ b/js/src/vm/CharacterEncoding.cpp @@ -116,7 +116,7 @@ DeflateStringToUTF8Buffer(const CharT* src, size_t srclen, mozilla::RangedPtr env, MutableHandleValue rv envobj->setPrivateGCThing(env); envobj->setReservedSlot(JSSLOT_DEBUGENV_OWNER, ObjectValue(*object)); if (!p.add(cx, environments, env, envobj)) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return false; } CrossCompartmentKey key(CrossCompartmentKey::DebuggerEnvironment, object, env); if (!object->compartment()->putWrapper(cx, key, ObjectValue(*envobj))) { environments.remove(env); - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return false; } } @@ -822,7 +822,7 @@ Debugger::wrapDebuggeeValue(JSContext* cx, MutableHandleValue vp) dobj->setReservedSlot(JSSLOT_DEBUGOBJECT_OWNER, ObjectValue(*object)); if (!p.add(cx, objects, obj, dobj)) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return false; } @@ -830,7 +830,7 @@ Debugger::wrapDebuggeeValue(JSContext* cx, MutableHandleValue vp) CrossCompartmentKey key(CrossCompartmentKey::DebuggerObject, object, obj); if (!object->compartment()->putWrapper(cx, key, ObjectValue(*dobj))) { objects.remove(obj); - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return false; } } @@ -875,7 +875,7 @@ Debugger::unwrapDebuggeeValue(JSContext* cx, MutableHandleValue vp) if (vp.isObject()) { JSObject* dobj = &vp.toObject(); if (dobj->getClass() != &DebuggerObject_class) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_NOT_EXPECTED_TYPE, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NOT_EXPECTED_TYPE, "Debugger", "Debugger.Object", dobj->getClass()->name); return false; } @@ -883,7 +883,7 @@ Debugger::unwrapDebuggeeValue(JSContext* cx, MutableHandleValue vp) Value owner = ndobj->getReservedSlot(JSSLOT_DEBUGOBJECT_OWNER); if (owner.isUndefined() || &owner.toObject() != object) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, owner.isUndefined() ? JSMSG_DEBUG_OBJECT_PROTO : JSMSG_DEBUG_OBJECT_WRONG_OWNER); @@ -904,7 +904,7 @@ CheckArgCompartment(JSContext* cx, JSObject* obj, HandleValue v, const char* methodname, const char* propname) { if (v.isObject() && v.toObject().compartment() != obj->compartment()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_DEBUG_COMPARTMENT_MISMATCH, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_DEBUG_COMPARTMENT_MISMATCH, methodname, propname); return false; } @@ -1097,7 +1097,7 @@ ParseResumptionValueAsObject(JSContext* cx, HandleValue rv, JSTrapStatus* status } if (hits != 1) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_DEBUG_BAD_RESUMPTION); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_DEBUG_BAD_RESUMPTION); return false; } return true; @@ -1320,7 +1320,7 @@ Debugger::slowPathOnNewScript(JSContext* cx, HandleScript script) Debugger* dbg = *p; if (dbg->observesNewScript() && dbg->observesScript(script)) { if (!triggered.append(ObjectValue(*dbg->toJSObject()))) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return; } } @@ -1517,7 +1517,7 @@ Debugger::fireNewGlobalObject(JSContext* cx, Handle global, Mutab // hooks. bool ok = Invoke(cx, ObjectValue(*object), ObjectValue(*hook), 1, wrappedGlobal.address(), &rv); if (ok && !rv.isUndefined()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_DEBUG_RESUMPTION_VALUE_DISALLOWED); ok = false; } @@ -1663,7 +1663,7 @@ Debugger::firePromiseHook(JSContext* cx, Hook hook, HandleObject promise, Mutabl RootedValue rv(cx); bool ok = Invoke(cx, ObjectValue(*object), ObjectValue(*hookObj), 1, dbgObj.address(), &rv); if (ok && !rv.isUndefined()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_DEBUG_RESUMPTION_VALUE_DISALLOWED); ok = false; } @@ -1825,7 +1825,7 @@ Debugger::updateExecutionObservabilityOfFrames(JSContext* cx, const ExecutionObs { jit::JitContext jctx(cx, nullptr); if (!jit::RecompileOnStackBaselineScriptsForDebugMode(cx, obs, observing)) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return false; } } @@ -2366,7 +2366,7 @@ Debugger::fromThisValue(JSContext* cx, const CallArgs& args, const char* fnname) } JSObject* thisobj = &args.thisv().toObject(); if (thisobj->getClass() != &Debugger::jsclass) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO, "Debugger", fnname, thisobj->getClass()->name); return nullptr; } @@ -2378,7 +2378,7 @@ Debugger::fromThisValue(JSContext* cx, const CallArgs& args, const char* fnname) */ Debugger* dbg = fromJSObject(thisobj); if (!dbg) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO, "Debugger", fnname, "prototype object"); } return dbg; @@ -2465,7 +2465,7 @@ Debugger::setHookImpl(JSContext* cx, unsigned argc, Value* vp, Hook which) if (!args[0].toObject().isCallable()) return ReportIsNotFunction(cx, args[0], args.length() - 1); } else if (!args[0].isUndefined()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_NOT_CALLABLE_OR_UNDEFINED); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NOT_CALLABLE_OR_UNDEFINED); return false; } dbg->object->setReservedSlot(JSSLOT_DEBUG_HOOK_START + which, args[0]); @@ -2600,7 +2600,7 @@ Debugger::setUncaughtExceptionHook(JSContext* cx, unsigned argc, Value* vp) if (!args.requireAtLeast(cx, "Debugger.set uncaughtExceptionHook", 1)) return false; if (!args[0].isNull() && (!args[0].isObject() || !args[0].toObject().isCallable())) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_ASSIGN_FUNCTION_OR_NULL, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_ASSIGN_FUNCTION_OR_NULL, "uncaughtExceptionHook"); return false; } @@ -2664,7 +2664,7 @@ GlobalObject* Debugger::unwrapDebuggeeArgument(JSContext* cx, const Value& v) { if (!v.isObject()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE, "argument", "not a global object"); return nullptr; } @@ -2693,7 +2693,7 @@ Debugger::unwrapDebuggeeArgument(JSContext* cx, const Value& v) /* If that didn't produce a global object, it's an error. */ if (!obj->is()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE, "argument", "not a global object"); return nullptr; } @@ -2890,7 +2890,7 @@ Debugger::construct(JSContext* cx, unsigned argc, Value* vp) return ReportObjectRequired(cx); JSObject* argobj = &arg.toObject(); if (!argobj->is()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_DEBUG_CCW_REQUIRED, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_DEBUG_CCW_REQUIRED, "Debugger"); return false; } @@ -2951,7 +2951,7 @@ Debugger::addDebuggeeGlobal(JSContext* cx, Handle global) // throw in that case. JSCompartment* debuggeeCompartment = global->compartment(); if (debuggeeCompartment->options().invisibleToDebugger()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_DEBUG_CANT_DEBUG_GLOBAL); return false; } @@ -2968,7 +2968,7 @@ Debugger::addDebuggeeGlobal(JSContext* cx, Handle global) for (size_t i = 0; i < visited.length(); i++) { JSCompartment* c = visited[i]; if (c == debuggeeCompartment) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_DEBUG_LOOP); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_DEBUG_LOOP); return false; } @@ -2993,7 +2993,7 @@ Debugger::addDebuggeeGlobal(JSContext* cx, Handle global) bool setMetadataCallback = false; if (trackingAllocationSites) { if (debuggeeCompartment->hasObjectMetadataCallback()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_OBJECT_METADATA_CALLBACK_ALREADY_SET); return false; } @@ -3012,10 +3012,10 @@ Debugger::addDebuggeeGlobal(JSContext* cx, Handle global) AutoCompartment ac(cx, global); GlobalObject::DebuggerVector* v = GlobalObject::getOrCreateDebuggers(cx, global); if (!v || !v->append(this)) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); } else { if (!debuggees.put(global)) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); } else { debuggeeCompartment->setIsDebuggee(); debuggeeCompartment->updateDebuggerObservesAsmJS(); @@ -3134,7 +3134,7 @@ class MOZ_STACK_CLASS Debugger::ScriptQuery if (!compartments.init() || !innermostForCompartment.init()) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return false; } @@ -3174,7 +3174,7 @@ class MOZ_STACK_CLASS Debugger::ScriptQuery if (!GetProperty(cx, query, query, cx->names().url, &url)) return false; if (!url.isUndefined() && !url.isString()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE, "query object's 'url' property", "neither undefined nor a string"); return false; } @@ -3186,7 +3186,7 @@ class MOZ_STACK_CLASS Debugger::ScriptQuery if (!debuggerSource.isUndefined()) { if (!debuggerSource.isObject() || debuggerSource.toObject().getClass() != &DebuggerSource_class) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE, "query object's 'source' property", "not undefined nor a Debugger.Source object"); return false; @@ -3200,7 +3200,7 @@ class MOZ_STACK_CLASS Debugger::ScriptQuery if (!GetProperty(cx, query, query, cx->names().displayURL, &displayURL)) return false; if (!displayURL.isUndefined() && !displayURL.isString()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE, "query object's 'displayURL' property", "neither undefined nor a string"); return false; @@ -3220,19 +3220,19 @@ class MOZ_STACK_CLASS Debugger::ScriptQuery hasLine = false; } else if (lineProperty.isNumber()) { if (displayURL.isUndefined() && url.isUndefined() && !source) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_QUERY_LINE_WITHOUT_URL); return false; } double doubleLine = lineProperty.toNumber(); if (doubleLine <= 0 || (unsigned int) doubleLine != doubleLine) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_DEBUG_BAD_LINE); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_DEBUG_BAD_LINE); return false; } hasLine = true; line = doubleLine; } else { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE, "query object's 'line' property", "neither undefined nor an integer"); return false; @@ -3247,7 +3247,7 @@ class MOZ_STACK_CLASS Debugger::ScriptQuery if (innermost) { /* Technically, we need only check hasLine, but this is clearer. */ if ((displayURL.isUndefined() && url.isUndefined() && !source) || !hasLine) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_QUERY_INNERMOST_WITHOUT_LINE_URL); return false; } @@ -3282,7 +3282,7 @@ class MOZ_STACK_CLASS Debugger::ScriptQuery oom = false; IterateScripts(cx->runtime(), singletonComp, this, considerScript); if (oom) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return false; } @@ -3303,7 +3303,7 @@ class MOZ_STACK_CLASS Debugger::ScriptQuery { JS::ExposeScriptToActiveJS(r.front().value()); if (!v->append(r.front().value())) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return false; } } @@ -3381,7 +3381,7 @@ class MOZ_STACK_CLASS Debugger::ScriptQuery bool matchSingleGlobal(GlobalObject* global) { MOZ_ASSERT(compartments.count() == 0); if (!addCompartment(global->compartment())) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return false; } return true; @@ -3396,7 +3396,7 @@ class MOZ_STACK_CLASS Debugger::ScriptQuery /* Build our compartment set from the debugger's set of debuggee globals. */ for (GlobalObjectSet::Range r = debugger->debuggees.all(); !r.empty(); r.popFront()) { if (!addCompartment(r.front()->compartment())) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return false; } } @@ -3452,7 +3452,7 @@ class MOZ_STACK_CLASS Debugger::ScriptQuery return; } if (hasLine) { - if (line < script->lineno() || script->lineno() + js_GetScriptLineExtent(script) < line) + if (line < script->lineno() || script->lineno() + GetScriptLineExtent(script) < line) return; } if (displayURLString) { @@ -3578,7 +3578,7 @@ class MOZ_STACK_CLASS Debugger::ObjectQuery return false; if (!cls.isUndefined()) { if (!cls.isString()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE, "query object's 'class' property", "neither undefined nor a string"); return false; @@ -3807,7 +3807,7 @@ Debugger::makeGlobalObjectReference(JSContext* cx, unsigned argc, Value* vp) // none of which we're ever supposed to see. JSCompartment* globalCompartment = global->compartment(); if (globalCompartment->options().invisibleToDebugger()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_DEBUG_INVISIBLE_COMPARTMENT); return false; } @@ -4170,14 +4170,14 @@ Debugger::wrapScript(JSContext* cx, HandleScript script) return nullptr; if (!p.add(cx, scripts, script, scriptobj)) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return nullptr; } CrossCompartmentKey key(CrossCompartmentKey::DebuggerScript, object, script); if (!object->compartment()->putWrapper(cx, key, ObjectValue(*scriptobj))) { scripts.remove(script); - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return nullptr; } } @@ -4195,7 +4195,7 @@ DebuggerScript_check(JSContext* cx, const Value& v, const char* clsname, const c } JSObject* thisobj = &v.toObject(); if (thisobj->getClass() != &DebuggerScript_class) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO, clsname, fnname, thisobj->getClass()->name); return nullptr; } @@ -4206,7 +4206,7 @@ DebuggerScript_check(JSContext* cx, const Value& v, const char* clsname, const c */ if (!GetScriptReferent(thisobj)) { MOZ_ASSERT(!GetScriptReferent(thisobj)); - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO, clsname, fnname, "prototype object"); return nullptr; } @@ -4280,7 +4280,7 @@ DebuggerScript_getLineCount(JSContext* cx, unsigned argc, Value* vp) { THIS_DEBUGSCRIPT_SCRIPT(cx, argc, vp, "(get lineCount)", args, obj, script); - unsigned maxLine = js_GetScriptLineExtent(script); + unsigned maxLine = GetScriptLineExtent(script); args.rval().setNumber(double(maxLine)); return true; } @@ -4389,7 +4389,7 @@ ScriptOffset(JSContext* cx, JSScript* script, const Value& v, size_t* offsetp) off = size_t(d); } if (!ok || off != d || !IsValidBytecodeOffset(cx, script, off)) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_DEBUG_BAD_OFFSET); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_DEBUG_BAD_OFFSET); return false; } *offsetp = off; @@ -4776,7 +4776,7 @@ DebuggerScript_getLineOffsets(JSContext* cx, unsigned argc, Value* vp) double d = linenoValue.toNumber(); lineno = size_t(d); if (lineno != d) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_DEBUG_BAD_LINE); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_DEBUG_BAD_LINE); return false; } } @@ -4853,7 +4853,7 @@ Debugger::replaceFrameGuts(JSContext* cx, AbstractFramePtr from, AbstractFramePt // Add the frame object with |to| as key. if (!dbg->frames.putNew(to, frameobj)) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return false; } } @@ -4962,7 +4962,7 @@ DebuggerScript_setBreakpoint(JSContext* cx, unsigned argc, Value* vp) Debugger* dbg = Debugger::fromChildJSObject(obj); if (!dbg->observesScript(script)) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_DEBUG_NOT_DEBUGGING); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_DEBUG_NOT_DEBUGGING); return false; } @@ -5096,7 +5096,7 @@ DebuggerScript_isInCatchScope(JSContext* cx, unsigned argc, Value* vp) static bool DebuggerScript_construct(JSContext* cx, unsigned argc, Value* vp) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_NO_CONSTRUCTOR, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NO_CONSTRUCTOR, "Debugger.Script"); return false; } @@ -5192,14 +5192,14 @@ Debugger::wrapSource(JSContext* cx, HandleScriptSource source) return nullptr; if (!p.add(cx, sources, source, sourceobj)) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return nullptr; } CrossCompartmentKey key(CrossCompartmentKey::DebuggerSource, object, source); if (!object->compartment()->putWrapper(cx, key, ObjectValue(*sourceobj))) { sources.remove(source); - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return nullptr; } } @@ -5211,7 +5211,7 @@ Debugger::wrapSource(JSContext* cx, HandleScriptSource source) static bool DebuggerSource_construct(JSContext* cx, unsigned argc, Value* vp) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_NO_CONSTRUCTOR, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NO_CONSTRUCTOR, "Debugger.Source"); return false; } @@ -5226,7 +5226,7 @@ DebuggerSource_checkThis(JSContext* cx, const CallArgs& args, const char* fnname JSObject* thisobj = &args.thisv().toObject(); if (thisobj->getClass() != &DebuggerSource_class) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO, "Debugger.Source", fnname, thisobj->getClass()->name); return nullptr; } @@ -5234,7 +5234,7 @@ DebuggerSource_checkThis(JSContext* cx, const CallArgs& args, const char* fnname NativeObject* nthisobj = &thisobj->as(); if (!GetSourceReferent(thisobj)) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO, "Debugger.Frame", fnname, "prototype object"); return nullptr; } @@ -5523,7 +5523,7 @@ CheckThisFrame(JSContext* cx, const CallArgs& args, const char* fnname, bool che } JSObject* thisobj = &args.thisv().toObject(); if (thisobj->getClass() != &DebuggerFrame_class) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO, "Debugger.Frame", fnname, thisobj->getClass()->name); return nullptr; } @@ -5538,12 +5538,12 @@ CheckThisFrame(JSContext* cx, const CallArgs& args, const char* fnname, bool che */ if (!nthisobj->getPrivate()) { if (nthisobj->getReservedSlot(JSSLOT_DEBUGFRAME_OWNER).isUndefined()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO, "Debugger.Frame", fnname, "prototype object"); return nullptr; } if (checkLive) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_DEBUG_NOT_LIVE, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_DEBUG_NOT_LIVE, "Debugger.Frame"); return nullptr; } @@ -5746,7 +5746,7 @@ DebuggerArguments_getArg(JSContext* cx, unsigned argc, Value* vp) } RootedObject argsobj(cx, &args.thisv().toObject()); if (argsobj->getClass() != &DebuggerArguments_class) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO, "Arguments", "getArgument", argsobj->getClass()->name); return false; } @@ -5930,7 +5930,7 @@ DebuggerFrame_setOnStep(JSContext* cx, unsigned argc, Value* vp) if (!args.requireAtLeast(cx, "Debugger.Frame.set onStep", 1)) return false; if (!IsValidHook(args[0])) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_NOT_CALLABLE_OR_UNDEFINED); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NOT_CALLABLE_OR_UNDEFINED); return false; } @@ -5970,7 +5970,7 @@ DebuggerFrame_setOnPop(JSContext* cx, unsigned argc, Value* vp) return false; (void) frame; // Silence GCC warning if (!IsValidHook(args[0])) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_NOT_CALLABLE_OR_UNDEFINED); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NOT_CALLABLE_OR_UNDEFINED); return false; } @@ -6051,7 +6051,7 @@ DebuggerGenericEval(JSContext* cx, const char* fullMethodName, const Value& code /* Check the first argument, the eval code string. */ if (!code.isString()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_NOT_EXPECTED_TYPE, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NOT_EXPECTED_TYPE, fullMethodName, "string", InformalValueTypeName(code)); return false; } @@ -6205,7 +6205,7 @@ DebuggerFrame_evalWithBindings(JSContext* cx, unsigned argc, Value* vp) static bool DebuggerFrame_construct(JSContext* cx, unsigned argc, Value* vp) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_NO_CONSTRUCTOR, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NO_CONSTRUCTOR, "Debugger.Frame"); return false; } @@ -6271,7 +6271,7 @@ DebuggerObject_checkThis(JSContext* cx, const CallArgs& args, const char* fnname } JSObject* thisobj = &args.thisv().toObject(); if (thisobj->getClass() != &DebuggerObject_class) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO, "Debugger.Object", fnname, thisobj->getClass()->name); return nullptr; } @@ -6283,7 +6283,7 @@ DebuggerObject_checkThis(JSContext* cx, const CallArgs& args, const char* fnname */ NativeObject* nthisobj = &thisobj->as(); if (!nthisobj->getPrivate()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO, "Debugger.Object", fnname, "prototype object"); return nullptr; } @@ -6310,7 +6310,7 @@ DebuggerObject_checkThis(JSContext* cx, const CallArgs& args, const char* fnname static bool DebuggerObject_construct(JSContext* cx, unsigned argc, Value* vp) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_NO_CONSTRUCTOR, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NO_CONSTRUCTOR, "Debugger.Object"); return false; } @@ -6818,7 +6818,7 @@ DebuggerObject_sealHelper(JSContext* cx, unsigned argc, Value* vp, SealHelperOp if (!ok) return false; if (!succeeded) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_CANT_CHANGE_EXTENSIBILITY); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CANT_CHANGE_EXTENSIBILITY); return false; } } @@ -6901,7 +6901,7 @@ ApplyOrCall(JSContext* cx, unsigned argc, Value* vp, ApplyOrCallMode mode) */ RootedValue calleev(cx, ObjectValue(*obj)); if (!obj->isCallable()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO, "Debugger.Object", "apply", obj->getClass()->name); return false; } @@ -6919,7 +6919,7 @@ ApplyOrCall(JSContext* cx, unsigned argc, Value* vp, ApplyOrCallMode mode) if (mode == ApplyMode) { if (args.length() >= 2 && !args[1].isNullOrUndefined()) { if (!args[1].isObject()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_BAD_APPLY_ARGS, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_BAD_APPLY_ARGS, js_apply_str); return false; } @@ -7086,7 +7086,7 @@ DebuggerObject_unwrap(JSContext* cx, unsigned argc, Value* vp) // and the wrapper is in a visible compartment, that's fine.) JSCompartment* unwrappedCompartment = unwrapped->compartment(); if (unwrappedCompartment->options().invisibleToDebugger()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_DEBUG_INVISIBLE_COMPARTMENT); return false; } @@ -7190,7 +7190,7 @@ DebuggerEnv_checkThis(JSContext* cx, const CallArgs& args, const char* fnname, } JSObject* thisobj = &args.thisv().toObject(); if (thisobj->getClass() != &DebuggerEnv_class) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO, "Debugger.Environment", fnname, thisobj->getClass()->name); return nullptr; } @@ -7202,7 +7202,7 @@ DebuggerEnv_checkThis(JSContext* cx, const CallArgs& args, const char* fnname, */ NativeObject* nthisobj = &thisobj->as(); if (!nthisobj->getPrivate()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO, "Debugger.Environment", fnname, "prototype object"); return nullptr; } @@ -7214,7 +7214,7 @@ DebuggerEnv_checkThis(JSContext* cx, const CallArgs& args, const char* fnname, if (requireDebuggee) { Rooted env(cx, static_cast(nthisobj->getPrivate())); if (!Debugger::fromChildJSObject(nthisobj)->observesGlobal(&env->global())) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_DEBUG_NOT_DEBUGGEE, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_DEBUG_NOT_DEBUGGEE, "Debugger.Environment", "environment"); return nullptr; } @@ -7239,7 +7239,7 @@ DebuggerEnv_checkThis(JSContext* cx, const CallArgs& args, const char* fnname, static bool DebuggerEnv_construct(JSContext* cx, unsigned argc, Value* vp) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_NO_CONSTRUCTOR, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NO_CONSTRUCTOR, "Debugger.Environment"); return false; } @@ -7298,7 +7298,7 @@ DebuggerEnv_getObject(JSContext* cx, unsigned argc, Value* vp) * possibly get its proto. */ if (IsDeclarative(env)) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_DEBUG_NO_SCOPE_OBJECT); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_DEBUG_NO_SCOPE_OBJECT); return false; } @@ -7506,7 +7506,7 @@ DebuggerEnv_setVariable(JSContext* cx, unsigned argc, Value* vp) if (!HasProperty(cx, env, id, &has)) return false; if (!has) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_DEBUG_VARIABLE_NOT_FOUND); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_DEBUG_VARIABLE_NOT_FOUND); return false; } @@ -7632,49 +7632,49 @@ JS_DefineDebuggerObject(JSContext* cx, HandleObject obj) objProto = obj->as().getOrCreateObjectPrototype(cx); if (!objProto) return false; - debugProto = js_InitClass(cx, obj, - objProto, &Debugger::jsclass, Debugger::construct, - 1, Debugger::properties, Debugger::methods, nullptr, nullptr, - debugCtor.address()); + debugProto = InitClass(cx, obj, + objProto, &Debugger::jsclass, Debugger::construct, + 1, Debugger::properties, Debugger::methods, nullptr, nullptr, + debugCtor.address()); if (!debugProto) return false; - frameProto = js_InitClass(cx, debugCtor, objProto, &DebuggerFrame_class, - DebuggerFrame_construct, 0, - DebuggerFrame_properties, DebuggerFrame_methods, - nullptr, nullptr); + frameProto = InitClass(cx, debugCtor, objProto, &DebuggerFrame_class, + DebuggerFrame_construct, 0, + DebuggerFrame_properties, DebuggerFrame_methods, + nullptr, nullptr); if (!frameProto) return false; - scriptProto = js_InitClass(cx, debugCtor, objProto, &DebuggerScript_class, - DebuggerScript_construct, 0, - DebuggerScript_properties, DebuggerScript_methods, - nullptr, nullptr); + scriptProto = InitClass(cx, debugCtor, objProto, &DebuggerScript_class, + DebuggerScript_construct, 0, + DebuggerScript_properties, DebuggerScript_methods, + nullptr, nullptr); if (!scriptProto) return false; - sourceProto = js_InitClass(cx, debugCtor, sourceProto, &DebuggerSource_class, - DebuggerSource_construct, 0, - DebuggerSource_properties, DebuggerSource_methods, - nullptr, nullptr); + sourceProto = InitClass(cx, debugCtor, sourceProto, &DebuggerSource_class, + DebuggerSource_construct, 0, + DebuggerSource_properties, DebuggerSource_methods, + nullptr, nullptr); if (!sourceProto) return false; - objectProto = js_InitClass(cx, debugCtor, objProto, &DebuggerObject_class, - DebuggerObject_construct, 0, - DebuggerObject_properties, DebuggerObject_methods, - nullptr, nullptr); + objectProto = InitClass(cx, debugCtor, objProto, &DebuggerObject_class, + DebuggerObject_construct, 0, + DebuggerObject_properties, DebuggerObject_methods, + nullptr, nullptr); if (!objectProto) return false; - envProto = js_InitClass(cx, debugCtor, objProto, &DebuggerEnv_class, - DebuggerEnv_construct, 0, - DebuggerEnv_properties, DebuggerEnv_methods, - nullptr, nullptr); + envProto = InitClass(cx, debugCtor, objProto, &DebuggerEnv_class, + DebuggerEnv_construct, 0, + DebuggerEnv_properties, DebuggerEnv_methods, + nullptr, nullptr); if (!envProto) return false; - memoryProto = js_InitClass(cx, debugCtor, objProto, &DebuggerMemory::class_, - DebuggerMemory::construct, 0, DebuggerMemory::properties, - DebuggerMemory::methods, nullptr, nullptr); + memoryProto = InitClass(cx, debugCtor, objProto, &DebuggerMemory::class_, + DebuggerMemory::construct, 0, DebuggerMemory::properties, + DebuggerMemory::methods, nullptr, nullptr); if (!memoryProto) return false; diff --git a/js/src/vm/DebuggerMemory.cpp b/js/src/vm/DebuggerMemory.cpp index b6b5fe1896..3c0fe41dd7 100644 --- a/js/src/vm/DebuggerMemory.cpp +++ b/js/src/vm/DebuggerMemory.cpp @@ -62,7 +62,7 @@ DebuggerMemory::getDebugger() /* static */ bool DebuggerMemory::construct(JSContext* cx, unsigned argc, Value* vp) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_NO_CONSTRUCTOR, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NO_CONSTRUCTOR, "Debugger.Memory"); return false; } @@ -79,13 +79,13 @@ DebuggerMemory::checkThis(JSContext* cx, CallArgs& args, const char* fnName) const Value& thisValue = args.thisv(); if (!thisValue.isObject()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_NOT_NONNULL_OBJECT, InformalValueTypeName(thisValue)); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NOT_NONNULL_OBJECT, InformalValueTypeName(thisValue)); return nullptr; } JSObject& thisObject = thisValue.toObject(); if (!thisObject.is()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO, class_.name, fnName, thisObject.getClass()->name); return nullptr; } @@ -95,7 +95,7 @@ DebuggerMemory::checkThis(JSContext* cx, CallArgs& args, const char* fnName) // of Debugger.Memory. It is the only object that is() but // doesn't have a Debugger instance. if (thisObject.as().getReservedSlot(JSSLOT_DEBUGGER).isUndefined()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO, class_.name, fnName, "prototype object"); return nullptr; } @@ -142,7 +142,7 @@ DebuggerMemory::setTrackingAllocationSites(JSContext* cx, unsigned argc, Value* for (GlobalObjectSet::Range r = dbg->debuggees.all(); !r.empty(); r.popFront()) { JSCompartment* compartment = r.front()->compartment(); if (compartment->hasObjectMetadataCallback()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_OBJECT_METADATA_CALLBACK_ALREADY_SET); return false; } @@ -180,7 +180,7 @@ DebuggerMemory::drainAllocationsLog(JSContext* cx, unsigned argc, Value* vp) Debugger* dbg = memory->getDebugger(); if (!dbg->trackingAllocationSites) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_NOT_TRACKING_ALLOCATIONS, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NOT_TRACKING_ALLOCATIONS, "drainAllocationsLog"); return false; } @@ -245,7 +245,7 @@ DebuggerMemory::setMaxAllocationsLogLength(JSContext* cx, unsigned argc, Value* return false; if (max < 1) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE, "(set maxAllocationsLogLength)'s parameter", "not a positive integer"); return false; @@ -283,7 +283,7 @@ DebuggerMemory::setAllocationSamplingProbability(JSContext* cx, unsigned argc, V return false; if (probability < 0.0 || probability > 1.0) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE, "(set allocationSamplingProbability)'s parameter", "not a number between 0 and 1"); return false; diff --git a/js/src/vm/ErrorObject.h b/js/src/vm/ErrorObject.h index c06b33f4c4..6faf277525 100644 --- a/js/src/vm/ErrorObject.h +++ b/js/src/vm/ErrorObject.h @@ -14,14 +14,14 @@ struct JSExnPrivate; + +namespace js { + /* * Initialize the exception constructor/prototype hierarchy. */ extern JSObject* -js_InitExceptionClasses(JSContext* cx, JS::HandleObject obj); - -namespace js { - +InitExceptionClasses(JSContext *cx, HandleObject obj); class ErrorObject : public NativeObject { static JSObject* @@ -32,7 +32,7 @@ class ErrorObject : public NativeObject /* For access to createProto. */ friend JSObject* - ::js_InitExceptionClasses(JSContext* cx, JS::HandleObject global); + js::InitExceptionClasses(JSContext *cx, HandleObject global); static bool init(JSContext* cx, Handle obj, JSExnType type, diff --git a/js/src/vm/ForOfIterator.cpp b/js/src/vm/ForOfIterator.cpp index e3824f10a8..94b764699f 100644 --- a/js/src/vm/ForOfIterator.cpp +++ b/js/src/vm/ForOfIterator.cpp @@ -72,7 +72,7 @@ ForOfIterator::init(HandleValue iterable, NonIterableBehavior nonIterableBehavio char* bytes = DecompileValueGenerator(cx, JSDVG_SEARCH_STACK, iterable, NullPtr()); if (!bytes) return false; - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_NOT_ITERABLE, bytes); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NOT_ITERABLE, bytes); js_free(bytes); return false; } diff --git a/js/src/vm/GlobalObject.cpp b/js/src/vm/GlobalObject.cpp index 42d4fb7a65..457fadabe4 100644 --- a/js/src/vm/GlobalObject.cpp +++ b/js/src/vm/GlobalObject.cpp @@ -47,13 +47,17 @@ struct ProtoTableEntry { ClassInitializerOp init; }; +namespace js { + #define DECLARE_PROTOTYPE_CLASS_INIT(name,code,init,clasp) \ extern JSObject* init(JSContext* cx, Handle obj); JS_FOR_EACH_PROTOTYPE(DECLARE_PROTOTYPE_CLASS_INIT) #undef DECLARE_PROTOTYPE_CLASS_INIT +} // namespace js + JSObject* -js_InitViaClassSpec(JSContext* cx, Handle obj) +js::InitViaClassSpec(JSContext* cx, Handle obj) { MOZ_CRASH("js_InitViaClassSpec() should not be called."); } @@ -105,7 +109,7 @@ GlobalObject::resolveConstructor(JSContext* cx, Handle global, JS // top of this file. The other lives in the ClassSpec for classes that // define it. Classes may use one or the other, but not both. ClassInitializerOp init = protoTable[key].init; - if (init == js_InitViaClassSpec) + if (init == InitViaClassSpec) init = nullptr; const Class* clasp = ProtoKeyToClass(key); @@ -396,7 +400,7 @@ GlobalObject::initSelfHostingBuiltins(JSContext* cx, Handle globa InitBareBuiltinCtor(cx, global, JSProto_Uint8Array) && InitBareBuiltinCtor(cx, global, JSProto_Uint32Array) && InitBareWeakMapCtor(cx, global) && - js_InitStopIterationClass(cx, global) && + InitStopIterationClass(cx, global) && InitSelfHostingCollectionIteratorFunctions(cx, global) && JS_DefineFunctions(cx, global, builtins); } @@ -423,7 +427,7 @@ GlobalObject::warnOnceAbout(JSContext* cx, HandleObject obj, uint32_t slot, unsi Rooted global(cx, &obj->global()); HeapSlot& v = global->getSlotRef(slot); if (v.isUndefined()) { - if (!JS_ReportErrorFlagsAndNumber(cx, JSREPORT_WARNING, js_GetErrorMessage, nullptr, + if (!JS_ReportErrorFlagsAndNumber(cx, JSREPORT_WARNING, GetErrorMessage, nullptr, errorNumber)) { return false; diff --git a/js/src/vm/GlobalObject.h b/js/src/vm/GlobalObject.h index 9942d6b8a9..e9592f55f4 100644 --- a/js/src/vm/GlobalObject.h +++ b/js/src/vm/GlobalObject.h @@ -20,14 +20,16 @@ #include "vm/ErrorObject.h" #include "vm/Runtime.h" -extern JSObject* -js_InitSharedArrayBufferClass(JSContext* cx, js::HandleObject obj); -extern JSObject* -js_InitStopIterationClass(JSContext* cx, js::HandleObject obj); namespace js { +extern JSObject* +InitSharedArrayBufferClass(JSContext *cx, HandleObject obj); + +extern JSObject* +InitStopIterationClass(JSContext* cx, HandleObject obj); + class Debugger; class TypedObjectModuleObject; diff --git a/js/src/vm/HelperThreads.cpp b/js/src/vm/HelperThreads.cpp index 7f72ec2852..49062c8b69 100644 --- a/js/src/vm/HelperThreads.cpp +++ b/js/src/vm/HelperThreads.cpp @@ -922,7 +922,7 @@ GlobalHelperThreadState::finishParseTask(JSContext* maybecx, JSRuntime* rt, void for (size_t i = 0; i < parseTask->errors.length(); i++) parseTask->errors[i]->throwError(cx); if (parseTask->overRecursed) - js_ReportOverRecursed(cx); + ReportOverRecursed(cx); if (cx->isExceptionPending()) return nullptr; @@ -1296,7 +1296,7 @@ js::StartOffThreadCompression(ExclusiveContext* cx, SourceCompressionTask* task) if (!HelperThreadState().compressionWorklist().append(task)) { if (JSContext* maybecx = cx->maybeJSContext()) - js_ReportOutOfMemory(maybecx); + ReportOutOfMemory(maybecx); return false; } @@ -1343,7 +1343,7 @@ SourceCompressionTask::complete() js_free(compressed); if (result == OOM) - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); else if (result == Aborted && !ss->ensureOwnsSource(cx)) result = OOM; } diff --git a/js/src/vm/Interpreter-inl.h b/js/src/vm/Interpreter-inl.h index d359a4c0e2..7c27439f88 100644 --- a/js/src/vm/Interpreter-inl.h +++ b/js/src/vm/Interpreter-inl.h @@ -92,7 +92,7 @@ static inline bool GuardFunApplyArgumentsOptimization(JSContext* cx, AbstractFramePtr frame, CallArgs& args) { if (args.length() == 2 && IsOptimizedArguments(frame, args[1])) { - if (!IsNativeFunction(args.calleev(), js_fun_apply)) { + if (!IsNativeFunction(args.calleev(), js::fun_apply)) { RootedScript script(cx, frame.script()); if (!JSScript::argumentsOptimizationFailed(cx, script)) return false; @@ -186,7 +186,7 @@ ValuePropertyBearer(JSContext* cx, InterpreterFrame* fp, HandleValue v, int spin return GlobalObject::getOrCreateBooleanPrototype(cx, global); MOZ_ASSERT(v.isNull() || v.isUndefined()); - js_ReportIsNullOrUndefined(cx, spindex, v, NullPtr()); + ReportIsNullOrUndefined(cx, spindex, v, NullPtr()); return nullptr; } @@ -230,7 +230,7 @@ FetchName(JSContext* cx, HandleObject obj, HandleObject obj2, HandlePropertyName } JSAutoByteString printable; if (AtomToPrintableString(cx, name, &printable)) - js_ReportIsNotDefined(cx, printable.ptr()); + ReportIsNotDefined(cx, printable.ptr()); return false; } @@ -355,7 +355,7 @@ DefVarOrConstOperation(JSContext* cx, HandleObject varobj, HandlePropertyName dn JSAutoByteString bytes; if (AtomToPrintableString(cx, dn, &bytes)) { JS_ALWAYS_FALSE(JS_ReportErrorFlagsAndNumber(cx, JSREPORT_ERROR, - js_GetErrorMessage, + GetErrorMessage, nullptr, JSMSG_REDECLARED_VAR, desc.isReadonly() ? "const" : "var", bytes.ptr())); @@ -636,7 +636,7 @@ InitArrayElemOperation(JSContext* cx, jsbytecode* pc, HandleObject obj, uint32_t } if (op == JSOP_INITELEM_INC && index == INT32_MAX) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_SPREAD_TOO_LARGE); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_SPREAD_TOO_LARGE); return false; } diff --git a/js/src/vm/Interpreter.cpp b/js/src/vm/Interpreter.cpp index 510a56b246..60429fe00d 100644 --- a/js/src/vm/Interpreter.cpp +++ b/js/src/vm/Interpreter.cpp @@ -236,7 +236,7 @@ GetPropertyOperation(JSContext* cx, InterpreterFrame* fp, HandleScript script, j NativeObject* proto = GlobalObject::getOrCreateNumberPrototype(cx, global); if (!proto) return false; - if (ClassMethodIsNative(cx, proto, &NumberObject::class_, id, js_num_toString)) + if (ClassMethodIsNative(cx, proto, &NumberObject::class_, id, num_toString)) obj = proto; } @@ -3598,7 +3598,7 @@ DEFAULT() { char numBuf[12]; JS_snprintf(numBuf, sizeof numBuf, "%d", *REGS.pc); - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_BAD_BYTECODE, numBuf); goto error; } @@ -3722,7 +3722,7 @@ js::GetScopeName(JSContext* cx, HandleObject scopeChain, HandlePropertyName name if (!shape) { JSAutoByteString printable; if (AtomToPrintableString(cx, name, &printable)) - js_ReportIsNotDefined(cx, printable.ptr()); + ReportIsNotDefined(cx, printable.ptr()); return false; } @@ -3858,7 +3858,7 @@ js::DefFunOperation(JSContext* cx, HandleScript script, HandleObject scopeChain, if (shape->isAccessorDescriptor() || !shape->writable() || !shape->enumerable()) { JSAutoByteString bytes; if (AtomToPrintableString(cx, name, &bytes)) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_CANT_REDEFINE_PROP, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CANT_REDEFINE_PROP, bytes.ptr()); } @@ -3880,7 +3880,7 @@ js::DefFunOperation(JSContext* cx, HandleScript script, HandleObject scopeChain, bool js::SetCallOperation(JSContext* cx) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_BAD_LEFTSIDE_OF_ASS); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_BAD_LEFTSIDE_OF_ASS); return false; } @@ -4147,7 +4147,7 @@ js::SpreadCallOperation(JSContext* cx, HandleScript script, jsbytecode* pc, Hand JSOp op = JSOp(*pc); if (length > ARGS_LENGTH_MAX) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, op == JSOP_SPREADNEW ? JSMSG_TOO_MANY_CON_SPREADARGS : JSMSG_TOO_MANY_FUN_SPREADARGS); return false; @@ -4206,7 +4206,7 @@ js::ReportUninitializedLexical(JSContext* cx, HandlePropertyName name) { JSAutoByteString printable; if (AtomToPrintableString(cx, name, &printable)) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_UNINITIALIZED_LEXICAL, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_UNINITIALIZED_LEXICAL, printable.ptr()); } } diff --git a/js/src/vm/Interpreter.h b/js/src/vm/Interpreter.h index e74e3fc102..a194a72a7c 100644 --- a/js/src/vm/Interpreter.h +++ b/js/src/vm/Interpreter.h @@ -51,12 +51,12 @@ enum MaybeConstruct { * before it reaches |v|. If it's -1, the decompiler will search the stack. */ extern bool -ReportIsNotFunction(JSContext* cx, HandleValue v, int numToSkip = -1, +ReportIsNotFunction(JSContext* cx, HandleValue v, int numToSkip, MaybeConstruct construct = NO_CONSTRUCT); /* See ReportIsNotFunction comment for the meaning of numToSkip. */ extern JSObject* -ValueToCallable(JSContext* cx, HandleValue v, int numToSkip = -1, +ValueToCallable(JSContext *cx, HandleValue v, int numToSkip, MaybeConstruct construct = NO_CONSTRUCT); /* diff --git a/js/src/vm/JSONParser.cpp b/js/src/vm/JSONParser.cpp index 8f3f5be118..77544f6c24 100644 --- a/js/src/vm/JSONParser.cpp +++ b/js/src/vm/JSONParser.cpp @@ -94,7 +94,7 @@ JSONParser::error(const char* msg) char lineNumber[MaxWidth]; JS_snprintf(lineNumber, sizeof lineNumber, "%lu", line); - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_JSON_BAD_PARSE, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_JSON_BAD_PARSE, msg, lineNumber, columnNumber); } } diff --git a/js/src/vm/NativeObject-inl.h b/js/src/vm/NativeObject-inl.h index ee0500308f..600c84c3c4 100644 --- a/js/src/vm/NativeObject-inl.h +++ b/js/src/vm/NativeObject-inl.h @@ -615,7 +615,7 @@ WarnIfNotConstructing(JSContext* cx, const CallArgs& args, const char* builtinNa { if (args.isConstructing()) return true; - return JS_ReportErrorFlagsAndNumber(cx, JSREPORT_WARNING, js_GetErrorMessage, nullptr, + return JS_ReportErrorFlagsAndNumber(cx, JSREPORT_WARNING, GetErrorMessage, nullptr, JSMSG_BUILTIN_CTOR_NO_NEW, builtinName); } diff --git a/js/src/vm/NativeObject.cpp b/js/src/vm/NativeObject.cpp index 474e9a21a3..528abe200d 100644 --- a/js/src/vm/NativeObject.cpp +++ b/js/src/vm/NativeObject.cpp @@ -53,7 +53,7 @@ PropDesc::checkGetter(JSContext* cx) { if (hasGet_) { if (!IsCallable(get_) && !get_.isUndefined()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_BAD_GET_SET_FIELD, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_BAD_GET_SET_FIELD, js_getter_str); return false; } @@ -66,7 +66,7 @@ PropDesc::checkSetter(JSContext* cx) { if (hasSet_) { if (!IsCallable(set_) && !set_.isUndefined()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_BAD_GET_SET_FIELD, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_BAD_GET_SET_FIELD, js_setter_str); return false; } @@ -626,7 +626,7 @@ NativeObject::maybeDensifySparseElements(js::ExclusiveContext* cx, HandleNativeO RootedShape shape(cx, obj->lastProperty()); while (!shape->isEmptyShape()) { uint32_t index; - if (js_IdIsIndex(shape->propid(), &index)) { + if (IdIsIndex(shape->propid(), &index)) { if (shape->attributes() == JSPROP_ENUMERATE && shape->hasDefaultGetter() && shape->hasDefaultSetter()) @@ -671,7 +671,7 @@ NativeObject::maybeDensifySparseElements(js::ExclusiveContext* cx, HandleNativeO while (!shape->isEmptyShape()) { jsid id = shape->propid(); uint32_t index; - if (js_IdIsIndex(id, &index)) { + if (IdIsIndex(id, &index)) { value = obj->getSlot(shape->slot()); /* @@ -979,7 +979,7 @@ NativeObject::allocSlot(ExclusiveContext* cx, HandleNativeObject obj, uint32_t* } if (slot >= SHAPE_MAXIMUM_SLOT) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return false; } @@ -1175,7 +1175,7 @@ DefinePropertyOrElement(ExclusiveContext* cx, HandleNativeObject obj, HandleId i } uint32_t index; - if (js_IdIsIndex(id, &index)) { + if (IdIsIndex(id, &index)) { bool definesPast; if (!WouldDefinePastNonwritableLength(cx, arr, index, setterIsStrict, &definesPast)) return false; @@ -1772,8 +1772,8 @@ GetNonexistentProperty(JSContext* cx, HandleNativeObject obj, HandleId id, // If we are doing a name lookup, this is a ReferenceError. if (nameLookup) { JSAutoByteString printable; - if (js_ValueToPrintable(cx, IdToValue(id), &printable)) - js_ReportIsNotDefined(cx, printable.ptr()); + if (ValueToPrintable(cx, IdToValue(id), &printable)) + ReportIsNotDefined(cx, printable.ptr()); return false; } @@ -1946,7 +1946,7 @@ MaybeReportUndeclaredVarAssignment(JSContext* cx, JSString* propname) JS_ReportErrorFlagsAndNumber(cx, (JSREPORT_WARNING | JSREPORT_STRICT | JSREPORT_STRICT_MODE_ERROR), - js_GetErrorMessage, nullptr, + GetErrorMessage, nullptr, JSMSG_UNDECLARED_VAR, bytes.ptr()); } @@ -2145,7 +2145,7 @@ NativeSet(JSContext* cx, HandleNativeObject obj, HandleObject receiver, * or throw if we're in strict mode. */ if (!shape->hasGetterValue() && shape->hasDefaultSetter()) - return js_ReportGetterOnlyAssignment(cx, strict); + return ReportGetterOnlyAssignment(cx, strict); } RootedValue ovp(cx, vp); @@ -2187,7 +2187,7 @@ SetExistingProperty(JSContext* cx, HandleNativeObject obj, HandleObject receiver /* ES5 8.12.4 [[Put]] step 2. */ if (shape->isAccessorDescriptor()) { if (shape->hasDefaultSetter()) - return js_ReportGetterOnlyAssignment(cx, strict); + return ReportGetterOnlyAssignment(cx, strict); } else { MOZ_ASSERT(shape->isDataDescriptor()); diff --git a/js/src/vm/NumberObject.h b/js/src/vm/NumberObject.h index 69d53f0e49..67bfb34b7b 100644 --- a/js/src/vm/NumberObject.h +++ b/js/src/vm/NumberObject.h @@ -38,7 +38,7 @@ class NumberObject : public NativeObject /* For access to init, as Number.prototype is special. */ friend JSObject* - ::js_InitNumberClass(JSContext* cx, js::HandleObject global); + js::InitNumberClass(JSContext *cx, HandleObject global); }; } // namespace js diff --git a/js/src/vm/RegExpObject.cpp b/js/src/vm/RegExpObject.cpp index ef3149cee7..2cad0d735a 100644 --- a/js/src/vm/RegExpObject.cpp +++ b/js/src/vm/RegExpObject.cpp @@ -888,7 +888,7 @@ RegExpCompartment::init(JSContext* cx) { if (!set_.init(0)) { if (cx) - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return false; } @@ -954,7 +954,7 @@ RegExpCompartment::get(JSContext* cx, JSAtom* source, RegExpFlag flags, RegExpGu return false; if (!set_.add(p, shared)) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return false; } @@ -1064,7 +1064,7 @@ js::ParseRegExpFlags(JSContext* cx, JSString* flagStr, RegExpFlag* flagsOut) char charBuf[2]; charBuf[0] = char(lastParsed); charBuf[1] = '\0'; - JS_ReportErrorFlagsAndNumber(cx, JSREPORT_ERROR, js_GetErrorMessage, nullptr, + JS_ReportErrorFlagsAndNumber(cx, JSREPORT_ERROR, GetErrorMessage, nullptr, JSMSG_BAD_REGEXP_FLAG, charBuf); return false; } diff --git a/js/src/vm/RegExpStatics.h b/js/src/vm/RegExpStatics.h index eec7e237b0..ad4856fd97 100644 --- a/js/src/vm/RegExpStatics.h +++ b/js/src/vm/RegExpStatics.h @@ -62,7 +62,7 @@ class RegExpStatics buffer->bufferLink = bufferLink; bufferLink = buffer; if (!buffer->matches.allocOrExpandArray(matches.length())) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return false; } return true; @@ -486,7 +486,7 @@ RegExpStatics::updateFromMatchPairs(JSContext* cx, JSLinearString* input, MatchP matchesInput, input); if (!matches.initArrayFrom(newPairs)) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return false; } diff --git a/js/src/vm/Runtime.cpp b/js/src/vm/Runtime.cpp index 003a7031c6..fc43d646b8 100644 --- a/js/src/vm/Runtime.cpp +++ b/js/src/vm/Runtime.cpp @@ -89,13 +89,13 @@ PerThreadData::PerThreadData(JSRuntime* runtime) PerThreadData::~PerThreadData() { if (dtoaState) - js_DestroyDtoaState(dtoaState); + DestroyDtoaState(dtoaState); } bool PerThreadData::init() { - dtoaState = js_NewDtoaState(); + dtoaState = NewDtoaState(); if (!dtoaState) return false; @@ -561,7 +561,7 @@ InvokeInterruptCallback(JSContext* cx) chars = stableChars.twoByteRange().start().get(); else chars = MOZ_UTF16("(stack not available)"); - JS_ReportErrorFlagsAndNumberUC(cx, JSREPORT_WARNING, js_GetErrorMessage, nullptr, + JS_ReportErrorFlagsAndNumberUC(cx, JSREPORT_WARNING, GetErrorMessage, nullptr, JSMSG_TERMINATED, chars); return false; @@ -626,7 +626,7 @@ JSRuntime::createMathCache(JSContext* cx) MathCache* newMathCache = js_new(); if (!newMathCache) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return nullptr; } @@ -740,7 +740,7 @@ JSRuntime::onOutOfMemory(void* p, size_t nbytes, JSContext* cx) if (p) return p; if (cx) - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return nullptr; } diff --git a/js/src/vm/Runtime.h b/js/src/vm/Runtime.h index c806ba0464..8900880438 100644 --- a/js/src/vm/Runtime.h +++ b/js/src/vm/Runtime.h @@ -64,17 +64,18 @@ extern mozilla::ThreadLocal TlsPerThreadData; struct DtoaState; -extern MOZ_COLD void -js_ReportOutOfMemory(js::ExclusiveContext* cx); - -extern MOZ_COLD void -js_ReportAllocationOverflow(js::ExclusiveContext* maybecx); - -extern MOZ_COLD void -js_ReportOverRecursed(js::ExclusiveContext* cx); - namespace js { +extern MOZ_COLD void +ReportOutOfMemory(ExclusiveContext *cx); + +extern MOZ_COLD void +ReportAllocationOverflow(ExclusiveContext *maybecx); + +extern MOZ_COLD void +ReportOverRecursed(ExclusiveContext *cx); + + class Activation; class ActivationIterator; class AsmJSActivation; @@ -514,7 +515,7 @@ class PerThreadData : public PerThreadDataFriendFields /* * When this flag is non-zero, any attempt to GC will be skipped. It is used - * to suppress GC when reporting an OOM (see js_ReportOutOfMemory) and in + * to suppress GC when reporting an OOM (see ReportOutOfMemory) and in * debugging facilities that cannot tolerate a GC and would rather OOM * immediately, such as utilities exposed to GDB. Setting this flag is * extremely dangerous and should only be used when in an OOM situation or @@ -1273,7 +1274,7 @@ struct JSRuntime : public JS::shadow::Runtime, void updateMallocCounter(size_t nbytes); void updateMallocCounter(JS::Zone* zone, size_t nbytes); - void reportAllocationOverflow() { js_ReportAllocationOverflow(nullptr); } + void reportAllocationOverflow() { js::ReportAllocationOverflow(nullptr); } /* * The function must be called outside the GC lock. diff --git a/js/src/vm/SavedStacks.cpp b/js/src/vm/SavedStacks.cpp index 753472cddf..5ec9ea77a6 100644 --- a/js/src/vm/SavedStacks.cpp +++ b/js/src/vm/SavedStacks.cpp @@ -301,7 +301,7 @@ SavedFrame::isSelfHosted() /* static */ bool SavedFrame::construct(JSContext* cx, unsigned argc, Value* vp) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_NO_CONSTRUCTOR, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NO_CONSTRUCTOR, "SavedFrame"); return false; } @@ -341,13 +341,13 @@ SavedFrame::checkThis(JSContext* cx, CallArgs& args, const char* fnName, const Value& thisValue = args.thisv(); if (!thisValue.isObject()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_NOT_NONNULL_OBJECT, InformalValueTypeName(thisValue)); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NOT_NONNULL_OBJECT, InformalValueTypeName(thisValue)); return false; } JSObject* thisObject = CheckedUnwrap(&thisValue.toObject()); if (!thisObject || !thisObject->is()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO, SavedFrame::class_.name, fnName, thisObject ? thisObject->getClass()->name : "object"); return false; @@ -357,7 +357,7 @@ SavedFrame::checkThis(JSContext* cx, CallArgs& args, const char* fnName, // instances, however doesn't actually represent a captured stack frame. It // is the only object that is() but doesn't have a source. if (thisObject->as().getReservedSlot(JSSLOT_SOURCE).isNull()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO, SavedFrame::class_.name, fnName, "prototype object"); return false; } diff --git a/js/src/vm/ScopeObject.cpp b/js/src/vm/ScopeObject.cpp index 256615593d..a87b81e9ce 100644 --- a/js/src/vm/ScopeObject.cpp +++ b/js/src/vm/ScopeObject.cpp @@ -1538,7 +1538,7 @@ class DebugScopeProxy : public BaseProxyHandler return false; if (!argsObj) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_DEBUG_NOT_LIVE, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_DEBUG_NOT_LIVE, "Debugger scope"); return false; } @@ -1578,7 +1578,7 @@ class DebugScopeProxy : public BaseProxyHandler case ACCESS_GENERIC: return JS_GetOwnPropertyDescriptorById(cx, scope, id, desc); case ACCESS_LOST: - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_DEBUG_OPTIMIZED_OUT); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_DEBUG_OPTIMIZED_OUT); return false; default: MOZ_CRASH("bad AccessResult"); @@ -1592,7 +1592,7 @@ class DebugScopeProxy : public BaseProxyHandler return false; if (!argsObj) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_DEBUG_NOT_LIVE, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_DEBUG_NOT_LIVE, "Debugger scope"); return false; } @@ -1622,7 +1622,7 @@ class DebugScopeProxy : public BaseProxyHandler case ACCESS_GENERIC: return GetProperty(cx, scope, scope, id, vp); case ACCESS_LOST: - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_DEBUG_OPTIMIZED_OUT); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_DEBUG_OPTIMIZED_OUT); return false; default: MOZ_CRASH("bad AccessResult"); @@ -1893,7 +1893,7 @@ DebugScopeObject::isOptimizedOut() const } bool -js_IsDebugScopeSlow(ProxyObject* proxy) +js::IsDebugScopeSlow(ProxyObject *proxy) { MOZ_ASSERT(proxy->hasClass(&ProxyObject::class_)); return proxy->handler() == &DebugScopeProxy::singleton; @@ -2058,7 +2058,7 @@ DebugScopes::ensureCompartmentData(JSContext* cx) if (c->debugScopes) js_delete(c->debugScopes); c->debugScopes = nullptr; - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return nullptr; } @@ -2092,7 +2092,7 @@ DebugScopes::addDebugScope(JSContext* cx, ScopeObject& scope, DebugScopeObject& MOZ_ASSERT(!scopes->proxiedScopes.has(&scope)); if (!scopes->proxiedScopes.put(&scope, &debugScope)) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return false; } @@ -2136,7 +2136,7 @@ DebugScopes::addDebugScope(JSContext* cx, const ScopeIter& si, DebugScopeObject& MissingScopeKey key(si); MOZ_ASSERT(!scopes->missingScopes.has(key)); if (!scopes->missingScopes.put(key, ReadBarriered(&debugScope))) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return false; } @@ -2145,7 +2145,7 @@ DebugScopes::addDebugScope(JSContext* cx, const ScopeIter& si, DebugScopeObject& if (si.withinInitialFrame()) { MOZ_ASSERT(!scopes->liveScopes.has(&debugScope.scope())); if (!scopes->liveScopes.put(&debugScope.scope(), LiveScopeVal(si))) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return false; } liveScopesPostWriteBarrier(cx->runtime(), &scopes->liveScopes, &debugScope.scope()); diff --git a/js/src/vm/ScopeObject.h b/js/src/vm/ScopeObject.h index 01d74575ac..d76d053880 100644 --- a/js/src/vm/ScopeObject.h +++ b/js/src/vm/ScopeObject.h @@ -990,6 +990,9 @@ class DebugScopes static void onCompartmentUnsetIsDebuggee(JSCompartment* c); }; +extern bool +IsDebugScopeSlow(ProxyObject *proxy); + } /* namespace js */ template<> @@ -1015,11 +1018,9 @@ template<> inline bool JSObject::is() const { - extern bool js_IsDebugScopeSlow(js::ProxyObject* proxy); - // Note: don't use is() here -- it also matches subclasses! return hasClass(&js::ProxyObject::class_) && - js_IsDebugScopeSlow(&const_cast(this)->as()); + IsDebugScopeSlow(&const_cast(this)->as()); } template<> diff --git a/js/src/vm/SelfHosting.cpp b/js/src/vm/SelfHosting.cpp index 7f63235efd..b87240a8a3 100644 --- a/js/src/vm/SelfHosting.cpp +++ b/js/src/vm/SelfHosting.cpp @@ -193,7 +193,7 @@ js::intrinsic_ThrowError(JSContext* cx, unsigned argc, Value* vp) uint32_t errorNumber = args[0].toInt32(); #ifdef DEBUG - const JSErrorFormatString* efs = js_GetErrorMessage(nullptr, errorNumber); + const JSErrorFormatString* efs = GetErrorMessage(nullptr, errorNumber); MOZ_ASSERT(efs->argCount == args.length() - 1); #endif @@ -214,7 +214,7 @@ js::intrinsic_ThrowError(JSContext* cx, unsigned argc, Value* vp) return false; } - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, errorNumber, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, errorNumber, errorArgs[0].ptr(), errorArgs[1].ptr(), errorArgs[2].ptr()); return false; } @@ -798,7 +798,7 @@ intrinsic_RuntimeDefaultLocale(JSContext* cx, unsigned argc, Value* vp) const char* locale = cx->runtime()->getDefaultLocale(); if (!locale) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_DEFAULT_LOCALE_ERROR); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_DEFAULT_LOCALE_ERROR); return false; } @@ -864,7 +864,7 @@ static const JSFunctionSpec intrinsic_functions[] = { JS_FN("std_Date_valueOf", date_valueOf, 0,0), JS_FN("std_Function_bind", fun_bind, 1,0), - JS_FN("std_Function_apply", js_fun_apply, 2,0), + JS_FN("std_Function_apply", fun_apply, 2,0), JS_FN("std_Math_floor", math_floor, 1,0), JS_FN("std_Math_max", math_max, 2,0), @@ -876,7 +876,7 @@ static const JSFunctionSpec intrinsic_functions[] = { JS_FN("std_Map_has", MapObject::has, 1,0), JS_FN("std_Map_iterator", MapObject::entries, 0,0), - JS_FN("std_Number_valueOf", js_num_valueOf, 0,0), + JS_FN("std_Number_valueOf", num_valueOf, 0,0), JS_FN("std_Object_create", obj_create, 2,0), JS_FN("std_Object_propertyIsEnumerable", obj_propertyIsEnumerable, 1,0), @@ -890,7 +890,7 @@ static const JSFunctionSpec intrinsic_functions[] = { JS_FN("std_Set_iterator", SetObject::values, 0,0), JS_FN("std_String_fromCharCode", str_fromCharCode, 1,0), - JS_FN("std_String_charCodeAt", js_str_charCodeAt, 1,0), + JS_FN("std_String_charCodeAt", str_charCodeAt, 1,0), JS_FN("std_String_indexOf", str_indexOf, 1,0), JS_FN("std_String_lastIndexOf", str_lastIndexOf, 1,0), JS_FN("std_String_match", str_match, 1,0), diff --git a/js/src/vm/Shape-inl.h b/js/src/vm/Shape-inl.h index 132b37c782..7426eb58e3 100644 --- a/js/src/vm/Shape-inl.h +++ b/js/src/vm/Shape-inl.h @@ -53,7 +53,7 @@ Shape::set(JSContext* cx, HandleNativeObject obj, HandleObject receiver, bool st } if (attrs & JSPROP_GETTER) - return js_ReportGetterOnlyAssignment(cx, strict); + return ReportGetterOnlyAssignment(cx, strict); if (!setterOp()) return true; @@ -109,7 +109,7 @@ Shape::new_(ExclusiveContext* cx, StackShape& unrootedOther, uint32_t nfixed) RootedGeneric other(cx, &unrootedOther); Shape* shape = other->isAccessorShape() ? NewGCAccessorShape(cx) : NewGCShape(cx); if (!shape) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return nullptr; } diff --git a/js/src/vm/Shape.cpp b/js/src/vm/Shape.cpp index cd3a648c03..dc3791064f 100644 --- a/js/src/vm/Shape.cpp +++ b/js/src/vm/Shape.cpp @@ -116,7 +116,7 @@ Shape::makeOwnBaseShape(ExclusiveContext* cx) MOZ_ASSERT(!base()->isOwned()); assertSameCompartmentDebugOnly(cx, compartment()); - BaseShape* nbase = js_NewGCBaseShape(cx); + BaseShape* nbase = NewGCBaseShape(cx); if (!nbase) return false; @@ -308,7 +308,7 @@ ShapeTable::grow(ExclusiveContext* cx) MOZ_ASSERT(entryCount_ + removedCount_ <= size - 1); if (!change(delta, cx) && entryCount_ + removedCount_ == size - 1) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return false; } return true; @@ -442,7 +442,7 @@ js::NativeObject::toDictionaryMode(ExclusiveContext* cx) Shape* dprop = shape->isAccessorShape() ? NewGCAccessorShape(cx) : NewGCShape(cx); if (!dprop) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return false; } @@ -459,7 +459,7 @@ js::NativeObject::toDictionaryMode(ExclusiveContext* cx) } if (!Shape::hashify(cx, root)) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return false; } @@ -564,7 +564,7 @@ NativeObject::addPropertyInternal(ExclusiveContext* cx, RootedShape last(cx, obj->lastProperty()); uint32_t index; - bool indexed = js_IdIsIndex(id, &index); + bool indexed = IdIsIndex(id, &index); Rooted nbase(cx); if (!indexed) { @@ -633,7 +633,7 @@ js::ReshapeForParentAndAllocKind(JSContext* cx, Shape* shape, TaggedProto proto, id = ids[i]; uint32_t index; - bool indexed = js_IdIsIndex(id, &index); + bool indexed = IdIsIndex(id, &index); Rooted nbase(cx, newShape->base()->unowned()); if (indexed) { @@ -692,7 +692,7 @@ NativeObject::putProperty(ExclusiveContext* cx, HandleNativeObject obj, HandleId if (obj->is()) { ArrayObject* arr = &obj->as(); uint32_t index; - if (js_IdIsIndex(id, &index)) + if (IdIsIndex(id, &index)) MOZ_ASSERT(index < arr->length() || arr->lengthIsWritable()); } #endif @@ -750,7 +750,7 @@ NativeObject::putProperty(ExclusiveContext* cx, HandleNativeObject obj, HandleId Rooted nbase(cx); { uint32_t index; - bool indexed = js_IdIsIndex(id, &index); + bool indexed = IdIsIndex(id, &index); StackBaseShape base(obj->lastProperty()->base()); if (indexed) base.flags |= BaseShape::INDEXED; @@ -1368,7 +1368,7 @@ BaseShape::getUnowned(ExclusiveContext* cx, StackBaseShape& base) RootedGeneric root(cx, &base); - BaseShape* nbase_ = js_NewGCBaseShape(cx); + BaseShape* nbase_ = NewGCBaseShape(cx); if (!nbase_) return nullptr; @@ -1627,7 +1627,7 @@ EmptyShape::new_(ExclusiveContext* cx, Handle base, uint32_t { Shape* shape = NewGCShape(cx); if (!shape) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return nullptr; } diff --git a/js/src/vm/SharedArrayObject.cpp b/js/src/vm/SharedArrayObject.cpp index 80230681d5..2ae8f33975 100644 --- a/js/src/vm/SharedArrayObject.cpp +++ b/js/src/vm/SharedArrayObject.cpp @@ -212,7 +212,7 @@ SharedArrayBufferObject::class_constructor(JSContext* cx, unsigned argc, Value* args.rval().set(args[0]); return true; } - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_SHARED_ARRAY_BAD_OBJECT); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_SHARED_ARRAY_BAD_OBJECT); return false; } @@ -221,7 +221,7 @@ SharedArrayBufferObject::class_constructor(JSContext* cx, unsigned argc, Value* if (!ToLengthClamped(cx, args.get(0), &length, &overflow)) { // Bug 1068458: Limit length to 2^31-1. if (overflow || length > INT32_MAX) - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_SHARED_ARRAY_BAD_LENGTH); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_SHARED_ARRAY_BAD_LENGTH); return false; } @@ -324,7 +324,7 @@ const Class SharedArrayBufferObject::class_ = { }; JSObject* -js_InitSharedArrayBufferClass(JSContext* cx, HandleObject obj) +js::InitSharedArrayBufferClass(JSContext *cx, HandleObject obj) { MOZ_ASSERT(obj->isNative()); Rooted global(cx, &obj->as()); diff --git a/js/src/vm/SharedTypedArrayObject.cpp b/js/src/vm/SharedTypedArrayObject.cpp index 7721caa247..e573b99b61 100644 --- a/js/src/vm/SharedTypedArrayObject.cpp +++ b/js/src/vm/SharedTypedArrayObject.cpp @@ -238,7 +238,7 @@ class SharedTypedArrayObjectTemplate : public SharedTypedArrayObject args.rval().set(args[0]); return true; } - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_SHARED_TYPED_ARRAY_BAD_LENGTH); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_SHARED_TYPED_ARRAY_BAD_LENGTH); return false; } @@ -263,7 +263,7 @@ class SharedTypedArrayObjectTemplate : public SharedTypedArrayObject if (!ToLengthClamped(cx, args[0], &length, &overflow)) { // Bug 1068458: Limit length to 2^31-1. if (overflow || length > INT32_MAX) - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_BAD_ARRAY_LENGTH); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_BAD_ARRAY_LENGTH); return nullptr; } return fromLength(cx, length); @@ -273,7 +273,7 @@ class SharedTypedArrayObjectTemplate : public SharedTypedArrayObject RootedObject dataObj(cx, &args.get(0).toObject()); if (!UncheckedUnwrap(dataObj)->is()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_SHARED_TYPED_ARRAY_BAD_OBJECT); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_SHARED_TYPED_ARRAY_BAD_OBJECT); return nullptr; } @@ -285,7 +285,7 @@ class SharedTypedArrayObjectTemplate : public SharedTypedArrayObject return nullptr; if (numByteOffset < 0 || numByteOffset > MAX_BYTEOFFSET) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_SHARED_TYPED_ARRAY_ARG_RANGE, "'byteOffset'"); return nullptr; } @@ -296,7 +296,7 @@ class SharedTypedArrayObjectTemplate : public SharedTypedArrayObject if (!ToLengthClamped(cx, args[2], &length, &overflow)) { // Bug 1068458: Limit length to 2^31-1. if (overflow || length > INT32_MAX) - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_SHARED_TYPED_ARRAY_ARG_RANGE, "'length'"); return nullptr; } @@ -412,7 +412,7 @@ class SharedTypedArrayObjectTemplate : public SharedTypedArrayObject HandleObject proto) { if (!ObjectClassIs(bufobj, ESClass_SharedArrayBuffer, cx)) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_SHARED_TYPED_ARRAY_BAD_OBJECT); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_SHARED_TYPED_ARRAY_BAD_OBJECT); return nullptr; // must be SharedArrayBuffer } @@ -426,7 +426,7 @@ class SharedTypedArrayObjectTemplate : public SharedTypedArrayObject if (byteOffset > buffer->byteLength() || byteOffset % sizeof(NativeType) != 0) { // Invalid byteOffset. - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_SHARED_TYPED_ARRAY_BAD_ARGS); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_SHARED_TYPED_ARRAY_BAD_ARGS); return nullptr; } @@ -434,14 +434,14 @@ class SharedTypedArrayObjectTemplate : public SharedTypedArrayObject if (length == LENGTH_NOT_PROVIDED) { if (bytesAvailable % sizeof(NativeType) != 0) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_SHARED_TYPED_ARRAY_BAD_ARGS); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_SHARED_TYPED_ARRAY_BAD_ARGS); return nullptr; } length = bytesAvailable / sizeof(NativeType); } if (length > MAX_LENGTH / sizeof(NativeType) || length * sizeof(NativeType) > bytesAvailable) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_BAD_ARRAY_LENGTH); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_BAD_ARRAY_LENGTH); return nullptr; } @@ -459,7 +459,7 @@ class SharedTypedArrayObjectTemplate : public SharedTypedArrayObject fromLength(JSContext* cx, uint32_t nelements) { if (nelements > MAX_LENGTH / sizeof(NativeType)) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_BAD_ARRAY_LENGTH); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_BAD_ARRAY_LENGTH); return nullptr; } Rooted buffer( diff --git a/js/src/vm/Stack-inl.h b/js/src/vm/Stack-inl.h index ed998533db..27f7056b62 100644 --- a/js/src/vm/Stack-inl.h +++ b/js/src/vm/Stack-inl.h @@ -258,7 +258,7 @@ InterpreterStack::allocateFrame(JSContext* cx, size_t size) maxFrames = MAX_FRAMES; if (MOZ_UNLIKELY(frameCount_ >= maxFrames)) { - js_ReportOverRecursed(cx); + ReportOverRecursed(cx); return nullptr; } diff --git a/js/src/vm/String-inl.h b/js/src/vm/String-inl.h index 433a55546a..5fba2cefb1 100644 --- a/js/src/vm/String-inl.h +++ b/js/src/vm/String-inl.h @@ -97,7 +97,7 @@ MOZ_ALWAYS_INLINE bool JSString::validateLength(js::ExclusiveContext* maybecx, size_t length) { if (MOZ_UNLIKELY(length > JSString::MAX_LENGTH)) { - js_ReportAllocationOverflow(maybecx); + js::ReportAllocationOverflow(maybecx); return false; } diff --git a/js/src/vm/StringBuffer.cpp b/js/src/vm/StringBuffer.cpp index dbf5e6695d..9263ca2790 100644 --- a/js/src/vm/StringBuffer.cpp +++ b/js/src/vm/StringBuffer.cpp @@ -161,7 +161,7 @@ js::ValueToStringBufferSlow(JSContext* cx, const Value& arg, StringBuffer& sb) if (v.isNull()) return sb.append(cx->names().null); if (v.isSymbol()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_SYMBOL_TO_STRING); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_SYMBOL_TO_STRING); return false; } MOZ_ASSERT(v.isUndefined()); diff --git a/js/src/vm/StringObject.h b/js/src/vm/StringObject.h index cfb65cd8a5..080c3af19b 100644 --- a/js/src/vm/StringObject.h +++ b/js/src/vm/StringObject.h @@ -65,7 +65,7 @@ class StringObject : public NativeObject /* For access to init, as String.prototype is special. */ friend JSObject* - ::js_InitStringClass(JSContext* cx, js::HandleObject global); + js::InitStringClass(JSContext *cx, HandleObject global); }; } // namespace js diff --git a/js/src/vm/StructuredClone.cpp b/js/src/vm/StructuredClone.cpp index 64ea57ca07..93dbcaffee 100644 --- a/js/src/vm/StructuredClone.cpp +++ b/js/src/vm/StructuredClone.cpp @@ -196,7 +196,7 @@ class SCInput { bool readArray(T* p, size_t nelems); bool reportTruncated() { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_SC_BAD_SERIALIZED_DATA, "truncated"); return false; } @@ -341,7 +341,7 @@ struct JSStructuredCloneWriter { }; JS_FRIEND_API(uint64_t) -js_GetSCOffset(JSStructuredCloneWriter* writer) +js::GetSCOffset(JSStructuredCloneWriter* writer) { MOZ_ASSERT(writer); return writer->output().count() * sizeof(uint64_t); @@ -357,7 +357,7 @@ ReportErrorTransferable(JSContext* cx, const JSStructuredCloneCallbacks* callbac if (callbacks && callbacks->reportError) callbacks->reportError(cx, JS_SCERR_TRANSFERABLE); else - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_SC_NOT_TRANSFERABLE); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_SC_NOT_TRANSFERABLE); } bool @@ -684,7 +684,7 @@ SCOutput::writeArray(const T* p, size_t nelems) return true; if (nelems + sizeof(uint64_t) / sizeof(T) - 1 < nelems) { - js_ReportAllocationOverflow(context()); + ReportAllocationOverflow(context()); return false; } size_t nwords = JS_HOWMANY(nelems, sizeof(uint64_t) / sizeof(T)); @@ -780,7 +780,7 @@ JSStructuredCloneWriter::parseTransferable() // No duplicates allowed if (std::find(transferableObjects.begin(), transferableObjects.end(), tObj) != transferableObjects.end()) { - JS_ReportErrorNumber(context(), js_GetErrorMessage, nullptr, JSMSG_SC_DUP_TRANSFERABLE); + JS_ReportErrorNumber(context(), GetErrorMessage, nullptr, JSMSG_SC_DUP_TRANSFERABLE); return false; } @@ -888,7 +888,7 @@ JSStructuredCloneWriter::writeArrayBuffer(HandleObject obj) bool JSStructuredCloneWriter::writeSharedArrayBuffer(HandleObject obj) { - JS_ReportErrorNumber(context(), js_GetErrorMessage, nullptr, JSMSG_SC_SHMEM_MUST_TRANSFER); + JS_ReportErrorNumber(context(), GetErrorMessage, nullptr, JSMSG_SC_SHMEM_MUST_TRANSFER); return false; } @@ -923,7 +923,7 @@ JSStructuredCloneWriter::startObject(HandleObject obj, bool* backref) return false; if (memory.count() == UINT32_MAX) { - JS_ReportErrorNumber(context(), js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(context(), GetErrorMessage, nullptr, JSMSG_NEED_DIET, "object graph to serialize"); return false; } @@ -1094,7 +1094,7 @@ JSStructuredCloneWriter::startWrite(HandleValue v) /* else fall through */ } - JS_ReportErrorNumber(context(), js_GetErrorMessage, nullptr, JSMSG_SC_UNSUPPORTED_TYPE); + JS_ReportErrorNumber(context(), GetErrorMessage, nullptr, JSMSG_SC_UNSUPPORTED_TYPE); return false; } @@ -1289,7 +1289,7 @@ JSStructuredCloneReader::checkDouble(double d) jsval_layout l; l.asDouble = d; if (!JSVAL_IS_DOUBLE_IMPL(l)) { - JS_ReportErrorNumber(context(), js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(context(), GetErrorMessage, nullptr, JSMSG_SC_BAD_SERIALIZED_DATA, "unrecognized NaN"); return false; } @@ -1327,7 +1327,7 @@ JSString* JSStructuredCloneReader::readStringImpl(uint32_t nchars) { if (nchars > JSString::MAX_LENGTH) { - JS_ReportErrorNumber(context(), js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(context(), GetErrorMessage, nullptr, JSMSG_SC_BAD_SERIALIZED_DATA, "string length"); return nullptr; } @@ -1360,7 +1360,7 @@ JSStructuredCloneReader::readTypedArray(uint32_t arrayType, uint32_t nelems, Mut bool v1Read) { if (arrayType > Scalar::Uint8Clamped) { - JS_ReportErrorNumber(context(), js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(context(), GetErrorMessage, nullptr, JSMSG_SC_BAD_SERIALIZED_DATA, "unhandled typed array element type"); return false; } @@ -1387,7 +1387,7 @@ JSStructuredCloneReader::readTypedArray(uint32_t arrayType, uint32_t nelems, Mut byteOffset = n; } if (!v.isObject() || !v.toObject().is()) { - JS_ReportErrorNumber(context(), js_GetErrorMessage, nullptr, JSMSG_SC_BAD_SERIALIZED_DATA, + JS_ReportErrorNumber(context(), GetErrorMessage, nullptr, JSMSG_SC_BAD_SERIALIZED_DATA, "typed array must be backed by an ArrayBuffer"); return false; } @@ -1439,7 +1439,7 @@ bool JSStructuredCloneReader::readSharedTypedArray(uint32_t arrayType, uint32_t nelems, MutableHandleValue vp) { if (arrayType > Scalar::Uint8Clamped) { - JS_ReportErrorNumber(context(), js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(context(), GetErrorMessage, nullptr, JSMSG_SC_BAD_SERIALIZED_DATA, "unhandled typed array element type"); return false; } @@ -1460,7 +1460,7 @@ JSStructuredCloneReader::readSharedTypedArray(uint32_t arrayType, uint32_t nelem return false; byteOffset = n; if (!v.isObject() || !v.toObject().is()) { - JS_ReportErrorNumber(context(), js_GetErrorMessage, nullptr, JSMSG_SC_BAD_SERIALIZED_DATA, + JS_ReportErrorNumber(context(), GetErrorMessage, nullptr, JSMSG_SC_BAD_SERIALIZED_DATA, "DataView must be backed by an ArrayBuffer"); return false; } @@ -1529,7 +1529,7 @@ JSStructuredCloneReader::readV1ArrayBuffer(uint32_t arrayType, uint32_t nelems, MutableHandleValue vp) { if (arrayType > Scalar::Uint8Clamped) { - JS_ReportErrorNumber(context(), js_GetErrorMessage, nullptr, JSMSG_SC_BAD_SERIALIZED_DATA, + JS_ReportErrorNumber(context(), GetErrorMessage, nullptr, JSMSG_SC_BAD_SERIALIZED_DATA, "invalid TypedArray type"); return false; } @@ -1538,7 +1538,7 @@ JSStructuredCloneReader::readV1ArrayBuffer(uint32_t arrayType, uint32_t nelems, mozilla::CheckedInt(nelems) * TypedArrayElemSize(static_cast(arrayType)); if (!nbytes.isValid() || nbytes.value() > UINT32_MAX) { - JS_ReportErrorNumber(context(), js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(context(), GetErrorMessage, nullptr, JSMSG_SC_BAD_SERIALIZED_DATA, "invalid typed array size"); return false; @@ -1635,11 +1635,11 @@ JSStructuredCloneReader::startRead(MutableHandleValue vp) if (!in.readDouble(&d) || !checkDouble(d)) return false; if (!IsNaN(d) && d != TimeClip(d)) { - JS_ReportErrorNumber(context(), js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(context(), GetErrorMessage, nullptr, JSMSG_SC_BAD_SERIALIZED_DATA, "date"); return false; } - JSObject* obj = js_NewDateObjectMsec(context(), d); + JSObject* obj = NewDateObjectMsec(context(), d); if (!obj) return false; vp.setObject(*obj); @@ -1652,7 +1652,7 @@ JSStructuredCloneReader::startRead(MutableHandleValue vp) if (!in.readPair(&tag2, &stringData)) return false; if (tag2 != SCTAG_STRING) { - JS_ReportErrorNumber(context(), js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(context(), GetErrorMessage, nullptr, JSMSG_SC_BAD_SERIALIZED_DATA, "regexp"); return false; } @@ -1685,7 +1685,7 @@ JSStructuredCloneReader::startRead(MutableHandleValue vp) case SCTAG_BACK_REFERENCE_OBJECT: { if (data >= allObjs.length()) { - JS_ReportErrorNumber(context(), js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(context(), GetErrorMessage, nullptr, JSMSG_SC_BAD_SERIALIZED_DATA, "invalid back reference in input"); return false; @@ -1697,7 +1697,7 @@ JSStructuredCloneReader::startRead(MutableHandleValue vp) case SCTAG_TRANSFER_MAP_HEADER: case SCTAG_TRANSFER_MAP_PENDING_ENTRY: // We should be past all the transfer map tags. - JS_ReportErrorNumber(context(), js_GetErrorMessage, NULL, + JS_ReportErrorNumber(context(), GetErrorMessage, NULL, JSMSG_SC_BAD_SERIALIZED_DATA, "invalid input"); return false; @@ -1755,7 +1755,7 @@ JSStructuredCloneReader::startRead(MutableHandleValue vp) } if (!callbacks || !callbacks->read) { - JS_ReportErrorNumber(context(), js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(context(), GetErrorMessage, nullptr, JSMSG_SC_BAD_SERIALIZED_DATA, "unsupported type"); return false; } @@ -1928,7 +1928,7 @@ JS_ReadStructuredClone(JSContext* cx, uint64_t* buf, size_t nbytes, CHECK_REQUEST(cx); if (version > JS_STRUCTURED_CLONE_VERSION) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_SC_BAD_CLONE_VERSION); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_SC_BAD_CLONE_VERSION); return false; } const JSStructuredCloneCallbacks* callbacks = @@ -2156,7 +2156,7 @@ JS_ReadTypedArray(JSStructuredCloneReader* r, MutableHandleValue vp) return false; return r->readTypedArray(arrayType, nelems, vp); } else { - JS_ReportErrorNumber(r->context(), js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(r->context(), GetErrorMessage, nullptr, JSMSG_SC_BAD_SERIALIZED_DATA, "expected type array"); return false; } diff --git a/js/src/vm/Symbol.cpp b/js/src/vm/Symbol.cpp index 258989e760..d731866678 100644 --- a/js/src/vm/Symbol.cpp +++ b/js/src/vm/Symbol.cpp @@ -28,7 +28,7 @@ Symbol::newInternal(ExclusiveContext* cx, JS::SymbolCode code, JSAtom* descripti // Following js::AtomizeString, we grudgingly forgo last-ditch GC here. Symbol* p = gc::AllocateNonObject(cx); if (!p) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return nullptr; } return new (p) Symbol(code, description); @@ -74,7 +74,7 @@ Symbol::for_(js::ExclusiveContext* cx, HandleString description) // lookupForAdd call, and newInternal can't GC. if (!registry.add(p, sym)) { // SystemAllocPolicy does not report OOM. - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return nullptr; } return sym; diff --git a/js/src/vm/TypeInference-inl.h b/js/src/vm/TypeInference-inl.h index 2f89552c75..365a51dc15 100644 --- a/js/src/vm/TypeInference-inl.h +++ b/js/src/vm/TypeInference-inl.h @@ -605,7 +605,7 @@ TypeScript::MonitorAssign(JSContext* cx, HandleObject obj, jsid id) * specific properties. */ uint32_t i; - if (js_IdIsIndex(id, &i)) + if (IdIsIndex(id, &i)) return; // But if we don't have too many properties yet, don't do anything. The diff --git a/js/src/vm/TypeInference.cpp b/js/src/vm/TypeInference.cpp index 87127eaae6..815283f945 100644 --- a/js/src/vm/TypeInference.cpp +++ b/js/src/vm/TypeInference.cpp @@ -1224,7 +1224,7 @@ js::FinishCompilation(JSContext* cx, HandleScript script, CompilerConstraintList uint32_t index = types.compilerOutputs->length(); if (!types.compilerOutputs->append(co)) { - js_ReportOutOfMemory(cx); + ReportOutOfMemory(cx); return false; } @@ -3032,7 +3032,7 @@ js::AddClearDefiniteFunctionUsesInScript(JSContext* cx, ObjectGroup* group, JSFunction* fun = &singleton->as(); if (!fun->isNative()) continue; - if (fun->native() != js_fun_call && fun->native() != js_fun_apply) + if (fun->native() != fun_call && fun->native() != fun_apply) continue; } // This is a type set that might have been used when inlining @@ -4151,7 +4151,7 @@ TypeScript::printTypes(JSContext* cx, HandleScript script) const Sprinter sprinter(cx); if (!sprinter.init()) return; - js_Disassemble1(cx, script, pc, script->pcToOffset(pc), true, &sprinter); + Disassemble1(cx, script, pc, script->pcToOffset(pc), true, &sprinter); fprintf(stderr, "%s", sprinter.string()); } diff --git a/js/src/vm/TypedArrayCommon.h b/js/src/vm/TypedArrayCommon.h index 265deaf406..d3b8120f51 100644 --- a/js/src/vm/TypedArrayCommon.h +++ b/js/src/vm/TypedArrayCommon.h @@ -507,7 +507,7 @@ class TypedArrayMethods begin = end; if (begin > tarray->length() || end > tarray->length() || begin > end) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_BAD_INDEX); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_BAD_INDEX); return false; } @@ -622,7 +622,7 @@ class TypedArrayMethods count > lengthDuringMove - from || count > lengthDuringMove - to) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_TYPED_ARRAY_BAD_ARGS); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_TYPED_ARRAY_BAD_ARGS); return false; } @@ -665,7 +665,7 @@ class TypedArrayMethods // The first argument must be either a typed array or arraylike. if (args.length() == 0 || !args[0].isObject()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_TYPED_ARRAY_BAD_ARGS); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_TYPED_ARRAY_BAD_ARGS); return false; } @@ -676,7 +676,7 @@ class TypedArrayMethods if (offset < 0 || uint32_t(offset) > target->length()) { // the given offset is bogus - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_TYPED_ARRAY_BAD_INDEX, "2"); return false; } @@ -685,7 +685,7 @@ class TypedArrayMethods RootedObject arg0(cx, &args[0].toObject()); if (IsAnyTypedArray(arg0)) { if (AnyTypedArrayLength(arg0) > target->length() - offset) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_BAD_ARRAY_LENGTH); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_BAD_ARRAY_LENGTH); return false; } @@ -697,7 +697,7 @@ class TypedArrayMethods return false; if (uint32_t(offset) > target->length() || len > target->length() - offset) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_BAD_ARRAY_LENGTH); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_BAD_ARRAY_LENGTH); return false; } diff --git a/js/src/vm/TypedArrayObject.cpp b/js/src/vm/TypedArrayObject.cpp index 8a0b15f2de..122376f7f7 100644 --- a/js/src/vm/TypedArrayObject.cpp +++ b/js/src/vm/TypedArrayObject.cpp @@ -442,7 +442,7 @@ class TypedArrayObjectTemplate : public TypedArrayObject /* (not an object) */ if (!args[0].isObject()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_TYPED_ARRAY_BAD_ARGS); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_TYPED_ARRAY_BAD_ARGS); return nullptr; } @@ -469,7 +469,7 @@ class TypedArrayObjectTemplate : public TypedArrayObject if (!ToInt32(cx, args[1], &byteOffset)) return nullptr; if (byteOffset < 0) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_TYPED_ARRAY_NEGATIVE_ARG, "1"); return nullptr; } @@ -478,7 +478,7 @@ class TypedArrayObjectTemplate : public TypedArrayObject if (!ToInt32(cx, args[2], &length)) return nullptr; if (length < 0) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_TYPED_ARRAY_NEGATIVE_ARG, "2"); return nullptr; } @@ -500,7 +500,7 @@ class TypedArrayObjectTemplate : public TypedArrayObject HandleObject proto) { if (!ObjectClassIs(bufobj, ESClass_ArrayBuffer, cx)) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_TYPED_ARRAY_BAD_ARGS); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_TYPED_ARRAY_BAD_ARGS); return nullptr; // must be arrayBuffer } @@ -558,14 +558,14 @@ class TypedArrayObjectTemplate : public TypedArrayObject } if (!IsArrayBuffer(bufobj)) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_TYPED_ARRAY_BAD_ARGS); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_TYPED_ARRAY_BAD_ARGS); return nullptr; // must be arrayBuffer } Rooted buffer(cx, &AsArrayBuffer(bufobj)); if (byteOffset > buffer->byteLength() || byteOffset % sizeof(NativeType) != 0) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_TYPED_ARRAY_BAD_ARGS); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_TYPED_ARRAY_BAD_ARGS); return nullptr; // invalid byteOffset } @@ -573,7 +573,7 @@ class TypedArrayObjectTemplate : public TypedArrayObject if (lengthInt == -1) { len = (buffer->byteLength() - byteOffset) / sizeof(NativeType); if (len * sizeof(NativeType) != buffer->byteLength() - byteOffset) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_TYPED_ARRAY_BAD_ARGS); return nullptr; // given byte array doesn't map exactly to sizeof(NativeType) * N } @@ -584,12 +584,12 @@ class TypedArrayObjectTemplate : public TypedArrayObject // Go slowly and check for overflow. uint32_t arrayByteLength = len * sizeof(NativeType); if (len >= INT32_MAX / sizeof(NativeType) || byteOffset >= INT32_MAX - arrayByteLength) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_TYPED_ARRAY_BAD_ARGS); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_TYPED_ARRAY_BAD_ARGS); return nullptr; // overflow when calculating byteOffset + len * sizeof(NativeType) } if (arrayByteLength + byteOffset > buffer->byteLength()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_TYPED_ARRAY_BAD_ARGS); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_TYPED_ARRAY_BAD_ARGS); return nullptr; // byteOffset + len is too big for the arraybuffer } @@ -608,7 +608,7 @@ class TypedArrayObjectTemplate : public TypedArrayObject } if (nelements >= INT32_MAX / sizeof(NativeType)) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NEED_DIET, "size and count"); return false; } @@ -989,7 +989,7 @@ DataViewObject::create(JSContext* cx, uint32_t byteOffset, uint32_t byteLength, Handle arrayBuffer, JSObject* protoArg) { if (arrayBuffer->isNeutered()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_TYPED_ARRAY_DETACHED); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_TYPED_ARRAY_DETACHED); return nullptr; } @@ -1001,7 +1001,7 @@ DataViewObject::create(JSContext* cx, uint32_t byteOffset, uint32_t byteLength, // This is overflow-safe: 2 * INT32_MAX is still a valid uint32_t. if (byteOffset + byteLength > arrayBuffer->byteLength()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_ARG_INDEX_OUT_OF_RANGE, "1"); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_ARG_INDEX_OUT_OF_RANGE, "1"); return nullptr; } @@ -1053,7 +1053,7 @@ bool DataViewObject::construct(JSContext* cx, JSObject* bufobj, const CallArgs& args, HandleObject proto) { if (!IsArrayBuffer(bufobj)) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_NOT_EXPECTED_TYPE, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NOT_EXPECTED_TYPE, "DataView", "ArrayBuffer", bufobj->getClass()->name); return false; } @@ -1067,7 +1067,7 @@ DataViewObject::construct(JSContext* cx, JSObject* bufobj, const CallArgs& args, if (!ToUint32(cx, args[1], &byteOffset)) return false; if (byteOffset > INT32_MAX) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_ARG_INDEX_OUT_OF_RANGE, "1"); return false; } @@ -1076,13 +1076,13 @@ DataViewObject::construct(JSContext* cx, JSObject* bufobj, const CallArgs& args, if (!ToUint32(cx, args[2], &byteLength)) return false; if (byteLength > INT32_MAX) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_ARG_INDEX_OUT_OF_RANGE, "2"); return false; } } else { if (byteOffset > bufferLength) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_ARG_INDEX_OUT_OF_RANGE, "1"); return false; } @@ -1096,7 +1096,7 @@ DataViewObject::construct(JSContext* cx, JSObject* bufobj, const CallArgs& args, MOZ_ASSERT(byteLength <= INT32_MAX); if (byteOffset + byteLength > bufferLength) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_ARG_INDEX_OUT_OF_RANGE, "1"); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_ARG_INDEX_OUT_OF_RANGE, "1"); return false; } @@ -1144,7 +1144,7 @@ DataViewObject::getDataPointer(JSContext* cx, Handle obj, uint3 { const size_t TypeSize = sizeof(NativeType); if (offset > UINT32_MAX - TypeSize || offset + TypeSize > obj->byteLength()) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_ARG_INDEX_OUT_OF_RANGE, "1"); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_ARG_INDEX_OUT_OF_RANGE, "1"); return nullptr; } @@ -1231,7 +1231,7 @@ DataViewObject::read(JSContext* cx, Handle obj, const CallArgs& args, NativeType* val, const char* method) { if (args.length() < 1) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, method, "0", "s"); return false; } @@ -1288,7 +1288,7 @@ DataViewObject::write(JSContext* cx, Handle obj, const CallArgs& args, const char* method) { if (args.length() < 2) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, method, "1", ""); return false; } @@ -2037,7 +2037,7 @@ DataViewObject::neuter(void* newData) } JSObject* -js_InitDataViewClass(JSContext* cx, HandleObject obj) +js::InitDataViewClass(JSContext *cx, HandleObject obj) { if (!DataViewObject::initClass(cx)) return nullptr; diff --git a/js/src/vm/TypedArrayObject.h b/js/src/vm/TypedArrayObject.h index a94a353557..d7fe009f7b 100644 --- a/js/src/vm/TypedArrayObject.h +++ b/js/src/vm/TypedArrayObject.h @@ -310,6 +310,9 @@ TypedArrayElemSize(Scalar::Type viewType) return 1u << TypedArrayShift(viewType); } +extern JSObject * +InitDataViewClass(JSContext *cx, HandleObject obj); + class DataViewObject : public NativeObject { private: diff --git a/js/src/vm/Xdr.cpp b/js/src/vm/Xdr.cpp index e1aa2b585c..1c0383f804 100644 --- a/js/src/vm/Xdr.cpp +++ b/js/src/vm/Xdr.cpp @@ -36,13 +36,13 @@ XDRBuffer::grow(size_t n) newCapacity = MIN_CAPACITY; if (isUint32Overflow(newCapacity)) { js::gc::AutoSuppressGC suppressGC(cx()); - JS_ReportErrorNumber(cx(), js_GetErrorMessage, nullptr, JSMSG_TOO_BIG_TO_ENCODE); + JS_ReportErrorNumber(cx(), GetErrorMessage, nullptr, JSMSG_TOO_BIG_TO_ENCODE); return false; } void* data = js_realloc(base, newCapacity); if (!data) { - js_ReportOutOfMemory(cx()); + ReportOutOfMemory(cx()); return false; } base = static_cast(data); @@ -97,7 +97,7 @@ VersionCheck(XDRState* xdr) if (mode == XDR_DECODE && bytecodeVer != XDR_BYTECODE_VERSION) { /* We do not provide binary compatibility with older scripts. */ - JS_ReportErrorNumber(xdr->cx(), js_GetErrorMessage, nullptr, JSMSG_BAD_SCRIPT_MAGIC); + JS_ReportErrorNumber(xdr->cx(), GetErrorMessage, nullptr, JSMSG_BAD_SCRIPT_MAGIC); return false; } diff --git a/js/xpconnect/wrappers/XrayWrapper.cpp b/js/xpconnect/wrappers/XrayWrapper.cpp index 7a65212939..37307a6f78 100644 --- a/js/xpconnect/wrappers/XrayWrapper.cpp +++ b/js/xpconnect/wrappers/XrayWrapper.cpp @@ -1602,7 +1602,7 @@ DOMXrayTraits::call(JSContext* cx, HandleObject wrapper, if (clasp->flags & JSCLASS_IS_DOMIFACEANDPROTOJSCLASS) { if (!clasp->call) { RootedValue v(cx, ObjectValue(*wrapper)); - js_ReportIsNotFunction(cx, v); + js::ReportIsNotFunction(cx, v); return false; } // call it on the Xray compartment @@ -1628,7 +1628,7 @@ DOMXrayTraits::construct(JSContext* cx, HandleObject wrapper, if (clasp->flags & JSCLASS_IS_DOMIFACEANDPROTOJSCLASS) { if (!clasp->construct) { RootedValue v(cx, ObjectValue(*wrapper)); - js_ReportIsNotFunction(cx, v); + js::ReportIsNotFunction(cx, v); return false; } if (!clasp->construct(cx, args.length(), args.base())) diff --git a/js/xpconnect/wrappers/XrayWrapper.h b/js/xpconnect/wrappers/XrayWrapper.h index 3c57055a5b..69473340fe 100644 --- a/js/xpconnect/wrappers/XrayWrapper.h +++ b/js/xpconnect/wrappers/XrayWrapper.h @@ -233,7 +233,7 @@ public: return baseInstance.call(cx, wrapper, args); JS::RootedValue v(cx, JS::ObjectValue(*wrapper)); - js_ReportIsNotFunction(cx, v); + js::ReportIsNotFunction(cx, v); return false; } @@ -246,7 +246,7 @@ public: return baseInstance.construct(cx, wrapper, args); JS::RootedValue v(cx, JS::ObjectValue(*wrapper)); - js_ReportIsNotFunction(cx, v); + js::ReportIsNotFunction(cx, v); return false; } @@ -352,7 +352,7 @@ public: const JS::CallArgs& args, const js::Wrapper& baseInstance) { JS::RootedValue v(cx, JS::ObjectValue(*wrapper)); - js_ReportIsNotFunction(cx, v); + js::ReportIsNotFunction(cx, v); return false; } @@ -360,7 +360,7 @@ public: const JS::CallArgs& args, const js::Wrapper& baseInstance) { JS::RootedValue v(cx, JS::ObjectValue(*wrapper)); - js_ReportIsNotFunction(cx, v); + js::ReportIsNotFunction(cx, v); return false; }