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

Unified Diff: test/mjsunit/prototype-changes.js

Issue 1104813004: Lazily register prototype users (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebased (no conflicts) Created 5 years, 8 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 | « test/cctest/test-heap.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/prototype-changes.js
diff --git a/test/mjsunit/prototype-changes.js b/test/mjsunit/prototype-changes.js
new file mode 100644
index 0000000000000000000000000000000000000000..e7fcc7ee953238aa71f2cce6cdaf2b4f72f589c6
--- /dev/null
+++ b/test/mjsunit/prototype-changes.js
@@ -0,0 +1,56 @@
+// Copyright 2015 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
+
+function A() {
+ this.a = "a";
+}
+var a = new A();
+
+function B() {
+ this.b = "b";
+}
+B.prototype = a;
+
+function C() {
+ this.c = "c";
+}
+C.prototype = new B();
+
+var c = new C();
+
+function f(expected) {
+ var result = c.z;
+ assertEquals(expected, result);
+}
+f(undefined);
+f(undefined);
+%OptimizeFunctionOnNextCall(f);
+f(undefined);
+a.z = "z";
+f("z");
+f("z");
+
+// Test updating .__proto__ pointers.
+var p1 = {foo: 1.5};
+var p2 = {}; p2.__proto__ = p1;
+var p3 = {}; p3.__proto__ = p2;
+var o = {}; o.__proto__ = p3;
+
+for (var i = 0; i < 2; i++) o.foo; // Force registration.
+
+var p1a = {foo: 1.7};
+p2.__proto__ = p1a;
+
+function g(o, expected) {
+ var result = o.foo;
+ assertEquals(expected, result);
+}
+
+g(o, 1.7);
+g(o, 1.7);
+g(o, 1.7);
+Object.defineProperty(p1a, "foo", {get: function() { return "foo"}});
+g(o, "foo");
« no previous file with comments | « test/cctest/test-heap.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698