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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | test/cctest/test-api.cc » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1000 matching lines...) Expand 10 before | Expand all | Expand 10 after
1011 if (%IsJSProxy(obj)) { 1011 if (%IsJSProxy(obj)) {
1012 var handler = %GetHandler(obj); 1012 var handler = %GetHandler(obj);
1013 var names = CallTrap0(handler, "getOwnPropertyNames", void 0); 1013 var names = CallTrap0(handler, "getOwnPropertyNames", void 0);
1014 return ToStringArray(names, "getOwnPropertyNames"); 1014 return ToStringArray(names, "getOwnPropertyNames");
1015 } 1015 }
1016 1016
1017 // Find all the indexed properties. 1017 // Find all the indexed properties.
1018 1018
1019 // Get the local element names. 1019 // Get the local element names.
1020 var propertyNames = %GetLocalElementNames(obj); 1020 var propertyNames = %GetLocalElementNames(obj);
1021 for (var i = 0; i < propertyNames.length; ++i) {
1022 propertyNames[i] = %_NumberToString(propertyNames[i]);
1023 }
1021 1024
1022 // Get names for indexed interceptor properties. 1025 // Get names for indexed interceptor properties.
1023 if (%GetInterceptorInfo(obj) & 1) { 1026 var interceptorInfo = %GetInterceptorInfo(obj);
1027 if ((interceptorInfo & 1) != 0) {
1024 var indexedInterceptorNames = 1028 var indexedInterceptorNames =
1025 %GetIndexedInterceptorElementNames(obj); 1029 %GetIndexedInterceptorElementNames(obj);
1026 if (indexedInterceptorNames) { 1030 if (indexedInterceptorNames) {
1027 propertyNames = propertyNames.concat(indexedInterceptorNames); 1031 propertyNames = propertyNames.concat(indexedInterceptorNames);
1028 } 1032 }
1029 } 1033 }
1030 1034
1031 // Find all the named properties. 1035 // Find all the named properties.
1032 1036
1033 // Get the local property names. 1037 // Get the local property names.
1034 propertyNames = propertyNames.concat(%GetLocalPropertyNames(obj)); 1038 propertyNames = propertyNames.concat(%GetLocalPropertyNames(obj));
1035 1039
1036 // Get names for named interceptor properties if any. 1040 // Get names for named interceptor properties if any.
1037 1041 if ((interceptorInfo & 2) != 0) {
1038 if (%GetInterceptorInfo(obj) & 2) {
1039 var namedInterceptorNames = 1042 var namedInterceptorNames =
1040 %GetNamedInterceptorPropertyNames(obj); 1043 %GetNamedInterceptorPropertyNames(obj);
1041 if (namedInterceptorNames) { 1044 if (namedInterceptorNames) {
1042 propertyNames = propertyNames.concat(namedInterceptorNames); 1045 propertyNames = propertyNames.concat(namedInterceptorNames);
1043 } 1046 }
1044 } 1047 }
1045 1048
1046 // Property names are expected to be unique strings. 1049 // Property names are expected to be unique strings,
1047 var propertySet = { __proto__: null }; 1050 // but interceptors can interfere with that assumption.
1048 var j = 0; 1051 if (interceptorInfo != 0) {
1049 for (var i = 0; i < propertyNames.length; ++i) { 1052 var propertySet = { __proto__: null };
1050 var name = ToString(propertyNames[i]); 1053 var j = 0;
1051 // We need to check for the exact property value since for intrinsic 1054 for (var i = 0; i < propertyNames.length; ++i) {
1052 // properties like toString if(propertySet["toString"]) will always 1055 var name = ToString(propertyNames[i]);
1053 // succeed. 1056 // We need to check for the exact property value since for intrinsic
1054 if (propertySet[name] === true) { 1057 // properties like toString if(propertySet["toString"]) will always
1055 continue; 1058 // succeed.
1059 if (propertySet[name] === true) {
1060 continue;
1061 }
1062 propertySet[name] = true;
1063 propertyNames[j++] = name;
1056 } 1064 }
1057 propertySet[name] = true; 1065 propertyNames.length = j;
1058 propertyNames[j++] = name;
1059 } 1066 }
1060 propertyNames.length = j;
1061 1067
1062 return propertyNames; 1068 return propertyNames;
1063 } 1069 }
1064 1070
1065 1071
1066 // ES5 section 15.2.3.5. 1072 // ES5 section 15.2.3.5.
1067 function ObjectCreate(proto, properties) { 1073 function ObjectCreate(proto, properties) {
1068 if (!IS_SPEC_OBJECT(proto) && proto !== null) { 1074 if (!IS_SPEC_OBJECT(proto) && proto !== null) {
1069 throw MakeTypeError("proto_object_or_null", [proto]); 1075 throw MakeTypeError("proto_object_or_null", [proto]);
1070 } 1076 }
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
1718 1724
1719 function SetUpFunction() { 1725 function SetUpFunction() {
1720 %CheckIsBootstrapping(); 1726 %CheckIsBootstrapping();
1721 InstallFunctions($Function.prototype, DONT_ENUM, $Array( 1727 InstallFunctions($Function.prototype, DONT_ENUM, $Array(
1722 "bind", FunctionBind, 1728 "bind", FunctionBind,
1723 "toString", FunctionToString 1729 "toString", FunctionToString
1724 )); 1730 ));
1725 } 1731 }
1726 1732
1727 SetUpFunction(); 1733 SetUpFunction();
OLDNEW
« 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