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

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

Issue 141363005: A64: Synchronize with r15204. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/cctest/test-global-object.cc ('k') | test/cctest/test-heap-profiler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 396
397 static void TestWeakGlobalHandleCallback(v8::Isolate* isolate, 397 static void TestWeakGlobalHandleCallback(v8::Isolate* isolate,
398 v8::Persistent<v8::Value>* handle, 398 v8::Persistent<v8::Value>* handle,
399 void* id) { 399 void* id) {
400 if (1234 == reinterpret_cast<intptr_t>(id)) WeakPointerCleared = true; 400 if (1234 == reinterpret_cast<intptr_t>(id)) WeakPointerCleared = true;
401 handle->Dispose(isolate); 401 handle->Dispose(isolate);
402 } 402 }
403 403
404 404
405 TEST(WeakGlobalHandlesScavenge) { 405 TEST(WeakGlobalHandlesScavenge) {
406 i::FLAG_stress_compaction = false;
406 CcTest::InitializeVM(); 407 CcTest::InitializeVM();
407 Isolate* isolate = Isolate::Current(); 408 Isolate* isolate = Isolate::Current();
408 Heap* heap = isolate->heap(); 409 Heap* heap = isolate->heap();
409 Factory* factory = isolate->factory(); 410 Factory* factory = isolate->factory();
410 GlobalHandles* global_handles = isolate->global_handles(); 411 GlobalHandles* global_handles = isolate->global_handles();
411 412
412 WeakPointerCleared = false; 413 WeakPointerCleared = false;
413 414
414 Handle<Object> h1; 415 Handle<Object> h1;
415 Handle<Object> h2; 416 Handle<Object> h2;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 CHECK((*h1)->IsString()); 483 CHECK((*h1)->IsString());
483 484
484 CHECK(WeakPointerCleared); 485 CHECK(WeakPointerCleared);
485 CHECK(!GlobalHandles::IsNearDeath(h1.location())); 486 CHECK(!GlobalHandles::IsNearDeath(h1.location()));
486 487
487 global_handles->Destroy(h1.location()); 488 global_handles->Destroy(h1.location());
488 } 489 }
489 490
490 491
491 TEST(DeleteWeakGlobalHandle) { 492 TEST(DeleteWeakGlobalHandle) {
493 i::FLAG_stress_compaction = false;
492 CcTest::InitializeVM(); 494 CcTest::InitializeVM();
493 Isolate* isolate = Isolate::Current(); 495 Isolate* isolate = Isolate::Current();
494 Heap* heap = isolate->heap(); 496 Heap* heap = isolate->heap();
495 Factory* factory = isolate->factory(); 497 Factory* factory = isolate->factory();
496 GlobalHandles* global_handles = isolate->global_handles(); 498 GlobalHandles* global_handles = isolate->global_handles();
497 499
498 WeakPointerCleared = false; 500 WeakPointerCleared = false;
499 501
500 Handle<Object> h; 502 Handle<Object> h;
501 503
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
870 CHECK_EQ(length, ascii_str->length()); 872 CHECK_EQ(length, ascii_str->length());
871 DeleteArray(non_ascii); 873 DeleteArray(non_ascii);
872 DeleteArray(ascii); 874 DeleteArray(ascii);
873 } 875 }
874 } 876 }
875 877
876 878
877 static int ObjectsFoundInHeap(Heap* heap, Handle<Object> objs[], int size) { 879 static int ObjectsFoundInHeap(Heap* heap, Handle<Object> objs[], int size) {
878 // Count the number of objects found in the heap. 880 // Count the number of objects found in the heap.
879 int found_count = 0; 881 int found_count = 0;
882 heap->EnsureHeapIsIterable();
880 HeapIterator iterator(heap); 883 HeapIterator iterator(heap);
881 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { 884 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) {
882 for (int i = 0; i < size; i++) { 885 for (int i = 0; i < size; i++) {
883 if (*objs[i] == obj) { 886 if (*objs[i] == obj) {
884 found_count++; 887 found_count++;
885 } 888 }
886 } 889 }
887 } 890 }
888 return found_count; 891 return found_count;
889 } 892 }
(...skipping 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after
1970 map->GetPrototypeTransitions()->address())); 1973 map->GetPrototypeTransitions()->address()));
1971 CHECK(space->LastPage()->Contains(prototype->address())); 1974 CHECK(space->LastPage()->Contains(prototype->address()));
1972 baseObject->SetPrototype(*prototype, false)->ToObjectChecked(); 1975 baseObject->SetPrototype(*prototype, false)->ToObjectChecked();
1973 CHECK(map->GetPrototypeTransition(*prototype)->IsMap()); 1976 CHECK(map->GetPrototypeTransition(*prototype)->IsMap());
1974 HEAP->CollectAllGarbage(Heap::kNoGCFlags); 1977 HEAP->CollectAllGarbage(Heap::kNoGCFlags);
1975 CHECK(map->GetPrototypeTransition(*prototype)->IsMap()); 1978 CHECK(map->GetPrototypeTransition(*prototype)->IsMap());
1976 } 1979 }
1977 1980
1978 1981
1979 TEST(ResetSharedFunctionInfoCountersDuringIncrementalMarking) { 1982 TEST(ResetSharedFunctionInfoCountersDuringIncrementalMarking) {
1983 i::FLAG_stress_compaction = false;
1980 i::FLAG_allow_natives_syntax = true; 1984 i::FLAG_allow_natives_syntax = true;
1981 #ifdef VERIFY_HEAP 1985 #ifdef VERIFY_HEAP
1982 i::FLAG_verify_heap = true; 1986 i::FLAG_verify_heap = true;
1983 #endif 1987 #endif
1984 1988
1985 CcTest::InitializeVM(); 1989 CcTest::InitializeVM();
1986 if (!i::V8::UseCrankshaft()) return; 1990 if (!i::V8::UseCrankshaft()) return;
1987 v8::HandleScope outer_scope(v8::Isolate::GetCurrent()); 1991 v8::HandleScope outer_scope(v8::Isolate::GetCurrent());
1988 1992
1989 { 1993 {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
2026 "Test finalizing incremental mark-sweep"); 2030 "Test finalizing incremental mark-sweep");
2027 } 2031 }
2028 2032
2029 CHECK_EQ(HEAP->global_ic_age(), f->shared()->ic_age()); 2033 CHECK_EQ(HEAP->global_ic_age(), f->shared()->ic_age());
2030 CHECK_EQ(0, f->shared()->opt_count()); 2034 CHECK_EQ(0, f->shared()->opt_count());
2031 CHECK_EQ(0, f->shared()->code()->profiler_ticks()); 2035 CHECK_EQ(0, f->shared()->code()->profiler_ticks());
2032 } 2036 }
2033 2037
2034 2038
2035 TEST(ResetSharedFunctionInfoCountersDuringMarkSweep) { 2039 TEST(ResetSharedFunctionInfoCountersDuringMarkSweep) {
2040 i::FLAG_stress_compaction = false;
2036 i::FLAG_allow_natives_syntax = true; 2041 i::FLAG_allow_natives_syntax = true;
2037 #ifdef VERIFY_HEAP 2042 #ifdef VERIFY_HEAP
2038 i::FLAG_verify_heap = true; 2043 i::FLAG_verify_heap = true;
2039 #endif 2044 #endif
2040 2045
2041 CcTest::InitializeVM(); 2046 CcTest::InitializeVM();
2042 if (!i::V8::UseCrankshaft()) return; 2047 if (!i::V8::UseCrankshaft()) return;
2043 v8::HandleScope outer_scope(CcTest::isolate()); 2048 v8::HandleScope outer_scope(CcTest::isolate());
2044 2049
2045 { 2050 {
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
2208 } 2213 }
2209 2214
2210 static int CountMapTransitions(Map* map) { 2215 static int CountMapTransitions(Map* map) {
2211 return map->transitions()->number_of_transitions(); 2216 return map->transitions()->number_of_transitions();
2212 } 2217 }
2213 2218
2214 2219
2215 // Test that map transitions are cleared and maps are collected with 2220 // Test that map transitions are cleared and maps are collected with
2216 // incremental marking as well. 2221 // incremental marking as well.
2217 TEST(Regress1465) { 2222 TEST(Regress1465) {
2223 i::FLAG_stress_compaction = false;
2218 i::FLAG_allow_natives_syntax = true; 2224 i::FLAG_allow_natives_syntax = true;
2219 i::FLAG_trace_incremental_marking = true; 2225 i::FLAG_trace_incremental_marking = true;
2220 CcTest::InitializeVM(); 2226 CcTest::InitializeVM();
2221 v8::HandleScope scope(CcTest::isolate()); 2227 v8::HandleScope scope(CcTest::isolate());
2222 static const int transitions_count = 256; 2228 static const int transitions_count = 256;
2223 2229
2224 { 2230 {
2225 AlwaysAllocateScope always_allocate; 2231 AlwaysAllocateScope always_allocate;
2226 for (int i = 0; i < transitions_count; i++) { 2232 for (int i = 0; i < transitions_count; i++) {
2227 EmbeddedVector<char, 64> buffer; 2233 EmbeddedVector<char, 64> buffer;
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
2375 // size of the first page a little in SizeOfFirstPage in spaces.cc. The 2381 // size of the first page a little in SizeOfFirstPage in spaces.cc. The
2376 // first page should be small in order to reduce memory used when the VM 2382 // first page should be small in order to reduce memory used when the VM
2377 // boots, but if the 20 small arrays don't fit on the first page then that's 2383 // boots, but if the 20 small arrays don't fit on the first page then that's
2378 // an indication that it is too small. 2384 // an indication that it is too small.
2379 HEAP->CollectAllAvailableGarbage("triggered really hard"); 2385 HEAP->CollectAllAvailableGarbage("triggered really hard");
2380 CHECK_EQ(1, old_pointer_space->CountTotalPages()); 2386 CHECK_EQ(1, old_pointer_space->CountTotalPages());
2381 } 2387 }
2382 2388
2383 2389
2384 TEST(Regress2237) { 2390 TEST(Regress2237) {
2391 i::FLAG_stress_compaction = false;
2385 CcTest::InitializeVM(); 2392 CcTest::InitializeVM();
2386 Isolate* isolate = Isolate::Current(); 2393 Isolate* isolate = Isolate::Current();
2387 Factory* factory = isolate->factory(); 2394 Factory* factory = isolate->factory();
2388 v8::HandleScope scope(CcTest::isolate()); 2395 v8::HandleScope scope(CcTest::isolate());
2389 Handle<String> slice(HEAP->empty_string()); 2396 Handle<String> slice(HEAP->empty_string());
2390 2397
2391 { 2398 {
2392 // Generate a parent that lives in new-space. 2399 // Generate a parent that lives in new-space.
2393 v8::HandleScope inner_scope(CcTest::isolate()); 2400 v8::HandleScope inner_scope(CcTest::isolate());
2394 const char* c = "This text is long enough to trigger sliced strings."; 2401 const char* c = "This text is long enough to trigger sliced strings.";
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
2491 v8::Context::GetCurrent()->Global()->Set(v8_str("fun2"), fun2); 2498 v8::Context::GetCurrent()->Global()->Set(v8_str("fun2"), fun2);
2492 CompileRun("function f(a, b) { a(); b(); } f(fun1, fun2);"); 2499 CompileRun("function f(a, b) { a(); b(); } f(fun1, fun2);");
2493 Handle<JSFunction> f = 2500 Handle<JSFunction> f =
2494 v8::Utils::OpenHandle( 2501 v8::Utils::OpenHandle(
2495 *v8::Handle<v8::Function>::Cast( 2502 *v8::Handle<v8::Function>::Cast(
2496 v8::Context::GetCurrent()->Global()->Get(v8_str("f")))); 2503 v8::Context::GetCurrent()->Global()->Get(v8_str("f"))));
2497 Handle<TypeFeedbackCells> cells(TypeFeedbackInfo::cast( 2504 Handle<TypeFeedbackCells> cells(TypeFeedbackInfo::cast(
2498 f->shared()->code()->type_feedback_info())->type_feedback_cells()); 2505 f->shared()->code()->type_feedback_info())->type_feedback_cells());
2499 2506
2500 CHECK_EQ(2, cells->CellCount()); 2507 CHECK_EQ(2, cells->CellCount());
2501 CHECK(cells->Cell(0)->value()->IsJSFunction()); 2508 CHECK(cells->GetCell(0)->value()->IsJSFunction());
2502 CHECK(cells->Cell(1)->value()->IsJSFunction()); 2509 CHECK(cells->GetCell(1)->value()->IsJSFunction());
2503 2510
2504 SimulateIncrementalMarking(); 2511 SimulateIncrementalMarking();
2505 HEAP->CollectAllGarbage(Heap::kNoGCFlags); 2512 HEAP->CollectAllGarbage(Heap::kNoGCFlags);
2506 2513
2507 CHECK_EQ(2, cells->CellCount()); 2514 CHECK_EQ(2, cells->CellCount());
2508 CHECK(cells->Cell(0)->value()->IsTheHole()); 2515 CHECK(cells->GetCell(0)->value()->IsTheHole());
2509 CHECK(cells->Cell(1)->value()->IsTheHole()); 2516 CHECK(cells->GetCell(1)->value()->IsTheHole());
2510 } 2517 }
2511 2518
2512 2519
2513 static Code* FindFirstIC(Code* code, Code::Kind kind) { 2520 static Code* FindFirstIC(Code* code, Code::Kind kind) {
2514 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET) | 2521 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET) |
2515 RelocInfo::ModeMask(RelocInfo::CONSTRUCT_CALL) | 2522 RelocInfo::ModeMask(RelocInfo::CONSTRUCT_CALL) |
2516 RelocInfo::ModeMask(RelocInfo::CODE_TARGET_WITH_ID) | 2523 RelocInfo::ModeMask(RelocInfo::CODE_TARGET_WITH_ID) |
2517 RelocInfo::ModeMask(RelocInfo::CODE_TARGET_CONTEXT); 2524 RelocInfo::ModeMask(RelocInfo::CODE_TARGET_CONTEXT);
2518 for (RelocIterator it(code, mask); !it.done(); it.next()) { 2525 for (RelocIterator it(code, mask); !it.done(); it.next()) {
2519 RelocInfo* info = it.rinfo(); 2526 RelocInfo* info = it.rinfo();
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
2682 " (function f() { f(); })(); " 2689 " (function f() { f(); })(); "
2683 "} catch (e) { " 2690 "} catch (e) { "
2684 " error = e; " 2691 " error = e; "
2685 "} "; 2692 "} ";
2686 ReleaseStackTraceDataTest(source1); 2693 ReleaseStackTraceDataTest(source1);
2687 ReleaseStackTraceDataTest(source2); 2694 ReleaseStackTraceDataTest(source2);
2688 } 2695 }
2689 2696
2690 2697
2691 TEST(Regression144230) { 2698 TEST(Regression144230) {
2699 i::FLAG_stress_compaction = false;
2692 CcTest::InitializeVM(); 2700 CcTest::InitializeVM();
2693 Isolate* isolate = Isolate::Current(); 2701 Isolate* isolate = Isolate::Current();
2694 Heap* heap = isolate->heap(); 2702 Heap* heap = isolate->heap();
2695 HandleScope scope(isolate); 2703 HandleScope scope(isolate);
2696 2704
2697 // First make sure that the uninitialized CallIC stub is on a single page 2705 // First make sure that the uninitialized CallIC stub is on a single page
2698 // that will later be selected as an evacuation candidate. 2706 // that will later be selected as an evacuation candidate.
2699 { 2707 {
2700 HandleScope inner_scope(isolate); 2708 HandleScope inner_scope(isolate);
2701 AlwaysAllocateScope always_allocate; 2709 AlwaysAllocateScope always_allocate;
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
3171 " var a = new Array(n);" 3179 " var a = new Array(n);"
3172 " for (var i = 0; i < n; i += 100) a[i] = i;" 3180 " for (var i = 0; i < n; i += 100) a[i] = i;"
3173 "};" 3181 "};"
3174 "f(10 * 1024 * 1024);"); 3182 "f(10 * 1024 * 1024);");
3175 IncrementalMarking* marking = HEAP->incremental_marking(); 3183 IncrementalMarking* marking = HEAP->incremental_marking();
3176 if (marking->IsStopped()) marking->Start(); 3184 if (marking->IsStopped()) marking->Start();
3177 // This big step should be sufficient to mark the whole array. 3185 // This big step should be sufficient to mark the whole array.
3178 marking->Step(100 * MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD); 3186 marking->Step(100 * MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD);
3179 ASSERT(marking->IsComplete()); 3187 ASSERT(marking->IsComplete());
3180 } 3188 }
OLDNEW
« no previous file with comments | « test/cctest/test-global-object.cc ('k') | test/cctest/test-heap-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698