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 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 const v8::WeakCallbackInfo<void>& data) { | 482 const v8::WeakCallbackInfo<void>& data) { |
483 std::pair<v8::Persistent<v8::Value>*, int>* p = | 483 std::pair<v8::Persistent<v8::Value>*, int>* p = |
484 reinterpret_cast<std::pair<v8::Persistent<v8::Value>*, int>*>( | 484 reinterpret_cast<std::pair<v8::Persistent<v8::Value>*, int>*>( |
485 data.GetParameter()); | 485 data.GetParameter()); |
486 if (p->second == 1234) WeakPointerCleared = true; | 486 if (p->second == 1234) WeakPointerCleared = true; |
487 p->first->Reset(); | 487 p->first->Reset(); |
488 } | 488 } |
489 | 489 |
490 | 490 |
491 TEST(WeakGlobalHandlesScavenge) { | 491 TEST(WeakGlobalHandlesScavenge) { |
492 i::FLAG_stress_compaction = false; | 492 FLAG_stress_compaction = false; |
| 493 FLAG_stress_incremental_marking = false; |
493 CcTest::InitializeVM(); | 494 CcTest::InitializeVM(); |
494 Isolate* isolate = CcTest::i_isolate(); | 495 Isolate* isolate = CcTest::i_isolate(); |
495 Factory* factory = isolate->factory(); | 496 Factory* factory = isolate->factory(); |
496 GlobalHandles* global_handles = isolate->global_handles(); | 497 GlobalHandles* global_handles = isolate->global_handles(); |
497 | 498 |
498 WeakPointerCleared = false; | 499 WeakPointerCleared = false; |
499 | 500 |
500 Handle<Object> h1; | 501 Handle<Object> h1; |
501 Handle<Object> h2; | 502 Handle<Object> h2; |
502 | 503 |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 | 648 |
648 CcTest::CollectGarbage(NEW_SPACE); | 649 CcTest::CollectGarbage(NEW_SPACE); |
649 | 650 |
650 CHECK(!WeakPointerCleared); | 651 CHECK(!WeakPointerCleared); |
651 CHECK(!global_handles->IsNearDeath(h1.location())); | 652 CHECK(!global_handles->IsNearDeath(h1.location())); |
652 | 653 |
653 GlobalHandles::Destroy(h1.location()); | 654 GlobalHandles::Destroy(h1.location()); |
654 } | 655 } |
655 | 656 |
656 TEST(WeakGlobalHandlesMark) { | 657 TEST(WeakGlobalHandlesMark) { |
| 658 FLAG_stress_incremental_marking = false; |
657 CcTest::InitializeVM(); | 659 CcTest::InitializeVM(); |
658 Isolate* isolate = CcTest::i_isolate(); | 660 Isolate* isolate = CcTest::i_isolate(); |
659 Heap* heap = isolate->heap(); | 661 Heap* heap = isolate->heap(); |
660 Factory* factory = isolate->factory(); | 662 Factory* factory = isolate->factory(); |
661 GlobalHandles* global_handles = isolate->global_handles(); | 663 GlobalHandles* global_handles = isolate->global_handles(); |
662 | 664 |
663 WeakPointerCleared = false; | 665 WeakPointerCleared = false; |
664 | 666 |
665 Handle<Object> h1; | 667 Handle<Object> h1; |
666 Handle<Object> h2; | 668 Handle<Object> h2; |
(...skipping 26 matching lines...) Expand all Loading... |
693 CHECK((*h1)->IsString()); | 695 CHECK((*h1)->IsString()); |
694 | 696 |
695 CHECK(WeakPointerCleared); | 697 CHECK(WeakPointerCleared); |
696 CHECK(!GlobalHandles::IsNearDeath(h1.location())); | 698 CHECK(!GlobalHandles::IsNearDeath(h1.location())); |
697 | 699 |
698 GlobalHandles::Destroy(h1.location()); | 700 GlobalHandles::Destroy(h1.location()); |
699 } | 701 } |
700 | 702 |
701 | 703 |
702 TEST(DeleteWeakGlobalHandle) { | 704 TEST(DeleteWeakGlobalHandle) { |
703 i::FLAG_stress_compaction = false; | 705 FLAG_stress_compaction = false; |
| 706 FLAG_stress_incremental_marking = false; |
704 CcTest::InitializeVM(); | 707 CcTest::InitializeVM(); |
705 Isolate* isolate = CcTest::i_isolate(); | 708 Isolate* isolate = CcTest::i_isolate(); |
706 Factory* factory = isolate->factory(); | 709 Factory* factory = isolate->factory(); |
707 GlobalHandles* global_handles = isolate->global_handles(); | 710 GlobalHandles* global_handles = isolate->global_handles(); |
708 | 711 |
709 WeakPointerCleared = false; | 712 WeakPointerCleared = false; |
710 | 713 |
711 Handle<Object> h; | 714 Handle<Object> h; |
712 | 715 |
713 { | 716 { |
(...skipping 18 matching lines...) Expand all Loading... |
732 | 735 |
733 CHECK(WeakPointerCleared); | 736 CHECK(WeakPointerCleared); |
734 } | 737 } |
735 | 738 |
736 TEST(BytecodeArray) { | 739 TEST(BytecodeArray) { |
737 static const uint8_t kRawBytes[] = {0xc3, 0x7e, 0xa5, 0x5a}; | 740 static const uint8_t kRawBytes[] = {0xc3, 0x7e, 0xa5, 0x5a}; |
738 static const int kRawBytesSize = sizeof(kRawBytes); | 741 static const int kRawBytesSize = sizeof(kRawBytes); |
739 static const int kFrameSize = 32; | 742 static const int kFrameSize = 32; |
740 static const int kParameterCount = 2; | 743 static const int kParameterCount = 2; |
741 | 744 |
742 i::FLAG_manual_evacuation_candidates_selection = true; | 745 FLAG_manual_evacuation_candidates_selection = true; |
| 746 FLAG_stress_incremental_marking = false; |
743 CcTest::InitializeVM(); | 747 CcTest::InitializeVM(); |
744 Isolate* isolate = CcTest::i_isolate(); | 748 Isolate* isolate = CcTest::i_isolate(); |
745 Heap* heap = isolate->heap(); | 749 Heap* heap = isolate->heap(); |
746 Factory* factory = isolate->factory(); | 750 Factory* factory = isolate->factory(); |
747 HandleScope scope(isolate); | 751 HandleScope scope(isolate); |
748 | 752 |
749 heap::SimulateFullSpace(heap->old_space()); | 753 heap::SimulateFullSpace(heap->old_space()); |
750 Handle<FixedArray> constant_pool = factory->NewFixedArray(5, TENURED); | 754 Handle<FixedArray> constant_pool = factory->NewFixedArray(5, TENURED); |
751 for (int i = 0; i < 5; i++) { | 755 for (int i = 0; i < 5; i++) { |
752 Handle<Object> number = factory->NewHeapNumber(i); | 756 Handle<Object> number = factory->NewHeapNumber(i); |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1202 delete[] str; | 1206 delete[] str; |
1203 | 1207 |
1204 // Add a Map object to look for. | 1208 // Add a Map object to look for. |
1205 objs[next_objs_index++] = Handle<Map>(HeapObject::cast(*objs[0])->map()); | 1209 objs[next_objs_index++] = Handle<Map>(HeapObject::cast(*objs[0])->map()); |
1206 | 1210 |
1207 CHECK_EQ(objs_count, next_objs_index); | 1211 CHECK_EQ(objs_count, next_objs_index); |
1208 CHECK_EQ(objs_count, ObjectsFoundInHeap(CcTest::heap(), objs, objs_count)); | 1212 CHECK_EQ(objs_count, ObjectsFoundInHeap(CcTest::heap(), objs, objs_count)); |
1209 } | 1213 } |
1210 | 1214 |
1211 TEST(TestUseOfIncrementalBarrierOnCompileLazy) { | 1215 TEST(TestUseOfIncrementalBarrierOnCompileLazy) { |
1212 if (!i::FLAG_incremental_marking) return; | 1216 if (!FLAG_incremental_marking) return; |
1213 // Turn off always_opt because it interferes with running the built-in for | 1217 // Turn off always_opt because it interferes with running the built-in for |
1214 // the last call to g(). | 1218 // the last call to g(). |
1215 i::FLAG_always_opt = false; | 1219 FLAG_always_opt = false; |
1216 i::FLAG_allow_natives_syntax = true; | 1220 FLAG_allow_natives_syntax = true; |
1217 CcTest::InitializeVM(); | 1221 CcTest::InitializeVM(); |
1218 Isolate* isolate = CcTest::i_isolate(); | 1222 Isolate* isolate = CcTest::i_isolate(); |
1219 Factory* factory = isolate->factory(); | 1223 Factory* factory = isolate->factory(); |
1220 Heap* heap = isolate->heap(); | 1224 Heap* heap = isolate->heap(); |
1221 v8::HandleScope scope(CcTest::isolate()); | 1225 v8::HandleScope scope(CcTest::isolate()); |
1222 | 1226 |
1223 CompileRun( | 1227 CompileRun( |
1224 "function make_closure(x) {" | 1228 "function make_closure(x) {" |
1225 " return function() { return x + 3 };" | 1229 " return function() { return x + 3 };" |
1226 "}" | 1230 "}" |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1354 } | 1358 } |
1355 | 1359 |
1356 | 1360 |
1357 TEST(TestInternalWeakLists) { | 1361 TEST(TestInternalWeakLists) { |
1358 FLAG_always_opt = false; | 1362 FLAG_always_opt = false; |
1359 FLAG_allow_natives_syntax = true; | 1363 FLAG_allow_natives_syntax = true; |
1360 v8::V8::Initialize(); | 1364 v8::V8::Initialize(); |
1361 | 1365 |
1362 // Some flags turn Scavenge collections into Mark-sweep collections | 1366 // Some flags turn Scavenge collections into Mark-sweep collections |
1363 // and hence are incompatible with this test case. | 1367 // and hence are incompatible with this test case. |
1364 if (FLAG_gc_global || FLAG_stress_compaction) return; | 1368 if (FLAG_gc_global || FLAG_stress_compaction || |
| 1369 FLAG_stress_incremental_marking) |
| 1370 return; |
1365 FLAG_retain_maps_for_n_gc = 0; | 1371 FLAG_retain_maps_for_n_gc = 0; |
1366 | 1372 |
1367 static const int kNumTestContexts = 10; | 1373 static const int kNumTestContexts = 10; |
1368 | 1374 |
1369 Isolate* isolate = CcTest::i_isolate(); | 1375 Isolate* isolate = CcTest::i_isolate(); |
1370 HandleScope scope(isolate); | 1376 HandleScope scope(isolate); |
1371 v8::Local<v8::Context> ctx[kNumTestContexts]; | 1377 v8::Local<v8::Context> ctx[kNumTestContexts]; |
1372 if (!isolate->use_optimizer()) return; | 1378 if (!isolate->use_optimizer()) return; |
1373 | 1379 |
1374 CHECK_EQ(0, CountNativeContexts()); | 1380 CHECK_EQ(0, CountNativeContexts()); |
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1951 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { | 1957 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { |
1952 if (obj->IsJSGlobalObject()) count++; | 1958 if (obj->IsJSGlobalObject()) count++; |
1953 } | 1959 } |
1954 return count; | 1960 return count; |
1955 } | 1961 } |
1956 | 1962 |
1957 | 1963 |
1958 // Test that we don't embed maps from foreign contexts into | 1964 // Test that we don't embed maps from foreign contexts into |
1959 // optimized code. | 1965 // optimized code. |
1960 TEST(LeakNativeContextViaMap) { | 1966 TEST(LeakNativeContextViaMap) { |
1961 i::FLAG_allow_natives_syntax = true; | 1967 FLAG_allow_natives_syntax = true; |
1962 v8::Isolate* isolate = CcTest::isolate(); | 1968 v8::Isolate* isolate = CcTest::isolate(); |
1963 v8::HandleScope outer_scope(isolate); | 1969 v8::HandleScope outer_scope(isolate); |
1964 v8::Persistent<v8::Context> ctx1p; | 1970 v8::Persistent<v8::Context> ctx1p; |
1965 v8::Persistent<v8::Context> ctx2p; | 1971 v8::Persistent<v8::Context> ctx2p; |
1966 { | 1972 { |
1967 v8::HandleScope scope(isolate); | 1973 v8::HandleScope scope(isolate); |
1968 ctx1p.Reset(isolate, v8::Context::New(isolate)); | 1974 ctx1p.Reset(isolate, v8::Context::New(isolate)); |
1969 ctx2p.Reset(isolate, v8::Context::New(isolate)); | 1975 ctx2p.Reset(isolate, v8::Context::New(isolate)); |
1970 v8::Local<v8::Context>::New(isolate, ctx1p)->Enter(); | 1976 v8::Local<v8::Context>::New(isolate, ctx1p)->Enter(); |
1971 } | 1977 } |
(...skipping 28 matching lines...) Expand all Loading... |
2000 CHECK_EQ(1, NumberOfGlobalObjects()); | 2006 CHECK_EQ(1, NumberOfGlobalObjects()); |
2001 ctx2p.Reset(); | 2007 ctx2p.Reset(); |
2002 CcTest::CollectAllAvailableGarbage(); | 2008 CcTest::CollectAllAvailableGarbage(); |
2003 CHECK_EQ(0, NumberOfGlobalObjects()); | 2009 CHECK_EQ(0, NumberOfGlobalObjects()); |
2004 } | 2010 } |
2005 | 2011 |
2006 | 2012 |
2007 // Test that we don't embed functions from foreign contexts into | 2013 // Test that we don't embed functions from foreign contexts into |
2008 // optimized code. | 2014 // optimized code. |
2009 TEST(LeakNativeContextViaFunction) { | 2015 TEST(LeakNativeContextViaFunction) { |
2010 i::FLAG_allow_natives_syntax = true; | 2016 FLAG_allow_natives_syntax = true; |
2011 v8::Isolate* isolate = CcTest::isolate(); | 2017 v8::Isolate* isolate = CcTest::isolate(); |
2012 v8::HandleScope outer_scope(isolate); | 2018 v8::HandleScope outer_scope(isolate); |
2013 v8::Persistent<v8::Context> ctx1p; | 2019 v8::Persistent<v8::Context> ctx1p; |
2014 v8::Persistent<v8::Context> ctx2p; | 2020 v8::Persistent<v8::Context> ctx2p; |
2015 { | 2021 { |
2016 v8::HandleScope scope(isolate); | 2022 v8::HandleScope scope(isolate); |
2017 ctx1p.Reset(isolate, v8::Context::New(isolate)); | 2023 ctx1p.Reset(isolate, v8::Context::New(isolate)); |
2018 ctx2p.Reset(isolate, v8::Context::New(isolate)); | 2024 ctx2p.Reset(isolate, v8::Context::New(isolate)); |
2019 v8::Local<v8::Context>::New(isolate, ctx1p)->Enter(); | 2025 v8::Local<v8::Context>::New(isolate, ctx1p)->Enter(); |
2020 } | 2026 } |
(...skipping 26 matching lines...) Expand all Loading... |
2047 } | 2053 } |
2048 CcTest::CollectAllAvailableGarbage(); | 2054 CcTest::CollectAllAvailableGarbage(); |
2049 CHECK_EQ(1, NumberOfGlobalObjects()); | 2055 CHECK_EQ(1, NumberOfGlobalObjects()); |
2050 ctx2p.Reset(); | 2056 ctx2p.Reset(); |
2051 CcTest::CollectAllAvailableGarbage(); | 2057 CcTest::CollectAllAvailableGarbage(); |
2052 CHECK_EQ(0, NumberOfGlobalObjects()); | 2058 CHECK_EQ(0, NumberOfGlobalObjects()); |
2053 } | 2059 } |
2054 | 2060 |
2055 | 2061 |
2056 TEST(LeakNativeContextViaMapKeyed) { | 2062 TEST(LeakNativeContextViaMapKeyed) { |
2057 i::FLAG_allow_natives_syntax = true; | 2063 FLAG_allow_natives_syntax = true; |
2058 v8::Isolate* isolate = CcTest::isolate(); | 2064 v8::Isolate* isolate = CcTest::isolate(); |
2059 v8::HandleScope outer_scope(isolate); | 2065 v8::HandleScope outer_scope(isolate); |
2060 v8::Persistent<v8::Context> ctx1p; | 2066 v8::Persistent<v8::Context> ctx1p; |
2061 v8::Persistent<v8::Context> ctx2p; | 2067 v8::Persistent<v8::Context> ctx2p; |
2062 { | 2068 { |
2063 v8::HandleScope scope(isolate); | 2069 v8::HandleScope scope(isolate); |
2064 ctx1p.Reset(isolate, v8::Context::New(isolate)); | 2070 ctx1p.Reset(isolate, v8::Context::New(isolate)); |
2065 ctx2p.Reset(isolate, v8::Context::New(isolate)); | 2071 ctx2p.Reset(isolate, v8::Context::New(isolate)); |
2066 v8::Local<v8::Context>::New(isolate, ctx1p)->Enter(); | 2072 v8::Local<v8::Context>::New(isolate, ctx1p)->Enter(); |
2067 } | 2073 } |
(...skipping 26 matching lines...) Expand all Loading... |
2094 } | 2100 } |
2095 CcTest::CollectAllAvailableGarbage(); | 2101 CcTest::CollectAllAvailableGarbage(); |
2096 CHECK_EQ(1, NumberOfGlobalObjects()); | 2102 CHECK_EQ(1, NumberOfGlobalObjects()); |
2097 ctx2p.Reset(); | 2103 ctx2p.Reset(); |
2098 CcTest::CollectAllAvailableGarbage(); | 2104 CcTest::CollectAllAvailableGarbage(); |
2099 CHECK_EQ(0, NumberOfGlobalObjects()); | 2105 CHECK_EQ(0, NumberOfGlobalObjects()); |
2100 } | 2106 } |
2101 | 2107 |
2102 | 2108 |
2103 TEST(LeakNativeContextViaMapProto) { | 2109 TEST(LeakNativeContextViaMapProto) { |
2104 i::FLAG_allow_natives_syntax = true; | 2110 FLAG_allow_natives_syntax = true; |
2105 v8::Isolate* isolate = CcTest::isolate(); | 2111 v8::Isolate* isolate = CcTest::isolate(); |
2106 v8::HandleScope outer_scope(isolate); | 2112 v8::HandleScope outer_scope(isolate); |
2107 v8::Persistent<v8::Context> ctx1p; | 2113 v8::Persistent<v8::Context> ctx1p; |
2108 v8::Persistent<v8::Context> ctx2p; | 2114 v8::Persistent<v8::Context> ctx2p; |
2109 { | 2115 { |
2110 v8::HandleScope scope(isolate); | 2116 v8::HandleScope scope(isolate); |
2111 ctx1p.Reset(isolate, v8::Context::New(isolate)); | 2117 ctx1p.Reset(isolate, v8::Context::New(isolate)); |
2112 ctx2p.Reset(isolate, v8::Context::New(isolate)); | 2118 ctx2p.Reset(isolate, v8::Context::New(isolate)); |
2113 v8::Local<v8::Context>::New(isolate, ctx1p)->Enter(); | 2119 v8::Local<v8::Context>::New(isolate, ctx1p)->Enter(); |
2114 } | 2120 } |
(...skipping 30 matching lines...) Expand all Loading... |
2145 } | 2151 } |
2146 CcTest::CollectAllAvailableGarbage(); | 2152 CcTest::CollectAllAvailableGarbage(); |
2147 CHECK_EQ(1, NumberOfGlobalObjects()); | 2153 CHECK_EQ(1, NumberOfGlobalObjects()); |
2148 ctx2p.Reset(); | 2154 ctx2p.Reset(); |
2149 CcTest::CollectAllAvailableGarbage(); | 2155 CcTest::CollectAllAvailableGarbage(); |
2150 CHECK_EQ(0, NumberOfGlobalObjects()); | 2156 CHECK_EQ(0, NumberOfGlobalObjects()); |
2151 } | 2157 } |
2152 | 2158 |
2153 | 2159 |
2154 TEST(InstanceOfStubWriteBarrier) { | 2160 TEST(InstanceOfStubWriteBarrier) { |
2155 if (!i::FLAG_incremental_marking) return; | 2161 if (!FLAG_incremental_marking) return; |
2156 i::FLAG_allow_natives_syntax = true; | 2162 FLAG_stress_incremental_marking = false; |
| 2163 FLAG_allow_natives_syntax = true; |
2157 #ifdef VERIFY_HEAP | 2164 #ifdef VERIFY_HEAP |
2158 i::FLAG_verify_heap = true; | 2165 FLAG_verify_heap = true; |
2159 #endif | 2166 #endif |
2160 | 2167 |
2161 CcTest::InitializeVM(); | 2168 CcTest::InitializeVM(); |
2162 if (!CcTest::i_isolate()->use_optimizer()) return; | 2169 if (!CcTest::i_isolate()->use_optimizer()) return; |
2163 if (i::FLAG_force_marking_deque_overflows) return; | 2170 if (FLAG_force_marking_deque_overflows) return; |
2164 v8::HandleScope outer_scope(CcTest::isolate()); | 2171 v8::HandleScope outer_scope(CcTest::isolate()); |
2165 v8::Local<v8::Context> ctx = CcTest::isolate()->GetCurrentContext(); | 2172 v8::Local<v8::Context> ctx = CcTest::isolate()->GetCurrentContext(); |
2166 | 2173 |
2167 { | 2174 { |
2168 v8::HandleScope scope(CcTest::isolate()); | 2175 v8::HandleScope scope(CcTest::isolate()); |
2169 CompileRun( | 2176 CompileRun( |
2170 "function foo () { }" | 2177 "function foo () { }" |
2171 "function mkbar () { return new (new Function(\"\")) (); }" | 2178 "function mkbar () { return new (new Function(\"\")) (); }" |
2172 "function f (x) { return (x instanceof foo); }" | 2179 "function f (x) { return (x instanceof foo); }" |
2173 "function g () { f(mkbar()); }" | 2180 "function g () { f(mkbar()); }" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2213 namespace { | 2220 namespace { |
2214 | 2221 |
2215 int GetProfilerTicks(SharedFunctionInfo* shared) { | 2222 int GetProfilerTicks(SharedFunctionInfo* shared) { |
2216 return FLAG_ignition || FLAG_turbo ? shared->profiler_ticks() | 2223 return FLAG_ignition || FLAG_turbo ? shared->profiler_ticks() |
2217 : shared->code()->profiler_ticks(); | 2224 : shared->code()->profiler_ticks(); |
2218 } | 2225 } |
2219 | 2226 |
2220 } // namespace | 2227 } // namespace |
2221 | 2228 |
2222 TEST(ResetSharedFunctionInfoCountersDuringIncrementalMarking) { | 2229 TEST(ResetSharedFunctionInfoCountersDuringIncrementalMarking) { |
2223 if (!i::FLAG_incremental_marking) return; | 2230 if (!FLAG_incremental_marking) return; |
2224 i::FLAG_stress_compaction = false; | 2231 FLAG_stress_compaction = false; |
2225 i::FLAG_allow_natives_syntax = true; | 2232 FLAG_stress_incremental_marking = false; |
| 2233 FLAG_allow_natives_syntax = true; |
2226 #ifdef VERIFY_HEAP | 2234 #ifdef VERIFY_HEAP |
2227 i::FLAG_verify_heap = true; | 2235 FLAG_verify_heap = true; |
2228 #endif | 2236 #endif |
2229 | 2237 |
2230 CcTest::InitializeVM(); | 2238 CcTest::InitializeVM(); |
2231 if (!CcTest::i_isolate()->use_optimizer()) return; | 2239 if (!CcTest::i_isolate()->use_optimizer()) return; |
2232 v8::HandleScope outer_scope(CcTest::isolate()); | 2240 v8::HandleScope outer_scope(CcTest::isolate()); |
2233 v8::Local<v8::Context> ctx = CcTest::isolate()->GetCurrentContext(); | 2241 v8::Local<v8::Context> ctx = CcTest::isolate()->GetCurrentContext(); |
2234 | 2242 |
2235 { | 2243 { |
2236 v8::HandleScope scope(CcTest::isolate()); | 2244 v8::HandleScope scope(CcTest::isolate()); |
2237 CompileRun( | 2245 CompileRun( |
(...skipping 21 matching lines...) Expand all Loading... |
2259 heap::SimulateIncrementalMarking(CcTest::heap()); | 2267 heap::SimulateIncrementalMarking(CcTest::heap()); |
2260 CcTest::CollectAllGarbage(); | 2268 CcTest::CollectAllGarbage(); |
2261 | 2269 |
2262 CHECK_EQ(CcTest::heap()->global_ic_age(), f->shared()->ic_age()); | 2270 CHECK_EQ(CcTest::heap()->global_ic_age(), f->shared()->ic_age()); |
2263 CHECK_EQ(0, f->shared()->opt_count()); | 2271 CHECK_EQ(0, f->shared()->opt_count()); |
2264 CHECK_EQ(0, GetProfilerTicks(f->shared())); | 2272 CHECK_EQ(0, GetProfilerTicks(f->shared())); |
2265 } | 2273 } |
2266 | 2274 |
2267 | 2275 |
2268 TEST(ResetSharedFunctionInfoCountersDuringMarkSweep) { | 2276 TEST(ResetSharedFunctionInfoCountersDuringMarkSweep) { |
2269 i::FLAG_stress_compaction = false; | 2277 FLAG_stress_compaction = false; |
2270 i::FLAG_allow_natives_syntax = true; | 2278 FLAG_stress_incremental_marking = false; |
| 2279 FLAG_allow_natives_syntax = true; |
2271 #ifdef VERIFY_HEAP | 2280 #ifdef VERIFY_HEAP |
2272 i::FLAG_verify_heap = true; | 2281 FLAG_verify_heap = true; |
2273 #endif | 2282 #endif |
2274 | 2283 |
2275 CcTest::InitializeVM(); | 2284 CcTest::InitializeVM(); |
2276 if (!CcTest::i_isolate()->use_optimizer()) return; | 2285 if (!CcTest::i_isolate()->use_optimizer()) return; |
2277 v8::HandleScope outer_scope(CcTest::isolate()); | 2286 v8::HandleScope outer_scope(CcTest::isolate()); |
2278 v8::Local<v8::Context> ctx = CcTest::isolate()->GetCurrentContext(); | 2287 v8::Local<v8::Context> ctx = CcTest::isolate()->GetCurrentContext(); |
2279 | 2288 |
2280 { | 2289 { |
2281 v8::HandleScope scope(CcTest::isolate()); | 2290 v8::HandleScope scope(CcTest::isolate()); |
2282 CompileRun( | 2291 CompileRun( |
(...skipping 18 matching lines...) Expand all Loading... |
2301 CcTest::isolate()->ContextDisposedNotification(); | 2310 CcTest::isolate()->ContextDisposedNotification(); |
2302 CcTest::CollectAllGarbage(); | 2311 CcTest::CollectAllGarbage(); |
2303 | 2312 |
2304 CHECK_EQ(CcTest::heap()->global_ic_age(), f->shared()->ic_age()); | 2313 CHECK_EQ(CcTest::heap()->global_ic_age(), f->shared()->ic_age()); |
2305 CHECK_EQ(0, f->shared()->opt_count()); | 2314 CHECK_EQ(0, f->shared()->opt_count()); |
2306 CHECK_EQ(0, GetProfilerTicks(f->shared())); | 2315 CHECK_EQ(0, GetProfilerTicks(f->shared())); |
2307 } | 2316 } |
2308 | 2317 |
2309 | 2318 |
2310 HEAP_TEST(GCFlags) { | 2319 HEAP_TEST(GCFlags) { |
2311 if (!i::FLAG_incremental_marking) return; | 2320 if (!FLAG_incremental_marking) return; |
2312 CcTest::InitializeVM(); | 2321 CcTest::InitializeVM(); |
2313 Heap* heap = CcTest::heap(); | 2322 Heap* heap = CcTest::heap(); |
2314 | 2323 |
2315 heap->set_current_gc_flags(Heap::kNoGCFlags); | 2324 heap->set_current_gc_flags(Heap::kNoGCFlags); |
2316 CHECK_EQ(Heap::kNoGCFlags, heap->current_gc_flags_); | 2325 CHECK_EQ(Heap::kNoGCFlags, heap->current_gc_flags_); |
2317 | 2326 |
2318 // Set the flags to check whether we appropriately resets them after the GC. | 2327 // Set the flags to check whether we appropriately resets them after the GC. |
2319 heap->set_current_gc_flags(Heap::kAbortIncrementalMarkingMask); | 2328 heap->set_current_gc_flags(Heap::kAbortIncrementalMarkingMask); |
2320 CcTest::CollectAllGarbage(Heap::kReduceMemoryFootprintMask); | 2329 CcTest::CollectAllGarbage(Heap::kReduceMemoryFootprintMask); |
2321 CHECK_EQ(Heap::kNoGCFlags, heap->current_gc_flags_); | 2330 CHECK_EQ(Heap::kNoGCFlags, heap->current_gc_flags_); |
(...skipping 12 matching lines...) Expand all Loading... |
2334 CcTest::CollectGarbage(NEW_SPACE); | 2343 CcTest::CollectGarbage(NEW_SPACE); |
2335 // NewSpace scavenges should not overwrite the flags. | 2344 // NewSpace scavenges should not overwrite the flags. |
2336 CHECK_NE(0, heap->current_gc_flags_ & Heap::kReduceMemoryFootprintMask); | 2345 CHECK_NE(0, heap->current_gc_flags_ & Heap::kReduceMemoryFootprintMask); |
2337 | 2346 |
2338 CcTest::CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); | 2347 CcTest::CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); |
2339 CHECK_EQ(Heap::kNoGCFlags, heap->current_gc_flags_); | 2348 CHECK_EQ(Heap::kNoGCFlags, heap->current_gc_flags_); |
2340 } | 2349 } |
2341 | 2350 |
2342 | 2351 |
2343 TEST(IdleNotificationFinishMarking) { | 2352 TEST(IdleNotificationFinishMarking) { |
2344 if (!i::FLAG_incremental_marking) return; | 2353 if (!FLAG_incremental_marking) return; |
2345 i::FLAG_allow_natives_syntax = true; | 2354 FLAG_stress_incremental_marking = false; |
| 2355 FLAG_allow_natives_syntax = true; |
2346 CcTest::InitializeVM(); | 2356 CcTest::InitializeVM(); |
2347 const int initial_gc_count = CcTest::heap()->gc_count(); | 2357 const int initial_gc_count = CcTest::heap()->gc_count(); |
2348 heap::SimulateFullSpace(CcTest::heap()->old_space()); | 2358 heap::SimulateFullSpace(CcTest::heap()->old_space()); |
2349 IncrementalMarking* marking = CcTest::heap()->incremental_marking(); | 2359 IncrementalMarking* marking = CcTest::heap()->incremental_marking(); |
2350 marking->Stop(); | 2360 marking->Stop(); |
2351 CcTest::heap()->StartIncrementalMarking(i::Heap::kNoGCFlags, | 2361 CcTest::heap()->StartIncrementalMarking(i::Heap::kNoGCFlags, |
2352 i::GarbageCollectionReason::kTesting); | 2362 i::GarbageCollectionReason::kTesting); |
2353 | 2363 |
2354 CHECK_EQ(CcTest::heap()->gc_count(), initial_gc_count); | 2364 CHECK_EQ(CcTest::heap()->gc_count(), initial_gc_count); |
2355 | 2365 |
(...skipping 26 matching lines...) Expand all Loading... |
2382 CcTest::isolate()->IdleNotificationDeadline( | 2392 CcTest::isolate()->IdleNotificationDeadline( |
2383 (v8::base::TimeTicks::HighResolutionNow().ToInternalValue() / | 2393 (v8::base::TimeTicks::HighResolutionNow().ToInternalValue() / |
2384 static_cast<double>(v8::base::Time::kMicrosecondsPerSecond)) + | 2394 static_cast<double>(v8::base::Time::kMicrosecondsPerSecond)) + |
2385 kLongIdleTime); | 2395 kLongIdleTime); |
2386 CHECK_EQ(CcTest::heap()->gc_count(), initial_gc_count + 1); | 2396 CHECK_EQ(CcTest::heap()->gc_count(), initial_gc_count + 1); |
2387 } | 2397 } |
2388 | 2398 |
2389 | 2399 |
2390 // Test that HAllocateObject will always return an object in new-space. | 2400 // Test that HAllocateObject will always return an object in new-space. |
2391 TEST(OptimizedAllocationAlwaysInNewSpace) { | 2401 TEST(OptimizedAllocationAlwaysInNewSpace) { |
2392 i::FLAG_allow_natives_syntax = true; | 2402 FLAG_allow_natives_syntax = true; |
2393 CcTest::InitializeVM(); | 2403 CcTest::InitializeVM(); |
2394 if (!CcTest::i_isolate()->use_optimizer() || i::FLAG_always_opt) return; | 2404 if (!CcTest::i_isolate()->use_optimizer() || FLAG_always_opt) return; |
2395 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2405 if (FLAG_gc_global || FLAG_stress_compaction || |
| 2406 FLAG_stress_incremental_marking) |
| 2407 return; |
2396 v8::HandleScope scope(CcTest::isolate()); | 2408 v8::HandleScope scope(CcTest::isolate()); |
2397 v8::Local<v8::Context> ctx = CcTest::isolate()->GetCurrentContext(); | 2409 v8::Local<v8::Context> ctx = CcTest::isolate()->GetCurrentContext(); |
2398 heap::SimulateFullSpace(CcTest::heap()->new_space()); | 2410 heap::SimulateFullSpace(CcTest::heap()->new_space()); |
2399 AlwaysAllocateScope always_allocate(CcTest::i_isolate()); | 2411 AlwaysAllocateScope always_allocate(CcTest::i_isolate()); |
2400 v8::Local<v8::Value> res = CompileRun( | 2412 v8::Local<v8::Value> res = CompileRun( |
2401 "function c(x) {" | 2413 "function c(x) {" |
2402 " this.x = x;" | 2414 " this.x = x;" |
2403 " for (var i = 0; i < 32; i++) {" | 2415 " for (var i = 0; i < 32; i++) {" |
2404 " this['x' + i] = x;" | 2416 " this['x' + i] = x;" |
2405 " }" | 2417 " }" |
(...skipping 10 matching lines...) Expand all Loading... |
2416 .FromJust()); | 2428 .FromJust()); |
2417 | 2429 |
2418 i::Handle<JSReceiver> o = | 2430 i::Handle<JSReceiver> o = |
2419 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(res)); | 2431 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(res)); |
2420 | 2432 |
2421 CHECK(CcTest::heap()->InNewSpace(*o)); | 2433 CHECK(CcTest::heap()->InNewSpace(*o)); |
2422 } | 2434 } |
2423 | 2435 |
2424 | 2436 |
2425 TEST(OptimizedPretenuringAllocationFolding) { | 2437 TEST(OptimizedPretenuringAllocationFolding) { |
2426 i::FLAG_allow_natives_syntax = true; | 2438 FLAG_allow_natives_syntax = true; |
2427 i::FLAG_expose_gc = true; | 2439 FLAG_expose_gc = true; |
2428 CcTest::InitializeVM(); | 2440 CcTest::InitializeVM(); |
2429 if (!CcTest::i_isolate()->use_optimizer() || i::FLAG_always_opt) return; | 2441 if (!CcTest::i_isolate()->use_optimizer() || FLAG_always_opt) return; |
2430 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2442 if (FLAG_gc_global || FLAG_stress_compaction || |
| 2443 FLAG_stress_incremental_marking) |
| 2444 return; |
2431 v8::HandleScope scope(CcTest::isolate()); | 2445 v8::HandleScope scope(CcTest::isolate()); |
2432 v8::Local<v8::Context> ctx = CcTest::isolate()->GetCurrentContext(); | 2446 v8::Local<v8::Context> ctx = CcTest::isolate()->GetCurrentContext(); |
2433 // Grow new space unitl maximum capacity reached. | 2447 // Grow new space unitl maximum capacity reached. |
2434 while (!CcTest::heap()->new_space()->IsAtMaximumCapacity()) { | 2448 while (!CcTest::heap()->new_space()->IsAtMaximumCapacity()) { |
2435 CcTest::heap()->new_space()->Grow(); | 2449 CcTest::heap()->new_space()->Grow(); |
2436 } | 2450 } |
2437 | 2451 |
2438 i::ScopedVector<char> source(1024); | 2452 i::ScopedVector<char> source(1024); |
2439 i::SNPrintF( | 2453 i::SNPrintF( |
2440 source, | 2454 source, |
(...skipping 26 matching lines...) Expand all Loading... |
2467 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(res)); | 2481 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(res)); |
2468 CHECK(CcTest::heap()->InOldSpace(*o)); | 2482 CHECK(CcTest::heap()->InOldSpace(*o)); |
2469 CHECK(CcTest::heap()->InOldSpace(*int_array_handle)); | 2483 CHECK(CcTest::heap()->InOldSpace(*int_array_handle)); |
2470 CHECK(CcTest::heap()->InOldSpace(int_array_handle->elements())); | 2484 CHECK(CcTest::heap()->InOldSpace(int_array_handle->elements())); |
2471 CHECK(CcTest::heap()->InOldSpace(*double_array_handle)); | 2485 CHECK(CcTest::heap()->InOldSpace(*double_array_handle)); |
2472 CHECK(CcTest::heap()->InOldSpace(double_array_handle->elements())); | 2486 CHECK(CcTest::heap()->InOldSpace(double_array_handle->elements())); |
2473 } | 2487 } |
2474 | 2488 |
2475 | 2489 |
2476 TEST(OptimizedPretenuringObjectArrayLiterals) { | 2490 TEST(OptimizedPretenuringObjectArrayLiterals) { |
2477 i::FLAG_allow_natives_syntax = true; | 2491 FLAG_allow_natives_syntax = true; |
2478 i::FLAG_expose_gc = true; | 2492 FLAG_expose_gc = true; |
2479 CcTest::InitializeVM(); | 2493 CcTest::InitializeVM(); |
2480 if (!CcTest::i_isolate()->use_optimizer() || i::FLAG_always_opt) return; | 2494 if (!CcTest::i_isolate()->use_optimizer() || FLAG_always_opt) return; |
2481 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2495 if (FLAG_gc_global || FLAG_stress_compaction || |
| 2496 FLAG_stress_incremental_marking) |
| 2497 return; |
2482 v8::HandleScope scope(CcTest::isolate()); | 2498 v8::HandleScope scope(CcTest::isolate()); |
2483 | 2499 |
2484 // Grow new space unitl maximum capacity reached. | 2500 // Grow new space unitl maximum capacity reached. |
2485 while (!CcTest::heap()->new_space()->IsAtMaximumCapacity()) { | 2501 while (!CcTest::heap()->new_space()->IsAtMaximumCapacity()) { |
2486 CcTest::heap()->new_space()->Grow(); | 2502 CcTest::heap()->new_space()->Grow(); |
2487 } | 2503 } |
2488 | 2504 |
2489 i::ScopedVector<char> source(1024); | 2505 i::ScopedVector<char> source(1024); |
2490 i::SNPrintF( | 2506 i::SNPrintF( |
2491 source, | 2507 source, |
(...skipping 15 matching lines...) Expand all Loading... |
2507 | 2523 |
2508 i::Handle<JSObject> o = Handle<JSObject>::cast( | 2524 i::Handle<JSObject> o = Handle<JSObject>::cast( |
2509 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(res))); | 2525 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(res))); |
2510 | 2526 |
2511 CHECK(CcTest::heap()->InOldSpace(o->elements())); | 2527 CHECK(CcTest::heap()->InOldSpace(o->elements())); |
2512 CHECK(CcTest::heap()->InOldSpace(*o)); | 2528 CHECK(CcTest::heap()->InOldSpace(*o)); |
2513 } | 2529 } |
2514 | 2530 |
2515 | 2531 |
2516 TEST(OptimizedPretenuringMixedInObjectProperties) { | 2532 TEST(OptimizedPretenuringMixedInObjectProperties) { |
2517 i::FLAG_allow_natives_syntax = true; | 2533 FLAG_allow_natives_syntax = true; |
2518 i::FLAG_expose_gc = true; | 2534 FLAG_expose_gc = true; |
2519 CcTest::InitializeVM(); | 2535 CcTest::InitializeVM(); |
2520 if (!CcTest::i_isolate()->use_optimizer() || i::FLAG_always_opt) return; | 2536 if (!CcTest::i_isolate()->use_optimizer() || FLAG_always_opt) return; |
2521 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2537 if (FLAG_gc_global || FLAG_stress_compaction || |
| 2538 FLAG_stress_incremental_marking) |
| 2539 return; |
2522 v8::HandleScope scope(CcTest::isolate()); | 2540 v8::HandleScope scope(CcTest::isolate()); |
2523 | 2541 |
2524 // Grow new space unitl maximum capacity reached. | 2542 // Grow new space unitl maximum capacity reached. |
2525 while (!CcTest::heap()->new_space()->IsAtMaximumCapacity()) { | 2543 while (!CcTest::heap()->new_space()->IsAtMaximumCapacity()) { |
2526 CcTest::heap()->new_space()->Grow(); | 2544 CcTest::heap()->new_space()->Grow(); |
2527 } | 2545 } |
2528 | 2546 |
2529 | 2547 |
2530 i::ScopedVector<char> source(1024); | 2548 i::ScopedVector<char> source(1024); |
2531 i::SNPrintF( | 2549 i::SNPrintF( |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2565 if (!inner_object->IsUnboxedDoubleField(idx1)) { | 2583 if (!inner_object->IsUnboxedDoubleField(idx1)) { |
2566 CHECK(CcTest::heap()->InOldSpace(inner_object->RawFastPropertyAt(idx1))); | 2584 CHECK(CcTest::heap()->InOldSpace(inner_object->RawFastPropertyAt(idx1))); |
2567 } else { | 2585 } else { |
2568 CHECK_EQ(2.2, inner_object->RawFastDoublePropertyAt(idx1)); | 2586 CHECK_EQ(2.2, inner_object->RawFastDoublePropertyAt(idx1)); |
2569 } | 2587 } |
2570 CHECK(CcTest::heap()->InOldSpace(inner_object->RawFastPropertyAt(idx2))); | 2588 CHECK(CcTest::heap()->InOldSpace(inner_object->RawFastPropertyAt(idx2))); |
2571 } | 2589 } |
2572 | 2590 |
2573 | 2591 |
2574 TEST(OptimizedPretenuringDoubleArrayProperties) { | 2592 TEST(OptimizedPretenuringDoubleArrayProperties) { |
2575 i::FLAG_allow_natives_syntax = true; | 2593 FLAG_allow_natives_syntax = true; |
2576 i::FLAG_expose_gc = true; | 2594 FLAG_expose_gc = true; |
2577 CcTest::InitializeVM(); | 2595 CcTest::InitializeVM(); |
2578 if (!CcTest::i_isolate()->use_optimizer() || i::FLAG_always_opt) return; | 2596 if (!CcTest::i_isolate()->use_optimizer() || FLAG_always_opt) return; |
2579 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2597 if (FLAG_gc_global || FLAG_stress_compaction || |
| 2598 FLAG_stress_incremental_marking) |
| 2599 return; |
2580 v8::HandleScope scope(CcTest::isolate()); | 2600 v8::HandleScope scope(CcTest::isolate()); |
2581 | 2601 |
2582 // Grow new space unitl maximum capacity reached. | 2602 // Grow new space unitl maximum capacity reached. |
2583 while (!CcTest::heap()->new_space()->IsAtMaximumCapacity()) { | 2603 while (!CcTest::heap()->new_space()->IsAtMaximumCapacity()) { |
2584 CcTest::heap()->new_space()->Grow(); | 2604 CcTest::heap()->new_space()->Grow(); |
2585 } | 2605 } |
2586 | 2606 |
2587 i::ScopedVector<char> source(1024); | 2607 i::ScopedVector<char> source(1024); |
2588 i::SNPrintF( | 2608 i::SNPrintF( |
2589 source, | 2609 source, |
(...skipping 15 matching lines...) Expand all Loading... |
2605 | 2625 |
2606 i::Handle<JSObject> o = Handle<JSObject>::cast( | 2626 i::Handle<JSObject> o = Handle<JSObject>::cast( |
2607 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(res))); | 2627 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(res))); |
2608 | 2628 |
2609 CHECK(CcTest::heap()->InOldSpace(*o)); | 2629 CHECK(CcTest::heap()->InOldSpace(*o)); |
2610 CHECK(CcTest::heap()->InOldSpace(o->properties())); | 2630 CHECK(CcTest::heap()->InOldSpace(o->properties())); |
2611 } | 2631 } |
2612 | 2632 |
2613 | 2633 |
2614 TEST(OptimizedPretenuringdoubleArrayLiterals) { | 2634 TEST(OptimizedPretenuringdoubleArrayLiterals) { |
2615 i::FLAG_allow_natives_syntax = true; | 2635 FLAG_allow_natives_syntax = true; |
2616 i::FLAG_expose_gc = true; | 2636 FLAG_expose_gc = true; |
2617 CcTest::InitializeVM(); | 2637 CcTest::InitializeVM(); |
2618 if (!CcTest::i_isolate()->use_optimizer() || i::FLAG_always_opt) return; | 2638 if (!CcTest::i_isolate()->use_optimizer() || FLAG_always_opt) return; |
2619 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2639 if (FLAG_gc_global || FLAG_stress_compaction || |
| 2640 FLAG_stress_incremental_marking) |
| 2641 return; |
2620 v8::HandleScope scope(CcTest::isolate()); | 2642 v8::HandleScope scope(CcTest::isolate()); |
2621 | 2643 |
2622 // Grow new space unitl maximum capacity reached. | 2644 // Grow new space unitl maximum capacity reached. |
2623 while (!CcTest::heap()->new_space()->IsAtMaximumCapacity()) { | 2645 while (!CcTest::heap()->new_space()->IsAtMaximumCapacity()) { |
2624 CcTest::heap()->new_space()->Grow(); | 2646 CcTest::heap()->new_space()->Grow(); |
2625 } | 2647 } |
2626 | 2648 |
2627 i::ScopedVector<char> source(1024); | 2649 i::ScopedVector<char> source(1024); |
2628 i::SNPrintF( | 2650 i::SNPrintF( |
2629 source, | 2651 source, |
(...skipping 15 matching lines...) Expand all Loading... |
2645 | 2667 |
2646 i::Handle<JSObject> o = Handle<JSObject>::cast( | 2668 i::Handle<JSObject> o = Handle<JSObject>::cast( |
2647 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(res))); | 2669 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(res))); |
2648 | 2670 |
2649 CHECK(CcTest::heap()->InOldSpace(o->elements())); | 2671 CHECK(CcTest::heap()->InOldSpace(o->elements())); |
2650 CHECK(CcTest::heap()->InOldSpace(*o)); | 2672 CHECK(CcTest::heap()->InOldSpace(*o)); |
2651 } | 2673 } |
2652 | 2674 |
2653 | 2675 |
2654 TEST(OptimizedPretenuringNestedMixedArrayLiterals) { | 2676 TEST(OptimizedPretenuringNestedMixedArrayLiterals) { |
2655 i::FLAG_allow_natives_syntax = true; | 2677 FLAG_allow_natives_syntax = true; |
2656 i::FLAG_expose_gc = true; | 2678 FLAG_expose_gc = true; |
2657 CcTest::InitializeVM(); | 2679 CcTest::InitializeVM(); |
2658 if (!CcTest::i_isolate()->use_optimizer() || i::FLAG_always_opt) return; | 2680 if (!CcTest::i_isolate()->use_optimizer() || FLAG_always_opt) return; |
2659 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2681 if (FLAG_gc_global || FLAG_stress_compaction || |
| 2682 FLAG_stress_incremental_marking) |
| 2683 return; |
2660 v8::HandleScope scope(CcTest::isolate()); | 2684 v8::HandleScope scope(CcTest::isolate()); |
2661 v8::Local<v8::Context> ctx = CcTest::isolate()->GetCurrentContext(); | 2685 v8::Local<v8::Context> ctx = CcTest::isolate()->GetCurrentContext(); |
2662 // Grow new space unitl maximum capacity reached. | 2686 // Grow new space unitl maximum capacity reached. |
2663 while (!CcTest::heap()->new_space()->IsAtMaximumCapacity()) { | 2687 while (!CcTest::heap()->new_space()->IsAtMaximumCapacity()) { |
2664 CcTest::heap()->new_space()->Grow(); | 2688 CcTest::heap()->new_space()->Grow(); |
2665 } | 2689 } |
2666 | 2690 |
2667 i::ScopedVector<char> source(1024); | 2691 i::ScopedVector<char> source(1024); |
2668 i::SNPrintF( | 2692 i::SNPrintF( |
2669 source, | 2693 source, |
(...skipping 25 matching lines...) Expand all Loading... |
2695 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(res))); | 2719 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(res))); |
2696 CHECK(CcTest::heap()->InOldSpace(*o)); | 2720 CHECK(CcTest::heap()->InOldSpace(*o)); |
2697 CHECK(CcTest::heap()->InOldSpace(*int_array_handle)); | 2721 CHECK(CcTest::heap()->InOldSpace(*int_array_handle)); |
2698 CHECK(CcTest::heap()->InOldSpace(int_array_handle->elements())); | 2722 CHECK(CcTest::heap()->InOldSpace(int_array_handle->elements())); |
2699 CHECK(CcTest::heap()->InOldSpace(*double_array_handle)); | 2723 CHECK(CcTest::heap()->InOldSpace(*double_array_handle)); |
2700 CHECK(CcTest::heap()->InOldSpace(double_array_handle->elements())); | 2724 CHECK(CcTest::heap()->InOldSpace(double_array_handle->elements())); |
2701 } | 2725 } |
2702 | 2726 |
2703 | 2727 |
2704 TEST(OptimizedPretenuringNestedObjectLiterals) { | 2728 TEST(OptimizedPretenuringNestedObjectLiterals) { |
2705 i::FLAG_allow_natives_syntax = true; | 2729 FLAG_allow_natives_syntax = true; |
2706 i::FLAG_expose_gc = true; | 2730 FLAG_expose_gc = true; |
2707 CcTest::InitializeVM(); | 2731 CcTest::InitializeVM(); |
2708 if (!CcTest::i_isolate()->use_optimizer() || i::FLAG_always_opt) return; | 2732 if (!CcTest::i_isolate()->use_optimizer() || FLAG_always_opt) return; |
2709 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2733 if (FLAG_gc_global || FLAG_stress_compaction || |
| 2734 FLAG_stress_incremental_marking) |
| 2735 return; |
2710 v8::HandleScope scope(CcTest::isolate()); | 2736 v8::HandleScope scope(CcTest::isolate()); |
2711 v8::Local<v8::Context> ctx = CcTest::isolate()->GetCurrentContext(); | 2737 v8::Local<v8::Context> ctx = CcTest::isolate()->GetCurrentContext(); |
2712 // Grow new space unitl maximum capacity reached. | 2738 // Grow new space unitl maximum capacity reached. |
2713 while (!CcTest::heap()->new_space()->IsAtMaximumCapacity()) { | 2739 while (!CcTest::heap()->new_space()->IsAtMaximumCapacity()) { |
2714 CcTest::heap()->new_space()->Grow(); | 2740 CcTest::heap()->new_space()->Grow(); |
2715 } | 2741 } |
2716 | 2742 |
2717 i::ScopedVector<char> source(1024); | 2743 i::ScopedVector<char> source(1024); |
2718 i::SNPrintF( | 2744 i::SNPrintF( |
2719 source, | 2745 source, |
(...skipping 26 matching lines...) Expand all Loading... |
2746 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(res))); | 2772 v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(res))); |
2747 CHECK(CcTest::heap()->InOldSpace(*o)); | 2773 CHECK(CcTest::heap()->InOldSpace(*o)); |
2748 CHECK(CcTest::heap()->InOldSpace(*int_array_handle_1)); | 2774 CHECK(CcTest::heap()->InOldSpace(*int_array_handle_1)); |
2749 CHECK(CcTest::heap()->InOldSpace(int_array_handle_1->elements())); | 2775 CHECK(CcTest::heap()->InOldSpace(int_array_handle_1->elements())); |
2750 CHECK(CcTest::heap()->InOldSpace(*int_array_handle_2)); | 2776 CHECK(CcTest::heap()->InOldSpace(*int_array_handle_2)); |
2751 CHECK(CcTest::heap()->InOldSpace(int_array_handle_2->elements())); | 2777 CHECK(CcTest::heap()->InOldSpace(int_array_handle_2->elements())); |
2752 } | 2778 } |
2753 | 2779 |
2754 | 2780 |
2755 TEST(OptimizedPretenuringNestedDoubleLiterals) { | 2781 TEST(OptimizedPretenuringNestedDoubleLiterals) { |
2756 i::FLAG_allow_natives_syntax = true; | 2782 FLAG_allow_natives_syntax = true; |
2757 i::FLAG_expose_gc = true; | 2783 FLAG_expose_gc = true; |
2758 CcTest::InitializeVM(); | 2784 CcTest::InitializeVM(); |
2759 if (!CcTest::i_isolate()->use_optimizer() || i::FLAG_always_opt) return; | 2785 if (!CcTest::i_isolate()->use_optimizer() || FLAG_always_opt) return; |
2760 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2786 if (FLAG_gc_global || FLAG_stress_compaction || |
| 2787 FLAG_stress_incremental_marking) |
| 2788 return; |
2761 v8::HandleScope scope(CcTest::isolate()); | 2789 v8::HandleScope scope(CcTest::isolate()); |
2762 v8::Local<v8::Context> ctx = CcTest::isolate()->GetCurrentContext(); | 2790 v8::Local<v8::Context> ctx = CcTest::isolate()->GetCurrentContext(); |
2763 // Grow new space unitl maximum capacity reached. | 2791 // Grow new space unitl maximum capacity reached. |
2764 while (!CcTest::heap()->new_space()->IsAtMaximumCapacity()) { | 2792 while (!CcTest::heap()->new_space()->IsAtMaximumCapacity()) { |
2765 CcTest::heap()->new_space()->Grow(); | 2793 CcTest::heap()->new_space()->Grow(); |
2766 } | 2794 } |
2767 | 2795 |
2768 i::ScopedVector<char> source(1024); | 2796 i::ScopedVector<char> source(1024); |
2769 i::SNPrintF( | 2797 i::SNPrintF( |
2770 source, | 2798 source, |
(...skipping 27 matching lines...) Expand all Loading... |
2798 CHECK(CcTest::heap()->InOldSpace(*o)); | 2826 CHECK(CcTest::heap()->InOldSpace(*o)); |
2799 CHECK(CcTest::heap()->InOldSpace(*double_array_handle_1)); | 2827 CHECK(CcTest::heap()->InOldSpace(*double_array_handle_1)); |
2800 CHECK(CcTest::heap()->InOldSpace(double_array_handle_1->elements())); | 2828 CHECK(CcTest::heap()->InOldSpace(double_array_handle_1->elements())); |
2801 CHECK(CcTest::heap()->InOldSpace(*double_array_handle_2)); | 2829 CHECK(CcTest::heap()->InOldSpace(*double_array_handle_2)); |
2802 CHECK(CcTest::heap()->InOldSpace(double_array_handle_2->elements())); | 2830 CHECK(CcTest::heap()->InOldSpace(double_array_handle_2->elements())); |
2803 } | 2831 } |
2804 | 2832 |
2805 | 2833 |
2806 // Test regular array literals allocation. | 2834 // Test regular array literals allocation. |
2807 TEST(OptimizedAllocationArrayLiterals) { | 2835 TEST(OptimizedAllocationArrayLiterals) { |
2808 i::FLAG_allow_natives_syntax = true; | 2836 FLAG_allow_natives_syntax = true; |
2809 CcTest::InitializeVM(); | 2837 CcTest::InitializeVM(); |
2810 if (!CcTest::i_isolate()->use_optimizer() || i::FLAG_always_opt) return; | 2838 if (!CcTest::i_isolate()->use_optimizer() || FLAG_always_opt) return; |
2811 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2839 if (FLAG_gc_global || FLAG_stress_compaction || |
| 2840 FLAG_stress_incremental_marking) |
| 2841 return; |
2812 v8::HandleScope scope(CcTest::isolate()); | 2842 v8::HandleScope scope(CcTest::isolate()); |
2813 v8::Local<v8::Context> ctx = CcTest::isolate()->GetCurrentContext(); | 2843 v8::Local<v8::Context> ctx = CcTest::isolate()->GetCurrentContext(); |
2814 v8::Local<v8::Value> res = CompileRun( | 2844 v8::Local<v8::Value> res = CompileRun( |
2815 "function f() {" | 2845 "function f() {" |
2816 " var numbers = new Array(1, 2, 3);" | 2846 " var numbers = new Array(1, 2, 3);" |
2817 " numbers[0] = 3.14;" | 2847 " numbers[0] = 3.14;" |
2818 " return numbers;" | 2848 " return numbers;" |
2819 "};" | 2849 "};" |
2820 "f(); f(); f();" | 2850 "f(); f(); f();" |
2821 "%OptimizeFunctionOnNextCall(f);" | 2851 "%OptimizeFunctionOnNextCall(f);" |
(...skipping 12 matching lines...) Expand all Loading... |
2834 | 2864 |
2835 | 2865 |
2836 static int CountMapTransitions(Map* map) { | 2866 static int CountMapTransitions(Map* map) { |
2837 return TransitionArray::NumberOfTransitions(map->raw_transitions()); | 2867 return TransitionArray::NumberOfTransitions(map->raw_transitions()); |
2838 } | 2868 } |
2839 | 2869 |
2840 | 2870 |
2841 // Test that map transitions are cleared and maps are collected with | 2871 // Test that map transitions are cleared and maps are collected with |
2842 // incremental marking as well. | 2872 // incremental marking as well. |
2843 TEST(Regress1465) { | 2873 TEST(Regress1465) { |
2844 if (!i::FLAG_incremental_marking) return; | 2874 if (!FLAG_incremental_marking) return; |
2845 i::FLAG_stress_compaction = false; | 2875 FLAG_stress_compaction = false; |
2846 i::FLAG_allow_natives_syntax = true; | 2876 FLAG_stress_incremental_marking = false; |
2847 i::FLAG_trace_incremental_marking = true; | 2877 FLAG_allow_natives_syntax = true; |
2848 i::FLAG_retain_maps_for_n_gc = 0; | 2878 FLAG_trace_incremental_marking = true; |
| 2879 FLAG_retain_maps_for_n_gc = 0; |
2849 CcTest::InitializeVM(); | 2880 CcTest::InitializeVM(); |
2850 v8::HandleScope scope(CcTest::isolate()); | 2881 v8::HandleScope scope(CcTest::isolate()); |
2851 v8::Local<v8::Context> ctx = CcTest::isolate()->GetCurrentContext(); | 2882 v8::Local<v8::Context> ctx = CcTest::isolate()->GetCurrentContext(); |
2852 static const int transitions_count = 256; | 2883 static const int transitions_count = 256; |
2853 | 2884 |
2854 CompileRun("function F() {}"); | 2885 CompileRun("function F() {}"); |
2855 { | 2886 { |
2856 AlwaysAllocateScope always_allocate(CcTest::i_isolate()); | 2887 AlwaysAllocateScope always_allocate(CcTest::i_isolate()); |
2857 for (int i = 0; i < transitions_count; i++) { | 2888 for (int i = 0; i < transitions_count; i++) { |
2858 EmbeddedVector<char, 64> buffer; | 2889 EmbeddedVector<char, 64> buffer; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2901 .ToLocalChecked()))); | 2932 .ToLocalChecked()))); |
2902 } | 2933 } |
2903 | 2934 |
2904 | 2935 |
2905 static void AddPropertyTo( | 2936 static void AddPropertyTo( |
2906 int gc_count, Handle<JSObject> object, const char* property_name) { | 2937 int gc_count, Handle<JSObject> object, const char* property_name) { |
2907 Isolate* isolate = CcTest::i_isolate(); | 2938 Isolate* isolate = CcTest::i_isolate(); |
2908 Factory* factory = isolate->factory(); | 2939 Factory* factory = isolate->factory(); |
2909 Handle<String> prop_name = factory->InternalizeUtf8String(property_name); | 2940 Handle<String> prop_name = factory->InternalizeUtf8String(property_name); |
2910 Handle<Smi> twenty_three(Smi::FromInt(23), isolate); | 2941 Handle<Smi> twenty_three(Smi::FromInt(23), isolate); |
2911 i::FLAG_gc_interval = gc_count; | 2942 FLAG_gc_interval = gc_count; |
2912 i::FLAG_gc_global = true; | 2943 FLAG_gc_global = true; |
2913 i::FLAG_retain_maps_for_n_gc = 0; | 2944 FLAG_retain_maps_for_n_gc = 0; |
2914 CcTest::heap()->set_allocation_timeout(gc_count); | 2945 CcTest::heap()->set_allocation_timeout(gc_count); |
2915 JSReceiver::SetProperty(object, prop_name, twenty_three, SLOPPY).Check(); | 2946 JSReceiver::SetProperty(object, prop_name, twenty_three, SLOPPY).Check(); |
2916 } | 2947 } |
2917 | 2948 |
2918 | 2949 |
2919 TEST(TransitionArrayShrinksDuringAllocToZero) { | 2950 TEST(TransitionArrayShrinksDuringAllocToZero) { |
2920 i::FLAG_stress_compaction = false; | 2951 FLAG_stress_compaction = false; |
2921 i::FLAG_allow_natives_syntax = true; | 2952 FLAG_stress_incremental_marking = false; |
| 2953 FLAG_allow_natives_syntax = true; |
2922 CcTest::InitializeVM(); | 2954 CcTest::InitializeVM(); |
2923 v8::HandleScope scope(CcTest::isolate()); | 2955 v8::HandleScope scope(CcTest::isolate()); |
2924 static const int transitions_count = 10; | 2956 static const int transitions_count = 10; |
2925 CompileRun("function F() { }"); | 2957 CompileRun("function F() { }"); |
2926 AddTransitions(transitions_count); | 2958 AddTransitions(transitions_count); |
2927 CompileRun("var root = new F;"); | 2959 CompileRun("var root = new F;"); |
2928 Handle<JSObject> root = GetByName("root"); | 2960 Handle<JSObject> root = GetByName("root"); |
2929 | 2961 |
2930 // Count number of live transitions before marking. | 2962 // Count number of live transitions before marking. |
2931 int transitions_before = CountMapTransitions(root->map()); | 2963 int transitions_before = CountMapTransitions(root->map()); |
2932 CHECK_EQ(transitions_count, transitions_before); | 2964 CHECK_EQ(transitions_count, transitions_before); |
2933 | 2965 |
2934 // Get rid of o | 2966 // Get rid of o |
2935 CompileRun("o = new F;" | 2967 CompileRun("o = new F;" |
2936 "root = new F"); | 2968 "root = new F"); |
2937 root = GetByName("root"); | 2969 root = GetByName("root"); |
2938 AddPropertyTo(2, root, "funny"); | 2970 AddPropertyTo(2, root, "funny"); |
2939 CcTest::CollectGarbage(NEW_SPACE); | 2971 CcTest::CollectGarbage(NEW_SPACE); |
2940 | 2972 |
2941 // Count number of live transitions after marking. Note that one transition | 2973 // Count number of live transitions after marking. Note that one transition |
2942 // is left, because 'o' still holds an instance of one transition target. | 2974 // is left, because 'o' still holds an instance of one transition target. |
2943 int transitions_after = CountMapTransitions( | 2975 int transitions_after = CountMapTransitions( |
2944 Map::cast(root->map()->GetBackPointer())); | 2976 Map::cast(root->map()->GetBackPointer())); |
2945 CHECK_EQ(1, transitions_after); | 2977 CHECK_EQ(1, transitions_after); |
2946 } | 2978 } |
2947 | 2979 |
2948 | 2980 |
2949 TEST(TransitionArrayShrinksDuringAllocToOne) { | 2981 TEST(TransitionArrayShrinksDuringAllocToOne) { |
2950 i::FLAG_stress_compaction = false; | 2982 FLAG_stress_compaction = false; |
2951 i::FLAG_allow_natives_syntax = true; | 2983 FLAG_stress_incremental_marking = false; |
| 2984 FLAG_allow_natives_syntax = true; |
2952 CcTest::InitializeVM(); | 2985 CcTest::InitializeVM(); |
2953 v8::HandleScope scope(CcTest::isolate()); | 2986 v8::HandleScope scope(CcTest::isolate()); |
2954 static const int transitions_count = 10; | 2987 static const int transitions_count = 10; |
2955 CompileRun("function F() {}"); | 2988 CompileRun("function F() {}"); |
2956 AddTransitions(transitions_count); | 2989 AddTransitions(transitions_count); |
2957 CompileRun("var root = new F;"); | 2990 CompileRun("var root = new F;"); |
2958 Handle<JSObject> root = GetByName("root"); | 2991 Handle<JSObject> root = GetByName("root"); |
2959 | 2992 |
2960 // Count number of live transitions before marking. | 2993 // Count number of live transitions before marking. |
2961 int transitions_before = CountMapTransitions(root->map()); | 2994 int transitions_before = CountMapTransitions(root->map()); |
2962 CHECK_EQ(transitions_count, transitions_before); | 2995 CHECK_EQ(transitions_count, transitions_before); |
2963 | 2996 |
2964 root = GetByName("root"); | 2997 root = GetByName("root"); |
2965 AddPropertyTo(2, root, "funny"); | 2998 AddPropertyTo(2, root, "funny"); |
2966 CcTest::CollectGarbage(NEW_SPACE); | 2999 CcTest::CollectGarbage(NEW_SPACE); |
2967 | 3000 |
2968 // Count number of live transitions after marking. Note that one transition | 3001 // Count number of live transitions after marking. Note that one transition |
2969 // is left, because 'o' still holds an instance of one transition target. | 3002 // is left, because 'o' still holds an instance of one transition target. |
2970 int transitions_after = CountMapTransitions( | 3003 int transitions_after = CountMapTransitions( |
2971 Map::cast(root->map()->GetBackPointer())); | 3004 Map::cast(root->map()->GetBackPointer())); |
2972 CHECK_EQ(2, transitions_after); | 3005 CHECK_EQ(2, transitions_after); |
2973 } | 3006 } |
2974 | 3007 |
2975 | 3008 |
2976 TEST(TransitionArrayShrinksDuringAllocToOnePropertyFound) { | 3009 TEST(TransitionArrayShrinksDuringAllocToOnePropertyFound) { |
2977 i::FLAG_stress_compaction = false; | 3010 FLAG_stress_compaction = false; |
2978 i::FLAG_allow_natives_syntax = true; | 3011 FLAG_stress_incremental_marking = false; |
| 3012 FLAG_allow_natives_syntax = true; |
2979 CcTest::InitializeVM(); | 3013 CcTest::InitializeVM(); |
2980 v8::HandleScope scope(CcTest::isolate()); | 3014 v8::HandleScope scope(CcTest::isolate()); |
2981 static const int transitions_count = 10; | 3015 static const int transitions_count = 10; |
2982 CompileRun("function F() {}"); | 3016 CompileRun("function F() {}"); |
2983 AddTransitions(transitions_count); | 3017 AddTransitions(transitions_count); |
2984 CompileRun("var root = new F;"); | 3018 CompileRun("var root = new F;"); |
2985 Handle<JSObject> root = GetByName("root"); | 3019 Handle<JSObject> root = GetByName("root"); |
2986 | 3020 |
2987 // Count number of live transitions before marking. | 3021 // Count number of live transitions before marking. |
2988 int transitions_before = CountMapTransitions(root->map()); | 3022 int transitions_before = CountMapTransitions(root->map()); |
2989 CHECK_EQ(transitions_count, transitions_before); | 3023 CHECK_EQ(transitions_count, transitions_before); |
2990 | 3024 |
2991 root = GetByName("root"); | 3025 root = GetByName("root"); |
2992 AddPropertyTo(0, root, "prop9"); | 3026 AddPropertyTo(0, root, "prop9"); |
2993 CcTest::CollectGarbage(OLD_SPACE); | 3027 CcTest::CollectGarbage(OLD_SPACE); |
2994 | 3028 |
2995 // Count number of live transitions after marking. Note that one transition | 3029 // Count number of live transitions after marking. Note that one transition |
2996 // is left, because 'o' still holds an instance of one transition target. | 3030 // is left, because 'o' still holds an instance of one transition target. |
2997 int transitions_after = CountMapTransitions( | 3031 int transitions_after = CountMapTransitions( |
2998 Map::cast(root->map()->GetBackPointer())); | 3032 Map::cast(root->map()->GetBackPointer())); |
2999 CHECK_EQ(1, transitions_after); | 3033 CHECK_EQ(1, transitions_after); |
3000 } | 3034 } |
3001 | 3035 |
3002 | 3036 |
3003 TEST(TransitionArraySimpleToFull) { | 3037 TEST(TransitionArraySimpleToFull) { |
3004 i::FLAG_stress_compaction = false; | 3038 FLAG_stress_compaction = false; |
3005 i::FLAG_allow_natives_syntax = true; | 3039 FLAG_stress_incremental_marking = false; |
| 3040 FLAG_allow_natives_syntax = true; |
3006 CcTest::InitializeVM(); | 3041 CcTest::InitializeVM(); |
3007 v8::HandleScope scope(CcTest::isolate()); | 3042 v8::HandleScope scope(CcTest::isolate()); |
3008 static const int transitions_count = 1; | 3043 static const int transitions_count = 1; |
3009 CompileRun("function F() {}"); | 3044 CompileRun("function F() {}"); |
3010 AddTransitions(transitions_count); | 3045 AddTransitions(transitions_count); |
3011 CompileRun("var root = new F;"); | 3046 CompileRun("var root = new F;"); |
3012 Handle<JSObject> root = GetByName("root"); | 3047 Handle<JSObject> root = GetByName("root"); |
3013 | 3048 |
3014 // Count number of live transitions before marking. | 3049 // Count number of live transitions before marking. |
3015 int transitions_before = CountMapTransitions(root->map()); | 3050 int transitions_before = CountMapTransitions(root->map()); |
3016 CHECK_EQ(transitions_count, transitions_before); | 3051 CHECK_EQ(transitions_count, transitions_before); |
3017 | 3052 |
3018 CompileRun("o = new F;" | 3053 CompileRun("o = new F;" |
3019 "root = new F"); | 3054 "root = new F"); |
3020 root = GetByName("root"); | 3055 root = GetByName("root"); |
3021 CHECK(TransitionArray::IsSimpleTransition(root->map()->raw_transitions())); | 3056 CHECK(TransitionArray::IsSimpleTransition(root->map()->raw_transitions())); |
3022 AddPropertyTo(2, root, "happy"); | 3057 AddPropertyTo(2, root, "happy"); |
3023 | 3058 |
3024 // Count number of live transitions after marking. Note that one transition | 3059 // Count number of live transitions after marking. Note that one transition |
3025 // is left, because 'o' still holds an instance of one transition target. | 3060 // is left, because 'o' still holds an instance of one transition target. |
3026 int transitions_after = CountMapTransitions( | 3061 int transitions_after = CountMapTransitions( |
3027 Map::cast(root->map()->GetBackPointer())); | 3062 Map::cast(root->map()->GetBackPointer())); |
3028 CHECK_EQ(1, transitions_after); | 3063 CHECK_EQ(1, transitions_after); |
3029 } | 3064 } |
3030 #endif // DEBUG | 3065 #endif // DEBUG |
3031 | 3066 |
3032 | 3067 |
3033 TEST(Regress2143a) { | 3068 TEST(Regress2143a) { |
3034 i::FLAG_incremental_marking = true; | 3069 FLAG_incremental_marking = true; |
3035 CcTest::InitializeVM(); | 3070 CcTest::InitializeVM(); |
3036 v8::HandleScope scope(CcTest::isolate()); | 3071 v8::HandleScope scope(CcTest::isolate()); |
3037 | 3072 |
3038 // Prepare a map transition from the root object together with a yet | 3073 // Prepare a map transition from the root object together with a yet |
3039 // untransitioned root object. | 3074 // untransitioned root object. |
3040 CompileRun("var root = new Object;" | 3075 CompileRun("var root = new Object;" |
3041 "root.foo = 0;" | 3076 "root.foo = 0;" |
3042 "root = new Object;"); | 3077 "root = new Object;"); |
3043 | 3078 |
3044 heap::SimulateIncrementalMarking(CcTest::heap()); | 3079 heap::SimulateIncrementalMarking(CcTest::heap()); |
(...skipping 18 matching lines...) Expand all Loading... |
3063 ->Get(CcTest::isolate()->GetCurrentContext(), v8_str("root")) | 3098 ->Get(CcTest::isolate()->GetCurrentContext(), v8_str("root")) |
3064 .ToLocalChecked())); | 3099 .ToLocalChecked())); |
3065 | 3100 |
3066 // The root object should be in a sane state. | 3101 // The root object should be in a sane state. |
3067 CHECK(root->IsJSObject()); | 3102 CHECK(root->IsJSObject()); |
3068 CHECK(root->map()->IsMap()); | 3103 CHECK(root->map()->IsMap()); |
3069 } | 3104 } |
3070 | 3105 |
3071 | 3106 |
3072 TEST(Regress2143b) { | 3107 TEST(Regress2143b) { |
3073 i::FLAG_incremental_marking = true; | 3108 FLAG_incremental_marking = true; |
3074 i::FLAG_allow_natives_syntax = true; | 3109 FLAG_allow_natives_syntax = true; |
3075 CcTest::InitializeVM(); | 3110 CcTest::InitializeVM(); |
3076 v8::HandleScope scope(CcTest::isolate()); | 3111 v8::HandleScope scope(CcTest::isolate()); |
3077 | 3112 |
3078 // Prepare a map transition from the root object together with a yet | 3113 // Prepare a map transition from the root object together with a yet |
3079 // untransitioned root object. | 3114 // untransitioned root object. |
3080 CompileRun("var root = new Object;" | 3115 CompileRun("var root = new Object;" |
3081 "root.foo = 0;" | 3116 "root.foo = 0;" |
3082 "root = new Object;"); | 3117 "root = new Object;"); |
3083 | 3118 |
3084 heap::SimulateIncrementalMarking(CcTest::heap()); | 3119 heap::SimulateIncrementalMarking(CcTest::heap()); |
(...skipping 22 matching lines...) Expand all Loading... |
3107 .ToLocalChecked())); | 3142 .ToLocalChecked())); |
3108 | 3143 |
3109 // The root object should be in a sane state. | 3144 // The root object should be in a sane state. |
3110 CHECK(root->IsJSObject()); | 3145 CHECK(root->IsJSObject()); |
3111 CHECK(root->map()->IsMap()); | 3146 CHECK(root->map()->IsMap()); |
3112 } | 3147 } |
3113 | 3148 |
3114 | 3149 |
3115 TEST(ReleaseOverReservedPages) { | 3150 TEST(ReleaseOverReservedPages) { |
3116 if (FLAG_never_compact) return; | 3151 if (FLAG_never_compact) return; |
3117 i::FLAG_trace_gc = true; | 3152 FLAG_trace_gc = true; |
3118 // The optimizer can allocate stuff, messing up the test. | 3153 // The optimizer can allocate stuff, messing up the test. |
3119 i::FLAG_opt = false; | 3154 FLAG_opt = false; |
3120 i::FLAG_always_opt = false; | 3155 FLAG_always_opt = false; |
3121 // Parallel compaction increases fragmentation, depending on how existing | 3156 // Parallel compaction increases fragmentation, depending on how existing |
3122 // memory is distributed. Since this is non-deterministic because of | 3157 // memory is distributed. Since this is non-deterministic because of |
3123 // concurrent sweeping, we disable it for this test. | 3158 // concurrent sweeping, we disable it for this test. |
3124 i::FLAG_parallel_compaction = false; | 3159 FLAG_parallel_compaction = false; |
3125 // Concurrent sweeping adds non determinism, depending on when memory is | 3160 // Concurrent sweeping adds non determinism, depending on when memory is |
3126 // available for further reuse. | 3161 // available for further reuse. |
3127 i::FLAG_concurrent_sweeping = false; | 3162 FLAG_concurrent_sweeping = false; |
3128 // Fast evacuation of pages may result in a different page count in old space. | 3163 // Fast evacuation of pages may result in a different page count in old space. |
3129 i::FLAG_page_promotion = false; | 3164 FLAG_page_promotion = false; |
3130 CcTest::InitializeVM(); | 3165 CcTest::InitializeVM(); |
3131 Isolate* isolate = CcTest::i_isolate(); | 3166 Isolate* isolate = CcTest::i_isolate(); |
3132 // If there's snapshot available, we don't know whether 20 small arrays will | 3167 // If there's snapshot available, we don't know whether 20 small arrays will |
3133 // fit on the initial pages. | 3168 // fit on the initial pages. |
3134 if (!isolate->snapshot_available()) return; | 3169 if (!isolate->snapshot_available()) return; |
3135 Factory* factory = isolate->factory(); | 3170 Factory* factory = isolate->factory(); |
3136 Heap* heap = isolate->heap(); | 3171 Heap* heap = isolate->heap(); |
3137 v8::HandleScope scope(CcTest::isolate()); | 3172 v8::HandleScope scope(CcTest::isolate()); |
3138 static const int number_of_test_pages = 20; | 3173 static const int number_of_test_pages = 20; |
3139 | 3174 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3176 void MockUseCounterCallback(v8::Isolate* isolate, | 3211 void MockUseCounterCallback(v8::Isolate* isolate, |
3177 v8::Isolate::UseCounterFeature feature) { | 3212 v8::Isolate::UseCounterFeature feature) { |
3178 isolate->GetCurrentContext(); | 3213 isolate->GetCurrentContext(); |
3179 if (feature == v8::Isolate::kForcedGC) { | 3214 if (feature == v8::Isolate::kForcedGC) { |
3180 forced_gc_counter++; | 3215 forced_gc_counter++; |
3181 } | 3216 } |
3182 } | 3217 } |
3183 | 3218 |
3184 | 3219 |
3185 TEST(CountForcedGC) { | 3220 TEST(CountForcedGC) { |
3186 i::FLAG_expose_gc = true; | 3221 FLAG_expose_gc = true; |
3187 CcTest::InitializeVM(); | 3222 CcTest::InitializeVM(); |
3188 Isolate* isolate = CcTest::i_isolate(); | 3223 Isolate* isolate = CcTest::i_isolate(); |
3189 v8::HandleScope scope(CcTest::isolate()); | 3224 v8::HandleScope scope(CcTest::isolate()); |
3190 | 3225 |
3191 isolate->SetUseCounterCallback(MockUseCounterCallback); | 3226 isolate->SetUseCounterCallback(MockUseCounterCallback); |
3192 | 3227 |
3193 forced_gc_counter = 0; | 3228 forced_gc_counter = 0; |
3194 const char* source = "gc();"; | 3229 const char* source = "gc();"; |
3195 CompileRun(source); | 3230 CompileRun(source); |
3196 CHECK_GT(forced_gc_counter, 0); | 3231 CHECK_GT(forced_gc_counter, 0); |
(...skipping 14 matching lines...) Expand all Loading... |
3211 | 3246 |
3212 OFStream os(stdout); | 3247 OFStream os(stdout); |
3213 g->shared()->Print(os); | 3248 g->shared()->Print(os); |
3214 os << std::endl; | 3249 os << std::endl; |
3215 } | 3250 } |
3216 #endif // OBJECT_PRINT | 3251 #endif // OBJECT_PRINT |
3217 | 3252 |
3218 | 3253 |
3219 TEST(IncrementalMarkingPreservesMonomorphicCallIC) { | 3254 TEST(IncrementalMarkingPreservesMonomorphicCallIC) { |
3220 if (!FLAG_incremental_marking) return; | 3255 if (!FLAG_incremental_marking) return; |
3221 if (i::FLAG_always_opt) return; | 3256 if (FLAG_always_opt) return; |
3222 CcTest::InitializeVM(); | 3257 CcTest::InitializeVM(); |
3223 v8::HandleScope scope(CcTest::isolate()); | 3258 v8::HandleScope scope(CcTest::isolate()); |
3224 v8::Local<v8::Value> fun1, fun2; | 3259 v8::Local<v8::Value> fun1, fun2; |
3225 v8::Local<v8::Context> ctx = CcTest::isolate()->GetCurrentContext(); | 3260 v8::Local<v8::Context> ctx = CcTest::isolate()->GetCurrentContext(); |
3226 { | 3261 { |
3227 CompileRun("function fun() {};"); | 3262 CompileRun("function fun() {};"); |
3228 fun1 = CcTest::global()->Get(ctx, v8_str("fun")).ToLocalChecked(); | 3263 fun1 = CcTest::global()->Get(ctx, v8_str("fun")).ToLocalChecked(); |
3229 } | 3264 } |
3230 | 3265 |
3231 { | 3266 { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3285 LoadICNexus nexus(vector, slot); | 3320 LoadICNexus nexus(vector, slot); |
3286 CHECK(nexus.StateFromFeedback() == desired_state); | 3321 CHECK(nexus.StateFromFeedback() == desired_state); |
3287 } else { | 3322 } else { |
3288 CHECK(vector->IsKeyedLoadIC(slot)); | 3323 CHECK(vector->IsKeyedLoadIC(slot)); |
3289 KeyedLoadICNexus nexus(vector, slot); | 3324 KeyedLoadICNexus nexus(vector, slot); |
3290 CHECK(nexus.StateFromFeedback() == desired_state); | 3325 CHECK(nexus.StateFromFeedback() == desired_state); |
3291 } | 3326 } |
3292 } | 3327 } |
3293 | 3328 |
3294 TEST(IncrementalMarkingPreservesMonomorphicConstructor) { | 3329 TEST(IncrementalMarkingPreservesMonomorphicConstructor) { |
3295 if (!i::FLAG_incremental_marking) return; | 3330 if (!FLAG_incremental_marking) return; |
3296 if (i::FLAG_always_opt) return; | 3331 if (FLAG_always_opt) return; |
3297 CcTest::InitializeVM(); | 3332 CcTest::InitializeVM(); |
3298 v8::HandleScope scope(CcTest::isolate()); | 3333 v8::HandleScope scope(CcTest::isolate()); |
3299 v8::Local<v8::Context> ctx = CcTest::isolate()->GetCurrentContext(); | 3334 v8::Local<v8::Context> ctx = CcTest::isolate()->GetCurrentContext(); |
3300 // Prepare function f that contains a monomorphic IC for object | 3335 // Prepare function f that contains a monomorphic IC for object |
3301 // originating from the same native context. | 3336 // originating from the same native context. |
3302 CompileRun( | 3337 CompileRun( |
3303 "function fun() { this.x = 1; };" | 3338 "function fun() { this.x = 1; };" |
3304 "function f(o) { return new o(); } f(fun); f(fun);"); | 3339 "function f(o) { return new o(); } f(fun); f(fun);"); |
3305 Handle<JSFunction> f = Handle<JSFunction>::cast( | 3340 Handle<JSFunction> f = Handle<JSFunction>::cast( |
3306 v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast( | 3341 v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast( |
3307 CcTest::global()->Get(ctx, v8_str("f")).ToLocalChecked()))); | 3342 CcTest::global()->Get(ctx, v8_str("f")).ToLocalChecked()))); |
3308 | 3343 |
3309 Handle<FeedbackVector> vector(f->feedback_vector()); | 3344 Handle<FeedbackVector> vector(f->feedback_vector()); |
3310 CHECK(vector->Get(FeedbackSlot(0))->IsWeakCell()); | 3345 CHECK(vector->Get(FeedbackSlot(0))->IsWeakCell()); |
3311 | 3346 |
3312 heap::SimulateIncrementalMarking(CcTest::heap()); | 3347 heap::SimulateIncrementalMarking(CcTest::heap()); |
3313 CcTest::CollectAllGarbage(); | 3348 CcTest::CollectAllGarbage(); |
3314 | 3349 |
3315 CHECK(vector->Get(FeedbackSlot(0))->IsWeakCell()); | 3350 CHECK(vector->Get(FeedbackSlot(0))->IsWeakCell()); |
3316 } | 3351 } |
3317 | 3352 |
3318 TEST(IncrementalMarkingPreservesMonomorphicIC) { | 3353 TEST(IncrementalMarkingPreservesMonomorphicIC) { |
3319 if (!i::FLAG_incremental_marking) return; | 3354 if (!FLAG_incremental_marking) return; |
3320 if (i::FLAG_always_opt) return; | 3355 if (FLAG_always_opt) return; |
3321 CcTest::InitializeVM(); | 3356 CcTest::InitializeVM(); |
3322 v8::HandleScope scope(CcTest::isolate()); | 3357 v8::HandleScope scope(CcTest::isolate()); |
3323 v8::Local<v8::Context> ctx = CcTest::isolate()->GetCurrentContext(); | 3358 v8::Local<v8::Context> ctx = CcTest::isolate()->GetCurrentContext(); |
3324 // Prepare function f that contains a monomorphic IC for object | 3359 // Prepare function f that contains a monomorphic IC for object |
3325 // originating from the same native context. | 3360 // originating from the same native context. |
3326 CompileRun("function fun() { this.x = 1; }; var obj = new fun();" | 3361 CompileRun("function fun() { this.x = 1; }; var obj = new fun();" |
3327 "function f(o) { return o.x; } f(obj); f(obj);"); | 3362 "function f(o) { return o.x; } f(obj); f(obj);"); |
3328 Handle<JSFunction> f = Handle<JSFunction>::cast( | 3363 Handle<JSFunction> f = Handle<JSFunction>::cast( |
3329 v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast( | 3364 v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast( |
3330 CcTest::global()->Get(ctx, v8_str("f")).ToLocalChecked()))); | 3365 CcTest::global()->Get(ctx, v8_str("f")).ToLocalChecked()))); |
3331 | 3366 |
3332 CheckVectorIC(f, 0, MONOMORPHIC); | 3367 CheckVectorIC(f, 0, MONOMORPHIC); |
3333 | 3368 |
3334 heap::SimulateIncrementalMarking(CcTest::heap()); | 3369 heap::SimulateIncrementalMarking(CcTest::heap()); |
3335 CcTest::CollectAllGarbage(); | 3370 CcTest::CollectAllGarbage(); |
3336 | 3371 |
3337 CheckVectorIC(f, 0, MONOMORPHIC); | 3372 CheckVectorIC(f, 0, MONOMORPHIC); |
3338 } | 3373 } |
3339 | 3374 |
3340 TEST(IncrementalMarkingPreservesPolymorphicIC) { | 3375 TEST(IncrementalMarkingPreservesPolymorphicIC) { |
3341 if (!i::FLAG_incremental_marking) return; | 3376 if (!FLAG_incremental_marking) return; |
3342 if (i::FLAG_always_opt) return; | 3377 if (FLAG_always_opt) return; |
3343 CcTest::InitializeVM(); | 3378 CcTest::InitializeVM(); |
3344 v8::HandleScope scope(CcTest::isolate()); | 3379 v8::HandleScope scope(CcTest::isolate()); |
3345 v8::Local<v8::Value> obj1, obj2; | 3380 v8::Local<v8::Value> obj1, obj2; |
3346 v8::Local<v8::Context> ctx = CcTest::isolate()->GetCurrentContext(); | 3381 v8::Local<v8::Context> ctx = CcTest::isolate()->GetCurrentContext(); |
3347 | 3382 |
3348 { | 3383 { |
3349 LocalContext env; | 3384 LocalContext env; |
3350 CompileRun("function fun() { this.x = 1; }; var obj = new fun();"); | 3385 CompileRun("function fun() { this.x = 1; }; var obj = new fun();"); |
3351 obj1 = env->Global()->Get(env.local(), v8_str("obj")).ToLocalChecked(); | 3386 obj1 = env->Global()->Get(env.local(), v8_str("obj")).ToLocalChecked(); |
3352 } | 3387 } |
(...skipping 16 matching lines...) Expand all Loading... |
3369 CheckVectorIC(f, 0, POLYMORPHIC); | 3404 CheckVectorIC(f, 0, POLYMORPHIC); |
3370 | 3405 |
3371 // Fire context dispose notification. | 3406 // Fire context dispose notification. |
3372 heap::SimulateIncrementalMarking(CcTest::heap()); | 3407 heap::SimulateIncrementalMarking(CcTest::heap()); |
3373 CcTest::CollectAllGarbage(); | 3408 CcTest::CollectAllGarbage(); |
3374 | 3409 |
3375 CheckVectorIC(f, 0, POLYMORPHIC); | 3410 CheckVectorIC(f, 0, POLYMORPHIC); |
3376 } | 3411 } |
3377 | 3412 |
3378 TEST(ContextDisposeDoesntClearPolymorphicIC) { | 3413 TEST(ContextDisposeDoesntClearPolymorphicIC) { |
3379 if (!i::FLAG_incremental_marking) return; | 3414 if (!FLAG_incremental_marking) return; |
3380 if (i::FLAG_always_opt) return; | 3415 if (FLAG_always_opt) return; |
3381 CcTest::InitializeVM(); | 3416 CcTest::InitializeVM(); |
3382 v8::HandleScope scope(CcTest::isolate()); | 3417 v8::HandleScope scope(CcTest::isolate()); |
3383 v8::Local<v8::Value> obj1, obj2; | 3418 v8::Local<v8::Value> obj1, obj2; |
3384 v8::Local<v8::Context> ctx = CcTest::isolate()->GetCurrentContext(); | 3419 v8::Local<v8::Context> ctx = CcTest::isolate()->GetCurrentContext(); |
3385 | 3420 |
3386 { | 3421 { |
3387 LocalContext env; | 3422 LocalContext env; |
3388 CompileRun("function fun() { this.x = 1; }; var obj = new fun();"); | 3423 CompileRun("function fun() { this.x = 1; }; var obj = new fun();"); |
3389 obj1 = env->Global()->Get(env.local(), v8_str("obj")).ToLocalChecked(); | 3424 obj1 = env->Global()->Get(env.local(), v8_str("obj")).ToLocalChecked(); |
3390 } | 3425 } |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3466 i_isolate->heap()->CollectAllAvailableGarbage( | 3501 i_isolate->heap()->CollectAllAvailableGarbage( |
3467 i::GarbageCollectionReason::kTesting); | 3502 i::GarbageCollectionReason::kTesting); |
3468 | 3503 |
3469 // External source has been released. | 3504 // External source has been released. |
3470 CHECK(resource->IsDisposed()); | 3505 CHECK(resource->IsDisposed()); |
3471 delete resource; | 3506 delete resource; |
3472 } | 3507 } |
3473 | 3508 |
3474 | 3509 |
3475 UNINITIALIZED_TEST(ReleaseStackTraceData) { | 3510 UNINITIALIZED_TEST(ReleaseStackTraceData) { |
3476 if (i::FLAG_always_opt) { | 3511 if (FLAG_always_opt) { |
3477 // TODO(ulan): Remove this once the memory leak via code_next_link is fixed. | 3512 // TODO(ulan): Remove this once the memory leak via code_next_link is fixed. |
3478 // See: https://codereview.chromium.org/181833004/ | 3513 // See: https://codereview.chromium.org/181833004/ |
3479 return; | 3514 return; |
3480 } | 3515 } |
3481 FLAG_use_ic = false; // ICs retain objects. | 3516 FLAG_use_ic = false; // ICs retain objects. |
3482 FLAG_concurrent_recompilation = false; | 3517 FLAG_concurrent_recompilation = false; |
3483 v8::Isolate::CreateParams create_params; | 3518 v8::Isolate::CreateParams create_params; |
3484 create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); | 3519 create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); |
3485 v8::Isolate* isolate = v8::Isolate::New(create_params); | 3520 v8::Isolate* isolate = v8::Isolate::New(create_params); |
3486 { | 3521 { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3525 ReleaseStackTraceDataTest(isolate, source1, getter); | 3560 ReleaseStackTraceDataTest(isolate, source1, getter); |
3526 ReleaseStackTraceDataTest(isolate, source2, getter); | 3561 ReleaseStackTraceDataTest(isolate, source2, getter); |
3527 ReleaseStackTraceDataTest(isolate, source3, getter); | 3562 ReleaseStackTraceDataTest(isolate, source3, getter); |
3528 ReleaseStackTraceDataTest(isolate, source4, getter); | 3563 ReleaseStackTraceDataTest(isolate, source4, getter); |
3529 } | 3564 } |
3530 isolate->Dispose(); | 3565 isolate->Dispose(); |
3531 } | 3566 } |
3532 | 3567 |
3533 | 3568 |
3534 TEST(Regress159140) { | 3569 TEST(Regress159140) { |
3535 if (!i::FLAG_incremental_marking) return; | 3570 if (!FLAG_incremental_marking) return; |
3536 i::FLAG_allow_natives_syntax = true; | 3571 FLAG_allow_natives_syntax = true; |
3537 CcTest::InitializeVM(); | 3572 CcTest::InitializeVM(); |
3538 Isolate* isolate = CcTest::i_isolate(); | 3573 Isolate* isolate = CcTest::i_isolate(); |
3539 LocalContext env; | 3574 LocalContext env; |
3540 Heap* heap = isolate->heap(); | 3575 Heap* heap = isolate->heap(); |
3541 HandleScope scope(isolate); | 3576 HandleScope scope(isolate); |
3542 | 3577 |
3543 // Perform one initial GC to enable code flushing. | 3578 // Perform one initial GC to enable code flushing. |
3544 CcTest::CollectAllGarbage(); | 3579 CcTest::CollectAllGarbage(); |
3545 | 3580 |
3546 // Prepare several closures that are all eligible for code flushing | 3581 // Prepare several closures that are all eligible for code flushing |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3586 heap::SimulateIncrementalMarking(heap); | 3621 heap::SimulateIncrementalMarking(heap); |
3587 CompileRun("%OptimizeFunctionOnNextCall(g); g(3);"); | 3622 CompileRun("%OptimizeFunctionOnNextCall(g); g(3);"); |
3588 CcTest::CollectAllGarbage(); | 3623 CcTest::CollectAllGarbage(); |
3589 | 3624 |
3590 // Unoptimized code is missing and the deoptimizer will go ballistic. | 3625 // Unoptimized code is missing and the deoptimizer will go ballistic. |
3591 CompileRun("g('bozo');"); | 3626 CompileRun("g('bozo');"); |
3592 } | 3627 } |
3593 | 3628 |
3594 | 3629 |
3595 TEST(Regress165495) { | 3630 TEST(Regress165495) { |
3596 if (!i::FLAG_incremental_marking) return; | 3631 if (!FLAG_incremental_marking) return; |
3597 i::FLAG_allow_natives_syntax = true; | 3632 FLAG_allow_natives_syntax = true; |
3598 CcTest::InitializeVM(); | 3633 CcTest::InitializeVM(); |
3599 Isolate* isolate = CcTest::i_isolate(); | 3634 Isolate* isolate = CcTest::i_isolate(); |
3600 Heap* heap = isolate->heap(); | 3635 Heap* heap = isolate->heap(); |
3601 HandleScope scope(isolate); | 3636 HandleScope scope(isolate); |
3602 | 3637 |
3603 // Perform one initial GC to enable code flushing. | 3638 // Perform one initial GC to enable code flushing. |
3604 CcTest::CollectAllGarbage(); | 3639 CcTest::CollectAllGarbage(); |
3605 | 3640 |
3606 // Prepare an optimized closure that the optimized code map will get | 3641 // Prepare an optimized closure that the optimized code map will get |
3607 // populated. Then age the unoptimized code to trigger code flushing | 3642 // populated. Then age the unoptimized code to trigger code flushing |
(...skipping 24 matching lines...) Expand all Loading... |
3632 // even though it still is cached in the optimized code map. | 3667 // even though it still is cached in the optimized code map. |
3633 heap::SimulateIncrementalMarking(heap); | 3668 heap::SimulateIncrementalMarking(heap); |
3634 CcTest::CollectAllGarbage(); | 3669 CcTest::CollectAllGarbage(); |
3635 | 3670 |
3636 // Make a new closure that will get code installed from the code map. | 3671 // Make a new closure that will get code installed from the code map. |
3637 // Unoptimized code is missing and the deoptimizer will go ballistic. | 3672 // Unoptimized code is missing and the deoptimizer will go ballistic. |
3638 CompileRun("var g = mkClosure(); g('bozo');"); | 3673 CompileRun("var g = mkClosure(); g('bozo');"); |
3639 } | 3674 } |
3640 | 3675 |
3641 TEST(Regress169928) { | 3676 TEST(Regress169928) { |
3642 i::FLAG_allow_natives_syntax = true; | 3677 FLAG_allow_natives_syntax = true; |
3643 i::FLAG_opt = false; | 3678 FLAG_opt = false; |
3644 CcTest::InitializeVM(); | 3679 CcTest::InitializeVM(); |
3645 Isolate* isolate = CcTest::i_isolate(); | 3680 Isolate* isolate = CcTest::i_isolate(); |
3646 LocalContext env; | 3681 LocalContext env; |
3647 Factory* factory = isolate->factory(); | 3682 Factory* factory = isolate->factory(); |
3648 v8::HandleScope scope(CcTest::isolate()); | 3683 v8::HandleScope scope(CcTest::isolate()); |
3649 | 3684 |
3650 // Some flags turn Scavenge collections into Mark-sweep collections | 3685 // Some flags turn Scavenge collections into Mark-sweep collections |
3651 // and hence are incompatible with this test case. | 3686 // and hence are incompatible with this test case. |
3652 if (FLAG_gc_global || FLAG_stress_compaction) return; | 3687 if (FLAG_gc_global || FLAG_stress_compaction || |
| 3688 FLAG_stress_incremental_marking) |
| 3689 return; |
3653 | 3690 |
3654 // Prepare the environment | 3691 // Prepare the environment |
3655 CompileRun("function fastliteralcase(literal, value) {" | 3692 CompileRun("function fastliteralcase(literal, value) {" |
3656 " literal[0] = value;" | 3693 " literal[0] = value;" |
3657 " return literal;" | 3694 " return literal;" |
3658 "}" | 3695 "}" |
3659 "function get_standard_literal() {" | 3696 "function get_standard_literal() {" |
3660 " var literal = [1, 2, 3];" | 3697 " var literal = [1, 2, 3];" |
3661 " return literal;" | 3698 " return literal;" |
3662 "}" | 3699 "}" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3712 AlwaysAllocateScope aa_scope(isolate); | 3749 AlwaysAllocateScope aa_scope(isolate); |
3713 v8::Script::Compile(env.local(), mote_code_string) | 3750 v8::Script::Compile(env.local(), mote_code_string) |
3714 .ToLocalChecked() | 3751 .ToLocalChecked() |
3715 ->Run(env.local()) | 3752 ->Run(env.local()) |
3716 .ToLocalChecked(); | 3753 .ToLocalChecked(); |
3717 } | 3754 } |
3718 | 3755 |
3719 | 3756 |
3720 #ifdef DEBUG | 3757 #ifdef DEBUG |
3721 TEST(Regress513507) { | 3758 TEST(Regress513507) { |
3722 i::FLAG_allow_natives_syntax = true; | 3759 FLAG_allow_natives_syntax = true; |
3723 i::FLAG_gc_global = true; | 3760 FLAG_gc_global = true; |
3724 CcTest::InitializeVM(); | 3761 CcTest::InitializeVM(); |
3725 Isolate* isolate = CcTest::i_isolate(); | 3762 Isolate* isolate = CcTest::i_isolate(); |
3726 LocalContext env; | 3763 LocalContext env; |
3727 Heap* heap = isolate->heap(); | 3764 Heap* heap = isolate->heap(); |
3728 HandleScope scope(isolate); | 3765 HandleScope scope(isolate); |
3729 | 3766 |
3730 // Prepare function whose optimized code map we can use. | 3767 // Prepare function whose optimized code map we can use. |
3731 Handle<SharedFunctionInfo> shared; | 3768 Handle<SharedFunctionInfo> shared; |
3732 { | 3769 { |
3733 HandleScope inner_scope(isolate); | 3770 HandleScope inner_scope(isolate); |
(...skipping 28 matching lines...) Expand all Loading... |
3762 heap->set_allocation_timeout(5); | 3799 heap->set_allocation_timeout(5); |
3763 FLAG_gc_interval = 1000; | 3800 FLAG_gc_interval = 1000; |
3764 for (int i = 0; i < 10; ++i) { | 3801 for (int i = 0; i < 10; ++i) { |
3765 BailoutId id = BailoutId(i + 1); | 3802 BailoutId id = BailoutId(i + 1); |
3766 Context::AddToOSROptimizedCodeCache(context, shared, code, id); | 3803 Context::AddToOSROptimizedCodeCache(context, shared, code, id); |
3767 } | 3804 } |
3768 } | 3805 } |
3769 #endif // DEBUG | 3806 #endif // DEBUG |
3770 | 3807 |
3771 TEST(Regress513496) { | 3808 TEST(Regress513496) { |
3772 i::FLAG_allow_natives_syntax = true; | 3809 FLAG_allow_natives_syntax = true; |
3773 CcTest::InitializeVM(); | 3810 CcTest::InitializeVM(); |
3774 Isolate* isolate = CcTest::i_isolate(); | 3811 Isolate* isolate = CcTest::i_isolate(); |
3775 HandleScope scope(isolate); | 3812 HandleScope scope(isolate); |
3776 | 3813 |
3777 // Perfrom one initial GC to enable code flushing. | 3814 // Perfrom one initial GC to enable code flushing. |
3778 CcTest::CollectAllGarbage(); | 3815 CcTest::CollectAllGarbage(); |
3779 | 3816 |
3780 // Prepare an optimized closure with containing an inlined function. Then age | 3817 // Prepare an optimized closure with containing an inlined function. Then age |
3781 // the inlined unoptimized code to trigger code flushing but make sure the | 3818 // the inlined unoptimized code to trigger code flushing but make sure the |
3782 // outer optimized code is kept in the optimized code map. | 3819 // outer optimized code is kept in the optimized code map. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3822 // though the optimized code for 'f' is reachable via the optimized code map. | 3859 // though the optimized code for 'f' is reachable via the optimized code map. |
3823 CcTest::CollectAllGarbage(); | 3860 CcTest::CollectAllGarbage(); |
3824 | 3861 |
3825 // Make a new closure that will get code installed from the code map. | 3862 // Make a new closure that will get code installed from the code map. |
3826 // Unoptimized code is missing and the deoptimizer will go ballistic. | 3863 // Unoptimized code is missing and the deoptimizer will go ballistic. |
3827 CompileRun("var h = mkClosure(); h('bozo');"); | 3864 CompileRun("var h = mkClosure(); h('bozo');"); |
3828 } | 3865 } |
3829 | 3866 |
3830 | 3867 |
3831 TEST(LargeObjectSlotRecording) { | 3868 TEST(LargeObjectSlotRecording) { |
3832 if (!i::FLAG_incremental_marking) return; | 3869 if (!FLAG_incremental_marking) return; |
3833 FLAG_manual_evacuation_candidates_selection = true; | 3870 FLAG_manual_evacuation_candidates_selection = true; |
| 3871 FLAG_stress_incremental_marking = false; |
3834 CcTest::InitializeVM(); | 3872 CcTest::InitializeVM(); |
3835 Isolate* isolate = CcTest::i_isolate(); | 3873 Isolate* isolate = CcTest::i_isolate(); |
3836 Heap* heap = isolate->heap(); | 3874 Heap* heap = isolate->heap(); |
3837 HandleScope scope(isolate); | 3875 HandleScope scope(isolate); |
3838 | 3876 |
3839 // Create an object on an evacuation candidate. | 3877 // Create an object on an evacuation candidate. |
3840 heap::SimulateFullSpace(heap->old_space()); | 3878 heap::SimulateFullSpace(heap->old_space()); |
3841 Handle<FixedArray> lit = isolate->factory()->NewFixedArray(4, TENURED); | 3879 Handle<FixedArray> lit = isolate->factory()->NewFixedArray(4, TENURED); |
3842 Page* evac_page = Page::FromAddress(lit->address()); | 3880 Page* evac_page = Page::FromAddress(lit->address()); |
3843 heap::ForceEvacuationCandidate(evac_page); | 3881 heap::ForceEvacuationCandidate(evac_page); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3916 } | 3954 } |
3917 // This big step should be sufficient to mark the whole array. | 3955 // This big step should be sufficient to mark the whole array. |
3918 marking->Step(100 * MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD, | 3956 marking->Step(100 * MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD, |
3919 IncrementalMarking::FORCE_COMPLETION, StepOrigin::kV8); | 3957 IncrementalMarking::FORCE_COMPLETION, StepOrigin::kV8); |
3920 CHECK(marking->IsComplete() || | 3958 CHECK(marking->IsComplete() || |
3921 marking->IsReadyToOverApproximateWeakClosure()); | 3959 marking->IsReadyToOverApproximateWeakClosure()); |
3922 } | 3960 } |
3923 | 3961 |
3924 | 3962 |
3925 TEST(DisableInlineAllocation) { | 3963 TEST(DisableInlineAllocation) { |
3926 i::FLAG_allow_natives_syntax = true; | 3964 FLAG_allow_natives_syntax = true; |
3927 CcTest::InitializeVM(); | 3965 CcTest::InitializeVM(); |
3928 v8::HandleScope scope(CcTest::isolate()); | 3966 v8::HandleScope scope(CcTest::isolate()); |
3929 CompileRun("function test() {" | 3967 CompileRun("function test() {" |
3930 " var x = [];" | 3968 " var x = [];" |
3931 " for (var i = 0; i < 10; i++) {" | 3969 " for (var i = 0; i < 10; i++) {" |
3932 " x[i] = [ {}, [1,2,3], [1,x,3] ];" | 3970 " x[i] = [ {}, [1,2,3], [1,x,3] ];" |
3933 " }" | 3971 " }" |
3934 "}" | 3972 "}" |
3935 "function run() {" | 3973 "function run() {" |
3936 " %OptimizeFunctionOnNextCall(test);" | 3974 " %OptimizeFunctionOnNextCall(test);" |
(...skipping 19 matching lines...) Expand all Loading... |
3956 for (Object* site = heap->allocation_sites_list(); | 3994 for (Object* site = heap->allocation_sites_list(); |
3957 !(site->IsUndefined(heap->isolate())); | 3995 !(site->IsUndefined(heap->isolate())); |
3958 site = AllocationSite::cast(site)->weak_next()) { | 3996 site = AllocationSite::cast(site)->weak_next()) { |
3959 count++; | 3997 count++; |
3960 } | 3998 } |
3961 return count; | 3999 return count; |
3962 } | 4000 } |
3963 | 4001 |
3964 | 4002 |
3965 TEST(EnsureAllocationSiteDependentCodesProcessed) { | 4003 TEST(EnsureAllocationSiteDependentCodesProcessed) { |
3966 if (i::FLAG_always_opt || !i::FLAG_opt) return; | 4004 if (FLAG_always_opt || !FLAG_opt) return; |
3967 i::FLAG_allow_natives_syntax = true; | 4005 FLAG_allow_natives_syntax = true; |
3968 CcTest::InitializeVM(); | 4006 CcTest::InitializeVM(); |
3969 Isolate* isolate = CcTest::i_isolate(); | 4007 Isolate* isolate = CcTest::i_isolate(); |
3970 v8::internal::Heap* heap = CcTest::heap(); | 4008 v8::internal::Heap* heap = CcTest::heap(); |
3971 GlobalHandles* global_handles = isolate->global_handles(); | 4009 GlobalHandles* global_handles = isolate->global_handles(); |
3972 | 4010 |
3973 if (!isolate->use_optimizer()) return; | 4011 if (!isolate->use_optimizer()) return; |
3974 | 4012 |
3975 // The allocation site at the head of the list is ours. | 4013 // The allocation site at the head of the list is ours. |
3976 Handle<AllocationSite> site; | 4014 Handle<AllocationSite> site; |
3977 { | 4015 { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4027 } | 4065 } |
4028 | 4066 |
4029 // The site still exists because of our global handle, but the code is no | 4067 // The site still exists because of our global handle, but the code is no |
4030 // longer referred to by dependent_code(). | 4068 // longer referred to by dependent_code(). |
4031 CHECK(site->dependent_code()->object_at(0)->IsWeakCell() && | 4069 CHECK(site->dependent_code()->object_at(0)->IsWeakCell() && |
4032 WeakCell::cast(site->dependent_code()->object_at(0))->cleared()); | 4070 WeakCell::cast(site->dependent_code()->object_at(0))->cleared()); |
4033 } | 4071 } |
4034 | 4072 |
4035 | 4073 |
4036 TEST(CellsInOptimizedCodeAreWeak) { | 4074 TEST(CellsInOptimizedCodeAreWeak) { |
4037 if (i::FLAG_always_opt || !i::FLAG_opt) return; | 4075 if (FLAG_always_opt || !FLAG_opt) return; |
4038 i::FLAG_allow_natives_syntax = true; | 4076 FLAG_allow_natives_syntax = true; |
4039 CcTest::InitializeVM(); | 4077 CcTest::InitializeVM(); |
4040 Isolate* isolate = CcTest::i_isolate(); | 4078 Isolate* isolate = CcTest::i_isolate(); |
4041 v8::internal::Heap* heap = CcTest::heap(); | 4079 v8::internal::Heap* heap = CcTest::heap(); |
4042 | 4080 |
4043 if (!isolate->use_optimizer()) return; | 4081 if (!isolate->use_optimizer()) return; |
4044 HandleScope outer_scope(heap->isolate()); | 4082 HandleScope outer_scope(heap->isolate()); |
4045 Handle<Code> code; | 4083 Handle<Code> code; |
4046 { | 4084 { |
4047 LocalContext context; | 4085 LocalContext context; |
4048 HandleScope scope(heap->isolate()); | 4086 HandleScope scope(heap->isolate()); |
(...skipping 22 matching lines...) Expand all Loading... |
4071 // Now make sure that a gc should get rid of the function | 4109 // Now make sure that a gc should get rid of the function |
4072 for (int i = 0; i < 4; i++) { | 4110 for (int i = 0; i < 4; i++) { |
4073 CcTest::CollectAllGarbage(); | 4111 CcTest::CollectAllGarbage(); |
4074 } | 4112 } |
4075 | 4113 |
4076 CHECK(code->marked_for_deoptimization()); | 4114 CHECK(code->marked_for_deoptimization()); |
4077 } | 4115 } |
4078 | 4116 |
4079 | 4117 |
4080 TEST(ObjectsInOptimizedCodeAreWeak) { | 4118 TEST(ObjectsInOptimizedCodeAreWeak) { |
4081 if (i::FLAG_always_opt || !i::FLAG_opt) return; | 4119 if (FLAG_always_opt || !FLAG_opt) return; |
4082 i::FLAG_allow_natives_syntax = true; | 4120 FLAG_allow_natives_syntax = true; |
4083 CcTest::InitializeVM(); | 4121 CcTest::InitializeVM(); |
4084 Isolate* isolate = CcTest::i_isolate(); | 4122 Isolate* isolate = CcTest::i_isolate(); |
4085 v8::internal::Heap* heap = CcTest::heap(); | 4123 v8::internal::Heap* heap = CcTest::heap(); |
4086 | 4124 |
4087 if (!isolate->use_optimizer()) return; | 4125 if (!isolate->use_optimizer()) return; |
4088 HandleScope outer_scope(heap->isolate()); | 4126 HandleScope outer_scope(heap->isolate()); |
4089 Handle<Code> code; | 4127 Handle<Code> code; |
4090 { | 4128 { |
4091 LocalContext context; | 4129 LocalContext context; |
4092 HandleScope scope(heap->isolate()); | 4130 HandleScope scope(heap->isolate()); |
(...skipping 19 matching lines...) Expand all Loading... |
4112 | 4150 |
4113 // Now make sure that a gc should get rid of the function | 4151 // Now make sure that a gc should get rid of the function |
4114 for (int i = 0; i < 4; i++) { | 4152 for (int i = 0; i < 4; i++) { |
4115 CcTest::CollectAllGarbage(); | 4153 CcTest::CollectAllGarbage(); |
4116 } | 4154 } |
4117 | 4155 |
4118 CHECK(code->marked_for_deoptimization()); | 4156 CHECK(code->marked_for_deoptimization()); |
4119 } | 4157 } |
4120 | 4158 |
4121 TEST(NewSpaceObjectsInOptimizedCode) { | 4159 TEST(NewSpaceObjectsInOptimizedCode) { |
4122 if (i::FLAG_always_opt || !i::FLAG_opt || i::FLAG_turbo) return; | 4160 if (FLAG_always_opt || !FLAG_opt || FLAG_turbo) return; |
4123 i::FLAG_allow_natives_syntax = true; | 4161 FLAG_allow_natives_syntax = true; |
4124 CcTest::InitializeVM(); | 4162 CcTest::InitializeVM(); |
4125 Isolate* isolate = CcTest::i_isolate(); | 4163 Isolate* isolate = CcTest::i_isolate(); |
4126 v8::internal::Heap* heap = CcTest::heap(); | 4164 v8::internal::Heap* heap = CcTest::heap(); |
4127 | 4165 |
4128 if (!isolate->use_optimizer()) return; | 4166 if (!isolate->use_optimizer()) return; |
4129 HandleScope outer_scope(heap->isolate()); | 4167 HandleScope outer_scope(heap->isolate()); |
4130 Handle<Code> code; | 4168 Handle<Code> code; |
4131 { | 4169 { |
4132 LocalContext context; | 4170 LocalContext context; |
4133 HandleScope scope(heap->isolate()); | 4171 HandleScope scope(heap->isolate()); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4173 | 4211 |
4174 // Now make sure that a gc should get rid of the function | 4212 // Now make sure that a gc should get rid of the function |
4175 for (int i = 0; i < 4; i++) { | 4213 for (int i = 0; i < 4; i++) { |
4176 CcTest::CollectAllGarbage(); | 4214 CcTest::CollectAllGarbage(); |
4177 } | 4215 } |
4178 | 4216 |
4179 CHECK(code->marked_for_deoptimization()); | 4217 CHECK(code->marked_for_deoptimization()); |
4180 } | 4218 } |
4181 | 4219 |
4182 TEST(NoWeakHashTableLeakWithIncrementalMarking) { | 4220 TEST(NoWeakHashTableLeakWithIncrementalMarking) { |
4183 if (i::FLAG_always_opt || !i::FLAG_opt) return; | 4221 if (FLAG_always_opt || !FLAG_opt) return; |
4184 if (!i::FLAG_incremental_marking) return; | 4222 if (!FLAG_incremental_marking) return; |
4185 i::FLAG_allow_natives_syntax = true; | 4223 FLAG_allow_natives_syntax = true; |
4186 i::FLAG_compilation_cache = false; | 4224 FLAG_compilation_cache = false; |
4187 i::FLAG_retain_maps_for_n_gc = 0; | 4225 FLAG_retain_maps_for_n_gc = 0; |
4188 CcTest::InitializeVM(); | 4226 CcTest::InitializeVM(); |
4189 Isolate* isolate = CcTest::i_isolate(); | 4227 Isolate* isolate = CcTest::i_isolate(); |
4190 | 4228 |
4191 // Do not run for no-snap builds. | 4229 // Do not run for no-snap builds. |
4192 if (!i::Snapshot::HasContextSnapshot(isolate, 0)) return; | 4230 if (!i::Snapshot::HasContextSnapshot(isolate, 0)) return; |
4193 | 4231 |
4194 v8::internal::Heap* heap = CcTest::heap(); | 4232 v8::internal::Heap* heap = CcTest::heap(); |
4195 | 4233 |
4196 // Get a clean slate regarding optimized functions on the heap. | 4234 // Get a clean slate regarding optimized functions on the heap. |
4197 i::Deoptimizer::DeoptimizeAll(isolate); | 4235 i::Deoptimizer::DeoptimizeAll(isolate); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4252 int result = 0; | 4290 int result = 0; |
4253 while (code->next_code_link()->IsCode()) { | 4291 while (code->next_code_link()->IsCode()) { |
4254 result++; | 4292 result++; |
4255 code = Code::cast(code->next_code_link()); | 4293 code = Code::cast(code->next_code_link()); |
4256 } | 4294 } |
4257 return result; | 4295 return result; |
4258 } | 4296 } |
4259 | 4297 |
4260 | 4298 |
4261 TEST(NextCodeLinkIsWeak) { | 4299 TEST(NextCodeLinkIsWeak) { |
4262 i::FLAG_always_opt = false; | 4300 FLAG_always_opt = false; |
4263 i::FLAG_allow_natives_syntax = true; | 4301 FLAG_allow_natives_syntax = true; |
4264 CcTest::InitializeVM(); | 4302 CcTest::InitializeVM(); |
4265 Isolate* isolate = CcTest::i_isolate(); | 4303 Isolate* isolate = CcTest::i_isolate(); |
4266 v8::internal::Heap* heap = CcTest::heap(); | 4304 v8::internal::Heap* heap = CcTest::heap(); |
4267 | 4305 |
4268 if (!isolate->use_optimizer()) return; | 4306 if (!isolate->use_optimizer()) return; |
4269 HandleScope outer_scope(heap->isolate()); | 4307 HandleScope outer_scope(heap->isolate()); |
4270 Handle<Code> code; | 4308 Handle<Code> code; |
4271 CcTest::CollectAllAvailableGarbage(); | 4309 CcTest::CollectAllAvailableGarbage(); |
4272 int code_chain_length_before, code_chain_length_after; | 4310 int code_chain_length_before, code_chain_length_after; |
4273 { | 4311 { |
(...skipping 25 matching lines...) Expand all Loading... |
4299 masm.GetCode(&desc); | 4337 masm.GetCode(&desc); |
4300 Handle<Object> undefined(isolate->heap()->undefined_value(), isolate); | 4338 Handle<Object> undefined(isolate->heap()->undefined_value(), isolate); |
4301 Handle<Code> code = isolate->factory()->NewCode( | 4339 Handle<Code> code = isolate->factory()->NewCode( |
4302 desc, Code::ComputeFlags(Code::OPTIMIZED_FUNCTION), undefined); | 4340 desc, Code::ComputeFlags(Code::OPTIMIZED_FUNCTION), undefined); |
4303 CHECK(code->IsCode()); | 4341 CHECK(code->IsCode()); |
4304 return code; | 4342 return code; |
4305 } | 4343 } |
4306 | 4344 |
4307 | 4345 |
4308 TEST(NextCodeLinkIsWeak2) { | 4346 TEST(NextCodeLinkIsWeak2) { |
4309 i::FLAG_allow_natives_syntax = true; | 4347 FLAG_allow_natives_syntax = true; |
4310 CcTest::InitializeVM(); | 4348 CcTest::InitializeVM(); |
4311 Isolate* isolate = CcTest::i_isolate(); | 4349 Isolate* isolate = CcTest::i_isolate(); |
4312 v8::internal::Heap* heap = CcTest::heap(); | 4350 v8::internal::Heap* heap = CcTest::heap(); |
4313 | 4351 |
4314 if (!isolate->use_optimizer()) return; | 4352 if (!isolate->use_optimizer()) return; |
4315 HandleScope outer_scope(heap->isolate()); | 4353 HandleScope outer_scope(heap->isolate()); |
4316 CcTest::CollectAllAvailableGarbage(); | 4354 CcTest::CollectAllAvailableGarbage(); |
4317 Handle<Context> context(Context::cast(heap->native_contexts_list()), isolate); | 4355 Handle<Context> context(Context::cast(heap->native_contexts_list()), isolate); |
4318 Handle<Code> new_head; | 4356 Handle<Code> new_head; |
4319 Handle<Object> old_head(context->get(Context::OPTIMIZED_CODE_LIST), isolate); | 4357 Handle<Object> old_head(context->get(Context::OPTIMIZED_CODE_LIST), isolate); |
(...skipping 16 matching lines...) Expand all Loading... |
4336 | 4374 |
4337 static void ClearWeakIC( | 4375 static void ClearWeakIC( |
4338 const v8::WeakCallbackInfo<v8::Persistent<v8::Object>>& data) { | 4376 const v8::WeakCallbackInfo<v8::Persistent<v8::Object>>& data) { |
4339 printf("clear weak is called\n"); | 4377 printf("clear weak is called\n"); |
4340 weak_ic_cleared = true; | 4378 weak_ic_cleared = true; |
4341 data.GetParameter()->Reset(); | 4379 data.GetParameter()->Reset(); |
4342 } | 4380 } |
4343 | 4381 |
4344 | 4382 |
4345 TEST(WeakFunctionInConstructor) { | 4383 TEST(WeakFunctionInConstructor) { |
4346 if (i::FLAG_always_opt) return; | 4384 if (FLAG_always_opt) return; |
4347 i::FLAG_stress_compaction = false; | 4385 FLAG_stress_compaction = false; |
| 4386 FLAG_stress_incremental_marking = false; |
4348 CcTest::InitializeVM(); | 4387 CcTest::InitializeVM(); |
4349 v8::Isolate* isolate = CcTest::isolate(); | 4388 v8::Isolate* isolate = CcTest::isolate(); |
4350 LocalContext env; | 4389 LocalContext env; |
4351 v8::HandleScope scope(isolate); | 4390 v8::HandleScope scope(isolate); |
4352 CompileRun( | 4391 CompileRun( |
4353 "function createObj(obj) {" | 4392 "function createObj(obj) {" |
4354 " return new obj();" | 4393 " return new obj();" |
4355 "}"); | 4394 "}"); |
4356 i::Handle<JSFunction> createObj = Handle<JSFunction>::cast( | 4395 i::Handle<JSFunction> createObj = Handle<JSFunction>::cast( |
4357 v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast( | 4396 v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast( |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4396 CompileRun( | 4435 CompileRun( |
4397 "function coat() { this.x = 6; }" | 4436 "function coat() { this.x = 6; }" |
4398 "createObj(coat);"); | 4437 "createObj(coat);"); |
4399 slot_value = feedback_vector->Get(FeedbackSlot(0)); | 4438 slot_value = feedback_vector->Get(FeedbackSlot(0)); |
4400 CHECK(slot_value->IsWeakCell() && !WeakCell::cast(slot_value)->cleared()); | 4439 CHECK(slot_value->IsWeakCell() && !WeakCell::cast(slot_value)->cleared()); |
4401 } | 4440 } |
4402 | 4441 |
4403 | 4442 |
4404 // Checks that the value returned by execution of the source is weak. | 4443 // Checks that the value returned by execution of the source is weak. |
4405 void CheckWeakness(const char* source) { | 4444 void CheckWeakness(const char* source) { |
4406 i::FLAG_stress_compaction = false; | 4445 FLAG_stress_compaction = false; |
| 4446 FLAG_stress_incremental_marking = false; |
4407 CcTest::InitializeVM(); | 4447 CcTest::InitializeVM(); |
4408 v8::Isolate* isolate = CcTest::isolate(); | 4448 v8::Isolate* isolate = CcTest::isolate(); |
4409 LocalContext env; | 4449 LocalContext env; |
4410 v8::HandleScope scope(isolate); | 4450 v8::HandleScope scope(isolate); |
4411 v8::Persistent<v8::Object> garbage; | 4451 v8::Persistent<v8::Object> garbage; |
4412 { | 4452 { |
4413 v8::HandleScope scope(isolate); | 4453 v8::HandleScope scope(isolate); |
4414 garbage.Reset(isolate, CompileRun(env.local(), source) | 4454 garbage.Reset(isolate, CompileRun(env.local(), source) |
4415 .ToLocalChecked() | 4455 .ToLocalChecked() |
4416 ->ToObject(env.local()) | 4456 ->ToObject(env.local()) |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4738 CcTest::CollectAllGarbage(); | 4778 CcTest::CollectAllGarbage(); |
4739 CHECK_EQ(*survivor, weak_cells[0]->value()); | 4779 CHECK_EQ(*survivor, weak_cells[0]->value()); |
4740 for (int i = 1; i < N; i++) { | 4780 for (int i = 1; i < N; i++) { |
4741 CHECK(weak_cells[i]->cleared()); | 4781 CHECK(weak_cells[i]->cleared()); |
4742 } | 4782 } |
4743 } | 4783 } |
4744 | 4784 |
4745 | 4785 |
4746 #ifdef DEBUG | 4786 #ifdef DEBUG |
4747 TEST(AddInstructionChangesNewSpacePromotion) { | 4787 TEST(AddInstructionChangesNewSpacePromotion) { |
4748 i::FLAG_allow_natives_syntax = true; | 4788 FLAG_allow_natives_syntax = true; |
4749 i::FLAG_expose_gc = true; | 4789 FLAG_expose_gc = true; |
4750 i::FLAG_stress_compaction = true; | 4790 FLAG_stress_compaction = true; |
4751 i::FLAG_gc_interval = 1000; | 4791 FLAG_gc_interval = 1000; |
4752 CcTest::InitializeVM(); | 4792 CcTest::InitializeVM(); |
4753 if (!i::FLAG_allocation_site_pretenuring) return; | 4793 if (!FLAG_allocation_site_pretenuring) return; |
4754 v8::HandleScope scope(CcTest::isolate()); | 4794 v8::HandleScope scope(CcTest::isolate()); |
4755 Isolate* isolate = CcTest::i_isolate(); | 4795 Isolate* isolate = CcTest::i_isolate(); |
4756 Heap* heap = isolate->heap(); | 4796 Heap* heap = isolate->heap(); |
4757 LocalContext env; | 4797 LocalContext env; |
4758 CompileRun( | 4798 CompileRun( |
4759 "function add(a, b) {" | 4799 "function add(a, b) {" |
4760 " return a + b;" | 4800 " return a + b;" |
4761 "}" | 4801 "}" |
4762 "add(1, 2);" | 4802 "add(1, 2);" |
4763 "add(\"a\", \"b\");" | 4803 "add(\"a\", \"b\");" |
(...skipping 22 matching lines...) Expand all Loading... |
4786 } | 4826 } |
4787 | 4827 |
4788 | 4828 |
4789 void OnFatalErrorExpectOOM(const char* location, const char* message) { | 4829 void OnFatalErrorExpectOOM(const char* location, const char* message) { |
4790 // Exit with 0 if the location matches our expectation. | 4830 // Exit with 0 if the location matches our expectation. |
4791 exit(strcmp(location, "CALL_AND_RETRY_LAST")); | 4831 exit(strcmp(location, "CALL_AND_RETRY_LAST")); |
4792 } | 4832 } |
4793 | 4833 |
4794 | 4834 |
4795 TEST(CEntryStubOOM) { | 4835 TEST(CEntryStubOOM) { |
4796 i::FLAG_allow_natives_syntax = true; | 4836 FLAG_allow_natives_syntax = true; |
4797 CcTest::InitializeVM(); | 4837 CcTest::InitializeVM(); |
4798 v8::HandleScope scope(CcTest::isolate()); | 4838 v8::HandleScope scope(CcTest::isolate()); |
4799 CcTest::isolate()->SetFatalErrorHandler(OnFatalErrorExpectOOM); | 4839 CcTest::isolate()->SetFatalErrorHandler(OnFatalErrorExpectOOM); |
4800 | 4840 |
4801 v8::Local<v8::Value> result = CompileRun( | 4841 v8::Local<v8::Value> result = CompileRun( |
4802 "%SetFlags('--gc-interval=1');" | 4842 "%SetFlags('--gc-interval=1');" |
4803 "var a = [];" | 4843 "var a = [];" |
4804 "a.__proto__ = [];" | 4844 "a.__proto__ = [];" |
4805 "a.unshift(1)"); | 4845 "a.unshift(1)"); |
4806 | 4846 |
4807 CHECK(result->IsNumber()); | 4847 CHECK(result->IsNumber()); |
4808 } | 4848 } |
4809 | 4849 |
4810 #endif // DEBUG | 4850 #endif // DEBUG |
4811 | 4851 |
4812 | 4852 |
4813 static void InterruptCallback357137(v8::Isolate* isolate, void* data) { } | 4853 static void InterruptCallback357137(v8::Isolate* isolate, void* data) { } |
4814 | 4854 |
4815 | 4855 |
4816 static void RequestInterrupt(const v8::FunctionCallbackInfo<v8::Value>& args) { | 4856 static void RequestInterrupt(const v8::FunctionCallbackInfo<v8::Value>& args) { |
4817 CcTest::isolate()->RequestInterrupt(&InterruptCallback357137, NULL); | 4857 CcTest::isolate()->RequestInterrupt(&InterruptCallback357137, NULL); |
4818 } | 4858 } |
4819 | 4859 |
4820 HEAP_TEST(Regress538257) { | 4860 HEAP_TEST(Regress538257) { |
4821 i::FLAG_manual_evacuation_candidates_selection = true; | 4861 FLAG_manual_evacuation_candidates_selection = true; |
4822 v8::Isolate::CreateParams create_params; | 4862 v8::Isolate::CreateParams create_params; |
4823 // Set heap limits. | 4863 // Set heap limits. |
4824 create_params.constraints.set_max_semi_space_size(1); | 4864 create_params.constraints.set_max_semi_space_size(1); |
4825 create_params.constraints.set_max_old_space_size(6); | 4865 create_params.constraints.set_max_old_space_size(6); |
4826 create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); | 4866 create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); |
4827 v8::Isolate* isolate = v8::Isolate::New(create_params); | 4867 v8::Isolate* isolate = v8::Isolate::New(create_params); |
4828 isolate->Enter(); | 4868 isolate->Enter(); |
4829 { | 4869 { |
4830 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 4870 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
4831 Heap* heap = i_isolate->heap(); | 4871 Heap* heap = i_isolate->heap(); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4893 o1->Shrink(kFixedArrayLen - 1); | 4933 o1->Shrink(kFixedArrayLen - 1); |
4894 | 4934 |
4895 for (HeapObject* obj = it.next(); obj != NULL; obj = it.next()) { | 4935 for (HeapObject* obj = it.next(); obj != NULL; obj = it.next()) { |
4896 // Let's not optimize the loop away. | 4936 // Let's not optimize the loop away. |
4897 CHECK(obj->address() != nullptr); | 4937 CHECK(obj->address() != nullptr); |
4898 } | 4938 } |
4899 } | 4939 } |
4900 | 4940 |
4901 | 4941 |
4902 UNINITIALIZED_TEST(PromotionQueue) { | 4942 UNINITIALIZED_TEST(PromotionQueue) { |
4903 i::FLAG_expose_gc = true; | 4943 FLAG_expose_gc = true; |
4904 i::FLAG_max_semi_space_size = 2 * Page::kPageSize / MB; | 4944 FLAG_max_semi_space_size = 2 * Page::kPageSize / MB; |
4905 i::FLAG_min_semi_space_size = i::FLAG_max_semi_space_size; | 4945 FLAG_min_semi_space_size = FLAG_max_semi_space_size; |
4906 v8::Isolate::CreateParams create_params; | 4946 v8::Isolate::CreateParams create_params; |
4907 create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); | 4947 create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); |
4908 v8::Isolate* isolate = v8::Isolate::New(create_params); | 4948 v8::Isolate* isolate = v8::Isolate::New(create_params); |
4909 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 4949 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
4910 { | 4950 { |
4911 v8::Isolate::Scope isolate_scope(isolate); | 4951 v8::Isolate::Scope isolate_scope(isolate); |
4912 v8::HandleScope handle_scope(isolate); | 4952 v8::HandleScope handle_scope(isolate); |
4913 v8::Context::New(isolate)->Enter(); | 4953 v8::Context::New(isolate)->Enter(); |
4914 Heap* heap = i_isolate->heap(); | 4954 Heap* heap = i_isolate->heap(); |
4915 NewSpace* new_space = heap->new_space(); | 4955 NewSpace* new_space = heap->new_space(); |
(...skipping 12 matching lines...) Expand all Loading... |
4928 // (2) and will create promotion queue entries at the end of the second | 4968 // (2) and will create promotion queue entries at the end of the second |
4929 // semi-space page during the next scavenge when it promotes the objects to | 4969 // semi-space page during the next scavenge when it promotes the objects to |
4930 // the old generation. The first allocation of (3) will fill up the first | 4970 // the old generation. The first allocation of (3) will fill up the first |
4931 // semi-space page. The second allocation in (3) will not fit into the | 4971 // semi-space page. The second allocation in (3) will not fit into the |
4932 // first semi-space page, but it will overwrite the promotion queue which | 4972 // first semi-space page, but it will overwrite the promotion queue which |
4933 // are in the second semi-space page. If the right guards are in place, the | 4973 // are in the second semi-space page. If the right guards are in place, the |
4934 // promotion queue will be evacuated in that case. | 4974 // promotion queue will be evacuated in that case. |
4935 | 4975 |
4936 | 4976 |
4937 CHECK(new_space->IsAtMaximumCapacity()); | 4977 CHECK(new_space->IsAtMaximumCapacity()); |
4938 CHECK_EQ(static_cast<size_t>(i::FLAG_min_semi_space_size * MB), | 4978 CHECK_EQ(static_cast<size_t>(FLAG_min_semi_space_size * MB), |
4939 new_space->TotalCapacity()); | 4979 new_space->TotalCapacity()); |
4940 | 4980 |
4941 // Call the scavenger two times to get an empty new space | 4981 // Call the scavenger two times to get an empty new space |
4942 heap->CollectGarbage(NEW_SPACE, i::GarbageCollectionReason::kTesting); | 4982 heap->CollectGarbage(NEW_SPACE, i::GarbageCollectionReason::kTesting); |
4943 heap->CollectGarbage(NEW_SPACE, i::GarbageCollectionReason::kTesting); | 4983 heap->CollectGarbage(NEW_SPACE, i::GarbageCollectionReason::kTesting); |
4944 | 4984 |
4945 // First create a few objects which will survive a scavenge, and will get | 4985 // First create a few objects which will survive a scavenge, and will get |
4946 // promoted to the old generation later on. These objects will create | 4986 // promoted to the old generation later on. These objects will create |
4947 // promotion queue entries at the end of the second semi-space page. | 4987 // promotion queue entries at the end of the second semi-space page. |
4948 const int number_handles = 12; | 4988 const int number_handles = 12; |
4949 Handle<FixedArray> handles[number_handles]; | 4989 Handle<FixedArray> handles[number_handles]; |
4950 for (int i = 0; i < number_handles; i++) { | 4990 for (int i = 0; i < number_handles; i++) { |
4951 handles[i] = i_isolate->factory()->NewFixedArray(1, NOT_TENURED); | 4991 handles[i] = i_isolate->factory()->NewFixedArray(1, NOT_TENURED); |
4952 } | 4992 } |
4953 | 4993 |
4954 heap->CollectGarbage(NEW_SPACE, i::GarbageCollectionReason::kTesting); | 4994 heap->CollectGarbage(NEW_SPACE, i::GarbageCollectionReason::kTesting); |
4955 CHECK_EQ(static_cast<size_t>(i::FLAG_min_semi_space_size * MB), | 4995 CHECK_EQ(static_cast<size_t>(FLAG_min_semi_space_size * MB), |
4956 new_space->TotalCapacity()); | 4996 new_space->TotalCapacity()); |
4957 | 4997 |
4958 // Fill-up the first semi-space page. | 4998 // Fill-up the first semi-space page. |
4959 heap::FillUpOnePage(new_space); | 4999 heap::FillUpOnePage(new_space); |
4960 | 5000 |
4961 // Create a small object to initialize the bump pointer on the second | 5001 // Create a small object to initialize the bump pointer on the second |
4962 // semi-space page. | 5002 // semi-space page. |
4963 Handle<FixedArray> small = | 5003 Handle<FixedArray> small = |
4964 i_isolate->factory()->NewFixedArray(1, NOT_TENURED); | 5004 i_isolate->factory()->NewFixedArray(1, NOT_TENURED); |
4965 CHECK(heap->InNewSpace(*small)); | 5005 CHECK(heap->InNewSpace(*small)); |
4966 | 5006 |
4967 // Fill-up the second semi-space page. | 5007 // Fill-up the second semi-space page. |
4968 heap::FillUpOnePage(new_space); | 5008 heap::FillUpOnePage(new_space); |
4969 | 5009 |
4970 // This scavenge will corrupt memory if the promotion queue is not | 5010 // This scavenge will corrupt memory if the promotion queue is not |
4971 // evacuated. | 5011 // evacuated. |
4972 heap->CollectGarbage(NEW_SPACE, i::GarbageCollectionReason::kTesting); | 5012 heap->CollectGarbage(NEW_SPACE, i::GarbageCollectionReason::kTesting); |
4973 } | 5013 } |
4974 isolate->Dispose(); | 5014 isolate->Dispose(); |
4975 } | 5015 } |
4976 | 5016 |
4977 | 5017 |
4978 TEST(Regress388880) { | 5018 TEST(Regress388880) { |
4979 if (!FLAG_incremental_marking) return; | 5019 if (!FLAG_incremental_marking) return; |
4980 i::FLAG_expose_gc = true; | 5020 FLAG_stress_incremental_marking = false; |
| 5021 FLAG_expose_gc = true; |
4981 CcTest::InitializeVM(); | 5022 CcTest::InitializeVM(); |
4982 v8::HandleScope scope(CcTest::isolate()); | 5023 v8::HandleScope scope(CcTest::isolate()); |
4983 Isolate* isolate = CcTest::i_isolate(); | 5024 Isolate* isolate = CcTest::i_isolate(); |
4984 Factory* factory = isolate->factory(); | 5025 Factory* factory = isolate->factory(); |
4985 Heap* heap = isolate->heap(); | 5026 Heap* heap = isolate->heap(); |
4986 | 5027 |
4987 Handle<Map> map1 = Map::Create(isolate, 1); | 5028 Handle<Map> map1 = Map::Create(isolate, 1); |
4988 Handle<String> name = factory->NewStringFromStaticChars("foo"); | 5029 Handle<String> name = factory->NewStringFromStaticChars("foo"); |
4989 name = factory->InternalizeString(name); | 5030 name = factory->InternalizeString(name); |
4990 Handle<Map> map2 = | 5031 Handle<Map> map2 = |
(...skipping 27 matching lines...) Expand all Loading... |
5018 CHECK(marking->IsMarking()); | 5059 CHECK(marking->IsMarking()); |
5019 | 5060 |
5020 // Now everything is set up for crashing in JSObject::MigrateFastToFast() | 5061 // Now everything is set up for crashing in JSObject::MigrateFastToFast() |
5021 // when it calls heap->AdjustLiveBytes(...). | 5062 // when it calls heap->AdjustLiveBytes(...). |
5022 JSObject::MigrateToMap(o, map2); | 5063 JSObject::MigrateToMap(o, map2); |
5023 } | 5064 } |
5024 | 5065 |
5025 | 5066 |
5026 TEST(Regress3631) { | 5067 TEST(Regress3631) { |
5027 if (!FLAG_incremental_marking) return; | 5068 if (!FLAG_incremental_marking) return; |
5028 i::FLAG_expose_gc = true; | 5069 FLAG_expose_gc = true; |
5029 CcTest::InitializeVM(); | 5070 CcTest::InitializeVM(); |
5030 v8::HandleScope scope(CcTest::isolate()); | 5071 v8::HandleScope scope(CcTest::isolate()); |
5031 Isolate* isolate = CcTest::i_isolate(); | 5072 Isolate* isolate = CcTest::i_isolate(); |
5032 Heap* heap = isolate->heap(); | 5073 Heap* heap = isolate->heap(); |
5033 IncrementalMarking* marking = CcTest::heap()->incremental_marking(); | 5074 IncrementalMarking* marking = CcTest::heap()->incremental_marking(); |
5034 v8::Local<v8::Value> result = CompileRun( | 5075 v8::Local<v8::Value> result = CompileRun( |
5035 "var weak_map = new WeakMap();" | 5076 "var weak_map = new WeakMap();" |
5036 "var future_keys = [];" | 5077 "var future_keys = [];" |
5037 "for (var i = 0; i < 50; i++) {" | 5078 "for (var i = 0; i < 50; i++) {" |
5038 " var key = {'k' : i + 0.1};" | 5079 " var key = {'k' : i + 0.1};" |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5153 } | 5194 } |
5154 CHECK(!weak_cell->cleared()); | 5195 CHECK(!weak_cell->cleared()); |
5155 heap::SimulateIncrementalMarking(heap); | 5196 heap::SimulateIncrementalMarking(heap); |
5156 CcTest::CollectGarbage(OLD_SPACE); | 5197 CcTest::CollectGarbage(OLD_SPACE); |
5157 CHECK(weak_cell->cleared()); | 5198 CHECK(weak_cell->cleared()); |
5158 } | 5199 } |
5159 | 5200 |
5160 | 5201 |
5161 TEST(MapRetaining) { | 5202 TEST(MapRetaining) { |
5162 if (!FLAG_incremental_marking) return; | 5203 if (!FLAG_incremental_marking) return; |
| 5204 FLAG_stress_incremental_marking = false; |
5163 CcTest::InitializeVM(); | 5205 CcTest::InitializeVM(); |
5164 v8::HandleScope scope(CcTest::isolate()); | 5206 v8::HandleScope scope(CcTest::isolate()); |
5165 CheckMapRetainingFor(FLAG_retain_maps_for_n_gc); | 5207 CheckMapRetainingFor(FLAG_retain_maps_for_n_gc); |
5166 CheckMapRetainingFor(0); | 5208 CheckMapRetainingFor(0); |
5167 CheckMapRetainingFor(1); | 5209 CheckMapRetainingFor(1); |
5168 CheckMapRetainingFor(7); | 5210 CheckMapRetainingFor(7); |
5169 } | 5211 } |
5170 | 5212 |
5171 | 5213 |
5172 TEST(RegressArrayListGC) { | 5214 TEST(RegressArrayListGC) { |
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5838 Isolate* isolate = heap->isolate(); | 5880 Isolate* isolate = heap->isolate(); |
5839 | 5881 |
5840 intptr_t size_before = heap->SizeOfObjects(); | 5882 intptr_t size_before = heap->SizeOfObjects(); |
5841 Handle<FixedArray> array = isolate->factory()->NewFixedArray(200000); | 5883 Handle<FixedArray> array = isolate->factory()->NewFixedArray(200000); |
5842 array->Shrink(1); | 5884 array->Shrink(1); |
5843 intptr_t size_after = heap->SizeOfObjects(); | 5885 intptr_t size_after = heap->SizeOfObjects(); |
5844 CHECK_EQ(size_after, size_before + array->Size()); | 5886 CHECK_EQ(size_after, size_before + array->Size()); |
5845 } | 5887 } |
5846 | 5888 |
5847 TEST(Regress615489) { | 5889 TEST(Regress615489) { |
5848 if (!i::FLAG_incremental_marking) return; | 5890 if (!FLAG_incremental_marking) return; |
5849 FLAG_black_allocation = true; | 5891 FLAG_black_allocation = true; |
5850 CcTest::InitializeVM(); | 5892 CcTest::InitializeVM(); |
5851 v8::HandleScope scope(CcTest::isolate()); | 5893 v8::HandleScope scope(CcTest::isolate()); |
5852 Heap* heap = CcTest::heap(); | 5894 Heap* heap = CcTest::heap(); |
5853 Isolate* isolate = heap->isolate(); | 5895 Isolate* isolate = heap->isolate(); |
5854 CcTest::CollectAllGarbage(); | 5896 CcTest::CollectAllGarbage(); |
5855 | 5897 |
5856 i::MarkCompactCollector* collector = heap->mark_compact_collector(); | 5898 i::MarkCompactCollector* collector = heap->mark_compact_collector(); |
5857 i::IncrementalMarking* marking = heap->incremental_marking(); | 5899 i::IncrementalMarking* marking = heap->incremental_marking(); |
5858 if (collector->sweeping_in_progress()) { | 5900 if (collector->sweeping_in_progress()) { |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5939 } | 5981 } |
5940 | 5982 |
5941 { | 5983 { |
5942 StaticOneByteResource external_string("12345678901234"); | 5984 StaticOneByteResource external_string("12345678901234"); |
5943 s3->MakeExternal(&external_string); | 5985 s3->MakeExternal(&external_string); |
5944 CcTest::CollectGarbage(OLD_SPACE); | 5986 CcTest::CollectGarbage(OLD_SPACE); |
5945 } | 5987 } |
5946 } | 5988 } |
5947 | 5989 |
5948 TEST(LeftTrimFixedArrayInBlackArea) { | 5990 TEST(LeftTrimFixedArrayInBlackArea) { |
5949 if (!i::FLAG_incremental_marking) return; | 5991 if (!FLAG_incremental_marking) return; |
5950 FLAG_black_allocation = true; | 5992 FLAG_black_allocation = true; |
5951 CcTest::InitializeVM(); | 5993 CcTest::InitializeVM(); |
5952 v8::HandleScope scope(CcTest::isolate()); | 5994 v8::HandleScope scope(CcTest::isolate()); |
5953 Heap* heap = CcTest::heap(); | 5995 Heap* heap = CcTest::heap(); |
5954 Isolate* isolate = heap->isolate(); | 5996 Isolate* isolate = heap->isolate(); |
5955 CcTest::CollectAllGarbage(); | 5997 CcTest::CollectAllGarbage(); |
5956 | 5998 |
5957 i::MarkCompactCollector* collector = heap->mark_compact_collector(); | 5999 i::MarkCompactCollector* collector = heap->mark_compact_collector(); |
5958 i::IncrementalMarking* marking = heap->incremental_marking(); | 6000 i::IncrementalMarking* marking = heap->incremental_marking(); |
5959 if (collector->sweeping_in_progress()) { | 6001 if (collector->sweeping_in_progress()) { |
(...skipping 18 matching lines...) Expand all Loading... |
5978 // Now left trim the allocated black area. A filler has to be installed | 6020 // Now left trim the allocated black area. A filler has to be installed |
5979 // for the trimmed area and all mark bits of the trimmed area have to be | 6021 // for the trimmed area and all mark bits of the trimmed area have to be |
5980 // cleared. | 6022 // cleared. |
5981 FixedArrayBase* trimmed = heap->LeftTrimFixedArray(*array, 10); | 6023 FixedArrayBase* trimmed = heap->LeftTrimFixedArray(*array, 10); |
5982 CHECK(ObjectMarking::IsBlack(trimmed, MarkingState::Internal(trimmed))); | 6024 CHECK(ObjectMarking::IsBlack(trimmed, MarkingState::Internal(trimmed))); |
5983 | 6025 |
5984 heap::GcAndSweep(heap, OLD_SPACE); | 6026 heap::GcAndSweep(heap, OLD_SPACE); |
5985 } | 6027 } |
5986 | 6028 |
5987 TEST(ContinuousLeftTrimFixedArrayInBlackArea) { | 6029 TEST(ContinuousLeftTrimFixedArrayInBlackArea) { |
5988 if (!i::FLAG_incremental_marking) return; | 6030 if (!FLAG_incremental_marking) return; |
5989 FLAG_black_allocation = true; | 6031 FLAG_black_allocation = true; |
5990 CcTest::InitializeVM(); | 6032 CcTest::InitializeVM(); |
5991 v8::HandleScope scope(CcTest::isolate()); | 6033 v8::HandleScope scope(CcTest::isolate()); |
5992 Heap* heap = CcTest::heap(); | 6034 Heap* heap = CcTest::heap(); |
5993 Isolate* isolate = heap->isolate(); | 6035 Isolate* isolate = heap->isolate(); |
5994 CcTest::CollectAllGarbage(); | 6036 CcTest::CollectAllGarbage(); |
5995 | 6037 |
5996 i::MarkCompactCollector* collector = heap->mark_compact_collector(); | 6038 i::MarkCompactCollector* collector = heap->mark_compact_collector(); |
5997 i::IncrementalMarking* marking = heap->incremental_marking(); | 6039 i::IncrementalMarking* marking = heap->incremental_marking(); |
5998 if (collector->sweeping_in_progress()) { | 6040 if (collector->sweeping_in_progress()) { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6044 CHECK(ObjectMarking::IsBlack(trimmed, MarkingState::Internal(trimmed))); | 6086 CHECK(ObjectMarking::IsBlack(trimmed, MarkingState::Internal(trimmed))); |
6045 CHECK(ObjectMarking::IsBlack(previous, MarkingState::Internal(previous))); | 6087 CHECK(ObjectMarking::IsBlack(previous, MarkingState::Internal(previous))); |
6046 previous = trimmed; | 6088 previous = trimmed; |
6047 } | 6089 } |
6048 } | 6090 } |
6049 | 6091 |
6050 heap::GcAndSweep(heap, OLD_SPACE); | 6092 heap::GcAndSweep(heap, OLD_SPACE); |
6051 } | 6093 } |
6052 | 6094 |
6053 TEST(ContinuousRightTrimFixedArrayInBlackArea) { | 6095 TEST(ContinuousRightTrimFixedArrayInBlackArea) { |
6054 if (!i::FLAG_incremental_marking) return; | 6096 if (!FLAG_incremental_marking) return; |
6055 FLAG_black_allocation = true; | 6097 FLAG_black_allocation = true; |
6056 CcTest::InitializeVM(); | 6098 CcTest::InitializeVM(); |
6057 v8::HandleScope scope(CcTest::isolate()); | 6099 v8::HandleScope scope(CcTest::isolate()); |
6058 Heap* heap = CcTest::heap(); | 6100 Heap* heap = CcTest::heap(); |
6059 Isolate* isolate = heap->isolate(); | 6101 Isolate* isolate = heap->isolate(); |
6060 CcTest::CollectAllGarbage(); | 6102 CcTest::CollectAllGarbage(); |
6061 | 6103 |
6062 i::MarkCompactCollector* collector = heap->mark_compact_collector(); | 6104 i::MarkCompactCollector* collector = heap->mark_compact_collector(); |
6063 i::IncrementalMarking* marking = heap->incremental_marking(); | 6105 i::IncrementalMarking* marking = heap->incremental_marking(); |
6064 if (collector->sweeping_in_progress()) { | 6106 if (collector->sweeping_in_progress()) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6104 HeapObject* filler = HeapObject::FromAddress(previous); | 6146 HeapObject* filler = HeapObject::FromAddress(previous); |
6105 CHECK(filler->IsFiller()); | 6147 CHECK(filler->IsFiller()); |
6106 CHECK(ObjectMarking::IsWhite(filler, MarkingState::Internal(filler))); | 6148 CHECK(ObjectMarking::IsWhite(filler, MarkingState::Internal(filler))); |
6107 } | 6149 } |
6108 } | 6150 } |
6109 | 6151 |
6110 heap::GcAndSweep(heap, OLD_SPACE); | 6152 heap::GcAndSweep(heap, OLD_SPACE); |
6111 } | 6153 } |
6112 | 6154 |
6113 TEST(Regress618958) { | 6155 TEST(Regress618958) { |
6114 if (!i::FLAG_incremental_marking) return; | 6156 if (!FLAG_incremental_marking) return; |
6115 CcTest::InitializeVM(); | 6157 CcTest::InitializeVM(); |
6116 v8::HandleScope scope(CcTest::isolate()); | 6158 v8::HandleScope scope(CcTest::isolate()); |
6117 Heap* heap = CcTest::heap(); | 6159 Heap* heap = CcTest::heap(); |
6118 bool isolate_is_locked = true; | 6160 bool isolate_is_locked = true; |
6119 heap->update_external_memory(100 * MB); | 6161 heap->update_external_memory(100 * MB); |
6120 int mark_sweep_count_before = heap->ms_count(); | 6162 int mark_sweep_count_before = heap->ms_count(); |
6121 heap->MemoryPressureNotification(MemoryPressureLevel::kCritical, | 6163 heap->MemoryPressureNotification(MemoryPressureLevel::kCritical, |
6122 isolate_is_locked); | 6164 isolate_is_locked); |
6123 int mark_sweep_count_after = heap->ms_count(); | 6165 int mark_sweep_count_after = heap->ms_count(); |
6124 int mark_sweeps_performed = mark_sweep_count_after - mark_sweep_count_before; | 6166 int mark_sweeps_performed = mark_sweep_count_after - mark_sweep_count_before; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6214 SlotSet::FREE_EMPTY_BUCKETS); | 6256 SlotSet::FREE_EMPTY_BUCKETS); |
6215 slots[chunk->area_end() - kPointerSize] = false; | 6257 slots[chunk->area_end() - kPointerSize] = false; |
6216 RememberedSet<OLD_TO_NEW>::Iterate(chunk, [&slots](Address addr) { | 6258 RememberedSet<OLD_TO_NEW>::Iterate(chunk, [&slots](Address addr) { |
6217 CHECK(slots[addr]); | 6259 CHECK(slots[addr]); |
6218 return KEEP_SLOT; | 6260 return KEEP_SLOT; |
6219 }); | 6261 }); |
6220 } | 6262 } |
6221 | 6263 |
6222 HEAP_TEST(Regress670675) { | 6264 HEAP_TEST(Regress670675) { |
6223 if (!FLAG_incremental_marking) return; | 6265 if (!FLAG_incremental_marking) return; |
| 6266 FLAG_stress_incremental_marking = false; |
6224 CcTest::InitializeVM(); | 6267 CcTest::InitializeVM(); |
6225 v8::HandleScope scope(CcTest::isolate()); | 6268 v8::HandleScope scope(CcTest::isolate()); |
6226 Heap* heap = CcTest::heap(); | 6269 Heap* heap = CcTest::heap(); |
6227 Isolate* isolate = heap->isolate(); | 6270 Isolate* isolate = heap->isolate(); |
6228 i::MarkCompactCollector* collector = heap->mark_compact_collector(); | 6271 i::MarkCompactCollector* collector = heap->mark_compact_collector(); |
6229 CcTest::CollectAllGarbage(); | 6272 CcTest::CollectAllGarbage(); |
6230 | 6273 |
6231 if (collector->sweeping_in_progress()) { | 6274 if (collector->sweeping_in_progress()) { |
6232 collector->EnsureSweepingCompleted(); | 6275 collector->EnsureSweepingCompleted(); |
6233 } | 6276 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6298 CHECK(!heap->code_space()->FirstPage()->Contains(code->address())); | 6341 CHECK(!heap->code_space()->FirstPage()->Contains(code->address())); |
6299 | 6342 |
6300 // Ensure it's not in large object space. | 6343 // Ensure it's not in large object space. |
6301 MemoryChunk* chunk = MemoryChunk::FromAddress(code->address()); | 6344 MemoryChunk* chunk = MemoryChunk::FromAddress(code->address()); |
6302 CHECK(chunk->owner()->identity() != LO_SPACE); | 6345 CHECK(chunk->owner()->identity() != LO_SPACE); |
6303 CHECK(chunk->NeverEvacuate()); | 6346 CHECK(chunk->NeverEvacuate()); |
6304 } | 6347 } |
6305 | 6348 |
6306 } // namespace internal | 6349 } // namespace internal |
6307 } // namespace v8 | 6350 } // namespace v8 |
OLD | NEW |