mirror of
https://github.com/denoland/deno.git
synced 2024-12-22 07:14:47 -05:00
Rename deno_core::Isolate to deno_core::CoreIsolate (#4851)
This commit is contained in:
parent
10a174834e
commit
d8711155ca
36 changed files with 253 additions and 227 deletions
10
cli/build.rs
10
cli/build.rs
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
||||
use deno_core::include_crate_modules;
|
||||
use deno_core::Isolate;
|
||||
use deno_core::CoreIsolate;
|
||||
use deno_core::StartupData;
|
||||
use std::collections::HashMap;
|
||||
use std::env;
|
||||
|
@ -48,10 +48,10 @@ fn main() {
|
|||
.expect("Bundle compilation failed");
|
||||
assert!(bundle_path.exists());
|
||||
|
||||
let runtime_isolate = &mut Isolate::new(StartupData::None, true);
|
||||
let mut runtime_isolate = CoreIsolate::new(StartupData::None, true);
|
||||
|
||||
deno_typescript::mksnapshot_bundle(
|
||||
runtime_isolate,
|
||||
&mut runtime_isolate,
|
||||
&snapshot_path,
|
||||
&bundle_path,
|
||||
&main_module_name,
|
||||
|
@ -71,7 +71,7 @@ fn main() {
|
|||
.expect("Bundle compilation failed");
|
||||
assert!(bundle_path.exists());
|
||||
|
||||
let runtime_isolate = &mut Isolate::new(StartupData::None, true);
|
||||
let mut runtime_isolate = CoreIsolate::new(StartupData::None, true);
|
||||
|
||||
let mut custom_libs: HashMap<String, PathBuf> = HashMap::new();
|
||||
custom_libs.insert(
|
||||
|
@ -96,7 +96,7 @@ fn main() {
|
|||
);
|
||||
|
||||
deno_typescript::mksnapshot_bundle_ts(
|
||||
runtime_isolate,
|
||||
&mut runtime_isolate,
|
||||
&snapshot_path,
|
||||
&bundle_path,
|
||||
&main_module_name,
|
||||
|
|
|
@ -308,11 +308,11 @@ impl DenoInspector {
|
|||
const CONTEXT_GROUP_ID: i32 = 1;
|
||||
|
||||
pub fn new(
|
||||
isolate: &mut deno_core::Isolate,
|
||||
isolate: &mut deno_core::CoreIsolate,
|
||||
host: SocketAddr,
|
||||
wait_for_debugger: bool,
|
||||
) -> Box<Self> {
|
||||
let deno_core::Isolate {
|
||||
let deno_core::CoreIsolate {
|
||||
v8_isolate,
|
||||
global_context,
|
||||
..
|
||||
|
|
|
@ -23,7 +23,7 @@ pub static WINDOW_LIB: &str = include_str!("js/lib.deno.window.d.ts");
|
|||
|
||||
#[test]
|
||||
fn cli_snapshot() {
|
||||
let mut isolate = deno_core::Isolate::new(
|
||||
let mut isolate = deno_core::CoreIsolate::new(
|
||||
deno_core::StartupData::Snapshot(deno_core::Snapshot::Static(CLI_SNAPSHOT)),
|
||||
false,
|
||||
);
|
||||
|
@ -40,7 +40,7 @@ fn cli_snapshot() {
|
|||
|
||||
#[test]
|
||||
fn compiler_snapshot() {
|
||||
let mut isolate = deno_core::Isolate::new(
|
||||
let mut isolate = deno_core::CoreIsolate::new(
|
||||
deno_core::StartupData::Snapshot(deno_core::Snapshot::Static(
|
||||
COMPILER_SNAPSHOT,
|
||||
)),
|
||||
|
|
|
@ -6,11 +6,13 @@ use crate::futures::future::try_join_all;
|
|||
use crate::msg;
|
||||
use crate::op_error::OpError;
|
||||
use crate::state::State;
|
||||
use deno_core::CoreIsolate;
|
||||
use deno_core::ModuleLoader;
|
||||
use deno_core::*;
|
||||
use deno_core::ModuleSpecifier;
|
||||
use deno_core::ZeroCopyBuf;
|
||||
use futures::future::FutureExt;
|
||||
|
||||
pub fn init(i: &mut Isolate, s: &State) {
|
||||
pub fn init(i: &mut CoreIsolate, s: &State) {
|
||||
i.register_op("op_cache", s.stateful_json_op(op_cache));
|
||||
i.register_op("op_resolve_modules", s.stateful_json_op(op_resolve_modules));
|
||||
i.register_op(
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
||||
use crate::op_error::OpError;
|
||||
use deno_core::*;
|
||||
use deno_core::Buf;
|
||||
use deno_core::CoreIsolate;
|
||||
use deno_core::Op;
|
||||
use deno_core::ZeroCopyBuf;
|
||||
use futures::future::FutureExt;
|
||||
pub use serde_derive::Deserialize;
|
||||
use serde_json::json;
|
||||
|
@ -43,15 +46,12 @@ struct AsyncArgs {
|
|||
|
||||
pub fn json_op<D>(
|
||||
d: D,
|
||||
) -> impl Fn(&mut deno_core::Isolate, &[u8], Option<ZeroCopyBuf>) -> Op
|
||||
) -> impl Fn(&mut CoreIsolate, &[u8], Option<ZeroCopyBuf>) -> Op
|
||||
where
|
||||
D: Fn(
|
||||
&mut deno_core::Isolate,
|
||||
Value,
|
||||
Option<ZeroCopyBuf>,
|
||||
) -> Result<JsonOp, OpError>,
|
||||
D:
|
||||
Fn(&mut CoreIsolate, Value, Option<ZeroCopyBuf>) -> Result<JsonOp, OpError>,
|
||||
{
|
||||
move |isolate: &mut deno_core::Isolate,
|
||||
move |isolate: &mut CoreIsolate,
|
||||
control: &[u8],
|
||||
zero_copy: Option<ZeroCopyBuf>| {
|
||||
let async_args: AsyncArgs = match serde_json::from_slice(control) {
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
use crate::op_error::OpError;
|
||||
use byteorder::{LittleEndian, WriteBytesExt};
|
||||
use deno_core::Buf;
|
||||
use deno_core::CoreIsolate;
|
||||
use deno_core::Op;
|
||||
use deno_core::ZeroCopyBuf;
|
||||
use futures::future::FutureExt;
|
||||
|
@ -115,11 +116,11 @@ fn test_parse_min_record() {
|
|||
|
||||
pub fn minimal_op<D>(
|
||||
d: D,
|
||||
) -> impl Fn(&mut deno_core::Isolate, &[u8], Option<ZeroCopyBuf>) -> Op
|
||||
) -> impl Fn(&mut CoreIsolate, &[u8], Option<ZeroCopyBuf>) -> Op
|
||||
where
|
||||
D: Fn(&mut deno_core::Isolate, bool, i32, Option<ZeroCopyBuf>) -> MinimalOp,
|
||||
D: Fn(&mut CoreIsolate, bool, i32, Option<ZeroCopyBuf>) -> MinimalOp,
|
||||
{
|
||||
move |isolate: &mut deno_core::Isolate,
|
||||
move |isolate: &mut CoreIsolate,
|
||||
control: &[u8],
|
||||
zero_copy: Option<ZeroCopyBuf>| {
|
||||
let mut record = match parse_min_record(control) {
|
||||
|
|
|
@ -5,10 +5,11 @@ use crate::op_error::OpError;
|
|||
use crate::source_maps::get_orig_position;
|
||||
use crate::source_maps::CachedMaps;
|
||||
use crate::state::State;
|
||||
use deno_core::*;
|
||||
use deno_core::CoreIsolate;
|
||||
use deno_core::ZeroCopyBuf;
|
||||
use std::collections::HashMap;
|
||||
|
||||
pub fn init(i: &mut Isolate, s: &State) {
|
||||
pub fn init(i: &mut CoreIsolate, s: &State) {
|
||||
i.register_op(
|
||||
"op_apply_source_map",
|
||||
s.stateful_json_op(op_apply_source_map),
|
||||
|
|
|
@ -4,14 +4,15 @@ use super::io::{StreamResource, StreamResourceHolder};
|
|||
use crate::http_util::{create_http_client, HttpBody};
|
||||
use crate::op_error::OpError;
|
||||
use crate::state::State;
|
||||
use deno_core::*;
|
||||
use deno_core::CoreIsolate;
|
||||
use deno_core::ZeroCopyBuf;
|
||||
use futures::future::FutureExt;
|
||||
use http::header::HeaderName;
|
||||
use http::header::HeaderValue;
|
||||
use http::Method;
|
||||
use std::convert::From;
|
||||
|
||||
pub fn init(i: &mut Isolate, s: &State) {
|
||||
pub fn init(i: &mut CoreIsolate, s: &State) {
|
||||
i.register_op("op_fetch", s.stateful_json_op2(op_fetch));
|
||||
}
|
||||
|
||||
|
@ -23,7 +24,7 @@ struct FetchArgs {
|
|||
}
|
||||
|
||||
pub fn op_fetch(
|
||||
isolate: &mut deno_core::Isolate,
|
||||
isolate: &mut CoreIsolate,
|
||||
state: &State,
|
||||
args: Value,
|
||||
data: Option<ZeroCopyBuf>,
|
||||
|
|
|
@ -7,7 +7,7 @@ use crate::fs::resolve_from_cwd;
|
|||
use crate::op_error::OpError;
|
||||
use crate::ops::dispatch_json::JsonResult;
|
||||
use crate::state::State;
|
||||
use deno_core::Isolate;
|
||||
use deno_core::CoreIsolate;
|
||||
use deno_core::ZeroCopyBuf;
|
||||
use futures::future::FutureExt;
|
||||
use std::convert::From;
|
||||
|
@ -17,7 +17,7 @@ use std::time::UNIX_EPOCH;
|
|||
|
||||
use rand::{thread_rng, Rng};
|
||||
|
||||
pub fn init(i: &mut Isolate, s: &State) {
|
||||
pub fn init(i: &mut CoreIsolate, s: &State) {
|
||||
i.register_op("op_open", s.stateful_json_op2(op_open));
|
||||
i.register_op("op_seek", s.stateful_json_op2(op_seek));
|
||||
i.register_op("op_umask", s.stateful_json_op(op_umask));
|
||||
|
@ -68,7 +68,7 @@ struct OpenOptions {
|
|||
}
|
||||
|
||||
fn op_open(
|
||||
isolate: &mut deno_core::Isolate,
|
||||
isolate: &mut CoreIsolate,
|
||||
state: &State,
|
||||
args: Value,
|
||||
_zero_copy: Option<ZeroCopyBuf>,
|
||||
|
@ -205,7 +205,7 @@ struct SeekArgs {
|
|||
}
|
||||
|
||||
fn op_seek(
|
||||
isolate: &mut deno_core::Isolate,
|
||||
isolate: &mut CoreIsolate,
|
||||
_state: &State,
|
||||
args: Value,
|
||||
_zero_copy: Option<ZeroCopyBuf>,
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
use super::dispatch_json::{Deserialize, JsonOp, Value};
|
||||
use crate::op_error::OpError;
|
||||
use crate::state::State;
|
||||
use deno_core::*;
|
||||
use deno_core::CoreIsolate;
|
||||
use deno_core::ErrBox;
|
||||
use deno_core::ZeroCopyBuf;
|
||||
use futures::future::poll_fn;
|
||||
use futures::future::FutureExt;
|
||||
use notify::event::Event as NotifyEvent;
|
||||
|
@ -16,7 +18,7 @@ use std::convert::From;
|
|||
use std::path::PathBuf;
|
||||
use tokio::sync::mpsc;
|
||||
|
||||
pub fn init(i: &mut Isolate, s: &State) {
|
||||
pub fn init(i: &mut CoreIsolate, s: &State) {
|
||||
i.register_op("op_fs_events_open", s.stateful_json_op2(op_fs_events_open));
|
||||
i.register_op("op_fs_events_poll", s.stateful_json_op2(op_fs_events_poll));
|
||||
}
|
||||
|
@ -60,7 +62,7 @@ impl From<NotifyEvent> for FsEvent {
|
|||
}
|
||||
|
||||
pub fn op_fs_events_open(
|
||||
isolate: &mut deno_core::Isolate,
|
||||
isolate: &mut CoreIsolate,
|
||||
state: &State,
|
||||
args: Value,
|
||||
_zero_copy: Option<ZeroCopyBuf>,
|
||||
|
@ -98,7 +100,7 @@ pub fn op_fs_events_open(
|
|||
}
|
||||
|
||||
pub fn op_fs_events_poll(
|
||||
isolate: &mut deno_core::Isolate,
|
||||
isolate: &mut CoreIsolate,
|
||||
_state: &State,
|
||||
args: Value,
|
||||
_zero_copy: Option<ZeroCopyBuf>,
|
||||
|
|
|
@ -2,7 +2,9 @@ use super::dispatch_minimal::MinimalOp;
|
|||
use crate::http_util::HttpBody;
|
||||
use crate::op_error::OpError;
|
||||
use crate::state::State;
|
||||
use deno_core::*;
|
||||
use deno_core::CoreIsolate;
|
||||
use deno_core::ResourceTable;
|
||||
use deno_core::ZeroCopyBuf;
|
||||
use futures::future::poll_fn;
|
||||
use futures::future::FutureExt;
|
||||
use futures::ready;
|
||||
|
@ -58,7 +60,7 @@ lazy_static! {
|
|||
};
|
||||
}
|
||||
|
||||
pub fn init(i: &mut Isolate, s: &State) {
|
||||
pub fn init(i: &mut CoreIsolate, s: &State) {
|
||||
i.register_op("op_read", s.stateful_minimal_op2(op_read));
|
||||
i.register_op("op_write", s.stateful_minimal_op2(op_write));
|
||||
}
|
||||
|
@ -204,7 +206,7 @@ impl DenoAsyncRead for StreamResource {
|
|||
}
|
||||
|
||||
pub fn op_read(
|
||||
isolate: &mut deno_core::Isolate,
|
||||
isolate: &mut CoreIsolate,
|
||||
_state: &State,
|
||||
is_sync: bool,
|
||||
rid: i32,
|
||||
|
@ -328,7 +330,7 @@ impl DenoAsyncWrite for StreamResource {
|
|||
}
|
||||
|
||||
pub fn op_write(
|
||||
isolate: &mut deno_core::Isolate,
|
||||
isolate: &mut CoreIsolate,
|
||||
_state: &State,
|
||||
is_sync: bool,
|
||||
rid: i32,
|
||||
|
|
|
@ -4,7 +4,9 @@ use super::io::{StreamResource, StreamResourceHolder};
|
|||
use crate::op_error::OpError;
|
||||
use crate::resolve_addr::resolve_addr;
|
||||
use crate::state::State;
|
||||
use deno_core::*;
|
||||
use deno_core::CoreIsolate;
|
||||
use deno_core::ResourceTable;
|
||||
use deno_core::ZeroCopyBuf;
|
||||
use futures::future::poll_fn;
|
||||
use futures::future::FutureExt;
|
||||
use std::convert::From;
|
||||
|
@ -19,7 +21,7 @@ use tokio::net::UdpSocket;
|
|||
#[cfg(unix)]
|
||||
use super::net_unix;
|
||||
|
||||
pub fn init(i: &mut Isolate, s: &State) {
|
||||
pub fn init(i: &mut CoreIsolate, s: &State) {
|
||||
i.register_op("op_accept", s.stateful_json_op2(op_accept));
|
||||
i.register_op("op_connect", s.stateful_json_op2(op_connect));
|
||||
i.register_op("op_shutdown", s.stateful_json_op2(op_shutdown));
|
||||
|
@ -35,7 +37,7 @@ struct AcceptArgs {
|
|||
}
|
||||
|
||||
fn accept_tcp(
|
||||
isolate: &mut deno_core::Isolate,
|
||||
isolate: &mut CoreIsolate,
|
||||
args: AcceptArgs,
|
||||
_zero_copy: Option<ZeroCopyBuf>,
|
||||
) -> Result<JsonOp, OpError> {
|
||||
|
@ -95,7 +97,7 @@ fn accept_tcp(
|
|||
}
|
||||
|
||||
fn op_accept(
|
||||
isolate: &mut deno_core::Isolate,
|
||||
isolate: &mut CoreIsolate,
|
||||
_state: &State,
|
||||
args: Value,
|
||||
zero_copy: Option<ZeroCopyBuf>,
|
||||
|
@ -119,7 +121,7 @@ struct ReceiveArgs {
|
|||
}
|
||||
|
||||
fn receive_udp(
|
||||
isolate: &mut deno_core::Isolate,
|
||||
isolate: &mut CoreIsolate,
|
||||
_state: &State,
|
||||
args: ReceiveArgs,
|
||||
zero_copy: Option<ZeroCopyBuf>,
|
||||
|
@ -156,7 +158,7 @@ fn receive_udp(
|
|||
}
|
||||
|
||||
fn op_receive(
|
||||
isolate: &mut deno_core::Isolate,
|
||||
isolate: &mut CoreIsolate,
|
||||
state: &State,
|
||||
args: Value,
|
||||
zero_copy: Option<ZeroCopyBuf>,
|
||||
|
@ -185,7 +187,7 @@ struct SendArgs {
|
|||
}
|
||||
|
||||
fn op_send(
|
||||
isolate: &mut deno_core::Isolate,
|
||||
isolate: &mut CoreIsolate,
|
||||
state: &State,
|
||||
args: Value,
|
||||
zero_copy: Option<ZeroCopyBuf>,
|
||||
|
@ -254,7 +256,7 @@ struct ConnectArgs {
|
|||
}
|
||||
|
||||
fn op_connect(
|
||||
isolate: &mut deno_core::Isolate,
|
||||
isolate: &mut CoreIsolate,
|
||||
state: &State,
|
||||
args: Value,
|
||||
_zero_copy: Option<ZeroCopyBuf>,
|
||||
|
@ -339,7 +341,7 @@ struct ShutdownArgs {
|
|||
}
|
||||
|
||||
fn op_shutdown(
|
||||
isolate: &mut deno_core::Isolate,
|
||||
isolate: &mut CoreIsolate,
|
||||
_state: &State,
|
||||
args: Value,
|
||||
_zero_copy: Option<ZeroCopyBuf>,
|
||||
|
@ -479,7 +481,7 @@ fn listen_udp(
|
|||
}
|
||||
|
||||
fn op_listen(
|
||||
isolate: &mut deno_core::Isolate,
|
||||
isolate: &mut CoreIsolate,
|
||||
state: &State,
|
||||
args: Value,
|
||||
_zero_copy: Option<ZeroCopyBuf>,
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
use super::dispatch_json::{Deserialize, JsonOp};
|
||||
use super::io::{StreamResource, StreamResourceHolder};
|
||||
use crate::op_error::OpError;
|
||||
use deno_core::CoreIsolate;
|
||||
use deno_core::ResourceTable;
|
||||
use deno_core::ZeroCopyBuf;
|
||||
use futures::future::FutureExt;
|
||||
|
||||
use deno_core::*;
|
||||
use std::fs::remove_file;
|
||||
use std::os::unix;
|
||||
pub use std::path::Path;
|
||||
|
@ -26,7 +27,7 @@ pub struct UnixListenArgs {
|
|||
}
|
||||
|
||||
pub fn accept_unix(
|
||||
isolate: &mut deno_core::Isolate,
|
||||
isolate: &mut CoreIsolate,
|
||||
rid: u32,
|
||||
_zero_copy: Option<ZeroCopyBuf>,
|
||||
) -> Result<JsonOp, OpError> {
|
||||
|
@ -77,7 +78,7 @@ pub fn accept_unix(
|
|||
}
|
||||
|
||||
pub fn receive_unix_packet(
|
||||
isolate: &mut deno_core::Isolate,
|
||||
isolate: &mut CoreIsolate,
|
||||
rid: u32,
|
||||
zero_copy: Option<ZeroCopyBuf>,
|
||||
) -> Result<JsonOp, OpError> {
|
||||
|
|
|
@ -2,13 +2,14 @@
|
|||
use super::dispatch_json::{Deserialize, JsonOp, Value};
|
||||
use crate::op_error::OpError;
|
||||
use crate::state::State;
|
||||
use deno_core::*;
|
||||
use deno_core::CoreIsolate;
|
||||
use deno_core::ZeroCopyBuf;
|
||||
use std::collections::HashMap;
|
||||
use std::env;
|
||||
use std::io::{Error, ErrorKind};
|
||||
use url::Url;
|
||||
|
||||
pub fn init(i: &mut Isolate, s: &State) {
|
||||
pub fn init(i: &mut CoreIsolate, s: &State) {
|
||||
i.register_op("op_exit", s.stateful_json_op(op_exit));
|
||||
i.register_op("op_env", s.stateful_json_op(op_env));
|
||||
i.register_op("op_exec_path", s.stateful_json_op(op_exec_path));
|
||||
|
|
|
@ -3,10 +3,11 @@ use super::dispatch_json::{Deserialize, JsonOp, Value};
|
|||
use crate::fs as deno_fs;
|
||||
use crate::op_error::OpError;
|
||||
use crate::state::State;
|
||||
use deno_core::*;
|
||||
use deno_core::CoreIsolate;
|
||||
use deno_core::ZeroCopyBuf;
|
||||
use std::path::Path;
|
||||
|
||||
pub fn init(i: &mut Isolate, s: &State) {
|
||||
pub fn init(i: &mut CoreIsolate, s: &State) {
|
||||
i.register_op(
|
||||
"op_query_permission",
|
||||
s.stateful_json_op(op_query_permission),
|
||||
|
|
|
@ -3,15 +3,15 @@ use crate::fs as deno_fs;
|
|||
use crate::op_error::OpError;
|
||||
use crate::ops::json_op;
|
||||
use crate::state::State;
|
||||
use deno_core::Isolate;
|
||||
use deno_core::CoreIsolate;
|
||||
use deno_core::ZeroCopyBuf;
|
||||
use dlopen::symbor::Library;
|
||||
use std::ffi::OsStr;
|
||||
use std::path::Path;
|
||||
|
||||
pub type PluginInitFn = fn(isolate: &mut deno_core::Isolate);
|
||||
pub type PluginInitFn = fn(isolate: &mut CoreIsolate);
|
||||
|
||||
pub fn init(i: &mut Isolate, s: &State) {
|
||||
pub fn init(i: &mut CoreIsolate, s: &State) {
|
||||
i.register_op(
|
||||
"op_open_plugin",
|
||||
s.core_op(json_op(s.stateful_op2(op_open_plugin))),
|
||||
|
@ -34,7 +34,7 @@ struct OpenPluginArgs {
|
|||
}
|
||||
|
||||
pub fn op_open_plugin(
|
||||
isolate: &mut deno_core::Isolate,
|
||||
isolate: &mut CoreIsolate,
|
||||
state: &State,
|
||||
args: Value,
|
||||
_zero_copy: Option<ZeroCopyBuf>,
|
||||
|
|
|
@ -4,7 +4,9 @@ use super::io::{std_file_resource, StreamResource, StreamResourceHolder};
|
|||
use crate::op_error::OpError;
|
||||
use crate::signal::kill;
|
||||
use crate::state::State;
|
||||
use deno_core::*;
|
||||
use deno_core::CoreIsolate;
|
||||
use deno_core::ResourceTable;
|
||||
use deno_core::ZeroCopyBuf;
|
||||
use futures::future::poll_fn;
|
||||
use futures::future::FutureExt;
|
||||
use futures::TryFutureExt;
|
||||
|
@ -14,7 +16,7 @@ use tokio::process::Command;
|
|||
#[cfg(unix)]
|
||||
use std::os::unix::process::ExitStatusExt;
|
||||
|
||||
pub fn init(i: &mut Isolate, s: &State) {
|
||||
pub fn init(i: &mut CoreIsolate, s: &State) {
|
||||
i.register_op("op_run", s.stateful_json_op2(op_run));
|
||||
i.register_op("op_run_status", s.stateful_json_op2(op_run_status));
|
||||
i.register_op("op_kill", s.stateful_json_op(op_kill));
|
||||
|
@ -58,7 +60,7 @@ struct ChildResource {
|
|||
}
|
||||
|
||||
fn op_run(
|
||||
isolate: &mut deno_core::Isolate,
|
||||
isolate: &mut CoreIsolate,
|
||||
state: &State,
|
||||
args: Value,
|
||||
_zero_copy: Option<ZeroCopyBuf>,
|
||||
|
@ -172,7 +174,7 @@ struct RunStatusArgs {
|
|||
}
|
||||
|
||||
fn op_run_status(
|
||||
isolate: &mut deno_core::Isolate,
|
||||
isolate: &mut CoreIsolate,
|
||||
state: &State,
|
||||
args: Value,
|
||||
_zero_copy: Option<ZeroCopyBuf>,
|
||||
|
|
|
@ -2,11 +2,12 @@
|
|||
use super::dispatch_json::{JsonOp, Value};
|
||||
use crate::op_error::OpError;
|
||||
use crate::state::State;
|
||||
use deno_core::*;
|
||||
use deno_core::CoreIsolate;
|
||||
use deno_core::ZeroCopyBuf;
|
||||
use rand::thread_rng;
|
||||
use rand::Rng;
|
||||
|
||||
pub fn init(i: &mut Isolate, s: &State) {
|
||||
pub fn init(i: &mut CoreIsolate, s: &State) {
|
||||
i.register_op(
|
||||
"op_get_random_values",
|
||||
s.stateful_json_op(op_get_random_values),
|
||||
|
|
|
@ -4,11 +4,12 @@ use crate::op_error::OpError;
|
|||
use crate::repl;
|
||||
use crate::repl::Repl;
|
||||
use crate::state::State;
|
||||
use deno_core::*;
|
||||
use deno_core::CoreIsolate;
|
||||
use deno_core::ZeroCopyBuf;
|
||||
use std::sync::Arc;
|
||||
use std::sync::Mutex;
|
||||
|
||||
pub fn init(i: &mut Isolate, s: &State) {
|
||||
pub fn init(i: &mut CoreIsolate, s: &State) {
|
||||
i.register_op("op_repl_start", s.stateful_json_op2(op_repl_start));
|
||||
i.register_op("op_repl_readline", s.stateful_json_op2(op_repl_readline));
|
||||
}
|
||||
|
@ -22,7 +23,7 @@ struct ReplStartArgs {
|
|||
}
|
||||
|
||||
fn op_repl_start(
|
||||
isolate: &mut deno_core::Isolate,
|
||||
isolate: &mut CoreIsolate,
|
||||
state: &State,
|
||||
args: Value,
|
||||
_zero_copy: Option<ZeroCopyBuf>,
|
||||
|
@ -45,7 +46,7 @@ struct ReplReadlineArgs {
|
|||
}
|
||||
|
||||
fn op_repl_readline(
|
||||
isolate: &mut deno_core::Isolate,
|
||||
isolate: &mut CoreIsolate,
|
||||
_state: &State,
|
||||
args: Value,
|
||||
_zero_copy: Option<ZeroCopyBuf>,
|
||||
|
|
|
@ -2,15 +2,16 @@
|
|||
use super::dispatch_json::{Deserialize, JsonOp, Value};
|
||||
use crate::op_error::OpError;
|
||||
use crate::state::State;
|
||||
use deno_core::*;
|
||||
use deno_core::CoreIsolate;
|
||||
use deno_core::ZeroCopyBuf;
|
||||
|
||||
pub fn init(i: &mut Isolate, s: &State) {
|
||||
pub fn init(i: &mut CoreIsolate, s: &State) {
|
||||
i.register_op("op_resources", s.stateful_json_op2(op_resources));
|
||||
i.register_op("op_close", s.stateful_json_op2(op_close));
|
||||
}
|
||||
|
||||
fn op_resources(
|
||||
isolate: &mut deno_core::Isolate,
|
||||
isolate: &mut CoreIsolate,
|
||||
_state: &State,
|
||||
_args: Value,
|
||||
_zero_copy: Option<ZeroCopyBuf>,
|
||||
|
@ -21,7 +22,7 @@ fn op_resources(
|
|||
|
||||
/// op_close removes a resource from the resource table.
|
||||
fn op_close(
|
||||
isolate: &mut deno_core::Isolate,
|
||||
isolate: &mut CoreIsolate,
|
||||
_state: &State,
|
||||
args: Value,
|
||||
_zero_copy: Option<ZeroCopyBuf>,
|
||||
|
|
|
@ -5,7 +5,8 @@ use crate::op_error::OpError;
|
|||
use crate::state::State;
|
||||
use crate::version;
|
||||
use crate::DenoSubcommand;
|
||||
use deno_core::*;
|
||||
use deno_core::CoreIsolate;
|
||||
use deno_core::ZeroCopyBuf;
|
||||
use std::env;
|
||||
|
||||
/// BUILD_OS and BUILD_ARCH match the values in Deno.build. See js/build.ts.
|
||||
|
@ -18,7 +19,7 @@ static BUILD_OS: &str = "win";
|
|||
#[cfg(target_arch = "x86_64")]
|
||||
static BUILD_ARCH: &str = "x64";
|
||||
|
||||
pub fn init(i: &mut Isolate, s: &State) {
|
||||
pub fn init(i: &mut CoreIsolate, s: &State) {
|
||||
i.register_op("op_start", s.stateful_json_op(op_start));
|
||||
i.register_op("op_metrics", s.stateful_json_op(op_metrics));
|
||||
}
|
||||
|
|
|
@ -4,10 +4,11 @@ use crate::compilers::runtime_compile;
|
|||
use crate::compilers::runtime_transpile;
|
||||
use crate::op_error::OpError;
|
||||
use crate::state::State;
|
||||
use deno_core::*;
|
||||
use deno_core::CoreIsolate;
|
||||
use deno_core::ZeroCopyBuf;
|
||||
use std::collections::HashMap;
|
||||
|
||||
pub fn init(i: &mut Isolate, s: &State) {
|
||||
pub fn init(i: &mut CoreIsolate, s: &State) {
|
||||
i.register_op("op_compile", s.stateful_json_op(op_compile));
|
||||
i.register_op("op_transpile", s.stateful_json_op(op_transpile));
|
||||
}
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
use super::dispatch_json::{JsonOp, Value};
|
||||
use crate::op_error::OpError;
|
||||
use crate::state::State;
|
||||
use deno_core::*;
|
||||
use deno_core::CoreIsolate;
|
||||
use deno_core::ZeroCopyBuf;
|
||||
|
||||
#[cfg(unix)]
|
||||
use super::dispatch_json::Deserialize;
|
||||
|
@ -13,7 +14,7 @@ use std::task::Waker;
|
|||
#[cfg(unix)]
|
||||
use tokio::signal::unix::{signal, Signal, SignalKind};
|
||||
|
||||
pub fn init(i: &mut Isolate, s: &State) {
|
||||
pub fn init(i: &mut CoreIsolate, s: &State) {
|
||||
i.register_op("op_signal_bind", s.stateful_json_op2(op_signal_bind));
|
||||
i.register_op("op_signal_unbind", s.stateful_json_op2(op_signal_unbind));
|
||||
i.register_op("op_signal_poll", s.stateful_json_op2(op_signal_poll));
|
||||
|
@ -38,7 +39,7 @@ struct SignalArgs {
|
|||
|
||||
#[cfg(unix)]
|
||||
fn op_signal_bind(
|
||||
isolate: &mut deno_core::Isolate,
|
||||
isolate: &mut CoreIsolate,
|
||||
_state: &State,
|
||||
args: Value,
|
||||
_zero_copy: Option<ZeroCopyBuf>,
|
||||
|
@ -59,7 +60,7 @@ fn op_signal_bind(
|
|||
|
||||
#[cfg(unix)]
|
||||
fn op_signal_poll(
|
||||
isolate: &mut deno_core::Isolate,
|
||||
isolate: &mut CoreIsolate,
|
||||
_state: &State,
|
||||
args: Value,
|
||||
_zero_copy: Option<ZeroCopyBuf>,
|
||||
|
@ -85,7 +86,7 @@ fn op_signal_poll(
|
|||
|
||||
#[cfg(unix)]
|
||||
pub fn op_signal_unbind(
|
||||
isolate: &mut deno_core::Isolate,
|
||||
isolate: &mut CoreIsolate,
|
||||
_state: &State,
|
||||
args: Value,
|
||||
_zero_copy: Option<ZeroCopyBuf>,
|
||||
|
@ -109,7 +110,7 @@ pub fn op_signal_unbind(
|
|||
|
||||
#[cfg(not(unix))]
|
||||
pub fn op_signal_bind(
|
||||
_isolate: &mut deno_core::Isolate,
|
||||
_isolate: &mut CoreIsolate,
|
||||
_state: &State,
|
||||
_args: Value,
|
||||
_zero_copy: Option<ZeroCopyBuf>,
|
||||
|
@ -119,7 +120,7 @@ pub fn op_signal_bind(
|
|||
|
||||
#[cfg(not(unix))]
|
||||
fn op_signal_unbind(
|
||||
_isolate: &mut deno_core::Isolate,
|
||||
_isolate: &mut CoreIsolate,
|
||||
_state: &State,
|
||||
_args: Value,
|
||||
_zero_copy: Option<ZeroCopyBuf>,
|
||||
|
@ -129,7 +130,7 @@ fn op_signal_unbind(
|
|||
|
||||
#[cfg(not(unix))]
|
||||
fn op_signal_poll(
|
||||
_isolate: &mut deno_core::Isolate,
|
||||
_isolate: &mut CoreIsolate,
|
||||
_state: &State,
|
||||
_args: Value,
|
||||
_zero_copy: Option<ZeroCopyBuf>,
|
||||
|
|
|
@ -2,12 +2,13 @@
|
|||
use super::dispatch_json::{Deserialize, JsonOp, Value};
|
||||
use crate::op_error::OpError;
|
||||
use crate::state::State;
|
||||
use deno_core::*;
|
||||
use deno_core::CoreIsolate;
|
||||
use deno_core::ZeroCopyBuf;
|
||||
use futures::future::FutureExt;
|
||||
use std::time::Duration;
|
||||
use std::time::Instant;
|
||||
|
||||
pub fn init(i: &mut Isolate, s: &State) {
|
||||
pub fn init(i: &mut CoreIsolate, s: &State) {
|
||||
i.register_op(
|
||||
"op_global_timer_stop",
|
||||
s.stateful_json_op(op_global_timer_stop),
|
||||
|
|
|
@ -4,7 +4,8 @@ use super::io::{StreamResource, StreamResourceHolder};
|
|||
use crate::op_error::OpError;
|
||||
use crate::resolve_addr::resolve_addr;
|
||||
use crate::state::State;
|
||||
use deno_core::*;
|
||||
use deno_core::CoreIsolate;
|
||||
use deno_core::ZeroCopyBuf;
|
||||
use futures::future::poll_fn;
|
||||
use futures::future::FutureExt;
|
||||
use std::convert::From;
|
||||
|
@ -27,7 +28,7 @@ use tokio_rustls::{
|
|||
};
|
||||
use webpki::DNSNameRef;
|
||||
|
||||
pub fn init(i: &mut Isolate, s: &State) {
|
||||
pub fn init(i: &mut CoreIsolate, s: &State) {
|
||||
i.register_op("op_start_tls", s.stateful_json_op2(op_start_tls));
|
||||
i.register_op("op_connect_tls", s.stateful_json_op2(op_connect_tls));
|
||||
i.register_op("op_listen_tls", s.stateful_json_op2(op_listen_tls));
|
||||
|
@ -52,7 +53,7 @@ struct StartTLSArgs {
|
|||
}
|
||||
|
||||
pub fn op_start_tls(
|
||||
isolate: &mut deno_core::Isolate,
|
||||
isolate: &mut CoreIsolate,
|
||||
_state: &State,
|
||||
args: Value,
|
||||
_zero_copy: Option<ZeroCopyBuf>,
|
||||
|
@ -125,7 +126,7 @@ pub fn op_start_tls(
|
|||
}
|
||||
|
||||
pub fn op_connect_tls(
|
||||
isolate: &mut deno_core::Isolate,
|
||||
isolate: &mut CoreIsolate,
|
||||
state: &State,
|
||||
args: Value,
|
||||
_zero_copy: Option<ZeroCopyBuf>,
|
||||
|
@ -301,7 +302,7 @@ struct ListenTlsArgs {
|
|||
}
|
||||
|
||||
fn op_listen_tls(
|
||||
isolate: &mut deno_core::Isolate,
|
||||
isolate: &mut CoreIsolate,
|
||||
state: &State,
|
||||
args: Value,
|
||||
_zero_copy: Option<ZeroCopyBuf>,
|
||||
|
@ -351,7 +352,7 @@ struct AcceptTlsArgs {
|
|||
}
|
||||
|
||||
fn op_accept_tls(
|
||||
isolate: &mut deno_core::Isolate,
|
||||
isolate: &mut CoreIsolate,
|
||||
_state: &State,
|
||||
args: Value,
|
||||
_zero_copy: Option<ZeroCopyBuf>,
|
||||
|
|
|
@ -3,7 +3,8 @@ use super::io::std_file_resource;
|
|||
use super::io::{StreamResource, StreamResourceHolder};
|
||||
use crate::op_error::OpError;
|
||||
use crate::state::State;
|
||||
use deno_core::*;
|
||||
use deno_core::CoreIsolate;
|
||||
use deno_core::ZeroCopyBuf;
|
||||
#[cfg(unix)]
|
||||
use nix::sys::termios;
|
||||
use serde_derive::Deserialize;
|
||||
|
@ -33,7 +34,7 @@ fn get_windows_handle(
|
|||
Ok(handle)
|
||||
}
|
||||
|
||||
pub fn init(i: &mut Isolate, s: &State) {
|
||||
pub fn init(i: &mut CoreIsolate, s: &State) {
|
||||
i.register_op("op_set_raw", s.stateful_json_op2(op_set_raw));
|
||||
i.register_op("op_isatty", s.stateful_json_op2(op_isatty));
|
||||
}
|
||||
|
@ -45,7 +46,7 @@ struct SetRawArgs {
|
|||
}
|
||||
|
||||
pub fn op_set_raw(
|
||||
isolate: &mut deno_core::Isolate,
|
||||
isolate: &mut CoreIsolate,
|
||||
_state: &State,
|
||||
args: Value,
|
||||
_zero_copy: Option<ZeroCopyBuf>,
|
||||
|
@ -213,7 +214,7 @@ struct IsattyArgs {
|
|||
}
|
||||
|
||||
pub fn op_isatty(
|
||||
isolate: &mut deno_core::Isolate,
|
||||
isolate: &mut CoreIsolate,
|
||||
_state: &State,
|
||||
args: Value,
|
||||
_zero_copy: Option<ZeroCopyBuf>,
|
||||
|
|
|
@ -5,18 +5,15 @@ use crate::ops::json_op;
|
|||
use crate::state::State;
|
||||
use crate::web_worker::WebWorkerHandle;
|
||||
use crate::worker::WorkerEvent;
|
||||
use deno_core::*;
|
||||
use deno_core::CoreIsolate;
|
||||
use deno_core::ZeroCopyBuf;
|
||||
use futures::channel::mpsc;
|
||||
use std::convert::From;
|
||||
|
||||
pub fn web_worker_op<D>(
|
||||
sender: mpsc::Sender<WorkerEvent>,
|
||||
dispatcher: D,
|
||||
) -> impl Fn(
|
||||
&mut deno_core::Isolate,
|
||||
Value,
|
||||
Option<ZeroCopyBuf>,
|
||||
) -> Result<JsonOp, OpError>
|
||||
) -> impl Fn(&mut CoreIsolate, Value, Option<ZeroCopyBuf>) -> Result<JsonOp, OpError>
|
||||
where
|
||||
D: Fn(
|
||||
&mpsc::Sender<WorkerEvent>,
|
||||
|
@ -24,7 +21,7 @@ where
|
|||
Option<ZeroCopyBuf>,
|
||||
) -> Result<JsonOp, OpError>,
|
||||
{
|
||||
move |_isolate: &mut deno_core::Isolate,
|
||||
move |_isolate: &mut CoreIsolate,
|
||||
args: Value,
|
||||
zero_copy: Option<ZeroCopyBuf>|
|
||||
-> Result<JsonOp, OpError> { dispatcher(&sender, args, zero_copy) }
|
||||
|
@ -34,11 +31,7 @@ pub fn web_worker_op2<D>(
|
|||
handle: WebWorkerHandle,
|
||||
sender: mpsc::Sender<WorkerEvent>,
|
||||
dispatcher: D,
|
||||
) -> impl Fn(
|
||||
&mut deno_core::Isolate,
|
||||
Value,
|
||||
Option<ZeroCopyBuf>,
|
||||
) -> Result<JsonOp, OpError>
|
||||
) -> impl Fn(&mut CoreIsolate, Value, Option<ZeroCopyBuf>) -> Result<JsonOp, OpError>
|
||||
where
|
||||
D: Fn(
|
||||
WebWorkerHandle,
|
||||
|
@ -47,7 +40,7 @@ where
|
|||
Option<ZeroCopyBuf>,
|
||||
) -> Result<JsonOp, OpError>,
|
||||
{
|
||||
move |_isolate: &mut deno_core::Isolate,
|
||||
move |_isolate: &mut CoreIsolate,
|
||||
args: Value,
|
||||
zero_copy: Option<ZeroCopyBuf>|
|
||||
-> Result<JsonOp, OpError> {
|
||||
|
@ -56,7 +49,7 @@ where
|
|||
}
|
||||
|
||||
pub fn init(
|
||||
i: &mut Isolate,
|
||||
i: &mut CoreIsolate,
|
||||
s: &State,
|
||||
sender: &mpsc::Sender<WorkerEvent>,
|
||||
handle: WebWorkerHandle,
|
||||
|
|
|
@ -11,12 +11,15 @@ use crate::tokio_util::create_basic_runtime;
|
|||
use crate::web_worker::WebWorker;
|
||||
use crate::web_worker::WebWorkerHandle;
|
||||
use crate::worker::WorkerEvent;
|
||||
use deno_core::*;
|
||||
use deno_core::CoreIsolate;
|
||||
use deno_core::ErrBox;
|
||||
use deno_core::ModuleSpecifier;
|
||||
use deno_core::ZeroCopyBuf;
|
||||
use futures::future::FutureExt;
|
||||
use std::convert::From;
|
||||
use std::thread::JoinHandle;
|
||||
|
||||
pub fn init(i: &mut Isolate, s: &State) {
|
||||
pub fn init(i: &mut CoreIsolate, s: &State) {
|
||||
i.register_op("op_create_worker", s.stateful_json_op(op_create_worker));
|
||||
i.register_op(
|
||||
"op_host_terminate_worker",
|
||||
|
|
30
cli/state.rs
30
cli/state.rs
|
@ -71,7 +71,7 @@ impl State {
|
|||
pub fn stateful_json_op<D>(
|
||||
&self,
|
||||
dispatcher: D,
|
||||
) -> impl Fn(&mut deno_core::Isolate, &[u8], Option<ZeroCopyBuf>) -> Op
|
||||
) -> impl Fn(&mut deno_core::CoreIsolate, &[u8], Option<ZeroCopyBuf>) -> Op
|
||||
where
|
||||
D: Fn(&State, Value, Option<ZeroCopyBuf>) -> Result<JsonOp, OpError>,
|
||||
{
|
||||
|
@ -82,10 +82,10 @@ impl State {
|
|||
pub fn stateful_json_op2<D>(
|
||||
&self,
|
||||
dispatcher: D,
|
||||
) -> impl Fn(&mut deno_core::Isolate, &[u8], Option<ZeroCopyBuf>) -> Op
|
||||
) -> impl Fn(&mut deno_core::CoreIsolate, &[u8], Option<ZeroCopyBuf>) -> Op
|
||||
where
|
||||
D: Fn(
|
||||
&mut deno_core::Isolate,
|
||||
&mut deno_core::CoreIsolate,
|
||||
&State,
|
||||
Value,
|
||||
Option<ZeroCopyBuf>,
|
||||
|
@ -101,13 +101,13 @@ impl State {
|
|||
pub fn core_op<D>(
|
||||
&self,
|
||||
dispatcher: D,
|
||||
) -> impl Fn(&mut deno_core::Isolate, &[u8], Option<ZeroCopyBuf>) -> Op
|
||||
) -> impl Fn(&mut deno_core::CoreIsolate, &[u8], Option<ZeroCopyBuf>) -> Op
|
||||
where
|
||||
D: Fn(&mut deno_core::Isolate, &[u8], Option<ZeroCopyBuf>) -> Op,
|
||||
D: Fn(&mut deno_core::CoreIsolate, &[u8], Option<ZeroCopyBuf>) -> Op,
|
||||
{
|
||||
let state = self.clone();
|
||||
|
||||
move |isolate: &mut deno_core::Isolate,
|
||||
move |isolate: &mut deno_core::CoreIsolate,
|
||||
control: &[u8],
|
||||
zero_copy: Option<ZeroCopyBuf>|
|
||||
-> Op {
|
||||
|
@ -161,10 +161,10 @@ impl State {
|
|||
pub fn stateful_minimal_op2<D>(
|
||||
&self,
|
||||
dispatcher: D,
|
||||
) -> impl Fn(&mut deno_core::Isolate, &[u8], Option<ZeroCopyBuf>) -> Op
|
||||
) -> impl Fn(&mut deno_core::CoreIsolate, &[u8], Option<ZeroCopyBuf>) -> Op
|
||||
where
|
||||
D: Fn(
|
||||
&mut deno_core::Isolate,
|
||||
&mut deno_core::CoreIsolate,
|
||||
&State,
|
||||
bool,
|
||||
i32,
|
||||
|
@ -173,7 +173,7 @@ impl State {
|
|||
{
|
||||
let state = self.clone();
|
||||
self.core_op(crate::ops::minimal_op(
|
||||
move |isolate: &mut deno_core::Isolate,
|
||||
move |isolate: &mut deno_core::CoreIsolate,
|
||||
is_sync: bool,
|
||||
rid: i32,
|
||||
zero_copy: Option<ZeroCopyBuf>|
|
||||
|
@ -186,13 +186,13 @@ impl State {
|
|||
/// This is a special function that provides `state` argument to dispatcher.
|
||||
///
|
||||
/// NOTE: This only works with JSON dispatcher.
|
||||
/// This is a band-aid for transition to `Isolate.register_op` API as most of our
|
||||
/// This is a band-aid for transition to `CoreIsolate.register_op` API as most of our
|
||||
/// ops require `state` argument.
|
||||
pub fn stateful_op<D>(
|
||||
&self,
|
||||
dispatcher: D,
|
||||
) -> impl Fn(
|
||||
&mut deno_core::Isolate,
|
||||
&mut deno_core::CoreIsolate,
|
||||
Value,
|
||||
Option<ZeroCopyBuf>,
|
||||
) -> Result<JsonOp, OpError>
|
||||
|
@ -200,7 +200,7 @@ impl State {
|
|||
D: Fn(&State, Value, Option<ZeroCopyBuf>) -> Result<JsonOp, OpError>,
|
||||
{
|
||||
let state = self.clone();
|
||||
move |_isolate: &mut deno_core::Isolate,
|
||||
move |_isolate: &mut deno_core::CoreIsolate,
|
||||
args: Value,
|
||||
zero_copy: Option<ZeroCopyBuf>|
|
||||
-> Result<JsonOp, OpError> { dispatcher(&state, args, zero_copy) }
|
||||
|
@ -210,20 +210,20 @@ impl State {
|
|||
&self,
|
||||
dispatcher: D,
|
||||
) -> impl Fn(
|
||||
&mut deno_core::Isolate,
|
||||
&mut deno_core::CoreIsolate,
|
||||
Value,
|
||||
Option<ZeroCopyBuf>,
|
||||
) -> Result<JsonOp, OpError>
|
||||
where
|
||||
D: Fn(
|
||||
&mut deno_core::Isolate,
|
||||
&mut deno_core::CoreIsolate,
|
||||
&State,
|
||||
Value,
|
||||
Option<ZeroCopyBuf>,
|
||||
) -> Result<JsonOp, OpError>,
|
||||
{
|
||||
let state = self.clone();
|
||||
move |isolate: &mut deno_core::Isolate,
|
||||
move |isolate: &mut deno_core::CoreIsolate,
|
||||
args: Value,
|
||||
zero_copy: Option<ZeroCopyBuf>|
|
||||
-> Result<JsonOp, OpError> {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
use crate::es_isolate::EsIsolate;
|
||||
use crate::isolate::Isolate;
|
||||
use crate::isolate::CoreIsolate;
|
||||
use crate::isolate::ZeroCopyBuf;
|
||||
use crate::js_errors::JSError;
|
||||
|
||||
|
@ -251,7 +251,7 @@ pub extern "C" fn host_import_module_dynamically_callback(
|
|||
let mut hs = v8::EscapableHandleScope::new(cbs.enter());
|
||||
let scope = hs.enter();
|
||||
let isolate = scope.isolate();
|
||||
let deno_isolate: &mut EsIsolate =
|
||||
let core_isolate: &mut EsIsolate =
|
||||
unsafe { &mut *(isolate.get_data(1) as *mut EsIsolate) };
|
||||
|
||||
// NOTE(bartlomieju): will crash for non-UTF-8 specifier
|
||||
|
@ -277,13 +277,13 @@ pub extern "C" fn host_import_module_dynamically_callback(
|
|||
let mut resolver_handle = v8::Global::new();
|
||||
resolver_handle.set(scope, resolver);
|
||||
|
||||
let import_id = deno_isolate.next_dyn_import_id;
|
||||
deno_isolate.next_dyn_import_id += 1;
|
||||
deno_isolate
|
||||
let import_id = core_isolate.next_dyn_import_id;
|
||||
core_isolate.next_dyn_import_id += 1;
|
||||
core_isolate
|
||||
.dyn_import_map
|
||||
.insert(import_id, resolver_handle);
|
||||
|
||||
deno_isolate.dyn_import_cb(&specifier_str, &referrer_name_str, import_id);
|
||||
core_isolate.dyn_import_cb(&specifier_str, &referrer_name_str, import_id);
|
||||
|
||||
&mut *scope.escape(promise)
|
||||
}
|
||||
|
@ -297,13 +297,13 @@ pub extern "C" fn host_initialize_import_meta_object_callback(
|
|||
let mut hs = v8::HandleScope::new(cbs.enter());
|
||||
let scope = hs.enter();
|
||||
let isolate = scope.isolate();
|
||||
let deno_isolate: &mut EsIsolate =
|
||||
let core_isolate: &mut EsIsolate =
|
||||
unsafe { &mut *(isolate.get_data(1) as *mut EsIsolate) };
|
||||
|
||||
let id = module.get_identity_hash();
|
||||
assert_ne!(id, 0);
|
||||
|
||||
let info = deno_isolate.modules.get_info(id).expect("Module not found");
|
||||
let info = core_isolate.modules.get_info(id).expect("Module not found");
|
||||
|
||||
meta.create_data_property(
|
||||
context,
|
||||
|
@ -322,10 +322,10 @@ pub extern "C" fn promise_reject_callback(message: v8::PromiseRejectMessage) {
|
|||
let mut hs = v8::HandleScope::new(cbs.enter());
|
||||
let scope = hs.enter();
|
||||
|
||||
let deno_isolate: &mut Isolate =
|
||||
unsafe { &mut *(scope.isolate().get_data(0) as *mut Isolate) };
|
||||
let core_isolate: &mut CoreIsolate =
|
||||
unsafe { &mut *(scope.isolate().get_data(0) as *mut CoreIsolate) };
|
||||
|
||||
let context = deno_isolate.global_context.get(scope).unwrap();
|
||||
let context = core_isolate.global_context.get(scope).unwrap();
|
||||
let mut cs = v8::ContextScope::new(scope, context);
|
||||
let scope = cs.enter();
|
||||
|
||||
|
@ -337,13 +337,13 @@ pub extern "C" fn promise_reject_callback(message: v8::PromiseRejectMessage) {
|
|||
let error = message.get_value();
|
||||
let mut error_global = v8::Global::<v8::Value>::new();
|
||||
error_global.set(scope, error);
|
||||
deno_isolate
|
||||
core_isolate
|
||||
.pending_promise_exceptions
|
||||
.insert(promise_id, error_global);
|
||||
}
|
||||
v8::PromiseRejectEvent::PromiseHandlerAddedAfterReject => {
|
||||
if let Some(mut handle) =
|
||||
deno_isolate.pending_promise_exceptions.remove(&promise_id)
|
||||
core_isolate.pending_promise_exceptions.remove(&promise_id)
|
||||
{
|
||||
handle.reset(scope);
|
||||
}
|
||||
|
@ -417,17 +417,17 @@ fn recv(
|
|||
args: v8::FunctionCallbackArguments,
|
||||
_rv: v8::ReturnValue,
|
||||
) {
|
||||
let deno_isolate: &mut Isolate =
|
||||
unsafe { &mut *(scope.isolate().get_data(0) as *mut Isolate) };
|
||||
let core_isolate: &mut CoreIsolate =
|
||||
unsafe { &mut *(scope.isolate().get_data(0) as *mut CoreIsolate) };
|
||||
|
||||
if !deno_isolate.js_recv_cb.is_empty() {
|
||||
if !core_isolate.js_recv_cb.is_empty() {
|
||||
let msg = v8::String::new(scope, "Deno.core.recv already called.").unwrap();
|
||||
scope.isolate().throw_exception(msg.into());
|
||||
return;
|
||||
}
|
||||
|
||||
let recv_fn = v8::Local::<v8::Function>::try_from(args.get(0)).unwrap();
|
||||
deno_isolate.js_recv_cb.set(scope, recv_fn);
|
||||
core_isolate.js_recv_cb.set(scope, recv_fn);
|
||||
}
|
||||
|
||||
fn send(
|
||||
|
@ -435,9 +435,9 @@ fn send(
|
|||
args: v8::FunctionCallbackArguments,
|
||||
mut rv: v8::ReturnValue,
|
||||
) {
|
||||
let deno_isolate: &mut Isolate =
|
||||
unsafe { &mut *(scope.isolate().get_data(0) as *mut Isolate) };
|
||||
assert!(!deno_isolate.global_context.is_empty());
|
||||
let core_isolate: &mut CoreIsolate =
|
||||
unsafe { &mut *(scope.isolate().get_data(0) as *mut CoreIsolate) };
|
||||
assert!(!core_isolate.global_context.is_empty());
|
||||
|
||||
let op_id = match v8::Local::<v8::Uint32>::try_from(args.get(0)) {
|
||||
Ok(op_id) => op_id.value() as u32,
|
||||
|
@ -469,7 +469,7 @@ fn send(
|
|||
|
||||
// If response is empty then it's either async op or exception was thrown
|
||||
let maybe_response =
|
||||
deno_isolate.dispatch_op(scope, op_id, control, zero_copy);
|
||||
core_isolate.dispatch_op(scope, op_id, control, zero_copy);
|
||||
|
||||
if let Some(response) = maybe_response {
|
||||
// Synchronous response.
|
||||
|
@ -488,10 +488,10 @@ fn set_macrotask_callback(
|
|||
args: v8::FunctionCallbackArguments,
|
||||
_rv: v8::ReturnValue,
|
||||
) {
|
||||
let deno_isolate: &mut Isolate =
|
||||
unsafe { &mut *(scope.isolate().get_data(0) as *mut Isolate) };
|
||||
let core_isolate: &mut CoreIsolate =
|
||||
unsafe { &mut *(scope.isolate().get_data(0) as *mut CoreIsolate) };
|
||||
|
||||
if !deno_isolate.js_macrotask_cb.is_empty() {
|
||||
if !core_isolate.js_macrotask_cb.is_empty() {
|
||||
let msg =
|
||||
v8::String::new(scope, "Deno.core.setMacrotaskCallback already called.")
|
||||
.unwrap();
|
||||
|
@ -501,7 +501,7 @@ fn set_macrotask_callback(
|
|||
|
||||
let macrotask_cb_fn =
|
||||
v8::Local::<v8::Function>::try_from(args.get(0)).unwrap();
|
||||
deno_isolate.js_macrotask_cb.set(scope, macrotask_cb_fn);
|
||||
core_isolate.js_macrotask_cb.set(scope, macrotask_cb_fn);
|
||||
}
|
||||
|
||||
fn eval_context(
|
||||
|
@ -509,10 +509,10 @@ fn eval_context(
|
|||
args: v8::FunctionCallbackArguments,
|
||||
mut rv: v8::ReturnValue,
|
||||
) {
|
||||
let deno_isolate: &mut Isolate =
|
||||
unsafe { &mut *(scope.isolate().get_data(0) as *mut Isolate) };
|
||||
assert!(!deno_isolate.global_context.is_empty());
|
||||
let context = deno_isolate.global_context.get(scope).unwrap();
|
||||
let core_isolate: &mut CoreIsolate =
|
||||
unsafe { &mut *(scope.isolate().get_data(0) as *mut CoreIsolate) };
|
||||
assert!(!core_isolate.global_context.is_empty());
|
||||
let context = core_isolate.global_context.get(scope).unwrap();
|
||||
|
||||
let source = match v8::Local::<v8::String>::try_from(args.get(0)) {
|
||||
Ok(s) => s,
|
||||
|
@ -645,10 +645,10 @@ fn format_error(
|
|||
args: v8::FunctionCallbackArguments,
|
||||
mut rv: v8::ReturnValue,
|
||||
) {
|
||||
let deno_isolate: &mut Isolate =
|
||||
unsafe { &mut *(scope.isolate().get_data(0) as *mut Isolate) };
|
||||
let core_isolate: &mut CoreIsolate =
|
||||
unsafe { &mut *(scope.isolate().get_data(0) as *mut CoreIsolate) };
|
||||
let e = JSError::from_v8_exception(scope, args.get(0));
|
||||
let e = (deno_isolate.js_error_create_fn)(e);
|
||||
let e = (core_isolate.js_error_create_fn)(e);
|
||||
let e = e.to_string();
|
||||
let e = v8::String::new(scope, &e).unwrap();
|
||||
rv.set(e.into())
|
||||
|
@ -736,19 +736,19 @@ fn shared_getter(
|
|||
_args: v8::PropertyCallbackArguments,
|
||||
mut rv: v8::ReturnValue,
|
||||
) {
|
||||
let deno_isolate: &mut Isolate =
|
||||
unsafe { &mut *(scope.isolate().get_data(0) as *mut Isolate) };
|
||||
let core_isolate: &mut CoreIsolate =
|
||||
unsafe { &mut *(scope.isolate().get_data(0) as *mut CoreIsolate) };
|
||||
|
||||
// Lazily initialize the persistent external ArrayBuffer.
|
||||
if deno_isolate.shared_ab.is_empty() {
|
||||
if core_isolate.shared_ab.is_empty() {
|
||||
let ab = v8::SharedArrayBuffer::with_backing_store(
|
||||
scope,
|
||||
deno_isolate.shared.get_backing_store(),
|
||||
core_isolate.shared.get_backing_store(),
|
||||
);
|
||||
deno_isolate.shared_ab.set(scope, ab);
|
||||
core_isolate.shared_ab.set(scope, ab);
|
||||
}
|
||||
|
||||
let shared_ab = deno_isolate.shared_ab.get(scope).unwrap();
|
||||
let shared_ab = core_isolate.shared_ab.get(scope).unwrap();
|
||||
rv.set(shared_ab.into());
|
||||
}
|
||||
|
||||
|
@ -761,11 +761,11 @@ pub fn module_resolve_callback<'s>(
|
|||
let mut scope = v8::EscapableHandleScope::new(scope.enter());
|
||||
let scope = scope.enter();
|
||||
|
||||
let deno_isolate: &mut EsIsolate =
|
||||
let core_isolate: &mut EsIsolate =
|
||||
unsafe { &mut *(scope.isolate().get_data(1) as *mut EsIsolate) };
|
||||
|
||||
let referrer_id = referrer.get_identity_hash();
|
||||
let referrer_name = deno_isolate
|
||||
let referrer_name = core_isolate
|
||||
.modules
|
||||
.get_info(referrer_id)
|
||||
.expect("ModuleInfo not found")
|
||||
|
@ -780,8 +780,8 @@ pub fn module_resolve_callback<'s>(
|
|||
let req_str = req.to_rust_string_lossy(scope);
|
||||
|
||||
if req_str == specifier_str {
|
||||
let id = deno_isolate.module_resolve_cb(&req_str, referrer_id);
|
||||
let maybe_info = deno_isolate.modules.get_info(id);
|
||||
let id = core_isolate.module_resolve_cb(&req_str, referrer_id);
|
||||
let maybe_info = core_isolate.modules.get_info(id);
|
||||
|
||||
if maybe_info.is_none() {
|
||||
let msg = format!(
|
||||
|
@ -812,10 +812,10 @@ fn get_promise_details(
|
|||
args: v8::FunctionCallbackArguments,
|
||||
mut rv: v8::ReturnValue,
|
||||
) {
|
||||
let deno_isolate: &mut Isolate =
|
||||
unsafe { &mut *(scope.isolate().get_data(0) as *mut Isolate) };
|
||||
assert!(!deno_isolate.global_context.is_empty());
|
||||
let context = deno_isolate.global_context.get(scope).unwrap();
|
||||
let core_isolate: &mut CoreIsolate =
|
||||
unsafe { &mut *(scope.isolate().get_data(0) as *mut CoreIsolate) };
|
||||
assert!(!core_isolate.global_context.is_empty());
|
||||
let context = core_isolate.global_context.get(scope).unwrap();
|
||||
|
||||
let promise = match v8::Local::<v8::Promise>::try_from(args.get(0)) {
|
||||
Ok(val) => val,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
// This module provides higher level implementation of Isolate that
|
||||
// This module provides higher level implementation of CoreIsolate that
|
||||
// supports asynchronous loading and executution of ES Modules.
|
||||
// The isolate.rs should never depend on this module.
|
||||
|
||||
|
@ -27,7 +27,7 @@ use std::task::Poll;
|
|||
|
||||
use crate::isolate::attach_handle_to_error;
|
||||
use crate::isolate::exception_to_err_result;
|
||||
use crate::isolate::Isolate;
|
||||
use crate::isolate::CoreIsolate;
|
||||
use crate::isolate::StartupData;
|
||||
use crate::module_specifier::ModuleSpecifier;
|
||||
use crate::modules::LoadState;
|
||||
|
@ -39,14 +39,14 @@ use crate::modules::RecursiveModuleLoad;
|
|||
pub type ModuleId = i32;
|
||||
pub type DynImportId = i32;
|
||||
|
||||
/// More specialized version of `Isolate` that provides loading
|
||||
/// More specialized version of `CoreIsolate` that provides loading
|
||||
/// and execution of ES Modules.
|
||||
///
|
||||
/// Creating `EsIsolate` requires to pass `loader` argument
|
||||
/// that implements `ModuleLoader` trait - that way actual resolution and
|
||||
/// loading of modules can be customized by the implementor.
|
||||
pub struct EsIsolate {
|
||||
core_isolate: Box<Isolate>,
|
||||
core_isolate: Box<CoreIsolate>,
|
||||
loader: Rc<dyn ModuleLoader>,
|
||||
pub modules: Modules,
|
||||
pub(crate) next_dyn_import_id: DynImportId,
|
||||
|
@ -58,7 +58,7 @@ pub struct EsIsolate {
|
|||
}
|
||||
|
||||
impl Deref for EsIsolate {
|
||||
type Target = Isolate;
|
||||
type Target = CoreIsolate;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.core_isolate
|
||||
|
@ -77,7 +77,7 @@ impl EsIsolate {
|
|||
startup_data: StartupData,
|
||||
will_snapshot: bool,
|
||||
) -> Box<Self> {
|
||||
let mut core_isolate = Isolate::new(startup_data, will_snapshot);
|
||||
let mut core_isolate = CoreIsolate::new(startup_data, will_snapshot);
|
||||
{
|
||||
let v8_isolate = core_isolate.v8_isolate.as_mut().unwrap();
|
||||
v8_isolate.set_host_initialize_import_meta_object_callback(
|
||||
|
@ -174,7 +174,7 @@ impl EsIsolate {
|
|||
///
|
||||
/// ErrBox can be downcast to a type that exposes additional information about
|
||||
/// the V8 exception. By default this type is JSError, however it may be a
|
||||
/// different type if Isolate::set_js_error_create_fn() has been used.
|
||||
/// different type if CoreIsolate::set_js_error_create_fn() has been used.
|
||||
fn mod_instantiate(&mut self, id: ModuleId) -> Result<(), ErrBox> {
|
||||
let v8_isolate = self.core_isolate.v8_isolate.as_mut().unwrap();
|
||||
let js_error_create_fn = &*self.core_isolate.js_error_create_fn;
|
||||
|
@ -219,7 +219,7 @@ impl EsIsolate {
|
|||
///
|
||||
/// ErrBox can be downcast to a type that exposes additional information about
|
||||
/// the V8 exception. By default this type is JSError, however it may be a
|
||||
/// different type if Isolate::set_js_error_create_fn() has been used.
|
||||
/// different type if CoreIsolate::set_js_error_create_fn() has been used.
|
||||
pub fn mod_evaluate(&mut self, id: ModuleId) -> Result<(), ErrBox> {
|
||||
let core_isolate = &mut self.core_isolate;
|
||||
let v8_isolate = core_isolate.v8_isolate.as_mut().unwrap();
|
||||
|
@ -580,7 +580,7 @@ pub mod tests {
|
|||
|
||||
let mut isolate = EsIsolate::new(loader, StartupData::None, false);
|
||||
|
||||
let dispatcher = move |_isolate: &mut Isolate,
|
||||
let dispatcher = move |_isolate: &mut CoreIsolate,
|
||||
control: &[u8],
|
||||
_zero_copy: Option<ZeroCopyBuf>|
|
||||
-> Op {
|
||||
|
|
|
@ -3,8 +3,12 @@ extern crate derive_deref;
|
|||
#[macro_use]
|
||||
extern crate log;
|
||||
|
||||
use deno_core::Isolate as CoreIsolate;
|
||||
use deno_core::*;
|
||||
use deno_core::CoreIsolate;
|
||||
use deno_core::Op;
|
||||
use deno_core::ResourceTable;
|
||||
use deno_core::Script;
|
||||
use deno_core::StartupData;
|
||||
use deno_core::ZeroCopyBuf;
|
||||
use futures::future::poll_fn;
|
||||
use futures::prelude::*;
|
||||
use futures::task::Context;
|
||||
|
@ -111,7 +115,7 @@ impl Isolate {
|
|||
F: 'static + Fn(State, u32, Option<ZeroCopyBuf>) -> Result<u32, Error>,
|
||||
{
|
||||
let state = self.state.clone();
|
||||
let core_handler = move |_isolate: &mut deno_core::Isolate,
|
||||
let core_handler = move |_isolate: &mut CoreIsolate,
|
||||
control_buf: &[u8],
|
||||
zero_copy_buf: Option<ZeroCopyBuf>|
|
||||
-> Op {
|
||||
|
@ -141,7 +145,7 @@ impl Isolate {
|
|||
<F::Ok as TryInto<i32>>::Error: Debug,
|
||||
{
|
||||
let state = self.state.clone();
|
||||
let core_handler = move |_isolate: &mut deno_core::Isolate,
|
||||
let core_handler = move |_isolate: &mut CoreIsolate,
|
||||
control_buf: &[u8],
|
||||
zero_copy_buf: Option<ZeroCopyBuf>|
|
||||
-> Op {
|
||||
|
|
|
@ -140,15 +140,15 @@ type JSErrorCreateFn = dyn Fn(JSError) -> ErrBox;
|
|||
type IsolateErrorHandleFn = dyn FnMut(ErrBox) -> Result<(), ErrBox>;
|
||||
|
||||
/// A single execution context of JavaScript. Corresponds roughly to the "Web
|
||||
/// Worker" concept in the DOM. An Isolate is a Future that can be used with
|
||||
/// Tokio. The Isolate future complete when there is an error or when all
|
||||
/// Worker" concept in the DOM. An CoreIsolate is a Future that can be used with
|
||||
/// Tokio. The CoreIsolate future complete when there is an error or when all
|
||||
/// pending ops have completed.
|
||||
///
|
||||
/// Ops are created in JavaScript by calling Deno.core.dispatch(), and in Rust
|
||||
/// by implementing dispatcher function that takes control buffer and optional zero copy buffer
|
||||
/// as arguments. An async Op corresponds exactly to a Promise in JavaScript.
|
||||
#[allow(unused)]
|
||||
pub struct Isolate {
|
||||
pub struct CoreIsolate {
|
||||
pub v8_isolate: Option<v8::OwnedIsolate>,
|
||||
snapshot_creator: Option<v8::SnapshotCreator>,
|
||||
has_snapshotted: bool,
|
||||
|
@ -171,7 +171,7 @@ pub struct Isolate {
|
|||
error_handler: Option<Box<IsolateErrorHandleFn>>,
|
||||
}
|
||||
|
||||
impl Drop for Isolate {
|
||||
impl Drop for CoreIsolate {
|
||||
fn drop(&mut self) {
|
||||
if let Some(creator) = self.snapshot_creator.take() {
|
||||
// TODO(ry): in rusty_v8, `SnapShotCreator::get_owned_isolate()` returns
|
||||
|
@ -212,7 +212,7 @@ pub unsafe fn v8_init() {
|
|||
v8::V8::set_flags_from_command_line(argv);
|
||||
}
|
||||
|
||||
impl Isolate {
|
||||
impl CoreIsolate {
|
||||
/// startup_data defines the snapshot or script used at startup to initialize
|
||||
/// the isolate.
|
||||
pub fn new(startup_data: StartupData, will_snapshot: bool) -> Box<Self> {
|
||||
|
@ -233,7 +233,7 @@ impl Isolate {
|
|||
let mut creator =
|
||||
v8::SnapshotCreator::new(Some(&bindings::EXTERNAL_REFERENCES));
|
||||
let isolate = unsafe { creator.get_owned_isolate() };
|
||||
let mut isolate = Isolate::setup_isolate(isolate);
|
||||
let mut isolate = CoreIsolate::setup_isolate(isolate);
|
||||
|
||||
let mut hs = v8::HandleScope::new(&mut isolate);
|
||||
let scope = hs.enter();
|
||||
|
@ -257,7 +257,7 @@ impl Isolate {
|
|||
};
|
||||
|
||||
let isolate = v8::Isolate::new(params);
|
||||
let mut isolate = Isolate::setup_isolate(isolate);
|
||||
let mut isolate = CoreIsolate::setup_isolate(isolate);
|
||||
|
||||
let mut hs = v8::HandleScope::new(&mut isolate);
|
||||
let scope = hs.enter();
|
||||
|
@ -314,7 +314,7 @@ impl Isolate {
|
|||
boxed_isolate
|
||||
}
|
||||
|
||||
pub fn setup_isolate(mut isolate: v8::OwnedIsolate) -> v8::OwnedIsolate {
|
||||
fn setup_isolate(mut isolate: v8::OwnedIsolate) -> v8::OwnedIsolate {
|
||||
isolate.set_capture_stack_trace_for_uncaught_exceptions(true, 10);
|
||||
isolate.set_promise_reject_callback(bindings::promise_reject_callback);
|
||||
isolate
|
||||
|
@ -327,7 +327,7 @@ impl Isolate {
|
|||
/// Requires runtime to explicitly ask for op ids before using any of the ops.
|
||||
pub fn register_op<F>(&mut self, name: &str, op: F) -> OpId
|
||||
where
|
||||
F: Fn(&mut Isolate, &[u8], Option<ZeroCopyBuf>) -> Op + 'static,
|
||||
F: Fn(&mut CoreIsolate, &[u8], Option<ZeroCopyBuf>) -> Op + 'static,
|
||||
{
|
||||
self.op_registry.register(name, op)
|
||||
}
|
||||
|
@ -400,7 +400,7 @@ impl Isolate {
|
|||
///
|
||||
/// ErrBox can be downcast to a type that exposes additional information about
|
||||
/// the V8 exception. By default this type is JSError, however it may be a
|
||||
/// different type if Isolate::set_js_error_create_fn() has been used.
|
||||
/// different type if CoreIsolate::set_js_error_create_fn() has been used.
|
||||
pub fn execute(
|
||||
&mut self,
|
||||
js_filename: &str,
|
||||
|
@ -449,7 +449,7 @@ impl Isolate {
|
|||
///
|
||||
/// ErrBox can be downcast to a type that exposes additional information about
|
||||
/// the V8 exception. By default this type is JSError, however it may be a
|
||||
/// different type if Isolate::set_js_error_create_fn() has been used.
|
||||
/// different type if CoreIsolate::set_js_error_create_fn() has been used.
|
||||
pub fn snapshot(&mut self) -> v8::StartupData {
|
||||
assert!(self.snapshot_creator.is_some());
|
||||
|
||||
|
@ -473,7 +473,7 @@ impl Isolate {
|
|||
}
|
||||
}
|
||||
|
||||
impl Future for Isolate {
|
||||
impl Future for CoreIsolate {
|
||||
type Output = Result<(), ErrBox>;
|
||||
|
||||
fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
|
||||
|
@ -727,7 +727,7 @@ pub mod tests {
|
|||
}
|
||||
}
|
||||
panic!(
|
||||
"Isolate still not ready after polling {} times.",
|
||||
"CoreIsolate still not ready after polling {} times.",
|
||||
max_poll_count
|
||||
)
|
||||
}
|
||||
|
@ -741,13 +741,13 @@ pub mod tests {
|
|||
OverflowResAsync,
|
||||
}
|
||||
|
||||
pub fn setup(mode: Mode) -> (Box<Isolate>, Arc<AtomicUsize>) {
|
||||
pub fn setup(mode: Mode) -> (Box<CoreIsolate>, Arc<AtomicUsize>) {
|
||||
let dispatch_count = Arc::new(AtomicUsize::new(0));
|
||||
let dispatch_count_ = dispatch_count.clone();
|
||||
|
||||
let mut isolate = Isolate::new(StartupData::None, false);
|
||||
let mut isolate = CoreIsolate::new(StartupData::None, false);
|
||||
|
||||
let dispatcher = move |_isolate: &mut Isolate,
|
||||
let dispatcher = move |_isolate: &mut CoreIsolate,
|
||||
control: &[u8],
|
||||
_zero_copy: Option<ZeroCopyBuf>|
|
||||
-> Op {
|
||||
|
@ -1141,7 +1141,7 @@ pub mod tests {
|
|||
|
||||
#[test]
|
||||
fn syntax_error() {
|
||||
let mut isolate = Isolate::new(StartupData::None, false);
|
||||
let mut isolate = CoreIsolate::new(StartupData::None, false);
|
||||
let src = "hocuspocus(";
|
||||
let r = isolate.execute("i.js", src);
|
||||
let e = r.unwrap_err();
|
||||
|
@ -1166,13 +1166,13 @@ pub mod tests {
|
|||
#[test]
|
||||
fn will_snapshot() {
|
||||
let snapshot = {
|
||||
let mut isolate = Isolate::new(StartupData::None, true);
|
||||
let mut isolate = CoreIsolate::new(StartupData::None, true);
|
||||
js_check(isolate.execute("a.js", "a = 1 + 2"));
|
||||
isolate.snapshot()
|
||||
};
|
||||
|
||||
let startup_data = StartupData::Snapshot(Snapshot::JustCreated(snapshot));
|
||||
let mut isolate2 = Isolate::new(startup_data, false);
|
||||
let mut isolate2 = CoreIsolate::new(startup_data, false);
|
||||
js_check(isolate2.execute("check.js", "if (a != 3) throw Error('x')"));
|
||||
}
|
||||
}
|
||||
|
|
10
core/ops.rs
10
core/ops.rs
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
||||
use crate::Isolate;
|
||||
use crate::CoreIsolate;
|
||||
use crate::ZeroCopyBuf;
|
||||
use futures::Future;
|
||||
use std::collections::HashMap;
|
||||
|
@ -22,7 +22,7 @@ pub enum Op {
|
|||
|
||||
/// Main type describing op
|
||||
pub type OpDispatcher =
|
||||
dyn Fn(&mut Isolate, &[u8], Option<ZeroCopyBuf>) -> Op + 'static;
|
||||
dyn Fn(&mut CoreIsolate, &[u8], Option<ZeroCopyBuf>) -> Op + 'static;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct OpRegistry {
|
||||
|
@ -43,7 +43,7 @@ impl OpRegistry {
|
|||
|
||||
pub fn register<F>(&mut self, name: &str, op: F) -> OpId
|
||||
where
|
||||
F: Fn(&mut Isolate, &[u8], Option<ZeroCopyBuf>) -> Op + 'static,
|
||||
F: Fn(&mut CoreIsolate, &[u8], Option<ZeroCopyBuf>) -> Op + 'static,
|
||||
{
|
||||
let op_id = self.dispatchers.len() as u32;
|
||||
|
||||
|
@ -86,7 +86,7 @@ fn test_op_registry() {
|
|||
expected.insert("test".to_string(), 1);
|
||||
assert_eq!(op_registry.name_to_id, expected);
|
||||
|
||||
let mut isolate = Isolate::new(crate::StartupData::None, false);
|
||||
let mut isolate = CoreIsolate::new(crate::StartupData::None, false);
|
||||
|
||||
let dispatch = op_registry.get(test_id).unwrap();
|
||||
let res = dispatch(&mut isolate, &[], None);
|
||||
|
@ -126,7 +126,7 @@ fn register_op_during_call() {
|
|||
};
|
||||
assert!(test_id != 0);
|
||||
|
||||
let mut isolate = Isolate::new(crate::StartupData::None, false);
|
||||
let mut isolate = CoreIsolate::new(crate::StartupData::None, false);
|
||||
|
||||
let dispatcher1 = {
|
||||
let g = op_registry.lock().unwrap();
|
||||
|
|
|
@ -8,8 +8,8 @@ extern crate serde_json;
|
|||
mod ops;
|
||||
use deno_core::js_check;
|
||||
pub use deno_core::v8_set_flags;
|
||||
use deno_core::CoreIsolate;
|
||||
use deno_core::ErrBox;
|
||||
use deno_core::Isolate;
|
||||
use deno_core::ModuleSpecifier;
|
||||
use deno_core::Op;
|
||||
use deno_core::StartupData;
|
||||
|
@ -49,11 +49,11 @@ pub struct TSState {
|
|||
fn compiler_op<D>(
|
||||
ts_state: Arc<Mutex<TSState>>,
|
||||
dispatcher: D,
|
||||
) -> impl Fn(&mut deno_core::Isolate, &[u8], Option<ZeroCopyBuf>) -> Op
|
||||
) -> impl Fn(&mut CoreIsolate, &[u8], Option<ZeroCopyBuf>) -> Op
|
||||
where
|
||||
D: Fn(&mut TSState, &[u8]) -> Op,
|
||||
{
|
||||
move |_isolate: &mut deno_core::Isolate,
|
||||
move |_isolate: &mut CoreIsolate,
|
||||
control: &[u8],
|
||||
zero_copy_buf: Option<ZeroCopyBuf>|
|
||||
-> Op {
|
||||
|
@ -64,7 +64,7 @@ where
|
|||
}
|
||||
|
||||
pub struct TSIsolate {
|
||||
isolate: Box<Isolate>,
|
||||
isolate: Box<CoreIsolate>,
|
||||
state: Arc<Mutex<TSState>>,
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ impl TSIsolate {
|
|||
bundle: bool,
|
||||
maybe_extern_crate_modules: Option<ExternCrateModules>,
|
||||
) -> TSIsolate {
|
||||
let mut isolate = Isolate::new(StartupData::None, false);
|
||||
let mut isolate = CoreIsolate::new(StartupData::None, false);
|
||||
js_check(isolate.execute("assets/typescript.js", TYPESCRIPT_CODE));
|
||||
js_check(isolate.execute("compiler_main.js", COMPILER_CODE));
|
||||
|
||||
|
@ -196,7 +196,7 @@ fn print_source_code(code: &str) {
|
|||
|
||||
/// Create a V8 snapshot.
|
||||
pub fn mksnapshot_bundle(
|
||||
isolate: &mut Isolate,
|
||||
isolate: &mut CoreIsolate,
|
||||
snapshot_filename: &Path,
|
||||
bundle_filename: &Path,
|
||||
main_module_name: &str,
|
||||
|
@ -216,7 +216,7 @@ pub fn mksnapshot_bundle(
|
|||
/// Create a V8 snapshot. This differs from mksnapshot_bundle in that is also
|
||||
/// runs typescript.js
|
||||
pub fn mksnapshot_bundle_ts(
|
||||
isolate: &mut Isolate,
|
||||
isolate: &mut CoreIsolate,
|
||||
snapshot_filename: &Path,
|
||||
bundle_filename: &Path,
|
||||
main_module_name: &str,
|
||||
|
@ -231,7 +231,7 @@ pub fn mksnapshot_bundle_ts(
|
|||
}
|
||||
|
||||
fn write_snapshot(
|
||||
runtime_isolate: &mut Isolate,
|
||||
runtime_isolate: &mut CoreIsolate,
|
||||
snapshot_filename: &Path,
|
||||
) -> Result<(), ErrBox> {
|
||||
println!("Creating snapshot...");
|
||||
|
@ -326,14 +326,14 @@ pub fn trace_serializer() {
|
|||
}
|
||||
|
||||
/// Warning: Returns a non-JSON op dispatcher. Must be manually attached to
|
||||
/// Isolate.
|
||||
/// CoreIsolate.
|
||||
pub fn op_fetch_asset<S: ::std::hash::BuildHasher>(
|
||||
custom_assets: HashMap<String, PathBuf, S>,
|
||||
) -> impl Fn(&mut deno_core::Isolate, &[u8], Option<ZeroCopyBuf>) -> Op {
|
||||
) -> impl Fn(&mut CoreIsolate, &[u8], Option<ZeroCopyBuf>) -> Op {
|
||||
for (_, path) in custom_assets.iter() {
|
||||
println!("cargo:rerun-if-changed={}", path.display());
|
||||
}
|
||||
move |_isolate: &mut deno_core::Isolate,
|
||||
move |_isolate: &mut CoreIsolate,
|
||||
control: &[u8],
|
||||
zero_copy_buf: Option<ZeroCopyBuf>|
|
||||
-> Op {
|
||||
|
|
|
@ -2,18 +2,19 @@ extern crate deno_core;
|
|||
extern crate futures;
|
||||
|
||||
use deno_core::Buf;
|
||||
use deno_core::CoreIsolate;
|
||||
use deno_core::Op;
|
||||
use deno_core::ZeroCopyBuf;
|
||||
use futures::future::FutureExt;
|
||||
|
||||
#[no_mangle]
|
||||
pub fn deno_plugin_init(isolate: &mut deno_core::Isolate) {
|
||||
pub fn deno_plugin_init(isolate: &mut CoreIsolate) {
|
||||
isolate.register_op("testSync", op_test_sync);
|
||||
isolate.register_op("testAsync", op_test_async);
|
||||
}
|
||||
|
||||
pub fn op_test_sync(
|
||||
_isolate: &mut deno_core::Isolate,
|
||||
_isolate: &mut CoreIsolate,
|
||||
data: &[u8],
|
||||
zero_copy: Option<ZeroCopyBuf>,
|
||||
) -> Op {
|
||||
|
@ -31,7 +32,7 @@ pub fn op_test_sync(
|
|||
}
|
||||
|
||||
pub fn op_test_async(
|
||||
_isolate: &mut deno_core::Isolate,
|
||||
_isolate: &mut CoreIsolate,
|
||||
data: &[u8],
|
||||
zero_copy: Option<ZeroCopyBuf>,
|
||||
) -> Op {
|
||||
|
|
Loading…
Reference in a new issue