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

Unified Diff: src/v8natives.js

Issue 12314081: Speed up non-interceptor case of Object.getOwnPropertyNames (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Simplify patch Created 7 years, 10 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 | « no previous file | test/cctest/test-api.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/v8natives.js
diff --git a/src/v8natives.js b/src/v8natives.js
index 3978e88685156e69ec1660f1ea76d2f8b845b3b9..8473dd15960c18255168d1e8ffc266c84748afa6 100644
--- a/src/v8natives.js
+++ b/src/v8natives.js
@@ -1018,9 +1018,13 @@ function ObjectGetOwnPropertyNames(obj) {
// Get the local element names.
var propertyNames = %GetLocalElementNames(obj);
+ for (var i = 0; i < propertyNames.length; ++i) {
+ propertyNames[i] = %_NumberToString(propertyNames[i]);
+ }
// Get names for indexed interceptor properties.
- if (%GetInterceptorInfo(obj) & 1) {
+ var interceptorInfo = %GetInterceptorInfo(obj);
+ if ((interceptorInfo & 1) != 0) {
var indexedInterceptorNames =
%GetIndexedInterceptorElementNames(obj);
if (indexedInterceptorNames) {
@@ -1034,8 +1038,7 @@ function ObjectGetOwnPropertyNames(obj) {
propertyNames = propertyNames.concat(%GetLocalPropertyNames(obj));
// Get names for named interceptor properties if any.
-
- if (%GetInterceptorInfo(obj) & 2) {
+ if ((interceptorInfo & 2) != 0) {
var namedInterceptorNames =
%GetNamedInterceptorPropertyNames(obj);
if (namedInterceptorNames) {
@@ -1043,21 +1046,24 @@ function ObjectGetOwnPropertyNames(obj) {
}
}
- // Property names are expected to be unique strings.
- var propertySet = { __proto__: null };
- var j = 0;
- for (var i = 0; i < propertyNames.length; ++i) {
- var name = ToString(propertyNames[i]);
- // We need to check for the exact property value since for intrinsic
- // properties like toString if(propertySet["toString"]) will always
- // succeed.
- if (propertySet[name] === true) {
- continue;
+ // Property names are expected to be unique strings,
+ // but interceptors can interfere with that assumption.
+ if (interceptorInfo != 0) {
+ var propertySet = { __proto__: null };
+ var j = 0;
+ for (var i = 0; i < propertyNames.length; ++i) {
+ var name = ToString(propertyNames[i]);
+ // We need to check for the exact property value since for intrinsic
+ // properties like toString if(propertySet["toString"]) will always
+ // succeed.
+ if (propertySet[name] === true) {
+ continue;
+ }
+ propertySet[name] = true;
+ propertyNames[j++] = name;
}
- propertySet[name] = true;
- propertyNames[j++] = name;
+ propertyNames.length = j;
}
- propertyNames.length = j;
return propertyNames;
}
« no previous file with comments | « no previous file | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698