Reviewers: Hannes Payer,
Description:
Remove calls to IdleNotification()
All users should use IdleNotificationDeadline() instead
BUG=none
[email protected]
LOG=y
Please review this at https://codereview.chromium.org/1028163003/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+42, -38 lines):
M include/v8.h
M src/d8.cc
M test/cctest/test-api.cc
M test/cctest/test-heap.cc
Index: include/v8.h
diff --git a/include/v8.h b/include/v8.h
index
32d4392a3598da2033f7d9e3efc1bfa6e7539e43..9e3c1470dac9052dc864fce8067c5983a7dc0f61
100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -5440,7 +5440,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
Index: src/d8.cc
diff --git a/src/d8.cc b/src/d8.cc
index
f28ff39ef354eb8a9436d9f3b4b31a48e7c467c3..089aca9f92429402b9cbb4a12497c071e97e1f02
100644
--- a/src/d8.cc
+++ b/src/d8.cc
@@ -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;
}
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index
dcb11be19d1c84a377b2381a7d3929aff4bbe3a1..9b8be0a7a139b7ee39872437ad6fc2205beac468
100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -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);
Index: test/cctest/test-heap.cc
diff --git a/test/cctest/test-heap.cc b/test/cctest/test-heap.cc
index
cd012f6bfa91b942771008077c02715ef8535ea7..83e6f17c52d3edadec1f133958a26f99d6c47684
100644
--- a/test/cctest/test-heap.cc
+++ b/test/cctest/test-heap.cc
@@ -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);
}
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.