Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(692)

Side by Side Diff: src/objects.cc

Issue 1405243006: [es6] Partially implement Reflect.ownKeys. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Reland 1405243006: [es6] Partially implement Reflect.ownKeys. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/objects.h ('k') | test/mjsunit/harmony/reflect.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/objects.h" 5 #include "src/objects.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <iomanip> 8 #include <iomanip>
9 #include <sstream> 9 #include <sstream>
10 10
(...skipping 7803 matching lines...) Expand 10 before | Expand all | Expand 10 after
7814 Handle<FixedArray> storage = isolate->factory()->NewFixedArray(length); 7814 Handle<FixedArray> storage = isolate->factory()->NewFixedArray(length);
7815 dictionary->CopyEnumKeysTo(*storage); 7815 dictionary->CopyEnumKeysTo(*storage);
7816 return storage; 7816 return storage;
7817 } 7817 }
7818 } 7818 }
7819 7819
7820 7820
7821 MaybeHandle<FixedArray> JSReceiver::GetKeys(Handle<JSReceiver> object, 7821 MaybeHandle<FixedArray> JSReceiver::GetKeys(Handle<JSReceiver> object,
7822 KeyCollectionType type, 7822 KeyCollectionType type,
7823 KeyFilter filter, 7823 KeyFilter filter,
7824 GetKeysConversion getConversion) { 7824 GetKeysConversion getConversion,
7825 Enumerability enum_policy) {
7825 USE(ContainsOnlyValidKeys); 7826 USE(ContainsOnlyValidKeys);
7826 Isolate* isolate = object->GetIsolate(); 7827 Isolate* isolate = object->GetIsolate();
7827 KeyAccumulator accumulator(isolate, filter); 7828 KeyAccumulator accumulator(isolate, filter);
7828 Handle<JSFunction> arguments_function( 7829 Handle<JSFunction> arguments_function(
7829 JSFunction::cast(isolate->sloppy_arguments_map()->GetConstructor())); 7830 JSFunction::cast(isolate->sloppy_arguments_map()->GetConstructor()));
7830 PrototypeIterator::WhereToEnd end = type == OWN_ONLY 7831 PrototypeIterator::WhereToEnd end = type == OWN_ONLY
7831 ? PrototypeIterator::END_AT_NON_HIDDEN 7832 ? PrototypeIterator::END_AT_NON_HIDDEN
7832 : PrototypeIterator::END_AT_NULL; 7833 : PrototypeIterator::END_AT_NULL;
7834 PropertyAttributes attr_filter = static_cast<PropertyAttributes>(
7835 (enum_policy == RESPECT_ENUMERABILITY ? DONT_ENUM : NONE) |
7836 PRIVATE_SYMBOL);
7837
7833 // Only collect keys if access is permitted. 7838 // Only collect keys if access is permitted.
7834 for (PrototypeIterator iter(isolate, object, 7839 for (PrototypeIterator iter(isolate, object,
7835 PrototypeIterator::START_AT_RECEIVER); 7840 PrototypeIterator::START_AT_RECEIVER);
7836 !iter.IsAtEnd(end); iter.Advance()) { 7841 !iter.IsAtEnd(end); iter.Advance()) {
7837 accumulator.NextPrototype(); 7842 accumulator.NextPrototype();
7838 if (PrototypeIterator::GetCurrent(iter)->IsJSProxy()) { 7843 if (PrototypeIterator::GetCurrent(iter)->IsJSProxy()) {
7839 Handle<JSProxy> proxy = PrototypeIterator::GetCurrent<JSProxy>(iter); 7844 Handle<JSProxy> proxy = PrototypeIterator::GetCurrent<JSProxy>(iter);
7840 Handle<Object> args[] = { proxy }; 7845 Handle<Object> args[] = { proxy };
7841 Handle<Object> names; 7846 Handle<Object> names;
7842 ASSIGN_RETURN_ON_EXCEPTION( 7847 ASSIGN_RETURN_ON_EXCEPTION(
(...skipping 13 matching lines...) Expand all
7856 // Check access rights if required. 7861 // Check access rights if required.
7857 if (current->IsAccessCheckNeeded() && 7862 if (current->IsAccessCheckNeeded() &&
7858 !isolate->MayAccess(handle(isolate->context()), current)) { 7863 !isolate->MayAccess(handle(isolate->context()), current)) {
7859 if (iter.IsAtEnd(PrototypeIterator::END_AT_NON_HIDDEN)) { 7864 if (iter.IsAtEnd(PrototypeIterator::END_AT_NON_HIDDEN)) {
7860 isolate->ReportFailedAccessCheck(current); 7865 isolate->ReportFailedAccessCheck(current);
7861 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, FixedArray); 7866 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, FixedArray);
7862 } 7867 }
7863 break; 7868 break;
7864 } 7869 }
7865 7870
7866 JSObject::CollectOwnElementKeys(current, &accumulator, 7871 JSObject::CollectOwnElementKeys(current, &accumulator, attr_filter);
7867 static_cast<PropertyAttributes>(DONT_ENUM));
7868 7872
7869 // Add the element keys from the interceptor. 7873 // Add the element keys from the interceptor.
7870 if (current->HasIndexedInterceptor()) { 7874 if (current->HasIndexedInterceptor()) {
7871 Handle<JSObject> result; 7875 Handle<JSObject> result;
7872 if (JSObject::GetKeysForIndexedInterceptor(current, object) 7876 if (JSObject::GetKeysForIndexedInterceptor(current, object)
7873 .ToHandle(&result)) { 7877 .ToHandle(&result)) {
7874 accumulator.AddElementKeysFromInterceptor(result); 7878 accumulator.AddElementKeysFromInterceptor(result);
7875 } 7879 }
7876 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, FixedArray); 7880 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, FixedArray);
7877 } 7881 }
7878 7882
7879 if (filter == SKIP_SYMBOLS) { 7883 if (filter == SKIP_SYMBOLS) {
7884 if (enum_policy == IGNORE_ENUMERABILITY) UNIMPLEMENTED();
7885
7880 // We can cache the computed property keys if access checks are 7886 // We can cache the computed property keys if access checks are
7881 // not needed and no interceptors are involved. 7887 // not needed and no interceptors are involved.
7882 // 7888 //
7883 // We do not use the cache if the object has elements and 7889 // We do not use the cache if the object has elements and
7884 // therefore it does not make sense to cache the property names 7890 // therefore it does not make sense to cache the property names
7885 // for arguments objects. Arguments objects will always have 7891 // for arguments objects. Arguments objects will always have
7886 // elements. 7892 // elements.
7887 // Wrapped strings have elements, but don't have an elements 7893 // Wrapped strings have elements, but don't have an elements
7888 // array or dictionary. So the fast inline test for whether to 7894 // array or dictionary. So the fast inline test for whether to
7889 // use the cache says yes, so we should not create a cache. 7895 // use the cache says yes, so we should not create a cache.
7890 bool cache_enum_length = 7896 bool cache_enum_length =
7891 ((current->map()->GetConstructor() != *arguments_function) && 7897 ((current->map()->GetConstructor() != *arguments_function) &&
7892 !current->IsJSValue() && !current->IsAccessCheckNeeded() && 7898 !current->IsJSValue() && !current->IsAccessCheckNeeded() &&
7893 !current->HasNamedInterceptor() && 7899 !current->HasNamedInterceptor() &&
7894 !current->HasIndexedInterceptor()); 7900 !current->HasIndexedInterceptor());
7895 // Compute the property keys and cache them if possible. 7901 // Compute the property keys and cache them if possible.
7896 Handle<FixedArray> enum_keys = 7902 Handle<FixedArray> enum_keys =
7897 JSObject::GetEnumPropertyKeys(current, cache_enum_length); 7903 JSObject::GetEnumPropertyKeys(current, cache_enum_length);
7898 accumulator.AddKeys(enum_keys); 7904 accumulator.AddKeys(enum_keys);
7899 } else { 7905 } else {
7900 DCHECK(filter == INCLUDE_SYMBOLS); 7906 DCHECK(filter == INCLUDE_SYMBOLS);
7901 PropertyAttributes attr_filter =
7902 static_cast<PropertyAttributes>(DONT_ENUM | PRIVATE_SYMBOL);
7903 current->CollectOwnPropertyNames(&accumulator, attr_filter); 7907 current->CollectOwnPropertyNames(&accumulator, attr_filter);
7904 } 7908 }
7905 7909
7906 // Add the property keys from the interceptor. 7910 // Add the property keys from the interceptor.
7907 if (current->HasNamedInterceptor()) { 7911 if (current->HasNamedInterceptor()) {
7908 Handle<JSObject> result; 7912 Handle<JSObject> result;
7909 if (JSObject::GetKeysForNamedInterceptor(current, object) 7913 if (JSObject::GetKeysForNamedInterceptor(current, object)
7910 .ToHandle(&result)) { 7914 .ToHandle(&result)) {
7911 accumulator.AddKeys(result); 7915 accumulator.AddKeys(result);
7912 } 7916 }
(...skipping 10210 matching lines...) Expand 10 before | Expand all | Expand 10 after
18123 if (cell->value() != *new_value) { 18127 if (cell->value() != *new_value) {
18124 cell->set_value(*new_value); 18128 cell->set_value(*new_value);
18125 Isolate* isolate = cell->GetIsolate(); 18129 Isolate* isolate = cell->GetIsolate();
18126 cell->dependent_code()->DeoptimizeDependentCodeGroup( 18130 cell->dependent_code()->DeoptimizeDependentCodeGroup(
18127 isolate, DependentCode::kPropertyCellChangedGroup); 18131 isolate, DependentCode::kPropertyCellChangedGroup);
18128 } 18132 }
18129 } 18133 }
18130 18134
18131 } // namespace internal 18135 } // namespace internal
18132 } // namespace v8 18136 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects.h ('k') | test/mjsunit/harmony/reflect.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698