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 1324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1335 | 1335 |
1336 // Create a handle scope so no function objects get stuch in the outer | 1336 // Create a handle scope so no function objects get stuch in the outer |
1337 // handle scope | 1337 // handle scope |
1338 HandleScope scope(isolate); | 1338 HandleScope scope(isolate); |
1339 const char* source = "function f1() { };" | 1339 const char* source = "function f1() { };" |
1340 "function f2() { };" | 1340 "function f2() { };" |
1341 "function f3() { };" | 1341 "function f3() { };" |
1342 "function f4() { };" | 1342 "function f4() { };" |
1343 "function f5() { };"; | 1343 "function f5() { };"; |
1344 CompileRun(source); | 1344 CompileRun(source); |
1345 CHECK_EQ(0, CountOptimizedUserFunctions(ctx[i])); | 1345 int optimized_user_functions_base = CountOptimizedUserFunctions(ctx[i]); |
Michael Starzinger
2013/07/05 12:28:46
Can we move up getting the base number of optimize
| |
1346 CompileRun("f1()"); | 1346 CompileRun("f1()"); |
1347 CHECK_EQ(opt ? 1 : 0, CountOptimizedUserFunctions(ctx[i])); | 1347 CHECK_EQ(opt ? optimized_user_functions_base + 1 : 0, |
1348 CountOptimizedUserFunctions(ctx[i])); | |
1348 CompileRun("f2()"); | 1349 CompileRun("f2()"); |
1349 CHECK_EQ(opt ? 2 : 0, CountOptimizedUserFunctions(ctx[i])); | 1350 CHECK_EQ(opt ? optimized_user_functions_base + 2 : 0, |
1351 CountOptimizedUserFunctions(ctx[i])); | |
1350 CompileRun("f3()"); | 1352 CompileRun("f3()"); |
1351 CHECK_EQ(opt ? 3 : 0, CountOptimizedUserFunctions(ctx[i])); | 1353 CHECK_EQ(opt ? optimized_user_functions_base + 3 : 0, |
1354 CountOptimizedUserFunctions(ctx[i])); | |
1352 CompileRun("f4()"); | 1355 CompileRun("f4()"); |
1353 CHECK_EQ(opt ? 4 : 0, CountOptimizedUserFunctions(ctx[i])); | 1356 CHECK_EQ(opt ? optimized_user_functions_base + 4 : 0, |
1357 CountOptimizedUserFunctions(ctx[i])); | |
1354 CompileRun("f5()"); | 1358 CompileRun("f5()"); |
1355 CHECK_EQ(opt ? 5 : 0, CountOptimizedUserFunctions(ctx[i])); | 1359 CHECK_EQ(opt ? optimized_user_functions_base + 5 : 0, |
1360 CountOptimizedUserFunctions(ctx[i])); | |
1356 | 1361 |
1357 // Remove function f1, and | 1362 // Remove function f1, and |
1358 CompileRun("f1=null"); | 1363 CompileRun("f1=null"); |
1359 | 1364 |
1360 // Scavenge treats these references as strong. | 1365 // Scavenge treats these references as strong. |
1361 for (int j = 0; j < 10; j++) { | 1366 for (int j = 0; j < 10; j++) { |
1362 HEAP->PerformScavenge(); | 1367 HEAP->PerformScavenge(); |
1363 CHECK_EQ(opt ? 5 : 0, CountOptimizedUserFunctions(ctx[i])); | 1368 CHECK_EQ(opt ? optimized_user_functions_base + 5 : 0, |
1369 CountOptimizedUserFunctions(ctx[i])); | |
1364 } | 1370 } |
1365 | 1371 |
1366 // Mark compact handles the weak references. | 1372 // Mark compact handles the weak references. |
1367 isolate->compilation_cache()->Clear(); | 1373 isolate->compilation_cache()->Clear(); |
1368 heap->CollectAllGarbage(Heap::kNoGCFlags); | 1374 heap->CollectAllGarbage(Heap::kNoGCFlags); |
1369 CHECK_EQ(opt ? 4 : 0, CountOptimizedUserFunctions(ctx[i])); | 1375 CHECK_EQ(opt ? optimized_user_functions_base + 4 : 0, |
1376 CountOptimizedUserFunctions(ctx[i])); | |
1370 | 1377 |
1371 // Get rid of f3 and f5 in the same way. | 1378 // Get rid of f3 and f5 in the same way. |
1372 CompileRun("f3=null"); | 1379 CompileRun("f3=null"); |
1373 for (int j = 0; j < 10; j++) { | 1380 for (int j = 0; j < 10; j++) { |
1374 HEAP->PerformScavenge(); | 1381 HEAP->PerformScavenge(); |
1375 CHECK_EQ(opt ? 4 : 0, CountOptimizedUserFunctions(ctx[i])); | 1382 CHECK_EQ(opt ? optimized_user_functions_base + 4 : 0, |
1383 CountOptimizedUserFunctions(ctx[i])); | |
1376 } | 1384 } |
1377 HEAP->CollectAllGarbage(Heap::kNoGCFlags); | 1385 HEAP->CollectAllGarbage(Heap::kNoGCFlags); |
1378 CHECK_EQ(opt ? 3 : 0, CountOptimizedUserFunctions(ctx[i])); | 1386 CHECK_EQ(opt ? optimized_user_functions_base + 3 : 0, |
1387 CountOptimizedUserFunctions(ctx[i])); | |
1379 CompileRun("f5=null"); | 1388 CompileRun("f5=null"); |
1380 for (int j = 0; j < 10; j++) { | 1389 for (int j = 0; j < 10; j++) { |
1381 HEAP->PerformScavenge(); | 1390 HEAP->PerformScavenge(); |
1382 CHECK_EQ(opt ? 3 : 0, CountOptimizedUserFunctions(ctx[i])); | 1391 CHECK_EQ(opt ? optimized_user_functions_base + 3 : 0, |
1392 CountOptimizedUserFunctions(ctx[i])); | |
1383 } | 1393 } |
1384 HEAP->CollectAllGarbage(Heap::kNoGCFlags); | 1394 HEAP->CollectAllGarbage(Heap::kNoGCFlags); |
1385 CHECK_EQ(opt ? 2 : 0, CountOptimizedUserFunctions(ctx[i])); | 1395 CHECK_EQ(opt ? optimized_user_functions_base + 2 : 0, |
1396 CountOptimizedUserFunctions(ctx[i])); | |
1386 | 1397 |
1387 ctx[i]->Exit(); | 1398 ctx[i]->Exit(); |
1388 } | 1399 } |
1389 | 1400 |
1390 // Force compilation cache cleanup. | 1401 // Force compilation cache cleanup. |
1391 HEAP->CollectAllGarbage(Heap::kNoGCFlags); | 1402 HEAP->CollectAllGarbage(Heap::kNoGCFlags); |
1392 | 1403 |
1393 // Dispose the native contexts one by one. | 1404 // Dispose the native contexts one by one. |
1394 for (int i = 0; i < kNumTestContexts; i++) { | 1405 for (int i = 0; i < kNumTestContexts; i++) { |
1395 // TODO(dcarney): is there a better way to do this? | 1406 // TODO(dcarney): is there a better way to do this? |
(...skipping 1917 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3313 " var a = new Array(n);" | 3324 " var a = new Array(n);" |
3314 " for (var i = 0; i < n; i += 100) a[i] = i;" | 3325 " for (var i = 0; i < n; i += 100) a[i] = i;" |
3315 "};" | 3326 "};" |
3316 "f(10 * 1024 * 1024);"); | 3327 "f(10 * 1024 * 1024);"); |
3317 IncrementalMarking* marking = HEAP->incremental_marking(); | 3328 IncrementalMarking* marking = HEAP->incremental_marking(); |
3318 if (marking->IsStopped()) marking->Start(); | 3329 if (marking->IsStopped()) marking->Start(); |
3319 // This big step should be sufficient to mark the whole array. | 3330 // This big step should be sufficient to mark the whole array. |
3320 marking->Step(100 * MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD); | 3331 marking->Step(100 * MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD); |
3321 ASSERT(marking->IsComplete()); | 3332 ASSERT(marking->IsComplete()); |
3322 } | 3333 } |
OLD | NEW |