diff options
author | Andreas Kling <kling@serenityos.org> | 2022-09-05 14:31:25 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-09-06 00:27:09 +0200 |
commit | 00c8f071923a6d6fbbd4fe989dd6980d3a6b18af (patch) | |
tree | 4b01357deed0a36349d11cb275c66f3f28a673d9 /Userland/Libraries/LibJS/SyntheticModule.cpp | |
parent | cb151321463b133fbdfff57c0ab25da067e66410 (diff) | |
download | serenity-00c8f071923a6d6fbbd4fe989dd6980d3a6b18af.zip |
LibJS: Make Script and Module GC-allocated
This ensures that code currently in any active or saved execution stack
always stays alive.
Diffstat (limited to 'Userland/Libraries/LibJS/SyntheticModule.cpp')
-rw-r--r-- | Userland/Libraries/LibJS/SyntheticModule.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Userland/Libraries/LibJS/SyntheticModule.cpp b/Userland/Libraries/LibJS/SyntheticModule.cpp index bf76e76106..65f0ee9a48 100644 --- a/Userland/Libraries/LibJS/SyntheticModule.cpp +++ b/Userland/Libraries/LibJS/SyntheticModule.cpp @@ -86,7 +86,7 @@ ThrowCompletionOr<Promise*> SyntheticModule::evaluate(VM& vm) module_context.realm = &realm(); // 5. Set the ScriptOrModule of moduleContext to module. - module_context.script_or_module = this->make_weak_ptr(); + module_context.script_or_module = NonnullGCPtr<Module>(*this); // 6. Set the VariableEnvironment of moduleContext to module.[[Environment]]. module_context.variable_environment = environment(); @@ -129,7 +129,7 @@ ThrowCompletionOr<void> SyntheticModule::set_synthetic_module_export(FlyString c } // 1.3 CreateDefaultExportSyntheticModule ( defaultExport ), https://tc39.es/proposal-json-modules/#sec-create-default-export-synthetic-module -NonnullRefPtr<SyntheticModule> SyntheticModule::create_default_export_synthetic_module(Value default_export, Realm& realm, StringView filename) +NonnullGCPtr<SyntheticModule> SyntheticModule::create_default_export_synthetic_module(Value default_export, Realm& realm, StringView filename) { // Note: Has some changes from PR: https://github.com/tc39/proposal-json-modules/pull/13. // 1. Let closure be the a Abstract Closure with parameters (module) that captures defaultExport and performs the following steps when called: @@ -139,11 +139,11 @@ NonnullRefPtr<SyntheticModule> SyntheticModule::create_default_export_synthetic_ }; // 2. Return CreateSyntheticModule("default", closure, realm) - return adopt_ref(*new SyntheticModule({ "default" }, move(closure), realm, filename)); + return *realm.heap().allocate_without_realm<SyntheticModule>(Vector<FlyString> { "default" }, move(closure), realm, filename); } // 1.4 ParseJSONModule ( source ), https://tc39.es/proposal-json-modules/#sec-parse-json-module -ThrowCompletionOr<NonnullRefPtr<Module>> parse_json_module(StringView source_text, Realm& realm, StringView filename) +ThrowCompletionOr<NonnullGCPtr<Module>> parse_json_module(StringView source_text, Realm& realm, StringView filename) { auto& vm = realm.vm(); |