[defer-import-eval] deferred import evaluation for ES modules [v8/v8 : main]

0 views
Skip to first unread message

Caio Lima (Gerrit)

unread,
Dec 15, 2025, 12:38:27 PM (yesterday) Dec 15
to Igor Sheludko, V8 LUCI CQ, Olivier Flückiger, Leszek Swirski, Nicolò Ribaudo, Hannes Payer, dmercadi...@chromium.org, mlippau...@chromium.org, v8-re...@googlegroups.com, was...@google.com
Attention needed from Igor Sheludko, Leszek Swirski and Olivier Flückiger

Caio Lima added 3 comments

Patchset-level comments
File-level comment, Patchset 6 (Latest):
Caio Lima . resolved

This new CL includes all the operations that should trigger an module evaluation.

File src/objects/js-objects.cc
Line 104, Patchset 4: case LookupIterator::DEFERRED_MODULE_NAMESPACE:
Igor Sheludko . resolved

This should be reachable via `Object.hasOwn()`. Please write a test for this.

It should evaluate the module and `continue`.

Caio Lima

I was planning to do other operations [[Has]], [[Set]], [[Delete]], [[GetOwnProperty]], etc in a separate patch to make it easier we review each case, but I can do them here if you prefer.

Igor Sheludko

Let's try to put it into one CL as long as it's not huge.

Caio Lima

Acknowledged

File src/objects/objects.cc
Line 1287, Patchset 4: it->GetName());
Igor Sheludko . resolved

Can we make it so that here we do just `JSDeferredModuleNamespace::EvaluateModuleSync(isolate, holder);` + exception handling, and let the regular path for `JSModuleNamespace` objects handle the rest?

Caio Lima

Yes. This would mean basically to inline `JSDeferredModuleNamespace::GetProperty` here. In this new Patchset, once a module is evaluated, it will never get through `DEFERRED_MODULE_NAMESPACE` anymore, as you suggested above.

Caio Lima

Acknowledged

Open in Gerrit

Related details

Attention is currently required from:
  • Igor Sheludko
  • Leszek Swirski
  • Olivier Flückiger
Submit Requirements:
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: v8/v8
Gerrit-Branch: main
Gerrit-Change-Id: I49a3a8e39bce0cb14ee2c032f6f7ff4d769c227f
Gerrit-Change-Number: 7247865
Gerrit-PatchSet: 6
Gerrit-Owner: Caio Lima <caio...@igalia.com>
Gerrit-Reviewer: Caio Lima <caio...@igalia.com>
Gerrit-Reviewer: Igor Sheludko <ish...@chromium.org>
Gerrit-Reviewer: Leszek Swirski <les...@chromium.org>
Gerrit-Reviewer: Olivier Flückiger <ol...@chromium.org>
Gerrit-CC: Hannes Payer <hpa...@chromium.org>
Gerrit-CC: Nicolò Ribaudo <nrib...@igalia.com>
Gerrit-Attention: Igor Sheludko <ish...@chromium.org>
Gerrit-Attention: Olivier Flückiger <ol...@chromium.org>
Gerrit-Attention: Leszek Swirski <les...@chromium.org>
Gerrit-Comment-Date: Mon, 15 Dec 2025 17:38:24 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Caio Lima <caio...@igalia.com>
Comment-In-Reply-To: Igor Sheludko <ish...@chromium.org>
unsatisfied_requirement
open
diffy

Caio Lima (Gerrit)

unread,
9:25 AM (5 hours ago) 9:25 AM
to Igor Sheludko, V8 LUCI CQ, Olivier Flückiger, Leszek Swirski, Nicolò Ribaudo, Hannes Payer, dmercadi...@chromium.org, mlippau...@chromium.org, v8-re...@googlegroups.com, was...@google.com
Attention needed from Igor Sheludko, Leszek Swirski and Olivier Flückiger

Caio Lima added 1 comment

File src/runtime/runtime-forin.cc
Line 78, Patchset 4: case LookupIterator::DEFERRED_MODULE_NAMESPACE:
Igor Sheludko . unresolved

This case might be reachable via `ns.propertyIsEnumerable(..)`.

