Skip to content

Commit 1ccf3a7

Browse files
committed
what about ff147?
1 parent 9c16db9 commit 1ccf3a7

File tree

5 files changed

+53
-13
lines changed

5 files changed

+53
-13
lines changed

builtins/web/crypto/uuid.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#include "uuid.h"
22
#include "host_api.h"
33

4+
#include <fmt/format.h>
5+
46

57

68
namespace builtins::web::crypto {

builtins/web/event/event-target.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ template <typename T> struct GCPolicy<RefPtr<T>> {
123123
}
124124
return true;
125125
}
126+
static constexpr bool mightBeInNursery() { return false; }
126127
};
127128

128129
} // namespace JS

cmake/spidermonkey.cmake

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
set(SM_TAG FIREFOX_140_0_4_RELEASE_STARLING)
1+
set(SM_TAG FIREFOX_147_0_4_RELEASE_STARLING)
22

33
include("manage-git-source")
44

@@ -12,7 +12,6 @@ option(WEVAL "Build with a SpiderMonkey variant that supports weval-based AOT co
1212

1313
if (WEVAL)
1414
set(SM_BUILD_TYPE "${SM_BUILD_TYPE}_weval")
15-
set(SM_TAG WEVAL)
1615
endif()
1716

1817
# If the developer has specified an alternate local set of SpiderMonkey

runtime/engine.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <cassert>
1616
#include <chrono>
1717
#include <cstdlib>
18+
#include <fmt/format.h>
1819
#include <utility>
1920

2021
#ifdef MEM_STATS

runtime/script_loader.cpp

Lines changed: 48 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <cstdio>
55
#include <js/CompilationAndEvaluation.h>
66
#include <js/MapAndSet.h>
7+
#include <js/ScriptPrivate.h>
78
#include <js/Value.h>
89
#include <jsfriendapi.h>
910
#include <sys/stat.h>
@@ -310,36 +311,54 @@ static JSObject* get_builtin_module(JSContext* cx, HandleValue id, HandleObject
310311
return module;
311312
}
312313

313-
JSObject* module_resolve_hook(JSContext* cx, HandleValue referencingPrivate,
314-
HandleObject moduleRequest) {
314+
bool module_load_hook(JSContext* cx, JS::HandleScript referrer,
315+
JS::HandleObject moduleRequest, JS::HandleValue hostDefined,
316+
JS::HandleValue payload, uint32_t lineNumber,
317+
JS::ColumnNumberOneOrigin columnNumber) {
315318
RootedString specifier(cx, GetModuleRequestSpecifier(cx, moduleRequest));
316319
if (!specifier) {
317-
return nullptr;
320+
return false;
318321
}
319322

320323
RootedValue path_val(cx, StringValue(specifier));
321324
auto path = JS_EncodeStringToUTF8(cx, specifier);
322325
if (!path) {
323-
return nullptr;
326+
return false;
324327
}
325328

326329
RootedValue builtin_val(cx);
327330
if (!MapGet(cx, builtinModules, path_val, &builtin_val)) {
328-
return nullptr;
331+
return false;
329332
}
330333
if (!builtin_val.isUndefined()) {
331334
RootedValue specifier_val(cx, StringValue(specifier));
332335
RootedObject builtin_obj(cx, &builtin_val.toObject());
333-
return get_builtin_module(cx, specifier_val, builtin_obj);
336+
RootedObject result(cx, get_builtin_module(cx, specifier_val, builtin_obj));
337+
if (!result) {
338+
return false;
339+
}
340+
return FinishLoadingImportedModule(cx, referrer, moduleRequest, payload,
341+
result, false);
342+
}
343+
344+
RootedValue referencingPrivate(cx);
345+
if (referrer) {
346+
referencingPrivate = JS::GetScriptPrivate(referrer);
347+
}
348+
349+
if (referencingPrivate.isUndefined() || !referencingPrivate.isObject()) {
350+
JS_ReportErrorASCII(cx, "Module referrer has no private value");
351+
return false;
334352
}
335353

336354
RootedObject info(cx, &referencingPrivate.toObject());
337355
RootedValue parent_path_val(cx);
338356
if (!JS_GetProperty(cx, info, "id", &parent_path_val)) {
339-
return nullptr;
357+
return false;
340358
}
341359
if (!parent_path_val.isString()) {
342-
return nullptr;
360+
JS_ReportErrorASCII(cx, "Module referrer has no id property");
361+
return false;
343362
}
344363

345364
HostString str = core::encode(cx, parent_path_val);
@@ -348,7 +367,12 @@ JSObject* module_resolve_hook(JSContext* cx, HandleValue referencingPrivate,
348367
JS::CompileOptions opts(cx, *COMPILE_OPTS);
349368
auto stripped = strip_prefix(resolved_path, PATH_PREFIX);
350369
opts.setFileAndLine(stripped.c_str(), 1);
351-
return get_module(cx, path.get(), resolved_path, opts);
370+
RootedObject result(cx, get_module(cx, path.get(), resolved_path, opts));
371+
if (!result) {
372+
return false;
373+
}
374+
return FinishLoadingImportedModule(cx, referrer, moduleRequest, payload,
375+
result, false);
352376
}
353377

354378
bool module_metadata_hook(JSContext* cx, HandleValue referencingPrivate, HandleObject metaObject) {
@@ -384,7 +408,7 @@ ScriptLoader::ScriptLoader(api::Engine* engine, JS::CompileOptions *opts,
384408
MOZ_RELEASE_ASSERT(moduleRegistry);
385409
MOZ_RELEASE_ASSERT(builtinModules);
386410
JSRuntime *rt = JS_GetRuntime(cx);
387-
SetModuleResolveHook(rt, module_resolve_hook);
411+
SetModuleLoadHook(rt, module_load_hook);
388412
SetModuleMetadataHook(rt, module_metadata_hook);
389413
}
390414

@@ -491,7 +515,20 @@ bool ScriptLoader::eval_top_level_script(std::string_view path, JS::SourceText<m
491515
if (!module) {
492516
return false;
493517
}
494-
if (!ModuleLink(cx, module)) {
518+
RootedValue hostDefined(cx, ObjectValue(*module));
519+
if (!LoadRequestedModules(cx, module, hostDefined,
520+
[](JSContext* cx, JS::Handle<JS::Value> hd) {
521+
JS::RootedObject mod(cx, &hd.toObject());
522+
return JS::ModuleLink(cx, mod);
523+
},
524+
[](JSContext* cx, JS::Handle<JS::Value>,
525+
JS::Handle<JS::Value> error) {
526+
JS_SetPendingException(cx, error);
527+
return true;
528+
})) {
529+
return false;
530+
}
531+
if (JS_IsExceptionPending(cx)) {
495532
return false;
496533
}
497534
} else {

0 commit comments

Comments
 (0)