Skip to content

Commit

Permalink
Revert "use-snapshots build option for cross compile support. (deno…
Browse files Browse the repository at this point in the history
…land#1852)"

Slows down startup time
denoland#1852 (comment)

This reverts commit 75fe80d.
  • Loading branch information
ry committed Mar 5, 2019
1 parent ee29ed7 commit b6e113b
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 209 deletions.
7 changes: 0 additions & 7 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,6 @@ fn main() {
}
}

// Enable snapshots for x64 builds
if env::var("CARGO_CFG_TARGET_ARCH").unwrap() == "x86_64" {
// Not related to v8_use_snapshot
// This only enables using pregenerated snapshots for isolate init
println!("cargo:rustc-cfg=feature=\"use-snapshot-init\"");
}

if !gn_out_path.join("build.ninja").exists() {
let status = Command::new("python")
.env("DENO_BUILD_PATH", &gn_out_dir)
Expand Down
11 changes: 4 additions & 7 deletions libdeno/api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <string>

#include "third_party/v8/include/libplatform/libplatform.h"
Expand All @@ -11,7 +10,6 @@

#include "deno.h"
#include "exceptions.h"
#include "file_util.h"
#include "internal.h"

extern "C" {
Expand Down Expand Up @@ -108,11 +106,10 @@ deno_buf deno_get_snapshot(Deno* d_) {
static std::unique_ptr<v8::Platform> platform;

void deno_init() {
if (platform.get() == nullptr) {
platform = v8::platform::NewDefaultPlatform();
v8::V8::InitializePlatform(platform.get());
v8::V8::Initialize();
}
CHECK_NULL(platform.get());
platform = v8::platform::NewDefaultPlatform();
v8::V8::InitializePlatform(platform.get());
v8::V8::Initialize();
}

const char* deno_v8_version() { return v8::V8::GetVersion(); }
Expand Down
3 changes: 0 additions & 3 deletions src/compiler.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
use crate::isolate::Buf;
use crate::isolate::IsolateState;
use crate::isolate_init;
use crate::msg;
use crate::permissions::DenoPermissions;
use crate::resources;
Expand Down Expand Up @@ -51,7 +50,6 @@ impl ModuleMetaData {

fn lazy_start(parent_state: &Arc<IsolateState>) -> Resource {
let mut cell = C_RID.lock().unwrap();
let isolate_init = isolate_init::compiler_isolate_init();
let permissions = DenoPermissions {
allow_read: AtomicBool::new(true),
allow_write: AtomicBool::new(true),
Expand All @@ -61,7 +59,6 @@ fn lazy_start(parent_state: &Arc<IsolateState>) -> Resource {
};
let rid = cell.get_or_insert_with(|| {
let resource = workers::spawn(
isolate_init,
parent_state.clone(),
"compilerMain()".to_string(),
permissions,
Expand Down
77 changes: 21 additions & 56 deletions src/isolate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use crate::errors::DenoError;
use crate::errors::DenoResult;
use crate::errors::RustOrJsError;
use crate::flags;
use crate::isolate_init::IsolateInit;
use crate::js_errors::apply_source_map;
use crate::libdeno;
use crate::modules::Modules;
Expand Down Expand Up @@ -167,7 +166,7 @@ static DENO_INIT: Once = ONCE_INIT;

impl Isolate {
pub fn new(
init: IsolateInit,
snapshot: libdeno::deno_buf,
state: Arc<IsolateState>,
dispatch: Dispatch,
permissions: DenoPermissions,
Expand All @@ -177,18 +176,15 @@ impl Isolate {
});
let config = libdeno::deno_config {
will_snapshot: 0,
load_snapshot: match init.snapshot {
Some(s) => s,
None => libdeno::deno_buf::empty(),
},
load_snapshot: snapshot,
shared: libdeno::deno_buf::empty(), // TODO Use for message passing.
recv_cb: pre_dispatch,
};
let libdeno_isolate = unsafe { libdeno::deno_new(config) };
// This channel handles sending async messages back to the runtime.
let (tx, rx) = mpsc::channel::<(usize, Buf)>();

let new_isolate = Self {
Self {
libdeno_isolate,
dispatch,
rx,
Expand All @@ -198,17 +194,7 @@ impl Isolate {
modules: RefCell::new(Modules::new()),
state,
permissions: Arc::new(permissions),
};

// Run init script if present.
match init.init_script {
Some(init_script) => new_isolate
.execute2(init_script.filename.as_str(), init_script.source.as_str())
.unwrap(),
None => {}
};

new_isolate
}
}

#[inline]
Expand Down Expand Up @@ -632,12 +618,9 @@ mod tests {
#[test]
fn test_dispatch_sync() {
let state = IsolateState::mock();
let init = IsolateInit {
snapshot: None,
init_script: None,
};
let isolate =
Isolate::new(init, state, dispatch_sync, DenoPermissions::default());
let snapshot = libdeno::deno_buf::empty();
let permissions = DenoPermissions::default();
let isolate = Isolate::new(snapshot, state, dispatch_sync, permissions);
tokio_util::init(|| {
isolate
.execute(
Expand Down Expand Up @@ -675,16 +658,10 @@ mod tests {
#[test]
fn test_metrics_sync() {
let state = IsolateState::mock();
let init = IsolateInit {
snapshot: None,
init_script: None,
};
let isolate = Isolate::new(
init,
state,
metrics_dispatch_sync,
DenoPermissions::default(),
);
let snapshot = libdeno::deno_buf::empty();
let permissions = DenoPermissions::default();
let isolate =
Isolate::new(snapshot, state, metrics_dispatch_sync, permissions);
tokio_util::init(|| {
// Verify that metrics have been properly initialized.
{
Expand Down Expand Up @@ -717,16 +694,10 @@ mod tests {
#[test]
fn test_metrics_async() {
let state = IsolateState::mock();
let init = IsolateInit {
snapshot: None,
init_script: None,
};
let isolate = Isolate::new(
init,
state,
metrics_dispatch_async,
DenoPermissions::default(),
);
let snapshot = libdeno::deno_buf::empty();
let permissions = DenoPermissions::default();
let isolate =
Isolate::new(snapshot, state, metrics_dispatch_async, permissions);
tokio_util::init(|| {
// Verify that metrics have been properly initialized.
{
Expand Down Expand Up @@ -813,12 +784,9 @@ mod tests {
let (flags, rest_argv, _) = flags::set_flags(argv).unwrap();

let state = Arc::new(IsolateState::new(flags, rest_argv, None));
let init = IsolateInit {
snapshot: None,
init_script: None,
};
let mut isolate =
Isolate::new(init, state, dispatch_sync, DenoPermissions::default());
let snapshot = libdeno::deno_buf::empty();
let permissions = DenoPermissions::default();
let mut isolate = Isolate::new(snapshot, state, dispatch_sync, permissions);
tokio_util::init(|| {
isolate
.execute_mod(filename, false)
Expand All @@ -839,12 +807,9 @@ mod tests {
let (flags, rest_argv, _) = flags::set_flags(argv).unwrap();

let state = Arc::new(IsolateState::new(flags, rest_argv, None));
let init = IsolateInit {
snapshot: None,
init_script: None,
};
let mut isolate =
Isolate::new(init, state, dispatch_sync, DenoPermissions::default());
let snapshot = libdeno::deno_buf::empty();
let permissions = DenoPermissions::default();
let mut isolate = Isolate::new(snapshot, state, dispatch_sync, permissions);
tokio_util::init(|| {
isolate
.execute_mod(filename, false)
Expand Down
86 changes: 0 additions & 86 deletions src/isolate_init.rs

This file was deleted.

6 changes: 3 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ mod fs;
mod http_body;
mod http_util;
pub mod isolate;
pub mod isolate_init;
pub mod js_errors;
pub mod libdeno;
pub mod modules;
Expand All @@ -28,6 +27,7 @@ pub mod permissions;
mod repl;
pub mod resolve_addr;
pub mod resources;
pub mod snapshot;
mod tokio_util;
mod tokio_write;
pub mod version;
Expand Down Expand Up @@ -95,10 +95,10 @@ fn main() {
let should_display_info = flags.info;

let state = Arc::new(isolate::IsolateState::new(flags, rest_argv, None));
let isolate_init = isolate_init::deno_isolate_init();
let snapshot = snapshot::deno_snapshot();
let permissions = permissions::DenoPermissions::from_flags(&state.flags);
let mut isolate =
isolate::Isolate::new(isolate_init, state, ops::dispatch, permissions);
isolate::Isolate::new(snapshot, state, ops::dispatch, permissions);

tokio_util::init(|| {
// Setup runtime.
Expand Down
Loading

0 comments on commit b6e113b

Please sign in to comment.