Caio Lima

Thanks for pointing this out. I'm adding a test case for it as well. I don't know why I missed this comment before.

When using `Object.prototype.propertyIsEnumerable`, it actually goes to `JSReceiver::GetOwnPropertyAttributes` (ref: https://source.chromium.org/chromium/chromium/src/+/main:v8/src/builtins/builtins-object.cc;l=31;drc=d26244cc105a77ea0708ee85fd8cf2e3ab33c608), that is analogous to `[[GetOwnProperty]]` from spec (ref: https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable).

Also, it's important to notice that `ns.propertyIsEnumerable` will trigger evaluation due to `[[Get]]` first, so at this point, this `DEFERRED_MODULE_NAMESPACE` state should be unexpected as well. Another thing that's important is that namespace's prototype is null, and since it's also non-extensible, it can't be changed. The way to execute `propertyIsEnumrable` is through `Object.prototype.propertyIsEnumerable(ns, ...)`.

Open in Gerrit

Related details

Attention is currently required from:
  • Igor Sheludko
  • Leszek Swirski
  • Olivier Flückiger
Submit Requirements:
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: v8/v8
Gerrit-Branch: main
Gerrit-Change-Id: I49a3a8e39bce0cb14ee2c032f6f7ff4d769c227f
Gerrit-Change-Number: 7247865
Gerrit-PatchSet: 8
Gerrit-Owner: Caio Lima <caio...@igalia.com>
Gerrit-Reviewer: Caio Lima <caio...@igalia.com>
Gerrit-Reviewer: Igor Sheludko <ish...@chromium.org>
Gerrit-Reviewer: Leszek Swirski <les...@chromium.org>
Gerrit-Reviewer: Olivier Flückiger <ol...@chromium.org>
Gerrit-CC: Hannes Payer <hpa...@chromium.org>
Gerrit-CC: Nicolò Ribaudo <nrib...@igalia.com>
Gerrit-Attention: Igor Sheludko <ish...@chromium.org>
Gerrit-Attention: Olivier Flückiger <ol...@chromium.org>
Gerrit-Attention: Leszek Swirski <les...@chromium.org>
Gerrit-Comment-Date: Tue, 16 Dec 2025 14:25:12 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Igor Sheludko <ish...@chromium.org>
unsatisfied_requirement
open
diffy

Olivier Flückiger (Gerrit)

unread,
10:21 AM (4 hours ago) 10:21 AM
to Caio Lima, Igor Sheludko, V8 LUCI CQ, Leszek Swirski, Nicolò Ribaudo, Hannes Payer, dmercadi...@chromium.org, mlippau...@chromium.org, v8-re...@googlegroups.com, was...@google.com
Attention needed from Caio Lima, Igor Sheludko and Leszek Swirski

Olivier Flückiger added 5 comments

Patchset-level comments
File-level comment, Patchset 10 (Latest):
Olivier Flückiger . resolved

I am basically happy. Only one question left on my last pass over the CL.

File src/ic/ic.cc
Line 1020, Patchset 2: LoadHandler::LoadModuleExport(isolate(), value_index);
Olivier Flückiger . resolved

I would like to see a CSA_DCHECK that this load never happens on an unevaluated object.

This would go here: https://source.chromium.org/chromium/chromium/src/+/main:v8/src/ic/accessor-assembler.cc;l=1000;drc=adf1c0b0a7acf756e039e4203f41018e4bae22d0;bpv=0;bpt=1

Caio Lima

Here I'd need something that asserts `IsJSDeferredModuleNamespace(receiver) && module->status() == kEvaluated`. Would it make sense? The thing is that we can have accesses to ordinary module namespaces while it's module is not evaluated yet, since they can be in a evaluating or evaluating-async` state if there's a dependency cycle.

Caio Lima

This code doesn't exist in the new version, but I'm wondering if we'd still want to add this CSA_DCHECK there as well.

Igor Sheludko

IIUC the spec correctly that evaluated module does not require any more processing. I'd suggest to treat `LookupIterator::DEFERRED_MODULE_NAMESPACE` state as "not yet evaluated deferred module", and thus once it's evaluated we wouldn't even get into this case again.

Caio Lima

I think that's the behavior we have now, right? In the implementation of `JSDeferredModuleNamespace::TriggersEvaluation`, we do check if the module is evaluated or not. The only detail here is that if a module gets evaluated and transitions to `kErrored` estate because it throws, we still keep going through `LookupIterator::DEFERRED_MODULE_NAMESPACE`, because every future access to the `ns` needs to throws the same Exception, and it's stored in the module's `top_level_capability`. That's also the reason why we don't cache access in this case.

Olivier Flückiger

Acknowledged

File src/objects/js-objects.cc
Line 181, Patchset 8: case LookupIterator::DEFERRED_MODULE_NAMESPACE:
Olivier Flückiger . unresolved

When do we end up here?

Line 1042, Patchset 8: // TODO(https://crbug.com/348660658): replace language mode
Olivier Flückiger . unresolved
```suggestion
// TODO(348660658): replace language mode
```
File src/objects/module.cc
Line 511, Patchset 2: return true;
Olivier Flückiger . resolved

should we return false if it is already evaluated? (unsure about the implications)

Caio Lima

The implication here is that once a module gets evaluated, we will never get `DEFERRED_MODULE_NAMESPACE` kind.

This would require that I install the accessors for exported names once, and behave like `JSModuleNamespace` now. I didn't think about that earlier, but this could be work. For now I'm mostly doing on `MaybeEvaluate`, however doing this here can simplify things a bit. This might better, since I don't have to think in how IC would work with `DEFERRED_MODULE_NAMESPACE, and it will behave pretty much like `JSModuleNamespace` does today. I'll give it a try.

Caio Lima

I changed it in this new Patchset. I feel this version is better than before, since we won't have much difference between an evaluated deferred module and an ordinary module anymore. Also the IC handling is pretty much like `do nothing if the module is not evaluated`. Once it's evaluated, it'll get the same IC behavior as ordinary module namespaces.

Olivier Flückiger

Acknowledged

Open in Gerrit

Related details

Attention is currently required from:
  • Caio Lima
  • Igor Sheludko
  • Leszek Swirski
Submit Requirements:
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: v8/v8
Gerrit-Branch: main
Gerrit-Change-Id: I49a3a8e39bce0cb14ee2c032f6f7ff4d769c227f
Gerrit-Change-Number: 7247865
Gerrit-PatchSet: 10
Gerrit-Owner: Caio Lima <caio...@igalia.com>
Gerrit-Reviewer: Caio Lima <caio...@igalia.com>
Gerrit-Reviewer: Igor Sheludko <ish...@chromium.org>
Gerrit-Reviewer: Leszek Swirski <les...@chromium.org>
Gerrit-Reviewer: Olivier Flückiger <ol...@chromium.org>
Gerrit-CC: Hannes Payer <hpa...@chromium.org>
Gerrit-CC: Nicolò Ribaudo <nrib...@igalia.com>
Gerrit-Attention: Caio Lima <caio...@igalia.com>
Gerrit-Attention: Igor Sheludko <ish...@chromium.org>
Gerrit-Attention: Leszek Swirski <les...@chromium.org>
Gerrit-Comment-Date: Tue, 16 Dec 2025 15:21:53 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Caio Lima <caio...@igalia.com>
Comment-In-Reply-To: Igor Sheludko <ish...@chromium.org>
Comment-In-Reply-To: Olivier Flückiger <ol...@chromium.org>
unsatisfied_requirement
open
diffy

Caio Lima (Gerrit)

unread,
12:15 PM (2 hours ago) 12:15 PM
to Igor Sheludko, V8 LUCI CQ, Olivier Flückiger, Leszek Swirski, Nicolò Ribaudo, Hannes Payer, dmercadi...@chromium.org, mlippau...@chromium.org, v8-re...@googlegroups.com, was...@google.com
Attention needed from Igor Sheludko, Leszek Swirski and Olivier Flückiger

Caio Lima added 1 comment

File src/objects/js-objects.cc
Line 181, Patchset 8: case LookupIterator::DEFERRED_MODULE_NAMESPACE:
Olivier Flückiger . unresolved

When do we end up here?

Caio Lima

One path that I see is coming from Object::NoSideEffectsToString. This is called with `"toString"` when formatting an error message, (https://source.chromium.org/chromium/chromium/src/+/main:v8/src/objects/objects.cc;l=636;drc=07576e5c96c664c421fcf6fb0dfdb940622f8aa3). This is a test case where this gets called (https://github.com/tc39/test262/blob/079b13f85da120049919365612163e4579678e89/test/language/import/import-defer/evaluation-triggers/ignore-symbol-toStringTag-delete.js). Looks like all the callers for it are somewhat internal operations, and we shouldn't trigger an evaluation here, otherwise, it'll break the spec.

Open in Gerrit

Related details

Attention is currently required from:
  • Igor Sheludko
  • Leszek Swirski
  • Olivier Flückiger
Submit Requirements:
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: v8/v8
Gerrit-Branch: main
Gerrit-Change-Id: I49a3a8e39bce0cb14ee2c032f6f7ff4d769c227f
Gerrit-Change-Number: 7247865
Gerrit-PatchSet: 10
Gerrit-Owner: Caio Lima <caio...@igalia.com>
Gerrit-Reviewer: Caio Lima <caio...@igalia.com>
Gerrit-Reviewer: Igor Sheludko <ish...@chromium.org>
Gerrit-Reviewer: Leszek Swirski <les...@chromium.org>
Gerrit-Reviewer: Olivier Flückiger <ol...@chromium.org>
Gerrit-CC: Hannes Payer <hpa...@chromium.org>
Gerrit-CC: Nicolò Ribaudo <nrib...@igalia.com>
Gerrit-Attention: Igor Sheludko <ish...@chromium.org>
Gerrit-Attention: Olivier Flückiger <ol...@chromium.org>
Gerrit-Attention: Leszek Swirski <les...@chromium.org>
Gerrit-Comment-Date: Tue, 16 Dec 2025 17:15:45 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Olivier Flückiger <ol...@chromium.org>
unsatisfied_requirement
open
diffy

Caio Lima (Gerrit)

unread,
12:19 PM (2 hours ago) 12:19 PM
to Igor Sheludko, V8 LUCI CQ, Olivier Flückiger, Leszek Swirski, Nicolò Ribaudo, Hannes Payer, dmercadi...@chromium.org, mlippau...@chromium.org, v8-re...@googlegroups.com, was...@google.com
Attention needed from Igor Sheludko, Leszek Swirski and Olivier Flückiger

Caio Lima added 1 comment

File src/objects/js-objects.cc
Line 1042, Patchset 8: // TODO(https://crbug.com/348660658): replace language mode
Olivier Flückiger . resolved
```suggestion
// TODO(348660658): replace language mode
```
Caio Lima

Fix applied.

Open in Gerrit

Related details

Attention is currently required from:
  • Igor Sheludko
  • Leszek Swirski
  • Olivier Flückiger
Submit Requirements:
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: v8/v8
Gerrit-Branch: main
Gerrit-Change-Id: I49a3a8e39bce0cb14ee2c032f6f7ff4d769c227f
Gerrit-Change-Number: 7247865
Gerrit-PatchSet: 11
Gerrit-Owner: Caio Lima <caio...@igalia.com>
Gerrit-Reviewer: Caio Lima <caio...@igalia.com>
Gerrit-Reviewer: Igor Sheludko <ish...@chromium.org>
Gerrit-Reviewer: Leszek Swirski <les...@chromium.org>
Gerrit-Reviewer: Olivier Flückiger <ol...@chromium.org>
Gerrit-CC: Hannes Payer <hpa...@chromium.org>
Gerrit-CC: Nicolò Ribaudo <nrib...@igalia.com>
Gerrit-Attention: Igor Sheludko <ish...@chromium.org>
Gerrit-Attention: Olivier Flückiger <ol...@chromium.org>
Gerrit-Attention: Leszek Swirski <les...@chromium.org>
Gerrit-Comment-Date: Tue, 16 Dec 2025 17:19:12 +0000
unsatisfied_requirement
open
diffy
Reply all
Reply to author
Forward
0 new messages