Skip to content

fix(engine): don't cache a slot when the access changed the object's shape - #5601

Open
lehni wants to merge 1 commit into
boa-dev:mainfrom
lehni:fix/inline-cache-shape-change
Open

lehni wants to merge 1 commit into
boa-dev:mainfrom
lehni:fix/inline-cache-shape-change

Conversation

@lehni

@lehni lehni commented Oct 20, 2026

Copy link
Copy Markdown

On an inline cache miss, GetPropertyByName and SetPropertyByName call __get__ / __set__ and only afterwards read the object's shape to cache (shape, slot). If a prototype getter or setter defines an own property on the receiver, that shape is the new one, so it gets cached with the slot of the prototype accessor. Every later access at that site then hits the cache and calls the accessor again, instead of reading or writing the own property (#5600: the getter runs 3 times where V8 runs it once).

The fix reads the shape before the access and caches the slot only if the shape is unchanged: the slot was found in the old shape, so it isn't valid for the new one.

Tests: two regression tests in vm/inline_cache/tests.rs. A prototype getter that shadows itself runs once, and a prototype setter that shadows itself runs once, with later writes going to the own property. Both fail without the fix.

Note: GetNameGlobal has the same pattern, but the default global object has a unique shape, which gains properties in place without changing address, so a shape check can't see the change there. That's a separate issue with unique shapes and inline caches (it also shows without any accessor), left out of this PR.

Fixes #5600

…shape

On an inline cache miss, `GetPropertyByName` and `SetPropertyByName` cached the slot found by the lookup under the object's shape read after the get or set. A prototype getter or setter that defines an own property on the receiver changes that shape, so the new shape was cached with the prototype accessor's slot, and every later access at that site called the accessor again instead of reading or writing the own property.

The shape is now read before the access, and the slot is cached only if the shape is unchanged.

Fixes boa-dev#5600
@lehni
lehni requested a review from a team as a code owner October 20, 2026 02:29
@github-actions github-actions Bot added Waiting On Review Waiting on reviews from the maintainers C-Tests Issues and PRs related to the tests. C-VM Issues and PRs related to the Boa Virtual Machine. and removed Waiting On Review Waiting on reviews from the maintainers labels Oct 20, 2026
@github-actions github-actions Bot added this to the v0.23 milestone Oct 20, 2026
@github-actions

Copy link
Copy Markdown

Test262 conformance changes

Test result main count PR count difference
Total 53,578 53,578 0
Passed 51,450 51,450 0
Ignored 1,648 1,648 0
Failed 480 480 0
Panics 0 0 0
Conformance 96.03% 96.03% 0.00%

Tested main commit: 9871775a4999591e27bbb026b92530bf43caef52
Tested PR commit: 75a60abfac0f9296122eeda276bab62f0b0a26a9
Compare commits: 9871775...75a60ab

@codecov

codecov Bot commented Oct 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 63.08%. Comparing base (6ddc2b4) to head (75a60ab).
⚠️ Report is 1078 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #5601       +/-   ##
===========================================
+ Coverage   47.24%   63.08%   +15.83%     
===========================================
  Files         476      536       +60     
  Lines       46892    60538    +13646     
===========================================
+ Hits        22154    38189    +16035     
+ Misses      24738    22349     -2389     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

lehni added a commit to lehni/vectorcraft that referenced this pull request Oct 21, 2026
…oa#5600 (boa-dev/boa#5601), so the Boa engine keeps a move made right after an item reloaded; its test runs again

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-Tests Issues and PRs related to the tests. C-VM Issues and PRs related to the Boa Virtual Machine.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Property read keeps calling a prototype getter after the getter defines an own property

1 participant