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

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

Issue 1314863003: [heap] More flag cleanup. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix compilation and add const to parameters Created 5 years, 4 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
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 591 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 bool success = 602 bool success =
603 cons->MakeExternal(new TestOneByteResource(i::StrDup(c_cons), NULL, 1)); 603 cons->MakeExternal(new TestOneByteResource(i::StrDup(c_cons), NULL, 1));
604 CHECK(success); 604 CHECK(success);
605 const char* c_slice = "_bcdefghijklmnopqrstuvwxyz"; 605 const char* c_slice = "_bcdefghijklmnopqrstuvwxyz";
606 success = 606 success =
607 slice->MakeExternal(new TestOneByteResource(i::StrDup(c_slice), NULL, 1)); 607 slice->MakeExternal(new TestOneByteResource(i::StrDup(c_slice), NULL, 1));
608 CHECK(success); 608 CHECK(success);
609 609
610 // Trigger GCs and force evacuation. 610 // Trigger GCs and force evacuation.
611 CcTest::heap()->CollectAllGarbage(); 611 CcTest::heap()->CollectAllGarbage();
612 CcTest::heap()->CollectAllGarbage(i::Heap::kReduceMemoryFootprintMask); 612 CcTest::heap()->CollectAllGarbage("MakingExternalUnalignedOneByteString",
613 i::Heap::kReduceMemoryFootprintMask);
613 } 614 }
614 615
615 616
616 THREADED_TEST(UsingExternalString) { 617 THREADED_TEST(UsingExternalString) {
617 i::Factory* factory = CcTest::i_isolate()->factory(); 618 i::Factory* factory = CcTest::i_isolate()->factory();
618 { 619 {
619 v8::HandleScope scope(CcTest::isolate()); 620 v8::HandleScope scope(CcTest::isolate());
620 uint16_t* two_byte_string = AsciiToTwoByteString("test string"); 621 uint16_t* two_byte_string = AsciiToTwoByteString("test string");
621 Local<String> string = String::NewExternal( 622 Local<String> string = String::NewExternal(
622 CcTest::isolate(), new TestResource(two_byte_string)); 623 CcTest::isolate(), new TestResource(two_byte_string));
(...skipping 2760 matching lines...) Expand 10 before | Expand all | Expand 10 after
3383 Local<v8::Object> expected2 = NewObjectForIntKey(isolate, templ, 8); 3384 Local<v8::Object> expected2 = NewObjectForIntKey(isolate, templ, 8);
3384 removed = map.Set(8, v8::Global<v8::Object>(isolate, expected2), &ref); 3385 removed = map.Set(8, v8::Global<v8::Object>(isolate, expected2), &ref);
3385 CHECK_EQ(1, static_cast<int>(map.Size())); 3386 CHECK_EQ(1, static_cast<int>(map.Size()));
3386 CHECK(expected == removed); 3387 CHECK(expected == removed);
3387 CHECK(expected2->Equals(ref.NewLocal(isolate))); 3388 CHECK(expected2->Equals(ref.NewLocal(isolate)));
3388 } 3389 }
3389 } 3390 }
3390 CHECK_EQ(initial_handle_count + 1, global_handles->global_handles_count()); 3391 CHECK_EQ(initial_handle_count + 1, global_handles->global_handles_count());
3391 if (map.IsWeak()) { 3392 if (map.IsWeak()) {
3392 CcTest::i_isolate()->heap()->CollectAllGarbage( 3393 CcTest::i_isolate()->heap()->CollectAllGarbage(
3393 i::Heap::kAbortIncrementalMarkingMask); 3394 "TestGlobalValueMap", i::Heap::kAbortIncrementalMarkingMask);
3394 } else { 3395 } else {
3395 map.Clear(); 3396 map.Clear();
3396 } 3397 }
3397 CHECK_EQ(0, static_cast<int>(map.Size())); 3398 CHECK_EQ(0, static_cast<int>(map.Size()));
3398 CHECK_EQ(initial_handle_count, global_handles->global_handles_count()); 3399 CHECK_EQ(initial_handle_count, global_handles->global_handles_count());
3399 { 3400 {
3400 HandleScope scope(isolate); 3401 HandleScope scope(isolate);
3401 Local<v8::Object> value = NewObjectForIntKey(isolate, templ, 9); 3402 Local<v8::Object> value = NewObjectForIntKey(isolate, templ, 9);
3402 map.Set(9, value); 3403 map.Set(9, value);
3403 map.Clear(); 3404 map.Clear();
(...skipping 3295 matching lines...) Expand 10 before | Expand all | Expand 10 after
6699 6700
6700 FlagAndPersistent object_a, object_b; 6701 FlagAndPersistent object_a, object_b;
6701 6702
6702 { 6703 {
6703 v8::HandleScope handle_scope(iso); 6704 v8::HandleScope handle_scope(iso);
6704 Local<Object> a(v8::Object::New(iso)); 6705 Local<Object> a(v8::Object::New(iso));
6705 Local<Object> b(v8::Object::New(iso)); 6706 Local<Object> b(v8::Object::New(iso));
6706 object_a.handle.Reset(iso, a); 6707 object_a.handle.Reset(iso, a);
6707 object_b.handle.Reset(iso, b); 6708 object_b.handle.Reset(iso, b);
6708 if (global_gc) { 6709 if (global_gc) {
6709 CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); 6710 CcTest::heap()->CollectAllGarbage("ResetWeakHandle",
6711 Heap::kAbortIncrementalMarkingMask);
6710 } else { 6712 } else {
6711 CcTest::heap()->CollectGarbage(i::NEW_SPACE); 6713 CcTest::heap()->CollectGarbage(i::NEW_SPACE);
6712 } 6714 }
6713 } 6715 }
6714 6716
6715 object_a.flag = false; 6717 object_a.flag = false;
6716 object_b.flag = false; 6718 object_b.flag = false;
6717 object_a.handle.SetWeak(&object_a, &ResetUseValueAndSetFlag, 6719 object_a.handle.SetWeak(&object_a, &ResetUseValueAndSetFlag,
6718 v8::WeakCallbackType::kParameter); 6720 v8::WeakCallbackType::kParameter);
6719 object_b.handle.SetWeak(&object_b, &ResetUseValueAndSetFlag, 6721 object_b.handle.SetWeak(&object_b, &ResetUseValueAndSetFlag,
6720 v8::WeakCallbackType::kParameter); 6722 v8::WeakCallbackType::kParameter);
6721 if (!global_gc) { 6723 if (!global_gc) {
6722 object_a.handle.MarkIndependent(); 6724 object_a.handle.MarkIndependent();
6723 object_b.handle.MarkIndependent(); 6725 object_b.handle.MarkIndependent();
6724 CHECK(object_b.handle.IsIndependent()); 6726 CHECK(object_b.handle.IsIndependent());
6725 } 6727 }
6726 if (global_gc) { 6728 if (global_gc) {
6727 CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); 6729 CcTest::heap()->CollectAllGarbage("ResetWeakHandle",
6730 Heap::kAbortIncrementalMarkingMask);
6728 } else { 6731 } else {
6729 CcTest::heap()->CollectGarbage(i::NEW_SPACE); 6732 CcTest::heap()->CollectGarbage(i::NEW_SPACE);
6730 } 6733 }
6731 CHECK(object_a.flag); 6734 CHECK(object_a.flag);
6732 CHECK(object_b.flag); 6735 CHECK(object_b.flag);
6733 } 6736 }
6734 6737
6735 6738
6736 THREADED_HEAP_TEST(ResetWeakHandle) { 6739 THREADED_HEAP_TEST(ResetWeakHandle) {
6737 v8::internal::HeapTester::ResetWeakHandle(false); 6740 v8::internal::HeapTester::ResetWeakHandle(false);
(...skipping 4967 matching lines...) Expand 10 before | Expand all | Expand 10 after
11705 } 11708 }
11706 11709
11707 11710
11708 static void CheckSurvivingGlobalObjectsCount(int expected) { 11711 static void CheckSurvivingGlobalObjectsCount(int expected) {
11709 // We need to collect all garbage twice to be sure that everything 11712 // We need to collect all garbage twice to be sure that everything
11710 // has been collected. This is because inline caches are cleared in 11713 // has been collected. This is because inline caches are cleared in
11711 // the first garbage collection but some of the maps have already 11714 // the first garbage collection but some of the maps have already
11712 // been marked at that point. Therefore some of the maps are not 11715 // been marked at that point. Therefore some of the maps are not
11713 // collected until the second garbage collection. 11716 // collected until the second garbage collection.
11714 CcTest::heap()->CollectAllGarbage(); 11717 CcTest::heap()->CollectAllGarbage();
11715 CcTest::heap()->CollectAllGarbage(i::Heap::kMakeHeapIterableMask); 11718 CcTest::heap()->CollectAllGarbage("CheckSurvivingGlobalObjectsCount",
11719 i::Heap::kMakeHeapIterableMask);
11716 int count = GetGlobalObjectsCount(); 11720 int count = GetGlobalObjectsCount();
11717 #ifdef DEBUG 11721 #ifdef DEBUG
11718 if (count != expected) CcTest::heap()->TracePathToGlobal(); 11722 if (count != expected) CcTest::heap()->TracePathToGlobal();
11719 #endif 11723 #endif
11720 CHECK_EQ(expected, count); 11724 CHECK_EQ(expected, count);
11721 } 11725 }
11722 11726
11723 11727
11724 TEST(DontLeakGlobalObjects) { 11728 TEST(DontLeakGlobalObjects) {
11725 // Regression test for issues 1139850 and 1174891. 11729 // Regression test for issues 1139850 and 1174891.
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
11804 { 11808 {
11805 v8::HandleScope scope(isolate); 11809 v8::HandleScope scope(isolate);
11806 v8::Local<v8::Object> obj = v8::Object::New(isolate); 11810 v8::Local<v8::Object> obj = v8::Object::New(isolate);
11807 obj->Set(v8_str("key"), v8::Integer::New(isolate, 231)); 11811 obj->Set(v8_str("key"), v8::Integer::New(isolate, 231));
11808 v8::Persistent<v8::Object>* handle = 11812 v8::Persistent<v8::Object>* handle =
11809 new v8::Persistent<v8::Object>(isolate, obj); 11813 new v8::Persistent<v8::Object>(isolate, obj);
11810 handle->SetWeak<v8::Persistent<v8::Object>>( 11814 handle->SetWeak<v8::Persistent<v8::Object>>(
11811 handle, WeakApiCallback, v8::WeakCallbackType::kParameter); 11815 handle, WeakApiCallback, v8::WeakCallbackType::kParameter);
11812 } 11816 }
11813 reinterpret_cast<i::Isolate*>(isolate)->heap()->CollectAllGarbage( 11817 reinterpret_cast<i::Isolate*>(isolate)->heap()->CollectAllGarbage(
11814 i::Heap::kAbortIncrementalMarkingMask); 11818 "WeakCallbackApi", i::Heap::kAbortIncrementalMarkingMask);
11815 // Verify disposed. 11819 // Verify disposed.
11816 CHECK_EQ(initial_handles, globals->global_handles_count()); 11820 CHECK_EQ(initial_handles, globals->global_handles_count());
11817 } 11821 }
11818 11822
11819 11823
11820 v8::Persistent<v8::Object> some_object; 11824 v8::Persistent<v8::Object> some_object;
11821 v8::Persistent<v8::Object> bad_handle; 11825 v8::Persistent<v8::Object> bad_handle;
11822 11826
11823 11827
11824 void NewPersistentHandleCallback2( 11828 void NewPersistentHandleCallback2(
(...skipping 4627 matching lines...) Expand 10 before | Expand all | Expand 10 after
16452 CHECK_EQ(flags, v8::kNoGCCallbackFlags); 16456 CHECK_EQ(flags, v8::kNoGCCallbackFlags);
16453 CHECK_EQ(gc_callbacks_isolate, isolate); 16457 CHECK_EQ(gc_callbacks_isolate, isolate);
16454 ++prologue_call_count_alloc; 16458 ++prologue_call_count_alloc;
16455 16459
16456 // Simulate full heap to see if we will reenter this callback 16460 // Simulate full heap to see if we will reenter this callback
16457 SimulateFullSpace(CcTest::heap()->new_space()); 16461 SimulateFullSpace(CcTest::heap()->new_space());
16458 16462
16459 Local<Object> obj = Object::New(isolate); 16463 Local<Object> obj = Object::New(isolate);
16460 CHECK(!obj.IsEmpty()); 16464 CHECK(!obj.IsEmpty());
16461 16465
16462 CcTest::heap()->CollectAllGarbage( 16466 CcTest::heap()->CollectAllGarbage("PrologueCallbackAlloc",
16463 i::Heap::kAbortIncrementalMarkingMask); 16467 i::Heap::kAbortIncrementalMarkingMask);
16464 } 16468 }
16465 16469
16466 16470
16467 void EpilogueCallbackAlloc(v8::Isolate* isolate, 16471 void EpilogueCallbackAlloc(v8::Isolate* isolate,
16468 v8::GCType, 16472 v8::GCType,
16469 v8::GCCallbackFlags flags) { 16473 v8::GCCallbackFlags flags) {
16470 v8::HandleScope scope(isolate); 16474 v8::HandleScope scope(isolate);
16471 16475
16472 CHECK_EQ(flags, v8::kNoGCCallbackFlags); 16476 CHECK_EQ(flags, v8::kNoGCCallbackFlags);
16473 CHECK_EQ(gc_callbacks_isolate, isolate); 16477 CHECK_EQ(gc_callbacks_isolate, isolate);
16474 ++epilogue_call_count_alloc; 16478 ++epilogue_call_count_alloc;
16475 16479
16476 // Simulate full heap to see if we will reenter this callback 16480 // Simulate full heap to see if we will reenter this callback
16477 SimulateFullSpace(CcTest::heap()->new_space()); 16481 SimulateFullSpace(CcTest::heap()->new_space());
16478 16482
16479 Local<Object> obj = Object::New(isolate); 16483 Local<Object> obj = Object::New(isolate);
16480 CHECK(!obj.IsEmpty()); 16484 CHECK(!obj.IsEmpty());
16481 16485
16482 CcTest::heap()->CollectAllGarbage( 16486 CcTest::heap()->CollectAllGarbage("EpilogueCallbackAlloc",
16483 i::Heap::kAbortIncrementalMarkingMask); 16487 i::Heap::kAbortIncrementalMarkingMask);
16484 } 16488 }
16485 16489
16486 16490
16487 TEST(GCCallbacksOld) { 16491 TEST(GCCallbacksOld) {
16488 LocalContext context; 16492 LocalContext context;
16489 16493
16490 v8::V8::AddGCPrologueCallback(PrologueCallback); 16494 v8::V8::AddGCPrologueCallback(PrologueCallback);
16491 v8::V8::AddGCEpilogueCallback(EpilogueCallback); 16495 v8::V8::AddGCEpilogueCallback(EpilogueCallback);
16492 CHECK_EQ(0, prologue_call_count); 16496 CHECK_EQ(0, prologue_call_count);
16493 CHECK_EQ(0, epilogue_call_count); 16497 CHECK_EQ(0, epilogue_call_count);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
16548 CcTest::heap()->CollectAllGarbage(); 16552 CcTest::heap()->CollectAllGarbage();
16549 CHECK_EQ(2, prologue_call_count); 16553 CHECK_EQ(2, prologue_call_count);
16550 CHECK_EQ(2, epilogue_call_count); 16554 CHECK_EQ(2, epilogue_call_count);
16551 CHECK_EQ(2, prologue_call_count_second); 16555 CHECK_EQ(2, prologue_call_count_second);
16552 CHECK_EQ(2, epilogue_call_count_second); 16556 CHECK_EQ(2, epilogue_call_count_second);
16553 16557
16554 CHECK_EQ(0, prologue_call_count_alloc); 16558 CHECK_EQ(0, prologue_call_count_alloc);
16555 CHECK_EQ(0, epilogue_call_count_alloc); 16559 CHECK_EQ(0, epilogue_call_count_alloc);
16556 isolate->AddGCPrologueCallback(PrologueCallbackAlloc); 16560 isolate->AddGCPrologueCallback(PrologueCallbackAlloc);
16557 isolate->AddGCEpilogueCallback(EpilogueCallbackAlloc); 16561 isolate->AddGCEpilogueCallback(EpilogueCallbackAlloc);
16558 CcTest::heap()->CollectAllGarbage( 16562 CcTest::heap()->CollectAllGarbage("GCCallbacks",
16559 i::Heap::kAbortIncrementalMarkingMask); 16563 i::Heap::kAbortIncrementalMarkingMask);
16560 CHECK_EQ(1, prologue_call_count_alloc); 16564 CHECK_EQ(1, prologue_call_count_alloc);
16561 CHECK_EQ(1, epilogue_call_count_alloc); 16565 CHECK_EQ(1, epilogue_call_count_alloc);
16562 isolate->RemoveGCPrologueCallback(PrologueCallbackAlloc); 16566 isolate->RemoveGCPrologueCallback(PrologueCallbackAlloc);
16563 isolate->RemoveGCEpilogueCallback(EpilogueCallbackAlloc); 16567 isolate->RemoveGCEpilogueCallback(EpilogueCallbackAlloc);
16564 } 16568 }
16565 16569
16566 16570
16567 THREADED_TEST(TwoByteStringInOneByteCons) { 16571 THREADED_TEST(TwoByteStringInOneByteCons) {
16568 // See Chromium issue 47824. 16572 // See Chromium issue 47824.
16569 LocalContext context; 16573 LocalContext context;
(...skipping 5281 matching lines...) Expand 10 before | Expand all | Expand 10 after
21851 timeout_thread.Join(); 21855 timeout_thread.Join();
21852 } 21856 }
21853 21857
21854 21858
21855 TEST(EstimatedContextSize) { 21859 TEST(EstimatedContextSize) {
21856 v8::Isolate* isolate = CcTest::isolate(); 21860 v8::Isolate* isolate = CcTest::isolate();
21857 v8::HandleScope scope(isolate); 21861 v8::HandleScope scope(isolate);
21858 LocalContext env; 21862 LocalContext env;
21859 CHECK(50000 < env->EstimatedSize()); 21863 CHECK(50000 < env->EstimatedSize());
21860 } 21864 }
OLDNEW
« src/heap/heap.cc ('K') | « src/runtime/runtime-debug.cc ('k') | test/cctest/test-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698