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

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

Issue 1028163003: Remove calls to IdleNotification() (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/d8.cc ('k') | test/cctest/test-heap.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 15704 matching lines...) Expand 10 before | Expand all | Expand 10 after
15715 static void CreateGarbageInOldSpace() { 15715 static void CreateGarbageInOldSpace() {
15716 i::Factory* factory = CcTest::i_isolate()->factory(); 15716 i::Factory* factory = CcTest::i_isolate()->factory();
15717 v8::HandleScope scope(CcTest::isolate()); 15717 v8::HandleScope scope(CcTest::isolate());
15718 i::AlwaysAllocateScope always_allocate(CcTest::i_isolate()); 15718 i::AlwaysAllocateScope always_allocate(CcTest::i_isolate());
15719 for (int i = 0; i < 1000; i++) { 15719 for (int i = 0; i < 1000; i++) {
15720 factory->NewFixedArray(1000, i::TENURED); 15720 factory->NewFixedArray(1000, i::TENURED);
15721 } 15721 }
15722 } 15722 }
15723 15723
15724 15724
15725 // Test that idle notification can be handled and eventually returns true.
15726 TEST(IdleNotification) {
15727 const intptr_t MB = 1024 * 1024;
15728 const int IdlePauseInMs = 1000;
15729 LocalContext env;
15730 v8::HandleScope scope(env->GetIsolate());
15731 intptr_t initial_size = CcTest::heap()->SizeOfObjects();
15732 CreateGarbageInOldSpace();
15733 intptr_t size_with_garbage = CcTest::heap()->SizeOfObjects();
15734 CHECK_GT(size_with_garbage, initial_size + MB);
15735 bool finished = false;
15736 for (int i = 0; i < 200 && !finished; i++) {
15737 finished = env->GetIsolate()->IdleNotification(IdlePauseInMs);
15738 }
15739 intptr_t final_size = CcTest::heap()->SizeOfObjects();
15740 CHECK(finished);
15741 CHECK_LT(final_size, initial_size + 1);
15742 }
15743
15744
15745 // Test that idle notification can be handled and eventually collects garbage. 15725 // Test that idle notification can be handled and eventually collects garbage.
15746 TEST(IdleNotificationWithSmallHint) { 15726 TEST(IdleNotificationWithSmallHint) {
15747 const intptr_t MB = 1024 * 1024; 15727 const intptr_t MB = 1024 * 1024;
15748 const int IdlePauseInMs = 900; 15728 const double IdlePauseInSeconds = 0.9;
15749 LocalContext env; 15729 LocalContext env;
15750 v8::HandleScope scope(env->GetIsolate()); 15730 v8::HandleScope scope(env->GetIsolate());
15751 intptr_t initial_size = CcTest::heap()->SizeOfObjects(); 15731 intptr_t initial_size = CcTest::heap()->SizeOfObjects();
15752 CreateGarbageInOldSpace(); 15732 CreateGarbageInOldSpace();
15753 intptr_t size_with_garbage = CcTest::heap()->SizeOfObjects(); 15733 intptr_t size_with_garbage = CcTest::heap()->SizeOfObjects();
15754 CHECK_GT(size_with_garbage, initial_size + MB); 15734 CHECK_GT(size_with_garbage, initial_size + MB);
15755 bool finished = false; 15735 bool finished = false;
15756 for (int i = 0; i < 200 && !finished; i++) { 15736 for (int i = 0; i < 200 && !finished; i++) {
15757 finished = env->GetIsolate()->IdleNotification(IdlePauseInMs); 15737 finished = env->GetIsolate()->IdleNotificationDeadline(
15738 (v8::base::TimeTicks::HighResolutionNow().ToInternalValue() /
15739 static_cast<double>(v8::base::Time::kMicrosecondsPerSecond)) +
15740 IdlePauseInSeconds);
15758 } 15741 }
15759 intptr_t final_size = CcTest::heap()->SizeOfObjects(); 15742 intptr_t final_size = CcTest::heap()->SizeOfObjects();
15760 CHECK(finished); 15743 CHECK(finished);
15761 CHECK_LT(final_size, initial_size + 1); 15744 CHECK_LT(final_size, initial_size + 1);
15762 } 15745 }
15763 15746
15764 15747
15765 // Test that idle notification can be handled and eventually collects garbage. 15748 // Test that idle notification can be handled and eventually collects garbage.
15766 TEST(IdleNotificationWithLargeHint) { 15749 TEST(IdleNotificationWithLargeHint) {
15767 const intptr_t MB = 1024 * 1024; 15750 const intptr_t MB = 1024 * 1024;
15768 const int IdlePauseInMs = 900; 15751 const double IdlePauseInSeconds = 1.0;
15769 LocalContext env; 15752 LocalContext env;
15770 v8::HandleScope scope(env->GetIsolate()); 15753 v8::HandleScope scope(env->GetIsolate());
15771 intptr_t initial_size = CcTest::heap()->SizeOfObjects(); 15754 intptr_t initial_size = CcTest::heap()->SizeOfObjects();
15772 CreateGarbageInOldSpace(); 15755 CreateGarbageInOldSpace();
15773 intptr_t size_with_garbage = CcTest::heap()->SizeOfObjects(); 15756 intptr_t size_with_garbage = CcTest::heap()->SizeOfObjects();
15774 CHECK_GT(size_with_garbage, initial_size + MB); 15757 CHECK_GT(size_with_garbage, initial_size + MB);
15775 bool finished = false; 15758 bool finished = false;
15776 for (int i = 0; i < 200 && !finished; i++) { 15759 for (int i = 0; i < 200 && !finished; i++) {
15777 finished = env->GetIsolate()->IdleNotification(IdlePauseInMs); 15760 finished = env->GetIsolate()->IdleNotificationDeadline(
15761 (v8::base::TimeTicks::HighResolutionNow().ToInternalValue() /
15762 static_cast<double>(v8::base::Time::kMicrosecondsPerSecond)) +
15763 IdlePauseInSeconds);
15778 } 15764 }
15779 intptr_t final_size = CcTest::heap()->SizeOfObjects(); 15765 intptr_t final_size = CcTest::heap()->SizeOfObjects();
15780 CHECK(finished); 15766 CHECK(finished);
15781 CHECK_LT(final_size, initial_size + 1); 15767 CHECK_LT(final_size, initial_size + 1);
15782 } 15768 }
15783 15769
15784 15770
15785 TEST(Regress2333) { 15771 TEST(Regress2333) {
15786 LocalContext env; 15772 LocalContext env;
15787 for (int i = 0; i < 3; i++) { 15773 for (int i = 0; i < 3; i++) {
(...skipping 5846 matching lines...) Expand 10 before | Expand all | Expand 10 after
21634 } 21620 }
21635 { 21621 {
21636 v8::TryCatch try_catch; 21622 v8::TryCatch try_catch;
21637 uint16_t* data = reinterpret_cast<uint16_t*>(buffer); 21623 uint16_t* data = reinterpret_cast<uint16_t*>(buffer);
21638 CHECK(v8::String::NewFromTwoByte(isolate, data, v8::String::kNormalString, 21624 CHECK(v8::String::NewFromTwoByte(isolate, data, v8::String::kNormalString,
21639 length).IsEmpty()); 21625 length).IsEmpty());
21640 CHECK(!try_catch.HasCaught()); 21626 CHECK(!try_catch.HasCaught());
21641 } 21627 }
21642 free(buffer); 21628 free(buffer);
21643 } 21629 }
OLDNEW
« no previous file with comments | « src/d8.cc ('k') | test/cctest/test-heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698