Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): Add support for modules in realms. #15760

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions core/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ pub fn host_import_module_dynamically_callback<'s>(
let resolver_handle = v8::Global::new(scope, resolver);
{
let state_rc = JsRuntime::state(scope);
let module_map_rc = JsRuntime::module_map(scope);
let module_map_rc = JsRealm::module_map_from_scope(scope);

debug!(
"dyn_import specifier {} referrer {} ",
Expand Down Expand Up @@ -337,7 +337,7 @@ pub extern "C" fn host_initialize_import_meta_object_callback(
) {
// SAFETY: `CallbackScope` can be safely constructed from `Local<Context>`
let scope = &mut unsafe { v8::CallbackScope::new(context) };
let module_map_rc = JsRuntime::module_map(scope);
let module_map_rc = JsRealm::module_map_from_scope(scope);
let module_map = module_map_rc.borrow();

let module_global = v8::Global::new(scope, module);
Expand Down Expand Up @@ -380,7 +380,7 @@ fn import_meta_resolve(
let url_prop = args.data();
url_prop.to_rust_string_lossy(scope)
};
let module_map_rc = JsRuntime::module_map(scope);
let module_map_rc = JsRealm::module_map_from_scope(scope);
let (loader, snapshot_loaded_and_not_snapshotting) = {
let module_map = module_map_rc.borrow();
(
Expand Down Expand Up @@ -511,7 +511,7 @@ pub extern "C" fn promise_reject_callback(message: v8::PromiseRejectMessage) {
};

if has_unhandled_rejection_handler {
let state_rc = JsRuntime::state(tc_scope);
let state_rc = JsRealm::state_from_scope(tc_scope);
let mut state = state_rc.borrow_mut();
if let Some(pending_mod_evaluate) = state.pending_mod_evaluate.as_mut() {
if !pending_mod_evaluate.has_evaluated {
Expand Down Expand Up @@ -609,7 +609,7 @@ pub fn module_resolve_callback<'s>(
// SAFETY: `CallbackScope` can be safely constructed from `Local<Context>`
let scope = &mut unsafe { v8::CallbackScope::new(context) };

let module_map_rc = JsRuntime::module_map(scope);
let module_map_rc = JsRealm::module_map_from_scope(scope);
let module_map = module_map_rc.borrow();

let referrer_global = v8::Global::new(scope, referrer);
Expand Down
4 changes: 2 additions & 2 deletions core/modules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::module_specifier::ModuleSpecifier;
use crate::resolve_import;
use crate::resolve_url;
use crate::snapshot_util::SnapshottedData;
use crate::JsRuntime;
use crate::JsRealm;
use crate::OpState;
use anyhow::Error;
use core::panic;
Expand Down Expand Up @@ -135,7 +135,7 @@ fn json_module_evaluation_steps<'a>(
// SAFETY: `CallbackScope` can be safely constructed from `Local<Context>`
let scope = &mut unsafe { v8::CallbackScope::new(context) };
let tc_scope = &mut v8::TryCatch::new(scope);
let module_map = JsRuntime::module_map(tc_scope);
let module_map = JsRealm::module_map_from_scope(tc_scope);

let handle = v8::Global::<v8::Module>::new(tc_scope, module);
let value_handle = module_map
Expand Down
Loading