New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.
Starred by 40 users
Status: Fixed
Owner:
Last visit > 30 days ago
Closed: Nov 2013
Cc:
HW: ----
NextAction: ----
OS: ----
Priority: 2
Type: FeatureRequest


Sign in to add a comment
Implement Object.observe
Project Member Reported by rossberg@chromium.org, Nov 14 2012 Back to list
Implement the Object.observe proposal for ES7 (http://wiki.ecmascript.org/doku.php?id=harmony:observe).
 
Cases working:

- named properties on plain objects
- arguments object (strict and non-strict)
- proxies
- value & date objects

Cases not fully working yet, or working incorrectly:

- indexed properties (spurious oldValue in some reconfiguration cases)
- nop reconfigurations of accessors (produces change record)
- "length" property on arrays (wrong change records in some reconfiguration cases)
- "prototype" property on function objects
- the global object
- typed arrays and array buffers ("length" and friend should not be observable)
- __proto__

Not tested yet:
- objects with interceptors
- objects with access checks
- other DOM-style objects

Open questions:
- Should change record layout be fully determined by "type" field?

Also not working:

Due to use of instance type checks instead of map checks in various places of V8 (especially optimised code), changes may not be picked up on code paths that have previously been executed with unobserved objects. This applies to array elements in particular.

Comment 3 by adamk@chromium.org, Nov 26 2012
Regarding access checks, a proposal from a quick discussion with abarth and rafaelw is to do an access check on observation, and disallow observation altogether if access is not allowed. The tricky part with that there's not a nice hook in the API for this right now: the two callbacks are NamedSecurityCheck and IndexedSecurityCheck, neither of which apply here (we don't have a specific property to check). As far as WebKit's use of these access checks go we could easily get away with passing some bogus value for the property name, but it's not clear to me what other users of this API might expect.
Comment 4 by adamk@chromium.org, Nov 29 2012
Some status on the "Not fully working" cases in #1, and some questions for rossberg:

> - indexed properties (spurious oldValue in some reconfiguration cases)
fixed in https://codereview.chromium.org/11414177/ (awaiting review)

> - the global object
fixed in https://codereview.chromium.org/11414094/ (awaiting review)

> - "prototype" property on function objects
> - __proto__
These two still need work.

> - "length" property on arrays (wrong change records in some reconfiguration cases)
This bug is still present. Not sure how big a deal it is: it simply sends more records than needed (two instead of one).

> - nop reconfigurations of accessors (produces change record)
I can't reproduce this, is it still a problem?

> - typed arrays and array buffers ("length" and friend should not be observable)
Is length even mutable? Do we have a test case that fails this requirement?
Update:

Cases working:
- named properties
- defineProperty
- __proto__
- arguments object (strict and non-strict)
- proxies
- value & date objects

Cases not fully working yet, or working incorrectly:
- indexed properties (assignment might not be recognised on previously used code paths)
- "length" property on arrays (two change records in some cases)
- "prototype" property on function objects (under review)
- the global object (not handling hidden prototypes yet)

Not tested yet:
- objects with hidden prototypes
- objects with interceptors
- objects with access checks
- other DOM-style objects

Open questions:
- Should change record layout be fully determined by "type" field?


(@Adam: nop reconfigurations are fixed, length and friends are indeed immutable, my mistake.)
Comment 6 by adamk@chromium.org, Dec 5 2012
The global object patch should be handling hidden prototypes, is it not?
No, unfortunately, hidden prototypes are a mechanism entirely separate from the global proxy thing, activated by the SetHiddenPrototype method in the API. They were introduced for additional hacks in the WebKit bindings. In Chrome, the observable global object actually consists of 4(!) objects at a time: the global proxy, the "real" global, and that has a hidden prototype; plus, the "real" global also is the hidden prototype of yet another object, the outer window. I honestly still don't understand why it has to be that complicated, but...
Comment 8 by adamk@chromium.org, Dec 6 2012
Oh, sorry, I was indeed confused by having too much knowledge of the WebKit side of things. This is indeed something that needs testing via the API.
Update:

Cases working:
- named & indexed properties
- plain assignment, compound assignment, in/decrement operators
- defineProperty
- "length" property on arrays
- "prototype" property on function objects
- arguments object (strict and non-strict)
- "__proto__" pseudo property
- proxies
- value & date objects
- ES intrinsics

Cases not fully working yet:
- the global object (not fully handling hidden prototypes yet)

Not tested yet:
- objects with interceptors
- objects with access checks
- other DOM-style objects

To be done:
- Modify spec of change records to be dependent on "type" field only

Blockedon: v8:2877
Blockedon: v8:2940
Blockedon: v8:2941
Blockedon: v8:2942
Blockedon: v8:2944
Blockedon: v8:2945
Blockedon: v8:2946
Blockedon: v8:2418
Blockedon: v8:2975
Status: Fixed
Labels: Priority-2
Sign in to add a comment