Remove calls to IdleNotification()

All users should use IdleNotificationDeadline() instead

BUG=none
R=hpayer@chromium.org
LOG=y

Review URL: https://codereview.chromium.org/1028163003

Cr-Commit-Position: refs/heads/master@{#27386}
This commit is contained in:
jochen 2015-03-24 01:29:52 -07:00 committed by Commit bot
parent 5703794412
commit d19d0be8a0
4 changed files with 42 additions and 38 deletions

View File

@ -5439,7 +5439,9 @@ class V8_EXPORT Isolate {
*
* The idle_time_in_ms argument specifies the time V8 has to perform
* garbage collection. There is no guarantee that the actual work will be
* done within the time limit.
* done within the time limit. This variant is deprecated and will be removed
* in the future.
*
* The deadline_in_seconds argument specifies the deadline V8 has to finish
* garbage collection work. deadline_in_seconds is compared with
* MonotonicallyIncreasingTime() and should be based on the same timebase as

View File

@ -72,6 +72,10 @@
namespace v8 {
namespace {
v8::Platform* g_platform = NULL;
} // namespace
static Handle<Value> Throw(Isolate* isolate, const char* message) {
return isolate->ThrowException(String::NewFromUtf8(isolate, message));
@ -1289,9 +1293,11 @@ void SourceGroup::ExecuteInThread() {
}
}
if (Shell::options.send_idle_notification) {
const int kLongIdlePauseInMs = 1000;
const double kLongIdlePauseInSeconds = 1.0;
isolate->ContextDisposedNotification();
isolate->IdleNotification(kLongIdlePauseInMs);
isolate->IdleNotificationDeadline(
g_platform->MonotonicallyIncreasingTime() +
kLongIdlePauseInSeconds);
}
if (Shell::options.invoke_weak_callbacks) {
// By sending a low memory notifications, we will try hard to collect
@ -1487,9 +1493,10 @@ int Shell::RunMain(Isolate* isolate, int argc, char* argv[]) {
}
}
if (options.send_idle_notification) {
const int kLongIdlePauseInMs = 1000;
const double kLongIdlePauseInSeconds = 1.0;
isolate->ContextDisposedNotification();
isolate->IdleNotification(kLongIdlePauseInMs);
isolate->IdleNotificationDeadline(
g_platform->MonotonicallyIncreasingTime() + kLongIdlePauseInSeconds);
}
if (options.invoke_weak_callbacks) {
// By sending a low memory notifications, we will try hard to collect all
@ -1601,8 +1608,8 @@ int Shell::Main(int argc, char* argv[]) {
#endif // defined(_WIN32) || defined(_WIN64)
if (!SetOptions(argc, argv)) return 1;
v8::V8::InitializeICU(options.icu_data_file);
v8::Platform* platform = v8::platform::CreateDefaultPlatform();
v8::V8::InitializePlatform(platform);
g_platform = v8::platform::CreateDefaultPlatform();
v8::V8::InitializePlatform(g_platform);
v8::V8::Initialize();
#ifdef V8_USE_EXTERNAL_STARTUP_DATA
v8::StartupDataHandler startup_data(argv[0], options.natives_blob,
@ -1705,7 +1712,7 @@ int Shell::Main(int argc, char* argv[]) {
isolate->Dispose();
V8::Dispose();
V8::ShutdownPlatform();
delete platform;
delete g_platform;
return result;
}

View File

@ -15722,30 +15722,10 @@ static void CreateGarbageInOldSpace() {
}
// Test that idle notification can be handled and eventually returns true.
TEST(IdleNotification) {
const intptr_t MB = 1024 * 1024;
const int IdlePauseInMs = 1000;
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
intptr_t initial_size = CcTest::heap()->SizeOfObjects();
CreateGarbageInOldSpace();
intptr_t size_with_garbage = CcTest::heap()->SizeOfObjects();
CHECK_GT(size_with_garbage, initial_size + MB);
bool finished = false;
for (int i = 0; i < 200 && !finished; i++) {
finished = env->GetIsolate()->IdleNotification(IdlePauseInMs);
}
intptr_t final_size = CcTest::heap()->SizeOfObjects();
CHECK(finished);
CHECK_LT(final_size, initial_size + 1);
}
// Test that idle notification can be handled and eventually collects garbage.
TEST(IdleNotificationWithSmallHint) {
const intptr_t MB = 1024 * 1024;
const int IdlePauseInMs = 900;
const double IdlePauseInSeconds = 0.9;
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
intptr_t initial_size = CcTest::heap()->SizeOfObjects();
@ -15754,7 +15734,10 @@ TEST(IdleNotificationWithSmallHint) {
CHECK_GT(size_with_garbage, initial_size + MB);
bool finished = false;
for (int i = 0; i < 200 && !finished; i++) {
finished = env->GetIsolate()->IdleNotification(IdlePauseInMs);
finished = env->GetIsolate()->IdleNotificationDeadline(
(v8::base::TimeTicks::HighResolutionNow().ToInternalValue() /
static_cast<double>(v8::base::Time::kMicrosecondsPerSecond)) +
IdlePauseInSeconds);
}
intptr_t final_size = CcTest::heap()->SizeOfObjects();
CHECK(finished);
@ -15765,7 +15748,7 @@ TEST(IdleNotificationWithSmallHint) {
// Test that idle notification can be handled and eventually collects garbage.
TEST(IdleNotificationWithLargeHint) {
const intptr_t MB = 1024 * 1024;
const int IdlePauseInMs = 900;
const double IdlePauseInSeconds = 1.0;
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
intptr_t initial_size = CcTest::heap()->SizeOfObjects();
@ -15774,7 +15757,10 @@ TEST(IdleNotificationWithLargeHint) {
CHECK_GT(size_with_garbage, initial_size + MB);
bool finished = false;
for (int i = 0; i < 200 && !finished; i++) {
finished = env->GetIsolate()->IdleNotification(IdlePauseInMs);
finished = env->GetIsolate()->IdleNotificationDeadline(
(v8::base::TimeTicks::HighResolutionNow().ToInternalValue() /
static_cast<double>(v8::base::Time::kMicrosecondsPerSecond)) +
IdlePauseInSeconds);
}
intptr_t final_size = CcTest::heap()->SizeOfObjects();
CHECK(finished);

View File

@ -2240,9 +2240,12 @@ TEST(ResetSharedFunctionInfoCountersDuringIncrementalMarking) {
marking->Start();
// The following two calls will increment CcTest::heap()->global_ic_age().
const int kLongIdlePauseInMs = 1000;
const double kLongIdlePauseInSeconds = 1.0;
CcTest::isolate()->ContextDisposedNotification();
CcTest::isolate()->IdleNotification(kLongIdlePauseInMs);
CcTest::isolate()->IdleNotificationDeadline(
(v8::base::TimeTicks::HighResolutionNow().ToInternalValue() /
static_cast<double>(v8::base::Time::kMicrosecondsPerSecond)) +
kLongIdlePauseInSeconds);
while (!marking->IsStopped() && !marking->IsComplete()) {
marking->Step(1 * MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD);
@ -2296,9 +2299,12 @@ TEST(ResetSharedFunctionInfoCountersDuringMarkSweep) {
// The following two calls will increment CcTest::heap()->global_ic_age().
// Since incremental marking is off, IdleNotification will do full GC.
const int kLongIdlePauseInMs = 1000;
const double kLongIdlePauseInSeconds = 1.0;
CcTest::isolate()->ContextDisposedNotification();
CcTest::isolate()->IdleNotification(kLongIdlePauseInMs);
CcTest::isolate()->IdleNotificationDeadline(
(v8::base::TimeTicks::HighResolutionNow().ToInternalValue() /
static_cast<double>(v8::base::Time::kMicrosecondsPerSecond)) +
kLongIdlePauseInSeconds);
CHECK_EQ(CcTest::heap()->global_ic_age(), f->shared()->ic_age());
CHECK_EQ(0, f->shared()->opt_count());
@ -2344,8 +2350,11 @@ TEST(IdleNotificationFinishMarking) {
marking->SetWeakClosureWasOverApproximatedForTesting(true);
// The next idle notification has to finish incremental marking.
const int kLongIdleTime = 1000000;
CcTest::isolate()->IdleNotification(kLongIdleTime);
const double kLongIdleTime = 1000.0;
CcTest::isolate()->IdleNotificationDeadline(
(v8::base::TimeTicks::HighResolutionNow().ToInternalValue() /
static_cast<double>(v8::base::Time::kMicrosecondsPerSecond)) +
kLongIdleTime);
CHECK_EQ(CcTest::heap()->gc_count(), 1);
}