From dfc677a6684a0d829a37529cd41debfb1be2a08f Mon Sep 17 00:00:00 2001 From: "sgjesse@chromium.org" Date: Tue, 1 Dec 2009 09:37:28 +0000 Subject: [PATCH] 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 --- test/cctest/test-api.cc | 47 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 15 deletions(-) diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc index 9eb135d..c484601 100644 --- a/test/cctest/test-api.cc +++ b/test/cctest/test-api.cc @@ -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; + v8::Persistent 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 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 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(); } -- 2.7.4