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

Unified Diff: src/v8natives.js

Issue 7631039: Use InternalArray in Object.defineProperties to avoid issues with overwriten properties on Array.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 4 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/mjsunit/regress/regress-1625.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/v8natives.js
===================================================================
--- src/v8natives.js (revision 8946)
+++ src/v8natives.js (working copy)
@@ -1015,25 +1015,30 @@
}
+function GetOwnPropertyNames(properties) {
Lasse Reichstein 2011/08/18 08:35:22 Put "Enuerable" in the name somewhere.
+ var names = new InternalArray();
+ for (var key in properties) {
Lasse Reichstein 2011/08/18 08:35:22 I was hoping there would be a way to get the own p
+ global.print("key: " + key);
Lasse Reichstein 2011/08/18 08:35:22 Without the prints? :)
+ if (%HasLocalProperty(properties, key)) {
+ global.print("key: " + key);
+ names.push(key);
+ }
+ }
+ return names;
+}
+
+
// ES5 section 15.2.3.7.
function ObjectDefineProperties(obj, properties) {
if (!IS_SPEC_OBJECT(obj))
throw MakeTypeError("obj_ctor_property_non_object", ["defineProperties"]);
var props = ToObject(properties);
- var key_values = [];
- for (var key in props) {
- if (%HasLocalProperty(props, key)) {
- key_values.push(key);
- var value = props[key];
- var desc = ToPropertyDescriptor(value);
- key_values.push(desc);
- }
+ var names = GetOwnPropertyNames(props);
+ for (var i = 0; i < names.length; i++) {
+ var name = names[i];
+ var desc = ToPropertyDescriptor(props[name]);
+ DefineOwnProperty(obj, name, desc, true);
}
- for (var i = 0; i < key_values.length; i += 2) {
- var key = key_values[i];
- var desc = key_values[i + 1];
- DefineOwnProperty(obj, key, desc, true);
- }
return obj;
}
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-1625.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698