summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2020-10-07 17:20:20 +0200
committerGitHub <noreply@github.com>2020-10-07 17:20:20 +0200
commit9b70f2f34540909daf4f4bce5ab77e3bfb8f1bed (patch)
tree38f4ea4d00953faa2e9ca7ec4edb9cdd17355e87
parent83f6def3c62e7f336516d59881e8f9f7846d9024 (diff)
refactor: rename isolate to js_runtime (#7858)
This commit renames occurrences of "isolate" variable name to "js_runtime". This was outstanding debt after renaming deno_core::CoreIsolate to JsRuntime.
-rw-r--r--cli/build.rs20
-rw-r--r--cli/inspector.rs6
-rw-r--r--cli/js.rs8
-rw-r--r--cli/ops/worker_host.rs2
-rw-r--r--cli/worker.rs30
-rw-r--r--core/examples/http_bench_bin_ops.rs30
-rw-r--r--core/examples/http_bench_json_ops.rs8
7 files changed, 52 insertions, 52 deletions
diff --git a/cli/build.rs b/cli/build.rs
index 64cef3082..6435f0225 100644
--- a/cli/build.rs
+++ b/cli/build.rs
@@ -10,12 +10,12 @@ use std::path::Path;
use std::path::PathBuf;
fn create_snapshot(
- mut isolate: JsRuntime,
+ mut js_runtime: JsRuntime,
snapshot_path: &Path,
files: Vec<PathBuf>,
) {
- deno_web::init(&mut isolate);
- deno_fetch::init(&mut isolate);
+ deno_web::init(&mut js_runtime);
+ deno_fetch::init(&mut js_runtime);
// TODO(nayeemrmn): https://github.com/rust-lang/cargo/issues/3946 to get the
// workspace root.
let display_root = Path::new(env!("CARGO_MANIFEST_DIR")).parent().unwrap();
@@ -23,7 +23,7 @@ fn create_snapshot(
println!("cargo:rerun-if-changed={}", file.display());
let display_path = file.strip_prefix(display_root).unwrap();
let display_path_str = display_path.display().to_string();
- isolate
+ js_runtime
.execute(
&("deno:".to_string() + &display_path_str.replace('\\', "/")),
&std::fs::read_to_string(&file).unwrap(),
@@ -31,7 +31,7 @@ fn create_snapshot(
.unwrap();
}
- let snapshot = isolate.snapshot();
+ let snapshot = js_runtime.snapshot();
let snapshot_slice: &[u8] = &*snapshot;
println!("Snapshot size: {}", snapshot_slice.len());
std::fs::write(&snapshot_path, snapshot_slice).unwrap();
@@ -39,11 +39,11 @@ fn create_snapshot(
}
fn create_runtime_snapshot(snapshot_path: &Path, files: Vec<PathBuf>) {
- let isolate = JsRuntime::new(RuntimeOptions {
+ let js_runtime = JsRuntime::new(RuntimeOptions {
will_snapshot: true,
..Default::default()
});
- create_snapshot(isolate, snapshot_path, files);
+ create_snapshot(js_runtime, snapshot_path, files);
}
fn create_compiler_snapshot(
@@ -79,15 +79,15 @@ fn create_compiler_snapshot(
cwd.join("dts/lib.deno.unstable.d.ts"),
);
- let mut isolate = JsRuntime::new(RuntimeOptions {
+ let mut js_runtime = JsRuntime::new(RuntimeOptions {
will_snapshot: true,
..Default::default()
});
- isolate.register_op(
+ js_runtime.register_op(
"op_fetch_asset",
op_fetch_asset::op_fetch_asset(custom_libs),
);
- create_snapshot(isolate, snapshot_path, files);
+ create_snapshot(js_runtime, snapshot_path, files);
}
fn ts_version() -> String {
diff --git a/cli/inspector.rs b/cli/inspector.rs
index 6992e9855..3cc3bf566 100644
--- a/cli/inspector.rs
+++ b/cli/inspector.rs
@@ -390,11 +390,11 @@ impl DenoInspector {
const CONTEXT_GROUP_ID: i32 = 1;
pub fn new(
- isolate: &mut deno_core::JsRuntime,
+ js_runtime: &mut deno_core::JsRuntime,
server: Option<Arc<InspectorServer>>,
) -> Box<Self> {
- let context = isolate.global_context();
- let scope = &mut v8::HandleScope::new(isolate.v8_isolate());
+ let context = js_runtime.global_context();
+ let scope = &mut v8::HandleScope::new(js_runtime.v8_isolate());
let (new_websocket_tx, new_websocket_rx) =
mpsc::unbounded::<WebSocketProxy>();
diff --git a/cli/js.rs b/cli/js.rs
index beb8df192..d51d7dd92 100644
--- a/cli/js.rs
+++ b/cli/js.rs
@@ -30,11 +30,11 @@ pub fn compiler_isolate_init() -> Snapshot {
#[test]
fn cli_snapshot() {
- let mut isolate = deno_core::JsRuntime::new(deno_core::RuntimeOptions {
+ let mut js_runtime = deno_core::JsRuntime::new(deno_core::RuntimeOptions {
startup_snapshot: Some(deno_isolate_init()),
..Default::default()
});
- isolate
+ js_runtime
.execute(
"<anon>",
r#"
@@ -49,11 +49,11 @@ fn cli_snapshot() {
#[test]
fn compiler_snapshot() {
- let mut isolate = deno_core::JsRuntime::new(deno_core::RuntimeOptions {
+ let mut js_runtime = deno_core::JsRuntime::new(deno_core::RuntimeOptions {
startup_snapshot: Some(compiler_isolate_init()),
..Default::default()
});
- isolate
+ js_runtime
.execute(
"<anon>",
r#"
diff --git a/cli/ops/worker_host.rs b/cli/ops/worker_host.rs
index 17e0e397f..6d74bb9f4 100644
--- a/cli/ops/worker_host.rs
+++ b/cli/ops/worker_host.rs
@@ -62,7 +62,7 @@ fn create_web_worker(
);
if has_deno_namespace {
- let state = worker.isolate.op_state();
+ let state = worker.js_runtime.op_state();
let mut state = state.borrow_mut();
let (stdin, stdout, stderr) = get_stdio();
if let Some(stream) = stdin {
diff --git a/cli/worker.rs b/cli/worker.rs
index 0a50b5624..488a2eeba 100644
--- a/cli/worker.rs
+++ b/cli/worker.rs
@@ -96,7 +96,7 @@ fn create_channels() -> (WorkerChannelsInternal, WorkerHandle) {
/// - `WebWorker`
pub struct Worker {
pub name: String,
- pub isolate: JsRuntime,
+ pub js_runtime: JsRuntime,
pub inspector: Option<Box<DenoInspector>>,
pub waker: AtomicWaker,
pub(crate) internal_channels: WorkerChannelsInternal,
@@ -114,7 +114,7 @@ impl Worker {
) -> Self {
let global_state_ = global_state.clone();
- let mut isolate = JsRuntime::new(RuntimeOptions {
+ let mut js_runtime = JsRuntime::new(RuntimeOptions {
module_loader: Some(module_loader),
startup_snapshot: Some(startup_snapshot),
js_error_create_fn: Some(Box::new(move |core_js_error| {
@@ -123,7 +123,7 @@ impl Worker {
..Default::default()
});
{
- let op_state = isolate.op_state();
+ let op_state = js_runtime.op_state();
let mut op_state = op_state.borrow_mut();
op_state.get_error_class_fn = &crate::errors::get_error_class_name;
}
@@ -131,11 +131,11 @@ impl Worker {
let inspector =
if let Some(inspector_server) = &global_state.maybe_inspector_server {
Some(DenoInspector::new(
- &mut isolate,
+ &mut js_runtime,
Some(inspector_server.clone()),
))
} else if global_state.flags.coverage || global_state.flags.repl {
- Some(DenoInspector::new(&mut isolate, None))
+ Some(DenoInspector::new(&mut js_runtime, None))
} else {
None
};
@@ -148,7 +148,7 @@ impl Worker {
Self {
name,
- isolate,
+ js_runtime,
inspector,
waker: AtomicWaker::new(),
internal_channels,
@@ -171,7 +171,7 @@ impl Worker {
js_filename: &str,
js_source: &str,
) -> Result<(), AnyError> {
- self.isolate.execute(js_filename, js_source)
+ self.js_runtime.execute(js_filename, js_source)
}
/// Loads and instantiates specified JavaScript module.
@@ -179,7 +179,7 @@ impl Worker {
&mut self,
module_specifier: &ModuleSpecifier,
) -> Result<ModuleId, AnyError> {
- self.isolate.load_module(module_specifier, None).await
+ self.js_runtime.load_module(module_specifier, None).await
}
/// Loads, instantiates and executes specified JavaScript module.
@@ -189,7 +189,7 @@ impl Worker {
) -> Result<(), AnyError> {
let id = self.preload_module(module_specifier).await?;
self.wait_for_inspector_session();
- self.isolate.mod_evaluate(id).await
+ self.js_runtime.mod_evaluate(id).await
}
/// Loads, instantiates and executes provided source code
@@ -200,11 +200,11 @@ impl Worker {
code: String,
) -> Result<(), AnyError> {
let id = self
- .isolate
+ .js_runtime
.load_module(module_specifier, Some(code))
.await?;
self.wait_for_inspector_session();
- self.isolate.mod_evaluate(id).await
+ self.js_runtime.mod_evaluate(id).await
}
/// Returns a way to communicate with the Worker from other threads.
@@ -240,20 +240,20 @@ impl Future for Worker {
// We always poll the inspector if it exists.
let _ = inner.inspector.as_mut().map(|i| i.poll_unpin(cx));
inner.waker.register(cx.waker());
- inner.isolate.poll_unpin(cx)
+ inner.js_runtime.poll_unpin(cx)
}
}
impl Deref for Worker {
type Target = JsRuntime;
fn deref(&self) -> &Self::Target {
- &self.isolate
+ &self.js_runtime
}
}
impl DerefMut for Worker {
fn deref_mut(&mut self) -> &mut Self::Target {
- &mut self.isolate
+ &mut self.js_runtime
}
}
@@ -428,7 +428,7 @@ impl WebWorker {
);
let terminated = Arc::new(AtomicBool::new(false));
- let isolate_handle = worker.isolate.v8_isolate().thread_safe_handle();
+ let isolate_handle = worker.js_runtime.v8_isolate().thread_safe_handle();
let (terminate_tx, terminate_rx) = mpsc::channel::<()>(1);
let handle = WebWorkerHandle {
diff --git a/core/examples/http_bench_bin_ops.rs b/core/examples/http_bench_bin_ops.rs
index bc92007b0..8d612f146 100644
--- a/core/examples/http_bench_bin_ops.rs
+++ b/core/examples/http_bench_bin_ops.rs
@@ -76,14 +76,14 @@ impl From<Record> for RecordBuf {
}
}
-fn create_isolate() -> JsRuntime {
- let mut isolate = JsRuntime::new(Default::default());
- register_op_bin_sync(&mut isolate, "listen", op_listen);
- register_op_bin_sync(&mut isolate, "close", op_close);
- register_op_bin_async(&mut isolate, "accept", op_accept);
- register_op_bin_async(&mut isolate, "read", op_read);
- register_op_bin_async(&mut isolate, "write", op_write);
- isolate
+fn create_js_runtime() -> JsRuntime {
+ let mut js_runtime = JsRuntime::new(Default::default());
+ register_op_bin_sync(&mut js_runtime, "listen", op_listen);
+ register_op_bin_sync(&mut js_runtime, "close", op_close);
+ register_op_bin_async(&mut js_runtime, "accept", op_accept);
+ register_op_bin_async(&mut js_runtime, "read", op_read);
+ register_op_bin_async(&mut js_runtime, "write", op_write);
+ js_runtime
}
fn op_listen(
@@ -172,7 +172,7 @@ fn op_write(
}
fn register_op_bin_sync<F>(
- isolate: &mut JsRuntime,
+ js_runtime: &mut JsRuntime,
name: &'static str,
op_fn: F,
) where
@@ -193,11 +193,11 @@ fn register_op_bin_sync<F>(
Op::Sync(buf)
};
- isolate.register_op(name, base_op_fn);
+ js_runtime.register_op(name, base_op_fn);
}
fn register_op_bin_async<F, R>(
- isolate: &mut JsRuntime,
+ js_runtime: &mut JsRuntime,
name: &'static str,
op_fn: F,
) where
@@ -227,7 +227,7 @@ fn register_op_bin_async<F, R>(
Op::Async(fut.boxed_local())
};
- isolate.register_op(name, base_op_fn);
+ js_runtime.register_op(name, base_op_fn);
}
fn bad_resource_id() -> Error {
@@ -246,7 +246,7 @@ fn main() {
// NOTE: `--help` arg will display V8 help and exit
deno_core::v8_set_flags(env::args().collect());
- let mut isolate = create_isolate();
+ let mut js_runtime = create_js_runtime();
let mut runtime = runtime::Builder::new()
.basic_scheduler()
.enable_all()
@@ -254,13 +254,13 @@ fn main() {
.unwrap();
let future = async move {
- isolate
+ js_runtime
.execute(
"http_bench_bin_ops.js",
include_str!("http_bench_bin_ops.js"),
)
.unwrap();
- isolate.await
+ js_runtime.await
};
runtime.block_on(future).unwrap();
}
diff --git a/core/examples/http_bench_json_ops.rs b/core/examples/http_bench_json_ops.rs
index a260159e5..106b96f36 100644
--- a/core/examples/http_bench_json_ops.rs
+++ b/core/examples/http_bench_json_ops.rs
@@ -41,7 +41,7 @@ impl log::Log for Logger {
fn flush(&self) {}
}
-fn create_isolate() -> JsRuntime {
+fn create_js_runtime() -> JsRuntime {
let mut runtime = JsRuntime::new(Default::default());
runtime.register_op("listen", deno_core::json_op_sync(op_listen));
runtime.register_op("close", deno_core::json_op_sync(op_close));
@@ -179,7 +179,7 @@ fn main() {
// NOTE: `--help` arg will display V8 help and exit
deno_core::v8_set_flags(env::args().collect());
- let mut isolate = create_isolate();
+ let mut js_runtime = create_js_runtime();
let mut runtime = runtime::Builder::new()
.basic_scheduler()
.enable_all()
@@ -187,13 +187,13 @@ fn main() {
.unwrap();
let future = async move {
- isolate
+ js_runtime
.execute(
"http_bench_json_ops.js",
include_str!("http_bench_json_ops.js"),
)
.unwrap();
- isolate.await
+ js_runtime.await
};
runtime.block_on(future).unwrap();
}