Skip to content

Commit

Permalink
fix: don't create code caches when snapshotting
Browse files Browse the repository at this point in the history
  • Loading branch information
devsnek committed Jun 26, 2024
1 parent 1d32260 commit efeea2c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .github/workflows/ci-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,15 @@ jobs:
id: test
if: inputs.job == 'test'
uses: ./.github/workflows/ci-test
env:
V8_FORCE_DEBUG: ${{ inputs.label == "linux" && "1" : "0" }}

- name: Test (ops)
id: test-ops
if: inputs.job == 'test-ops'
uses: ./.github/workflows/ci-test-ops
env:
V8_FORCE_DEBUG: ${{ inputs.label == "linux" && "1" : "0" }}

- name: Test (miri)
id: test-miri
Expand Down
7 changes: 6 additions & 1 deletion core/modules/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ pub(crate) struct ModuleMap {
pending_code_cache_ready: Cell<bool>,
module_waker: AtomicWaker,
data: RefCell<ModuleMapData>,
will_snapshot: bool,

/// A counter used to delay our dynamic import deadlock detection by one spin
/// of the event loop.
Expand Down Expand Up @@ -202,8 +203,10 @@ impl ModuleMap {
loader: Rc<dyn ModuleLoader>,
exception_state: Rc<ExceptionState>,
import_meta_resolve_cb: ImportMetaResolveCallback,
will_snapshot: bool,
) -> Self {
Self {
will_snapshot,
loader: loader.into(),
exception_state,
import_meta_resolve_cb,
Expand Down Expand Up @@ -639,7 +642,9 @@ impl ModuleMap {

let module = maybe_module.unwrap();

if try_store_code_cache {
// V8 does not support creating code caches while also snapshotting,
// and it's not needed anyway, as the snapshot already contains it.
if try_store_code_cache && !self.will_snapshot {
if let Some(code_cache_info) = code_cache_info.take() {
let unbound_module_script = module.get_unbound_module_script(tc_scope);
let code_cache =
Expand Down
1 change: 1 addition & 0 deletions core/runtime/jsruntime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -899,6 +899,7 @@ impl JsRuntime {
loader,
exception_state.clone(),
import_meta_resolve_cb,
will_snapshot,
));

if let Some((snapshotted_data, mut data_store)) = snapshotted_data {
Expand Down

0 comments on commit efeea2c

Please sign in to comment.