Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: test/cctest/heap/test-heap.cc

Issue 1882833006: Revert of Immediately cache compiled scripts. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/objects.cc ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1569 matching lines...) Expand 10 before | Expand all | Expand 10 after
1580 "};" 1580 "};"
1581 "foo()"; 1581 "foo()";
1582 Handle<String> source = factory->InternalizeUtf8String(raw_source); 1582 Handle<String> source = factory->InternalizeUtf8String(raw_source);
1583 Handle<Context> native_context = isolate->native_context(); 1583 Handle<Context> native_context = isolate->native_context();
1584 1584
1585 { 1585 {
1586 v8::HandleScope scope(CcTest::isolate()); 1586 v8::HandleScope scope(CcTest::isolate());
1587 CompileRun(raw_source); 1587 CompileRun(raw_source);
1588 } 1588 }
1589 1589
1590 // The script should be in the cache now. 1590 // On first compilation, only a hash is inserted in the code cache. We can't
1591 // find that value.
1591 MaybeHandle<SharedFunctionInfo> info = compilation_cache->LookupScript( 1592 MaybeHandle<SharedFunctionInfo> info = compilation_cache->LookupScript(
1592 source, Handle<Object>(), 0, 0, 1593 source, Handle<Object>(), 0, 0,
1593 v8::ScriptOriginOptions(false, true, false), native_context, 1594 v8::ScriptOriginOptions(false, true, false), native_context,
1594 language_mode); 1595 language_mode);
1596 CHECK(info.is_null());
1597
1598 {
1599 v8::HandleScope scope(CcTest::isolate());
1600 CompileRun(raw_source);
1601 }
1602
1603 // On second compilation, the hash is replaced by a real cache entry mapping
1604 // the source to the shared function info containing the code.
1605 info = compilation_cache->LookupScript(
1606 source, Handle<Object>(), 0, 0,
1607 v8::ScriptOriginOptions(false, true, false), native_context,
1608 language_mode);
1595 CHECK(!info.is_null()); 1609 CHECK(!info.is_null());
1596 1610
1597 // Check that the code cache entry survives at least on GC. 1611 // Check that the code cache entry survives at least on GC.
1598 // (Unless --optimize-for-size, in which case it might get collected 1612 // (Unless --optimize-for-size, in which case it might get collected
1599 // immediately.) 1613 // immediately.)
1600 if (!FLAG_optimize_for_size) { 1614 if (!FLAG_optimize_for_size) {
1601 heap->CollectAllGarbage(); 1615 heap->CollectAllGarbage();
1602 info = compilation_cache->LookupScript( 1616 info = compilation_cache->LookupScript(
1603 source, Handle<Object>(), 0, 0, 1617 source, Handle<Object>(), 0, 0,
1604 v8::ScriptOriginOptions(false, true, false), native_context, 1618 v8::ScriptOriginOptions(false, true, false), native_context,
1605 language_mode); 1619 language_mode);
1606 CHECK(!info.is_null()); 1620 CHECK(!info.is_null());
1607 } 1621 }
1608 1622
1609 // Progress code age until it's old and ready for GC. 1623 // Progress code age until it's old and ready for GC.
1610 while (!info.ToHandleChecked()->code()->IsOld()) { 1624 while (!info.ToHandleChecked()->code()->IsOld()) {
1611 // To guarantee progress, we have to MakeOlder with different parities. 1625 // To guarantee progress, we have to MakeOlder with different parities.
1612 // We can't just use NO_MARKING_PARITY, since e.g. kExecutedOnceCodeAge is 1626 // We can't just use NO_MARKING_PARITY, since e.g. kExecutedOnceCodeAge is
1613 // always NO_MARKING_PARITY and the code age only progresses if the parity 1627 // always NO_MARKING_PARITY and the code age only progresses if the parity
1614 // is different. 1628 // is different.
1615 info.ToHandleChecked()->code()->MakeOlder(ODD_MARKING_PARITY); 1629 info.ToHandleChecked()->code()->MakeOlder(ODD_MARKING_PARITY);
1616 info.ToHandleChecked()->code()->MakeOlder(EVEN_MARKING_PARITY); 1630 info.ToHandleChecked()->code()->MakeOlder(EVEN_MARKING_PARITY);
1617 } 1631 }
1618 1632
1619 heap->CollectAllGarbage(); 1633 heap->CollectAllGarbage();
1620 // Ensure code aging cleared the entry from the cache. 1634 // Ensure code aging cleared the entry from the cache.
1621 info = compilation_cache->LookupScript( 1635 info = compilation_cache->LookupScript(
1622 source, Handle<Object>(), 0, 0, 1636 source, Handle<Object>(), 0, 0,
1623 v8::ScriptOriginOptions(false, true, false), native_context, 1637 v8::ScriptOriginOptions(false, true, false), native_context,
1638 language_mode);
1639 CHECK(info.is_null());
1640
1641 {
1642 v8::HandleScope scope(CcTest::isolate());
1643 CompileRun(raw_source);
1644 }
1645
1646 // On first compilation, only a hash is inserted in the code cache. We can't
1647 // find that value.
1648 info = compilation_cache->LookupScript(
1649 source, Handle<Object>(), 0, 0,
1650 v8::ScriptOriginOptions(false, true, false), native_context,
1651 language_mode);
1652 CHECK(info.is_null());
1653
1654 for (int i = 0; i < CompilationCacheTable::kHashGenerations; i++) {
1655 compilation_cache->MarkCompactPrologue();
1656 }
1657
1658 {
1659 v8::HandleScope scope(CcTest::isolate());
1660 CompileRun(raw_source);
1661 }
1662
1663 // If we aged the cache before caching the script, ensure that we didn't cache
1664 // on next compilation.
1665 info = compilation_cache->LookupScript(
1666 source, Handle<Object>(), 0, 0,
1667 v8::ScriptOriginOptions(false, true, false), native_context,
1624 language_mode); 1668 language_mode);
1625 CHECK(info.is_null()); 1669 CHECK(info.is_null());
1626 } 1670 }
1627 1671
1628 1672
1629 static void OptimizeEmptyFunction(const char* name) { 1673 static void OptimizeEmptyFunction(const char* name) {
1630 HandleScope scope(CcTest::i_isolate()); 1674 HandleScope scope(CcTest::i_isolate());
1631 EmbeddedVector<char, 256> source; 1675 EmbeddedVector<char, 256> source;
1632 SNPrintF(source, 1676 SNPrintF(source,
1633 "function %s() { return 0; }" 1677 "function %s() { return 0; }"
(...skipping 4924 matching lines...) Expand 10 before | Expand all | Expand 10 after
6558 heap->RightTrimFixedArray<Heap::CONCURRENT_TO_SWEEPER>(arrays[j], N - 1); 6602 heap->RightTrimFixedArray<Heap::CONCURRENT_TO_SWEEPER>(arrays[j], N - 1);
6559 } 6603 }
6560 } 6604 }
6561 // Force allocation from the free list. 6605 // Force allocation from the free list.
6562 heap->set_force_oom(true); 6606 heap->set_force_oom(true);
6563 heap->CollectGarbage(OLD_SPACE); 6607 heap->CollectGarbage(OLD_SPACE);
6564 } 6608 }
6565 6609
6566 } // namespace internal 6610 } // namespace internal
6567 } // namespace v8 6611 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698