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:
parent
5703794412
commit
d19d0be8a0
@ -5439,7 +5439,9 @@ class V8_EXPORT Isolate {
|
|||||||
*
|
*
|
||||||
* The idle_time_in_ms argument specifies the time V8 has to perform
|
* 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
|
* 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
|
* The deadline_in_seconds argument specifies the deadline V8 has to finish
|
||||||
* garbage collection work. deadline_in_seconds is compared with
|
* garbage collection work. deadline_in_seconds is compared with
|
||||||
* MonotonicallyIncreasingTime() and should be based on the same timebase as
|
* MonotonicallyIncreasingTime() and should be based on the same timebase as
|
||||||
|
21
src/d8.cc
21
src/d8.cc
@ -72,6 +72,10 @@
|
|||||||
|
|
||||||
namespace v8 {
|
namespace v8 {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
v8::Platform* g_platform = NULL;
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
|
||||||
static Handle<Value> Throw(Isolate* isolate, const char* message) {
|
static Handle<Value> Throw(Isolate* isolate, const char* message) {
|
||||||
return isolate->ThrowException(String::NewFromUtf8(isolate, message));
|
return isolate->ThrowException(String::NewFromUtf8(isolate, message));
|
||||||
@ -1289,9 +1293,11 @@ void SourceGroup::ExecuteInThread() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Shell::options.send_idle_notification) {
|
if (Shell::options.send_idle_notification) {
|
||||||
const int kLongIdlePauseInMs = 1000;
|
const double kLongIdlePauseInSeconds = 1.0;
|
||||||
isolate->ContextDisposedNotification();
|
isolate->ContextDisposedNotification();
|
||||||
isolate->IdleNotification(kLongIdlePauseInMs);
|
isolate->IdleNotificationDeadline(
|
||||||
|
g_platform->MonotonicallyIncreasingTime() +
|
||||||
|
kLongIdlePauseInSeconds);
|
||||||
}
|
}
|
||||||
if (Shell::options.invoke_weak_callbacks) {
|
if (Shell::options.invoke_weak_callbacks) {
|
||||||
// By sending a low memory notifications, we will try hard to collect
|
// 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) {
|
if (options.send_idle_notification) {
|
||||||
const int kLongIdlePauseInMs = 1000;
|
const double kLongIdlePauseInSeconds = 1.0;
|
||||||
isolate->ContextDisposedNotification();
|
isolate->ContextDisposedNotification();
|
||||||
isolate->IdleNotification(kLongIdlePauseInMs);
|
isolate->IdleNotificationDeadline(
|
||||||
|
g_platform->MonotonicallyIncreasingTime() + kLongIdlePauseInSeconds);
|
||||||
}
|
}
|
||||||
if (options.invoke_weak_callbacks) {
|
if (options.invoke_weak_callbacks) {
|
||||||
// By sending a low memory notifications, we will try hard to collect all
|
// 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)
|
#endif // defined(_WIN32) || defined(_WIN64)
|
||||||
if (!SetOptions(argc, argv)) return 1;
|
if (!SetOptions(argc, argv)) return 1;
|
||||||
v8::V8::InitializeICU(options.icu_data_file);
|
v8::V8::InitializeICU(options.icu_data_file);
|
||||||
v8::Platform* platform = v8::platform::CreateDefaultPlatform();
|
g_platform = v8::platform::CreateDefaultPlatform();
|
||||||
v8::V8::InitializePlatform(platform);
|
v8::V8::InitializePlatform(g_platform);
|
||||||
v8::V8::Initialize();
|
v8::V8::Initialize();
|
||||||
#ifdef V8_USE_EXTERNAL_STARTUP_DATA
|
#ifdef V8_USE_EXTERNAL_STARTUP_DATA
|
||||||
v8::StartupDataHandler startup_data(argv[0], options.natives_blob,
|
v8::StartupDataHandler startup_data(argv[0], options.natives_blob,
|
||||||
@ -1705,7 +1712,7 @@ int Shell::Main(int argc, char* argv[]) {
|
|||||||
isolate->Dispose();
|
isolate->Dispose();
|
||||||
V8::Dispose();
|
V8::Dispose();
|
||||||
V8::ShutdownPlatform();
|
V8::ShutdownPlatform();
|
||||||
delete platform;
|
delete g_platform;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -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 that idle notification can be handled and eventually collects garbage.
|
||||||
TEST(IdleNotificationWithSmallHint) {
|
TEST(IdleNotificationWithSmallHint) {
|
||||||
const intptr_t MB = 1024 * 1024;
|
const intptr_t MB = 1024 * 1024;
|
||||||
const int IdlePauseInMs = 900;
|
const double IdlePauseInSeconds = 0.9;
|
||||||
LocalContext env;
|
LocalContext env;
|
||||||
v8::HandleScope scope(env->GetIsolate());
|
v8::HandleScope scope(env->GetIsolate());
|
||||||
intptr_t initial_size = CcTest::heap()->SizeOfObjects();
|
intptr_t initial_size = CcTest::heap()->SizeOfObjects();
|
||||||
@ -15754,7 +15734,10 @@ TEST(IdleNotificationWithSmallHint) {
|
|||||||
CHECK_GT(size_with_garbage, initial_size + MB);
|
CHECK_GT(size_with_garbage, initial_size + MB);
|
||||||
bool finished = false;
|
bool finished = false;
|
||||||
for (int i = 0; i < 200 && !finished; i++) {
|
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();
|
intptr_t final_size = CcTest::heap()->SizeOfObjects();
|
||||||
CHECK(finished);
|
CHECK(finished);
|
||||||
@ -15765,7 +15748,7 @@ TEST(IdleNotificationWithSmallHint) {
|
|||||||
// Test that idle notification can be handled and eventually collects garbage.
|
// Test that idle notification can be handled and eventually collects garbage.
|
||||||
TEST(IdleNotificationWithLargeHint) {
|
TEST(IdleNotificationWithLargeHint) {
|
||||||
const intptr_t MB = 1024 * 1024;
|
const intptr_t MB = 1024 * 1024;
|
||||||
const int IdlePauseInMs = 900;
|
const double IdlePauseInSeconds = 1.0;
|
||||||
LocalContext env;
|
LocalContext env;
|
||||||
v8::HandleScope scope(env->GetIsolate());
|
v8::HandleScope scope(env->GetIsolate());
|
||||||
intptr_t initial_size = CcTest::heap()->SizeOfObjects();
|
intptr_t initial_size = CcTest::heap()->SizeOfObjects();
|
||||||
@ -15774,7 +15757,10 @@ TEST(IdleNotificationWithLargeHint) {
|
|||||||
CHECK_GT(size_with_garbage, initial_size + MB);
|
CHECK_GT(size_with_garbage, initial_size + MB);
|
||||||
bool finished = false;
|
bool finished = false;
|
||||||
for (int i = 0; i < 200 && !finished; i++) {
|
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();
|
intptr_t final_size = CcTest::heap()->SizeOfObjects();
|
||||||
CHECK(finished);
|
CHECK(finished);
|
||||||
|
@ -2240,9 +2240,12 @@ TEST(ResetSharedFunctionInfoCountersDuringIncrementalMarking) {
|
|||||||
marking->Start();
|
marking->Start();
|
||||||
|
|
||||||
// The following two calls will increment CcTest::heap()->global_ic_age().
|
// 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()->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()) {
|
while (!marking->IsStopped() && !marking->IsComplete()) {
|
||||||
marking->Step(1 * MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD);
|
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().
|
// The following two calls will increment CcTest::heap()->global_ic_age().
|
||||||
// Since incremental marking is off, IdleNotification will do full GC.
|
// Since incremental marking is off, IdleNotification will do full GC.
|
||||||
const int kLongIdlePauseInMs = 1000;
|
const double kLongIdlePauseInSeconds = 1.0;
|
||||||
CcTest::isolate()->ContextDisposedNotification();
|
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(CcTest::heap()->global_ic_age(), f->shared()->ic_age());
|
||||||
CHECK_EQ(0, f->shared()->opt_count());
|
CHECK_EQ(0, f->shared()->opt_count());
|
||||||
@ -2344,8 +2350,11 @@ TEST(IdleNotificationFinishMarking) {
|
|||||||
marking->SetWeakClosureWasOverApproximatedForTesting(true);
|
marking->SetWeakClosureWasOverApproximatedForTesting(true);
|
||||||
|
|
||||||
// The next idle notification has to finish incremental marking.
|
// The next idle notification has to finish incremental marking.
|
||||||
const int kLongIdleTime = 1000000;
|
const double kLongIdleTime = 1000.0;
|
||||||
CcTest::isolate()->IdleNotification(kLongIdleTime);
|
CcTest::isolate()->IdleNotificationDeadline(
|
||||||
|
(v8::base::TimeTicks::HighResolutionNow().ToInternalValue() /
|
||||||
|
static_cast<double>(v8::base::Time::kMicrosecondsPerSecond)) +
|
||||||
|
kLongIdleTime);
|
||||||
CHECK_EQ(CcTest::heap()->gc_count(), 1);
|
CHECK_EQ(CcTest::heap()->gc_count(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user