diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/lib.rs | 2 | ||||
-rw-r--r-- | core/resources.rs | 7 | ||||
-rw-r--r-- | core/runtime.rs | 10 |
3 files changed, 18 insertions, 1 deletions
diff --git a/core/lib.rs b/core/lib.rs index ab22392c4..57e81ee7a 100644 --- a/core/lib.rs +++ b/core/lib.rs @@ -101,6 +101,8 @@ pub use crate::runtime::JsRuntime; pub use crate::runtime::RuntimeOptions; pub use crate::runtime::SharedArrayBufferStore; pub use crate::runtime::Snapshot; +pub use crate::runtime::V8_WRAPPER_OBJECT_INDEX; +pub use crate::runtime::V8_WRAPPER_TYPE_INDEX; pub use crate::source_map::SourceMapGetter; pub use deno_ops::op; diff --git a/core/resources.rs b/core/resources.rs index a4bb3607d..82b079201 100644 --- a/core/resources.rs +++ b/core/resources.rs @@ -64,6 +64,13 @@ pub trait Resource: Any + 'static { /// resource specific clean-ups, such as cancelling pending futures, after a /// resource has been removed from the resource table. fn close(self: Rc<Self>) {} + + /// Resources backed by a file descriptor can let ops know to allow for + /// low-level optimizations. + #[cfg(unix)] + fn backing_fd(self: Rc<Self>) -> Option<std::os::unix::prelude::RawFd> { + None + } } impl dyn Resource { diff --git a/core/runtime.rs b/core/runtime.rs index 7f113223f..def38e1eb 100644 --- a/core/runtime.rs +++ b/core/runtime.rs @@ -250,6 +250,9 @@ fn v8_init( v8::V8::initialize(); } +pub const V8_WRAPPER_TYPE_INDEX: i32 = 0; +pub const V8_WRAPPER_OBJECT_INDEX: i32 = 1; + #[derive(Default)] pub struct RuntimeOptions { /// Source map reference for errors. @@ -360,7 +363,12 @@ impl JsRuntime { let mut params = options .create_params .take() - .unwrap_or_else(v8::Isolate::create_params) + .unwrap_or_else(|| { + v8::CreateParams::default().embedder_wrapper_type_info_offsets( + V8_WRAPPER_TYPE_INDEX, + V8_WRAPPER_OBJECT_INDEX, + ) + }) .external_references(&**bindings::EXTERNAL_REFERENCES); let snapshot_loaded = if let Some(snapshot) = options.startup_snapshot { params = match snapshot { |