Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add getOwnPropertyDescriptor Proxy trap #1567

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

svaarala
Copy link
Owner

@svaarala svaarala commented Jun 15, 2017

Add minimal support for getOwnPropertyDescriptor Proxy trap to support virtualized enumeration.

Tasks:

  • Add Proxy passthrough for reading a descriptor when a getOwnPropertyDescriptor trap doesn't exist
  • Add Proxy passthrough for Object.defineProperty() and variants
  • Add getOwnPropertyDescriptor trap call, minimally to handling enumeration at least
  • Check propdesc call sites; especiall e_idx + a_idx assumptions
  • Test coverage for passthrough
  • Test coverage for trap call
  • Specific test for virtualized enumeration
  • Releases entry

@svaarala svaarala force-pushed the add-getownpropertydescriptor-proxy-trap branch from 2cc762b to a5fec8e Compare June 15, 2017 21:24
@svaarala
Copy link
Owner Author

svaarala commented Jun 15, 2017

One internal difficulty with this change is that most internals deal with duk_propdesc struct which provides property attributes, the property's storage location (if any), and borrowed references to get/set.

With the Proxy getOwnPropertyDescriptor call the borrowed get/set reference is a problem because the trap result is quite likely not reachable once it is popped (as expected by the current internal call sites).

So, for now, when getOwnPropertyDescriptor trap is invoked, I'm just checking and filling in only the property attributes and the value, and nothing else. This is enough for enumeration but not for other call sites.

@svaarala svaarala force-pushed the add-getownpropertydescriptor-proxy-trap branch from a5fec8e to 4f88883 Compare June 15, 2017 23:22
Very minimal implementations:

* getOwnPropertyDescriptor trap: works enough to support virtualization
  of enumeration, but doesn't provide 'value', 'get', or 'set'.

* defineProperty: just pass-through so far, no actual trap implementation.
Also add property descriptor print helpers and change a few test cases
to use them.
@svaarala svaarala force-pushed the add-getownpropertydescriptor-proxy-trap branch from 4f88883 to 6fc448e Compare November 29, 2017 22:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant