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

Unified Diff: src/api.cc

Issue 2002203002: [api] Add more parameters to Object::GetPropertyNames (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@2016-05-06_keys_fast_path_1995263002
Patch Set: addressing nits Created 4 years, 7 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/v8.h ('k') | src/builtins.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index e5bcd24bd7b7ff4238a5266ea038d3d2ad9c68e0..1d78ab7f0a5767cc5e283b40938f9e590cd87c63 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -3867,15 +3867,27 @@ Local<Object> v8::Object::FindInstanceInPrototypeChain(
return Utils::ToLocal(i::handle(iter.GetCurrent<i::JSObject>(), isolate));
}
-
MaybeLocal<Array> v8::Object::GetPropertyNames(Local<Context> context) {
+ return GetPropertyNames(
+ context, v8::KeyCollectionMode::kIncludePrototypes,
+ static_cast<v8::PropertyFilter>(ONLY_ENUMERABLE | SKIP_SYMBOLS),
+ v8::IndexFilter::kIncludeIndices);
+}
+
+MaybeLocal<Array> v8::Object::GetPropertyNames(Local<Context> context,
+ KeyCollectionMode mode,
+ PropertyFilter property_filter,
+ IndexFilter index_filter) {
PREPARE_FOR_EXECUTION(context, Object, GetPropertyNames, Array);
auto self = Utils::OpenHandle(this);
i::Handle<i::FixedArray> value;
- has_pending_exception = !i::KeyAccumulator::GetKeys(self, i::INCLUDE_PROTOS,
- i::ENUMERABLE_STRINGS)
- .ToHandle(&value);
+ i::KeyAccumulator accumulator(
+ isolate, static_cast<i::KeyCollectionMode>(mode),
+ static_cast<i::PropertyFilter>(property_filter));
+ accumulator.set_skip_indices(index_filter == IndexFilter::kSkipIndices);
+ has_pending_exception = accumulator.CollectKeys(self, self).IsNothing();
RETURN_ON_FAILED_EXECUTION(Array);
+ value = accumulator.GetKeys(i::GetKeysConversion::kKeepNumbers);
DCHECK(self->map()->EnumLength() == i::kInvalidEnumCacheSentinel ||
self->map()->EnumLength() == 0 ||
self->map()->instance_descriptors()->GetEnumCache() != *value);
@@ -3901,19 +3913,8 @@ Local<Array> v8::Object::GetOwnPropertyNames() {
MaybeLocal<Array> v8::Object::GetOwnPropertyNames(Local<Context> context,
PropertyFilter filter) {
- PREPARE_FOR_EXECUTION(context, Object, GetOwnPropertyNames, Array);
- auto self = Utils::OpenHandle(this);
- i::Handle<i::FixedArray> value;
- has_pending_exception =
- !i::KeyAccumulator::GetKeys(self, i::OWN_ONLY,
- static_cast<i::PropertyFilter>(filter))
- .ToHandle(&value);
- RETURN_ON_FAILED_EXECUTION(Array);
- DCHECK(self->map()->EnumLength() == i::kInvalidEnumCacheSentinel ||
- self->map()->EnumLength() == 0 ||
- self->map()->instance_descriptors()->GetEnumCache() != *value);
- auto result = isolate->factory()->NewJSArrayWithElements(value);
- RETURN_ESCAPED(Utils::ToLocal(result));
+ return GetPropertyNames(context, KeyCollectionMode::kOwnOnly, filter,
+ v8::IndexFilter::kIncludeIndices);
}
MaybeLocal<String> v8::Object::ObjectProtoToString(Local<Context> context) {
« no previous file with comments | « include/v8.h ('k') | src/builtins.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698