mirror of
https://github.com/denoland/deno.git
synced 2025-01-03 04:48:52 -05:00
This reverts commit 022aae9854
.
This commit is contained in:
parent
df1ca4a158
commit
7da8b1d9bb
3 changed files with 0 additions and 68 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -876,7 +876,6 @@ dependencies = [
|
||||||
"serde_v8",
|
"serde_v8",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
"sourcemap",
|
"sourcemap",
|
||||||
"tikv-jemalloc-sys",
|
|
||||||
"tokio",
|
"tokio",
|
||||||
"url",
|
"url",
|
||||||
"v8",
|
"v8",
|
||||||
|
|
|
@ -39,9 +39,6 @@ sourcemap = "6.1"
|
||||||
url.workspace = true
|
url.workspace = true
|
||||||
v8.workspace = true
|
v8.workspace = true
|
||||||
|
|
||||||
[target.'cfg(not(target_env = "msvc"))'.dependencies]
|
|
||||||
tikv-jemalloc-sys.workspace = true
|
|
||||||
|
|
||||||
[[example]]
|
[[example]]
|
||||||
name = "http_bench_json_ops"
|
name = "http_bench_json_ops"
|
||||||
path = "examples/http_bench_json_ops/main.rs"
|
path = "examples/http_bench_json_ops/main.rs"
|
||||||
|
|
|
@ -72,48 +72,6 @@ struct IsolateAllocations {
|
||||||
Option<(Box<RefCell<dyn Any>>, v8::NearHeapLimitCallback)>,
|
Option<(Box<RefCell<dyn Any>>, v8::NearHeapLimitCallback)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A custom allocator for array buffers for V8. It uses `jemalloc` so it's
|
|
||||||
/// not available on Windows.
|
|
||||||
#[cfg(not(target_env = "msvc"))]
|
|
||||||
mod custom_allocator {
|
|
||||||
use std::ffi::c_void;
|
|
||||||
|
|
||||||
pub struct RustAllocator;
|
|
||||||
|
|
||||||
pub unsafe extern "C" fn allocate(
|
|
||||||
_alloc: &RustAllocator,
|
|
||||||
n: usize,
|
|
||||||
) -> *mut c_void {
|
|
||||||
tikv_jemalloc_sys::calloc(1, n)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub unsafe extern "C" fn allocate_uninitialized(
|
|
||||||
_alloc: &RustAllocator,
|
|
||||||
n: usize,
|
|
||||||
) -> *mut c_void {
|
|
||||||
tikv_jemalloc_sys::malloc(n)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub unsafe extern "C" fn free(
|
|
||||||
_alloc: &RustAllocator,
|
|
||||||
data: *mut c_void,
|
|
||||||
_n: usize,
|
|
||||||
) {
|
|
||||||
tikv_jemalloc_sys::free(data)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub unsafe extern "C" fn reallocate(
|
|
||||||
_alloc: &RustAllocator,
|
|
||||||
prev: *mut c_void,
|
|
||||||
_oldlen: usize,
|
|
||||||
newlen: usize,
|
|
||||||
) -> *mut c_void {
|
|
||||||
tikv_jemalloc_sys::realloc(prev, newlen)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub unsafe extern "C" fn drop(_alloc: *const RustAllocator) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A single execution context of JavaScript. Corresponds roughly to the "Web
|
/// A single execution context of JavaScript. Corresponds roughly to the "Web
|
||||||
/// Worker" concept in the DOM. A JsRuntime is a Future that can be used with
|
/// Worker" concept in the DOM. A JsRuntime is a Future that can be used with
|
||||||
/// an event loop (Tokio, async_std).
|
/// an event loop (Tokio, async_std).
|
||||||
|
@ -435,20 +393,6 @@ impl JsRuntime {
|
||||||
}
|
}
|
||||||
isolate
|
isolate
|
||||||
} else {
|
} else {
|
||||||
#[cfg(not(target_env = "msvc"))]
|
|
||||||
let vtable: &'static v8::RustAllocatorVtable<
|
|
||||||
custom_allocator::RustAllocator,
|
|
||||||
> = &v8::RustAllocatorVtable {
|
|
||||||
allocate: custom_allocator::allocate,
|
|
||||||
allocate_uninitialized: custom_allocator::allocate_uninitialized,
|
|
||||||
free: custom_allocator::free,
|
|
||||||
reallocate: custom_allocator::reallocate,
|
|
||||||
drop: custom_allocator::drop,
|
|
||||||
};
|
|
||||||
#[cfg(not(target_env = "msvc"))]
|
|
||||||
let allocator = Arc::new(custom_allocator::RustAllocator);
|
|
||||||
|
|
||||||
#[allow(unused_mut)]
|
|
||||||
let mut params = options
|
let mut params = options
|
||||||
.create_params
|
.create_params
|
||||||
.take()
|
.take()
|
||||||
|
@ -460,14 +404,6 @@ impl JsRuntime {
|
||||||
})
|
})
|
||||||
.external_references(&**refs);
|
.external_references(&**refs);
|
||||||
|
|
||||||
#[cfg(not(target_env = "msvc"))]
|
|
||||||
// SAFETY: We are leaking the created `allocator` variable so we're sure
|
|
||||||
// it will outlive the created isolate. We also made sure that the vtable
|
|
||||||
// is correct.
|
|
||||||
let mut params = params.array_buffer_allocator(unsafe {
|
|
||||||
v8::new_rust_allocator(Arc::into_raw(allocator), vtable)
|
|
||||||
});
|
|
||||||
|
|
||||||
if let Some(snapshot) = options.startup_snapshot {
|
if let Some(snapshot) = options.startup_snapshot {
|
||||||
params = match snapshot {
|
params = match snapshot {
|
||||||
Snapshot::Static(data) => params.snapshot_blob(data),
|
Snapshot::Static(data) => params.snapshot_blob(data),
|
||||||
|
|
Loading…
Reference in a new issue