ce488c0156
Builtins are not snapshotted, but instead we insert "builtin wrappers" into the snapshot, and create references to the corresponding builtin when deserializing. Subclassing builtins will be implemented in a follow-up CL. First version: https://chromium-review.googlesource.com/c/v8/v8/+/3630080 Fix: initialize builtin_objects_handle_ Bug: v8:11525,v8:12820 Change-Id: Ia2b5d41af5d7f577f1b02356b22a8760963009e4 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3635718 Reviewed-by: Camillo Bruni <cbruni@chromium.org> Commit-Queue: Marja Hölttä <marja@chromium.org> Cr-Commit-Position: refs/heads/main@{#80430}
26 lines
898 B
JavaScript
26 lines
898 B
JavaScript
// Copyright 2022 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
function use(exports) {
|
|
const result = Object.create(null);
|
|
exports.forEach(x => result[x] = globalThis[x]);
|
|
return result;
|
|
}
|
|
|
|
function takeAndUseWebSnapshot(createObjects, exports, realmForDeserializing) {
|
|
// Take a snapshot in Realm r1.
|
|
const r1 = Realm.create();
|
|
Realm.eval(r1, createObjects, { type: 'function' });
|
|
const snapshot = Realm.takeWebSnapshot(r1, exports);
|
|
// Use the snapshot in Realm r2.
|
|
const r2 = realmForDeserializing != undefined ?
|
|
realmForDeserializing : Realm.create();
|
|
const success = Realm.useWebSnapshot(r2, snapshot);
|
|
assertTrue(success);
|
|
const result =
|
|
Realm.eval(r2, use, { type: 'function', arguments: [exports] });
|
|
%HeapObjectVerify(result);
|
|
return result;
|
|
}
|