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