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 1549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1560 } | 1560 } |
1561 | 1561 |
1562 // On second compilation, the hash is replaced by a real cache entry mapping | 1562 // On second compilation, the hash is replaced by a real cache entry mapping |
1563 // the source to the shared function info containing the code. | 1563 // the source to the shared function info containing the code. |
1564 info = compilation_cache->LookupScript( | 1564 info = compilation_cache->LookupScript( |
1565 source, Handle<Object>(), 0, 0, | 1565 source, Handle<Object>(), 0, 0, |
1566 v8::ScriptOriginOptions(false, true, false), native_context, | 1566 v8::ScriptOriginOptions(false, true, false), native_context, |
1567 language_mode); | 1567 language_mode); |
1568 CHECK(!info.is_null()); | 1568 CHECK(!info.is_null()); |
1569 | 1569 |
1570 heap->CollectAllGarbage(); | 1570 // Check that the code cache entry survives at least on GC. |
| 1571 // (Unless --optimize-for-size, in which case it might get collected |
| 1572 // immediately.) |
| 1573 if (!FLAG_optimize_for_size) { |
| 1574 heap->CollectAllGarbage(); |
| 1575 info = compilation_cache->LookupScript( |
| 1576 source, Handle<Object>(), 0, 0, |
| 1577 v8::ScriptOriginOptions(false, true, false), native_context, |
| 1578 language_mode); |
| 1579 CHECK(!info.is_null()); |
| 1580 } |
1571 | 1581 |
1572 // On second compilation, the hash is replaced by a real cache entry mapping | 1582 // Progress code age until it's old and ready for GC. |
1573 // the source to the shared function info containing the code. | |
1574 info = compilation_cache->LookupScript( | |
1575 source, Handle<Object>(), 0, 0, | |
1576 v8::ScriptOriginOptions(false, true, false), native_context, | |
1577 language_mode); | |
1578 CHECK(!info.is_null()); | |
1579 | |
1580 while (!info.ToHandleChecked()->code()->IsOld()) { | 1583 while (!info.ToHandleChecked()->code()->IsOld()) { |
1581 info.ToHandleChecked()->code()->MakeOlder(NO_MARKING_PARITY); | 1584 // To guarantee progress, we have to MakeOlder with different parities. |
| 1585 // We can't just use NO_MARKING_PARITY, since e.g. kExecutedOnceCodeAge is |
| 1586 // always NO_MARKING_PARITY and the code age only progresses if the parity |
| 1587 // is different. |
| 1588 info.ToHandleChecked()->code()->MakeOlder(ODD_MARKING_PARITY); |
| 1589 info.ToHandleChecked()->code()->MakeOlder(EVEN_MARKING_PARITY); |
1582 } | 1590 } |
1583 | 1591 |
1584 heap->CollectAllGarbage(); | 1592 heap->CollectAllGarbage(); |
1585 // Ensure code aging cleared the entry from the cache. | 1593 // Ensure code aging cleared the entry from the cache. |
1586 info = compilation_cache->LookupScript( | 1594 info = compilation_cache->LookupScript( |
1587 source, Handle<Object>(), 0, 0, | 1595 source, Handle<Object>(), 0, 0, |
1588 v8::ScriptOriginOptions(false, true, false), native_context, | 1596 v8::ScriptOriginOptions(false, true, false), native_context, |
1589 language_mode); | 1597 language_mode); |
1590 CHECK(info.is_null()); | 1598 CHECK(info.is_null()); |
1591 | 1599 |
(...skipping 4866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6458 isolate->IncrementJsCallsFromApiCounter(); | 6466 isolate->IncrementJsCallsFromApiCounter(); |
6459 isolate->IncrementJsCallsFromApiCounter(); | 6467 isolate->IncrementJsCallsFromApiCounter(); |
6460 isolate->IncrementJsCallsFromApiCounter(); | 6468 isolate->IncrementJsCallsFromApiCounter(); |
6461 calls_per_ms = memory_reducer->SampleAndGetJsCallsPerMs(4); | 6469 calls_per_ms = memory_reducer->SampleAndGetJsCallsPerMs(4); |
6462 CheckDoubleEquals(2, calls_per_ms); | 6470 CheckDoubleEquals(2, calls_per_ms); |
6463 } | 6471 } |
6464 | 6472 |
6465 | 6473 |
6466 } // namespace internal | 6474 } // namespace internal |
6467 } // namespace v8 | 6475 } // namespace v8 |
OLD | NEW |