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

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

Issue 2534763003: [Interpreter] Add bytecode aging and use it enable CompilationCache for bytecode (Closed)
Patch Set: Created 4 years 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
« src/objects.cc ('K') | « test/cctest/cctest.status ('k') | no next file » | 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 1601 matching lines...) Expand 10 before | Expand all | Expand 10 after
1612 // g should now have available an optimized function, unmarked by gc. The 1612 // g should now have available an optimized function, unmarked by gc. The
1613 // CompileLazy built-in will discover it and install it in the closure, and 1613 // CompileLazy built-in will discover it and install it in the closure, and
1614 // the incremental write barrier should be used. 1614 // the incremental write barrier should be used.
1615 CompileRun("g();"); 1615 CompileRun("g();");
1616 CHECK(g_function->is_compiled()); 1616 CHECK(g_function->is_compiled());
1617 } 1617 }
1618 1618
1619 TEST(CompilationCacheCachingBehavior) { 1619 TEST(CompilationCacheCachingBehavior) {
1620 // If we do not flush code, or have the compilation cache turned off, this 1620 // If we do not flush code, or have the compilation cache turned off, this
1621 // test is invalid. 1621 // test is invalid.
1622 i::FLAG_allow_natives_syntax = true;
1623 if (!FLAG_flush_code || !FLAG_compilation_cache) { 1622 if (!FLAG_flush_code || !FLAG_compilation_cache) {
1624 return; 1623 return;
1625 } 1624 }
1626 CcTest::InitializeVM(); 1625 CcTest::InitializeVM();
1627 Isolate* isolate = CcTest::i_isolate(); 1626 Isolate* isolate = CcTest::i_isolate();
1628 Factory* factory = isolate->factory(); 1627 Factory* factory = isolate->factory();
1629 CompilationCache* compilation_cache = isolate->compilation_cache(); 1628 CompilationCache* compilation_cache = isolate->compilation_cache();
1630 LanguageMode language_mode = construct_language_mode(FLAG_use_strict); 1629 LanguageMode language_mode = construct_language_mode(FLAG_use_strict);
1631 1630
1632 v8::HandleScope scope(CcTest::isolate()); 1631 v8::HandleScope scope(CcTest::isolate());
(...skipping 23 matching lines...) Expand all
1656 // immediately.) 1655 // immediately.)
1657 if (!FLAG_optimize_for_size) { 1656 if (!FLAG_optimize_for_size) {
1658 CcTest::CollectAllGarbage(i::Heap::kFinalizeIncrementalMarkingMask); 1657 CcTest::CollectAllGarbage(i::Heap::kFinalizeIncrementalMarkingMask);
1659 info = compilation_cache->LookupScript(source, Handle<Object>(), 0, 0, 1658 info = compilation_cache->LookupScript(source, Handle<Object>(), 0, 0,
1660 v8::ScriptOriginOptions(true, false), 1659 v8::ScriptOriginOptions(true, false),
1661 native_context, language_mode); 1660 native_context, language_mode);
1662 CHECK(!info.is_null()); 1661 CHECK(!info.is_null());
1663 } 1662 }
1664 1663
1665 // Progress code age until it's old and ready for GC. 1664 // Progress code age until it's old and ready for GC.
1666 while (!info.ToHandleChecked()->code()->IsOld()) { 1665 const int kAgingThreshold = 6;
1666 for (int i = 0; i < kAgingThreshold; i++) {
1667 // To guarantee progress, we have to MakeOlder with different parities. 1667 // To guarantee progress, we have to MakeOlder with different parities.
1668 // We can't just use NO_MARKING_PARITY, since e.g. kExecutedOnceCodeAge is 1668 // We can't just use NO_MARKING_PARITY, since e.g. kExecutedOnceCodeAge is
1669 // always NO_MARKING_PARITY and the code age only progresses if the parity 1669 // always NO_MARKING_PARITY and the code age only progresses if the parity
1670 // is different. 1670 // is different.
1671 info.ToHandleChecked()->code()->MakeOlder(ODD_MARKING_PARITY); 1671 info.ToHandleChecked()->code()->MakeOlder(ODD_MARKING_PARITY);
1672 info.ToHandleChecked()->code()->MakeOlder(EVEN_MARKING_PARITY); 1672 info.ToHandleChecked()->code()->MakeOlder(EVEN_MARKING_PARITY);
1673 if (info.ToHandleChecked()->HasBytecodeArray()) {
1674 info.ToHandleChecked()->bytecode_array()->MakeOlder();
1675 }
1673 } 1676 }
1674 1677
1675 CcTest::CollectAllGarbage(i::Heap::kFinalizeIncrementalMarkingMask); 1678 CcTest::CollectAllGarbage(i::Heap::kFinalizeIncrementalMarkingMask);
1676 // Ensure code aging cleared the entry from the cache. 1679 // Ensure code aging cleared the entry from the cache.
1677 info = compilation_cache->LookupScript(source, Handle<Object>(), 0, 0, 1680 info = compilation_cache->LookupScript(source, Handle<Object>(), 0, 0,
1678 v8::ScriptOriginOptions(true, false), 1681 v8::ScriptOriginOptions(true, false),
1679 native_context, language_mode); 1682 native_context, language_mode);
1680 CHECK(info.is_null()); 1683 CHECK(info.is_null());
1681 } 1684 }
1682 1685
(...skipping 5366 matching lines...) Expand 10 before | Expand all | Expand 10 after
7049 SlotSet::FREE_EMPTY_BUCKETS); 7052 SlotSet::FREE_EMPTY_BUCKETS);
7050 slots[chunk->area_end() - kPointerSize] = false; 7053 slots[chunk->area_end() - kPointerSize] = false;
7051 RememberedSet<OLD_TO_NEW>::Iterate(chunk, [&slots](Address addr) { 7054 RememberedSet<OLD_TO_NEW>::Iterate(chunk, [&slots](Address addr) {
7052 CHECK(slots[addr]); 7055 CHECK(slots[addr]);
7053 return KEEP_SLOT; 7056 return KEEP_SLOT;
7054 }); 7057 });
7055 } 7058 }
7056 7059
7057 } // namespace internal 7060 } // namespace internal
7058 } // namespace v8 7061 } // namespace v8
OLDNEW
« src/objects.cc ('K') | « test/cctest/cctest.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698