Repository navigation
runtime: P3 B2, class prototype reads return the materialized prototype; the JS-visible INT32-space prototype word is gone - #14358
Merged
Conversation
…tered class (its prototype object, never the word)
|
Caution Review failedThe pull request is closed.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
P3 B2: a
prototyperead on a class never returns the INT32-space prototype word. Design:/root/CHB/DESIGN-p3-canonical-numbers.md rev 3.1 §3 B2 (REVIEW-p3 R4, D3). It follows NANB (eb9ec0d, canonical NaN
at foreign-float boundaries, R1) and B1 (#14354).
What changes
prototyperead (object/field_get_set/get_field_by_name.rs): for a registered class, it is now alwaysclass_decl_prototype_value(class_id).!class_identity_has_surface,class_registry/state.rs:1559) readsundefined: the declaration path's ownanswer, decided at the read and never at class registration (D3). A registered id with no declaration still has
a prototype object, built on the read, which is unchanged.
0x7FFE | CLASS_PROTOTYPE_REF_FLAG | id, a JS-visible word in the INT32tag space. Top-16-only tests read it as the Number
id(REVIEW-p3 H4).GetPrototypeFromConstructor(class_registry/construct.rs new_target_custom_object_prototype): when the class'sdeclared prototype is not an object, it returns
None, so the default per-kind prototype applies, as the spec saysfor a non-object
newTarget.prototype. Before, it returned the same word.superand brand lookup (decl_prototype_birth.rs:181,symbol_members.rs:65,class_method_values.rs:42,class_ref_values.rs:202,state.rs:1418). It is read onlyby the runtime.
INTERNAL_WORD_TAGis B4b.class_method_values.rs:42builds a bound method whose receiver isclass_prototype_ref_value(owner), decoded atclosure/dispatch/bound.rs:39. So the ~60class_prototype_ref_iddecoders in JS-operation paths stay live untilthat producer changes, which is a separate decision. Nothing is materialized at registration, so there is
no startup work.
neither: class prototypes only, read path only. Its own-keys invariant holds here: a class prototype's own keys
are the declaration's (controls below).
Tests
object/field_get_set/undeclared_prototype_tests.rs:prototypeasundefined;class_decl_prototype_value).tests/parity/language/class/test_p3_b2_class_prototype.ts, compared with node. It covers:C.prototypeidentity, read before and after the firstnew;Object.getPrototypeOf(new C) === C.prototype;static x = this.prototype,static {});instanceof;definePropertyon the prototype, seen through instances;Reflect.constructwith a classnewTarget;getOwnPropertyNames,constructornot enumerable);+ 1as detectors: a misread INT32 word would show asnumber.runtime-p3-b2-class-prototype-word.md.Gates (qb9 x86-64; final head 3d4a2f5 = branch + main 43c5093; main artifacts built from 43c5093)
class_value_get_field−35,new_target_custom_object_prototype−11, nothing else. The first cut grew by 1152 B because the shrunknew_target_custom_object_prototypegot inlined into its three construct callers (+467, +404, +361). It is now#[inline(never)]: one out-of-line copytest_p3_b2_class_prototype.ts: main OK, B2 OKFiles
object/field_get_set/get_field_by_name.rs;object/class_registry/construct.rs;object/native_module/class_ref_values.rs(comment);object/field_get_set.rs(the test module declaration);object/field_get_set/undeclared_prototype_tests.rs(new).