refactor(runtime): manual serialization of bootstrap data (#18448)

This commit changes how data required to bootstrap main and worker
runtime is serialized. 

Instead of relying on serde_v8 and using JSON object,
we're doing manual serialization to a "v8::Array". This limits number 
of V8 strings that need to be serialized by 16. 

It also made it clear that some data could be obtained during
snapshotting instead of during bootstrap.
This commit is contained in:
Bartek Iwańczuk 2023-03-28 10:27:17 +02:00 committed by GitHub
parent 86c3c4f343
commit 795ecfa146
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 230 additions and 62 deletions

View file

@ -361,13 +361,12 @@ impl MainWorker {
pub fn bootstrap(&mut self, options: &BootstrapOptions) {
let scope = &mut self.js_runtime.handle_scope();
let options_v8 =
deno_core::serde_v8::to_v8(scope, options.as_json()).unwrap();
let args = options.as_v8(scope);
let bootstrap_fn = self.bootstrap_fn_global.take().unwrap();
let bootstrap_fn = v8::Local::new(scope, bootstrap_fn);
let undefined = v8::undefined(scope);
bootstrap_fn
.call(scope, undefined.into(), &[options_v8])
.call(scope, undefined.into(), &[args.into()])
.unwrap();
}