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

Side by Side Diff: test/mjsunit/track-fields.js

Issue 14850006: Use mutable heapnumbers to store doubles in fields. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 7 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/stub-cache.cc ('K') | « test/cctest/test-heap-profiler.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
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 var of1 = {a:0}; 111 var of1 = {a:0};
112 of1.field = {}; 112 of1.field = {};
113 var of2 = {b:0}; 113 var of2 = {b:0};
114 of2.field = 10; 114 of2.field = 10;
115 115
116 poly_load(of1, false); 116 poly_load(of1, false);
117 poly_load(of1, false); 117 poly_load(of1, false);
118 poly_load(of2, true); 118 poly_load(of2, true);
119 %OptimizeFunctionOnNextCall(poly_load); 119 %OptimizeFunctionOnNextCall(poly_load);
120 assertEquals("[object Object]10", poly_load(of1, true)); 120 assertEquals("[object Object]10", poly_load(of1, true));
121
122 // Ensure small object literals with doubles do not share double storage.
123 function object_literal() { return {"a":1.5}; }
124 var o8 = object_literal();
125 var o9 = object_literal();
126 o8.a = 4.6
127 assertEquals(1.5, o9.a);
128
129 // Ensure double storage is not leaked in the case of polymorphic loads.
130 function load_poly(o) {
131 return o.a;
132 }
133
134 var o10 = { "a": 1.6 };
135 var o11 = { "b": 1, "a": 1.7 };
136 load_poly(o10);
137 load_poly(o10);
138 load_poly(o11);
139 %OptimizeFunctionOnNextCall(load_poly);
140 var val = load_poly(o10);
141 o10.a = 19.5;
142 assertFalse(o10.a == val);
143
144 // Ensure polymorphic loads only go monomorphic when the representations are
145 // compatible.
146
147 // Check polymorphic load from double + object fields.
148 function load_mono(o) {
149 return o.a1;
150 }
151
152 var object = {"x": 1};
153 var o10 = { "a1": 1.6 };
154 var o11 = { "a1": object, "b": 1 };
155 load_mono(o10);
156 load_mono(o10);
157 load_mono(o11);
158 %OptimizeFunctionOnNextCall(load_mono);
159 assertEquals(object, load_mono(o11));
160
161 // Check polymorphic load from smi + object fields.
162 function load_mono2(o) {
163 return o.a2;
164 }
165
166 var o12 = { "a2": 5 };
167 var o13 = { "a2": object, "b": 1 };
168 load_mono2(o12);
169 load_mono2(o12);
170 load_mono2(o13);
171 %OptimizeFunctionOnNextCall(load_mono2);
172 assertEquals(object, load_mono2(o13));
173
174 // Check polymorphic load from double + double fields.
175 function load_mono3(o) {
176 return o.a3;
177 }
178
179 var o14 = { "a3": 1.6 };
180 var o15 = { "a3": 1.8, "b": 1 };
181 load_mono3(o14);
182 load_mono3(o14);
183 load_mono3(o15);
184 %OptimizeFunctionOnNextCall(load_mono3);
185 assertEquals(1.6, load_mono3(o14));
186 assertEquals(1.8, load_mono3(o15));
OLDNEW
« src/stub-cache.cc ('K') | « test/cctest/test-heap-profiler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698