author | Jon Coppeard <jcoppeard@mozilla.com> |
Tue, 22 Aug 2017 09:56:17 +0100 | |
changeset 376156 | 932c5acc1f86b26863abf895fed5890afe5c2ac7 |
parent 376155 | 2e4748827cda73771b02c8e9316e257505518a36 |
child 376157 | fec5a36cf325478431185b457568f813d15ad87c |
push id | 32376 |
push user | kwierso@gmail.com |
push date | Wed, 23 Aug 2017 00:07:40 +0000 |
treeherder | mozilla-central@64a45ee1731c [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | bbouvier |
bugs | 1388728 |
milestone | 57.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/js/src/frontend/BytecodeEmitter.cpp +++ b/js/src/frontend/BytecodeEmitter.cpp @@ -8255,17 +8255,17 @@ BytecodeEmitter::emitFunction(ParseNode* NameLocation loc = lookupName(name); topLevelFunction = loc.kind() == NameLocation::Kind::Dynamic || loc.bindingKind() == BindingKind::Var; } if (topLevelFunction) { if (sc->isModuleContext()) { // For modules, we record the function and instantiate the binding - // during ModuleDeclarationInstantiation(), before the script is run. + // during ModuleInstantiate(), before the script is run. RootedModuleObject module(cx, sc->asModuleContext()->module()); if (!module->noteFunctionDeclaration(cx, name, fun)) return false; } else { MOZ_ASSERT(sc->isGlobalContext() || sc->isEvalContext()); MOZ_ASSERT(pn->getOp() == JSOP_NOP); switchToPrologue();
--- a/js/src/frontend/Parser.cpp +++ b/js/src/frontend/Parser.cpp @@ -5184,17 +5184,17 @@ Parser<FullParseHandler, char16_t>::name Node importName = newName(context->names().star); if (!importName) return false; // Namespace imports are are not indirect bindings but lexical // definitions that hold a module namespace object. They are treated // as const variables which are initialized during the - // ModuleDeclarationInstantiation step. + // ModuleInstantiate step. RootedPropertyName bindingName(context, importedBinding()); if (!bindingName) return false; Node bindingNameNode = newName(bindingName); if (!bindingNameNode) return false; if (!noteDeclaredName(bindingName, DeclarationKind::Const, pos())) return false;
--- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -4874,26 +4874,26 @@ JS::SetModuleHostDefinedField(JSObject* JS_PUBLIC_API(JS::Value) JS::GetModuleHostDefinedField(JSObject* module) { return module->as<ModuleObject>().hostDefinedField(); } JS_PUBLIC_API(bool) -JS::ModuleDeclarationInstantiation(JSContext* cx, JS::HandleObject moduleArg) +JS::ModuleInstantiate(JSContext* cx, JS::HandleObject moduleArg) { AssertHeapIsIdle(); CHECK_REQUEST(cx); assertSameCompartment(cx, moduleArg); return ModuleObject::Instantiate(cx, moduleArg.as<ModuleObject>()); } JS_PUBLIC_API(bool) -JS::ModuleEvaluation(JSContext* cx, JS::HandleObject moduleArg) +JS::ModuleEvaluate(JSContext* cx, JS::HandleObject moduleArg) { AssertHeapIsIdle(); CHECK_REQUEST(cx); assertSameCompartment(cx, moduleArg); return ModuleObject::Evaluate(cx, moduleArg.as<ModuleObject>()); } JS_PUBLIC_API(JSObject*) @@ -4909,16 +4909,30 @@ JS_PUBLIC_API(JSScript*) JS::GetModuleScript(JSContext* cx, JS::HandleObject moduleArg) { AssertHeapIsIdle(); CHECK_REQUEST(cx); assertSameCompartment(cx, moduleArg); return moduleArg->as<ModuleObject>().script(); } +JS_PUBLIC_API(bool) +JS::IsModuleErrored(JSObject* moduleArg) +{ + AssertHeapIsIdle(); + return moduleArg->as<ModuleObject>().status() == MODULE_STATUS_ERRORED; +} + +JS_PUBLIC_API(JS::Value) +JS::GetModuleError(JSObject* moduleArg) +{ + AssertHeapIsIdle(); + return moduleArg->as<ModuleObject>().error(); +} + JS_PUBLIC_API(JSObject*) JS_New(JSContext* cx, HandleObject ctor, const JS::HandleValueArray& inputArgs) { AssertHeapIsIdle(); CHECK_REQUEST(cx); assertSameCompartment(cx, ctor, inputArgs); RootedValue ctorVal(cx, ObjectValue(*ctor));
--- a/js/src/jsapi.h +++ b/js/src/jsapi.h @@ -4650,38 +4650,37 @@ SetModuleHostDefinedField(JSObject* modu /** * Get the [[HostDefined]] field of a source text module record. */ extern JS_PUBLIC_API(JS::Value) GetModuleHostDefinedField(JSObject* module); /* - * Perform the ModuleDeclarationInstantiation operation on on the give source - * text module record. + * Perform the ModuleInstantiate operation on the given source text module + * record. * * This transitively resolves all module dependencies (calling the * HostResolveImportedModule hook) and initializes the environment record for * the module. */ extern JS_PUBLIC_API(bool) -ModuleDeclarationInstantiation(JSContext* cx, JS::HandleObject moduleRecord); +ModuleInstantiate(JSContext* cx, JS::HandleObject moduleRecord); /* - * Perform the ModuleEvaluation operation on on the give source text module - * record. + * Perform the ModuleEvaluate operation on the given source text module record. * * This does nothing if this module has already been evaluated. Otherwise, it * transitively evaluates all dependences of this module and then evaluates this * module. * - * ModuleDeclarationInstantiation must have completed prior to calling this. - */ -extern JS_PUBLIC_API(bool) -ModuleEvaluation(JSContext* cx, JS::HandleObject moduleRecord); + * ModuleInstantiate must have completed prior to calling this. + */ +extern JS_PUBLIC_API(bool) +ModuleEvaluate(JSContext* cx, JS::HandleObject moduleRecord); /* * Get a list of the module specifiers used by a source text module * record to request importation of modules. * * The result is a JavaScript array of string values. To extract the individual * values use only JS_GetArrayLength and JS_GetElement with indices 0 to * length - 1. @@ -4690,16 +4689,22 @@ extern JS_PUBLIC_API(JSObject*) GetRequestedModules(JSContext* cx, JS::HandleObject moduleRecord); /* * Get the script associated with a module. */ extern JS_PUBLIC_API(JSScript*) GetModuleScript(JSContext* cx, JS::HandleObject moduleRecord); +extern JS_PUBLIC_API(bool) +IsModuleErrored(JSObject* moduleRecord); + +extern JS_PUBLIC_API(JS::Value) +GetModuleError(JSObject* moduleRecord); + } /* namespace JS */ extern JS_PUBLIC_API(bool) JS_CheckForInterrupt(JSContext* cx); /* * These functions allow setting an interrupt callback that will be called * from the JS thread some time after any thread triggered the callback using