Unify the way cctest initalizes the VM for each test case.

R=svenpanne@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14199 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 4623e711
......@@ -1019,6 +1019,9 @@ class EnumSet {
void Intersect(const EnumSet& set) { bits_ &= set.bits_; }
T ToIntegral() const { return bits_; }
bool operator==(const EnumSet& set) { return bits_ == set.bits_; }
EnumSet<E, T> operator|(const EnumSet& set) const {
return EnumSet<E, T>(bits_ | set.bits_);
}
private:
T Mask(E element) const {
......
......@@ -57,6 +57,24 @@ CcTest::CcTest(TestFunction* callback, const char* file, const char* name,
}
v8::Persistent<v8::Context> CcTest::context_;
void CcTest::InitializeVM(CcTestExtensionFlags extensions) {
const char* extension_names[kMaxExtensions];
int extension_count = 0;
#define CHECK_EXTENSION_FLAG(Name, Id) \
if (extensions.Contains(Name##_ID)) extension_names[extension_count++] = Id;
EXTENSION_LIST(CHECK_EXTENSION_FLAG)
#undef CHECK_EXTENSION_FLAG
if (context_.IsEmpty()) {
v8::ExtensionConfiguration config(extension_count, extension_names);
context_ = v8::Context::New(&config);
}
context_->Enter();
}
static void PrintTestList(CcTest* current) {
if (current == NULL) return;
PrintTestList(current->prev());
......@@ -71,6 +89,7 @@ static void PrintTestList(CcTest* current) {
v8::Isolate* CcTest::default_isolate_;
int main(int argc, char* argv[]) {
v8::internal::FlagList::SetFlagsFromCommandLine(&argc, argv, true);
CcTest::set_default_isolate(v8::Isolate::GetCurrent());
......
......@@ -51,6 +51,26 @@
static void Test##Name()
#endif
#define EXTENSION_LIST(V) \
V(GC_EXTENSION, "v8/gc") \
V(PRINT_EXTENSION, "v8/print") \
V(TRACE_EXTENSION, "v8/trace")
#define DEFINE_EXTENSION_ID(Name, Ident) Name##_ID,
enum CcTestExtensionIds {
EXTENSION_LIST(DEFINE_EXTENSION_ID)
kMaxExtensions
};
#undef DEFINE_EXTENSION_ID
typedef v8::internal::EnumSet<CcTestExtensionIds> CcTestExtensionFlags;
#define DEFINE_EXTENSION_FLAG(Name, Ident) \
static const CcTestExtensionFlags Name(1 << Name##_ID);
static const CcTestExtensionFlags NO_EXTENSIONS(0);
static const CcTestExtensionFlags ALL_EXTENSIONS((1 << kMaxExtensions) - 1);
EXTENSION_LIST(DEFINE_EXTENSION_FLAG)
#undef DEFINE_EXTENSION_FLAG
class CcTest {
public:
typedef void (TestFunction)();
......@@ -67,6 +87,11 @@ class CcTest {
default_isolate_ = default_isolate;
}
static v8::Isolate* default_isolate() { return default_isolate_; }
static v8::Isolate* isolate() { return context_->GetIsolate(); }
static v8::Handle<v8::Context> env() { return context_; }
// Helper function to initialize the VM.
static void InitializeVM(CcTestExtensionFlags extensions = NO_EXTENSIONS);
private:
TestFunction* callback_;
......@@ -74,9 +99,10 @@ class CcTest {
const char* name_;
const char* dependency_;
bool enabled_;
static CcTest* last_;
CcTest* prev_;
static CcTest* last_;
static v8::Isolate* default_isolate_;
static v8::Persistent<v8::Context> context_;
};
// Switches between all the Api tests using the threading support.
......
......@@ -43,20 +43,10 @@ typedef Object* (*F3)(void* p0, int p1, int p2, int p3, int p4);
typedef Object* (*F4)(void* p0, void* p1, int p2, int p3, int p4);
static v8::Persistent<v8::Context> env;
static void InitializeVM() {
if (env.IsEmpty()) {
env = v8::Context::New();
}
}
#define __ assm.
TEST(0) {
InitializeVM();
CcTest::InitializeVM();
Isolate* isolate = Isolate::Current();
HandleScope scope(isolate);
......@@ -83,7 +73,7 @@ TEST(0) {
TEST(1) {
InitializeVM();
CcTest::InitializeVM();
Isolate* isolate = Isolate::Current();
HandleScope scope(isolate);
......@@ -121,7 +111,7 @@ TEST(1) {
TEST(2) {
InitializeVM();
CcTest::InitializeVM();
Isolate* isolate = Isolate::Current();
HandleScope scope(isolate);
......@@ -168,7 +158,7 @@ TEST(2) {
TEST(3) {
InitializeVM();
CcTest::InitializeVM();
Isolate* isolate = Isolate::Current();
HandleScope scope(isolate);
......@@ -224,7 +214,7 @@ TEST(3) {
TEST(4) {
// Test the VFP floating point instructions.
InitializeVM();
CcTest::InitializeVM();
Isolate* isolate = Isolate::Current();
HandleScope scope(isolate);
......@@ -363,7 +353,7 @@ TEST(4) {
TEST(5) {
// Test the ARMv7 bitfield instructions.
InitializeVM();
CcTest::InitializeVM();
Isolate* isolate = Isolate::Current();
HandleScope scope(isolate);
......@@ -400,7 +390,7 @@ TEST(5) {
TEST(6) {
// Test saturating instructions.
InitializeVM();
CcTest::InitializeVM();
Isolate* isolate = Isolate::Current();
HandleScope scope(isolate);
......@@ -444,7 +434,7 @@ static void TestRoundingMode(VCVTTypes types,
double value,
int expected,
bool expected_exception = false) {
InitializeVM();
CcTest::InitializeVM();
Isolate* isolate = Isolate::Current();
HandleScope scope(isolate);
......@@ -622,7 +612,7 @@ TEST(7) {
TEST(8) {
// Test VFP multi load/store with ia_w.
InitializeVM();
CcTest::InitializeVM();
Isolate* isolate = Isolate::Current();
HandleScope scope(isolate);
......@@ -730,7 +720,7 @@ TEST(8) {
TEST(9) {
// Test VFP multi load/store with ia.
InitializeVM();
CcTest::InitializeVM();
Isolate* isolate = Isolate::Current();
HandleScope scope(isolate);
......@@ -842,7 +832,7 @@ TEST(9) {
TEST(10) {
// Test VFP multi load/store with db_w.
InitializeVM();
CcTest::InitializeVM();
Isolate* isolate = Isolate::Current();
HandleScope scope(isolate);
......@@ -950,7 +940,7 @@ TEST(10) {
TEST(11) {
// Test instructions using the carry flag.
InitializeVM();
CcTest::InitializeVM();
Isolate* isolate = Isolate::Current();
HandleScope scope(isolate);
......@@ -1016,7 +1006,7 @@ TEST(11) {
TEST(12) {
// Test chaining of label usages within instructions (issue 1644).
InitializeVM();
CcTest::InitializeVM();
Isolate* isolate = Isolate::Current();
HandleScope scope(isolate);
......@@ -1031,7 +1021,7 @@ TEST(12) {
TEST(13) {
// Test VFP instructions using registers d16-d31.
InitializeVM();
CcTest::InitializeVM();
Isolate* isolate = Isolate::Current();
HandleScope scope(isolate);
......
......@@ -44,21 +44,11 @@ typedef int (*F1)(int x);
typedef int (*F2)(int x, int y);
static v8::Persistent<v8::Context> env;
static void InitializeVM() {
if (env.IsEmpty()) {
env = v8::Context::New();
}
}
#define __ assm.
TEST(AssemblerIa320) {
InitializeVM();
Isolate* isolate = reinterpret_cast<Isolate*>(env->GetIsolate());
CcTest::InitializeVM();
Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate());
HandleScope scope(isolate);
v8::internal::byte buffer[256];
......@@ -86,8 +76,8 @@ TEST(AssemblerIa320) {
TEST(AssemblerIa321) {
InitializeVM();
Isolate* isolate = reinterpret_cast<Isolate*>(env->GetIsolate());
CcTest::InitializeVM();
Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate());
HandleScope scope(isolate);
v8::internal::byte buffer[256];
......@@ -125,8 +115,8 @@ TEST(AssemblerIa321) {
TEST(AssemblerIa322) {
InitializeVM();
Isolate* isolate = reinterpret_cast<Isolate*>(env->GetIsolate());
CcTest::InitializeVM();
Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate());
HandleScope scope(isolate);
v8::internal::byte buffer[256];
......@@ -170,10 +160,10 @@ TEST(AssemblerIa322) {
typedef int (*F3)(float x);
TEST(AssemblerIa323) {
InitializeVM();
CcTest::InitializeVM();
if (!CpuFeatures::IsSupported(SSE2)) return;
Isolate* isolate = reinterpret_cast<Isolate*>(env->GetIsolate());
Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate());
HandleScope scope(isolate);
v8::internal::byte buffer[256];
......@@ -206,10 +196,10 @@ TEST(AssemblerIa323) {
typedef int (*F4)(double x);
TEST(AssemblerIa324) {
InitializeVM();
CcTest::InitializeVM();
if (!CpuFeatures::IsSupported(SSE2)) return;
Isolate* isolate = reinterpret_cast<Isolate*>(env->GetIsolate());
Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate());
HandleScope scope(isolate);
v8::internal::byte buffer[256];
......@@ -240,8 +230,8 @@ TEST(AssemblerIa324) {
static int baz = 42;
TEST(AssemblerIa325) {
InitializeVM();
Isolate* isolate = reinterpret_cast<Isolate*>(env->GetIsolate());
CcTest::InitializeVM();
Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate());
HandleScope scope(isolate);
v8::internal::byte buffer[256];
......@@ -265,10 +255,10 @@ TEST(AssemblerIa325) {
typedef double (*F5)(double x, double y);
TEST(AssemblerIa326) {
InitializeVM();
CcTest::InitializeVM();
if (!CpuFeatures::IsSupported(SSE2)) return;
Isolate* isolate = reinterpret_cast<Isolate*>(env->GetIsolate());
Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate());
HandleScope scope(isolate);
v8::internal::byte buffer[256];
Assembler assm(isolate, buffer, sizeof buffer);
......@@ -311,10 +301,10 @@ TEST(AssemblerIa326) {
typedef double (*F6)(int x);
TEST(AssemblerIa328) {
InitializeVM();
CcTest::InitializeVM();
if (!CpuFeatures::IsSupported(SSE2)) return;
Isolate* isolate = reinterpret_cast<Isolate*>(env->GetIsolate());
Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate());
HandleScope scope(isolate);
v8::internal::byte buffer[256];
Assembler assm(isolate, buffer, sizeof buffer);
......@@ -348,8 +338,8 @@ TEST(AssemblerIa328) {
typedef int (*F7)(double x, double y);
TEST(AssemblerIa329) {
InitializeVM();
Isolate* isolate = reinterpret_cast<Isolate*>(env->GetIsolate());
CcTest::InitializeVM();
Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate());
HandleScope scope(isolate);
v8::internal::byte buffer[256];
MacroAssembler assm(isolate, buffer, sizeof buffer);
......@@ -404,8 +394,8 @@ TEST(AssemblerIa329) {
TEST(AssemblerIa3210) {
// Test chaining of label usages within instructions (issue 1644).
InitializeVM();
Isolate* isolate = reinterpret_cast<Isolate*>(env->GetIsolate());
CcTest::InitializeVM();
Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate());
HandleScope scope(isolate);
Assembler assm(isolate, NULL, 0);
......@@ -418,8 +408,8 @@ TEST(AssemblerIa3210) {
TEST(AssemblerMultiByteNop) {
InitializeVM();
Isolate* isolate = reinterpret_cast<Isolate*>(env->GetIsolate());
CcTest::InitializeVM();
Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate());
HandleScope scope(isolate);
v8::internal::byte buffer[1024];
Assembler assm(isolate, buffer, sizeof(buffer));
......
......@@ -44,24 +44,11 @@ typedef Object* (*F2)(int x, int y, int p2, int p3, int p4);
typedef Object* (*F3)(void* p, int p1, int p2, int p3, int p4);
static v8::Persistent<v8::Context> env;
static void InitializeVM() {
// Disable compilation of natives.
FLAG_disable_native_files = true;
if (env.IsEmpty()) {
env = v8::Context::New();
}
}
#define __ assm.
TEST(MIPS0) {
InitializeVM();
CcTest::InitializeVM();
Isolate* isolate = Isolate::Current();
HandleScope scope(isolate);
......@@ -87,7 +74,7 @@ TEST(MIPS0) {
TEST(MIPS1) {
InitializeVM();
CcTest::InitializeVM();
Isolate* isolate = Isolate::Current();
HandleScope scope(isolate);
......@@ -126,7 +113,7 @@ TEST(MIPS1) {
TEST(MIPS2) {
InitializeVM();
CcTest::InitializeVM();
Isolate* isolate = Isolate::Current();
HandleScope scope(isolate);
......@@ -268,7 +255,7 @@ TEST(MIPS2) {
TEST(MIPS3) {
// Test floating point instructions.
InitializeVM();
CcTest::InitializeVM();
Isolate* isolate = Isolate::Current();
HandleScope scope(isolate);
......@@ -360,7 +347,7 @@ TEST(MIPS3) {
TEST(MIPS4) {
// Test moves between floating point and integer registers.
InitializeVM();
CcTest::InitializeVM();
Isolate* isolate = Isolate::Current();
HandleScope scope(isolate);
......@@ -421,7 +408,7 @@ TEST(MIPS4) {
TEST(MIPS5) {
// Test conversions between doubles and integers.
InitializeVM();
CcTest::InitializeVM();
Isolate* isolate = Isolate::Current();
HandleScope scope(isolate);
......@@ -493,7 +480,7 @@ TEST(MIPS5) {
TEST(MIPS6) {
// Test simple memory loads and stores.
InitializeVM();
CcTest::InitializeVM();
Isolate* isolate = Isolate::Current();
HandleScope scope(isolate);
......@@ -566,7 +553,7 @@ TEST(MIPS6) {
TEST(MIPS7) {
// Test floating point compare and branch instructions.
InitializeVM();
CcTest::InitializeVM();
Isolate* isolate = Isolate::Current();
HandleScope scope(isolate);
......@@ -648,7 +635,7 @@ TEST(MIPS7) {
TEST(MIPS8) {
// Test ROTR and ROTRV instructions.
InitializeVM();
CcTest::InitializeVM();
Isolate* isolate = Isolate::Current();
HandleScope scope(isolate);
......@@ -753,7 +740,7 @@ TEST(MIPS8) {
TEST(MIPS9) {
// Test BRANCH improvements.
InitializeVM();
CcTest::InitializeVM();
Isolate* isolate = Isolate::Current();
HandleScope scope(isolate);
......@@ -783,7 +770,7 @@ TEST(MIPS9) {
TEST(MIPS10) {
// Test conversions between doubles and long integers.
// Test hos the long ints map to FP regs pairs.
InitializeVM();
CcTest::InitializeVM();
Isolate* isolate = Isolate::Current();
HandleScope scope(isolate);
......@@ -858,7 +845,7 @@ TEST(MIPS10) {
TEST(MIPS11) {
// Test LWL, LWR, SWL and SWR instructions.
InitializeVM();
CcTest::InitializeVM();
Isolate* isolate = Isolate::Current();
HandleScope scope(isolate);
......@@ -1002,7 +989,7 @@ TEST(MIPS11) {
TEST(MIPS12) {
InitializeVM();
CcTest::InitializeVM();
Isolate* isolate = Isolate::Current();
HandleScope scope(isolate);
......@@ -1094,7 +1081,7 @@ TEST(MIPS12) {
TEST(MIPS13) {
// Test Cvt_d_uw and Trunc_uw_d macros.
InitializeVM();
CcTest::InitializeVM();
Isolate* isolate = Isolate::Current();
HandleScope scope(isolate);
......@@ -1157,7 +1144,7 @@ TEST(MIPS13) {
TEST(MIPS14) {
// Test round, floor, ceil, trunc, cvt.
InitializeVM();
CcTest::InitializeVM();
Isolate* isolate = Isolate::Current();
HandleScope scope(isolate);
......@@ -1294,7 +1281,7 @@ TEST(MIPS14) {
TEST(MIPS15) {
// Test chaining of label usages within instructions (issue 1644).
InitializeVM();
CcTest::InitializeVM();
Isolate* isolate = Isolate::Current();
HandleScope scope(isolate);
Assembler assm(isolate, NULL, 0);
......
......@@ -88,16 +88,6 @@ static const v8::internal::Register arg2 = rsi;
#define __ assm.
static v8::Persistent<v8::Context> env;
static void InitializeVM() {
if (env.IsEmpty()) {
env = v8::Context::New();
}
}
TEST(AssemblerX64ReturnOperation) {
OS::SetUp();
// Allocate an executable page of memory.
......@@ -361,8 +351,8 @@ TEST(OperandRegisterDependency) {
TEST(AssemblerX64LabelChaining) {
// Test chaining of label usages within instructions (issue 1644).
InitializeVM();
v8::HandleScope scope(env->GetIsolate());
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
Assembler assm(Isolate::Current(), NULL, 0);
Label target;
......@@ -374,8 +364,8 @@ TEST(AssemblerX64LabelChaining) {
TEST(AssemblerMultiByteNop) {
InitializeVM();
v8::HandleScope scope(env->GetIsolate());
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
v8::internal::byte buffer[1024];
Isolate* isolate = Isolate::Current();
Assembler assm(isolate, buffer, sizeof(buffer));
......
......@@ -40,8 +40,6 @@
using namespace v8::internal;
static v8::Persistent<v8::Context> env;
// --- P r i n t E x t e n s i o n ---
class PrintExtension : public v8::Extension {
......@@ -81,16 +79,6 @@ static PrintExtension kPrintExtension;
v8::DeclareExtension kPrintExtensionDeclaration(&kPrintExtension);
static void InitializeVM() {
if (env.IsEmpty()) {
const char* extensions[] = { "v8/print", "v8/gc" };
v8::ExtensionConfiguration config(2, extensions);
env = v8::Context::New(&config);
}
env->Enter();
}
static MaybeObject* GetGlobalProperty(const char* name) {
Handle<String> internalized_name = FACTORY->InternalizeUtf8String(name);
return Isolate::Current()->context()->global_object()->GetProperty(
......@@ -142,8 +130,8 @@ static double Inc(int x) {
TEST(Inc) {
InitializeVM();
v8::HandleScope scope(env->GetIsolate());
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
CHECK_EQ(4.0, Inc(3));
}
......@@ -163,8 +151,8 @@ static double Add(int x, int y) {
TEST(Add) {
InitializeVM();
v8::HandleScope scope(env->GetIsolate());
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
CHECK_EQ(5.0, Add(2, 3));
}
......@@ -183,8 +171,8 @@ static double Abs(int x) {
TEST(Abs) {
InitializeVM();
v8::HandleScope scope(env->GetIsolate());
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
CHECK_EQ(3.0, Abs(-3));
}
......@@ -204,15 +192,15 @@ static double Sum(int n) {
TEST(Sum) {
InitializeVM();
v8::HandleScope scope(env->GetIsolate());
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
CHECK_EQ(5050.0, Sum(100));
}
TEST(Print) {
InitializeVM();
v8::HandleScope scope(env->GetIsolate());
CcTest::InitializeVM(PRINT_EXTENSION);
v8::HandleScope scope(CcTest::isolate());
const char* source = "for (n = 0; n < 100; ++n) print(n, 1, 2);";
Handle<JSFunction> fun = Compile(source);
if (fun.is_null()) return;
......@@ -226,8 +214,8 @@ TEST(Print) {
// The following test method stems from my coding efforts today. It
// tests all the functionality I have added to the compiler today
TEST(Stuff) {
InitializeVM();
v8::HandleScope scope(env->GetIsolate());
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
const char* source =
"r = 0;\n"
"a = new Object;\n"
......@@ -258,8 +246,8 @@ TEST(Stuff) {
TEST(UncaughtThrow) {
InitializeVM();
v8::HandleScope scope(env->GetIsolate());
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
const char* source = "throw 42;";
Handle<JSFunction> fun = Compile(source);
......@@ -280,8 +268,8 @@ TEST(UncaughtThrow) {
// | JS |
// | C-to-JS |
TEST(C2JSFrames) {
InitializeVM();
v8::HandleScope scope(env->GetIsolate());
CcTest::InitializeVM(PRINT_EXTENSION | GC_EXTENSION);
v8::HandleScope scope(CcTest::isolate());
const char* source = "function foo(a) { gc(), print(a); }";
......@@ -317,8 +305,8 @@ TEST(C2JSFrames) {
// Regression 236. Calling InitLineEnds on a Script with undefined
// source resulted in crash.
TEST(Regression236) {
InitializeVM();
v8::HandleScope scope(env->GetIsolate());
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
Handle<Script> script = FACTORY->NewScript(FACTORY->empty_string());
script->set_source(HEAP->undefined_value());
......@@ -329,8 +317,8 @@ TEST(Regression236) {
TEST(GetScriptLineNumber) {
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::New("test"));
const char function_f[] = "function f() {}";
const int max_rows = 1000;
......@@ -346,7 +334,7 @@ TEST(GetScriptLineNumber) {
v8::Handle<v8::String> script_body = v8::String::New(buffer.start());
v8::Script::Compile(script_body, &origin)->Run();
v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(
env->Global()->Get(v8::String::New("f")));
CcTest::env()->Global()->Get(v8::String::New("f")));
CHECK_EQ(i, f->GetScriptLineNumber());
}
}
......@@ -359,8 +347,8 @@ TEST(OptimizedCodeSharing) {
// FastNewClosureStub that is baked into the snapshot is incorrect.
if (!FLAG_cache_optimized_code) return;
FLAG_allow_natives_syntax = true;
InitializeVM();
v8::HandleScope scope(env->GetIsolate());
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
for (int i = 0; i < 10; i++) {
LocalContext env;
env->Global()->Set(v8::String::New("x"), v8::Integer::New(i));
......@@ -423,16 +411,16 @@ static void CheckCodeForUnsafeLiteral(Handle<JSFunction> f) {
TEST(SplitConstantsInFullCompiler) {
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
CompileRun("function f() { a = 12345678 }; f();");
CheckCodeForUnsafeLiteral(GetJSFunction(env->Global(), "f"));
CheckCodeForUnsafeLiteral(GetJSFunction(CcTest::env()->Global(), "f"));
CompileRun("function f(x) { a = 12345678 + x}; f(1);");
CheckCodeForUnsafeLiteral(GetJSFunction(env->Global(), "f"));
CheckCodeForUnsafeLiteral(GetJSFunction(CcTest::env()->Global(), "f"));
CompileRun("function f(x) { var arguments = 1; x += 12345678}; f(1);");
CheckCodeForUnsafeLiteral(GetJSFunction(env->Global(), "f"));
CheckCodeForUnsafeLiteral(GetJSFunction(CcTest::env()->Global(), "f"));
CompileRun("function f(x) { var arguments = 1; x = 12345678}; f(1);");
CheckCodeForUnsafeLiteral(GetJSFunction(env->Global(), "f"));
CheckCodeForUnsafeLiteral(GetJSFunction(CcTest::env()->Global(), "f"));
}
#endif
......@@ -51,14 +51,6 @@ TEST(StartStop) {
processor.Join();
}
static v8::Persistent<v8::Context> env;
static void InitializeVM() {
if (env.IsEmpty()) env = v8::Context::New();
v8::HandleScope scope(env->GetIsolate());
env->Enter();
}
static inline i::Address ToAddress(int n) {
return reinterpret_cast<i::Address>(n);
}
......@@ -101,7 +93,7 @@ class TestSetup {
} // namespace
TEST(CodeEvents) {
InitializeVM();
CcTest::InitializeVM();
i::Isolate* isolate = i::Isolate::Current();
i::Heap* heap = isolate->heap();
i::Factory* factory = isolate->factory();
......@@ -217,7 +209,7 @@ TEST(TickEvents) {
// http://crbug/51594
// This test must not crash.
TEST(CrashIfStoppingLastNonExistentProfile) {
InitializeVM();
CcTest::InitializeVM();
TestSetup test_setup;
CpuProfiler* profiler = i::Isolate::Current()->cpu_profiler();
profiler->StartProfiling("1");
......@@ -268,7 +260,7 @@ TEST(Issue1398) {
TEST(DeleteAllCpuProfiles) {
InitializeVM();
CcTest::InitializeVM();
TestSetup test_setup;
CpuProfiler* profiler = i::Isolate::Current()->cpu_profiler();
CHECK_EQ(0, profiler->GetProfilesCount());
......
......@@ -40,15 +40,6 @@
using namespace v8::internal;
static v8::Persistent<v8::Context> env;
static void InitializeVM() {
if (env.IsEmpty()) {
env = v8::Context::New();
}
}
bool DisassembleAndCompare(byte* pc, const char* compare_string) {
disasm::NameConverter converter;
disasm::Disassembler disasm(converter);
......@@ -73,7 +64,7 @@ bool DisassembleAndCompare(byte* pc, const char* compare_string) {
// disassembler. Declare the variables and allocate the data structures used
// in the rest of the macros.
#define SET_UP() \
InitializeVM(); \
CcTest::InitializeVM(); \
Isolate* isolate = Isolate::Current(); \
HandleScope scope(isolate); \
byte *buffer = reinterpret_cast<byte*>(malloc(4*1024)); \
......
......@@ -38,14 +38,6 @@
using namespace v8::internal;
static v8::Persistent<v8::Context> env;
static void InitializeVM() {
if (env.IsEmpty()) {
env = v8::Context::New();
}
}
#define __ assm.
......@@ -55,8 +47,8 @@ static void DummyStaticFunction(Object* result) {
TEST(DisasmIa320) {
InitializeVM();
Isolate* isolate = reinterpret_cast<Isolate*>(env->GetIsolate());
CcTest::InitializeVM();
Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate());
HandleScope scope(isolate);
v8::internal::byte buffer[2048];
Assembler assm(isolate, buffer, sizeof buffer);
......
......@@ -40,17 +40,6 @@
using namespace v8::internal;
static v8::Persistent<v8::Context> env;
static void InitializeVM() {
// Disable compilation of natives.
FLAG_disable_native_files = true;
if (env.IsEmpty()) {
env = v8::Context::New();
}
}
bool DisassembleAndCompare(byte* pc, const char* compare_string) {
disasm::NameConverter converter;
disasm::Disassembler disasm(converter);
......@@ -75,7 +64,7 @@ bool DisassembleAndCompare(byte* pc, const char* compare_string) {
// disassembler. Declare the variables and allocate the data structures used
// in the rest of the macros.
#define SET_UP() \
InitializeVM(); \
CcTest::InitializeVM(); \
Isolate* isolate = Isolate::Current(); \
HandleScope scope(isolate); \
byte *buffer = reinterpret_cast<byte*>(malloc(4*1024)); \
......
......@@ -38,14 +38,6 @@
using namespace v8::internal;
static v8::Persistent<v8::Context> env;
static void InitializeVM() {
if (env.IsEmpty()) {
env = v8::Context::New();
}
}
#define __ assm.
......@@ -55,7 +47,7 @@ static void DummyStaticFunction(Object* result) {
TEST(DisasmX64) {
InitializeVM();
CcTest::InitializeVM();
v8::HandleScope scope;
v8::internal::byte buffer[2048];
Assembler assm(Isolate::Current(), buffer, sizeof buffer);
......
......@@ -47,17 +47,6 @@ using ::v8::internal::SharedFunctionInfo;
using ::v8::internal::String;
static v8::Persistent<v8::Context> env;
static void InitializeVM() {
if (env.IsEmpty()) {
env = v8::Context::New();
}
env->Enter();
}
static void CheckFunctionName(v8::Handle<v8::Script> script,
const char* func_pos_src,
const char* ref_inferred_name) {
......@@ -108,8 +97,8 @@ static v8::Handle<v8::Script> Compile(const char* src) {
TEST(GlobalProperty) {
InitializeVM();
v8::HandleScope scope(env->GetIsolate());
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile(
"fun1 = function() { return 1; }\n"
......@@ -120,8 +109,8 @@ TEST(GlobalProperty) {
TEST(GlobalVar) {
InitializeVM();
v8::HandleScope scope(env->GetIsolate());
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile(
"var fun1 = function() { return 1; }\n"
......@@ -132,8 +121,8 @@ TEST(GlobalVar) {
TEST(LocalVar) {
InitializeVM();
v8::HandleScope scope(env->GetIsolate());
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile(
"function outer() {\n"
......@@ -146,8 +135,8 @@ TEST(LocalVar) {
TEST(InConstructor) {
InitializeVM();
v8::HandleScope scope(env->GetIsolate());
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile(
"function MyClass() {\n"
......@@ -160,8 +149,8 @@ TEST(InConstructor) {
TEST(Factory) {
InitializeVM();
v8::HandleScope scope(env->GetIsolate());
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile(
"function createMyObj() {\n"
......@@ -176,8 +165,8 @@ TEST(Factory) {
TEST(Static) {
InitializeVM();
v8::HandleScope scope(env->GetIsolate());
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile(
"function MyClass() {}\n"
......@@ -194,8 +183,8 @@ TEST(Static) {
TEST(Prototype) {
InitializeVM();
v8::HandleScope scope(env->GetIsolate());
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile(
"function MyClass() {}\n"
......@@ -212,8 +201,8 @@ TEST(Prototype) {
TEST(ObjectLiteral) {
InitializeVM();
v8::HandleScope scope(env->GetIsolate());
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile(
"function MyClass() {}\n"
......@@ -226,8 +215,8 @@ TEST(ObjectLiteral) {
TEST(AsParameter) {
InitializeVM();
v8::HandleScope scope(env->GetIsolate());
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile(
"function f1(a) { return a(); }\n"
......@@ -242,8 +231,8 @@ TEST(AsParameter) {
TEST(MultipleFuncsConditional) {
InitializeVM();
v8::HandleScope scope(env->GetIsolate());
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile(
"fun1 = 0 ?\n"
......@@ -255,8 +244,8 @@ TEST(MultipleFuncsConditional) {
TEST(MultipleFuncsInLiteral) {
InitializeVM();
v8::HandleScope scope(env->GetIsolate());
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile(
"function MyClass() {}\n"
......@@ -270,8 +259,8 @@ TEST(MultipleFuncsInLiteral) {
// See http://code.google.com/p/v8/issues/detail?id=380
TEST(Issue380) {
InitializeVM();
v8::HandleScope scope(env->GetIsolate());
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile(
"function a() {\n"
......@@ -283,8 +272,8 @@ TEST(Issue380) {
TEST(MultipleAssignments) {
InitializeVM();
v8::HandleScope scope(env->GetIsolate());
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile(
"var fun1 = fun2 = function () { return 1; }\n"
......@@ -299,8 +288,8 @@ TEST(MultipleAssignments) {
TEST(AsConstructorParameter) {
InitializeVM();
v8::HandleScope scope(env->GetIsolate());
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile(
"function Foo() {}\n"
......@@ -313,8 +302,8 @@ TEST(AsConstructorParameter) {
TEST(FactoryHashmap) {
InitializeVM();
v8::HandleScope scope(env->GetIsolate());
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile(
"function createMyObj() {\n"
......@@ -329,8 +318,8 @@ TEST(FactoryHashmap) {
TEST(FactoryHashmapVariable) {
InitializeVM();
v8::HandleScope scope(env->GetIsolate());
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile(
"function createMyObj() {\n"
......@@ -348,8 +337,8 @@ TEST(FactoryHashmapVariable) {
TEST(FactoryHashmapConditional) {
InitializeVM();
v8::HandleScope scope(env->GetIsolate());
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile(
"function createMyObj() {\n"
......@@ -363,8 +352,8 @@ TEST(FactoryHashmapConditional) {
TEST(GlobalAssignmentAndCall) {
InitializeVM();
v8::HandleScope scope(env->GetIsolate());
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile(
"var Foo = function() {\n"
......@@ -381,8 +370,8 @@ TEST(GlobalAssignmentAndCall) {
TEST(AssignmentAndCall) {
InitializeVM();
v8::HandleScope scope(env->GetIsolate());
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile(
"(function Enclosing() {\n"
......@@ -404,8 +393,8 @@ TEST(AssignmentAndCall) {
TEST(MethodAssignmentInAnonymousFunctionCall) {
InitializeVM();
v8::HandleScope scope(env->GetIsolate());
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile(
"(function () {\n"
......@@ -420,8 +409,8 @@ TEST(MethodAssignmentInAnonymousFunctionCall) {
TEST(ReturnAnonymousFunction) {
InitializeVM();
v8::HandleScope scope(env->GetIsolate());
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile(
"(function() {\n"
......
This diff is collapsed.
......@@ -55,9 +55,6 @@ using v8::internal::StackTracer;
using v8::internal::TickSample;
static v8::Persistent<v8::Context> env;
static struct {
TickSample* sample;
} trace_env = { NULL };
......@@ -185,23 +182,13 @@ static TraceExtension kTraceExtension;
v8::DeclareExtension kTraceExtensionDeclaration(&kTraceExtension);
static void InitializeVM() {
if (env.IsEmpty()) {
const char* extensions[] = { "v8/trace" };
v8::ExtensionConfiguration config(1, extensions);
env = v8::Context::New(&config);
}
env->Enter();
}
static bool IsAddressWithinFuncCode(JSFunction* function, Address addr) {
i::Code* code = function->code();
return code->contains(addr);
}
static bool IsAddressWithinFuncCode(const char* func_name, Address addr) {
v8::Local<v8::Value> func = env->Global()->Get(v8_str(func_name));
v8::Local<v8::Value> func = CcTest::env()->Global()->Get(v8_str(func_name));
CHECK(func->IsFunction());
JSFunction* js_func = JSFunction::cast(*v8::Utils::OpenHandle(*func));
return IsAddressWithinFuncCode(js_func, addr);
......@@ -243,7 +230,7 @@ void CreateFramePointerGrabberConstructor(const char* constructor_name) {
v8::FunctionTemplate::New(construct_call);
constructor_template->SetClassName(v8_str("FPGrabber"));
Local<Function> fun = constructor_template->GetFunction();
env->Global()->Set(v8_str(constructor_name), fun);
CcTest::env()->Global()->Set(v8_str(constructor_name), fun);
}
......@@ -280,8 +267,8 @@ TEST(CFromJSStackTrace) {
TickSample sample;
InitTraceEnv(&sample);
InitializeVM();
v8::HandleScope scope(env->GetIsolate());
CcTest::InitializeVM(TRACE_EXTENSION);
v8::HandleScope scope(CcTest::isolate());
// Create global function JSFuncDoTrace which calls
// extension function trace() with the current frame pointer value.
CreateTraceCallerFunction("JSFuncDoTrace", "trace");
......@@ -325,8 +312,8 @@ TEST(PureJSStackTrace) {
TickSample sample;
InitTraceEnv(&sample);
InitializeVM();
v8::HandleScope scope(env->GetIsolate());
CcTest::InitializeVM(TRACE_EXTENSION);
v8::HandleScope scope(CcTest::isolate());
// Create global function JSFuncDoTrace which calls
// extension function js_trace() with the current frame pointer value.
CreateTraceCallerFunction("JSFuncDoTrace", "js_trace");
......@@ -392,15 +379,15 @@ static int CFunc(int depth) {
TEST(PureCStackTrace) {
TickSample sample;
InitTraceEnv(&sample);
InitializeVM();
CcTest::InitializeVM(TRACE_EXTENSION);
// Check that sampler doesn't crash
CHECK_EQ(10, CFunc(10));
}
TEST(JsEntrySp) {
InitializeVM();
v8::HandleScope scope(env->GetIsolate());
CcTest::InitializeVM(TRACE_EXTENSION);
v8::HandleScope scope(CcTest::isolate());
CHECK_EQ(0, GetJsEntrySp());
CompileRun("a = 1; b = a + 1;");
CHECK_EQ(0, GetJsEntrySp());
......
......@@ -43,16 +43,9 @@
using namespace v8::internal;
static v8::Persistent<v8::Context> env;
static void InitializeVM() {
if (env.IsEmpty()) env = v8::Context::New();
env->Enter();
}
TEST(MarkingDeque) {
InitializeVM();
CcTest::InitializeVM();
int mem_size = 20 * kPointerSize;
byte* mem = NewArray<byte>(20*kPointerSize);
Address low = reinterpret_cast<Address>(mem);
......@@ -89,9 +82,9 @@ TEST(Promotion) {
FLAG_always_compact = true;
HEAP->ConfigureHeap(2*256*KB, 8*MB, 8*MB);
InitializeVM();
CcTest::InitializeVM();
v8::HandleScope sc(env->GetIsolate());
v8::HandleScope sc(CcTest::isolate());
// Allocate a fixed array in the new space.
int array_size =
......@@ -117,9 +110,9 @@ TEST(NoPromotion) {
// Test the situation that some objects in new space are promoted to
// the old space
InitializeVM();
CcTest::InitializeVM();
v8::HandleScope sc(env->GetIsolate());
v8::HandleScope sc(CcTest::isolate());
// Do a mark compact GC to shrink the heap.
HEAP->CollectGarbage(OLD_POINTER_SPACE);
......@@ -155,9 +148,9 @@ TEST(NoPromotion) {
TEST(MarkCompactCollector) {
InitializeVM();
CcTest::InitializeVM();
v8::HandleScope sc(env->GetIsolate());
v8::HandleScope sc(CcTest::isolate());
// call mark-compact when heap is empty
HEAP->CollectGarbage(OLD_POINTER_SPACE);
......@@ -248,7 +241,7 @@ static Handle<Map> CreateMap() {
TEST(MapCompact) {
FLAG_max_map_space_pages = 16;
InitializeVM();
CcTest::InitializeVM();
{
v8::HandleScope sc;
......@@ -287,7 +280,7 @@ static void GCEpilogueCallbackFunc() {
TEST(GCCallback) {
InitializeVM();
CcTest::InitializeVM();
HEAP->SetGlobalGCPrologueCallback(&GCPrologueCallbackFunc);
HEAP->SetGlobalGCEpilogueCallback(&GCEpilogueCallbackFunc);
......@@ -315,11 +308,11 @@ static void WeakPointerCallback(v8::Isolate* isolate,
TEST(ObjectGroups) {
FLAG_incremental_marking = false;
InitializeVM();
CcTest::InitializeVM();
GlobalHandles* global_handles = Isolate::Current()->global_handles();
NumberOfWeakCalls = 0;
v8::HandleScope handle_scope(env->GetIsolate());
v8::HandleScope handle_scope(CcTest::isolate());
Handle<Object> g1s1 =
global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked());
......@@ -452,10 +445,10 @@ class TestRetainedObjectInfo : public v8::RetainedObjectInfo {
TEST(EmptyObjectGroups) {
InitializeVM();
CcTest::InitializeVM();
GlobalHandles* global_handles = Isolate::Current()->global_handles();
v8::HandleScope handle_scope(env->GetIsolate());
v8::HandleScope handle_scope(CcTest::isolate());
Handle<Object> object =
global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked());
......@@ -552,7 +545,7 @@ TEST(BootUpMemoryUse) {
// Only Linux has the proc filesystem and only if it is mapped. If it's not
// there we just skip the test.
if (initial_memory >= 0) {
InitializeVM();
CcTest::InitializeVM();
intptr_t delta = MemoryInUse() - initial_memory;
printf("delta: %" V8_PTR_PREFIX "d kB\n", delta / 1024);
if (sizeof(initial_memory) == 8) { // 64-bit.
......
......@@ -95,18 +95,6 @@ class RandomNumberGenerator {
using namespace v8::internal;
static v8::Persistent<v8::Context> env;
static void InitializeVM() {
if (env.IsEmpty()) {
const char* extensions[] = { "v8/print" };
v8::ExtensionConfiguration config(1, extensions);
env = v8::Context::New(&config);
}
env->Enter();
}
static const int DEEP_DEPTH = 8 * 1024;
static const int SUPER_DEEP_DEPTH = 80 * 1024;
......@@ -574,8 +562,8 @@ static void TraverseFirst(Handle<String> s1, Handle<String> s2, int chars) {
TEST(Traverse) {
printf("TestTraverse\n");
InitializeVM();
v8::HandleScope scope(env->GetIsolate());
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
ZoneScope zone(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT);
ConsStringGenerationData data(false);
Handle<String> flat = ConstructBalanced(&data);
......@@ -663,7 +651,7 @@ printf(
template<typename BuildString>
void TestStringCharacterStream(BuildString build, int test_cases) {
InitializeVM();
CcTest::InitializeVM();
Isolate* isolate = Isolate::Current();
HandleScope outer_scope(isolate);
ZoneScope zone(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT);
......@@ -863,8 +851,8 @@ static const int DEEP_ASCII_DEPTH = 100000;
TEST(DeepAscii) {
printf("TestDeepAscii\n");
InitializeVM();
v8::HandleScope scope(env->GetIsolate());
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
char* foo = NewArray<char>(DEEP_ASCII_DEPTH);
for (int i = 0; i < DEEP_ASCII_DEPTH; i++) {
......@@ -888,8 +876,8 @@ TEST(DeepAscii) {
TEST(Utf8Conversion) {
// Smoke test for converting strings to utf-8.
InitializeVM();
v8::HandleScope handle_scope(env->GetIsolate());
CcTest::InitializeVM();
v8::HandleScope handle_scope(CcTest::isolate());
// A simple ascii string
const char* ascii_string = "abcdef12345";
int len =
......@@ -935,8 +923,8 @@ TEST(Utf8Conversion) {
TEST(ExternalShortStringAdd) {
ZoneScope zonescope(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT);
InitializeVM();
v8::HandleScope handle_scope(env->GetIsolate());
CcTest::InitializeVM();
v8::HandleScope handle_scope(CcTest::isolate());
Zone* zone = Isolate::Current()->runtime_zone();
// Make sure we cover all always-flat lengths and at least one above.
......@@ -977,7 +965,7 @@ TEST(ExternalShortStringAdd) {
}
// Add the arrays with the short external strings in the global object.
v8::Handle<v8::Object> global = env->Global();
v8::Handle<v8::Object> global = CcTest::env()->Global();
global->Set(v8_str("external_ascii"), ascii_external_strings);
global->Set(v8_str("external_non_ascii"), non_ascii_external_strings);
global->Set(v8_str("max_length"), v8::Integer::New(kMaxLength));
......@@ -1027,8 +1015,8 @@ TEST(CachedHashOverflow) {
Isolate* isolate = Isolate::Current();
ZoneScope zone(isolate->runtime_zone(), DELETE_ON_EXIT);
InitializeVM();
v8::HandleScope handle_scope(env->GetIsolate());
CcTest::InitializeVM();
v8::HandleScope handle_scope(CcTest::isolate());
// Lines must be executed sequentially. Combining them into one script
// makes the bug go away.
const char* lines[] = {
......@@ -1070,8 +1058,8 @@ TEST(CachedHashOverflow) {
TEST(SliceFromCons) {
FLAG_string_slices = true;
InitializeVM();
v8::HandleScope scope(env->GetIsolate());
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
Handle<String> string =
FACTORY->NewStringFromAscii(CStrVector("parentparentparent"));
Handle<String> parent = FACTORY->NewConsString(string, string);
......@@ -1104,8 +1092,8 @@ class AsciiVectorResource : public v8::String::ExternalAsciiStringResource {
TEST(SliceFromExternal) {
FLAG_string_slices = true;
InitializeVM();
v8::HandleScope scope(env->GetIsolate());
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
AsciiVectorResource resource(
i::Vector<const char>("abcdefghijklmnopqrstuvwxyz", 26));
Handle<String> string = FACTORY->NewExternalStringFromAscii(&resource);
......@@ -1123,8 +1111,8 @@ TEST(TrivialSlice) {
// This tests whether a slice that contains the entire parent string
// actually creates a new string (it should not).
FLAG_string_slices = true;
InitializeVM();
v8::HandleScope scope(env->GetIsolate());
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Value> result;
Handle<String> string;
const char* init = "var str = 'abcdefghijklmnopqrstuvwxyz';";
......@@ -1152,8 +1140,8 @@ TEST(SliceFromSlice) {
// This tests whether a slice that contains the entire parent string
// actually creates a new string (it should not).
FLAG_string_slices = true;
InitializeVM();
v8::HandleScope scope(env->GetIsolate());
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Value> result;
Handle<String> string;
const char* init = "var str = 'abcdefghijklmnopqrstuvwxyz';";
......@@ -1220,8 +1208,8 @@ TEST(RobustSubStringStub) {
// This tests whether the SubStringStub can handle unsafe arguments.
// If not recognized, those unsafe arguments lead to out-of-bounds reads.
FLAG_allow_natives_syntax = true;
InitializeVM();
v8::HandleScope scope(env->GetIsolate());
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Value> result;
Handle<String> string;
CompileRun("var short = 'abcdef';");
......@@ -1264,8 +1252,8 @@ TEST(RobustSubStringStub) {
TEST(RegExpOverflow) {
// Result string has the length 2^32, causing a 32-bit integer overflow.
InitializeVM();
v8::HandleScope scope(env->GetIsolate());
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
LocalContext context;
v8::V8::IgnoreOutOfMemoryException();
v8::Local<v8::Value> result = CompileRun(
......@@ -1280,8 +1268,8 @@ TEST(RegExpOverflow) {
TEST(StringReplaceAtomTwoByteResult) {
InitializeVM();
v8::HandleScope scope(env->GetIsolate());
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
LocalContext context;
v8::Local<v8::Value> result = CompileRun(
"var subject = 'ascii~only~string~'; "
......
......@@ -12,20 +12,9 @@
using namespace v8::internal;
static v8::Persistent<v8::Context> env;
static void InitializeVM() {
if (env.IsEmpty()) {
const char* extensions[] = { "v8/print" };
v8::ExtensionConfiguration config(1, extensions);
env = v8::Context::New(&config);
}
env->Enter();
}
TEST(Create) {
InitializeVM();
CcTest::InitializeVM();
Isolate* isolate = Isolate::Current();
HandleScope scope(isolate);
......
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