diff options
Diffstat (limited to 'js/src/vm/SelfHosting.cpp')
-rw-r--r-- | js/src/vm/SelfHosting.cpp | 28 |
1 files changed, 8 insertions, 20 deletions
diff --git a/js/src/vm/SelfHosting.cpp b/js/src/vm/SelfHosting.cpp index 0dfeffc36..f324a0a67 100644 --- a/js/src/vm/SelfHosting.cpp +++ b/js/src/vm/SelfHosting.cpp @@ -2026,36 +2026,26 @@ intrinsic_HostResolveImportedModule(JSContext* cx, unsigned argc, Value* vp) { CallArgs args = CallArgsFromVp(argc, vp); MOZ_ASSERT(args.length() == 2); - MOZ_ASSERT(args[0].toObject().is<ModuleObject>()); - MOZ_ASSERT(args[1].isString()); + RootedModuleObject module(cx, &args[0].toObject().as<ModuleObject>()); + RootedString specifier(cx, args[1].toString()); - RootedFunction moduleResolveHook(cx, cx->global()->moduleResolveHook()); + JS::ModuleResolveHook moduleResolveHook = cx->runtime()->moduleResolveHook; if (!moduleResolveHook) { JS_ReportErrorASCII(cx, "Module resolve hook not set"); return false; } - RootedValue result(cx); - if (!JS_CallFunction(cx, nullptr, moduleResolveHook, args, &result)) + RootedObject result(cx); + result = moduleResolveHook(cx, module, specifier); + if (!result) return false; - if (!result.isObject() || !result.toObject().is<ModuleObject>()) { + if (!result->is<ModuleObject>()) { JS_ReportErrorASCII(cx, "Module resolve hook did not return Module object"); return false; } - args.rval().set(result); - return true; -} - -static bool -intrinsic_CreateModuleEnvironment(JSContext* cx, unsigned argc, Value* vp) -{ - CallArgs args = CallArgsFromVp(argc, vp); - MOZ_ASSERT(args.length() == 1); - RootedModuleObject module(cx, &args[0].toObject().as<ModuleObject>()); - module->createEnvironment(); - args.rval().setUndefined(); + args.rval().setObject(*result); return true; } @@ -2087,7 +2077,6 @@ intrinsic_CreateNamespaceBinding(JSContext* cx, unsigned argc, Value* vp) // the slot directly. RootedShape shape(cx, environment->lookup(cx, name)); MOZ_ASSERT(shape); - MOZ_ASSERT(environment->getSlot(shape->slot()).isMagic(JS_UNINITIALIZED_LEXICAL)); environment->setSlot(shape->slot(), args[2]); args.rval().setUndefined(); return true; @@ -2659,7 +2648,6 @@ static const JSFunctionSpec intrinsic_functions[] = { CallNonGenericSelfhostedMethod<Is<ModuleObject>>, 2, 0), JS_FN("HostResolveImportedModule", intrinsic_HostResolveImportedModule, 2, 0), JS_FN("IsModuleEnvironment", intrinsic_IsInstanceOfBuiltin<ModuleEnvironmentObject>, 1, 0), - JS_FN("CreateModuleEnvironment", intrinsic_CreateModuleEnvironment, 1, 0), JS_FN("CreateImportBinding", intrinsic_CreateImportBinding, 4, 0), JS_FN("CreateNamespaceBinding", intrinsic_CreateNamespaceBinding, 3, 0), JS_FN("InstantiateModuleFunctionDeclarations", |