Use per-subtype v8::CppHeapPointerTags for ScriptWrappables [chromium/src : main]

0 views
Skip to first unread message

Nate Chapin (Gerrit)

unread,
May 29, 2024, 7:45:01 PMMay 29
to Andrey Kosyakov, Chromium LUCI CQ, chromium...@chromium.org, Kentaro Hara, blink-revie...@chromium.org, blink-...@chromium.org, jbroma...@chromium.org, kinuko...@chromium.org, kouhe...@chromium.org, oilpan-rev...@chromium.org
Attention needed from Andrey Kosyakov

Nate Chapin added 6 comments

Patchset-level comments
File-level comment, Patchset 2 (Latest):
Nate Chapin . resolved

Early review request!

File third_party/blink/renderer/bindings/scripts/web_idl/async_iterator.py
Line 75, Patchset 2 (Latest): self.inherited = None
Nate Chapin . unresolved

Feels kinda bad to add all this boilerplate in all these places.

File third_party/blink/renderer/bindings/scripts/web_idl/idl_compiler.py
Line 613, Patchset 2 (Latest): new_interface.direct_deriveds = list(direct_derived_set)
Nate Chapin . unresolved

`direct_deriveds` could possible be a class member here - it doesn't need to be transferred from the IR to the final object.

Line 1115, Patchset 2 (Latest): next_tag = 256
Nate Chapin . unresolved

Should I base this from 0 and add each tag to some constexpr first tag number instead of hard coding a value here?

File third_party/blink/renderer/platform/bindings/wrapper_type_info.h
Line 203, Patchset 2 (Latest):
Nate Chapin . unresolved

Additional comments needed here.

Line 47, Patchset 2 (Latest):static constexpr v8::CppHeapPointerTag kDOMWrappersTag =
Nate Chapin . unresolved

Should I get rid of all usage of this in this CL? The users after this CL are the manual WrapperTypeInfo initializations.

Open in Gerrit

Related details

Attention is currently required from:
  • Andrey Kosyakov
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Ief0f230733f41cf3a008313348ea700588716136
Gerrit-Change-Number: 5581408
Gerrit-PatchSet: 2
Gerrit-Owner: Nate Chapin <jap...@chromium.org>
Gerrit-Reviewer: Andrey Kosyakov <ca...@chromium.org>
Gerrit-Reviewer: Nate Chapin <jap...@chromium.org>
Gerrit-CC: Kentaro Hara <har...@chromium.org>
Gerrit-Attention: Andrey Kosyakov <ca...@chromium.org>
Gerrit-Comment-Date: Wed, 29 May 2024 23:44:53 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Andrey Kosyakov (Gerrit)

unread,
May 29, 2024, 9:18:04 PMMay 29
to Nate Chapin, Chromium LUCI CQ, chromium...@chromium.org, Kentaro Hara, blink-revie...@chromium.org, blink-...@chromium.org, jbroma...@chromium.org, kinuko...@chromium.org, kouhe...@chromium.org, oilpan-rev...@chromium.org
Attention needed from Nate Chapin

Andrey Kosyakov added 11 comments

File third_party/blink/renderer/bindings/core/v8/local_window_proxy.cc
Line 132, Patchset 2 (Latest): window->GetWrapperTypeInfo());
Andrey Kosyakov . unresolved

Any reason we can't use static type info here as well?

File third_party/blink/renderer/bindings/core/v8/remote_window_proxy.cc
Line 79, Patchset 2 (Latest): window->GetWrapperTypeInfo());
Andrey Kosyakov . unresolved

ditto here, we know the static type, so let's take advantage of it?

File third_party/blink/renderer/bindings/scripts/web_idl/async_iterator.py
Line 75, Patchset 2 (Latest): self.inherited = None
Nate Chapin . unresolved

Feels kinda bad to add all this boilerplate in all these places.

Andrey Kosyakov

Would it make sense to introduce a superclass to take care of this?

Line 77, Patchset 2 (Latest): self.deriveds = []
Andrey Kosyakov . unresolved

plural of an adjective doesn't seem to work well in English :-) subclasses, perhaps, given you already use _subclass_ below?

