Skip to content

Commit

Permalink
Revert "Reland "refactor(core): cleanup feature flags for js source i… (
Browse files Browse the repository at this point in the history
denoland#19611)

…nclusion" (denoland#19519)"

This reverts commit 28a4f3d.

This change causes failures when used outside Deno repo:
```
============================================================
Deno has panicked. This is a bug in Deno. Please report this
at https://github.com/denoland/deno/issues/new.
If you can reliably reproduce this panic, include the
reproduction steps and re-run with the RUST_BACKTRACE=1 env
var set and include the backtrace in your report.

Platform: linux x86_64
Version: 1.34.3+b37b286
Args: ["/opt/hostedtoolcache/deno/0.0.0-b37b286f7fa68d5656f7c180f6127bdc38cf2cf5/x64/deno", "test", "--doc", "--unstable", "--allow-all", "--coverage=./cov"]

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Failed to read "/home/runner/work/deno/deno/core/00_primordials.js"

Caused by:
    No such file or directory (os error 2)', core/runtime/jsruntime.rs:699:8
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```
  • Loading branch information
bartlomieju committed Jun 26, 2023
1 parent c7d38e5 commit ad3c494
Show file tree
Hide file tree
Showing 33 changed files with 326 additions and 290 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bench_util/benches/op_baseline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ deno_core::extension!(
);

fn setup() -> Vec<Extension> {
vec![bench_setup::init_ext()]
vec![bench_setup::init_ops()]
}

#[op]
Expand Down
8 changes: 4 additions & 4 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ harness = false
path = "./bench/lsp_bench_standalone.rs"

[build-dependencies]
deno_runtime = { workspace = true, features = ["exclude_js_main_from_snapshot"] }
deno_core = { workspace = true, features = ["runtime_js_sources"] }
deno_runtime = { workspace = true, features = ["snapshot_from_snapshot", "include_js_files_for_snapshotting"] }
deno_core = { workspace = true, features = ["include_js_files_for_snapshotting"] }
lazy-regex.workspace = true
serde.workspace = true
serde_json.workspace = true
Expand All @@ -41,14 +41,14 @@ winres.workspace = true

[dependencies]
deno_ast = { workspace = true, features = ["bundler", "cjs", "codegen", "dep_graph", "module_specifier", "proposal", "react", "sourcemap", "transforms", "typescript", "view", "visit"] }
deno_core = { workspace = true, features = ["exclude_js_sources"] }
deno_core = { workspace = true, features = ["include_js_files_for_snapshotting"] }
deno_doc = "=0.63.1"
deno_emit = "=0.24.0"
deno_graph = "=0.49.0"
deno_lint = { version = "=0.47.0", features = ["docs"] }
deno_lockfile.workspace = true
deno_npm.workspace = true
deno_runtime = { workspace = true, features = ["dont_create_runtime_snapshot"] }
deno_runtime = { workspace = true, features = ["dont_create_runtime_snapshot", "include_js_files_for_snapshotting"] }
deno_semver.workspace = true
deno_task_shell = "=0.12.0"
eszip = "=0.44.0"
Expand Down
48 changes: 26 additions & 22 deletions cli/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,11 @@ mod ts {
cargo_manifest_dir: env!("CARGO_MANIFEST_DIR"),
snapshot_path,
startup_snapshot: None,
extensions: vec![deno_tsc::init_ext(op_crate_libs, build_libs, path_dts)],
extensions: vec![deno_tsc::init_ops_and_esm(
op_crate_libs,
build_libs,
path_dts,
)],

// NOTE(bartlomieju): Compressing the TSC snapshot in debug build took
// ~45s on M1 MacBook Pro; without compression it took ~1s.
Expand Down Expand Up @@ -318,7 +322,7 @@ deno_core::extension!(
customizer = |ext: &mut deno_core::ExtensionBuilder| {
ext.esm(vec![ExtensionFileSource {
specifier: "ext:cli/runtime/js/99_main.js",
code: ExtensionFileSourceCode::LoadAtRuntime(
code: ExtensionFileSourceCode::LoadedFromFsDuringSnapshot(
std::path::PathBuf::from(deno_runtime::js::PATH_FOR_99_MAIN_JS),
),
}]);
Expand All @@ -331,42 +335,42 @@ fn create_cli_snapshot(snapshot_path: PathBuf) -> CreateSnapshotOutput {
// `runtime/worker.rs`, `runtime/web_worker.rs` and `runtime/build.rs`!
let fs = Arc::new(deno_fs::RealFs);
let extensions: Vec<Extension> = vec![
deno_webidl::deno_webidl::init_ext(),
deno_console::deno_console::init_ext(),
deno_url::deno_url::init_ext(),
deno_web::deno_web::init_ext::<PermissionsContainer>(
deno_webidl::deno_webidl::init_ops(),
deno_console::deno_console::init_ops(),
deno_url::deno_url::init_ops(),
deno_web::deno_web::init_ops::<PermissionsContainer>(
deno_web::BlobStore::default(),
Default::default(),
),
deno_fetch::deno_fetch::init_ext::<PermissionsContainer>(Default::default()),
deno_cache::deno_cache::init_ext::<SqliteBackedCache>(None),
deno_websocket::deno_websocket::init_ext::<PermissionsContainer>(
deno_fetch::deno_fetch::init_ops::<PermissionsContainer>(Default::default()),
deno_cache::deno_cache::init_ops::<SqliteBackedCache>(None),
deno_websocket::deno_websocket::init_ops::<PermissionsContainer>(
"".to_owned(),
None,
None,
),
deno_webstorage::deno_webstorage::init_ext(None),
deno_crypto::deno_crypto::init_ext(None),
deno_broadcast_channel::deno_broadcast_channel::init_ext(
deno_webstorage::deno_webstorage::init_ops(None),
deno_crypto::deno_crypto::init_ops(None),
deno_broadcast_channel::deno_broadcast_channel::init_ops(
deno_broadcast_channel::InMemoryBroadcastChannel::default(),
false, // No --unstable.
),
deno_ffi::deno_ffi::init_ext::<PermissionsContainer>(false),
deno_net::deno_net::init_ext::<PermissionsContainer>(
deno_ffi::deno_ffi::init_ops::<PermissionsContainer>(false),
deno_net::deno_net::init_ops::<PermissionsContainer>(
None, false, // No --unstable.
None,
),
deno_tls::deno_tls::init_ext(),
deno_kv::deno_kv::init_ext(
deno_tls::deno_tls::init_ops(),
deno_kv::deno_kv::init_ops(
SqliteDbHandler::<PermissionsContainer>::new(None),
false, // No --unstable.
),
deno_napi::deno_napi::init_ext::<PermissionsContainer>(),
deno_http::deno_http::init_ext::<DefaultHttpPropertyExtractor>(),
deno_io::deno_io::init_ext(Default::default()),
deno_fs::deno_fs::init_ext::<PermissionsContainer>(false, fs.clone()),
deno_node::deno_node::init_ext::<PermissionsContainer>(None, fs),
cli::init_ext(),
deno_napi::deno_napi::init_ops::<PermissionsContainer>(),
deno_http::deno_http::init_ops::<DefaultHttpPropertyExtractor>(),
deno_io::deno_io::init_ops(Default::default()),
deno_fs::deno_fs::init_ops::<PermissionsContainer>(false, fs.clone()),
deno_node::deno_node::init_ops::<PermissionsContainer>(None, fs),
cli::init_ops_and_esm(), // NOTE: This needs to be init_ops_and_esm!
];

create_snapshot(CreateSnapshotOptions {
Expand Down
2 changes: 1 addition & 1 deletion cli/lsp/tsc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3236,7 +3236,7 @@ fn op_script_version(
/// server.
fn js_runtime(performance: Arc<Performance>) -> JsRuntime {
JsRuntime::new(RuntimeOptions {
extensions: vec![deno_tsc::init_ext(performance)],
extensions: vec![deno_tsc::init_ops(performance)],
startup_snapshot: Some(tsc::compiler_snapshot()),
..Default::default()
})
Expand Down
2 changes: 1 addition & 1 deletion cli/ops/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub mod bench;
pub mod testing;

pub fn cli_exts(npm_resolver: Arc<CliNpmResolver>) -> Vec<Extension> {
vec![deno_cli::init_ext(npm_resolver)]
vec![deno_cli::init_ops(npm_resolver)]
}

deno_core::extension!(deno_cli,
Expand Down
2 changes: 1 addition & 1 deletion cli/tools/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ async fn bench_specifier(
.create_custom_worker(
specifier.clone(),
PermissionsContainer::new(permissions),
vec![ops::bench::deno_bench::init_ext(sender.clone())],
vec![ops::bench::deno_bench::init_ops(sender.clone())],
Default::default(),
)
.await?;
Expand Down
2 changes: 1 addition & 1 deletion cli/tools/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,7 @@ pub async fn test_specifier(
.create_custom_worker(
specifier.clone(),
PermissionsContainer::new(permissions),
vec![ops::testing::deno_test::init_ext(sender.clone())],
vec![ops::testing::deno_test::init_ops(sender.clone())],
Stdio {
stdin: StdioPipe::Inherit,
stdout,
Expand Down
4 changes: 2 additions & 2 deletions cli/tsc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ fn get_asset_texts_from_new_runtime() -> Result<Vec<AssetText>, AnyError> {
// the assets are stored within the typescript isolate, so take them out of there
let mut runtime = JsRuntime::new(RuntimeOptions {
startup_snapshot: Some(compiler_snapshot()),
extensions: vec![deno_cli_tsc::init_ext()],
extensions: vec![deno_cli_tsc::init_ops()],
..Default::default()
});
let global = runtime
Expand Down Expand Up @@ -787,7 +787,7 @@ pub fn exec(request: Request) -> Result<Response, AnyError> {

let mut runtime = JsRuntime::new(RuntimeOptions {
startup_snapshot: Some(compiler_snapshot()),
extensions: vec![deno_cli_tsc::init_ext(
extensions: vec![deno_cli_tsc::init_ops(
request,
root_map,
remapped_specifiers,
Expand Down
12 changes: 2 additions & 10 deletions core/00_primordials.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,6 @@
"use strict";

(() => {
// Provide bootstrap namespace
globalThis.__bootstrap ??= {};
const key = Symbol.for("00_primordials.js");
if (globalThis.__bootstrap[key]) {
return;
}
globalThis.__bootstrap[key] = true;

const primordials = {};

const {
Expand Down Expand Up @@ -305,7 +297,6 @@
ArrayPrototypeJoin,
ArrayPrototypeMap,
FunctionPrototypeCall,
ObjectAssign,
ObjectDefineProperty,
ObjectFreeze,
ObjectPrototypeIsPrototypeOf,
Expand Down Expand Up @@ -619,5 +610,6 @@
ObjectSetPrototypeOf(primordials, null);
ObjectFreeze(primordials);

ObjectAssign(globalThis.__bootstrap, { primordials });
// Provide bootstrap namespace
globalThis.__bootstrap = { primordials };
})();
7 changes: 0 additions & 7 deletions core/01_core.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,6 @@
URIError,
setQueueMicrotask,
} = window.__bootstrap.primordials;

const key = SymbolFor("01_core.js");
if (globalThis.__bootstrap[key]) {
return;
}
globalThis.__bootstrap[key] = true;

const { ops, asyncOps } = window.Deno.core;

const build = {
Expand Down
7 changes: 0 additions & 7 deletions core/02_error.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,8 @@
ArrayPrototypePush,
ArrayPrototypeMap,
ArrayPrototypeJoin,
SymbolFor,
} = window.__bootstrap.primordials;

const key = SymbolFor("02_error.js");
if (globalThis.__bootstrap[key]) {
return;
}
globalThis.__bootstrap[key] = true;

// Keep in sync with `cli/fmt_errors.rs`.
function formatLocation(cse) {
if (cse.isNative) {
Expand Down
11 changes: 2 additions & 9 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,7 @@ path = "lib.rs"
[features]
default = ["v8_use_custom_libcxx"]
v8_use_custom_libcxx = ["v8/use_custom_libcxx"]
# Enable to exclude extension!() JS sources from the binary (e.g. if they are already snapshotted).
exclude_js_sources = []
# Read extension!() JS sources at 'runtime' instead of statically including them. They will be read
# from their `CARGO_MANIFEST_DIR`-based paths, so it should only to be used in build and dev scripts
# where these paths are available. Overrides `exclude_js_sources`.
runtime_js_sources = ["exclude_js_sources"]
include_js_files_for_snapshotting = []

[dependencies]
anyhow.workspace = true
Expand Down Expand Up @@ -49,8 +44,6 @@ v8.workspace = true
name = "http_bench_json_ops"
path = "examples/http_bench_json_ops/main.rs"

[dev-dependencies]
deno_core = { workspace = true, features = ["runtime_js_sources"] }

# These dependencies are only used for the 'http_bench_*_ops' examples.
[dev-dependencies]
deno_ast.workspace = true
Loading

0 comments on commit ad3c494

Please sign in to comment.