Cleanup idle notification tests.
R=ulan@chromium.org TEST=cctest/test-api/IdleNotification Review URL: https://chromiumcodereview.appspot.com/9403014 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10713 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
01e46b955f
commit
bc7e01534d
@ -13711,58 +13711,65 @@ TEST(SourceURLInStackTrace) {
|
|||||||
THREADED_TEST(IdleNotification) {
|
THREADED_TEST(IdleNotification) {
|
||||||
v8::HandleScope scope;
|
v8::HandleScope scope;
|
||||||
LocalContext env;
|
LocalContext env;
|
||||||
CompileRun("function binom(n, m) {"
|
{
|
||||||
" var C = [[1]];"
|
// Create garbage in old-space to generate work for idle notification.
|
||||||
" for (var i = 1; i <= n; ++i) {"
|
i::AlwaysAllocateScope always_allocate;
|
||||||
" C[i] = [1];"
|
for (int i = 0; i < 100; i++) {
|
||||||
" for (var j = 1; j < i; ++j) {"
|
FACTORY->NewFixedArray(1000, i::TENURED);
|
||||||
" C[i][j] = C[i-1][j-1] + C[i-1][j];"
|
}
|
||||||
" }"
|
|
||||||
" C[i][i] = 1;"
|
|
||||||
" }"
|
|
||||||
" return C[n][m];"
|
|
||||||
"};"
|
|
||||||
"binom(1000, 500)");
|
|
||||||
bool rv = false;
|
|
||||||
for (int i = 0; i < 100; i++) {
|
|
||||||
rv = v8::V8::IdleNotification();
|
|
||||||
if (rv)
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
CHECK(rv == true);
|
bool finshed_idle_work = false;
|
||||||
|
for (int i = 0; i < 100 && !finshed_idle_work; i++) {
|
||||||
|
finshed_idle_work = v8::V8::IdleNotification();
|
||||||
|
}
|
||||||
|
CHECK(finshed_idle_work);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test that idle notification can be handled and eventually returns true.
|
// Test that idle notification can be handled and eventually returns true.
|
||||||
// This just checks the contract of the IdleNotification() function,
|
// This just checks the contract of the IdleNotification() function,
|
||||||
// and does not verify that it does reasonable work.
|
// and does not verify that it does reasonable work.
|
||||||
TEST(IdleNotificationWithHint) {
|
TEST(IdleNotificationWithSmallHint) {
|
||||||
v8::HandleScope scope;
|
v8::HandleScope scope;
|
||||||
LocalContext env;
|
LocalContext env;
|
||||||
{
|
{
|
||||||
|
// Create garbage in old-space to generate work for idle notification.
|
||||||
i::AlwaysAllocateScope always_allocate;
|
i::AlwaysAllocateScope always_allocate;
|
||||||
CompileRun("function binom(n, m) {"
|
for (int i = 0; i < 100; i++) {
|
||||||
" var C = [[1]];"
|
FACTORY->NewFixedArray(1000, i::TENURED);
|
||||||
" for (var i = 1; i <= n; ++i) {"
|
}
|
||||||
" C[i] = [1];"
|
|
||||||
" for (var j = 1; j < i; ++j) {"
|
|
||||||
" C[i][j] = C[i-1][j-1] + C[i-1][j];"
|
|
||||||
" }"
|
|
||||||
" C[i][i] = 1;"
|
|
||||||
" }"
|
|
||||||
" return C[n][m];"
|
|
||||||
"};"
|
|
||||||
"binom(1000, 500)");
|
|
||||||
}
|
}
|
||||||
bool rv = false;
|
|
||||||
intptr_t old_size = HEAP->SizeOfObjects();
|
intptr_t old_size = HEAP->SizeOfObjects();
|
||||||
|
bool finshed_idle_work = false;
|
||||||
bool no_idle_work = v8::V8::IdleNotification(10);
|
bool no_idle_work = v8::V8::IdleNotification(10);
|
||||||
for (int i = 0; i < 200; i++) {
|
for (int i = 0; i < 200 && !finshed_idle_work; i++) {
|
||||||
rv = v8::V8::IdleNotification(10);
|
finshed_idle_work = v8::V8::IdleNotification(10);
|
||||||
if (rv)
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
CHECK(rv == true);
|
|
||||||
intptr_t new_size = HEAP->SizeOfObjects();
|
intptr_t new_size = HEAP->SizeOfObjects();
|
||||||
|
CHECK(finshed_idle_work);
|
||||||
|
CHECK(no_idle_work || new_size < old_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// This just checks the contract of the IdleNotification() function,
|
||||||
|
// and does not verify that it does reasonable work.
|
||||||
|
TEST(IdleNotificationWithLargeHint) {
|
||||||
|
v8::HandleScope scope;
|
||||||
|
LocalContext env;
|
||||||
|
{
|
||||||
|
// Create garbage in old-space to generate work for idle notification.
|
||||||
|
i::AlwaysAllocateScope always_allocate;
|
||||||
|
for (int i = 0; i < 100; i++) {
|
||||||
|
FACTORY->NewFixedArray(1000, i::TENURED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
intptr_t old_size = HEAP->SizeOfObjects();
|
||||||
|
bool finshed_idle_work = false;
|
||||||
|
bool no_idle_work = v8::V8::IdleNotification(900);
|
||||||
|
for (int i = 0; i < 200 && !finshed_idle_work; i++) {
|
||||||
|
finshed_idle_work = v8::V8::IdleNotification(900);
|
||||||
|
}
|
||||||
|
intptr_t new_size = HEAP->SizeOfObjects();
|
||||||
|
CHECK(finshed_idle_work);
|
||||||
CHECK(no_idle_work || new_size < old_size);
|
CHECK(no_idle_work || new_size < old_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1328,35 +1328,6 @@ TEST(CollectingAllAvailableGarbageShrinksNewSpace) {
|
|||||||
CHECK(old_capacity == new_capacity);
|
CHECK(old_capacity == new_capacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This just checks the contract of the IdleNotification() function,
|
|
||||||
// and does not verify that it does reasonable work.
|
|
||||||
TEST(IdleNotificationAdvancesIncrementalMarking) {
|
|
||||||
if (!FLAG_incremental_marking || !FLAG_incremental_marking_steps) return;
|
|
||||||
InitializeVM();
|
|
||||||
v8::HandleScope scope;
|
|
||||||
const char* source = "function binom(n, m) {"
|
|
||||||
" var C = [[1]];"
|
|
||||||
" for (var i = 1; i <= n; ++i) {"
|
|
||||||
" C[i] = [1];"
|
|
||||||
" for (var j = 1; j < i; ++j) {"
|
|
||||||
" C[i][j] = C[i-1][j-1] + C[i-1][j];"
|
|
||||||
" }"
|
|
||||||
" C[i][i] = 1;"
|
|
||||||
" }"
|
|
||||||
" return C[n][m];"
|
|
||||||
"};"
|
|
||||||
"binom(1000, 500)";
|
|
||||||
{
|
|
||||||
AlwaysAllocateScope aa_scope;
|
|
||||||
CompileRun(source);
|
|
||||||
}
|
|
||||||
intptr_t old_size = HEAP->SizeOfObjects();
|
|
||||||
bool no_idle_work = v8::V8::IdleNotification(900);
|
|
||||||
while (!v8::V8::IdleNotification(900)) ;
|
|
||||||
intptr_t new_size = HEAP->SizeOfObjects();
|
|
||||||
CHECK(no_idle_work || new_size < old_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static int NumberOfGlobalObjects() {
|
static int NumberOfGlobalObjects() {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user