File third_party/blink/renderer/bindings/scripts/web_idl/idl_compiler.py
Line 608, Patchset 2 (Latest): direct_derived_set = identifier_to_direct_derived_set.get(
Andrey Kosyakov . unresolved

either move down to the only usage, or just inline there?

Line 1109, Patchset 2 (Latest): new_ir.max_subclass_tag = next_tag + len(new_ir.deriveds)
Andrey Kosyakov . unresolved

I think the _Embedder Pointer Sandboxing_ design doc contemplated the idea of making all tags for derived interfaces to share common binary prefix with the base class, so that the tag check could be accomplished with something like `(tag && child_mask) == expected_tag`. I understand this is going to be a bit more cumbersome to produce, so perhaps can be considered for a follow-up? Basically, for every subtree we would need to round up the subtree size to the next power of two.

Line 1113, Patchset 2 (Latest): return next_tag
Andrey Kosyakov . unresolved

might be worth asserting we don't accidentally go beyond `max_subclass_tag` while processing children here.

Nate Chapin . resolved

Should I base this from 0 and add each tag to some constexpr first tag number instead of hard coding a value here?

Andrey Kosyakov

I think explicit numbers are totally fine.

File third_party/blink/renderer/platform/bindings/wrapper_type_info.h
Line 195, Patchset 2 (Latest):// The return value can be null if |wrapper| is a global proxy, which points to
Andrey Kosyakov . unresolved

nit: Just _The return value may be null_ and don't go into details? I assume it would as well be null if one calls this on a random v8::Object not (yet?) associated to a wrapper?

Line 188, Patchset 2 (Latest): const WrapperTypeInfo* wrapper_type_info) {
Andrey Kosyakov . unresolved
So, given that (1) we now require a specific type here (2) this is a tiny inlined wrapper and (3) in most cases this would be followed by a `ScriptWrappable::ToImpl<T>()` call (which doesn't add overhead), can we combine the two? I.e. just make this a template on the type being requested and return the type:
```
template<typename T> T* ToScriptWrappable()
requires std::derived_from<T, ScriptWrappable> {
return v8::Object::Unwrap<ScriptWrappable>(
isolate, wrapper,
v8::CppHeapPointerTagRange(T::GetStaticWrapperTypeInfo()->this_pointer_tag,
T::GetStaticWrapperTypeInfo()->max_subclass_pointer_tag))->ToImpl<T>();
}
```
? Basically, the idea is that if we ask callers go give us more, we could as well give them more :-)

I understand this won't work for some of the hand-crafted types, but perhaps we could at least consider an overload for "regular" types to reduce boilerplate?

Line 47, Patchset 2 (Latest):static constexpr v8::CppHeapPointerTag kDOMWrappersTag =
Nate Chapin . unresolved

Should I get rid of all usage of this in this CL? The users after this CL are the manual WrapperTypeInfo initializations.

Andrey Kosyakov

We should get rid of it eventually, but as long as this CL is landable without removing all usages, a follow-up is totally fine.

Open in Gerrit

Related details

Attention is currently required from:
  • Nate Chapin
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Ief0f230733f41cf3a008313348ea700588716136
Gerrit-Change-Number: 5581408
Gerrit-PatchSet: 2
Gerrit-Owner: Nate Chapin <jap...@chromium.org>
Gerrit-Reviewer: Andrey Kosyakov <ca...@chromium.org>
Gerrit-Reviewer: Nate Chapin <jap...@chromium.org>
Gerrit-CC: Kentaro Hara <har...@chromium.org>
Gerrit-Attention: Nate Chapin <jap...@chromium.org>
Gerrit-Comment-Date: Thu, 30 May 2024 01:17:52 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Nate Chapin <jap...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Michael Lippautz (Gerrit)

unread,
May 30, 2024, 3:13:02 AMMay 30
to Nate Chapin, Andrey Kosyakov, Chromium LUCI CQ, chromium...@chromium.org, Kentaro Hara, blink-revie...@chromium.org, blink-...@chromium.org, jbroma...@chromium.org, kinuko...@chromium.org, kouhe...@chromium.org, oilpan-rev...@chromium.org
Attention needed from Nate Chapin

Michael Lippautz added 2 comments

Patchset-level comments
Michael Lippautz . resolved

Cool!

File third_party/blink/renderer/platform/bindings/v8_interface_bridge.h
Line 29, Patchset 2 (Latest): static inline T* ToWrappableUnsafe(v8::Isolate* isolate,
Michael Lippautz . unresolved

This is the hottest method used in all the trampolines _and_ we know `V8T`. I think we should store the limits as compile-time constants there as well and use from here.

(I don't immediately see how we could do that for Wrap() as it doesn't refer to `V8T` anywhere.

Open in Gerrit

Related details

Attention is currently required from:
  • Nate Chapin
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Ief0f230733f41cf3a008313348ea700588716136
Gerrit-Change-Number: 5581408
Gerrit-PatchSet: 2
Gerrit-Owner: Nate Chapin <jap...@chromium.org>
Gerrit-Reviewer: Andrey Kosyakov <ca...@chromium.org>
Gerrit-Reviewer: Nate Chapin <jap...@chromium.org>
Gerrit-CC: Kentaro Hara <har...@chromium.org>
Gerrit-CC: Michael Lippautz <mlip...@chromium.org>
Gerrit-Attention: Nate Chapin <jap...@chromium.org>
Gerrit-Comment-Date: Thu, 30 May 2024 07:12:53 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Andrey Kosyakov (Gerrit)

unread,
May 30, 2024, 2:22:12 PMMay 30
to Nate Chapin, Michael Lippautz, Chromium LUCI CQ, chromium...@chromium.org, Kentaro Hara, blink-revie...@chromium.org, blink-...@chromium.org, jbroma...@chromium.org, kinuko...@chromium.org, kouhe...@chromium.org, oilpan-rev...@chromium.org
Attention needed from Michael Lippautz and Nate Chapin

Andrey Kosyakov added 1 comment

File third_party/blink/renderer/platform/bindings/v8_interface_bridge.h
Line 29, Patchset 2 (Latest): static inline T* ToWrappableUnsafe(v8::Isolate* isolate,
Michael Lippautz . unresolved

This is the hottest method used in all the trampolines _and_ we know `V8T`. I think we should store the limits as compile-time constants there as well and use from here.

(I don't immediately see how we could do that for Wrap() as it doesn't refer to `V8T` anywhere.

Andrey Kosyakov

I'm fairly confident compiler is already capable to apply relevant optimizations considering T::GetStaticWrapperTypeInfo() returns a const pointer to a static const structure and `ToScriptWrappable()` gets inlined. Like this: https://godbolt.org/z/bqh5sndT6

Open in Gerrit

Related details

Attention is currently required from:
  • Michael Lippautz
  • Nate Chapin
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Ief0f230733f41cf3a008313348ea700588716136
Gerrit-Change-Number: 5581408
Gerrit-PatchSet: 2
Gerrit-Owner: Nate Chapin <jap...@chromium.org>
Gerrit-Reviewer: Andrey Kosyakov <ca...@chromium.org>
Gerrit-Reviewer: Nate Chapin <jap...@chromium.org>
Gerrit-CC: Kentaro Hara <har...@chromium.org>
Gerrit-CC: Michael Lippautz <mlip...@chromium.org>
Gerrit-Attention: Nate Chapin <jap...@chromium.org>
Gerrit-Attention: Michael Lippautz <mlip...@chromium.org>
Gerrit-Comment-Date: Thu, 30 May 2024 18:21:59 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Michael Lippautz <mlip...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Michael Lippautz (Gerrit)

unread,
May 30, 2024, 4:31:49 PMMay 30
to Nate Chapin, Andrey Kosyakov, Chromium LUCI CQ, chromium...@chromium.org, Kentaro Hara, blink-revie...@chromium.org, blink-...@chromium.org, jbroma...@chromium.org, kinuko...@chromium.org, kouhe...@chromium.org, oilpan-rev...@chromium.org
Attention needed from Andrey Kosyakov and Nate Chapin

Michael Lippautz added 1 comment

File third_party/blink/renderer/platform/bindings/v8_interface_bridge.h
Line 29, Patchset 2 (Latest): static inline T* ToWrappableUnsafe(v8::Isolate* isolate,
Michael Lippautz . resolved

This is the hottest method used in all the trampolines _and_ we know `V8T`. I think we should store the limits as compile-time constants there as well and use from here.

(I don't immediately see how we could do that for Wrap() as it doesn't refer to `V8T` anywhere.

Andrey Kosyakov

I'm fairly confident compiler is already capable to apply relevant optimizations considering T::GetStaticWrapperTypeInfo() returns a const pointer to a static const structure and `ToScriptWrappable()` gets inlined. Like this: https://godbolt.org/z/bqh5sndT6

Michael Lippautz

Nice!

Please make sure our code works as the small snippet :)

Open in Gerrit

Related details

Attention is currently required from:
  • Andrey Kosyakov
  • Nate Chapin
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Ief0f230733f41cf3a008313348ea700588716136
Gerrit-Change-Number: 5581408
Gerrit-PatchSet: 2
Gerrit-Owner: Nate Chapin <jap...@chromium.org>
Gerrit-Reviewer: Andrey Kosyakov <ca...@chromium.org>
Gerrit-Reviewer: Nate Chapin <jap...@chromium.org>
Gerrit-CC: Kentaro Hara <har...@chromium.org>
Gerrit-CC: Michael Lippautz <mlip...@chromium.org>
Gerrit-Attention: Nate Chapin <jap...@chromium.org>
Gerrit-Attention: Andrey Kosyakov <ca...@chromium.org>
Gerrit-Comment-Date: Thu, 30 May 2024 20:31:37 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Andrey Kosyakov <ca...@chromium.org>
Comment-In-Reply-To: Michael Lippautz <mlip...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Andrey Kosyakov (Gerrit)

unread,
May 30, 2024, 4:33:48 PMMay 30
to Nate Chapin, Michael Lippautz, Chromium LUCI CQ, chromium...@chromium.org, Kentaro Hara, blink-revie...@chromium.org, blink-...@chromium.org, jbroma...@chromium.org, kinuko...@chromium.org, kouhe...@chromium.org, oilpan-rev...@chromium.org
Attention needed from Michael Lippautz and Nate Chapin

Andrey Kosyakov added 1 comment

File third_party/blink/renderer/platform/bindings/v8_interface_bridge.h
Line 29, Patchset 2 (Latest): static inline T* ToWrappableUnsafe(v8::Isolate* isolate,
Michael Lippautz . resolved

This is the hottest method used in all the trampolines _and_ we know `V8T`. I think we should store the limits as compile-time constants there as well and use from here.

(I don't immediately see how we could do that for Wrap() as it doesn't refer to `V8T` anywhere.

Andrey Kosyakov

I'm fairly confident compiler is already capable to apply relevant optimizations considering T::GetStaticWrapperTypeInfo() returns a const pointer to a static const structure and `ToScriptWrappable()` gets inlined. Like this: https://godbolt.org/z/bqh5sndT6

Michael Lippautz

Nice!

Please make sure our code works as the small snippet :)

Andrey Kosyakov

Sure, this needs to be verified, after all, static object being in a different translation unit may complicate things, though LTO should help.

Open in Gerrit

Related details

Attention is currently required from:
  • Michael Lippautz
  • Nate Chapin
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Ief0f230733f41cf3a008313348ea700588716136
Gerrit-Change-Number: 5581408
Gerrit-PatchSet: 2
Gerrit-Owner: Nate Chapin <jap...@chromium.org>
Gerrit-Reviewer: Andrey Kosyakov <ca...@chromium.org>
Gerrit-Reviewer: Nate Chapin <jap...@chromium.org>
Gerrit-CC: Kentaro Hara <har...@chromium.org>
Gerrit-CC: Michael Lippautz <mlip...@chromium.org>
Gerrit-Attention: Nate Chapin <jap...@chromium.org>
Gerrit-Attention: Michael Lippautz <mlip...@chromium.org>
Gerrit-Comment-Date: Thu, 30 May 2024 20:33:35 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Michael Lippautz <mlip...@chromium.org>
Comment-In-Reply-To: Andrey Kosyakov <ca...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Nate Chapin (Gerrit)

unread,
May 30, 2024, 7:49:04 PMMay 30
to Michael Lippautz, Andrey Kosyakov, Chromium LUCI CQ, chromium...@chromium.org, Kentaro Hara, blink-revie...@chromium.org, blink-...@chromium.org, jbroma...@chromium.org, kinuko...@chromium.org, kouhe...@chromium.org, oilpan-rev...@chromium.org
Attention needed from Andrey Kosyakov and Michael Lippautz

Nate Chapin added 13 comments

File third_party/blink/renderer/bindings/core/v8/local_window_proxy.cc
Line 132, Patchset 2: window->GetWrapperTypeInfo());
Andrey Kosyakov . resolved

Any reason we can't use static type info here as well?

Nate Chapin

Done

File third_party/blink/renderer/bindings/core/v8/remote_window_proxy.cc
Line 79, Patchset 2: window->GetWrapperTypeInfo());
Andrey Kosyakov . resolved

ditto here, we know the static type, so let's take advantage of it?

Nate Chapin

Done

File third_party/blink/renderer/bindings/scripts/web_idl/async_iterator.py
Line 75, Patchset 2: self.inherited = None
Nate Chapin . resolved

Feels kinda bad to add all this boilerplate in all these places.

Andrey Kosyakov

Would it make sense to introduce a superclass to take care of this?

Nate Chapin

Maybe, but it also looks like there's a lot of other duplicate logic. Maybe a larger cleanup pass would be appropritate.

Line 77, Patchset 2: self.deriveds = []
Andrey Kosyakov . resolved

plural of an adjective doesn't seem to work well in English :-) subclasses, perhaps, given you already use _subclass_ below?

Nate Chapin

Done

File third_party/blink/renderer/bindings/scripts/web_idl/idl_compiler.py
Line 608, Patchset 2: direct_derived_set = identifier_to_direct_derived_set.get(
Andrey Kosyakov . resolved

either move down to the only usage, or just inline there?

Nate Chapin

Done

Line 1109, Patchset 2: new_ir.max_subclass_tag = next_tag + len(new_ir.deriveds)
Andrey Kosyakov . resolved

I think the _Embedder Pointer Sandboxing_ design doc contemplated the idea of making all tags for derived interfaces to share common binary prefix with the base class, so that the tag check could be accomplished with something like `(tag && child_mask) == expected_tag`. I understand this is going to be a bit more cumbersome to produce, so perhaps can be considered for a follow-up? Basically, for every subtree we would need to round up the subtree size to the next power of two.

Nate Chapin

Based on what mlippautz said, it sounded like that was a nice-to-have, but not necessary for v1.

Line 1113, Patchset 2: return next_tag
Andrey Kosyakov . resolved

might be worth asserting we don't accidentally go beyond `max_subclass_tag` while processing children here.

Nate Chapin

Added `assert next_tag == new_ir.max_subclass_tag + 1`

File third_party/blink/renderer/platform/bindings/v8_interface_bridge.h
Line 29, Patchset 2: static inline T* ToWrappableUnsafe(v8::Isolate* isolate,
Michael Lippautz . unresolved

This is the hottest method used in all the trampolines _and_ we know `V8T`. I think we should store the limits as compile-time constants there as well and use from here.

(I don't immediately see how we could do that for Wrap() as it doesn't refer to `V8T` anywhere.

Nate Chapin

I only saw the OP when I started working on this, not the full thread, so I went ahead and added constexpr members to V8T. I'll keep them unless it's a binary bloat problem?

Line 29, Patchset 2: static inline T* ToWrappableUnsafe(v8::Isolate* isolate,
Michael Lippautz . unresolved

This is the hottest method used in all the trampolines _and_ we know `V8T`. I think we should store the limits as compile-time constants there as well and use from here.

(I don't immediately see how we could do that for Wrap() as it doesn't refer to `V8T` anywhere.

Nate Chapin

Yeah, `Wrap()` is not

File third_party/blink/renderer/platform/bindings/wrapper_type_info.h
Line 203, Patchset 2:
Nate Chapin . resolved

Additional comments needed here.

Nate Chapin

Done

Line 195, Patchset 2:// The return value can be null if |wrapper| is a global proxy, which points to
Andrey Kosyakov . resolved

nit: Just _The return value may be null_ and don't go into details? I assume it would as well be null if one calls this on a random v8::Object not (yet?) associated to a wrapper?

Nate Chapin

Done

Line 188, Patchset 2: const WrapperTypeInfo* wrapper_type_info) {
Andrey Kosyakov . unresolved
So, given that (1) we now require a specific type here (2) this is a tiny inlined wrapper and (3) in most cases this would be followed by a `ScriptWrappable::ToImpl<T>()` call (which doesn't add overhead), can we combine the two? I.e. just make this a template on the type being requested and return the type:
```
template<typename T> T* ToScriptWrappable()
requires std::derived_from<T, ScriptWrappable> {
return v8::Object::Unwrap<ScriptWrappable>(
isolate, wrapper,
v8::CppHeapPointerTagRange(T::GetStaticWrapperTypeInfo()->this_pointer_tag,
T::GetStaticWrapperTypeInfo()->max_subclass_pointer_tag))->ToImpl<T>();
}
```
? Basically, the idea is that if we ask callers go give us more, we could as well give them more :-)

I understand this won't work for some of the hand-crafted types, but perhaps we could at least consider an overload for "regular" types to reduce boilerplate?

Nate Chapin

I think this makes sense - would it be alright if I attempted it in a followup?

Line 47, Patchset 2:static constexpr v8::CppHeapPointerTag kDOMWrappersTag =
Nate Chapin . resolved

Should I get rid of all usage of this in this CL? The users after this CL are the manual WrapperTypeInfo initializations.

Andrey Kosyakov

We should get rid of it eventually, but as long as this CL is landable without removing all usages, a follow-up is totally fine.

Nate Chapin

Acknowledged

Open in Gerrit

Related details

Attention is currently required from:
  • Andrey Kosyakov
  • Michael Lippautz
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Ief0f230733f41cf3a008313348ea700588716136
Gerrit-Change-Number: 5581408
Gerrit-PatchSet: 3
Gerrit-Owner: Nate Chapin <jap...@chromium.org>
Gerrit-Reviewer: Andrey Kosyakov <ca...@chromium.org>
Gerrit-Reviewer: Nate Chapin <jap...@chromium.org>
Gerrit-CC: Kentaro Hara <har...@chromium.org>
Gerrit-CC: Michael Lippautz <mlip...@chromium.org>
Gerrit-Attention: Andrey Kosyakov <ca...@chromium.org>
Gerrit-Attention: Michael Lippautz <mlip...@chromium.org>
Gerrit-Comment-Date: Thu, 30 May 2024 23:48:54 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Nate Chapin <jap...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Michael Lippautz (Gerrit)

unread,
May 31, 2024, 10:11:42 AMMay 31
to Nate Chapin, Andrey Kosyakov, Chromium LUCI CQ, chromium...@chromium.org, Kentaro Hara, blink-revie...@chromium.org, blink-...@chromium.org, jbroma...@chromium.org, kinuko...@chromium.org, kouhe...@chromium.org, oilpan-rev...@chromium.org
Attention needed from Andrey Kosyakov and Nate Chapin

Michael Lippautz added 1 comment

File third_party/blink/renderer/platform/bindings/v8_interface_bridge.h
Line 29, Patchset 2: static inline T* ToWrappableUnsafe(v8::Isolate* isolate,
Michael Lippautz . unresolved

This is the hottest method used in all the trampolines _and_ we know `V8T`. I think we should store the limits as compile-time constants there as well and use from here.

(I don't immediately see how we could do that for Wrap() as it doesn't refer to `V8T` anywhere.

Nate Chapin

I only saw the OP when I started working on this, not the full thread, so I went ahead and added constexpr members to V8T. I'll keep them unless it's a binary bloat problem?

Michael Lippautz

Mhm, maybe we should keep it then as it's a bit easier to see that this is will not require a global load.

(Don't have a strong opinion though as we _should_ get the same performance)

Open in Gerrit

Related details

Attention is currently required from:
  • Andrey Kosyakov
  • Nate Chapin
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Ief0f230733f41cf3a008313348ea700588716136
Gerrit-Change-Number: 5581408
Gerrit-PatchSet: 3
Gerrit-Owner: Nate Chapin <jap...@chromium.org>
Gerrit-Reviewer: Andrey Kosyakov <ca...@chromium.org>
Gerrit-Reviewer: Nate Chapin <jap...@chromium.org>
Gerrit-CC: Kentaro Hara <har...@chromium.org>
Gerrit-CC: Michael Lippautz <mlip...@chromium.org>
Gerrit-Attention: Nate Chapin <jap...@chromium.org>
Gerrit-Attention: Andrey Kosyakov <ca...@chromium.org>
Gerrit-Comment-Date: Fri, 31 May 2024 14:11:31 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Nate Chapin <jap...@chromium.org>
Comment-In-Reply-To: Michael Lippautz <mlip...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Michael Lippautz (Gerrit)

unread,
Jun 4, 2024, 11:58:06 AMJun 4
to Nate Chapin, Andrey Kosyakov, Chromium LUCI CQ, chromium...@chromium.org, Kentaro Hara, blink-revie...@chromium.org, blink-...@chromium.org, jbroma...@chromium.org, kinuko...@chromium.org, kouhe...@chromium.org, oilpan-rev...@chromium.org
Attention needed from Andrey Kosyakov and Nate Chapin

Michael Lippautz added 3 comments

Commit Message
Line 7, Patchset 5 (Latest):Use per-subtype v8::CppHeapPointerTags for ScriptWrappables
Michael Lippautz . unresolved

nit: Can you add a short description?

Line 8, Patchset 5 (Latest):
Michael Lippautz . unresolved

I think we can add the tag to swallow the binary size regression as this work was escalated.

Line 11, Patchset 5 (Latest):
Michael Lippautz . unresolved

Can you run Speedometer3 on pinpoint m1 to check for any regressions?

Open in Gerrit

Related details

Attention is currently required from:
  • Andrey Kosyakov
  • Nate Chapin
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Ief0f230733f41cf3a008313348ea700588716136
Gerrit-Change-Number: 5581408
Gerrit-PatchSet: 5
Gerrit-Owner: Nate Chapin <jap...@chromium.org>
Gerrit-Reviewer: Andrey Kosyakov <ca...@chromium.org>
Gerrit-Reviewer: Nate Chapin <jap...@chromium.org>
Gerrit-CC: Kentaro Hara <har...@chromium.org>
Gerrit-CC: Michael Lippautz <mlip...@chromium.org>
Gerrit-Attention: Nate Chapin <jap...@chromium.org>
Gerrit-Attention: Andrey Kosyakov <ca...@chromium.org>
Gerrit-Comment-Date: Tue, 04 Jun 2024 15:57:54 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Nate Chapin (Gerrit)

unread,
Jun 5, 2024, 5:03:37 PMJun 5
to Samuel Groß, Michael Lippautz, Andrey Kosyakov, Chromium LUCI CQ, chromium...@chromium.org, Kentaro Hara, blink-revie...@chromium.org, blink-...@chromium.org, jbroma...@chromium.org, kinuko...@chromium.org, kouhe...@chromium.org, oilpan-rev...@chromium.org
Attention needed from Andrey Kosyakov and Michael Lippautz

Nate Chapin voted and added 6 comments

Votes added by Nate Chapin

Commit-Queue+1

6 comments

Commit Message
Line 7, Patchset 5:Use per-subtype v8::CppHeapPointerTags for ScriptWrappables
Michael Lippautz . resolved

nit: Can you add a short description?

Nate Chapin

Done

Line 8, Patchset 5:
Michael Lippautz . resolved

I think we can add the tag to swallow the binary size regression as this work was escalated.

Nate Chapin

Acknowledged

Michael Lippautz . unresolved

Can you run Speedometer3 on pinpoint m1 to check for any regressions?

Nate Chapin

Results in progress.

File third_party/blink/renderer/bindings/scripts/web_idl/idl_compiler.py
Line 613, Patchset 2: new_interface.direct_deriveds = list(direct_derived_set)
Nate Chapin . resolved

`direct_deriveds` could possible be a class member here - it doesn't need to be transferred from the IR to the final object.

Nate Chapin

Acknowledged

File third_party/blink/renderer/platform/bindings/v8_interface_bridge.h
Line 29, Patchset 2: static inline T* ToWrappableUnsafe(v8::Isolate* isolate,
Michael Lippautz . resolved

This is the hottest method used in all the trampolines _and_ we know `V8T`. I think we should store the limits as compile-time constants there as well and use from here.

(I don't immediately see how we could do that for Wrap() as it doesn't refer to `V8T` anywhere.

Nate Chapin

I only saw the OP when I started working on this, not the full thread, so I went ahead and added constexpr members to V8T. I'll keep them unless it's a binary bloat problem?

Michael Lippautz

Mhm, maybe we should keep it then as it's a bit easier to see that this is will not require a global load.

(Don't have a strong opinion though as we _should_ get the same performance)

Nate Chapin

Acknowledged

File third_party/blink/renderer/platform/bindings/wrapper_type_info.h
Line 188, Patchset 2: const WrapperTypeInfo* wrapper_type_info) {
Andrey Kosyakov . resolved
So, given that (1) we now require a specific type here (2) this is a tiny inlined wrapper and (3) in most cases this would be followed by a `ScriptWrappable::ToImpl<T>()` call (which doesn't add overhead), can we combine the two? I.e. just make this a template on the type being requested and return the type:
```
template<typename T> T* ToScriptWrappable()
requires std::derived_from<T, ScriptWrappable> {
return v8::Object::Unwrap<ScriptWrappable>(
isolate, wrapper,
v8::CppHeapPointerTagRange(T::GetStaticWrapperTypeInfo()->this_pointer_tag,
T::GetStaticWrapperTypeInfo()->max_subclass_pointer_tag))->ToImpl<T>();
}
```
? Basically, the idea is that if we ask callers go give us more, we could as well give them more :-)

I understand this won't work for some of the hand-crafted types, but perhaps we could at least consider an overload for "regular" types to reduce boilerplate?

Nate Chapin

I think this makes sense - would it be alright if I attempted it in a followup?

Nate Chapin

Added to this CL.

Open in Gerrit

Related details

Attention is currently required from:
  • Andrey Kosyakov
  • Michael Lippautz
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Ief0f230733f41cf3a008313348ea700588716136
Gerrit-Change-Number: 5581408
Gerrit-PatchSet: 9
Gerrit-Owner: Nate Chapin <jap...@chromium.org>
Gerrit-Reviewer: Andrey Kosyakov <ca...@chromium.org>
Gerrit-Reviewer: Nate Chapin <jap...@chromium.org>
Gerrit-CC: Kentaro Hara <har...@chromium.org>
Gerrit-CC: Michael Lippautz <mlip...@chromium.org>
Gerrit-CC: Samuel Groß <sa...@chromium.org>
Gerrit-Attention: Michael Lippautz <mlip...@chromium.org>
Gerrit-Attention: Andrey Kosyakov <ca...@chromium.org>
Gerrit-Comment-Date: Wed, 05 Jun 2024 21:03:28 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Nate Chapin <jap...@chromium.org>
Comment-In-Reply-To: Michael Lippautz <mlip...@chromium.org>
Comment-In-Reply-To: Andrey Kosyakov <ca...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

chromeperf@appspot.gserviceaccount.com (Gerrit)

unread,
Jun 5, 2024, 5:37:16 PMJun 5
to Nate Chapin, Samuel Groß, Michael Lippautz, Andrey Kosyakov, Chromium LUCI CQ, chromium...@chromium.org, Kentaro Hara, blink-revie...@chromium.org, blink-...@chromium.org, jbroma...@chromium.org, kinuko...@chromium.org, kouhe...@chromium.org, oilpan-rev...@chromium.org
Attention needed from Andrey Kosyakov, Michael Lippautz and Nate Chapin

Message from chrom...@appspot.gserviceaccount.com

Attention is currently required from:
  • Andrey Kosyakov
  • Michael Lippautz
  • Nate Chapin
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Ief0f230733f41cf3a008313348ea700588716136
Gerrit-Change-Number: 5581408
Gerrit-PatchSet: 9
Gerrit-Owner: Nate Chapin <jap...@chromium.org>
Gerrit-Reviewer: Andrey Kosyakov <ca...@chromium.org>
Gerrit-Reviewer: Nate Chapin <jap...@chromium.org>
Gerrit-CC: Kentaro Hara <har...@chromium.org>
Gerrit-CC: Michael Lippautz <mlip...@chromium.org>
Gerrit-CC: Samuel Groß <sa...@chromium.org>
Gerrit-Attention: Nate Chapin <jap...@chromium.org>
Gerrit-Attention: Michael Lippautz <mlip...@chromium.org>
Gerrit-Attention: Andrey Kosyakov <ca...@chromium.org>
Gerrit-Comment-Date: Wed, 05 Jun 2024 21:37:04 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

chromeperf@appspot.gserviceaccount.com (Gerrit)

unread,
Jun 5, 2024, 5:59:01 PMJun 5
to Nate Chapin, Samuel Groß, Michael Lippautz, Andrey Kosyakov, Chromium LUCI CQ, chromium...@chromium.org, Kentaro Hara, blink-revie...@chromium.org, blink-...@chromium.org, jbroma...@chromium.org, kinuko...@chromium.org, kouhe...@chromium.org, oilpan-rev...@chromium.org
Attention needed from Andrey Kosyakov, Michael Lippautz and Nate Chapin

Message from chrom...@appspot.gserviceaccount.com

Gerrit-Comment-Date: Wed, 05 Jun 2024 21:58:48 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Nate Chapin (Gerrit)

unread,
Jun 5, 2024, 6:28:49 PMJun 5
to chrom...@appspot.gserviceaccount.com, Samuel Groß, Michael Lippautz, Andrey Kosyakov, Chromium LUCI CQ, chromium...@chromium.org, Kentaro Hara, blink-revie...@chromium.org, blink-...@chromium.org, jbroma...@chromium.org, kinuko...@chromium.org, kouhe...@chromium.org, oilpan-rev...@chromium.org
Attention needed from Andrey Kosyakov and Michael Lippautz

Nate Chapin added 1 comment

Commit Message
Line 11, Patchset 5:
Michael Lippautz . resolved

Can you run Speedometer3 on pinpoint m1 to check for any regressions?

Nate Chapin

Results in progress.

Nate Chapin

linux shows a ~0.2% regression. m1 shows a ~0.4% improvement. Looks like a wash.

Open in Gerrit

Related details

Attention is currently required from:
  • Andrey Kosyakov
  • Michael Lippautz
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Review
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Ief0f230733f41cf3a008313348ea700588716136
Gerrit-Change-Number: 5581408
Gerrit-PatchSet: 9
Gerrit-Owner: Nate Chapin <jap...@chromium.org>
Gerrit-Reviewer: Andrey Kosyakov <ca...@chromium.org>
Gerrit-Reviewer: Nate Chapin <jap...@chromium.org>
Gerrit-CC: Kentaro Hara <har...@chromium.org>
Gerrit-CC: Michael Lippautz <mlip...@chromium.org>
Gerrit-CC: Samuel Groß <sa...@chromium.org>
Gerrit-Attention: Michael Lippautz <mlip...@chromium.org>
Gerrit-Attention: Andrey Kosyakov <ca...@chromium.org>
Gerrit-Comment-Date: Wed, 05 Jun 2024 22:28:39 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Andrey Kosyakov (Gerrit)

unread,
Jun 5, 2024, 8:49:50 PMJun 5
to Nate Chapin, Tricium, chrom...@appspot.gserviceaccount.com, Samuel Groß, Michael Lippautz, Chromium LUCI CQ, chromium...@chromium.org, Kentaro Hara, blink-revie...@chromium.org, blink-...@chromium.org, jbroma...@chromium.org, kinuko...@chromium.org, kouhe...@chromium.org, oilpan-rev...@chromium.org
Attention needed from Michael Lippautz and Nate Chapin

Andrey Kosyakov voted and added 6 comments

Votes added by Andrey Kosyakov

Code-Review+1

6 comments

Patchset-level comments
File-level comment, Patchset 11 (Latest):
Andrey Kosyakov . resolved

lgtm with a bunch of nits.

Also, we figured out (at lease one) source of code bloat: usage of leaf-type specific tag prevents deduplication in case when the same underlying C++ method is called for multiple generated bindings callbacks, for example in case of mix-ins that are implemented as a common subclass (consider {Element,DocumentFragment,Document}::children() that is actually ContainerNode::children()). arm32 builds do not incur this overhead presumably because v8 sandbox is off and the entire tags business get optimized away.

File third_party/blink/renderer/bindings/scripts/bind_gen/interface.py
Line 6299, Patchset 11 (Latest): public_def = SequenceNode()
Andrey Kosyakov . unresolved

nit: move down to first usage? Also, consider "public_def**s**".

Line 6313, Patchset 11 (Latest): static_cast<v8::CppHeapPointerTag>({});
Andrey Kosyakov . unresolved

nit: might be worth using {named} variables here, it may be difficult to track positional {} with a multi-line template.

File third_party/blink/renderer/bindings/scripts/web_idl/async_iterator.py
Line 79, Patchset 11 (Latest): self.max_subclass_tag = None
Andrey Kosyakov . unresolved

Any chance the tag allocation logic could live on the bind_gen side? Feels like it doesn't belong to the Web IDL world.

File third_party/blink/renderer/platform/bindings/observable_array.h
Line 200, Patchset 11 (Latest): static T* Unwrap(v8::Isolate* isolate, v8::Local<v8::Array> v8_proxy_target) {
Andrey Kosyakov . unresolved

nit: consider keeping a more specific name to avoid confusion with v8's `Unwrap()` and indicate it does a very different thing under the hood?

File third_party/blink/renderer/platform/bindings/script_wrappable.h
Line 200, Patchset 11 (Latest): ->template ToImpl<T>();
Andrey Kosyakov . unresolved

nit: I feel like this could be named differently from the overload below and don't do a ToImpl<T>() because it has no chance of knowing if tag_range corresponds to T. So how about making this one non-templated and returning a ScriptWrappable, and the one below using it and doing ToImpl<T>()?

Open in Gerrit

Related details

Attention is currently required from:
  • Michael Lippautz
  • Nate Chapin
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Ief0f230733f41cf3a008313348ea700588716136
Gerrit-Change-Number: 5581408
Gerrit-PatchSet: 11
Gerrit-Owner: Nate Chapin <jap...@chromium.org>
Gerrit-Reviewer: Andrey Kosyakov <ca...@chromium.org>
Gerrit-Reviewer: Nate Chapin <jap...@chromium.org>
Gerrit-CC: Kentaro Hara <har...@chromium.org>
Gerrit-CC: Michael Lippautz <mlip...@chromium.org>
Gerrit-CC: Samuel Groß <sa...@chromium.org>
Gerrit-Attention: Nate Chapin <jap...@chromium.org>
Gerrit-Attention: Michael Lippautz <mlip...@chromium.org>
Gerrit-Comment-Date: Thu, 06 Jun 2024 00:49:38 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Michael Lippautz (Gerrit)

unread,
Jun 6, 2024, 2:47:56 AMJun 6
to Nate Chapin, Andrey Kosyakov, Tricium, chrom...@appspot.gserviceaccount.com, Samuel Groß, Chromium LUCI CQ, chromium...@chromium.org, Kentaro Hara, blink-revie...@chromium.org, blink-...@chromium.org, jbroma...@chromium.org, kinuko...@chromium.org, kouhe...@chromium.org, oilpan-rev...@chromium.org
Attention needed from Nate Chapin

Michael Lippautz added 1 comment

Patchset-level comments
Andrey Kosyakov . resolved

lgtm with a bunch of nits.

Also, we figured out (at lease one) source of code bloat: usage of leaf-type specific tag prevents deduplication in case when the same underlying C++ method is called for multiple generated bindings callbacks, for example in case of mix-ins that are implemented as a common subclass (consider {Element,DocumentFragment,Document}::children() that is actually ContainerNode::children()). arm32 builds do not incur this overhead presumably because v8 sandbox is off and the entire tags business get optimized away.

Michael Lippautz

Yeah, I think we went from:

  • GetAlignedPointerFromInternalField() -> Wrap (slight improvement, IIRC)
  • tag - > tage range, but using a single tag (regression in V8)
  • Using tag range in this CL wthat prohibits a lot of aliasing (regression)

On arm32 it's indeed off (because the sandbox needs a lot of virtual address space).

I think the subclassing is workng as expected. It's unfortunate that these result in different implementations now but I guess it's also somewhat working as expected because we validate sub types.

Open in Gerrit

Related details

Attention is currently required from:
  • Nate Chapin
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Ief0f230733f41cf3a008313348ea700588716136
Gerrit-Change-Number: 5581408
Gerrit-PatchSet: 11
Gerrit-Owner: Nate Chapin <jap...@chromium.org>
Gerrit-Reviewer: Andrey Kosyakov <ca...@chromium.org>
Gerrit-Reviewer: Nate Chapin <jap...@chromium.org>
Gerrit-CC: Kentaro Hara <har...@chromium.org>
Gerrit-CC: Michael Lippautz <mlip...@chromium.org>
Gerrit-CC: Samuel Groß <sa...@chromium.org>
Gerrit-Attention: Nate Chapin <jap...@chromium.org>
Gerrit-Comment-Date: Thu, 06 Jun 2024 06:47:42 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Andrey Kosyakov <ca...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Nate Chapin (Gerrit)

unread,
Jun 6, 2024, 2:05:54 PMJun 6
to Andrey Kosyakov, Tricium, chrom...@appspot.gserviceaccount.com, Samuel Groß, Michael Lippautz, Chromium LUCI CQ, chromium...@chromium.org, Kentaro Hara, blink-revie...@chromium.org, blink-...@chromium.org, jbroma...@chromium.org, kinuko...@chromium.org, kouhe...@chromium.org, oilpan-rev...@chromium.org

Nate Chapin voted and added 5 comments

Votes added by Nate Chapin

Commit-Queue+2

5 comments

File third_party/blink/renderer/bindings/scripts/bind_gen/interface.py
Line 6299, Patchset 11: public_def = SequenceNode()
Andrey Kosyakov . resolved

nit: move down to first usage? Also, consider "public_def**s**".

Nate Chapin

Done

Line 6313, Patchset 11: static_cast<v8::CppHeapPointerTag>({});
Andrey Kosyakov . resolved

nit: might be worth using {named} variables here, it may be difficult to track positional {} with a multi-line template.

Nate Chapin

Done

File third_party/blink/renderer/bindings/scripts/web_idl/async_iterator.py
Line 79, Patchset 11: self.max_subclass_tag = None
Andrey Kosyakov . resolved

Any chance the tag allocation logic could live on the bind_gen side? Feels like it doesn't belong to the Web IDL world.

Nate Chapin

Possibly. I'll look into that on the followup

File third_party/blink/renderer/platform/bindings/observable_array.h
Line 200, Patchset 11: static T* Unwrap(v8::Isolate* isolate, v8::Local<v8::Array> v8_proxy_target) {
Andrey Kosyakov . resolved

nit: consider keeping a more specific name to avoid confusion with v8's `Unwrap()` and indicate it does a very different thing under the hood?

Nate Chapin

`ProxyTargetToObservableArray()`

File third_party/blink/renderer/platform/bindings/script_wrappable.h
Line 200, Patchset 11: ->template ToImpl<T>();
Andrey Kosyakov . resolved

nit: I feel like this could be named differently from the overload below and don't do a ToImpl<T>() because it has no chance of knowing if tag_range corresponds to T. So how about making this one non-templated and returning a ScriptWrappable, and the one below using it and doing ToImpl<T>()?

Nate Chapin

Inlined this variant into its two callsites: the other variant of `ToScriptWrappable`, and `ToWrappableUnsafe`.

Also updated the comment of `ToWrappableUnsafe` to note that it is no longer unsafe and should be renamed or removed.

Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement satisfiedCode-Review
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Ief0f230733f41cf3a008313348ea700588716136
Gerrit-Change-Number: 5581408
Gerrit-PatchSet: 12
Gerrit-Owner: Nate Chapin <jap...@chromium.org>
Gerrit-Reviewer: Andrey Kosyakov <ca...@chromium.org>
Gerrit-Reviewer: Nate Chapin <jap...@chromium.org>
Gerrit-CC: Kentaro Hara <har...@chromium.org>
Gerrit-CC: Michael Lippautz <mlip...@chromium.org>
Gerrit-CC: Samuel Groß <sa...@chromium.org>
Gerrit-Comment-Date: Thu, 06 Jun 2024 18:05:42 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Andrey Kosyakov <ca...@chromium.org>
satisfied_requirement
open
diffy

Chromium LUCI CQ (Gerrit)

unread,
Jun 6, 2024, 3:01:07 PMJun 6
to Nate Chapin, Andrey Kosyakov, Tricium, chrom...@appspot.gserviceaccount.com, Samuel Groß, Michael Lippautz, chromium...@chromium.org, Kentaro Hara, blink-revie...@chromium.org, blink-...@chromium.org, jbroma...@chromium.org, kinuko...@chromium.org, kouhe...@chromium.org, oilpan-rev...@chromium.org

Chromium LUCI CQ submitted the change with unreviewed changes

Unreviewed changes

11 is the latest approved patch-set.
The change was submitted with unreviewed changes in the following files:

```
The name of the file: third_party/blink/renderer/bindings/core/v8/observable_array_exotic_object_handler.h
Insertions: 2, Deletions: 2.

@@ -465,8 +465,8 @@
private:
static BackingListWrappable& ToWrappableOrDie(v8::Isolate* isolate,
v8::Local<v8::Array> target) {
- return *ObservableArrayExoticObject::Unwrap<BackingListWrappable>(isolate,
- target);
+ return *ObservableArrayExoticObject::ProxyTargetToObservableArray<
+ BackingListWrappable>(isolate, target);
}

// https://webidl.spec.whatwg.org/#observable-array-exotic-object-set-the-length
```
```
The name of the file: third_party/blink/renderer/platform/bindings/observable_array.h
Insertions: 2, Deletions: 1.

@@ -197,7 +197,8 @@
// Returns the backing list object extracted from the proxy target object
// of type JS Array.
template <typename T>
- static T* Unwrap(v8::Isolate* isolate, v8::Local<v8::Array> v8_proxy_target) {
+ static T* ProxyTargetToObservableArray(v8::Isolate* isolate,
+ v8::Local<v8::Array> v8_proxy_target) {
return ToScriptWrappable<T>(
isolate, GetBackingObjectFromProxyTarget(isolate, v8_proxy_target));
}
```
```
The name of the file: third_party/blink/renderer/bindings/scripts/bind_gen/interface.py
Insertions: 9, Deletions: 7.

@@ -6296,24 +6296,26 @@
F = FormatNode
class_like = cg_context.class_like

- public_def = SequenceNode()
func_def = CxxFuncDefNode(name=function_name,
arg_decls=[],
return_type="constexpr const WrapperTypeInfo*",
static=True)
func_def.set_base_template_vars(cg_context.template_bindings())
func_def.body.append(TextNode("return &wrapper_type_info_;"))
- public_def.append(func_def)

- public_def.append(
+ public_defs = SequenceNode()
+ public_defs.append(func_def)
+
+ public_defs.append(
TextNode("""\
static constexpr v8::CppHeapPointerTag kThisTag =
- static_cast<v8::CppHeapPointerTag>({});
+ static_cast<v8::CppHeapPointerTag>({this_tag});
static constexpr v8::CppHeapPointerTag kMaxSubclassTag =
- static_cast<v8::CppHeapPointerTag>({});
+ static_cast<v8::CppHeapPointerTag>({max_subclass_tag});
static constexpr v8::CppHeapPointerTagRange kTagRange =
v8::CppHeapPointerTagRange(kThisTag, kMaxSubclassTag);
-""".format(class_like.tag, class_like.max_subclass_tag)))
+""".format(this_tag=class_like.tag,
+ max_subclass_tag=class_like.max_subclass_tag)))

member_var_def = TextNode(
"static const WrapperTypeInfo wrapper_type_info_;")
@@ -6434,7 +6436,7 @@
if class_like.is_interface:
wrapper_type_info_def.append(F(pattern, blink_class=blink_class))

- return public_def, member_var_def, wrapper_type_info_def
+ return public_defs, member_var_def, wrapper_type_info_def


# ----------------------------------------------------------------------------
```
```
The name of the file: third_party/blink/renderer/platform/bindings/v8_interface_bridge.h
Insertions: 5, Deletions: 4.

@@ -23,12 +23,13 @@
: nullptr;
}

- // This method will cause a bad cast if called on an object of the wrong type.
- // For use only inside bindings/, and only when the type of the object is
- // absolutely certain.
+ // TODO(japhet): Now that v8::Object::Unwrap uses tag ranges to enforce
+ // type safety, this returns nullptr if types are mismatched. It is therefore
+ // no longer "unsafe", and should be renamed or merged with ToWrappable().
static inline T* ToWrappableUnsafe(v8::Isolate* isolate,
v8::Local<v8::Object> value) {
- return ToScriptWrappable<T>(isolate, value, V8T::kTagRange);
+ return v8::Object::Unwrap<ScriptWrappable>(isolate, value, V8T::kTagRange)
+ ->template ToImpl<T>();
}

static inline bool HasInstance(v8::Isolate* isolate,
```
```
The name of the file: third_party/blink/renderer/platform/bindings/script_wrappable.h
Insertions: 5, Deletions: 13.

@@ -193,21 +193,13 @@

template <typename T>

requires std::derived_from<T, ScriptWrappable>
-inline T* ToScriptWrappable(v8::Isolate* isolate,
- v8::Local<v8::Object> wrapper,
- v8::CppHeapPointerTagRange tag_range) {
- return v8::Object::Unwrap<ScriptWrappable>(isolate, wrapper, tag_range)
- ->template ToImpl<T>();
-}
-
-template <typename T>
- requires std::derived_from<T, ScriptWrappable>
T* ToScriptWrappable(v8::Isolate* isolate, v8::Local<v8::Object> wrapper) {
const WrapperTypeInfo* wrapper_type_info = T::GetStaticWrapperTypeInfo();
- return ToScriptWrappable<T>(
- isolate, wrapper,
- v8::CppHeapPointerTagRange(wrapper_type_info->this_tag,
- wrapper_type_info->max_subclass_tag));
+ return v8::Object::Unwrap<ScriptWrappable>(
+ isolate, wrapper,
+ v8::CppHeapPointerTagRange(wrapper_type_info->this_tag,
+ wrapper_type_info->max_subclass_tag))
+ ->template ToImpl<T>();
}

// Defines |GetWrapperTypeInfo| virtual method which returns the WrapperTypeInfo
```

Change information

Commit message:
Use per-subtype v8::CppHeapPointerTags for ScriptWrappables

v8 has recently introduced a scheme of specifying a tag when alling
v8::Object::Wrap and v8::Object::Unwrap to assert that pointers are
not having their types confused between wrapping and unwrapping.
Unwrapping takes a tag range rather than a single tag, in order to
support wrapping as a derived class but unwrapping as one of its
base classes.

This CL makes use of that scheme in the generated bindings for
ScriptWrappables. Types with inheritance are simply assigned a tag.
Inheritance trees are processed together, starting from the base
of the inheritance tree, and assigning tags in depth-first order.
Each class that acts as a base class therefore has a contiguous range
of all of its derived classes.
Bug: 342350850
Binary-Size: Regression is a tradeoff for a new security feature.
Fuchsia-Binary-Size: Regression is a tradeoff for a new security feature.
Change-Id: Ief0f230733f41cf3a008313348ea700588716136
Reviewed-by: Andrey Kosyakov <ca...@chromium.org>
Commit-Queue: Nate Chapin <jap...@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1311453}
Files:
  • M third_party/blink/renderer/bindings/core/v8/local_window_proxy.cc
  • M third_party/blink/renderer/bindings/core/v8/native_value_traits_buffer_sources.cc
  • M third_party/blink/renderer/bindings/core/v8/native_value_traits_impl.h
  • M third_party/blink/renderer/bindings/core/v8/observable_array_exotic_object_handler.h
  • M third_party/blink/renderer/bindings/core/v8/remote_window_proxy.cc
  • M third_party/blink/renderer/bindings/core/v8/script_function.cc
  • M third_party/blink/renderer/bindings/core/v8/serialization/v8_script_value_serializer.cc
  • M third_party/blink/renderer/bindings/core/v8/worker_or_worklet_script_controller.cc
  • M third_party/blink/renderer/bindings/modules/v8/v8_context_snapshot_impl.cc
  • M third_party/blink/renderer/bindings/scripts/bind_gen/interface.py
  • M third_party/blink/renderer/bindings/scripts/bind_gen/observable_array.py
  • M third_party/blink/renderer/bindings/scripts/web_idl/async_iterator.py
  • M third_party/blink/renderer/bindings/scripts/web_idl/callback_interface.py
  • M third_party/blink/renderer/bindings/scripts/web_idl/idl_compiler.py
  • M third_party/blink/renderer/bindings/scripts/web_idl/interface.py
  • M third_party/blink/renderer/bindings/scripts/web_idl/namespace.py
  • M third_party/blink/renderer/bindings/scripts/web_idl/sync_iterator.py
  • M third_party/blink/renderer/core/typed_arrays/dom_array_buffer.cc
  • M third_party/blink/renderer/core/typed_arrays/dom_array_buffer_view.cc
  • M third_party/blink/renderer/core/typed_arrays/dom_data_view.cc
  • M third_party/blink/renderer/core/typed_arrays/dom_shared_array_buffer.cc
  • M third_party/blink/renderer/core/typed_arrays/dom_typed_array.cc
  • M third_party/blink/renderer/core/url_pattern/url_pattern_test.cc
  • M third_party/blink/renderer/platform/bindings/frozen_array_base.cc
  • M third_party/blink/renderer/platform/bindings/observable_array.cc
  • M third_party/blink/renderer/platform/bindings/observable_array.h
  • M third_party/blink/renderer/platform/bindings/script_wrappable.h
  • M third_party/blink/renderer/platform/bindings/v8_dom_wrapper.h
  • M third_party/blink/renderer/platform/bindings/v8_interface_bridge.h
  • M third_party/blink/renderer/platform/bindings/wrapper_type_info.cc
  • M third_party/blink/renderer/platform/bindings/wrapper_type_info.h
  • M third_party/blink/renderer/platform/heap/thread_state.cc
Change size: L
Delta: 32 files changed, 300 insertions(+), 101 deletions(-)
Branch: refs/heads/main
Submit Requirements:
  • requirement satisfiedCode-Review: +1 by Andrey Kosyakov
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Ief0f230733f41cf3a008313348ea700588716136
Gerrit-Change-Number: 5581408
Gerrit-PatchSet: 13
Gerrit-Owner: Nate Chapin <jap...@chromium.org>
Gerrit-Reviewer: Andrey Kosyakov <ca...@chromium.org>
Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
Gerrit-Reviewer: Nate Chapin <jap...@chromium.org>
open
diffy
satisfied_requirement

luci-bisection@appspot.gserviceaccount.com (Gerrit)

unread,
Jun 7, 2024, 10:54:20 PMJun 7
to Nate Chapin, Chromium LUCI CQ, Andrey Kosyakov, Tricium, chrom...@appspot.gserviceaccount.com, Samuel Groß, Michael Lippautz, chromium...@chromium.org, Kentaro Hara, blink-revie...@chromium.org, blink-...@chromium.org, jbroma...@chromium.org, kinuko...@chromium.org, kouhe...@chromium.org, oilpan-rev...@chromium.org

Message from luci-bi...@appspot.gserviceaccount.com

LUCI Bisection has identified this change as the cause of a test failure. See the analysis: https://ci.chromium.org/ui/p/chromium/bisection/test-analysis/b/5765981147234304

Sample build with failed test: https://ci.chromium.org/b/8745818937287910289
Affected test(s):
[ninja://chrome/test:browser_tests/ActionAndBrowserActionAPITest.TestSetBadgeTextGlobalAndTab/All.0](https://ci.chromium.org/ui/test/chromium/ninja:%2F%2Fchrome%2Ftest:browser_tests%2FActionAndBrowserActionAPITest.TestSetBadgeTextGlobalAndTab%2FAll.0?q=VHash%3Addb4f966843f3bd4)
[ninja://chrome/test:browser_tests/BrowserCommandControllerBrowserTestRefreshOnly.ExecuteShowSyncSettings](https://ci.chromium.org/ui/test/chromium/ninja:%2F%2Fchrome%2Ftest:browser_tests%2FBrowserCommandControllerBrowserTestRefreshOnly.ExecuteShowSyncSettings?q=VHash%3Addb4f966843f3bd4)
[ninja://chrome/test:browser_tests/BrowserCommandControllerBrowserTestRefreshOnly.ShowTranslateStatusChromePage](https://ci.chromium.org/ui/test/chromium/ninja:%2F%2Fchrome%2Ftest:browser_tests%2FBrowserCommandControllerBrowserTestRefreshOnly.ShowTranslateStatusChromePage?q=VHash%3Addb4f966843f3bd4)
[ninja://chrome/test:browser_tests/BrowserNavigatorTest.NavigateFromDefaultToOptionsInSameTab](https://ci.chromium.org/ui/test/chromium/ninja:%2F%2Fchrome%2Ftest:browser_tests%2FBrowserNavigatorTest.NavigateFromDefaultToOptionsInSameTab?q=VHash%3Addb4f966843f3bd4)
[ninja://chrome/test:browser_tests/ChromeMimeHandlerViewTest.DataUrl](https://ci.chromium.org/ui/test/chromium/ninja:%2F%2Fchrome%2Ftest:browser_tests%2FChromeMimeHandlerViewTest.DataUrl?q=VHash%3Addb4f966843f3bd4)
and 94 more ...
A revert for this change was not created because the builder of the failed test(s) is not being watched by gardeners.

If this is a false positive, please report it at http://b.corp.google.com/createIssue?component=1199205&description=Analysis%3A+https%3A%2F%2Fci.chromium.org%2Fui%2Fp%2Fchromium%2Fbisection%2Ftest-analysis%2Fb%2F5765981147234304&format=PLAIN&priority=P3&title=Wrongly+blamed+https%3A%2F%2Fchromium-review.googlesource.com%2Fc%2Fchromium%2Fsrc%2F%2B%2F5581408&type=BUG

Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement satisfiedCode-Review
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Ief0f230733f41cf3a008313348ea700588716136
Gerrit-Change-Number: 5581408
Gerrit-PatchSet: 13
Gerrit-Owner: Nate Chapin <jap...@chromium.org>
Gerrit-Reviewer: Andrey Kosyakov <ca...@chromium.org>
Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
Gerrit-Reviewer: Nate Chapin <jap...@chromium.org>
Gerrit-CC: Kentaro Hara <har...@chromium.org>
Gerrit-CC: Michael Lippautz <mlip...@chromium.org>
Gerrit-CC: Samuel Groß <sa...@chromium.org>
Gerrit-Comment-Date: Sat, 08 Jun 2024 02:54:09 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: No
satisfied_requirement
open
diffy
Reply all
Reply to author
Forward
0 new messages