Skip to content
This repository has been archived by the owner on Mar 25, 2018. It is now read-only.

Commit

Permalink
Merged: Squashed multiple commits.
Browse files Browse the repository at this point in the history
Merged: Add test for making private symbols non-enumerable
Revision: 942604d

Merged: Make private symbols non-enumerable
Revision: 135b9f9

BUG=chromium:664411,chromium:664411
LOG=N
NOTRY=true
NOPRESUBMIT=true
NOTREECHECKS=true
R=cbruni@chromium.org

Review URL: https://codereview.chromium.org/2498973002 .

Cr-Commit-Position: refs/branch-heads/5.5@{v8#40}
Cr-Branched-From: 3cbd583-refs/heads/5.5.372@{#1}
Cr-Branched-From: b3c8b0c-refs/heads/master@{#40015}
  • Loading branch information
verwaest committed Nov 14, 2016
1 parent 612f439 commit 551fc55
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/lookup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,11 @@ void LookupIterator::PrepareTransitionToDataProperty(
PropertyAttributes attributes, Object::StoreFromKeyed store_mode) {
DCHECK(receiver.is_identical_to(GetStoreTarget()));
if (state_ == TRANSITION) return;

if (!IsElement() && name()->IsPrivate()) {
attributes = static_cast<PropertyAttributes>(attributes | DONT_ENUM);
}

DCHECK(state_ != LookupIterator::ACCESSOR ||
(GetAccessors()->IsAccessorInfo() &&
AccessorInfo::cast(*GetAccessors())->is_special_data_property()));
Expand Down Expand Up @@ -441,6 +446,9 @@ void LookupIterator::TransitionToAccessorProperty(
// handled via a trap. Adding properties to primitive values is not
// observable.
Handle<JSObject> receiver = GetStoreTarget();
if (!IsElement() && name()->IsPrivate()) {
attributes = static_cast<PropertyAttributes>(attributes | DONT_ENUM);
}

if (!IsElement() && !receiver->map()->is_dictionary_map()) {
Handle<Map> old_map(receiver->map(), isolate_);
Expand Down
3 changes: 3 additions & 0 deletions src/property.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class Descriptor BASE_EMBEDDED {

void Init(Handle<Name> key, Handle<Object> value, PropertyDetails details) {
DCHECK(key->IsUniqueName());
DCHECK_IMPLIES(key->IsPrivate(), !details.IsEnumerable());
key_ = key;
value_ = value;
details_ = details;
Expand All @@ -44,6 +45,7 @@ class Descriptor BASE_EMBEDDED {
Descriptor(Handle<Name> key, Handle<Object> value, PropertyDetails details)
: key_(key), value_(value), details_(details) {
DCHECK(key->IsUniqueName());
DCHECK_IMPLIES(key->IsPrivate(), !details_.IsEnumerable());
}

Descriptor(Handle<Name> key, Handle<Object> value,
Expand All @@ -53,6 +55,7 @@ class Descriptor BASE_EMBEDDED {
value_(value),
details_(attributes, type, representation, field_index) {
DCHECK(key->IsUniqueName());
DCHECK_IMPLIES(key->IsPrivate(), !details_.IsEnumerable());
}

friend class DescriptorArray;
Expand Down
4 changes: 2 additions & 2 deletions test/mjsunit/harmony/private.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,8 @@ function TestKeyDescriptor(obj) {
assertEquals(i|0, desc.value)
assertTrue(desc.configurable)
assertEquals(i % 2 == 0, desc.writable)
assertEquals(i % 2 == 0, desc.enumerable)
assertEquals(i % 2 == 0,
assertEquals(false, desc.enumerable)
assertEquals(false,
Object.prototype.propertyIsEnumerable.call(obj, symbols[i]))
}
}
Expand Down
8 changes: 8 additions & 0 deletions test/mjsunit/regress/regress-private-enumerable.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

class A {}
class B {}
Object.assign(B, A);
assertEquals("class B {}", B.toString());

0 comments on commit 551fc55

Please sign in to comment.