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

Unified Diff: src/debug/mirrors.js

Issue 1498593006: [proxies] Use JSReceiver::GetKeys() for more purposes (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years 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 | src/isolate.h » ('j') | src/objects.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/debug/mirrors.js
diff --git a/src/debug/mirrors.js b/src/debug/mirrors.js
index f205fed4fa5e4537b7d0da1049641e2135fa9750..24330899f1b42786d3a3ce9057e469415d44bcf9 100644
--- a/src/debug/mirrors.js
+++ b/src/debug/mirrors.js
@@ -239,11 +239,6 @@ function inherits(ctor, superCtor) {
// Maximum length when sending strings through the JSON protocol.
var kMaxProtocolStringLength = 80;
-// Different kind of properties.
-var PropertyKind = {};
-PropertyKind.Named = 1;
-PropertyKind.Indexed = 2;
-
// A copy of the PropertyType enum from property-details.h
var PropertyType = {};
@@ -750,19 +745,6 @@ ObjectMirror.prototype.hasIndexedInterceptor = function() {
};
-// Get all own property names except for private symbols.
-function TryGetPropertyNames(object) {
- try {
- // TODO(yangguo): Should there be a special debugger implementation of
- // %GetOwnPropertyNames that doesn't perform access checks?
- return %GetOwnPropertyNames(object, PROPERTY_ATTRIBUTES_PRIVATE_SYMBOL);
- } catch (e) {
- // Might have hit a failed access check.
- return [];
- }
-}
-
-
/**
* Return the property names for this object.
* @param {number} kind Indicate whether named, indexed or both kinds of
@@ -771,66 +753,8 @@ function TryGetPropertyNames(object) {
value
* @return {Array} Property names for this object
*/
-ObjectMirror.prototype.propertyNames = function(kind, limit) {
- // Find kind and limit and allocate array for the result
- kind = kind || PropertyKind.Named | PropertyKind.Indexed;
-
- var propertyNames;
- var elementNames;
- var total = 0;
-
- // Find all the named properties.
- if (kind & PropertyKind.Named) {
- propertyNames = TryGetPropertyNames(this.value_);
- total += propertyNames.length;
-
- // Get names for named interceptor properties if any.
- if (this.hasNamedInterceptor() && (kind & PropertyKind.Named)) {
- var namedInterceptorNames =
- %GetNamedInterceptorPropertyNames(this.value_);
- if (namedInterceptorNames) {
- propertyNames = propertyNames.concat(namedInterceptorNames);
- total += namedInterceptorNames.length;
- }
- }
- }
-
- // Find all the indexed properties.
- if (kind & PropertyKind.Indexed) {
- // Get own element names.
- elementNames = %GetOwnElementNames(this.value_);
- total += elementNames.length;
-
- // Get names for indexed interceptor properties.
- if (this.hasIndexedInterceptor() && (kind & PropertyKind.Indexed)) {
- var indexedInterceptorNames =
- %GetIndexedInterceptorElementNames(this.value_);
- if (indexedInterceptorNames) {
- elementNames = elementNames.concat(indexedInterceptorNames);
- total += indexedInterceptorNames.length;
- }
- }
- }
- limit = MathMin(limit || total, total);
-
- var names = new GlobalArray(limit);
- var index = 0;
-
- // Copy names for named properties.
- if (kind & PropertyKind.Named) {
- for (var i = 0; index < limit && i < propertyNames.length; i++) {
- names[index++] = propertyNames[i];
- }
- }
-
- // Copy names for indexed properties.
- if (kind & PropertyKind.Indexed) {
- for (var i = 0; index < limit && i < elementNames.length; i++) {
- names[index++] = elementNames[i];
- }
- }
-
- return names;
+ObjectMirror.prototype.propertyNames = function() {
+ return %GetOwnPropertyKeys(this.value_, PROPERTY_FILTER_NONE);
};
@@ -842,8 +766,8 @@ ObjectMirror.prototype.propertyNames = function(kind, limit) {
specified value
* @return {Array} Property mirrors for this object
*/
-ObjectMirror.prototype.properties = function(kind, limit) {
- var names = this.propertyNames(kind, limit);
+ObjectMirror.prototype.properties = function() {
+ var names = this.propertyNames();
var properties = new GlobalArray(names.length);
for (var i = 0; i < names.length; i++) {
properties[i] = this.property(names[i]);
@@ -887,7 +811,7 @@ ObjectMirror.prototype.lookupProperty = function(value) {
// Look for property value in properties.
for (var i = 0; i < properties.length; i++) {
- // Skip properties which are defined through assessors.
+ // Skip properties which are defined through accessors.
var property = properties[i];
if (property.propertyType() != PropertyType.AccessorConstant) {
if (%_ObjectEquals(property.value_, value.value_)) {
@@ -2883,24 +2807,15 @@ JSONProtocolSerializer.prototype.serializeObject_ = function(mirror, content,
}
// Add actual properties - named properties followed by indexed properties.
- var propertyNames = mirror.propertyNames(PropertyKind.Named);
- var propertyIndexes = mirror.propertyNames(PropertyKind.Indexed);
- var p = new GlobalArray(propertyNames.length + propertyIndexes.length);
- for (var i = 0; i < propertyNames.length; i++) {
- var propertyMirror = mirror.property(propertyNames[i]);
- p[i] = this.serializeProperty_(propertyMirror);
- if (details) {
- this.add_(propertyMirror.value());
- }
- }
- for (var i = 0; i < propertyIndexes.length; i++) {
- var propertyMirror = mirror.property(propertyIndexes[i]);
- p[propertyNames.length + i] = this.serializeProperty_(propertyMirror);
+ var properties = mirror.propertyNames();
+ for (var i = 0; i < properties.length; i++) {
+ var propertyMirror = mirror.property(properties[i]);
+ properties[i] = this.serializeProperty_(propertyMirror);
if (details) {
this.add_(propertyMirror.value());
}
}
- content.properties = p;
+ content.properties = properties;
var internalProperties = mirror.internalProperties();
if (internalProperties.length > 0) {
@@ -3098,7 +3013,6 @@ utils.InstallFunctions(global, DONT_ENUM, [
utils.InstallConstants(global, [
"ScopeType", ScopeType,
- "PropertyKind", PropertyKind,
"PropertyType", PropertyType,
"PropertyAttribute", PropertyAttribute,
"Mirror", Mirror,
« no previous file with comments | « no previous file | src/isolate.h » ('j') | src/objects.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698