OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 // TODO(jochen): Remove this after the setting is turned on globally. |
| 29 #define V8_IMMINENT_DEPRECATION_WARNINGS |
| 30 |
28 #include <stdlib.h> | 31 #include <stdlib.h> |
29 | 32 |
30 #include "src/v8.h" | 33 #include "src/v8.h" |
31 | 34 |
32 #include "src/api.h" | 35 #include "src/api.h" |
33 #include "src/base/platform/platform.h" | 36 #include "src/base/platform/platform.h" |
34 #include "src/compilation-cache.h" | 37 #include "src/compilation-cache.h" |
35 #include "src/debug/debug.h" | 38 #include "src/debug/debug.h" |
36 #include "src/deoptimizer.h" | 39 #include "src/deoptimizer.h" |
37 #include "src/isolate.h" | 40 #include "src/isolate.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 }; | 109 }; |
107 | 110 |
108 | 111 |
109 // Abort any ongoing incremental marking to make sure that all weak global | 112 // Abort any ongoing incremental marking to make sure that all weak global |
110 // handle callbacks are processed. | 113 // handle callbacks are processed. |
111 static void NonIncrementalGC(i::Isolate* isolate) { | 114 static void NonIncrementalGC(i::Isolate* isolate) { |
112 isolate->heap()->CollectAllGarbage(); | 115 isolate->heap()->CollectAllGarbage(); |
113 } | 116 } |
114 | 117 |
115 | 118 |
116 static Handle<JSFunction> GetJSFunction(v8::Handle<v8::Object> obj, | 119 static Handle<JSFunction> GetJSFunction(v8::Local<v8::Context> context, |
117 const char* property_name) { | 120 const char* property_name) { |
118 v8::Local<v8::Function> fun = | 121 v8::Local<v8::Function> fun = v8::Local<v8::Function>::Cast( |
119 v8::Local<v8::Function>::Cast(obj->Get(v8_str(property_name))); | 122 context->Global()->Get(context, v8_str(property_name)).ToLocalChecked()); |
120 return i::Handle<i::JSFunction>::cast(v8::Utils::OpenHandle(*fun)); | 123 return i::Handle<i::JSFunction>::cast(v8::Utils::OpenHandle(*fun)); |
121 } | 124 } |
122 | 125 |
123 | 126 |
124 TEST(DeoptimizeSimple) { | 127 TEST(DeoptimizeSimple) { |
125 LocalContext env; | 128 LocalContext env; |
126 v8::HandleScope scope(env->GetIsolate()); | 129 v8::HandleScope scope(env->GetIsolate()); |
127 | 130 |
128 // Test lazy deoptimization of a simple function. | 131 // Test lazy deoptimization of a simple function. |
129 { | 132 { |
130 AlwaysOptimizeAllowNativesSyntaxNoInlining options; | 133 AlwaysOptimizeAllowNativesSyntaxNoInlining options; |
131 CompileRun( | 134 CompileRun( |
132 "var count = 0;" | 135 "var count = 0;" |
133 "function h() { %DeoptimizeFunction(f); }" | 136 "function h() { %DeoptimizeFunction(f); }" |
134 "function g() { count++; h(); }" | 137 "function g() { count++; h(); }" |
135 "function f() { g(); };" | 138 "function f() { g(); };" |
136 "f();"); | 139 "f();"); |
137 } | 140 } |
138 NonIncrementalGC(CcTest::i_isolate()); | 141 NonIncrementalGC(CcTest::i_isolate()); |
139 | 142 |
140 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); | 143 CHECK_EQ(1, env->Global() |
141 CHECK(!GetJSFunction(env->Global(), "f")->IsOptimized()); | 144 ->Get(env.local(), v8_str("count")) |
| 145 .ToLocalChecked() |
| 146 ->Int32Value(env.local()) |
| 147 .FromJust()); |
| 148 CHECK(!GetJSFunction(env.local(), "f")->IsOptimized()); |
142 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(CcTest::i_isolate())); | 149 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(CcTest::i_isolate())); |
143 | 150 |
144 // Test lazy deoptimization of a simple function. Call the function after the | 151 // Test lazy deoptimization of a simple function. Call the function after the |
145 // deoptimization while it is still activated further down the stack. | 152 // deoptimization while it is still activated further down the stack. |
146 { | 153 { |
147 AlwaysOptimizeAllowNativesSyntaxNoInlining options; | 154 AlwaysOptimizeAllowNativesSyntaxNoInlining options; |
148 CompileRun( | 155 CompileRun( |
149 "var count = 0;" | 156 "var count = 0;" |
150 "function g() { count++; %DeoptimizeFunction(f); f(false); }" | 157 "function g() { count++; %DeoptimizeFunction(f); f(false); }" |
151 "function f(x) { if (x) { g(); } else { return } };" | 158 "function f(x) { if (x) { g(); } else { return } };" |
152 "f(true);"); | 159 "f(true);"); |
153 } | 160 } |
154 NonIncrementalGC(CcTest::i_isolate()); | 161 NonIncrementalGC(CcTest::i_isolate()); |
155 | 162 |
156 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); | 163 CHECK_EQ(1, env->Global() |
157 CHECK(!GetJSFunction(env->Global(), "f")->IsOptimized()); | 164 ->Get(env.local(), v8_str("count")) |
| 165 .ToLocalChecked() |
| 166 ->Int32Value(env.local()) |
| 167 .FromJust()); |
| 168 CHECK(!GetJSFunction(env.local(), "f")->IsOptimized()); |
158 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(CcTest::i_isolate())); | 169 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(CcTest::i_isolate())); |
159 } | 170 } |
160 | 171 |
161 | 172 |
162 TEST(DeoptimizeSimpleWithArguments) { | 173 TEST(DeoptimizeSimpleWithArguments) { |
163 LocalContext env; | 174 LocalContext env; |
164 v8::HandleScope scope(env->GetIsolate()); | 175 v8::HandleScope scope(env->GetIsolate()); |
165 | 176 |
166 // Test lazy deoptimization of a simple function with some arguments. | 177 // Test lazy deoptimization of a simple function with some arguments. |
167 { | 178 { |
168 AlwaysOptimizeAllowNativesSyntaxNoInlining options; | 179 AlwaysOptimizeAllowNativesSyntaxNoInlining options; |
169 CompileRun( | 180 CompileRun( |
170 "var count = 0;" | 181 "var count = 0;" |
171 "function h(x) { %DeoptimizeFunction(f); }" | 182 "function h(x) { %DeoptimizeFunction(f); }" |
172 "function g(x, y) { count++; h(x); }" | 183 "function g(x, y) { count++; h(x); }" |
173 "function f(x, y, z) { g(1,x); y+z; };" | 184 "function f(x, y, z) { g(1,x); y+z; };" |
174 "f(1, \"2\", false);"); | 185 "f(1, \"2\", false);"); |
175 } | 186 } |
176 NonIncrementalGC(CcTest::i_isolate()); | 187 NonIncrementalGC(CcTest::i_isolate()); |
177 | 188 |
178 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); | 189 CHECK_EQ(1, env->Global() |
179 CHECK(!GetJSFunction(env->Global(), "f")->IsOptimized()); | 190 ->Get(env.local(), v8_str("count")) |
| 191 .ToLocalChecked() |
| 192 ->Int32Value(env.local()) |
| 193 .FromJust()); |
| 194 CHECK(!GetJSFunction(env.local(), "f")->IsOptimized()); |
180 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(CcTest::i_isolate())); | 195 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(CcTest::i_isolate())); |
181 | 196 |
182 // Test lazy deoptimization of a simple function with some arguments. Call the | 197 // Test lazy deoptimization of a simple function with some arguments. Call the |
183 // function after the deoptimization while it is still activated further down | 198 // function after the deoptimization while it is still activated further down |
184 // the stack. | 199 // the stack. |
185 { | 200 { |
186 AlwaysOptimizeAllowNativesSyntaxNoInlining options; | 201 AlwaysOptimizeAllowNativesSyntaxNoInlining options; |
187 CompileRun( | 202 CompileRun( |
188 "var count = 0;" | 203 "var count = 0;" |
189 "function g(x, y) { count++; %DeoptimizeFunction(f); f(false, 1, y); }" | 204 "function g(x, y) { count++; %DeoptimizeFunction(f); f(false, 1, y); }" |
190 "function f(x, y, z) { if (x) { g(x, y); } else { return y + z; } };" | 205 "function f(x, y, z) { if (x) { g(x, y); } else { return y + z; } };" |
191 "f(true, 1, \"2\");"); | 206 "f(true, 1, \"2\");"); |
192 } | 207 } |
193 NonIncrementalGC(CcTest::i_isolate()); | 208 NonIncrementalGC(CcTest::i_isolate()); |
194 | 209 |
195 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); | 210 CHECK_EQ(1, env->Global() |
196 CHECK(!GetJSFunction(env->Global(), "f")->IsOptimized()); | 211 ->Get(env.local(), v8_str("count")) |
| 212 .ToLocalChecked() |
| 213 ->Int32Value(env.local()) |
| 214 .FromJust()); |
| 215 CHECK(!GetJSFunction(env.local(), "f")->IsOptimized()); |
197 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(CcTest::i_isolate())); | 216 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(CcTest::i_isolate())); |
198 } | 217 } |
199 | 218 |
200 | 219 |
201 TEST(DeoptimizeSimpleNested) { | 220 TEST(DeoptimizeSimpleNested) { |
202 LocalContext env; | 221 LocalContext env; |
203 v8::HandleScope scope(env->GetIsolate()); | 222 v8::HandleScope scope(env->GetIsolate()); |
204 | 223 |
205 // Test lazy deoptimization of a simple function. Have a nested function call | 224 // Test lazy deoptimization of a simple function. Have a nested function call |
206 // do the deoptimization. | 225 // do the deoptimization. |
207 { | 226 { |
208 AlwaysOptimizeAllowNativesSyntaxNoInlining options; | 227 AlwaysOptimizeAllowNativesSyntaxNoInlining options; |
209 CompileRun( | 228 CompileRun( |
210 "var count = 0;" | 229 "var count = 0;" |
211 "var result = 0;" | 230 "var result = 0;" |
212 "function h(x, y, z) { return x + y + z; }" | 231 "function h(x, y, z) { return x + y + z; }" |
213 "function g(z) { count++; %DeoptimizeFunction(f); return z;}" | 232 "function g(z) { count++; %DeoptimizeFunction(f); return z;}" |
214 "function f(x,y,z) { return h(x, y, g(z)); };" | 233 "function f(x,y,z) { return h(x, y, g(z)); };" |
215 "result = f(1, 2, 3);"); | 234 "result = f(1, 2, 3);"); |
216 NonIncrementalGC(CcTest::i_isolate()); | 235 NonIncrementalGC(CcTest::i_isolate()); |
217 | 236 |
218 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); | 237 CHECK_EQ(1, env->Global() |
219 CHECK_EQ(6, env->Global()->Get(v8_str("result"))->Int32Value()); | 238 ->Get(env.local(), v8_str("count")) |
220 CHECK(!GetJSFunction(env->Global(), "f")->IsOptimized()); | 239 .ToLocalChecked() |
| 240 ->Int32Value(env.local()) |
| 241 .FromJust()); |
| 242 CHECK_EQ(6, env->Global() |
| 243 ->Get(env.local(), v8_str("result")) |
| 244 .ToLocalChecked() |
| 245 ->Int32Value(env.local()) |
| 246 .FromJust()); |
| 247 CHECK(!GetJSFunction(env.local(), "f")->IsOptimized()); |
221 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(CcTest::i_isolate())); | 248 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(CcTest::i_isolate())); |
222 } | 249 } |
223 } | 250 } |
224 | 251 |
225 | 252 |
226 TEST(DeoptimizeRecursive) { | 253 TEST(DeoptimizeRecursive) { |
227 LocalContext env; | 254 LocalContext env; |
228 v8::HandleScope scope(env->GetIsolate()); | 255 v8::HandleScope scope(env->GetIsolate()); |
229 | 256 |
230 { | 257 { |
231 // Test lazy deoptimization of a simple function called recursively. Call | 258 // Test lazy deoptimization of a simple function called recursively. Call |
232 // the function recursively a number of times before deoptimizing it. | 259 // the function recursively a number of times before deoptimizing it. |
233 AlwaysOptimizeAllowNativesSyntaxNoInlining options; | 260 AlwaysOptimizeAllowNativesSyntaxNoInlining options; |
234 CompileRun( | 261 CompileRun( |
235 "var count = 0;" | 262 "var count = 0;" |
236 "var calls = 0;" | 263 "var calls = 0;" |
237 "function g() { count++; %DeoptimizeFunction(f); }" | 264 "function g() { count++; %DeoptimizeFunction(f); }" |
238 "function f(x) { calls++; if (x > 0) { f(x - 1); } else { g(); } };" | 265 "function f(x) { calls++; if (x > 0) { f(x - 1); } else { g(); } };" |
239 "f(10);"); | 266 "f(10);"); |
240 } | 267 } |
241 NonIncrementalGC(CcTest::i_isolate()); | 268 NonIncrementalGC(CcTest::i_isolate()); |
242 | 269 |
243 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); | 270 CHECK_EQ(1, env->Global() |
244 CHECK_EQ(11, env->Global()->Get(v8_str("calls"))->Int32Value()); | 271 ->Get(env.local(), v8_str("count")) |
| 272 .ToLocalChecked() |
| 273 ->Int32Value(env.local()) |
| 274 .FromJust()); |
| 275 CHECK_EQ(11, env->Global() |
| 276 ->Get(env.local(), v8_str("calls")) |
| 277 .ToLocalChecked() |
| 278 ->Int32Value(env.local()) |
| 279 .FromJust()); |
245 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(CcTest::i_isolate())); | 280 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(CcTest::i_isolate())); |
246 | 281 |
247 v8::Local<v8::Function> fun = v8::Local<v8::Function>::Cast( | 282 v8::Local<v8::Function> fun = v8::Local<v8::Function>::Cast( |
248 env->Global()->Get(v8::String::NewFromUtf8(CcTest::isolate(), "f"))); | 283 env->Global() |
| 284 ->Get(env.local(), v8_str(CcTest::isolate(), "f")) |
| 285 .ToLocalChecked()); |
249 CHECK(!fun.IsEmpty()); | 286 CHECK(!fun.IsEmpty()); |
250 } | 287 } |
251 | 288 |
252 | 289 |
253 TEST(DeoptimizeMultiple) { | 290 TEST(DeoptimizeMultiple) { |
254 LocalContext env; | 291 LocalContext env; |
255 v8::HandleScope scope(env->GetIsolate()); | 292 v8::HandleScope scope(env->GetIsolate()); |
256 | 293 |
257 { | 294 { |
258 AlwaysOptimizeAllowNativesSyntaxNoInlining options; | 295 AlwaysOptimizeAllowNativesSyntaxNoInlining options; |
259 CompileRun( | 296 CompileRun( |
260 "var count = 0;" | 297 "var count = 0;" |
261 "var result = 0;" | 298 "var result = 0;" |
262 "function g() { count++;" | 299 "function g() { count++;" |
263 " %DeoptimizeFunction(f1);" | 300 " %DeoptimizeFunction(f1);" |
264 " %DeoptimizeFunction(f2);" | 301 " %DeoptimizeFunction(f2);" |
265 " %DeoptimizeFunction(f3);" | 302 " %DeoptimizeFunction(f3);" |
266 " %DeoptimizeFunction(f4);}" | 303 " %DeoptimizeFunction(f4);}" |
267 "function f4(x) { g(); };" | 304 "function f4(x) { g(); };" |
268 "function f3(x, y, z) { f4(); return x + y + z; };" | 305 "function f3(x, y, z) { f4(); return x + y + z; };" |
269 "function f2(x, y) { return x + f3(y + 1, y + 1, y + 1) + y; };" | 306 "function f2(x, y) { return x + f3(y + 1, y + 1, y + 1) + y; };" |
270 "function f1(x) { return f2(x + 1, x + 1) + x; };" | 307 "function f1(x) { return f2(x + 1, x + 1) + x; };" |
271 "result = f1(1);"); | 308 "result = f1(1);"); |
272 } | 309 } |
273 NonIncrementalGC(CcTest::i_isolate()); | 310 NonIncrementalGC(CcTest::i_isolate()); |
274 | 311 |
275 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); | 312 CHECK_EQ(1, env->Global() |
276 CHECK_EQ(14, env->Global()->Get(v8_str("result"))->Int32Value()); | 313 ->Get(env.local(), v8_str("count")) |
| 314 .ToLocalChecked() |
| 315 ->Int32Value(env.local()) |
| 316 .FromJust()); |
| 317 CHECK_EQ(14, env->Global() |
| 318 ->Get(env.local(), v8_str("result")) |
| 319 .ToLocalChecked() |
| 320 ->Int32Value(env.local()) |
| 321 .FromJust()); |
277 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(CcTest::i_isolate())); | 322 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(CcTest::i_isolate())); |
278 } | 323 } |
279 | 324 |
280 | 325 |
281 TEST(DeoptimizeConstructor) { | 326 TEST(DeoptimizeConstructor) { |
282 LocalContext env; | 327 LocalContext env; |
283 v8::HandleScope scope(env->GetIsolate()); | 328 v8::HandleScope scope(env->GetIsolate()); |
284 | 329 |
285 { | 330 { |
286 AlwaysOptimizeAllowNativesSyntaxNoInlining options; | 331 AlwaysOptimizeAllowNativesSyntaxNoInlining options; |
287 CompileRun( | 332 CompileRun( |
288 "var count = 0;" | 333 "var count = 0;" |
289 "function g() { count++;" | 334 "function g() { count++;" |
290 " %DeoptimizeFunction(f); }" | 335 " %DeoptimizeFunction(f); }" |
291 "function f() { g(); };" | 336 "function f() { g(); };" |
292 "result = new f() instanceof f;"); | 337 "result = new f() instanceof f;"); |
293 } | 338 } |
294 NonIncrementalGC(CcTest::i_isolate()); | 339 NonIncrementalGC(CcTest::i_isolate()); |
295 | 340 |
296 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); | 341 CHECK_EQ(1, env->Global() |
297 CHECK(env->Global()->Get(v8_str("result"))->IsTrue()); | 342 ->Get(env.local(), v8_str("count")) |
| 343 .ToLocalChecked() |
| 344 ->Int32Value(env.local()) |
| 345 .FromJust()); |
| 346 CHECK(env->Global() |
| 347 ->Get(env.local(), v8_str("result")) |
| 348 .ToLocalChecked() |
| 349 ->IsTrue()); |
298 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(CcTest::i_isolate())); | 350 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(CcTest::i_isolate())); |
299 | 351 |
300 { | 352 { |
301 AlwaysOptimizeAllowNativesSyntaxNoInlining options; | 353 AlwaysOptimizeAllowNativesSyntaxNoInlining options; |
302 CompileRun( | 354 CompileRun( |
303 "var count = 0;" | 355 "var count = 0;" |
304 "var result = 0;" | 356 "var result = 0;" |
305 "function g() { count++;" | 357 "function g() { count++;" |
306 " %DeoptimizeFunction(f); }" | 358 " %DeoptimizeFunction(f); }" |
307 "function f(x, y) { this.x = x; g(); this.y = y; };" | 359 "function f(x, y) { this.x = x; g(); this.y = y; };" |
308 "result = new f(1, 2);" | 360 "result = new f(1, 2);" |
309 "result = result.x + result.y;"); | 361 "result = result.x + result.y;"); |
310 } | 362 } |
311 NonIncrementalGC(CcTest::i_isolate()); | 363 NonIncrementalGC(CcTest::i_isolate()); |
312 | 364 |
313 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); | 365 CHECK_EQ(1, env->Global() |
314 CHECK_EQ(3, env->Global()->Get(v8_str("result"))->Int32Value()); | 366 ->Get(env.local(), v8_str("count")) |
| 367 .ToLocalChecked() |
| 368 ->Int32Value(env.local()) |
| 369 .FromJust()); |
| 370 CHECK_EQ(3, env->Global() |
| 371 ->Get(env.local(), v8_str("result")) |
| 372 .ToLocalChecked() |
| 373 ->Int32Value(env.local()) |
| 374 .FromJust()); |
315 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(CcTest::i_isolate())); | 375 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(CcTest::i_isolate())); |
316 } | 376 } |
317 | 377 |
318 | 378 |
319 TEST(DeoptimizeConstructorMultiple) { | 379 TEST(DeoptimizeConstructorMultiple) { |
320 LocalContext env; | 380 LocalContext env; |
321 v8::HandleScope scope(env->GetIsolate()); | 381 v8::HandleScope scope(env->GetIsolate()); |
322 | 382 |
323 { | 383 { |
324 AlwaysOptimizeAllowNativesSyntaxNoInlining options; | 384 AlwaysOptimizeAllowNativesSyntaxNoInlining options; |
325 CompileRun( | 385 CompileRun( |
326 "var count = 0;" | 386 "var count = 0;" |
327 "var result = 0;" | 387 "var result = 0;" |
328 "function g() { count++;" | 388 "function g() { count++;" |
329 " %DeoptimizeFunction(f1);" | 389 " %DeoptimizeFunction(f1);" |
330 " %DeoptimizeFunction(f2);" | 390 " %DeoptimizeFunction(f2);" |
331 " %DeoptimizeFunction(f3);" | 391 " %DeoptimizeFunction(f3);" |
332 " %DeoptimizeFunction(f4);}" | 392 " %DeoptimizeFunction(f4);}" |
333 "function f4(x) { this.result = x; g(); };" | 393 "function f4(x) { this.result = x; g(); };" |
334 "function f3(x, y, z) { this.result = new f4(x + y + z).result; };" | 394 "function f3(x, y, z) { this.result = new f4(x + y + z).result; };" |
335 "function f2(x, y) {" | 395 "function f2(x, y) {" |
336 " this.result = x + new f3(y + 1, y + 1, y + 1).result + y; };" | 396 " this.result = x + new f3(y + 1, y + 1, y + 1).result + y; };" |
337 "function f1(x) { this.result = new f2(x + 1, x + 1).result + x; };" | 397 "function f1(x) { this.result = new f2(x + 1, x + 1).result + x; };" |
338 "result = new f1(1).result;"); | 398 "result = new f1(1).result;"); |
339 } | 399 } |
340 NonIncrementalGC(CcTest::i_isolate()); | 400 NonIncrementalGC(CcTest::i_isolate()); |
341 | 401 |
342 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); | 402 CHECK_EQ(1, env->Global() |
343 CHECK_EQ(14, env->Global()->Get(v8_str("result"))->Int32Value()); | 403 ->Get(env.local(), v8_str("count")) |
| 404 .ToLocalChecked() |
| 405 ->Int32Value(env.local()) |
| 406 .FromJust()); |
| 407 CHECK_EQ(14, env->Global() |
| 408 ->Get(env.local(), v8_str("result")) |
| 409 .ToLocalChecked() |
| 410 ->Int32Value(env.local()) |
| 411 .FromJust()); |
344 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(CcTest::i_isolate())); | 412 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(CcTest::i_isolate())); |
345 } | 413 } |
346 | 414 |
347 | 415 |
348 UNINITIALIZED_TEST(DeoptimizeBinaryOperationADDString) { | 416 UNINITIALIZED_TEST(DeoptimizeBinaryOperationADDString) { |
349 i::FLAG_concurrent_recompilation = false; | 417 i::FLAG_concurrent_recompilation = false; |
350 AllowNativesSyntaxNoInlining options; | 418 AllowNativesSyntaxNoInlining options; |
351 v8::Isolate::CreateParams create_params; | 419 v8::Isolate::CreateParams create_params; |
352 create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); | 420 create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); |
353 v8::Isolate* isolate = v8::Isolate::New(create_params); | 421 v8::Isolate* isolate = v8::Isolate::New(create_params); |
(...skipping 21 matching lines...) Expand all Loading... |
375 CompileRun( | 443 CompileRun( |
376 "for (var i = 0; i < 5; i++) {" | 444 "for (var i = 0; i < 5; i++) {" |
377 " f('a+', new X());" | 445 " f('a+', new X());" |
378 "};"); | 446 "};"); |
379 | 447 |
380 // Compile an optimized version of f. | 448 // Compile an optimized version of f. |
381 i::FLAG_always_opt = true; | 449 i::FLAG_always_opt = true; |
382 CompileRun(f_source); | 450 CompileRun(f_source); |
383 CompileRun("f('a+', new X());"); | 451 CompileRun("f('a+', new X());"); |
384 CHECK(!i_isolate->use_crankshaft() || | 452 CHECK(!i_isolate->use_crankshaft() || |
385 GetJSFunction(env->Global(), "f")->IsOptimized()); | 453 GetJSFunction(env.local(), "f")->IsOptimized()); |
386 | 454 |
387 // Call f and force deoptimization while processing the binary operation. | 455 // Call f and force deoptimization while processing the binary operation. |
388 CompileRun( | 456 CompileRun( |
389 "deopt = true;" | 457 "deopt = true;" |
390 "var result = f('a+', new X());"); | 458 "var result = f('a+', new X());"); |
391 } | 459 } |
392 NonIncrementalGC(i_isolate); | 460 NonIncrementalGC(i_isolate); |
393 | 461 |
394 CHECK(!GetJSFunction(env->Global(), "f")->IsOptimized()); | 462 CHECK(!GetJSFunction(env.local(), "f")->IsOptimized()); |
395 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); | 463 CHECK_EQ(1, env->Global() |
396 v8::Handle<v8::Value> result = env->Global()->Get(v8_str("result")); | 464 ->Get(env.local(), v8_str("count")) |
| 465 .ToLocalChecked() |
| 466 ->Int32Value(env.local()) |
| 467 .FromJust()); |
| 468 v8::Local<v8::Value> result = |
| 469 env->Global()->Get(env.local(), v8_str("result")).ToLocalChecked(); |
397 CHECK(result->IsString()); | 470 CHECK(result->IsString()); |
398 v8::String::Utf8Value utf8(result); | 471 v8::String::Utf8Value utf8(result); |
399 CHECK_EQ(0, strcmp("a+an X", *utf8)); | 472 CHECK_EQ(0, strcmp("a+an X", *utf8)); |
400 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(i_isolate)); | 473 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(i_isolate)); |
401 } | 474 } |
402 isolate->Exit(); | 475 isolate->Exit(); |
403 isolate->Dispose(); | 476 isolate->Dispose(); |
404 } | 477 } |
405 | 478 |
406 | 479 |
(...skipping 25 matching lines...) Expand all Loading... |
432 CompileRun(f_source); | 505 CompileRun(f_source); |
433 CompileRun("for (var i = 0; i < 5; i++) {" | 506 CompileRun("for (var i = 0; i < 5; i++) {" |
434 " f(8, new X());" | 507 " f(8, new X());" |
435 "};"); | 508 "};"); |
436 | 509 |
437 // Compile an optimized version of f. | 510 // Compile an optimized version of f. |
438 i::FLAG_always_opt = true; | 511 i::FLAG_always_opt = true; |
439 CompileRun(f_source); | 512 CompileRun(f_source); |
440 CompileRun("f(7, new X());"); | 513 CompileRun("f(7, new X());"); |
441 CHECK(!i_isolate->use_crankshaft() || | 514 CHECK(!i_isolate->use_crankshaft() || |
442 GetJSFunction((*env)->Global(), "f")->IsOptimized()); | 515 GetJSFunction((*env).local(), "f")->IsOptimized()); |
443 | 516 |
444 // Call f and force deoptimization while processing the binary operation. | 517 // Call f and force deoptimization while processing the binary operation. |
445 CompileRun("deopt = true;" | 518 CompileRun("deopt = true;" |
446 "var result = f(7, new X());"); | 519 "var result = f(7, new X());"); |
447 NonIncrementalGC(i_isolate); | 520 NonIncrementalGC(i_isolate); |
448 CHECK(!GetJSFunction((*env)->Global(), "f")->IsOptimized()); | 521 CHECK(!GetJSFunction((*env).local(), "f")->IsOptimized()); |
449 } | 522 } |
450 | 523 |
451 | 524 |
452 UNINITIALIZED_TEST(DeoptimizeBinaryOperationADD) { | 525 UNINITIALIZED_TEST(DeoptimizeBinaryOperationADD) { |
453 i::FLAG_concurrent_recompilation = false; | 526 i::FLAG_concurrent_recompilation = false; |
454 v8::Isolate::CreateParams create_params; | 527 v8::Isolate::CreateParams create_params; |
455 create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); | 528 create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); |
456 v8::Isolate* isolate = v8::Isolate::New(create_params); | 529 v8::Isolate* isolate = v8::Isolate::New(create_params); |
457 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 530 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
458 isolate->Enter(); | 531 isolate->Enter(); |
459 { | 532 { |
460 LocalContext env(isolate); | 533 LocalContext env(isolate); |
461 v8::HandleScope scope(env->GetIsolate()); | 534 v8::HandleScope scope(env->GetIsolate()); |
462 | 535 |
463 TestDeoptimizeBinaryOpHelper(&env, "+"); | 536 TestDeoptimizeBinaryOpHelper(&env, "+"); |
464 | 537 |
465 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); | 538 CHECK_EQ(1, env->Global() |
466 CHECK_EQ(15, env->Global()->Get(v8_str("result"))->Int32Value()); | 539 ->Get(env.local(), v8_str("count")) |
| 540 .ToLocalChecked() |
| 541 ->Int32Value(env.local()) |
| 542 .FromJust()); |
| 543 CHECK_EQ(15, env->Global() |
| 544 ->Get(env.local(), v8_str("result")) |
| 545 .ToLocalChecked() |
| 546 ->Int32Value(env.local()) |
| 547 .FromJust()); |
467 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(i_isolate)); | 548 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(i_isolate)); |
468 } | 549 } |
469 isolate->Exit(); | 550 isolate->Exit(); |
470 isolate->Dispose(); | 551 isolate->Dispose(); |
471 } | 552 } |
472 | 553 |
473 | 554 |
474 UNINITIALIZED_TEST(DeoptimizeBinaryOperationSUB) { | 555 UNINITIALIZED_TEST(DeoptimizeBinaryOperationSUB) { |
475 i::FLAG_concurrent_recompilation = false; | 556 i::FLAG_concurrent_recompilation = false; |
476 v8::Isolate::CreateParams create_params; | 557 v8::Isolate::CreateParams create_params; |
477 create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); | 558 create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); |
478 v8::Isolate* isolate = v8::Isolate::New(create_params); | 559 v8::Isolate* isolate = v8::Isolate::New(create_params); |
479 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 560 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
480 isolate->Enter(); | 561 isolate->Enter(); |
481 { | 562 { |
482 LocalContext env(isolate); | 563 LocalContext env(isolate); |
483 v8::HandleScope scope(env->GetIsolate()); | 564 v8::HandleScope scope(env->GetIsolate()); |
484 | 565 |
485 TestDeoptimizeBinaryOpHelper(&env, "-"); | 566 TestDeoptimizeBinaryOpHelper(&env, "-"); |
486 | 567 |
487 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); | 568 CHECK_EQ(1, env->Global() |
488 CHECK_EQ(-1, env->Global()->Get(v8_str("result"))->Int32Value()); | 569 ->Get(env.local(), v8_str("count")) |
| 570 .ToLocalChecked() |
| 571 ->Int32Value(env.local()) |
| 572 .FromJust()); |
| 573 CHECK_EQ(-1, env->Global() |
| 574 ->Get(env.local(), v8_str("result")) |
| 575 .ToLocalChecked() |
| 576 ->Int32Value(env.local()) |
| 577 .FromJust()); |
489 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(i_isolate)); | 578 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(i_isolate)); |
490 } | 579 } |
491 isolate->Exit(); | 580 isolate->Exit(); |
492 isolate->Dispose(); | 581 isolate->Dispose(); |
493 } | 582 } |
494 | 583 |
495 | 584 |
496 UNINITIALIZED_TEST(DeoptimizeBinaryOperationMUL) { | 585 UNINITIALIZED_TEST(DeoptimizeBinaryOperationMUL) { |
497 i::FLAG_concurrent_recompilation = false; | 586 i::FLAG_concurrent_recompilation = false; |
498 v8::Isolate::CreateParams create_params; | 587 v8::Isolate::CreateParams create_params; |
499 create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); | 588 create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); |
500 v8::Isolate* isolate = v8::Isolate::New(create_params); | 589 v8::Isolate* isolate = v8::Isolate::New(create_params); |
501 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 590 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
502 isolate->Enter(); | 591 isolate->Enter(); |
503 { | 592 { |
504 LocalContext env(isolate); | 593 LocalContext env(isolate); |
505 v8::HandleScope scope(env->GetIsolate()); | 594 v8::HandleScope scope(env->GetIsolate()); |
506 | 595 |
507 TestDeoptimizeBinaryOpHelper(&env, "*"); | 596 TestDeoptimizeBinaryOpHelper(&env, "*"); |
508 | 597 |
509 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); | 598 CHECK_EQ(1, env->Global() |
510 CHECK_EQ(56, env->Global()->Get(v8_str("result"))->Int32Value()); | 599 ->Get(env.local(), v8_str("count")) |
| 600 .ToLocalChecked() |
| 601 ->Int32Value(env.local()) |
| 602 .FromJust()); |
| 603 CHECK_EQ(56, env->Global() |
| 604 ->Get(env.local(), v8_str("result")) |
| 605 .ToLocalChecked() |
| 606 ->Int32Value(env.local()) |
| 607 .FromJust()); |
511 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(i_isolate)); | 608 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(i_isolate)); |
512 } | 609 } |
513 isolate->Exit(); | 610 isolate->Exit(); |
514 isolate->Dispose(); | 611 isolate->Dispose(); |
515 } | 612 } |
516 | 613 |
517 | 614 |
518 UNINITIALIZED_TEST(DeoptimizeBinaryOperationDIV) { | 615 UNINITIALIZED_TEST(DeoptimizeBinaryOperationDIV) { |
519 i::FLAG_concurrent_recompilation = false; | 616 i::FLAG_concurrent_recompilation = false; |
520 v8::Isolate::CreateParams create_params; | 617 v8::Isolate::CreateParams create_params; |
521 create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); | 618 create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); |
522 v8::Isolate* isolate = v8::Isolate::New(create_params); | 619 v8::Isolate* isolate = v8::Isolate::New(create_params); |
523 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 620 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
524 isolate->Enter(); | 621 isolate->Enter(); |
525 { | 622 { |
526 LocalContext env(isolate); | 623 LocalContext env(isolate); |
527 v8::HandleScope scope(env->GetIsolate()); | 624 v8::HandleScope scope(env->GetIsolate()); |
528 | 625 |
529 TestDeoptimizeBinaryOpHelper(&env, "/"); | 626 TestDeoptimizeBinaryOpHelper(&env, "/"); |
530 | 627 |
531 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); | 628 CHECK_EQ(1, env->Global() |
532 CHECK_EQ(0, env->Global()->Get(v8_str("result"))->Int32Value()); | 629 ->Get(env.local(), v8_str("count")) |
| 630 .ToLocalChecked() |
| 631 ->Int32Value(env.local()) |
| 632 .FromJust()); |
| 633 CHECK_EQ(0, env->Global() |
| 634 ->Get(env.local(), v8_str("result")) |
| 635 .ToLocalChecked() |
| 636 ->Int32Value(env.local()) |
| 637 .FromJust()); |
533 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(i_isolate)); | 638 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(i_isolate)); |
534 } | 639 } |
535 isolate->Exit(); | 640 isolate->Exit(); |
536 isolate->Dispose(); | 641 isolate->Dispose(); |
537 } | 642 } |
538 | 643 |
539 | 644 |
540 UNINITIALIZED_TEST(DeoptimizeBinaryOperationMOD) { | 645 UNINITIALIZED_TEST(DeoptimizeBinaryOperationMOD) { |
541 i::FLAG_concurrent_recompilation = false; | 646 i::FLAG_concurrent_recompilation = false; |
542 v8::Isolate::CreateParams create_params; | 647 v8::Isolate::CreateParams create_params; |
543 create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); | 648 create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); |
544 v8::Isolate* isolate = v8::Isolate::New(create_params); | 649 v8::Isolate* isolate = v8::Isolate::New(create_params); |
545 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 650 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
546 isolate->Enter(); | 651 isolate->Enter(); |
547 { | 652 { |
548 LocalContext env(isolate); | 653 LocalContext env(isolate); |
549 v8::HandleScope scope(env->GetIsolate()); | 654 v8::HandleScope scope(env->GetIsolate()); |
550 | 655 |
551 TestDeoptimizeBinaryOpHelper(&env, "%"); | 656 TestDeoptimizeBinaryOpHelper(&env, "%"); |
552 | 657 |
553 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); | 658 CHECK_EQ(1, env->Global() |
554 CHECK_EQ(7, env->Global()->Get(v8_str("result"))->Int32Value()); | 659 ->Get(env.local(), v8_str("count")) |
| 660 .ToLocalChecked() |
| 661 ->Int32Value(env.local()) |
| 662 .FromJust()); |
| 663 CHECK_EQ(7, env->Global() |
| 664 ->Get(env.local(), v8_str("result")) |
| 665 .ToLocalChecked() |
| 666 ->Int32Value(env.local()) |
| 667 .FromJust()); |
555 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(i_isolate)); | 668 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(i_isolate)); |
556 } | 669 } |
557 isolate->Exit(); | 670 isolate->Exit(); |
558 isolate->Dispose(); | 671 isolate->Dispose(); |
559 } | 672 } |
560 | 673 |
561 | 674 |
562 UNINITIALIZED_TEST(DeoptimizeCompare) { | 675 UNINITIALIZED_TEST(DeoptimizeCompare) { |
563 i::FLAG_concurrent_recompilation = false; | 676 i::FLAG_concurrent_recompilation = false; |
564 v8::Isolate::CreateParams create_params; | 677 v8::Isolate::CreateParams create_params; |
(...skipping 24 matching lines...) Expand all Loading... |
589 CompileRun( | 702 CompileRun( |
590 "for (var i = 0; i < 5; i++) {" | 703 "for (var i = 0; i < 5; i++) {" |
591 " f('a', new X());" | 704 " f('a', new X());" |
592 "};"); | 705 "};"); |
593 | 706 |
594 // Compile an optimized version of f. | 707 // Compile an optimized version of f. |
595 i::FLAG_always_opt = true; | 708 i::FLAG_always_opt = true; |
596 CompileRun(f_source); | 709 CompileRun(f_source); |
597 CompileRun("f('a', new X());"); | 710 CompileRun("f('a', new X());"); |
598 CHECK(!i_isolate->use_crankshaft() || | 711 CHECK(!i_isolate->use_crankshaft() || |
599 GetJSFunction(env->Global(), "f")->IsOptimized()); | 712 GetJSFunction(env.local(), "f")->IsOptimized()); |
600 | 713 |
601 // Call f and force deoptimization while processing the comparison. | 714 // Call f and force deoptimization while processing the comparison. |
602 CompileRun( | 715 CompileRun( |
603 "deopt = true;" | 716 "deopt = true;" |
604 "var result = f('a', new X());"); | 717 "var result = f('a', new X());"); |
605 } | 718 } |
606 NonIncrementalGC(i_isolate); | 719 NonIncrementalGC(i_isolate); |
607 | 720 |
608 CHECK(!GetJSFunction(env->Global(), "f")->IsOptimized()); | 721 CHECK(!GetJSFunction(env.local(), "f")->IsOptimized()); |
609 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); | 722 CHECK_EQ(1, env->Global() |
610 CHECK_EQ(true, env->Global()->Get(v8_str("result"))->BooleanValue()); | 723 ->Get(env.local(), v8_str("count")) |
| 724 .ToLocalChecked() |
| 725 ->Int32Value(env.local()) |
| 726 .FromJust()); |
| 727 CHECK_EQ(true, env->Global() |
| 728 ->Get(env.local(), v8_str("result")) |
| 729 .ToLocalChecked() |
| 730 ->BooleanValue(env.local()) |
| 731 .FromJust()); |
611 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(i_isolate)); | 732 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(i_isolate)); |
612 } | 733 } |
613 isolate->Exit(); | 734 isolate->Exit(); |
614 isolate->Dispose(); | 735 isolate->Dispose(); |
615 } | 736 } |
616 | 737 |
617 | 738 |
618 UNINITIALIZED_TEST(DeoptimizeLoadICStoreIC) { | 739 UNINITIALIZED_TEST(DeoptimizeLoadICStoreIC) { |
619 i::FLAG_concurrent_recompilation = false; | 740 i::FLAG_concurrent_recompilation = false; |
620 v8::Isolate::CreateParams create_params; | 741 v8::Isolate::CreateParams create_params; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 i::FLAG_always_opt = true; | 793 i::FLAG_always_opt = true; |
673 CompileRun(f1_source); | 794 CompileRun(f1_source); |
674 CompileRun(g1_source); | 795 CompileRun(g1_source); |
675 CompileRun(f2_source); | 796 CompileRun(f2_source); |
676 CompileRun(g2_source); | 797 CompileRun(g2_source); |
677 CompileRun("f1(new X());"); | 798 CompileRun("f1(new X());"); |
678 CompileRun("g1(new X());"); | 799 CompileRun("g1(new X());"); |
679 CompileRun("f2(new X(), 'z');"); | 800 CompileRun("f2(new X(), 'z');"); |
680 CompileRun("g2(new X(), 'z');"); | 801 CompileRun("g2(new X(), 'z');"); |
681 if (i_isolate->use_crankshaft()) { | 802 if (i_isolate->use_crankshaft()) { |
682 CHECK(GetJSFunction(env->Global(), "f1")->IsOptimized()); | 803 CHECK(GetJSFunction(env.local(), "f1")->IsOptimized()); |
683 CHECK(GetJSFunction(env->Global(), "g1")->IsOptimized()); | 804 CHECK(GetJSFunction(env.local(), "g1")->IsOptimized()); |
684 CHECK(GetJSFunction(env->Global(), "f2")->IsOptimized()); | 805 CHECK(GetJSFunction(env.local(), "f2")->IsOptimized()); |
685 CHECK(GetJSFunction(env->Global(), "g2")->IsOptimized()); | 806 CHECK(GetJSFunction(env.local(), "g2")->IsOptimized()); |
686 } | 807 } |
687 | 808 |
688 // Call functions and force deoptimization while processing the ics. | 809 // Call functions and force deoptimization while processing the ics. |
689 CompileRun( | 810 CompileRun( |
690 "deopt = true;" | 811 "deopt = true;" |
691 "var result = f1(new X());" | 812 "var result = f1(new X());" |
692 "g1(new X());" | 813 "g1(new X());" |
693 "f2(new X(), 'z');" | 814 "f2(new X(), 'z');" |
694 "g2(new X(), 'z');"); | 815 "g2(new X(), 'z');"); |
695 } | 816 } |
696 NonIncrementalGC(i_isolate); | 817 NonIncrementalGC(i_isolate); |
697 | 818 |
698 CHECK(!GetJSFunction(env->Global(), "f1")->IsOptimized()); | 819 CHECK(!GetJSFunction(env.local(), "f1")->IsOptimized()); |
699 CHECK(!GetJSFunction(env->Global(), "g1")->IsOptimized()); | 820 CHECK(!GetJSFunction(env.local(), "g1")->IsOptimized()); |
700 CHECK(!GetJSFunction(env->Global(), "f2")->IsOptimized()); | 821 CHECK(!GetJSFunction(env.local(), "f2")->IsOptimized()); |
701 CHECK(!GetJSFunction(env->Global(), "g2")->IsOptimized()); | 822 CHECK(!GetJSFunction(env.local(), "g2")->IsOptimized()); |
702 CHECK_EQ(4, env->Global()->Get(v8_str("count"))->Int32Value()); | 823 CHECK_EQ(4, env->Global() |
703 CHECK_EQ(13, env->Global()->Get(v8_str("result"))->Int32Value()); | 824 ->Get(env.local(), v8_str("count")) |
| 825 .ToLocalChecked() |
| 826 ->Int32Value(env.local()) |
| 827 .FromJust()); |
| 828 CHECK_EQ(13, env->Global() |
| 829 ->Get(env.local(), v8_str("result")) |
| 830 .ToLocalChecked() |
| 831 ->Int32Value(env.local()) |
| 832 .FromJust()); |
704 } | 833 } |
705 isolate->Exit(); | 834 isolate->Exit(); |
706 isolate->Dispose(); | 835 isolate->Dispose(); |
707 } | 836 } |
708 | 837 |
709 | 838 |
710 UNINITIALIZED_TEST(DeoptimizeLoadICStoreICNested) { | 839 UNINITIALIZED_TEST(DeoptimizeLoadICStoreICNested) { |
711 i::FLAG_concurrent_recompilation = false; | 840 i::FLAG_concurrent_recompilation = false; |
712 v8::Isolate::CreateParams create_params; | 841 v8::Isolate::CreateParams create_params; |
713 create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); | 842 create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
768 i::FLAG_always_opt = true; | 897 i::FLAG_always_opt = true; |
769 CompileRun(f1_source); | 898 CompileRun(f1_source); |
770 CompileRun(g1_source); | 899 CompileRun(g1_source); |
771 CompileRun(f2_source); | 900 CompileRun(f2_source); |
772 CompileRun(g2_source); | 901 CompileRun(g2_source); |
773 CompileRun("f1(new X());"); | 902 CompileRun("f1(new X());"); |
774 CompileRun("g1(new X());"); | 903 CompileRun("g1(new X());"); |
775 CompileRun("f2(new X(), 'z');"); | 904 CompileRun("f2(new X(), 'z');"); |
776 CompileRun("g2(new X(), 'z');"); | 905 CompileRun("g2(new X(), 'z');"); |
777 if (i_isolate->use_crankshaft()) { | 906 if (i_isolate->use_crankshaft()) { |
778 CHECK(GetJSFunction(env->Global(), "f1")->IsOptimized()); | 907 CHECK(GetJSFunction(env.local(), "f1")->IsOptimized()); |
779 CHECK(GetJSFunction(env->Global(), "g1")->IsOptimized()); | 908 CHECK(GetJSFunction(env.local(), "g1")->IsOptimized()); |
780 CHECK(GetJSFunction(env->Global(), "f2")->IsOptimized()); | 909 CHECK(GetJSFunction(env.local(), "f2")->IsOptimized()); |
781 CHECK(GetJSFunction(env->Global(), "g2")->IsOptimized()); | 910 CHECK(GetJSFunction(env.local(), "g2")->IsOptimized()); |
782 } | 911 } |
783 | 912 |
784 // Call functions and force deoptimization while processing the ics. | 913 // Call functions and force deoptimization while processing the ics. |
785 CompileRun( | 914 CompileRun( |
786 "deopt = true;" | 915 "deopt = true;" |
787 "var result = f1(new X());"); | 916 "var result = f1(new X());"); |
788 } | 917 } |
789 NonIncrementalGC(i_isolate); | 918 NonIncrementalGC(i_isolate); |
790 | 919 |
791 CHECK(!GetJSFunction(env->Global(), "f1")->IsOptimized()); | 920 CHECK(!GetJSFunction(env.local(), "f1")->IsOptimized()); |
792 CHECK(!GetJSFunction(env->Global(), "g1")->IsOptimized()); | 921 CHECK(!GetJSFunction(env.local(), "g1")->IsOptimized()); |
793 CHECK(!GetJSFunction(env->Global(), "f2")->IsOptimized()); | 922 CHECK(!GetJSFunction(env.local(), "f2")->IsOptimized()); |
794 CHECK(!GetJSFunction(env->Global(), "g2")->IsOptimized()); | 923 CHECK(!GetJSFunction(env.local(), "g2")->IsOptimized()); |
795 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); | 924 CHECK_EQ(1, env->Global() |
796 CHECK_EQ(13, env->Global()->Get(v8_str("result"))->Int32Value()); | 925 ->Get(env.local(), v8_str("count")) |
| 926 .ToLocalChecked() |
| 927 ->Int32Value(env.local()) |
| 928 .FromJust()); |
| 929 CHECK_EQ(13, env->Global() |
| 930 ->Get(env.local(), v8_str("result")) |
| 931 .ToLocalChecked() |
| 932 ->Int32Value(env.local()) |
| 933 .FromJust()); |
797 } | 934 } |
798 isolate->Exit(); | 935 isolate->Exit(); |
799 isolate->Dispose(); | 936 isolate->Dispose(); |
800 } | 937 } |
OLD | NEW |