Commit e0ecb1a1 authored by dcarney@chromium.org's avatar dcarney@chromium.org

cleanup cctest generally and remove ctest::context

R=svenpanne@chromium.org
BUG=

Review URL: https://codereview.chromium.org/23519010

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16831 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 98477e38
...@@ -29,9 +29,14 @@ ...@@ -29,9 +29,14 @@
#include "cctest.h" #include "cctest.h"
#include "debug.h" #include "debug.h"
enum InitializationState {kUnset, kUnintialized, kInitialized};
static InitializationState initialization_state_ = kUnset;
CcTest* CcTest::last_ = NULL; CcTest* CcTest::last_ = NULL;
CcTest::InitializationState CcTest::initialization_state_ = kUnset; bool CcTest::initialize_called_ = false;
bool CcTest::isolate_used_ = false;
v8::Isolate* CcTest::isolate_ = NULL;
CcTest::CcTest(TestFunction* callback, const char* file, const char* name, CcTest::CcTest(TestFunction* callback, const char* file, const char* name,
const char* dependency, bool enabled, bool initialize) const char* dependency, bool enabled, bool initialize)
...@@ -62,48 +67,37 @@ void CcTest::Run() { ...@@ -62,48 +67,37 @@ void CcTest::Run() {
CHECK(initialization_state_ != kInitialized); CHECK(initialization_state_ != kInitialized);
initialization_state_ = kUnintialized; initialization_state_ = kUnintialized;
// TODO(dcarney): Remove this when default isolate is gone. // TODO(dcarney): Remove this when default isolate is gone.
if (default_isolate_ == NULL) { if (isolate_ == NULL) {
default_isolate_ = v8::Isolate::GetCurrent(); isolate_ = v8::Isolate::GetCurrent();
} }
} else { } else {
CHECK(initialization_state_ != kUnintialized); CHECK(initialization_state_ != kUnintialized);
initialization_state_ = kInitialized; initialization_state_ = kInitialized;
i::Isolate::SetCrashIfDefaultIsolateInitialized(); i::Isolate::SetCrashIfDefaultIsolateInitialized();
if (default_isolate_ == NULL) { if (isolate_ == NULL) {
default_isolate_ = v8::Isolate::New(); isolate_ = v8::Isolate::New();
} }
default_isolate_->Enter(); isolate_->Enter();
} }
callback_(); callback_();
if (initialize_) { if (initialize_) {
default_isolate_->Exit(); isolate_->Exit();
} }
} }
v8::Persistent<v8::Context> CcTest::context_; v8::Local<v8::Context> CcTest::NewContext(CcTestExtensionFlags extensions,
v8::Isolate* isolate) {
void CcTest::InitializeVM(CcTestExtensionFlags extensions) {
const char* extension_names[kMaxExtensions]; const char* extension_names[kMaxExtensions];
int extension_count = 0; int extension_count = 0;
#define CHECK_EXTENSION_FLAG(Name, Id) \ #define CHECK_EXTENSION_FLAG(Name, Id) \
if (extensions.Contains(Name##_ID)) extension_names[extension_count++] = Id; if (extensions.Contains(Name##_ID)) extension_names[extension_count++] = Id;
EXTENSION_LIST(CHECK_EXTENSION_FLAG) EXTENSION_LIST(CHECK_EXTENSION_FLAG)
#undef CHECK_EXTENSION_FLAG #undef CHECK_EXTENSION_FLAG
v8::Isolate* isolate = CcTest::isolate();
if (context_.IsEmpty()) {
v8::HandleScope scope(isolate);
v8::ExtensionConfiguration config(extension_count, extension_names); v8::ExtensionConfiguration config(extension_count, extension_names);
v8::Local<v8::Context> context = v8::Context::New(isolate, &config); v8::Local<v8::Context> context = v8::Context::New(isolate, &config);
context_.Reset(isolate, context); CHECK(!context.IsEmpty());
} return context;
{
v8::HandleScope scope(isolate);
v8::Local<v8::Context> context =
v8::Local<v8::Context>::New(isolate, context_);
context->Enter();
}
} }
...@@ -119,9 +113,6 @@ static void PrintTestList(CcTest* current) { ...@@ -119,9 +113,6 @@ static void PrintTestList(CcTest* current) {
} }
v8::Isolate* CcTest::default_isolate_ = NULL;
class CcTestArrayBufferAllocator : public v8::ArrayBuffer::Allocator { class CcTestArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
virtual void* Allocate(size_t length) { return malloc(length); } virtual void* Allocate(size_t length) { return malloc(length); }
virtual void* AllocateUninitialized(size_t length) { return malloc(length); } virtual void* AllocateUninitialized(size_t length) { return malloc(length); }
......
...@@ -92,12 +92,9 @@ class CcTest { ...@@ -92,12 +92,9 @@ class CcTest {
const char* dependency() { return dependency_; } const char* dependency() { return dependency_; }
bool enabled() { return enabled_; } bool enabled() { return enabled_; }
static v8::Handle<v8::Context> env() {
return v8::Local<v8::Context>::New(isolate(), context_);
}
static v8::Isolate* isolate() { static v8::Isolate* isolate() {
return default_isolate_; isolate_used_ = true;
return isolate_;
} }
static i::Isolate* i_isolate() { static i::Isolate* i_isolate() {
...@@ -108,8 +105,21 @@ class CcTest { ...@@ -108,8 +105,21 @@ class CcTest {
return i_isolate()->heap(); return i_isolate()->heap();
} }
// Helper function to initialize the VM. // TODO(dcarney): Remove.
static void InitializeVM(CcTestExtensionFlags extensions = NO_EXTENSIONS); // This must be called first in a test.
static void InitializeVM() {
CHECK(!isolate_used_);
CHECK(!initialize_called_);
initialize_called_ = true;
v8::HandleScope handle_scope(CcTest::isolate());
v8::Context::New(CcTest::isolate())->Enter();
}
// Helper function to configure a context.
// Must be in a HandleScope.
static v8::Local<v8::Context> NewContext(
CcTestExtensionFlags extensions,
v8::Isolate* isolate = CcTest::isolate());
private: private:
friend int main(int argc, char** argv); friend int main(int argc, char** argv);
...@@ -121,10 +131,9 @@ class CcTest { ...@@ -121,10 +131,9 @@ class CcTest {
bool initialize_; bool initialize_;
CcTest* prev_; CcTest* prev_;
static CcTest* last_; static CcTest* last_;
static v8::Isolate* default_isolate_; static v8::Isolate* isolate_;
enum InitializationState {kUnset, kUnintialized, kInitialized}; static bool initialize_called_;
static InitializationState initialization_state_; static bool isolate_used_;
static v8::Persistent<v8::Context> context_;
}; };
// Switches between all the Api tests using the threading support. // Switches between all the Api tests using the threading support.
......
...@@ -443,7 +443,6 @@ static void TestRoundingMode(VCVTTypes types, ...@@ -443,7 +443,6 @@ static void TestRoundingMode(VCVTTypes types,
double value, double value,
int expected, int expected,
bool expected_exception = false) { bool expected_exception = false) {
CcTest::InitializeVM();
Isolate* isolate = CcTest::i_isolate(); Isolate* isolate = CcTest::i_isolate();
HandleScope scope(isolate); HandleScope scope(isolate);
...@@ -511,6 +510,7 @@ static void TestRoundingMode(VCVTTypes types, ...@@ -511,6 +510,7 @@ static void TestRoundingMode(VCVTTypes types,
TEST(7) { TEST(7) {
CcTest::InitializeVM();
// Test vfp rounding modes. // Test vfp rounding modes.
// s32_f64 (double to integer). // s32_f64 (double to integer).
......
...@@ -433,7 +433,6 @@ TEST(AssemblerMultiByteNop) { ...@@ -433,7 +433,6 @@ TEST(AssemblerMultiByteNop) {
#define ELEMENT_COUNT 4 #define ELEMENT_COUNT 4
void DoSSE2(const v8::FunctionCallbackInfo<v8::Value>& args) { void DoSSE2(const v8::FunctionCallbackInfo<v8::Value>& args) {
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
v8::internal::byte buffer[1024]; v8::internal::byte buffer[1024];
...@@ -483,6 +482,7 @@ void DoSSE2(const v8::FunctionCallbackInfo<v8::Value>& args) { ...@@ -483,6 +482,7 @@ void DoSSE2(const v8::FunctionCallbackInfo<v8::Value>& args) {
TEST(StackAlignmentForSSE2) { TEST(StackAlignmentForSSE2) {
CcTest::InitializeVM();
CHECK_EQ(0, OS::ActivationFrameAlignment() % 16); CHECK_EQ(0, OS::ActivationFrameAlignment() % 16);
v8::Isolate* isolate = CcTest::isolate(); v8::Isolate* isolate = CcTest::isolate();
......
...@@ -202,8 +202,9 @@ TEST(Sum) { ...@@ -202,8 +202,9 @@ TEST(Sum) {
TEST(Print) { TEST(Print) {
CcTest::InitializeVM(PRINT_EXTENSION);
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Context> context = CcTest::NewContext(PRINT_EXTENSION);
v8::Context::Scope context_scope(context);
const char* source = "for (n = 0; n < 100; ++n) print(n, 1, 2);"; const char* source = "for (n = 0; n < 100; ++n) print(n, 1, 2);";
Handle<JSFunction> fun = Compile(source); Handle<JSFunction> fun = Compile(source);
if (fun.is_null()) return; if (fun.is_null()) return;
...@@ -273,8 +274,10 @@ TEST(UncaughtThrow) { ...@@ -273,8 +274,10 @@ TEST(UncaughtThrow) {
// | JS | // | JS |
// | C-to-JS | // | C-to-JS |
TEST(C2JSFrames) { TEST(C2JSFrames) {
CcTest::InitializeVM(PRINT_EXTENSION | GC_EXTENSION);
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Context> context =
CcTest::NewContext(PRINT_EXTENSION | GC_EXTENSION);
v8::Context::Scope context_scope(context);
const char* source = "function foo(a) { gc(), print(a); }"; const char* source = "function foo(a) { gc(), print(a); }";
...@@ -325,7 +328,7 @@ TEST(Regression236) { ...@@ -325,7 +328,7 @@ TEST(Regression236) {
TEST(GetScriptLineNumber) { TEST(GetScriptLineNumber) {
CcTest::InitializeVM(); LocalContext context;
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::New("test")); v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::New("test"));
const char function_f[] = "function f() {}"; const char function_f[] = "function f() {}";
...@@ -342,7 +345,7 @@ TEST(GetScriptLineNumber) { ...@@ -342,7 +345,7 @@ TEST(GetScriptLineNumber) {
v8::Handle<v8::String> script_body = v8::String::New(buffer.start()); v8::Handle<v8::String> script_body = v8::String::New(buffer.start());
v8::Script::Compile(script_body, &origin)->Run(); v8::Script::Compile(script_body, &origin)->Run();
v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(
CcTest::env()->Global()->Get(v8::String::New("f"))); context->Global()->Get(v8::String::New("f")));
CHECK_EQ(i, f->GetScriptLineNumber()); CHECK_EQ(i, f->GetScriptLineNumber());
} }
} }
...@@ -420,16 +423,16 @@ static void CheckCodeForUnsafeLiteral(Handle<JSFunction> f) { ...@@ -420,16 +423,16 @@ static void CheckCodeForUnsafeLiteral(Handle<JSFunction> f) {
TEST(SplitConstantsInFullCompiler) { TEST(SplitConstantsInFullCompiler) {
CcTest::InitializeVM(); LocalContext context;
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
CompileRun("function f() { a = 12345678 }; f();"); CompileRun("function f() { a = 12345678 }; f();");
CheckCodeForUnsafeLiteral(GetJSFunction(CcTest::env()->Global(), "f")); CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f"));
CompileRun("function f(x) { a = 12345678 + x}; f(1);"); CompileRun("function f(x) { a = 12345678 + x}; f(1);");
CheckCodeForUnsafeLiteral(GetJSFunction(CcTest::env()->Global(), "f")); CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f"));
CompileRun("function f(x) { var arguments = 1; x += 12345678}; f(1);"); CompileRun("function f(x) { var arguments = 1; x += 12345678}; f(1);");
CheckCodeForUnsafeLiteral(GetJSFunction(CcTest::env()->Global(), "f")); CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f"));
CompileRun("function f(x) { var arguments = 1; x = 12345678}; f(1);"); CompileRun("function f(x) { var arguments = 1; x = 12345678}; f(1);");
CheckCodeForUnsafeLiteral(GetJSFunction(CcTest::env()->Global(), "f")); CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f"));
} }
#endif #endif
...@@ -2896,7 +2896,6 @@ void ReleaseStackTraceDataTest(const char* source, const char* accessor) { ...@@ -2896,7 +2896,6 @@ void ReleaseStackTraceDataTest(const char* source, const char* accessor) {
// resource's callback is fired when the external string is GC'ed. // resource's callback is fired when the external string is GC'ed.
FLAG_use_ic = false; // ICs retain objects. FLAG_use_ic = false; // ICs retain objects.
FLAG_concurrent_recompilation = false; FLAG_concurrent_recompilation = false;
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
SourceResource* resource = new SourceResource(i::StrDup(source)); SourceResource* resource = new SourceResource(i::StrDup(source));
{ {
...@@ -2919,6 +2918,7 @@ void ReleaseStackTraceDataTest(const char* source, const char* accessor) { ...@@ -2919,6 +2918,7 @@ void ReleaseStackTraceDataTest(const char* source, const char* accessor) {
TEST(ReleaseStackTraceData) { TEST(ReleaseStackTraceData) {
CcTest::InitializeVM();
static const char* source1 = "var error = null; " static const char* source1 = "var error = null; "
/* Normal Error */ "try { " /* Normal Error */ "try { "
" throw new Error(); " " throw new Error(); "
......
...@@ -187,8 +187,10 @@ static bool IsAddressWithinFuncCode(JSFunction* function, Address addr) { ...@@ -187,8 +187,10 @@ static bool IsAddressWithinFuncCode(JSFunction* function, Address addr) {
} }
static bool IsAddressWithinFuncCode(const char* func_name, Address addr) { static bool IsAddressWithinFuncCode(v8::Local<v8::Context> context,
v8::Local<v8::Value> func = CcTest::env()->Global()->Get(v8_str(func_name)); const char* func_name,
Address addr) {
v8::Local<v8::Value> func = context->Global()->Get(v8_str(func_name));
CHECK(func->IsFunction()); CHECK(func->IsFunction());
JSFunction* js_func = JSFunction::cast(*v8::Utils::OpenHandle(*func)); JSFunction* js_func = JSFunction::cast(*v8::Utils::OpenHandle(*func));
return IsAddressWithinFuncCode(js_func, addr); return IsAddressWithinFuncCode(js_func, addr);
...@@ -225,19 +227,21 @@ static void construct_call(const v8::FunctionCallbackInfo<v8::Value>& args) { ...@@ -225,19 +227,21 @@ static void construct_call(const v8::FunctionCallbackInfo<v8::Value>& args) {
// Use the API to create a JSFunction object that calls the above C++ function. // Use the API to create a JSFunction object that calls the above C++ function.
void CreateFramePointerGrabberConstructor(const char* constructor_name) { void CreateFramePointerGrabberConstructor(v8::Local<v8::Context> context,
const char* constructor_name) {
Local<v8::FunctionTemplate> constructor_template = Local<v8::FunctionTemplate> constructor_template =
v8::FunctionTemplate::New(construct_call); v8::FunctionTemplate::New(construct_call);
constructor_template->SetClassName(v8_str("FPGrabber")); constructor_template->SetClassName(v8_str("FPGrabber"));
Local<Function> fun = constructor_template->GetFunction(); Local<Function> fun = constructor_template->GetFunction();
CcTest::env()->Global()->Set(v8_str(constructor_name), fun); context->Global()->Set(v8_str(constructor_name), fun);
} }
// Creates a global function named 'func_name' that calls the tracing // Creates a global function named 'func_name' that calls the tracing
// function 'trace_func_name' with an actual EBP register value, // function 'trace_func_name' with an actual EBP register value,
// encoded as one or two Smis. // encoded as one or two Smis.
static void CreateTraceCallerFunction(const char* func_name, static void CreateTraceCallerFunction(v8::Local<v8::Context> context,
const char* func_name,
const char* trace_func_name) { const char* trace_func_name) {
i::EmbeddedVector<char, 256> trace_call_buf; i::EmbeddedVector<char, 256> trace_call_buf;
i::OS::SNPrintF(trace_call_buf, i::OS::SNPrintF(trace_call_buf,
...@@ -249,7 +253,7 @@ static void CreateTraceCallerFunction(const char* func_name, ...@@ -249,7 +253,7 @@ static void CreateTraceCallerFunction(const char* func_name,
// Create the FPGrabber function, which grabs the caller's frame pointer // Create the FPGrabber function, which grabs the caller's frame pointer
// when called as a constructor. // when called as a constructor.
CreateFramePointerGrabberConstructor("FPGrabber"); CreateFramePointerGrabberConstructor(context, "FPGrabber");
// Compile the script. // Compile the script.
CompileRun(trace_call_buf.start()); CompileRun(trace_call_buf.start());
...@@ -267,11 +271,13 @@ TEST(CFromJSStackTrace) { ...@@ -267,11 +271,13 @@ TEST(CFromJSStackTrace) {
TickSample sample; TickSample sample;
InitTraceEnv(&sample); InitTraceEnv(&sample);
CcTest::InitializeVM(TRACE_EXTENSION);
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Context> context = CcTest::NewContext(TRACE_EXTENSION);
v8::Context::Scope context_scope(context);
// Create global function JSFuncDoTrace which calls // Create global function JSFuncDoTrace which calls
// extension function trace() with the current frame pointer value. // extension function trace() with the current frame pointer value.
CreateTraceCallerFunction("JSFuncDoTrace", "trace"); CreateTraceCallerFunction(context, "JSFuncDoTrace", "trace");
Local<Value> result = CompileRun( Local<Value> result = CompileRun(
"function JSTrace() {" "function JSTrace() {"
" JSFuncDoTrace();" " JSFuncDoTrace();"
...@@ -294,8 +300,9 @@ TEST(CFromJSStackTrace) { ...@@ -294,8 +300,9 @@ TEST(CFromJSStackTrace) {
int base = 0; int base = 0;
CHECK_GT(sample.frames_count, base + 1); CHECK_GT(sample.frames_count, base + 1);
CHECK(IsAddressWithinFuncCode("JSFuncDoTrace", sample.stack[base + 0])); CHECK(IsAddressWithinFuncCode(
CHECK(IsAddressWithinFuncCode("JSTrace", sample.stack[base + 1])); context, "JSFuncDoTrace", sample.stack[base + 0]));
CHECK(IsAddressWithinFuncCode(context, "JSTrace", sample.stack[base + 1]));
} }
...@@ -312,11 +319,13 @@ TEST(PureJSStackTrace) { ...@@ -312,11 +319,13 @@ TEST(PureJSStackTrace) {
TickSample sample; TickSample sample;
InitTraceEnv(&sample); InitTraceEnv(&sample);
CcTest::InitializeVM(TRACE_EXTENSION);
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Context> context = CcTest::NewContext(TRACE_EXTENSION);
v8::Context::Scope context_scope(context);
// Create global function JSFuncDoTrace which calls // Create global function JSFuncDoTrace which calls
// extension function js_trace() with the current frame pointer value. // extension function js_trace() with the current frame pointer value.
CreateTraceCallerFunction("JSFuncDoTrace", "js_trace"); CreateTraceCallerFunction(context, "JSFuncDoTrace", "js_trace");
Local<Value> result = CompileRun( Local<Value> result = CompileRun(
"function JSTrace() {" "function JSTrace() {"
" JSFuncDoTrace();" " JSFuncDoTrace();"
...@@ -343,8 +352,9 @@ TEST(PureJSStackTrace) { ...@@ -343,8 +352,9 @@ TEST(PureJSStackTrace) {
// Stack sampling will start from the caller of JSFuncDoTrace, i.e. "JSTrace" // Stack sampling will start from the caller of JSFuncDoTrace, i.e. "JSTrace"
int base = 0; int base = 0;
CHECK_GT(sample.frames_count, base + 1); CHECK_GT(sample.frames_count, base + 1);
CHECK(IsAddressWithinFuncCode("JSTrace", sample.stack[base + 0])); CHECK(IsAddressWithinFuncCode(context, "JSTrace", sample.stack[base + 0]));
CHECK(IsAddressWithinFuncCode("OuterJSTrace", sample.stack[base + 1])); CHECK(IsAddressWithinFuncCode(
context, "OuterJSTrace", sample.stack[base + 1]));
} }
...@@ -379,15 +389,18 @@ static int CFunc(int depth) { ...@@ -379,15 +389,18 @@ static int CFunc(int depth) {
TEST(PureCStackTrace) { TEST(PureCStackTrace) {
TickSample sample; TickSample sample;
InitTraceEnv(&sample); InitTraceEnv(&sample);
CcTest::InitializeVM(TRACE_EXTENSION); v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Context> context = CcTest::NewContext(TRACE_EXTENSION);
v8::Context::Scope context_scope(context);
// Check that sampler doesn't crash // Check that sampler doesn't crash
CHECK_EQ(10, CFunc(10)); CHECK_EQ(10, CFunc(10));
} }
TEST(JsEntrySp) { TEST(JsEntrySp) {
CcTest::InitializeVM(TRACE_EXTENSION);
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Context> context = CcTest::NewContext(TRACE_EXTENSION);
v8::Context::Scope context_scope(context);
CHECK_EQ(0, GetJsEntrySp()); CHECK_EQ(0, GetJsEntrySp());
CompileRun("a = 1; b = a + 1;"); CompileRun("a = 1; b = a + 1;");
CHECK_EQ(0, GetJsEntrySp()); CHECK_EQ(0, GetJsEntrySp());
......
...@@ -77,6 +77,8 @@ TEST(Promotion) { ...@@ -77,6 +77,8 @@ TEST(Promotion) {
// skip the entire test. // skip the entire test.
if (FLAG_never_compact) return; if (FLAG_never_compact) return;
CcTest::InitializeVM();
// Ensure that we get a compacting collection so that objects are promoted // Ensure that we get a compacting collection so that objects are promoted
// from new space. // from new space.
FLAG_gc_global = true; FLAG_gc_global = true;
...@@ -84,8 +86,6 @@ TEST(Promotion) { ...@@ -84,8 +86,6 @@ TEST(Promotion) {
Heap* heap = CcTest::heap(); Heap* heap = CcTest::heap();
heap->ConfigureHeap(2*256*KB, 8*MB, 8*MB); heap->ConfigureHeap(2*256*KB, 8*MB, 8*MB);
CcTest::InitializeVM();
v8::HandleScope sc(CcTest::isolate()); v8::HandleScope sc(CcTest::isolate());
// Allocate a fixed array in the new space. // Allocate a fixed array in the new space.
...@@ -108,12 +108,12 @@ TEST(Promotion) { ...@@ -108,12 +108,12 @@ TEST(Promotion) {
TEST(NoPromotion) { TEST(NoPromotion) {
CcTest::heap()->ConfigureHeap(2*256*KB, 8*MB, 8*MB);
// Test the situation that some objects in new space are promoted to // Test the situation that some objects in new space are promoted to
// the old space // the old space
CcTest::InitializeVM(); CcTest::InitializeVM();
CcTest::heap()->ConfigureHeap(2*256*KB, 8*MB, 8*MB);
v8::HandleScope sc(CcTest::isolate()); v8::HandleScope sc(CcTest::isolate());
// Do a mark compact GC to shrink the heap. // Do a mark compact GC to shrink the heap.
......
...@@ -933,7 +933,7 @@ TEST(ExternalShortStringAdd) { ...@@ -933,7 +933,7 @@ TEST(ExternalShortStringAdd) {
Isolate* isolate = CcTest::i_isolate(); Isolate* isolate = CcTest::i_isolate();
Zone zone(isolate); Zone zone(isolate);
CcTest::InitializeVM(); LocalContext context;
v8::HandleScope handle_scope(CcTest::isolate()); v8::HandleScope handle_scope(CcTest::isolate());
// Make sure we cover all always-flat lengths and at least one above. // Make sure we cover all always-flat lengths and at least one above.
...@@ -974,7 +974,7 @@ TEST(ExternalShortStringAdd) { ...@@ -974,7 +974,7 @@ TEST(ExternalShortStringAdd) {
} }
// Add the arrays with the short external strings in the global object. // Add the arrays with the short external strings in the global object.
v8::Handle<v8::Object> global = CcTest::env()->Global(); v8::Handle<v8::Object> global = context->Global();
global->Set(v8_str("external_ascii"), ascii_external_strings); global->Set(v8_str("external_ascii"), ascii_external_strings);
global->Set(v8_str("external_non_ascii"), non_ascii_external_strings); global->Set(v8_str("external_non_ascii"), non_ascii_external_strings);
global->Set(v8_str("max_length"), v8::Integer::New(kMaxLength)); global->Set(v8_str("max_length"), v8::Integer::New(kMaxLength));
...@@ -1018,9 +1018,9 @@ TEST(ExternalShortStringAdd) { ...@@ -1018,9 +1018,9 @@ TEST(ExternalShortStringAdd) {
TEST(JSONStringifySliceMadeExternal) { TEST(JSONStringifySliceMadeExternal) {
CcTest::InitializeVM();
Isolate* isolate = CcTest::i_isolate(); Isolate* isolate = CcTest::i_isolate();
Zone zone(isolate); Zone zone(isolate);
CcTest::InitializeVM();
// Create a sliced string from a one-byte string. The latter is turned // Create a sliced string from a one-byte string. The latter is turned
// into a two-byte external string. Check that JSON.stringify works. // into a two-byte external string. Check that JSON.stringify works.
v8::HandleScope handle_scope(CcTest::isolate()); v8::HandleScope handle_scope(CcTest::isolate());
...@@ -1048,13 +1048,13 @@ TEST(JSONStringifySliceMadeExternal) { ...@@ -1048,13 +1048,13 @@ TEST(JSONStringifySliceMadeExternal) {
TEST(CachedHashOverflow) { TEST(CachedHashOverflow) {
CcTest::InitializeVM();
// We incorrectly allowed strings to be tagged as array indices even if their // We incorrectly allowed strings to be tagged as array indices even if their
// values didn't fit in the hash field. // values didn't fit in the hash field.
// See http://code.google.com/p/v8/issues/detail?id=728 // See http://code.google.com/p/v8/issues/detail?id=728
Isolate* isolate = CcTest::i_isolate(); Isolate* isolate = CcTest::i_isolate();
Zone zone(isolate); Zone zone(isolate);
CcTest::InitializeVM();
v8::HandleScope handle_scope(CcTest::isolate()); v8::HandleScope handle_scope(CcTest::isolate());
// Lines must be executed sequentially. Combining them into one script // Lines must be executed sequentially. Combining them into one script
// makes the bug go away. // makes the bug go away.
......
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