Issue #1691 - Part 6e: Fix problems due to divergent codebases. This gets basic dynamic import working. Fix a problem in Part 5b where Mozilla used toGCThing() and we don't. Fix a problem in Part 4 where runtime() returns nullptr in our codebase since it runs on JS Helper thread. We need to get the runtime via runtimeFromAnyThread() instead.

(cherry picked from commit dddb46225bbd1adff11f635e32934aee36923e47)
This commit is contained in:
Brian Smith 2023-04-18 11:00:34 -05:00 committed by roytam1
commit e7d0b58e56
3 changed files with 3 additions and 3 deletions

View file

@ -842,7 +842,7 @@ ModuleObject::maybeScript() const
if (value.isUndefined())
return nullptr;
return value.toGCThing()->as<JSScript>();
return static_cast<JSScript*>(value.toPrivate());
}
JSScript*

View file

@ -9088,7 +9088,7 @@ BytecodeEmitter::emitTree(ParseNode* pn, ValueUsage valueUsage /* = ValueUsage::
break;
case PNK_CALL_IMPORT:
if (!cx->asJSContext()->runtime()->moduleDynamicImportHook) {
if (!cx->compartment()->runtimeFromAnyThread()->moduleDynamicImportHook) {
reportError(nullptr, JSMSG_NO_DYNAMIC_IMPORT);
return false;
}

View file

@ -10515,7 +10515,7 @@ Parser<ParseHandler>::importExpr(YieldHandling yieldHandling)
MUST_MATCH_TOKEN_MOD(TOK_RP, TokenStream::Operand, JSMSG_PAREN_AFTER_ARGS);
if (!context->asJSContext()->runtime()->moduleDynamicImportHook && !abortIfSyntaxParser()) {
if (!context->compartment()->runtimeFromAnyThread()->moduleDynamicImportHook && !abortIfSyntaxParser()) {
return null();
}