From 17e121925013c48db7fd1f45e48442a64ddbe58b Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Tue, 11 Jun 2024 18:42:38 +0530 Subject: chore: upgrade deno_core (#24146) With changes for https://github.com/denoland/deno_core/pull/778 --- ext/node/ops/vm_internal.rs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'ext/node/ops') diff --git a/ext/node/ops/vm_internal.rs b/ext/node/ops/vm_internal.rs index bbdcba632..54b9aaa47 100644 --- a/ext/node/ops/vm_internal.rs +++ b/ext/node/ops/vm_internal.rs @@ -4,7 +4,6 @@ use deno_core::error::type_error; use deno_core::error::AnyError; use deno_core::v8; use deno_core::v8::MapFnTo; -use std::rc::Rc; pub const PRIVATE_SYMBOL_NAME: v8::OneByteConst = v8::String::create_external_onebyte_const(b"node:contextify:context"); @@ -82,13 +81,18 @@ impl ContextifyContext { sandbox_obj: v8::Local, ) { let main_context = scope.get_current_context(); - let context_state = main_context - .get_slot::>(scope) - .unwrap() - .clone(); + let context_state = main_context.get_aligned_pointer_from_embedder_data( + deno_core::CONTEXT_STATE_SLOT_INDEX, + ); v8_context.set_security_token(main_context.get_security_token(scope)); - v8_context.set_slot(scope, context_state); + // SAFETY: set embedder data from the creation context + unsafe { + v8_context.set_aligned_pointer_in_embedder_data( + deno_core::CONTEXT_STATE_SLOT_INDEX, + context_state, + ); + } let context = v8::Global::new(scope, v8_context); let sandbox = v8::Global::new(scope, sandbox_obj); @@ -102,7 +106,7 @@ impl ContextifyContext { // lives longer than the execution context, so this should be safe. unsafe { v8_context.set_aligned_pointer_in_embedder_data( - 1, + 2, ptr as *const ContextifyContext as _, ); } @@ -164,7 +168,7 @@ impl ContextifyContext { ) -> Option<&'c ContextifyContext> { let context = object.get_creation_context(scope)?; - let context_ptr = context.get_aligned_pointer_from_embedder_data(1); + let context_ptr = context.get_aligned_pointer_from_embedder_data(2); // SAFETY: We are storing a pointer to the ContextifyContext // in the embedder data of the v8::Context during creation. Some(unsafe { &*(context_ptr as *const ContextifyContext) }) -- cgit v1.2.3