From 3f25d0c8e4d9296f0d45c85c251eab71f076937b Mon Sep 17 00:00:00 2001 From: Moonchild Date: Fri, 3 Jul 2020 13:56:49 +0000 Subject: Issue #618 - Align module instantiation/errors with the updated spec. Store and re-throw module instantiation and evaluation errors. Ref: BZ 1374239, 1394492 --- js/src/builtin/ModuleObject.h | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) (limited to 'js/src/builtin/ModuleObject.h') diff --git a/js/src/builtin/ModuleObject.h b/js/src/builtin/ModuleObject.h index 22db762ac..365fcd4bf 100644 --- a/js/src/builtin/ModuleObject.h +++ b/js/src/builtin/ModuleObject.h @@ -192,8 +192,8 @@ struct FunctionDeclaration using FunctionDeclarationVector = GCVector; -// Possible values for ModuleState are defined in SelfHostingDefines.h. -using ModuleState = int32_t; +// Possible values for ModuleStatus are defined in SelfHostingDefines.h. +using ModuleStatus = int32_t; class ModuleObject : public NativeObject { @@ -204,7 +204,8 @@ class ModuleObject : public NativeObject InitialEnvironmentSlot, EnvironmentSlot, NamespaceSlot, - StateSlot, + StatusSlot, + ErrorSlot, HostDefinedSlot, RequestedModulesSlot, ImportEntriesSlot, @@ -215,11 +216,21 @@ class ModuleObject : public NativeObject NamespaceExportsSlot, NamespaceBindingsSlot, FunctionDeclarationsSlot, + DFSIndexSlot, + DFSAncestorIndexSlot, SlotCount }; static_assert(EnvironmentSlot == MODULE_OBJECT_ENVIRONMENT_SLOT, "EnvironmentSlot must match self-hosting define"); + static_assert(StatusSlot == MODULE_OBJECT_STATUS_SLOT, + "StatusSlot must match self-hosting define"); + static_assert(ErrorSlot == MODULE_OBJECT_ERROR_SLOT, + "ErrorSlot must match self-hosting define"); + static_assert(DFSIndexSlot == MODULE_OBJECT_DFS_INDEX_SLOT, + "DFSIndexSlot must match self-hosting define"); + static_assert(DFSAncestorIndexSlot == MODULE_OBJECT_DFS_ANCESTOR_INDEX_SLOT, + "DFSAncestorIndexSlot must match self-hosting define"); static const Class class_; @@ -244,7 +255,8 @@ class ModuleObject : public NativeObject ModuleEnvironmentObject& initialEnvironment() const; ModuleEnvironmentObject* environment() const; ModuleNamespaceObject* namespace_(); - ModuleState state() const; + ModuleStatus status() const; + Value error() const; Value hostDefinedField() const; ArrayObject& requestedModules() const; ArrayObject& importEntries() const; @@ -255,8 +267,8 @@ class ModuleObject : public NativeObject JSObject* namespaceExports(); IndirectBindingMap* namespaceBindings(); - static bool DeclarationInstantiation(JSContext* cx, HandleModuleObject self); - static bool Evaluation(JSContext* cx, HandleModuleObject self); + static bool Instantiate(JSContext* cx, HandleModuleObject self); + static bool Evaluate(JSContext* cx, HandleModuleObject self); void setHostDefinedField(const JS::Value& value); @@ -269,10 +281,8 @@ class ModuleObject : public NativeObject // For intrinsic_InstantiateModuleFunctionDeclarations. static bool instantiateFunctionDeclarations(JSContext* cx, HandleModuleObject self); - void setState(ModuleState newState); - - // For intrinsic_EvaluateModule. - static bool evaluate(JSContext* cx, HandleModuleObject self, MutableHandleValue rval); + // For intrinsic_ExecuteModule. + static bool execute(JSContext* cx, HandleModuleObject self, MutableHandleValue rval); // For intrinsic_NewModuleNamespace. static ModuleNamespaceObject* createNamespace(JSContext* cx, HandleModuleObject self, -- cgit v1.2.3