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

Unified Diff: test/mjsunit/dictionary-properties.js

Issue 332783002: Optimize prototype chain when creating initial maps for functions used as constructors (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 6 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 | « src/objects.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/dictionary-properties.js
diff --git a/test/mjsunit/dictionary-properties.js b/test/mjsunit/dictionary-properties.js
new file mode 100644
index 0000000000000000000000000000000000000000..c70c598ac8cb617f7b0911a5964c1185c4f1b881
--- /dev/null
+++ b/test/mjsunit/dictionary-properties.js
@@ -0,0 +1,46 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Flags: --allow-natives-syntax
+
+// Test loading existent and nonexistent properties from dictionary
+// mode objects.
+
+function SlowObject() {
+ this.foo = 1;
+ this.bar = 2;
+ this.qux = 3;
+ delete this.qux;
+ assertFalse(%HasFastProperties(this));
+}
+function SlowObjectWithBaz() {
+ var o = new SlowObject();
+ o.baz = 4;
+ return o;
+}
+
+function Load(o) {
+ return o.baz;
+}
+
+for (var i = 0; i < 10; i++) {
+ var o1 = new SlowObject();
+ var o2 = SlowObjectWithBaz();
+ assertEquals(undefined, Load(o1));
+ assertEquals(4, Load(o2));
+}
+
+// Test objects getting optimized as fast prototypes.
+
+function SlowPrototype() {
+ this.foo = 1;
+}
+SlowPrototype.prototype.bar = 2;
+SlowPrototype.prototype.baz = 3;
+delete SlowPrototype.prototype.baz;
+
+assertFalse(%HasFastProperties(SlowPrototype.prototype));
+var fast_proto = new SlowPrototype();
+assertTrue(%HasFastProperties(SlowPrototype.prototype));
+assertTrue(%HasFastProperties(fast_proto.__proto__));
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698