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

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

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

Powered by Google App Engine
This is Rietveld 408576698