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

Side by Side Diff: test/cctest/compiler/test-run-inlining.cc

Issue 557253004: Switch inlining to use simplified instead of machine loads. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Drop obsolete local variable. Created 6 years, 3 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 | « test/cctest/cctest.status ('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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "test/cctest/compiler/function-tester.h" 7 #include "test/cctest/compiler/function-tester.h"
8 8
9 #if V8_TURBOFAN_TARGET 9 #if V8_TURBOFAN_TARGET
10 10
(...skipping 24 matching lines...) Expand all
35 } 35 }
36 36
37 37
38 TEST(SimpleInlining) { 38 TEST(SimpleInlining) {
39 FunctionTester T( 39 FunctionTester T(
40 "(function(){" 40 "(function(){"
41 "function foo(s) { AssertStackDepth(1); return s; };" 41 "function foo(s) { AssertStackDepth(1); return s; };"
42 "function bar(s, t) { return foo(s); };" 42 "function bar(s, t) { return foo(s); };"
43 "return bar;})();", 43 "return bar;})();",
44 CompilationInfo::kInliningEnabled | 44 CompilationInfo::kInliningEnabled |
45 CompilationInfo::kContextSpecializing); 45 CompilationInfo::kContextSpecializing |
46 CompilationInfo::kTypingEnabled);
46 47
47 InstallAssertStackDepthHelper(CcTest::isolate()); 48 InstallAssertStackDepthHelper(CcTest::isolate());
48 T.CheckCall(T.Val(1), T.Val(1), T.Val(2)); 49 T.CheckCall(T.Val(1), T.Val(1), T.Val(2));
49 } 50 }
50 51
51 52
52 TEST(SimpleInliningContext) { 53 TEST(SimpleInliningContext) {
53 FunctionTester T( 54 FunctionTester T(
54 "(function () {" 55 "(function () {"
55 "function foo(s) { AssertStackDepth(1); var x = 12; return s + x; };" 56 "function foo(s) { AssertStackDepth(1); var x = 12; return s + x; };"
56 "function bar(s, t) { return foo(s); };" 57 "function bar(s, t) { return foo(s); };"
57 "return bar;" 58 "return bar;"
58 "})();", 59 "})();",
59 CompilationInfo::kInliningEnabled | 60 CompilationInfo::kInliningEnabled |
60 CompilationInfo::kContextSpecializing); 61 CompilationInfo::kContextSpecializing |
62 CompilationInfo::kTypingEnabled);
61 63
62 InstallAssertStackDepthHelper(CcTest::isolate()); 64 InstallAssertStackDepthHelper(CcTest::isolate());
63 T.CheckCall(T.Val(13), T.Val(1), T.Val(2)); 65 T.CheckCall(T.Val(13), T.Val(1), T.Val(2));
64 } 66 }
65 67
66 68
67 TEST(CaptureContext) { 69 TEST(CaptureContext) {
68 FunctionTester T( 70 FunctionTester T(
69 "var f = (function () {" 71 "var f = (function () {"
70 "var x = 42;" 72 "var x = 42;"
71 "function bar(s) { return x + s; };" 73 "function bar(s) { return x + s; };"
72 "return (function (s) { return bar(s); });" 74 "return (function (s) { return bar(s); });"
73 "})();" 75 "})();"
74 "(function (s) { return f(s)})", 76 "(function (s) { return f(s)})",
75 CompilationInfo::kInliningEnabled | 77 CompilationInfo::kInliningEnabled |
76 CompilationInfo::kContextSpecializing); 78 CompilationInfo::kContextSpecializing |
79 CompilationInfo::kTypingEnabled);
77 80
78 InstallAssertStackDepthHelper(CcTest::isolate()); 81 InstallAssertStackDepthHelper(CcTest::isolate());
79 T.CheckCall(T.Val(42 + 12), T.Val(12), T.undefined()); 82 T.CheckCall(T.Val(42 + 12), T.Val(12), T.undefined());
80 } 83 }
81 84
82 85
83 // TODO(sigurds) For now we do not inline any native functions. If we do at 86 // TODO(sigurds) For now we do not inline any native functions. If we do at
84 // some point, change this test. 87 // some point, change this test.
85 TEST(DontInlineEval) { 88 TEST(DontInlineEval) {
86 FunctionTester T( 89 FunctionTester T(
87 "var x = 42;" 90 "var x = 42;"
88 "(function () {" 91 "(function () {"
89 "function bar(s, t) { return eval(\"AssertStackDepth(2); x\") };" 92 "function bar(s, t) { return eval(\"AssertStackDepth(2); x\") };"
90 "return bar;" 93 "return bar;"
91 "})();", 94 "})();",
92 CompilationInfo::kInliningEnabled | 95 CompilationInfo::kInliningEnabled |
93 CompilationInfo::kContextSpecializing); 96 CompilationInfo::kContextSpecializing |
97 CompilationInfo::kTypingEnabled);
94 98
95 InstallAssertStackDepthHelper(CcTest::isolate()); 99 InstallAssertStackDepthHelper(CcTest::isolate());
96 T.CheckCall(T.Val(42), T.Val("x"), T.undefined()); 100 T.CheckCall(T.Val(42), T.Val("x"), T.undefined());
97 } 101 }
98 102
99 103
100 TEST(InlineOmitArguments) { 104 TEST(InlineOmitArguments) {
101 FunctionTester T( 105 FunctionTester T(
102 "(function () {" 106 "(function () {"
103 "var x = 42;" 107 "var x = 42;"
104 "function bar(s, t, u, v) { AssertStackDepth(1); return x + s; };" 108 "function bar(s, t, u, v) { AssertStackDepth(1); return x + s; };"
105 "return (function (s,t) { return bar(s); });" 109 "return (function (s,t) { return bar(s); });"
106 "})();", 110 "})();",
107 CompilationInfo::kInliningEnabled | 111 CompilationInfo::kInliningEnabled |
108 CompilationInfo::kContextSpecializing); 112 CompilationInfo::kContextSpecializing |
113 CompilationInfo::kTypingEnabled);
109 114
110 InstallAssertStackDepthHelper(CcTest::isolate()); 115 InstallAssertStackDepthHelper(CcTest::isolate());
111 T.CheckCall(T.Val(42 + 12), T.Val(12), T.undefined()); 116 T.CheckCall(T.Val(42 + 12), T.Val(12), T.undefined());
112 } 117 }
113 118
114 119
115 TEST(InlineSurplusArguments) { 120 TEST(InlineSurplusArguments) {
116 FunctionTester T( 121 FunctionTester T(
117 "(function () {" 122 "(function () {"
118 "var x = 42;" 123 "var x = 42;"
119 "function foo(s) { AssertStackDepth(1); return x + s; };" 124 "function foo(s) { AssertStackDepth(1); return x + s; };"
120 "function bar(s,t) { return foo(s,t,13); };" 125 "function bar(s,t) { return foo(s,t,13); };"
121 "return bar;" 126 "return bar;"
122 "})();", 127 "})();",
123 CompilationInfo::kInliningEnabled | 128 CompilationInfo::kInliningEnabled |
124 CompilationInfo::kContextSpecializing); 129 CompilationInfo::kContextSpecializing |
130 CompilationInfo::kTypingEnabled);
125 131
126 InstallAssertStackDepthHelper(CcTest::isolate()); 132 InstallAssertStackDepthHelper(CcTest::isolate());
127 T.CheckCall(T.Val(42 + 12), T.Val(12), T.undefined()); 133 T.CheckCall(T.Val(42 + 12), T.Val(12), T.undefined());
128 } 134 }
129 135
130 136
131 TEST(InlineTwice) { 137 TEST(InlineTwice) {
132 FunctionTester T( 138 FunctionTester T(
133 "(function () {" 139 "(function () {"
134 "var x = 42;" 140 "var x = 42;"
135 "function bar(s) { AssertStackDepth(1); return x + s; };" 141 "function bar(s) { AssertStackDepth(1); return x + s; };"
136 "return (function (s,t) { return bar(s) + bar(t); });" 142 "return (function (s,t) { return bar(s) + bar(t); });"
137 "})();", 143 "})();",
138 CompilationInfo::kInliningEnabled | 144 CompilationInfo::kInliningEnabled |
139 CompilationInfo::kContextSpecializing); 145 CompilationInfo::kContextSpecializing |
146 CompilationInfo::kTypingEnabled);
140 147
141 InstallAssertStackDepthHelper(CcTest::isolate()); 148 InstallAssertStackDepthHelper(CcTest::isolate());
142 T.CheckCall(T.Val(2 * 42 + 12 + 4), T.Val(12), T.Val(4)); 149 T.CheckCall(T.Val(2 * 42 + 12 + 4), T.Val(12), T.Val(4));
143 } 150 }
144 151
145 152
146 TEST(InlineTwiceDependent) { 153 TEST(InlineTwiceDependent) {
147 FunctionTester T( 154 FunctionTester T(
148 "(function () {" 155 "(function () {"
149 "var x = 42;" 156 "var x = 42;"
150 "function foo(s) { AssertStackDepth(1); return x + s; };" 157 "function foo(s) { AssertStackDepth(1); return x + s; };"
151 "function bar(s,t) { return foo(foo(s)); };" 158 "function bar(s,t) { return foo(foo(s)); };"
152 "return bar;" 159 "return bar;"
153 "})();", 160 "})();",
154 CompilationInfo::kInliningEnabled | 161 CompilationInfo::kInliningEnabled |
155 CompilationInfo::kContextSpecializing); 162 CompilationInfo::kContextSpecializing |
163 CompilationInfo::kTypingEnabled);
156 164
157 InstallAssertStackDepthHelper(CcTest::isolate()); 165 InstallAssertStackDepthHelper(CcTest::isolate());
158 T.CheckCall(T.Val(42 + 42 + 12), T.Val(12), T.Val(4)); 166 T.CheckCall(T.Val(42 + 42 + 12), T.Val(12), T.Val(4));
159 } 167 }
160 168
161 169
162 TEST(InlineTwiceDependentDiamond) { 170 TEST(InlineTwiceDependentDiamond) {
163 FunctionTester T( 171 FunctionTester T(
164 "(function () {" 172 "(function () {"
165 "var x = 41;" 173 "var x = 41;"
166 "function foo(s) { AssertStackDepth(1); if (s % 2 == 0) {" 174 "function foo(s) { AssertStackDepth(1); if (s % 2 == 0) {"
167 " return x - s } else { return x + s; } };" 175 " return x - s } else { return x + s; } };"
168 "function bar(s,t) { return foo(foo(s)); };" 176 "function bar(s,t) { return foo(foo(s)); };"
169 "return bar;" 177 "return bar;"
170 "})();", 178 "})();",
171 CompilationInfo::kInliningEnabled | 179 CompilationInfo::kInliningEnabled |
172 CompilationInfo::kContextSpecializing); 180 CompilationInfo::kContextSpecializing |
181 CompilationInfo::kTypingEnabled);
173 182
174 InstallAssertStackDepthHelper(CcTest::isolate()); 183 InstallAssertStackDepthHelper(CcTest::isolate());
175 T.CheckCall(T.Val(-11), T.Val(11), T.Val(4)); 184 T.CheckCall(T.Val(-11), T.Val(11), T.Val(4));
176 } 185 }
177 186
178 187
179 TEST(InlineTwiceDependentDiamondDifferent) { 188 TEST(InlineTwiceDependentDiamondDifferent) {
180 FunctionTester T( 189 FunctionTester T(
181 "(function () {" 190 "(function () {"
182 "var x = 41;" 191 "var x = 41;"
183 "function foo(s,t) { AssertStackDepth(1); if (s % 2 == 0) {" 192 "function foo(s,t) { AssertStackDepth(1); if (s % 2 == 0) {"
184 " return x - s * t } else { return x + s * t; } };" 193 " return x - s * t } else { return x + s * t; } };"
185 "function bar(s,t) { return foo(foo(s, 3), 5); };" 194 "function bar(s,t) { return foo(foo(s, 3), 5); };"
186 "return bar;" 195 "return bar;"
187 "})();", 196 "})();",
188 CompilationInfo::kInliningEnabled | 197 CompilationInfo::kInliningEnabled |
189 CompilationInfo::kContextSpecializing); 198 CompilationInfo::kContextSpecializing |
199 CompilationInfo::kTypingEnabled);
190 200
191 InstallAssertStackDepthHelper(CcTest::isolate()); 201 InstallAssertStackDepthHelper(CcTest::isolate());
192 T.CheckCall(T.Val(-329), T.Val(11), T.Val(4)); 202 T.CheckCall(T.Val(-329), T.Val(11), T.Val(4));
193 } 203 }
194 204
195 205
196 TEST(InlineLoop) { 206 TEST(InlineLoop) {
197 FunctionTester T( 207 FunctionTester T(
198 "(function () {" 208 "(function () {"
199 "var x = 41;" 209 "var x = 41;"
200 "function foo(s) { AssertStackDepth(1); while (s > 0) {" 210 "function foo(s) { AssertStackDepth(1); while (s > 0) {"
201 " s = s - 1; }; return s; };" 211 " s = s - 1; }; return s; };"
202 "function bar(s,t) { return foo(foo(s)); };" 212 "function bar(s,t) { return foo(foo(s)); };"
203 "return bar;" 213 "return bar;"
204 "})();", 214 "})();",
205 CompilationInfo::kInliningEnabled | 215 CompilationInfo::kInliningEnabled |
206 CompilationInfo::kContextSpecializing); 216 CompilationInfo::kContextSpecializing |
217 CompilationInfo::kTypingEnabled);
207 218
208 InstallAssertStackDepthHelper(CcTest::isolate()); 219 InstallAssertStackDepthHelper(CcTest::isolate());
209 T.CheckCall(T.Val(0.0), T.Val(11), T.Val(4)); 220 T.CheckCall(T.Val(0.0), T.Val(11), T.Val(4));
210 } 221 }
211 222
212 223
213 TEST(InlineStrictIntoNonStrict) { 224 TEST(InlineStrictIntoNonStrict) {
214 FunctionTester T( 225 FunctionTester T(
215 "(function () {" 226 "(function () {"
216 "var x = Object.create({}, { y: { value:42, writable:false } });" 227 "var x = Object.create({}, { y: { value:42, writable:false } });"
217 "function foo(s) { 'use strict';" 228 "function foo(s) { 'use strict';"
218 " x.y = 9; };" 229 " x.y = 9; };"
219 "function bar(s,t) { return foo(s); };" 230 "function bar(s,t) { return foo(s); };"
220 "return bar;" 231 "return bar;"
221 "})();", 232 "})();",
222 CompilationInfo::kInliningEnabled | 233 CompilationInfo::kInliningEnabled |
223 CompilationInfo::kContextSpecializing); 234 CompilationInfo::kContextSpecializing |
235 CompilationInfo::kTypingEnabled);
224 236
225 InstallAssertStackDepthHelper(CcTest::isolate()); 237 InstallAssertStackDepthHelper(CcTest::isolate());
226 T.CheckThrows(T.undefined(), T.undefined()); 238 T.CheckThrows(T.undefined(), T.undefined());
227 } 239 }
228 240
229 241
230 TEST(InlineNonStrictIntoStrict) { 242 TEST(InlineNonStrictIntoStrict) {
231 FunctionTester T( 243 FunctionTester T(
232 "(function () {" 244 "(function () {"
233 "var x = Object.create({}, { y: { value:42, writable:false } });" 245 "var x = Object.create({}, { y: { value:42, writable:false } });"
234 "function foo(s) { x.y = 9; return x.y; };" 246 "function foo(s) { x.y = 9; return x.y; };"
235 "function bar(s,t) { \'use strict\'; return foo(s); };" 247 "function bar(s,t) { \'use strict\'; return foo(s); };"
236 "return bar;" 248 "return bar;"
237 "})();", 249 "})();",
238 CompilationInfo::kInliningEnabled | 250 CompilationInfo::kInliningEnabled |
239 CompilationInfo::kContextSpecializing); 251 CompilationInfo::kContextSpecializing |
252 CompilationInfo::kTypingEnabled);
240 253
241 InstallAssertStackDepthHelper(CcTest::isolate()); 254 InstallAssertStackDepthHelper(CcTest::isolate());
242 T.CheckCall(T.Val(42), T.undefined(), T.undefined()); 255 T.CheckCall(T.Val(42), T.undefined(), T.undefined());
243 } 256 }
244 257
245 258
246 #endif // V8_TURBOFAN_TARGET 259 #endif // V8_TURBOFAN_TARGET
OLDNEW
« no previous file with comments | « test/cctest/cctest.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698