| 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 1359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1370 Handle<Context> native_context = isolate->native_context(); | 1370 Handle<Context> native_context = isolate->native_context(); |
| 1371 | 1371 |
| 1372 { | 1372 { |
| 1373 v8::HandleScope scope(CcTest::isolate()); | 1373 v8::HandleScope scope(CcTest::isolate()); |
| 1374 CompileRun(raw_source); | 1374 CompileRun(raw_source); |
| 1375 } | 1375 } |
| 1376 | 1376 |
| 1377 // On first compilation, only a hash is inserted in the code cache. We can't | 1377 // On first compilation, only a hash is inserted in the code cache. We can't |
| 1378 // find that value. | 1378 // find that value. |
| 1379 MaybeHandle<SharedFunctionInfo> info = compilation_cache->LookupScript( | 1379 MaybeHandle<SharedFunctionInfo> info = compilation_cache->LookupScript( |
| 1380 source, Handle<Object>(), 0, 0, | 1380 source, Handle<Object>(), 0, 0, false, true, native_context, |
| 1381 v8::ScriptOriginOptions(false, true, false), native_context, | |
| 1382 language_mode); | 1381 language_mode); |
| 1383 CHECK(info.is_null()); | 1382 CHECK(info.is_null()); |
| 1384 | 1383 |
| 1385 { | 1384 { |
| 1386 v8::HandleScope scope(CcTest::isolate()); | 1385 v8::HandleScope scope(CcTest::isolate()); |
| 1387 CompileRun(raw_source); | 1386 CompileRun(raw_source); |
| 1388 } | 1387 } |
| 1389 | 1388 |
| 1390 // On second compilation, the hash is replaced by a real cache entry mapping | 1389 // On second compilation, the hash is replaced by a real cache entry mapping |
| 1391 // the source to the shared function info containing the code. | 1390 // the source to the shared function info containing the code. |
| 1392 info = compilation_cache->LookupScript( | 1391 info = compilation_cache->LookupScript(source, Handle<Object>(), 0, 0, false, |
| 1393 source, Handle<Object>(), 0, 0, | 1392 true, native_context, language_mode); |
| 1394 v8::ScriptOriginOptions(false, true, false), native_context, | |
| 1395 language_mode); | |
| 1396 CHECK(!info.is_null()); | 1393 CHECK(!info.is_null()); |
| 1397 | 1394 |
| 1398 heap->CollectAllGarbage(); | 1395 heap->CollectAllGarbage(); |
| 1399 | 1396 |
| 1400 // On second compilation, the hash is replaced by a real cache entry mapping | 1397 // On second compilation, the hash is replaced by a real cache entry mapping |
| 1401 // the source to the shared function info containing the code. | 1398 // the source to the shared function info containing the code. |
| 1402 info = compilation_cache->LookupScript( | 1399 info = compilation_cache->LookupScript(source, Handle<Object>(), 0, 0, false, |
| 1403 source, Handle<Object>(), 0, 0, | 1400 true, native_context, language_mode); |
| 1404 v8::ScriptOriginOptions(false, true, false), native_context, | |
| 1405 language_mode); | |
| 1406 CHECK(!info.is_null()); | 1401 CHECK(!info.is_null()); |
| 1407 | 1402 |
| 1408 while (!info.ToHandleChecked()->code()->IsOld()) { | 1403 while (!info.ToHandleChecked()->code()->IsOld()) { |
| 1409 info.ToHandleChecked()->code()->MakeOlder(NO_MARKING_PARITY); | 1404 info.ToHandleChecked()->code()->MakeOlder(NO_MARKING_PARITY); |
| 1410 } | 1405 } |
| 1411 | 1406 |
| 1412 heap->CollectAllGarbage(); | 1407 heap->CollectAllGarbage(); |
| 1413 // Ensure code aging cleared the entry from the cache. | 1408 // Ensure code aging cleared the entry from the cache. |
| 1414 info = compilation_cache->LookupScript( | 1409 info = compilation_cache->LookupScript(source, Handle<Object>(), 0, 0, false, |
| 1415 source, Handle<Object>(), 0, 0, | 1410 true, native_context, language_mode); |
| 1416 v8::ScriptOriginOptions(false, true, false), native_context, | |
| 1417 language_mode); | |
| 1418 CHECK(info.is_null()); | 1411 CHECK(info.is_null()); |
| 1419 | 1412 |
| 1420 { | 1413 { |
| 1421 v8::HandleScope scope(CcTest::isolate()); | 1414 v8::HandleScope scope(CcTest::isolate()); |
| 1422 CompileRun(raw_source); | 1415 CompileRun(raw_source); |
| 1423 } | 1416 } |
| 1424 | 1417 |
| 1425 // On first compilation, only a hash is inserted in the code cache. We can't | 1418 // On first compilation, only a hash is inserted in the code cache. We can't |
| 1426 // find that value. | 1419 // find that value. |
| 1427 info = compilation_cache->LookupScript( | 1420 info = compilation_cache->LookupScript(source, Handle<Object>(), 0, 0, false, |
| 1428 source, Handle<Object>(), 0, 0, | 1421 true, native_context, language_mode); |
| 1429 v8::ScriptOriginOptions(false, true, false), native_context, | |
| 1430 language_mode); | |
| 1431 CHECK(info.is_null()); | 1422 CHECK(info.is_null()); |
| 1432 | 1423 |
| 1433 for (int i = 0; i < CompilationCacheTable::kHashGenerations; i++) { | 1424 for (int i = 0; i < CompilationCacheTable::kHashGenerations; i++) { |
| 1434 compilation_cache->MarkCompactPrologue(); | 1425 compilation_cache->MarkCompactPrologue(); |
| 1435 } | 1426 } |
| 1436 | 1427 |
| 1437 { | 1428 { |
| 1438 v8::HandleScope scope(CcTest::isolate()); | 1429 v8::HandleScope scope(CcTest::isolate()); |
| 1439 CompileRun(raw_source); | 1430 CompileRun(raw_source); |
| 1440 } | 1431 } |
| 1441 | 1432 |
| 1442 // If we aged the cache before caching the script, ensure that we didn't cache | 1433 // If we aged the cache before caching the script, ensure that we didn't cache |
| 1443 // on next compilation. | 1434 // on next compilation. |
| 1444 info = compilation_cache->LookupScript( | 1435 info = compilation_cache->LookupScript(source, Handle<Object>(), 0, 0, false, |
| 1445 source, Handle<Object>(), 0, 0, | 1436 true, native_context, language_mode); |
| 1446 v8::ScriptOriginOptions(false, true, false), native_context, | |
| 1447 language_mode); | |
| 1448 CHECK(info.is_null()); | 1437 CHECK(info.is_null()); |
| 1449 } | 1438 } |
| 1450 | 1439 |
| 1451 | 1440 |
| 1452 static void OptimizeEmptyFunction(const char* name) { | 1441 static void OptimizeEmptyFunction(const char* name) { |
| 1453 HandleScope scope(CcTest::i_isolate()); | 1442 HandleScope scope(CcTest::i_isolate()); |
| 1454 EmbeddedVector<char, 256> source; | 1443 EmbeddedVector<char, 256> source; |
| 1455 SNPrintF(source, | 1444 SNPrintF(source, |
| 1456 "function %s() { return 0; }" | 1445 "function %s() { return 0; }" |
| 1457 "%s(); %s();" | 1446 "%s(); %s();" |
| (...skipping 3996 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5454 shared.SetWeak(&shared, SharedHasBeenCollected, | 5443 shared.SetWeak(&shared, SharedHasBeenCollected, |
| 5455 v8::WeakCallbackType::kParameter); | 5444 v8::WeakCallbackType::kParameter); |
| 5456 builtin_exports.SetWeak(&builtin_exports, BuiltinExportsHasBeenCollected, | 5445 builtin_exports.SetWeak(&builtin_exports, BuiltinExportsHasBeenCollected, |
| 5457 v8::WeakCallbackType::kParameter); | 5446 v8::WeakCallbackType::kParameter); |
| 5458 | 5447 |
| 5459 CcTest::heap()->CollectAllAvailableGarbage("fire weak callbacks"); | 5448 CcTest::heap()->CollectAllAvailableGarbage("fire weak callbacks"); |
| 5460 | 5449 |
| 5461 CHECK(shared_has_been_collected); | 5450 CHECK(shared_has_been_collected); |
| 5462 CHECK(builtin_exports_has_been_collected); | 5451 CHECK(builtin_exports_has_been_collected); |
| 5463 } | 5452 } |
| OLD | NEW |