mirror of
https://github.com/denoland/deno.git
synced 2025-02-08 07:16:56 -05:00
feat(core): Reorder extension initialization (#16136)
This commit is contained in:
parent
a5d55fe6ea
commit
7c3df66be7
2 changed files with 12 additions and 5 deletions
|
@ -466,14 +466,15 @@ impl JsRuntime {
|
||||||
extensions: options.extensions,
|
extensions: options.extensions,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Init resources and ops before extensions to make sure they are
|
||||||
|
// available during the initialization process.
|
||||||
|
js_runtime.init_extension_ops().unwrap();
|
||||||
// TODO(@AaronO): diff extensions inited in snapshot and those provided
|
// TODO(@AaronO): diff extensions inited in snapshot and those provided
|
||||||
// for now we assume that snapshot and extensions always match
|
// for now we assume that snapshot and extensions always match
|
||||||
if !has_startup_snapshot {
|
if !has_startup_snapshot {
|
||||||
let realm = js_runtime.global_realm();
|
let realm = js_runtime.global_realm();
|
||||||
js_runtime.init_extension_js(&realm).unwrap();
|
js_runtime.init_extension_js(&realm).unwrap();
|
||||||
}
|
}
|
||||||
// Init extension ops
|
|
||||||
js_runtime.init_extension_ops().unwrap();
|
|
||||||
// Init callbacks (opresolve)
|
// Init callbacks (opresolve)
|
||||||
let global_realm = js_runtime.global_realm();
|
let global_realm = js_runtime.global_realm();
|
||||||
js_runtime.init_cbs(&global_realm);
|
js_runtime.init_cbs(&global_realm);
|
||||||
|
|
|
@ -124,7 +124,8 @@ pub fn init_stdio(stdio: Stdio) -> Extension {
|
||||||
.take()
|
.take()
|
||||||
.expect("Extension only supports being used once.");
|
.expect("Extension only supports being used once.");
|
||||||
let t = &mut state.resource_table;
|
let t = &mut state.resource_table;
|
||||||
t.add(StdFileResource::stdio(
|
|
||||||
|
let rid = t.add(StdFileResource::stdio(
|
||||||
match stdio.stdin {
|
match stdio.stdin {
|
||||||
StdioPipe::Inherit => StdFileResourceInner {
|
StdioPipe::Inherit => StdFileResourceInner {
|
||||||
kind: StdFileResourceKind::Stdin,
|
kind: StdFileResourceKind::Stdin,
|
||||||
|
@ -134,7 +135,9 @@ pub fn init_stdio(stdio: Stdio) -> Extension {
|
||||||
},
|
},
|
||||||
"stdin",
|
"stdin",
|
||||||
));
|
));
|
||||||
t.add(StdFileResource::stdio(
|
assert_eq!(rid, 0, "stdin must have ResourceId 0");
|
||||||
|
|
||||||
|
let rid = t.add(StdFileResource::stdio(
|
||||||
match stdio.stdout {
|
match stdio.stdout {
|
||||||
StdioPipe::Inherit => StdFileResourceInner {
|
StdioPipe::Inherit => StdFileResourceInner {
|
||||||
kind: StdFileResourceKind::Stdout,
|
kind: StdFileResourceKind::Stdout,
|
||||||
|
@ -144,7 +147,9 @@ pub fn init_stdio(stdio: Stdio) -> Extension {
|
||||||
},
|
},
|
||||||
"stdout",
|
"stdout",
|
||||||
));
|
));
|
||||||
t.add(StdFileResource::stdio(
|
assert_eq!(rid, 1, "stdout must have ResourceId 1");
|
||||||
|
|
||||||
|
let rid = t.add(StdFileResource::stdio(
|
||||||
match stdio.stderr {
|
match stdio.stderr {
|
||||||
StdioPipe::Inherit => StdFileResourceInner {
|
StdioPipe::Inherit => StdFileResourceInner {
|
||||||
kind: StdFileResourceKind::Stderr,
|
kind: StdFileResourceKind::Stderr,
|
||||||
|
@ -154,6 +159,7 @@ pub fn init_stdio(stdio: Stdio) -> Extension {
|
||||||
},
|
},
|
||||||
"stderr",
|
"stderr",
|
||||||
));
|
));
|
||||||
|
assert_eq!(rid, 2, "stderr must have ResourceId 2");
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
.build()
|
.build()
|
||||||
|
|
Loading…
Add table
Reference in a new issue