Commit dfc677a6 authored by sgjesse@chromium.org's avatar sgjesse@chromium.org

Update test for issue 528

The check for the number og GC's required is now 1 or 2 instead of two to get rig of failures on ARM.

Updated the test to keep the code used by the test in the compilation cache by compiling it in another context. This makes the remaining issue with the eval cache more explicit.
Review URL: http://codereview.chromium.org/449051

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3387 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 4af7bf51
......@@ -8521,11 +8521,9 @@ static int GetGlobalObjectsCount() {
v8::internal::HeapObject* object = it.next();
if (object->IsJSGlobalObject()) {
count++;
//object->PrintLn();
}
}
#ifdef DEBUG
if (count > 0) v8::internal::Heap::TracePathToGlobal();
#endif
return count;
}
......@@ -8535,10 +8533,16 @@ TEST(Bug528) {
v8::HandleScope scope;
v8::Persistent<Context> context;
v8::Persistent<Context> other_context;
int gc_count;
// Create a context used to keep the code from aging in the compilation
// cache.
other_context = Context::New();
// Context-dependent context data creates reference from the compilation
// cache to the global object.
const char* source_simple = "1";
context = Context::New();
{
v8::HandleScope scope;
......@@ -8546,44 +8550,52 @@ TEST(Bug528) {
context->Enter();
Local<v8::String> obj = v8::String::New("");
context->SetData(obj);
CompileRun("1");
CompileRun(source_simple);
context->Exit();
}
context.Dispose();
for (gc_count = 1; gc_count < 10; gc_count++) {
other_context->Enter();
CompileRun(source_simple);
other_context->Exit();
v8::internal::Heap::CollectAllGarbage(false);
if (GetGlobalObjectsCount() == 0) break;
if (GetGlobalObjectsCount() == 1) break;
}
CHECK_EQ(0, GetGlobalObjectsCount());
CHECK_EQ(2, gc_count);
CHECK(gc_count <= 2);
CHECK_EQ(1, GetGlobalObjectsCount());
// Eval in a function creates reference from the compilation cache to the
// global object.
const char* source_eval = "function f(){eval('1')}; f()";
context = Context::New();
{
v8::HandleScope scope;
context->Enter();
CompileRun("function f(){eval('1')}; f()");
CompileRun(source_eval);
context->Exit();
}
context.Dispose();
for (gc_count = 1; gc_count < 10; gc_count++) {
other_context->Enter();
CompileRun(source_eval);
other_context->Exit();
v8::internal::Heap::CollectAllGarbage(false);
if (GetGlobalObjectsCount() == 0) break;
if (GetGlobalObjectsCount() == 1) break;
}
CHECK_EQ(0, GetGlobalObjectsCount());
CHECK_EQ(2, gc_count);
CHECK_EQ(10, gc_count); // Should be 1 or 2 when the bug is resolved.
CHECK_EQ(2, GetGlobalObjectsCount()); // Should be 1 when resolved.
// Looking up the line number for an exception creates reference from the
// compilation cache to the global object.
const char* source_exception = "function f(){throw 1;} f()";
context = Context::New();
{
v8::HandleScope scope;
context->Enter();
v8::TryCatch try_catch;
CompileRun("function f(){throw 1;}; f()");
CompileRun(source_exception);
CHECK(try_catch.HasCaught());
v8::Handle<v8::Message> message = try_catch.Message();
CHECK(!message.IsEmpty());
......@@ -8592,9 +8604,14 @@ TEST(Bug528) {
}
context.Dispose();
for (gc_count = 1; gc_count < 10; gc_count++) {
other_context->Enter();
CompileRun(source_exception);
other_context->Exit();
v8::internal::Heap::CollectAllGarbage(false);
if (GetGlobalObjectsCount() == 0) break;
if (GetGlobalObjectsCount() == 1) break;
}
CHECK_EQ(0, GetGlobalObjectsCount());
CHECK_EQ(2, gc_count);
CHECK(gc_count <= 2);
CHECK_EQ(1, GetGlobalObjectsCount());
other_context.Dispose();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment