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

Side by Side Diff: test/mjsunit/field-type-tracking.js

Issue 167303005: Track field types. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Support transitions in LookupResult. Created 6 years, 9 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
« src/property.h ('K') | « src/x64/stub-cache-x64.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 // Flags: --allow-natives-syntax --nostress-opt --track-field-types
29
30 (function() {
31 function A() {
32 this.a = "A";
33 }
34 function readA(x) {
35 return x.a;
36 }
37 var a = new A();
38 assertUnoptimized(readA);
39 readA(a); readA(a); readA(a);
40 %OptimizeFunctionOnNextCall(readA);
41 assertEquals(readA(a), "A");
42 assertOptimized(readA);
43
44 var b = new A();
45 b.b = "B";
46 assertEquals(readA(b), "A");
47 assertUnoptimized(readA);
48 %OptimizeFunctionOnNextCall(readA);
49 assertEquals(readA(a), "A");
50 assertOptimized(readA);
51 assertEquals(readA(a), "A");
52 assertEquals(readA(b), "A");
53 assertOptimized(readA);
54
55 function readAFromB(x) {
56 return x.a;
57 }
58 assertUnoptimized(readAFromB);
59 readAFromB(b); readAFromB(b); readAFromB(b);
60 %OptimizeFunctionOnNextCall(readAFromB);
61 assertEquals(readAFromB(b), "A");
62 assertOptimized(readAFromB);
63
64 var c = new A();
65 c.c = "C";
66 assertOptimized(readA);
67 assertOptimized(readAFromB);
68 c.a = [1];
69 assertUnoptimized(readA);
70 assertUnoptimized(readAFromB);
71 assertEquals(readA(a), "A");
72 assertEquals(readA(b), "A");
73 assertEquals(readA(c), [1]);
74 assertEquals(readAFromB(b), "A");
75
76 %OptimizeFunctionOnNextCall(readA);
77 assertEquals(readA(a), "A");
78 %OptimizeFunctionOnNextCall(readAFromB);
79 assertEquals(readAFromB(b), "A");
80 assertOptimized(readA);
81 a.a = [1];
82 assertEquals(readA(a), [1]);
83 assertEquals(readA(b), "A");
84 assertEquals(readA(c), [1]);
85 assertOptimized(readA);
86 b.a = [1];
87 assertEquals(readA(a), [1]);
88 assertEquals(readA(b), [1]);
89 assertEquals(readA(c), [1]);
90 assertOptimized(readA);
91 assertOptimized(readAFromB);
92 })();
93
94 (function() {
95 function A() { this.x = 0; }
96 A.prototype = {y: 20};
97 function B(o) { return o.a.y; }
98 function C() { this.a = new A(); }
99
100 B(new C());
101 B(new C());
102 %OptimizeFunctionOnNextCall(B);
103 var c = new C();
104 assertEquals(20, B(c));
105 assertOptimized(B);
106 c.a.y = 10;
107 assertEquals(10, B(c));
108 assertUnoptimized(B);
109
110 var c = new C();
111 %OptimizeFunctionOnNextCall(B);
112 assertEquals(20, B(c));
113 assertOptimized(B);
114 c.a.y = 30;
115 assertEquals(30, B(c));
116 assertOptimized(B);
117 })();
OLDNEW
« src/property.h ('K') | « src/x64/stub-cache-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698