diff --git a/js/src/builtin/Array.js b/js/src/builtin/Array.js index 6a9f7da230c..c595f20f847 100644 --- a/js/src/builtin/Array.js +++ b/js/src/builtin/Array.js @@ -774,7 +774,7 @@ function ArrayFrom(items, mapfn=undefined, thisArg=undefined) { // See . while (true) { // Steps 6.g.i-iii. - var next = callFunction(iterator.next, iterator); + var next = iterator.next(); if (!IsObject(next)) ThrowTypeError(JSMSG_NEXT_RETURNED_PRIMITIVE); diff --git a/js/src/builtin/Intl.js b/js/src/builtin/Intl.js index 501a5d98e86..07b636b3ecb 100644 --- a/js/src/builtin/Intl.js +++ b/js/src/builtin/Intl.js @@ -443,9 +443,9 @@ function CanonicalizeLanguageTag(locale) { while (i < subtags.length && subtags[i].length > 1) i++; var extension = callFunction(std_Array_join, callFunction(std_Array_slice, subtags, extensionStart, i), "-"); - callFunction(std_Array_push, extensions, extension); + extensions.push(extension); } - callFunction(std_Array_sort, extensions); + extensions.sort(); // Private use sequences are left as is. "x-private" var privateUse = ""; @@ -455,7 +455,7 @@ function CanonicalizeLanguageTag(locale) { // Put everything back together. var canonical = normal; if (extensions.length > 0) - canonical += "-" + callFunction(std_Array_join, extensions, "-"); + canonical += "-" + extensions.join("-"); if (privateUse.length > 0) { // Be careful of a Language-Tag that is entirely privateuse. if (canonical.length > 0) @@ -578,14 +578,11 @@ function DefaultLocale() { // (perhaps via fallback). Otherwise use the last-ditch locale. var candidate = DefaultLocaleIgnoringAvailableLocales(); var locale; - if (BestAvailableLocaleIgnoringDefault(callFunction(collatorInternalProperties.availableLocales, - collatorInternalProperties), + if (BestAvailableLocaleIgnoringDefault(collatorInternalProperties.availableLocales(), candidate) && - BestAvailableLocaleIgnoringDefault(callFunction(numberFormatInternalProperties.availableLocales, - numberFormatInternalProperties), + BestAvailableLocaleIgnoringDefault(numberFormatInternalProperties.availableLocales(), candidate) && - BestAvailableLocaleIgnoringDefault(callFunction(dateTimeFormatInternalProperties.availableLocales, - dateTimeFormalInternalProperties), + BestAvailableLocaleIgnoringDefault(dateTimeFormatInternalProperties.availableLocales(), candidate)) { locale = candidate; @@ -678,8 +675,8 @@ function CanonicalizeLocaleList(locales) { if (!IsStructurallyValidLanguageTag(tag)) ThrowRangeError(JSMSG_INVALID_LANGUAGE_TAG, tag); tag = CanonicalizeLanguageTag(tag); - if (callFunction(std_Array_indexOf, seen, tag) === -1) - callFunction(std_Array_push, seen, tag); + if (seen.indexOf(tag) === -1) + seen.push(tag); } k++; } @@ -971,14 +968,14 @@ function LookupSupportedLocales(availableLocales, requestedLocales) { // Step 4.c-d. var availableLocale = BestAvailableLocale(availableLocales, noExtensionsLocale); if (availableLocale !== undefined) - callFunction(std_Array_push, subset, locale); + subset.push(locale); // Step 4.e. k++; } // Steps 5-6. - return callFunction(std_Array_slice, subset, 0); + return subset.slice(0); } @@ -1320,7 +1317,7 @@ function resolveCollatorInternals(lazyCollatorData) var relevantExtensionKeys = Collator.relevantExtensionKeys; // Step 15. - var r = ResolveLocale(callFunction(Collator.availableLocales, Collator), + var r = ResolveLocale(Collator.availableLocales(), lazyCollatorData.requestedLocales, lazyCollatorData.opt, relevantExtensionKeys, @@ -1510,8 +1507,7 @@ function InitializeCollator(collator, locales, options) { function Intl_Collator_supportedLocalesOf(locales /*, options*/) { var options = arguments.length > 1 ? arguments[1] : undefined; - var availableLocales = callFunction(collatorInternalProperties.availableLocales, - collatorInternalProperties); + var availableLocales = collatorInternalProperties.availableLocales(); var requestedLocales = CanonicalizeLocaleList(locales); return SupportedLocales(availableLocales, requestedLocales, options); } @@ -1679,7 +1675,7 @@ function resolveNumberFormatInternals(lazyNumberFormatData) { var localeData = NumberFormat.localeData; // Step 11. - var r = ResolveLocale(callFunction(NumberFormat.availableLocales, NumberFormat), + var r = ResolveLocale(NumberFormat.availableLocales(), lazyNumberFormatData.requestedLocales, lazyNumberFormatData.opt, NumberFormat.relevantExtensionKeys, @@ -1963,8 +1959,7 @@ function CurrencyDigits(currency) { function Intl_NumberFormat_supportedLocalesOf(locales /*, options*/) { var options = arguments.length > 1 ? arguments[1] : undefined; - var availableLocales = callFunction(numberFormatInternalProperties.availableLocales, - numberFormatInternalProperties); + var availableLocales = numberFormatInternalProperties.availableLocales(); var requestedLocales = CanonicalizeLocaleList(locales); return SupportedLocales(availableLocales, requestedLocales, options); } @@ -2123,7 +2118,7 @@ function resolveDateTimeFormatInternals(lazyDateTimeFormatData) { var localeData = DateTimeFormat.localeData; // Step 10. - var r = ResolveLocale(callFunction(DateTimeFormat.availableLocales, DateTimeFormat), + var r = ResolveLocale(DateTimeFormat.availableLocales(), lazyDateTimeFormatData.requestedLocales, lazyDateTimeFormatData.localeOpt, DateTimeFormat.relevantExtensionKeys, @@ -2664,8 +2659,7 @@ function BestFitFormatMatcher(options, formats) { function Intl_DateTimeFormat_supportedLocalesOf(locales /*, options*/) { var options = arguments.length > 1 ? arguments[1] : undefined; - var availableLocales = callFunction(dateTimeFormatInternalProperties.availableLocales, - dateTimeFormatInternalProperties); + var availableLocales = dateTimeFormatInternalProperties.availableLocales(); var requestedLocales = CanonicalizeLocaleList(locales); return SupportedLocales(availableLocales, requestedLocales, options); } diff --git a/js/src/builtin/Iterator.js b/js/src/builtin/Iterator.js index a56b7228aa2..5f78547cadd 100644 --- a/js/src/builtin/Iterator.js +++ b/js/src/builtin/Iterator.js @@ -11,7 +11,7 @@ var LegacyIteratorWrapperMap = new std_WeakMap(); function LegacyIteratorNext(arg) { var iter = callFunction(std_WeakMap_get, LegacyIteratorWrapperMap, this); try { - return { value: callFunction(iter.next, iter, arg), done: false }; + return { value: iter.next(arg), done: false }; } catch (e) { if (e instanceof std_StopIteration) return { value: undefined, done: true }; @@ -22,7 +22,7 @@ function LegacyIteratorNext(arg) { function LegacyIteratorThrow(exn) { var iter = callFunction(std_WeakMap_get, LegacyIteratorWrapperMap, this); try { - return { value: callFunction(iter.throw, iter, exn), done: false }; + return { value: iter.throw(exn), done: false }; } catch (e) { if (e instanceof std_StopIteration) return { value: undefined, done: true }; diff --git a/js/src/builtin/Module.js b/js/src/builtin/Module.js index 15b36626a17..2e82cfcdf27 100644 --- a/js/src/builtin/Module.js +++ b/js/src/builtin/Module.js @@ -43,8 +43,7 @@ function ModuleGetExportedNames(exportStarSet = []) for (let i = 0; i < starExportEntries.length; i++) { let e = starExportEntries[i]; let requestedModule = HostResolveImportedModule(module, e.moduleRequest); - let starNames = callFunction(requestedModule.getExportedNames, requestedModule, - exportStarSet); + let starNames = requestedModule.getExportedNames(exportStarSet); for (let j = 0; j < starNames.length; j++) { let n = starNames[j]; if (n !== "default" && !(n in exportedNames)) @@ -90,8 +89,9 @@ function ModuleResolveExport(exportName, resolveSet = [], exportStarSet = []) let e = indirectExportEntries[i]; if (exportName === e.exportName) { let importedModule = HostResolveImportedModule(module, e.moduleRequest); - let indirectResolution = callFunction(importedModule.resolveExport, importedModule, - e.importName, resolveSet, exportStarSet); + let indirectResolution = importedModule.resolveExport(e.importName, + resolveSet, + exportStarSet); if (indirectResolution !== null) return indirectResolution; } @@ -118,8 +118,7 @@ function ModuleResolveExport(exportName, resolveSet = [], exportStarSet = []) for (let i = 0; i < starExportEntries.length; i++) { let e = starExportEntries[i]; let importedModule = HostResolveImportedModule(module, e.moduleRequest); - let resolution = callFunction(importedModule.resolveExport, importedModule, - exportName, resolveSet, exportStarSet); + let resolution = importedModule.resolveExport(exportName, resolveSet, exportStarSet); if (resolution === "ambiguous") return resolution; @@ -147,11 +146,11 @@ function GetModuleNamespace(module) // Step 3 if (typeof namespace === "undefined") { - let exportedNames = callFunction(module.getExportedNames, module); + let exportedNames = module.getExportedNames(); let unambiguousNames = []; for (let i = 0; i < exportedNames.length; i++) { let name = exportedNames[i]; - let resolution = callFunction(module.resolveExport, module, name); + let resolution = module.resolveExport(name); if (resolution === null) ThrowSyntaxError(JSMSG_MISSING_NAMESPACE_EXPORT); if (resolution !== "ambiguous") @@ -167,7 +166,7 @@ function GetModuleNamespace(module) // 9.4.6.13 ModuleNamespaceCreate(module, exports) function ModuleNamespaceCreate(module, exports) { - callFunction(std_Array_sort, exports); + exports.sort(); let ns = NewModuleNamespace(module, exports); @@ -175,7 +174,7 @@ function ModuleNamespaceCreate(module, exports) // access. for (let i = 0; i < exports.length; i++) { let name = exports[i]; - let binding = callFunction(module.resolveExport, module, name); + let binding = module.resolveExport(name); assert(binding !== null && binding !== "ambiguous", "Failed to resolve binding"); AddModuleNamespaceBinding(ns, name, binding.module, binding.bindingName); } @@ -205,14 +204,14 @@ function ModuleDeclarationInstantiation() for (let i = 0; i < requestedModules.length; i++) { let required = requestedModules[i]; let requiredModule = HostResolveImportedModule(module, required); - callFunction(requiredModule.declarationInstantiation, requiredModule); + requiredModule.declarationInstantiation(); } // Step 9 let indirectExportEntries = module.indirectExportEntries; for (let i = 0; i < indirectExportEntries.length; i++) { let e = indirectExportEntries[i]; - let resolution = callFunction(module.resolveExport, module, e.exportName); + let resolution = module.resolveExport(e.exportName); if (resolution === null) ThrowSyntaxError(JSMSG_MISSING_INDIRECT_EXPORT); if (resolution === "ambiguous") @@ -228,8 +227,7 @@ function ModuleDeclarationInstantiation() let namespace = GetModuleNamespace(importedModule); CreateNamespaceBinding(env, imp.localName, namespace); } else { - let resolution = callFunction(importedModule.resolveExport, importedModule, - imp.importName); + let resolution = importedModule.resolveExport(imp.importName); if (resolution === null) ThrowSyntaxError(JSMSG_MISSING_IMPORT); if (resolution === "ambiguous") @@ -263,7 +261,7 @@ function ModuleEvaluation() for (let i = 0; i < requestedModules.length; i++) { let required = requestedModules[i]; let requiredModule = HostResolveImportedModule(module, required); - callFunction(requiredModule.evaluation, requiredModule); + requiredModule.evaluation(); } return EvaluateModule(module); diff --git a/js/src/builtin/Object.js b/js/src/builtin/Object.js index 8610ff4029e..f4957ec46e9 100644 --- a/js/src/builtin/Object.js +++ b/js/src/builtin/Object.js @@ -57,7 +57,7 @@ function Object_toLocaleString() { var O = this; // Step 2. - return callFunction(O.toString, O); + return O.toString(); } function ObjectDefineSetter(name, setter) { diff --git a/js/src/builtin/String.js b/js/src/builtin/String.js index 23a2e21af8f..e1dc06f07b2 100644 --- a/js/src/builtin/String.js +++ b/js/src/builtin/String.js @@ -296,12 +296,12 @@ function String_static_fromCodePoint(codePoints) { // Step 5f. // Inlined UTF-16 Encoding if (nextCP <= 0xFFFF) { - callFunction(std_Array_push, elements, nextCP); + elements.push(nextCP); continue; } - callFunction(std_Array_push, elements, (((nextCP - 0x10000) / 0x400) | 0) + 0xD800); - callFunction(std_Array_push, elements, (nextCP - 0x10000) % 0x400 + 0xDC00); + elements.push((((nextCP - 0x10000) / 0x400) | 0) + 0xD800); + elements.push((nextCP - 0x10000) % 0x400 + 0xDC00); } // Step 6. diff --git a/js/src/builtin/TypedArray.js b/js/src/builtin/TypedArray.js index 4b0f1969355..b49e3b0f826 100644 --- a/js/src/builtin/TypedArray.js +++ b/js/src/builtin/TypedArray.js @@ -216,7 +216,7 @@ function TypedArrayFilter(callbackfn, thisArg = undefined) { // Step 13.f. if (selected) { // Step 13.f.i. - callFunction(std_Array_push, kept, kValue); + kept.push(kValue); // Step 13.f.ii. captured++; } @@ -1058,14 +1058,14 @@ function TypedArrayFrom(constructor, target, items, mapfn, thisArg) { // Steps 10.d-e. while (true) { // Steps 10.e.i-ii. - var next = callFunction(iterator.next, iterator); + var next = iterator.next(); if (!IsObject(next)) ThrowTypeError(JSMSG_NEXT_RETURNED_PRIMITIVE); // Steps 10.e.iii-vi. if (next.done) break; - callFunction(std_Array_push, values, next.value); + values.push(next.value); } // Step 10.f. diff --git a/js/src/builtin/Utilities.js b/js/src/builtin/Utilities.js index fc6d4ad9d65..6b22e6b9c2b 100644 --- a/js/src/builtin/Utilities.js +++ b/js/src/builtin/Utilities.js @@ -53,7 +53,16 @@ var std_Map_iterator_next = MapIteratorNext; function List() { this.length = 0; } -MakeConstructible(List, {__proto__: null}); + +{ + let ListProto = std_Object_create(null); + ListProto.indexOf = std_Array_indexOf; + ListProto.join = std_Array_join; + ListProto.push = std_Array_push; + ListProto.slice = std_Array_slice; + ListProto.sort = std_Array_sort; + MakeConstructible(List, ListProto); +} /********** Record specification type **********/ diff --git a/js/src/frontend/Parser.cpp b/js/src/frontend/Parser.cpp index afa2e25be3d..7c05d3dfe1e 100644 --- a/js/src/frontend/Parser.cpp +++ b/js/src/frontend/Parser.cpp @@ -8629,11 +8629,6 @@ Parser::memberExpr(YieldHandling yieldHandling, TripledotHandling return nextMember; } - if (options().selfHostingMode && handler.isPropertyAccess(lhs)) { - report(ParseError, false, null(), JSMSG_SELFHOSTED_METHOD_CALL); - return null(); - } - nextMember = tt == TOK_LP ? handler.newCall() : handler.newTaggedTemplate(); if (!nextMember) return null(); diff --git a/js/src/js.msg b/js/src/js.msg index ee77b911cd0..988aed7e09e 100644 --- a/js/src/js.msg +++ b/js/src/js.msg @@ -314,7 +314,6 @@ MSG_DEF(JSMSG_RESERVED_ID, 1, JSEXN_SYNTAXERR, "{0} is a reserved id MSG_DEF(JSMSG_REST_WITH_DEFAULT, 0, JSEXN_SYNTAXERR, "rest parameter may not have a default") MSG_DEF(JSMSG_SELFHOSTED_TOP_LEVEL_LEXICAL, 1, JSEXN_SYNTAXERR, "self-hosted code cannot contain top-level {0} declarations") MSG_DEF(JSMSG_SELFHOSTED_UNBOUND_NAME, 0, JSEXN_TYPEERR, "self-hosted code may not contain unbound name lookups") -MSG_DEF(JSMSG_SELFHOSTED_METHOD_CALL, 0, JSEXN_SYNTAXERR, "self-hosted code may not contain direct method calls") MSG_DEF(JSMSG_SEMI_AFTER_FOR_COND, 0, JSEXN_SYNTAXERR, "missing ; after for-loop condition") MSG_DEF(JSMSG_SEMI_AFTER_FOR_INIT, 0, JSEXN_SYNTAXERR, "missing ; after for-loop initializer") MSG_DEF(JSMSG_SEMI_BEFORE_STMNT, 0, JSEXN_SYNTAXERR, "missing ; before statement") diff --git a/js/src/jsexn.cpp b/js/src/jsexn.cpp index 43509f9706d..ee1e16b86e9 100644 --- a/js/src/jsexn.cpp +++ b/js/src/jsexn.cpp @@ -542,13 +542,6 @@ js::ErrorToException(JSContext* cx, const char* message, JSErrorReport* reportp, if (JSREPORT_IS_WARNING(reportp->flags)) return false; - // Similarly, we cannot throw a proper object inside the self-hosting - // compartment, as we cannot construct the Error constructor without - // self-hosted code. Tell our caller to report immediately. - // Without self-hosted code, we cannot get started anyway. - if (cx->runtime()->isSelfHostingCompartment(cx->compartment())) - return false; - // Find the exception index associated with this error. JSErrNum errorNumber = static_cast(reportp->errorNumber); if (!callback) diff --git a/js/src/vm/Xdr.h b/js/src/vm/Xdr.h index f2c767e200e..b94401665b9 100644 --- a/js/src/vm/Xdr.h +++ b/js/src/vm/Xdr.h @@ -29,11 +29,11 @@ namespace js { * * https://developer.mozilla.org/en-US/docs/SpiderMonkey/Internals/Bytecode */ -static const uint32_t XDR_BYTECODE_VERSION_SUBTRAHEND = 320; +static const uint32_t XDR_BYTECODE_VERSION_SUBTRAHEND = 319; static const uint32_t XDR_BYTECODE_VERSION = uint32_t(0xb973c0de - XDR_BYTECODE_VERSION_SUBTRAHEND); -static_assert(JSErr_Limit == 421, +static_assert(JSErr_Limit == 420, "GREETINGS, POTENTIAL SUBTRAHEND INCREMENTER! If you added or " "removed MSG_DEFs from js.msg, you should increment " "XDR_BYTECODE_VERSION_SUBTRAHEND and update this assertion's "