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

Side by Side Diff: test/mjsunit/regress/poly_count_operation.js

Issue 19528005: Fix wrong bailout id in polymorphic stores. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add test for precrement Created 7 years, 5 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
« no previous file with comments | « src/hydrogen.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
11 // with the distribution. 11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its 12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived 13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission. 14 // from this software without specific prior written permission.
15 // 15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 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. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 // Flags: --allow-natives-syntax 28 // Flags: --allow-natives-syntax
29 29
30 var non_const_true = true; 30 var o1 = {x:1};
31 var o2 = {};
32 var deopt = false;
31 33
32 function f(o) { 34 function f_mono(o) {
33 return (non_const_true && (o.val == null || false)); 35 return 5 + o.x++;
34 } 36 }
35 37
36 // Create an object with a constant function in another realm. 38 var to_deopt = f_mono;
37 var realm = Realm.create();
38 var realmObject = Realm.eval(realm, "function g() {}; var o = { val:g }; o;")
39 39
40 // Make the CompareNil IC in the function monomorphic. 40 var v = 1;
41 assertFalse(f(realmObject)); 41 var s = 0;
42 assertFalse(f(realmObject));
43 42
44 // Optimize the function containing the CompareNil IC. 43 Object.defineProperty(o2, "x",
45 %OptimizeFunctionOnNextCall(f); 44 {get:function() { return v; },
46 assertFalse(f(realmObject)); 45 set:function(new_v) {
titzer 2013/07/19 07:23:05 Do we need a version of this test that deopts on g
Toon Verwaest 2013/07/19 08:44:16 Although a bit convoluted perhaps, that's exactly
46 v = new_v;
47 s++;
48 if (deopt) {
49 deopt = false;
50 %DeoptimizeFunction(to_deopt);
51 }
52 }});
53
54 assertEquals(0, s);
55 assertEquals(6, f_mono(o2));
56 assertEquals(1, s);
57 assertEquals(7, f_mono(o2));
58 assertEquals(2, s);
59 %OptimizeFunctionOnNextCall(f_mono);
60 deopt = true;
61 assertEquals(8, f_mono(o2));
62 assertEquals(3, s);
63
64 function f_poly(o) {
65 return 5 + o.x++;
66 }
67
68 v = 1;
69 to_deopt = f_poly;
70
71 f_poly(o1);
72 f_poly(o1);
73 assertEquals(6, f_poly(o2));
74 assertEquals(4, s);
75 assertEquals(7, f_poly(o2));
76 assertEquals(5, s);
77 %OptimizeFunctionOnNextCall(f_poly);
78 deopt = true;
79 assertEquals(8, f_poly(o2));
80 assertEquals(6, s);
81
82 %OptimizeFunctionOnNextCall(f_poly);
83 v = undefined;
84 assertEquals(NaN, f_poly(o2));
85 assertEquals(7, s);
86
87 function f_pre(o) {
88 return 5 + ++o.x
89 }
90
91 v = 1;
92 to_deopt = f_pre;
93
94 f_pre(o1);
95 f_pre(o1);
96 assertEquals(7, f_pre(o2));
97 assertEquals(8, s);
98 assertEquals(8, f_pre(o2));
99 assertEquals(9, s);
100 %OptimizeFunctionOnNextCall(f_pre);
101 deopt = true;
102 assertEquals(9, f_pre(o2));
103 assertEquals(10, s);
104
105 %OptimizeFunctionOnNextCall(f_pre);
106 v = undefined;
107 assertEquals(NaN, f_pre(o2));
108 assertEquals(11, s);
OLDNEW
« no previous file with comments | « src/hydrogen.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698