A few questions
1. Right now this handles interceptors using symbols. Is that even possible?
2. The spec has a shared internal function called GetOwnPropertyKeys (O, Type).
We could do the same and share more code but it would involve more runtime
branches.
3. The runtime function %GetLocalPropertyNames takes a boolean. true means only
strings and false means strings and symbols. I see that some mirroring functions
uses the latter. Would it be OK to change the runtime function to only include
symbols when passed false and change the mirrorring function? That would mean
that the ordering would change. Another option is to use a tri state (bitmask)
but that seems a bit of an overkill.
Thanks for reviewing
arv (Not doing code reviews)
Ouch, this leaks private symbols. Let me fix that.
https://codereview.chromium.org/108083005/diff/90001/src/runtime.cc
File src/runtime.cc (right):
https://codereview.chromium.org/108083005/diff/90001/src/runtime.cc#newcode5861
src/runtime.cc:5861: if ((key_type & Runtime::PROPERTY_KEY_SYMBOL) &&
On 2013/12/12 15:37:59, rossberg wrote:
> How about splitting PropertyAttributes SYMBOLIC filter into SYMBOLIC_PUBLIC
and
> SYMBOLIC_PRIVATE, so that you can avoid the filter post-processing altogether?
> (Except for interceptors of course, which you have to post-process anyway, but
> see below.)
>
> You would only need to refine a couple of places in objects.cc accordingly,
> namely Map::NumberOfDescribedProperties and JSObject::GetLocalPropertyNames,
and
> Dictionary<Shape, Key>::NumberOfElementsFilterAttributes.
I considered going down this route to handle string vs symbol but we currently
have 3 cases: strings, symbols and symbols+strings. If we also want to filter
out private symbols we need to add 2 bits to the bitmask.
I guess that is fine. I'll make the change and see what it looks like in the
end.
Looking quite good now, just two more comments. https://codereview.chromium.org/108083005/diff/130001/src/objects.cc File src/objects.cc (right): https://codereview.chromium.org/108083005/diff/130001/src/objects.cc#newcode5915 src/objects.cc:5915: if ...
LGTM
I'll try to land once the tree allows it (given the long line of CLs currently
waiting that may not happen before my vacation, though -- just in case you
wonder ;) ).
https://codereview.chromium.org/108083005/diff/130001/src/v8natives.js
File src/v8natives.js (right):
https://codereview.chromium.org/108083005/diff/130001/src/v8natives.js#newcod...
src/v8natives.js:1041: function FilterKeyNames(array, symbolsOnly) {
On 2013/12/18 18:07:12, arv wrote:
> On 2013/12/18 16:50:12, rossberg wrote:
> > Why can't we fold this into the loop at line 1108, and avoid duplicating the
> > work?
>
> Done.
>
> That would make more sense. And now I understand what you mean with your
> previous comment.
Yes, sorry if that was too cryptic.
https://codereview.chromium.org/108083005/diff/150001/src/objects.cc
File src/objects.cc (right):
https://codereview.chromium.org/108083005/diff/150001/src/objects.cc#newcode5915
src/objects.cc:5915: if ((filter & SYMBOLIC) && key->IsSymbol()) {
On 2013/12/18 18:10:02, arv wrote:
> One option here would be:
>
> if (filter & (SYMBOLIC | SYMBOLIC | STRING)) {
> bool is_symbol = key->IsSymbol();
>
> ...
> }
> return false;
I leave that up to you, I'm fine either way.
rossberg
Hm, I get plenty of assertion failures when running the test suite on a debug ...
Hm, I get plenty of assertion failures when running the test suite on a debug
build...
arv (Not doing code reviews)
PTAL Here are the issues that was causing debug failures. 1. I added an assert ...
6 years, 11 months ago
(2014-01-06 23:41:50 UTC)
#14
PTAL
Here are the issues that was causing debug failures.
1. I added an assert that the filter was within range. The fuzzer of course
tries random things outside this range.
2. A few tests still passed treu to %GetLocalPropertyNames
3. But strangest of all was that I had to move the definition of
ObjectGetOwnPropertySymbols into symbol.js. One of the asserts fail if we define
ObjectGetOwnPropertySymbols in v8Natives.js and install it in symbol.js.
rossberg
LGTM with small nits. (Next time please upload a suitable diff if you rebase. ;) ...
6 years, 11 months ago
(2014-01-09 12:01:27 UTC)
#15
Issue 108083005: ES6: Add Object.getOwnPropertySymbols
(Closed)
Created 7 years ago by arv (Not doing code reviews)
Modified 6 years, 11 months ago
Reviewers: rossberg
Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Comments: 41