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 |
(...skipping 2182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2193 | 2193 |
2194 | 2194 |
2195 TEST(OptimizedPretenuringAllocationFolding) { | 2195 TEST(OptimizedPretenuringAllocationFolding) { |
2196 i::FLAG_allow_natives_syntax = true; | 2196 i::FLAG_allow_natives_syntax = true; |
2197 i::FLAG_expose_gc = true; | 2197 i::FLAG_expose_gc = true; |
2198 CcTest::InitializeVM(); | 2198 CcTest::InitializeVM(); |
2199 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; | 2199 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
2200 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2200 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
2201 v8::HandleScope scope(CcTest::isolate()); | 2201 v8::HandleScope scope(CcTest::isolate()); |
2202 | 2202 |
| 2203 // Grow new space unitl maximum capacity reached. |
| 2204 while (!CcTest::heap()->new_space()->IsAtMaximumCapacity()) { |
| 2205 CcTest::heap()->new_space()->Grow(); |
| 2206 } |
| 2207 |
2203 i::ScopedVector<char> source(1024); | 2208 i::ScopedVector<char> source(1024); |
2204 i::OS::SNPrintF( | 2209 i::OS::SNPrintF( |
2205 source, | 2210 source, |
2206 "var number_elements = %d;" | 2211 "var number_elements = %d;" |
2207 "var elements = new Array();" | 2212 "var elements = new Array();" |
2208 "function f() {" | 2213 "function f() {" |
2209 " for (var i = 0; i < number_elements; i++) {" | 2214 " for (var i = 0; i < number_elements; i++) {" |
2210 " elements[i] = [[{}], [1.1]];" | 2215 " elements[i] = [[{}], [1.1]];" |
2211 " }" | 2216 " }" |
2212 " return elements[number_elements-1]" | 2217 " return elements[number_elements-1]" |
(...skipping 24 matching lines...) Expand all Loading... |
2237 | 2242 |
2238 | 2243 |
2239 TEST(OptimizedPretenuringObjectArrayLiterals) { | 2244 TEST(OptimizedPretenuringObjectArrayLiterals) { |
2240 i::FLAG_allow_natives_syntax = true; | 2245 i::FLAG_allow_natives_syntax = true; |
2241 i::FLAG_expose_gc = true; | 2246 i::FLAG_expose_gc = true; |
2242 CcTest::InitializeVM(); | 2247 CcTest::InitializeVM(); |
2243 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; | 2248 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
2244 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2249 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
2245 v8::HandleScope scope(CcTest::isolate()); | 2250 v8::HandleScope scope(CcTest::isolate()); |
2246 | 2251 |
| 2252 // Grow new space unitl maximum capacity reached. |
| 2253 while (!CcTest::heap()->new_space()->IsAtMaximumCapacity()) { |
| 2254 CcTest::heap()->new_space()->Grow(); |
| 2255 } |
| 2256 |
2247 i::ScopedVector<char> source(1024); | 2257 i::ScopedVector<char> source(1024); |
2248 i::OS::SNPrintF( | 2258 i::OS::SNPrintF( |
2249 source, | 2259 source, |
2250 "var number_elements = %d;" | 2260 "var number_elements = %d;" |
2251 "var elements = new Array(number_elements);" | 2261 "var elements = new Array(number_elements);" |
2252 "function f() {" | 2262 "function f() {" |
2253 " for (var i = 0; i < number_elements; i++) {" | 2263 " for (var i = 0; i < number_elements; i++) {" |
2254 " elements[i] = [{}, {}, {}];" | 2264 " elements[i] = [{}, {}, {}];" |
2255 " }" | 2265 " }" |
2256 " return elements[number_elements - 1];" | 2266 " return elements[number_elements - 1];" |
(...skipping 15 matching lines...) Expand all Loading... |
2272 | 2282 |
2273 | 2283 |
2274 TEST(OptimizedPretenuringMixedInObjectProperties) { | 2284 TEST(OptimizedPretenuringMixedInObjectProperties) { |
2275 i::FLAG_allow_natives_syntax = true; | 2285 i::FLAG_allow_natives_syntax = true; |
2276 i::FLAG_expose_gc = true; | 2286 i::FLAG_expose_gc = true; |
2277 CcTest::InitializeVM(); | 2287 CcTest::InitializeVM(); |
2278 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; | 2288 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
2279 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2289 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
2280 v8::HandleScope scope(CcTest::isolate()); | 2290 v8::HandleScope scope(CcTest::isolate()); |
2281 | 2291 |
| 2292 // Grow new space unitl maximum capacity reached. |
| 2293 while (!CcTest::heap()->new_space()->IsAtMaximumCapacity()) { |
| 2294 CcTest::heap()->new_space()->Grow(); |
| 2295 } |
| 2296 |
| 2297 |
2282 i::ScopedVector<char> source(1024); | 2298 i::ScopedVector<char> source(1024); |
2283 i::OS::SNPrintF( | 2299 i::OS::SNPrintF( |
2284 source, | 2300 source, |
2285 "var number_elements = %d;" | 2301 "var number_elements = %d;" |
2286 "var elements = new Array(number_elements);" | 2302 "var elements = new Array(number_elements);" |
2287 "function f() {" | 2303 "function f() {" |
2288 " for (var i = 0; i < number_elements; i++) {" | 2304 " for (var i = 0; i < number_elements; i++) {" |
2289 " elements[i] = {a: {c: 2.2, d: {}}, b: 1.1};" | 2305 " elements[i] = {a: {c: 2.2, d: {}}, b: 1.1};" |
2290 " }" | 2306 " }" |
2291 " return elements[number_elements - 1];" | 2307 " return elements[number_elements - 1];" |
(...skipping 21 matching lines...) Expand all Loading... |
2313 | 2329 |
2314 | 2330 |
2315 TEST(OptimizedPretenuringDoubleArrayProperties) { | 2331 TEST(OptimizedPretenuringDoubleArrayProperties) { |
2316 i::FLAG_allow_natives_syntax = true; | 2332 i::FLAG_allow_natives_syntax = true; |
2317 i::FLAG_expose_gc = true; | 2333 i::FLAG_expose_gc = true; |
2318 CcTest::InitializeVM(); | 2334 CcTest::InitializeVM(); |
2319 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; | 2335 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
2320 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2336 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
2321 v8::HandleScope scope(CcTest::isolate()); | 2337 v8::HandleScope scope(CcTest::isolate()); |
2322 | 2338 |
| 2339 // Grow new space unitl maximum capacity reached. |
| 2340 while (!CcTest::heap()->new_space()->IsAtMaximumCapacity()) { |
| 2341 CcTest::heap()->new_space()->Grow(); |
| 2342 } |
| 2343 |
2323 i::ScopedVector<char> source(1024); | 2344 i::ScopedVector<char> source(1024); |
2324 i::OS::SNPrintF( | 2345 i::OS::SNPrintF( |
2325 source, | 2346 source, |
2326 "var number_elements = %d;" | 2347 "var number_elements = %d;" |
2327 "var elements = new Array(number_elements);" | 2348 "var elements = new Array(number_elements);" |
2328 "function f() {" | 2349 "function f() {" |
2329 " for (var i = 0; i < number_elements; i++) {" | 2350 " for (var i = 0; i < number_elements; i++) {" |
2330 " elements[i] = {a: 1.1, b: 2.2};" | 2351 " elements[i] = {a: 1.1, b: 2.2};" |
2331 " }" | 2352 " }" |
2332 " return elements[i - 1];" | 2353 " return elements[i - 1];" |
(...skipping 15 matching lines...) Expand all Loading... |
2348 | 2369 |
2349 | 2370 |
2350 TEST(OptimizedPretenuringdoubleArrayLiterals) { | 2371 TEST(OptimizedPretenuringdoubleArrayLiterals) { |
2351 i::FLAG_allow_natives_syntax = true; | 2372 i::FLAG_allow_natives_syntax = true; |
2352 i::FLAG_expose_gc = true; | 2373 i::FLAG_expose_gc = true; |
2353 CcTest::InitializeVM(); | 2374 CcTest::InitializeVM(); |
2354 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; | 2375 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
2355 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2376 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
2356 v8::HandleScope scope(CcTest::isolate()); | 2377 v8::HandleScope scope(CcTest::isolate()); |
2357 | 2378 |
| 2379 // Grow new space unitl maximum capacity reached. |
| 2380 while (!CcTest::heap()->new_space()->IsAtMaximumCapacity()) { |
| 2381 CcTest::heap()->new_space()->Grow(); |
| 2382 } |
| 2383 |
2358 i::ScopedVector<char> source(1024); | 2384 i::ScopedVector<char> source(1024); |
2359 i::OS::SNPrintF( | 2385 i::OS::SNPrintF( |
2360 source, | 2386 source, |
2361 "var number_elements = %d;" | 2387 "var number_elements = %d;" |
2362 "var elements = new Array(number_elements);" | 2388 "var elements = new Array(number_elements);" |
2363 "function f() {" | 2389 "function f() {" |
2364 " for (var i = 0; i < number_elements; i++) {" | 2390 " for (var i = 0; i < number_elements; i++) {" |
2365 " elements[i] = [1.1, 2.2, 3.3];" | 2391 " elements[i] = [1.1, 2.2, 3.3];" |
2366 " }" | 2392 " }" |
2367 " return elements[number_elements - 1];" | 2393 " return elements[number_elements - 1];" |
(...skipping 15 matching lines...) Expand all Loading... |
2383 | 2409 |
2384 | 2410 |
2385 TEST(OptimizedPretenuringNestedMixedArrayLiterals) { | 2411 TEST(OptimizedPretenuringNestedMixedArrayLiterals) { |
2386 i::FLAG_allow_natives_syntax = true; | 2412 i::FLAG_allow_natives_syntax = true; |
2387 i::FLAG_expose_gc = true; | 2413 i::FLAG_expose_gc = true; |
2388 CcTest::InitializeVM(); | 2414 CcTest::InitializeVM(); |
2389 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; | 2415 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
2390 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2416 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
2391 v8::HandleScope scope(CcTest::isolate()); | 2417 v8::HandleScope scope(CcTest::isolate()); |
2392 | 2418 |
| 2419 // Grow new space unitl maximum capacity reached. |
| 2420 while (!CcTest::heap()->new_space()->IsAtMaximumCapacity()) { |
| 2421 CcTest::heap()->new_space()->Grow(); |
| 2422 } |
| 2423 |
2393 i::ScopedVector<char> source(1024); | 2424 i::ScopedVector<char> source(1024); |
2394 i::OS::SNPrintF( | 2425 i::OS::SNPrintF( |
2395 source, | 2426 source, |
2396 "var number_elements = 100;" | 2427 "var number_elements = 100;" |
2397 "var elements = new Array(number_elements);" | 2428 "var elements = new Array(number_elements);" |
2398 "function f() {" | 2429 "function f() {" |
2399 " for (var i = 0; i < number_elements; i++) {" | 2430 " for (var i = 0; i < number_elements; i++) {" |
2400 " elements[i] = [[{}, {}, {}], [1.1, 2.2, 3.3]];" | 2431 " elements[i] = [[{}, {}, {}], [1.1, 2.2, 3.3]];" |
2401 " }" | 2432 " }" |
2402 " return elements[number_elements - 1];" | 2433 " return elements[number_elements - 1];" |
(...skipping 24 matching lines...) Expand all Loading... |
2427 | 2458 |
2428 | 2459 |
2429 TEST(OptimizedPretenuringNestedObjectLiterals) { | 2460 TEST(OptimizedPretenuringNestedObjectLiterals) { |
2430 i::FLAG_allow_natives_syntax = true; | 2461 i::FLAG_allow_natives_syntax = true; |
2431 i::FLAG_expose_gc = true; | 2462 i::FLAG_expose_gc = true; |
2432 CcTest::InitializeVM(); | 2463 CcTest::InitializeVM(); |
2433 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; | 2464 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
2434 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2465 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
2435 v8::HandleScope scope(CcTest::isolate()); | 2466 v8::HandleScope scope(CcTest::isolate()); |
2436 | 2467 |
| 2468 // Grow new space unitl maximum capacity reached. |
| 2469 while (!CcTest::heap()->new_space()->IsAtMaximumCapacity()) { |
| 2470 CcTest::heap()->new_space()->Grow(); |
| 2471 } |
| 2472 |
2437 i::ScopedVector<char> source(1024); | 2473 i::ScopedVector<char> source(1024); |
2438 i::OS::SNPrintF( | 2474 i::OS::SNPrintF( |
2439 source, | 2475 source, |
2440 "var number_elements = %d;" | 2476 "var number_elements = %d;" |
2441 "var elements = new Array(number_elements);" | 2477 "var elements = new Array(number_elements);" |
2442 "function f() {" | 2478 "function f() {" |
2443 " for (var i = 0; i < number_elements; i++) {" | 2479 " for (var i = 0; i < number_elements; i++) {" |
2444 " elements[i] = [[{}, {}, {}],[{}, {}, {}]];" | 2480 " elements[i] = [[{}, {}, {}],[{}, {}, {}]];" |
2445 " }" | 2481 " }" |
2446 " return elements[number_elements - 1];" | 2482 " return elements[number_elements - 1];" |
(...skipping 24 matching lines...) Expand all Loading... |
2471 | 2507 |
2472 | 2508 |
2473 TEST(OptimizedPretenuringNestedDoubleLiterals) { | 2509 TEST(OptimizedPretenuringNestedDoubleLiterals) { |
2474 i::FLAG_allow_natives_syntax = true; | 2510 i::FLAG_allow_natives_syntax = true; |
2475 i::FLAG_expose_gc = true; | 2511 i::FLAG_expose_gc = true; |
2476 CcTest::InitializeVM(); | 2512 CcTest::InitializeVM(); |
2477 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; | 2513 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
2478 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2514 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
2479 v8::HandleScope scope(CcTest::isolate()); | 2515 v8::HandleScope scope(CcTest::isolate()); |
2480 | 2516 |
| 2517 // Grow new space unitl maximum capacity reached. |
| 2518 while (!CcTest::heap()->new_space()->IsAtMaximumCapacity()) { |
| 2519 CcTest::heap()->new_space()->Grow(); |
| 2520 } |
| 2521 |
2481 i::ScopedVector<char> source(1024); | 2522 i::ScopedVector<char> source(1024); |
2482 i::OS::SNPrintF( | 2523 i::OS::SNPrintF( |
2483 source, | 2524 source, |
2484 "var number_elements = %d;" | 2525 "var number_elements = %d;" |
2485 "var elements = new Array(number_elements);" | 2526 "var elements = new Array(number_elements);" |
2486 "function f() {" | 2527 "function f() {" |
2487 " for (var i = 0; i < number_elements; i++) {" | 2528 " for (var i = 0; i < number_elements; i++) {" |
2488 " elements[i] = [[1.1, 1.2, 1.3],[2.1, 2.2, 2.3]];" | 2529 " elements[i] = [[1.1, 1.2, 1.3],[2.1, 2.2, 2.3]];" |
2489 " }" | 2530 " }" |
2490 " return elements[number_elements - 1];" | 2531 " return elements[number_elements - 1];" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2523 // FLAG_pretenuring_call_new needs to be synced with the snapshot. | 2564 // FLAG_pretenuring_call_new needs to be synced with the snapshot. |
2524 return; | 2565 return; |
2525 } | 2566 } |
2526 i::FLAG_allow_natives_syntax = true; | 2567 i::FLAG_allow_natives_syntax = true; |
2527 i::FLAG_expose_gc = true; | 2568 i::FLAG_expose_gc = true; |
2528 CcTest::InitializeVM(); | 2569 CcTest::InitializeVM(); |
2529 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; | 2570 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
2530 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2571 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
2531 v8::HandleScope scope(CcTest::isolate()); | 2572 v8::HandleScope scope(CcTest::isolate()); |
2532 | 2573 |
| 2574 // Grow new space unitl maximum capacity reached. |
| 2575 while (!CcTest::heap()->new_space()->IsAtMaximumCapacity()) { |
| 2576 CcTest::heap()->new_space()->Grow(); |
| 2577 } |
| 2578 |
2533 i::ScopedVector<char> source(1024); | 2579 i::ScopedVector<char> source(1024); |
2534 // Call new is doing slack tracking for the first | 2580 // Call new is doing slack tracking for the first |
2535 // JSFunction::kGenerousAllocationCount allocations, and we can't find | 2581 // JSFunction::kGenerousAllocationCount allocations, and we can't find |
2536 // mementos during that time. | 2582 // mementos during that time. |
2537 i::OS::SNPrintF( | 2583 i::OS::SNPrintF( |
2538 source, | 2584 source, |
2539 "var number_elements = %d;" | 2585 "var number_elements = %d;" |
2540 "var elements = new Array(number_elements);" | 2586 "var elements = new Array(number_elements);" |
2541 "function foo() {" | 2587 "function foo() {" |
2542 " this.a = 3;" | 2588 " this.a = 3;" |
(...skipping 26 matching lines...) Expand all Loading... |
2569 // FLAG_pretenuring_call_new needs to be synced with the snapshot. | 2615 // FLAG_pretenuring_call_new needs to be synced with the snapshot. |
2570 return; | 2616 return; |
2571 } | 2617 } |
2572 i::FLAG_allow_natives_syntax = true; | 2618 i::FLAG_allow_natives_syntax = true; |
2573 i::FLAG_expose_gc = true; | 2619 i::FLAG_expose_gc = true; |
2574 CcTest::InitializeVM(); | 2620 CcTest::InitializeVM(); |
2575 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; | 2621 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
2576 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2622 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
2577 v8::HandleScope scope(CcTest::isolate()); | 2623 v8::HandleScope scope(CcTest::isolate()); |
2578 | 2624 |
| 2625 // Grow new space unitl maximum capacity reached. |
| 2626 while (!CcTest::heap()->new_space()->IsAtMaximumCapacity()) { |
| 2627 CcTest::heap()->new_space()->Grow(); |
| 2628 } |
| 2629 |
2579 i::ScopedVector<char> source(1024); | 2630 i::ScopedVector<char> source(1024); |
2580 // Call new is doing slack tracking for the first | 2631 // Call new is doing slack tracking for the first |
2581 // JSFunction::kGenerousAllocationCount allocations, and we can't find | 2632 // JSFunction::kGenerousAllocationCount allocations, and we can't find |
2582 // mementos during that time. | 2633 // mementos during that time. |
2583 i::OS::SNPrintF( | 2634 i::OS::SNPrintF( |
2584 source, | 2635 source, |
2585 "var number_elements = %d;" | 2636 "var number_elements = %d;" |
2586 "var elements = new Array(number_elements);" | 2637 "var elements = new Array(number_elements);" |
2587 "function g() { this.a = 0; }" | 2638 "function g() { this.a = 0; }" |
2588 "function f() {" | 2639 "function f() {" |
(...skipping 1688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4277 // Type cast checks fail because the path tracer abuses the map for marking. | 4328 // Type cast checks fail because the path tracer abuses the map for marking. |
4278 if (i::FLAG_enable_slow_asserts) return; | 4329 if (i::FLAG_enable_slow_asserts) return; |
4279 CcTest::InitializeVM(); | 4330 CcTest::InitializeVM(); |
4280 v8::HandleScope scope(CcTest::isolate()); | 4331 v8::HandleScope scope(CcTest::isolate()); |
4281 | 4332 |
4282 v8::Local<v8::Value> result = CompileRun("'abc'"); | 4333 v8::Local<v8::Value> result = CompileRun("'abc'"); |
4283 Handle<Object> o = v8::Utils::OpenHandle(*result); | 4334 Handle<Object> o = v8::Utils::OpenHandle(*result); |
4284 CcTest::i_isolate()->heap()->TracePathToObject(*o); | 4335 CcTest::i_isolate()->heap()->TracePathToObject(*o); |
4285 } | 4336 } |
4286 #endif // DEBUG | 4337 #endif // DEBUG |
OLD | NEW |