Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(936)

Unified Diff: test/cctest/test-cpu-profiler.cc

Issue 83343002: Remove usage of deprecated APIs from cctests (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/cctest/test-compiler.cc ('k') | test/cctest/test-debug.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-cpu-profiler.cc
diff --git a/test/cctest/test-cpu-profiler.cc b/test/cctest/test-cpu-profiler.cc
index 33444ead8f25c3aa862ace864ccbfa06b3f8d4b9..c847afcc2708a0f4dec257759b35483edb464968 100644
--- a/test/cctest/test-cpu-profiler.cc
+++ b/test/cctest/test-cpu-profiler.cc
@@ -355,7 +355,7 @@ TEST(DeleteCpuProfile) {
v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
CHECK_EQ(0, cpu_profiler->GetProfileCount());
- v8::Local<v8::String> name1 = v8::String::New("1");
+ v8::Local<v8::String> name1 = v8::String::NewFromUtf8(env->GetIsolate(), "1");
cpu_profiler->StartCpuProfiling(name1);
const v8::CpuProfile* p1 = cpu_profiler->StopCpuProfiling(name1);
CHECK_NE(NULL, p1);
@@ -366,7 +366,7 @@ TEST(DeleteCpuProfile) {
CHECK_EQ(0, cpu_profiler->GetProfileCount());
CHECK_EQ(NULL, FindCpuProfile(cpu_profiler, uid1));
- v8::Local<v8::String> name2 = v8::String::New("2");
+ v8::Local<v8::String> name2 = v8::String::NewFromUtf8(env->GetIsolate(), "2");
cpu_profiler->StartCpuProfiling(name2);
const v8::CpuProfile* p2 = cpu_profiler->StopCpuProfiling(name2);
CHECK_NE(NULL, p2);
@@ -375,7 +375,7 @@ TEST(DeleteCpuProfile) {
CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid2));
CHECK_EQ(p2, FindCpuProfile(cpu_profiler, uid2));
CHECK_EQ(NULL, FindCpuProfile(cpu_profiler, uid1));
- v8::Local<v8::String> name3 = v8::String::New("3");
+ v8::Local<v8::String> name3 = v8::String::NewFromUtf8(env->GetIsolate(), "3");
cpu_profiler->StartCpuProfiling(name3);
const v8::CpuProfile* p3 = cpu_profiler->StopCpuProfiling(name3);
CHECK_NE(NULL, p3);
@@ -401,7 +401,8 @@ TEST(ProfileStartEndTime) {
v8::HandleScope scope(env->GetIsolate());
v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
- v8::Local<v8::String> profile_name = v8::String::New("test");
+ v8::Local<v8::String> profile_name =
+ v8::String::NewFromUtf8(env->GetIsolate(), "test");
cpu_profiler->StartCpuProfiling(profile_name);
const v8::CpuProfile* profile = cpu_profiler->StopCpuProfiling(profile_name);
CHECK(profile->GetStartTime() <= profile->GetEndTime());
@@ -413,7 +414,8 @@ static const v8::CpuProfile* RunProfiler(
v8::Handle<v8::Value> argv[], int argc,
unsigned min_js_samples) {
v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
- v8::Local<v8::String> profile_name = v8::String::New("my_profile");
+ v8::Local<v8::String> profile_name =
+ v8::String::NewFromUtf8(env->GetIsolate(), "my_profile");
cpu_profiler->StartCpuProfiling(profile_name);
@@ -460,10 +462,11 @@ static void CheckChildrenNames(const v8::CpuProfileNode* node,
}
-static const v8::CpuProfileNode* FindChild(const v8::CpuProfileNode* node,
+static const v8::CpuProfileNode* FindChild(v8::Isolate* isolate,
+ const v8::CpuProfileNode* node,
const char* name) {
int count = node->GetChildrenCount();
- v8::Handle<v8::String> nameHandle = v8::String::New(name);
+ v8::Handle<v8::String> nameHandle = v8::String::NewFromUtf8(isolate, name);
for (int i = 0; i < count; i++) {
const v8::CpuProfileNode* child = node->GetChild(i);
if (nameHandle->Equals(child->GetFunctionName())) return child;
@@ -472,9 +475,10 @@ static const v8::CpuProfileNode* FindChild(const v8::CpuProfileNode* node,
}
-static const v8::CpuProfileNode* GetChild(const v8::CpuProfileNode* node,
+static const v8::CpuProfileNode* GetChild(v8::Isolate* isolate,
+ const v8::CpuProfileNode* node,
const char* name) {
- const v8::CpuProfileNode* result = FindChild(node, name);
+ const v8::CpuProfileNode* result = FindChild(isolate, node, name);
if (!result) {
char buffer[100];
i::OS::SNPrintF(Vector<char>(buffer, ARRAY_SIZE(buffer)),
@@ -485,11 +489,12 @@ static const v8::CpuProfileNode* GetChild(const v8::CpuProfileNode* node,
}
-static void CheckSimpleBranch(const v8::CpuProfileNode* node,
+static void CheckSimpleBranch(v8::Isolate* isolate,
+ const v8::CpuProfileNode* node,
const char* names[], int length) {
for (int i = 0; i < length; i++) {
const char* name = names[i];
- node = GetChild(node, name);
+ node = GetChild(isolate, node, name);
int expectedChildrenCount = (i == length - 1) ? 0 : 1;
CHECK_EQ(expectedChildrenCount, node->GetChildrenCount());
}
@@ -549,9 +554,10 @@ TEST(CollectCpuProfile) {
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
- v8::Script::Compile(v8::String::New(cpu_profiler_test_source))->Run();
+ v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(),
+ cpu_profiler_test_source))->Run();
v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::New("start")));
+ env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start")));
int32_t profiling_interval_ms = 200;
v8::Handle<v8::Value> args[] = { v8::Integer::New(profiling_interval_ms) };
@@ -562,23 +568,30 @@ TEST(CollectCpuProfile) {
const v8::CpuProfileNode* root = profile->GetTopDownRoot();
ScopedVector<v8::Handle<v8::String> > names(3);
- names[0] = v8::String::New(ProfileGenerator::kGarbageCollectorEntryName);
- names[1] = v8::String::New(ProfileGenerator::kProgramEntryName);
- names[2] = v8::String::New("start");
+ names[0] = v8::String::NewFromUtf8(
+ env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName);
+ names[1] = v8::String::NewFromUtf8(env->GetIsolate(),
+ ProfileGenerator::kProgramEntryName);
+ names[2] = v8::String::NewFromUtf8(env->GetIsolate(), "start");
CheckChildrenNames(root, names);
- const v8::CpuProfileNode* startNode = GetChild(root, "start");
+ const v8::CpuProfileNode* startNode =
+ GetChild(env->GetIsolate(), root, "start");
CHECK_EQ(1, startNode->GetChildrenCount());
- const v8::CpuProfileNode* fooNode = GetChild(startNode, "foo");
+ const v8::CpuProfileNode* fooNode =
+ GetChild(env->GetIsolate(), startNode, "foo");
CHECK_EQ(3, fooNode->GetChildrenCount());
const char* barBranch[] = { "bar", "delay", "loop" };
- CheckSimpleBranch(fooNode, barBranch, ARRAY_SIZE(barBranch));
+ CheckSimpleBranch(env->GetIsolate(), fooNode, barBranch,
+ ARRAY_SIZE(barBranch));
const char* bazBranch[] = { "baz", "delay", "loop" };
- CheckSimpleBranch(fooNode, bazBranch, ARRAY_SIZE(bazBranch));
+ CheckSimpleBranch(env->GetIsolate(), fooNode, bazBranch,
+ ARRAY_SIZE(bazBranch));
const char* delayBranch[] = { "delay", "loop" };
- CheckSimpleBranch(fooNode, delayBranch, ARRAY_SIZE(delayBranch));
+ CheckSimpleBranch(env->GetIsolate(), fooNode, delayBranch,
+ ARRAY_SIZE(delayBranch));
v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
cpu_profiler->DeleteAllCpuProfiles();
@@ -610,9 +623,10 @@ TEST(SampleWhenFrameIsNotSetup) {
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
- v8::Script::Compile(v8::String::New(cpu_profiler_test_source2))->Run();
+ v8::Script::Compile(v8::String::NewFromUtf8(
+ env->GetIsolate(), cpu_profiler_test_source2))->Run();
v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::New("start")));
+ env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start")));
int32_t repeat_count = 100;
#if defined(USE_SIMULATOR)
@@ -626,20 +640,24 @@ TEST(SampleWhenFrameIsNotSetup) {
const v8::CpuProfileNode* root = profile->GetTopDownRoot();
ScopedVector<v8::Handle<v8::String> > names(3);
- names[0] = v8::String::New(ProfileGenerator::kGarbageCollectorEntryName);
- names[1] = v8::String::New(ProfileGenerator::kProgramEntryName);
- names[2] = v8::String::New("start");
+ names[0] = v8::String::NewFromUtf8(
+ env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName);
+ names[1] = v8::String::NewFromUtf8(env->GetIsolate(),
+ ProfileGenerator::kProgramEntryName);
+ names[2] = v8::String::NewFromUtf8(env->GetIsolate(), "start");
CheckChildrenNames(root, names);
- const v8::CpuProfileNode* startNode = FindChild(root, "start");
+ const v8::CpuProfileNode* startNode =
+ FindChild(env->GetIsolate(), root, "start");
// On slow machines there may be no meaningfull samples at all, skip the
// check there.
if (startNode && startNode->GetChildrenCount() > 0) {
CHECK_EQ(1, startNode->GetChildrenCount());
- const v8::CpuProfileNode* delayNode = GetChild(startNode, "delay");
+ const v8::CpuProfileNode* delayNode =
+ GetChild(env->GetIsolate(), startNode, "delay");
if (delayNode->GetChildrenCount() > 0) {
CHECK_EQ(1, delayNode->GetChildrenCount());
- GetChild(delayNode, "loop");
+ GetChild(env->GetIsolate(), delayNode, "loop");
}
}
@@ -721,15 +739,18 @@ TEST(NativeAccessorUninitializedIC) {
v8::Local<v8::External> data =
v8::External::New(env->GetIsolate(), &accessors);
instance_template->SetAccessor(
- v8::String::New("foo"), &TestApiCallbacks::Getter,
- &TestApiCallbacks::Setter, data);
+ v8::String::NewFromUtf8(env->GetIsolate(), "foo"),
+ &TestApiCallbacks::Getter, &TestApiCallbacks::Setter, data);
v8::Local<v8::Function> func = func_template->GetFunction();
v8::Local<v8::Object> instance = func->NewInstance();
- env->Global()->Set(v8::String::New("instance"), instance);
+ env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "instance"),
+ instance);
- v8::Script::Compile(v8::String::New(native_accessor_test_source))->Run();
+ v8::Script::Compile(
+ v8::String::NewFromUtf8(env->GetIsolate(), native_accessor_test_source))
+ ->Run();
v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::New("start")));
+ env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start")));
int32_t repeat_count = 1;
v8::Handle<v8::Value> args[] = { v8::Integer::New(repeat_count) };
@@ -737,9 +758,10 @@ TEST(NativeAccessorUninitializedIC) {
RunProfiler(env, function, args, ARRAY_SIZE(args), 180);
const v8::CpuProfileNode* root = profile->GetTopDownRoot();
- const v8::CpuProfileNode* startNode = GetChild(root, "start");
- GetChild(startNode, "get foo");
- GetChild(startNode, "set foo");
+ const v8::CpuProfileNode* startNode =
+ GetChild(env->GetIsolate(), root, "start");
+ GetChild(env->GetIsolate(), startNode, "get foo");
+ GetChild(env->GetIsolate(), startNode, "set foo");
v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
cpu_profiler->DeleteAllCpuProfiles();
@@ -762,15 +784,18 @@ TEST(NativeAccessorMonomorphicIC) {
v8::Local<v8::External> data =
v8::External::New(env->GetIsolate(), &accessors);
instance_template->SetAccessor(
- v8::String::New("foo"), &TestApiCallbacks::Getter,
- &TestApiCallbacks::Setter, data);
+ v8::String::NewFromUtf8(env->GetIsolate(), "foo"),
+ &TestApiCallbacks::Getter, &TestApiCallbacks::Setter, data);
v8::Local<v8::Function> func = func_template->GetFunction();
v8::Local<v8::Object> instance = func->NewInstance();
- env->Global()->Set(v8::String::New("instance"), instance);
+ env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "instance"),
+ instance);
- v8::Script::Compile(v8::String::New(native_accessor_test_source))->Run();
+ v8::Script::Compile(
+ v8::String::NewFromUtf8(env->GetIsolate(), native_accessor_test_source))
+ ->Run();
v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::New("start")));
+ env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start")));
{
// Make sure accessors ICs are in monomorphic state before starting
@@ -788,9 +813,10 @@ TEST(NativeAccessorMonomorphicIC) {
RunProfiler(env, function, args, ARRAY_SIZE(args), 200);
const v8::CpuProfileNode* root = profile->GetTopDownRoot();
- const v8::CpuProfileNode* startNode = GetChild(root, "start");
- GetChild(startNode, "get foo");
- GetChild(startNode, "set foo");
+ const v8::CpuProfileNode* startNode =
+ GetChild(env->GetIsolate(), root, "start");
+ GetChild(env->GetIsolate(), startNode, "get foo");
+ GetChild(env->GetIsolate(), startNode, "set foo");
v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
cpu_profiler->DeleteAllCpuProfiles();
@@ -813,20 +839,24 @@ TEST(NativeMethodUninitializedIC) {
v8::External::New(env->GetIsolate(), &callbacks);
v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New();
- func_template->SetClassName(v8::String::New("Test_InstanceCostructor"));
+ func_template->SetClassName(
+ v8::String::NewFromUtf8(env->GetIsolate(), "Test_InstanceCostructor"));
v8::Local<v8::ObjectTemplate> proto_template =
func_template->PrototypeTemplate();
v8::Local<v8::Signature> signature = v8::Signature::New(func_template);
- proto_template->Set(v8::String::New("fooMethod"), v8::FunctionTemplate::New(
- &TestApiCallbacks::Callback, data, signature, 0));
+ proto_template->Set(v8::String::NewFromUtf8(env->GetIsolate(), "fooMethod"),
+ v8::FunctionTemplate::New(&TestApiCallbacks::Callback,
+ data, signature, 0));
v8::Local<v8::Function> func = func_template->GetFunction();
v8::Local<v8::Object> instance = func->NewInstance();
- env->Global()->Set(v8::String::New("instance"), instance);
+ env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "instance"),
+ instance);
- v8::Script::Compile(v8::String::New(native_method_test_source))->Run();
+ v8::Script::Compile(v8::String::NewFromUtf8(
+ env->GetIsolate(), native_method_test_source))->Run();
v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::New("start")));
+ env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start")));
int32_t repeat_count = 1;
v8::Handle<v8::Value> args[] = { v8::Integer::New(repeat_count) };
@@ -834,8 +864,9 @@ TEST(NativeMethodUninitializedIC) {
RunProfiler(env, function, args, ARRAY_SIZE(args), 100);
const v8::CpuProfileNode* root = profile->GetTopDownRoot();
- const v8::CpuProfileNode* startNode = GetChild(root, "start");
- GetChild(startNode, "fooMethod");
+ const v8::CpuProfileNode* startNode =
+ GetChild(env->GetIsolate(), root, "start");
+ GetChild(env->GetIsolate(), startNode, "fooMethod");
v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
cpu_profiler->DeleteAllCpuProfiles();
@@ -851,20 +882,24 @@ TEST(NativeMethodMonomorphicIC) {
v8::External::New(env->GetIsolate(), &callbacks);
v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New();
- func_template->SetClassName(v8::String::New("Test_InstanceCostructor"));
+ func_template->SetClassName(
+ v8::String::NewFromUtf8(env->GetIsolate(), "Test_InstanceCostructor"));
v8::Local<v8::ObjectTemplate> proto_template =
func_template->PrototypeTemplate();
v8::Local<v8::Signature> signature = v8::Signature::New(func_template);
- proto_template->Set(v8::String::New("fooMethod"), v8::FunctionTemplate::New(
- &TestApiCallbacks::Callback, data, signature, 0));
+ proto_template->Set(v8::String::NewFromUtf8(env->GetIsolate(), "fooMethod"),
+ v8::FunctionTemplate::New(&TestApiCallbacks::Callback,
+ data, signature, 0));
v8::Local<v8::Function> func = func_template->GetFunction();
v8::Local<v8::Object> instance = func->NewInstance();
- env->Global()->Set(v8::String::New("instance"), instance);
+ env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "instance"),
+ instance);
- v8::Script::Compile(v8::String::New(native_method_test_source))->Run();
+ v8::Script::Compile(v8::String::NewFromUtf8(
+ env->GetIsolate(), native_method_test_source))->Run();
v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::New("start")));
+ env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start")));
{
// Make sure method ICs are in monomorphic state before starting
// profiling.
@@ -881,9 +916,10 @@ TEST(NativeMethodMonomorphicIC) {
RunProfiler(env, function, args, ARRAY_SIZE(args), 100);
const v8::CpuProfileNode* root = profile->GetTopDownRoot();
- GetChild(root, "start");
- const v8::CpuProfileNode* startNode = GetChild(root, "start");
- GetChild(startNode, "fooMethod");
+ GetChild(env->GetIsolate(), root, "start");
+ const v8::CpuProfileNode* startNode =
+ GetChild(env->GetIsolate(), root, "start");
+ GetChild(env->GetIsolate(), startNode, "fooMethod");
v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
cpu_profiler->DeleteAllCpuProfiles();
@@ -908,9 +944,11 @@ TEST(BoundFunctionCall) {
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
- v8::Script::Compile(v8::String::New(bound_function_test_source))->Run();
+ v8::Script::Compile(
+ v8::String::NewFromUtf8(env->GetIsolate(), bound_function_test_source))
+ ->Run();
v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::New("start")));
+ env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start")));
int32_t duration_ms = 100;
v8::Handle<v8::Value> args[] = { v8::Integer::New(duration_ms) };
@@ -919,14 +957,17 @@ TEST(BoundFunctionCall) {
const v8::CpuProfileNode* root = profile->GetTopDownRoot();
ScopedVector<v8::Handle<v8::String> > names(3);
- names[0] = v8::String::New(ProfileGenerator::kGarbageCollectorEntryName);
- names[1] = v8::String::New(ProfileGenerator::kProgramEntryName);
- names[2] = v8::String::New("start");
+ names[0] = v8::String::NewFromUtf8(
+ env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName);
+ names[1] = v8::String::NewFromUtf8(env->GetIsolate(),
+ ProfileGenerator::kProgramEntryName);
+ names[2] = v8::String::NewFromUtf8(env->GetIsolate(), "start");
// Don't allow |foo| node to be at the top level.
CheckChildrenNames(root, names);
- const v8::CpuProfileNode* startNode = GetChild(root, "start");
- GetChild(startNode, "foo");
+ const v8::CpuProfileNode* startNode =
+ GetChild(env->GetIsolate(), root, "start");
+ GetChild(env->GetIsolate(), startNode, "foo");
v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
cpu_profiler->DeleteAllCpuProfiles();
@@ -964,9 +1005,10 @@ TEST(FunctionCallSample) {
// Collect garbage that might have be generated while installing extensions.
CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
- v8::Script::Compile(v8::String::New(call_function_test_source))->Run();
+ v8::Script::Compile(v8::String::NewFromUtf8(
+ env->GetIsolate(), call_function_test_source))->Run();
v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::New("start")));
+ env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start")));
int32_t duration_ms = 100;
v8::Handle<v8::Value> args[] = { v8::Integer::New(duration_ms) };
@@ -976,10 +1018,13 @@ TEST(FunctionCallSample) {
const v8::CpuProfileNode* root = profile->GetTopDownRoot();
{
ScopedVector<v8::Handle<v8::String> > names(4);
- names[0] = v8::String::New(ProfileGenerator::kGarbageCollectorEntryName);
- names[1] = v8::String::New(ProfileGenerator::kProgramEntryName);
- names[2] = v8::String::New("start");
- names[3] = v8::String::New(i::ProfileGenerator::kUnresolvedFunctionName);
+ names[0] = v8::String::NewFromUtf8(
+ env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName);
+ names[1] = v8::String::NewFromUtf8(env->GetIsolate(),
+ ProfileGenerator::kProgramEntryName);
+ names[2] = v8::String::NewFromUtf8(env->GetIsolate(), "start");
+ names[3] = v8::String::NewFromUtf8(
+ env->GetIsolate(), i::ProfileGenerator::kUnresolvedFunctionName);
// Don't allow |bar| and |call| nodes to be at the top level.
CheckChildrenNames(root, names);
}
@@ -988,20 +1033,21 @@ TEST(FunctionCallSample) {
// won't be |start| node in the profiles.
bool is_gc_stress_testing =
(i::FLAG_gc_interval != -1) || i::FLAG_stress_compaction;
- const v8::CpuProfileNode* startNode = FindChild(root, "start");
+ const v8::CpuProfileNode* startNode =
+ FindChild(env->GetIsolate(), root, "start");
CHECK(is_gc_stress_testing || startNode);
if (startNode) {
ScopedVector<v8::Handle<v8::String> > names(2);
- names[0] = v8::String::New("bar");
- names[1] = v8::String::New("call");
+ names[0] = v8::String::NewFromUtf8(env->GetIsolate(), "bar");
+ names[1] = v8::String::NewFromUtf8(env->GetIsolate(), "call");
CheckChildrenNames(startNode, names);
}
- const v8::CpuProfileNode* unresolvedNode =
- FindChild(root, i::ProfileGenerator::kUnresolvedFunctionName);
+ const v8::CpuProfileNode* unresolvedNode = FindChild(
+ env->GetIsolate(), root, i::ProfileGenerator::kUnresolvedFunctionName);
if (unresolvedNode) {
ScopedVector<v8::Handle<v8::String> > names(1);
- names[0] = v8::String::New("call");
+ names[0] = v8::String::NewFromUtf8(env->GetIsolate(), "call");
CheckChildrenNames(unresolvedNode, names);
}
@@ -1039,9 +1085,11 @@ TEST(FunctionApplySample) {
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
- v8::Script::Compile(v8::String::New(function_apply_test_source))->Run();
+ v8::Script::Compile(
+ v8::String::NewFromUtf8(env->GetIsolate(), function_apply_test_source))
+ ->Run();
v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::New("start")));
+ env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start")));
int32_t duration_ms = 100;
v8::Handle<v8::Value> args[] = { v8::Integer::New(duration_ms) };
@@ -1052,36 +1100,42 @@ TEST(FunctionApplySample) {
const v8::CpuProfileNode* root = profile->GetTopDownRoot();
{
ScopedVector<v8::Handle<v8::String> > names(3);
- names[0] = v8::String::New(ProfileGenerator::kGarbageCollectorEntryName);
- names[1] = v8::String::New(ProfileGenerator::kProgramEntryName);
- names[2] = v8::String::New("start");
+ names[0] = v8::String::NewFromUtf8(
+ env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName);
+ names[1] = v8::String::NewFromUtf8(env->GetIsolate(),
+ ProfileGenerator::kProgramEntryName);
+ names[2] = v8::String::NewFromUtf8(env->GetIsolate(), "start");
// Don't allow |test|, |bar| and |apply| nodes to be at the top level.
CheckChildrenNames(root, names);
}
- const v8::CpuProfileNode* startNode = FindChild(root, "start");
+ const v8::CpuProfileNode* startNode =
+ FindChild(env->GetIsolate(), root, "start");
if (startNode) {
{
ScopedVector<v8::Handle<v8::String> > names(2);
- names[0] = v8::String::New("test");
- names[1] = v8::String::New(ProfileGenerator::kUnresolvedFunctionName);
+ names[0] = v8::String::NewFromUtf8(env->GetIsolate(), "test");
+ names[1] = v8::String::NewFromUtf8(
+ env->GetIsolate(), ProfileGenerator::kUnresolvedFunctionName);
CheckChildrenNames(startNode, names);
}
- const v8::CpuProfileNode* testNode = FindChild(startNode, "test");
+ const v8::CpuProfileNode* testNode =
+ FindChild(env->GetIsolate(), startNode, "test");
if (testNode) {
ScopedVector<v8::Handle<v8::String> > names(2);
- names[0] = v8::String::New("bar");
- names[1] = v8::String::New("apply");
+ names[0] = v8::String::NewFromUtf8(env->GetIsolate(), "bar");
+ names[1] = v8::String::NewFromUtf8(env->GetIsolate(), "apply");
CheckChildrenNames(testNode, names);
}
if (const v8::CpuProfileNode* unresolvedNode =
- FindChild(startNode, ProfileGenerator::kUnresolvedFunctionName)) {
+ FindChild(env->GetIsolate(), startNode,
+ ProfileGenerator::kUnresolvedFunctionName)) {
ScopedVector<v8::Handle<v8::String> > names(1);
- names[0] = v8::String::New("apply");
+ names[0] = v8::String::NewFromUtf8(env->GetIsolate(), "apply");
CheckChildrenNames(unresolvedNode, names);
- GetChild(unresolvedNode, "apply");
+ GetChild(env->GetIsolate(), unresolvedNode, "apply");
}
}
@@ -1136,12 +1190,14 @@ TEST(JsNativeJsSample) {
v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New(
CallJsFunction);
v8::Local<v8::Function> func = func_template->GetFunction();
- func->SetName(v8::String::New("CallJsFunction"));
- env->Global()->Set(v8::String::New("CallJsFunction"), func);
+ func->SetName(v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction"));
+ env->Global()->Set(
+ v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction"), func);
- v8::Script::Compile(v8::String::New(js_native_js_test_source))->Run();
+ v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(),
+ js_native_js_test_source))->Run();
v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::New("start")));
+ env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start")));
int32_t duration_ms = 20;
v8::Handle<v8::Value> args[] = { v8::Integer::New(duration_ms) };
@@ -1151,22 +1207,26 @@ TEST(JsNativeJsSample) {
const v8::CpuProfileNode* root = profile->GetTopDownRoot();
{
ScopedVector<v8::Handle<v8::String> > names(3);
- names[0] = v8::String::New(ProfileGenerator::kGarbageCollectorEntryName);
- names[1] = v8::String::New(ProfileGenerator::kProgramEntryName);
- names[2] = v8::String::New("start");
+ names[0] = v8::String::NewFromUtf8(
+ env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName);
+ names[1] = v8::String::NewFromUtf8(env->GetIsolate(),
+ ProfileGenerator::kProgramEntryName);
+ names[2] = v8::String::NewFromUtf8(env->GetIsolate(), "start");
CheckChildrenNames(root, names);
}
- const v8::CpuProfileNode* startNode = GetChild(root, "start");
+ const v8::CpuProfileNode* startNode =
+ GetChild(env->GetIsolate(), root, "start");
CHECK_EQ(1, startNode->GetChildrenCount());
const v8::CpuProfileNode* nativeFunctionNode =
- GetChild(startNode, "CallJsFunction");
+ GetChild(env->GetIsolate(), startNode, "CallJsFunction");
CHECK_EQ(1, nativeFunctionNode->GetChildrenCount());
- const v8::CpuProfileNode* barNode = GetChild(nativeFunctionNode, "bar");
+ const v8::CpuProfileNode* barNode =
+ GetChild(env->GetIsolate(), nativeFunctionNode, "bar");
CHECK_EQ(1, barNode->GetChildrenCount());
- GetChild(barNode, "foo");
+ GetChild(env->GetIsolate(), barNode, "foo");
v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
cpu_profiler->DeleteAllCpuProfiles();
@@ -1214,13 +1274,15 @@ TEST(JsNativeJsRuntimeJsSample) {
v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New(
CallJsFunction);
v8::Local<v8::Function> func = func_template->GetFunction();
- func->SetName(v8::String::New("CallJsFunction"));
- env->Global()->Set(v8::String::New("CallJsFunction"), func);
+ func->SetName(v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction"));
+ env->Global()->Set(
+ v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction"), func);
- v8::Script::Compile(v8::String::New(js_native_js_runtime_js_test_source))->
- Run();
+ v8::Script::Compile(
+ v8::String::NewFromUtf8(env->GetIsolate(),
+ js_native_js_runtime_js_test_source))->Run();
v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::New("start")));
+ env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start")));
int32_t duration_ms = 20;
v8::Handle<v8::Value> args[] = { v8::Integer::New(duration_ms) };
@@ -1229,21 +1291,25 @@ TEST(JsNativeJsRuntimeJsSample) {
const v8::CpuProfileNode* root = profile->GetTopDownRoot();
ScopedVector<v8::Handle<v8::String> > names(3);
- names[0] = v8::String::New(ProfileGenerator::kGarbageCollectorEntryName);
- names[1] = v8::String::New(ProfileGenerator::kProgramEntryName);
- names[2] = v8::String::New("start");
+ names[0] = v8::String::NewFromUtf8(
+ env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName);
+ names[1] = v8::String::NewFromUtf8(env->GetIsolate(),
+ ProfileGenerator::kProgramEntryName);
+ names[2] = v8::String::NewFromUtf8(env->GetIsolate(), "start");
CheckChildrenNames(root, names);
- const v8::CpuProfileNode* startNode = GetChild(root, "start");
+ const v8::CpuProfileNode* startNode =
+ GetChild(env->GetIsolate(), root, "start");
CHECK_EQ(1, startNode->GetChildrenCount());
const v8::CpuProfileNode* nativeFunctionNode =
- GetChild(startNode, "CallJsFunction");
+ GetChild(env->GetIsolate(), startNode, "CallJsFunction");
CHECK_EQ(1, nativeFunctionNode->GetChildrenCount());
- const v8::CpuProfileNode* barNode = GetChild(nativeFunctionNode, "bar");
+ const v8::CpuProfileNode* barNode =
+ GetChild(env->GetIsolate(), nativeFunctionNode, "bar");
CHECK_EQ(1, barNode->GetChildrenCount());
- GetChild(barNode, "foo");
+ GetChild(env->GetIsolate(), barNode, "foo");
v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
cpu_profiler->DeleteAllCpuProfiles();
@@ -1296,18 +1362,21 @@ TEST(JsNative1JsNative2JsSample) {
v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New(
CallJsFunction);
v8::Local<v8::Function> func1 = func_template->GetFunction();
- func1->SetName(v8::String::New("CallJsFunction1"));
- env->Global()->Set(v8::String::New("CallJsFunction1"), func1);
+ func1->SetName(v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction1"));
+ env->Global()->Set(
+ v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction1"), func1);
v8::Local<v8::Function> func2 = v8::FunctionTemplate::New(
CallJsFunction2)->GetFunction();
- func2->SetName(v8::String::New("CallJsFunction2"));
- env->Global()->Set(v8::String::New("CallJsFunction2"), func2);
+ func2->SetName(v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction2"));
+ env->Global()->Set(
+ v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction2"), func2);
- v8::Script::Compile(v8::String::New(js_native1_js_native2_js_test_source))->
- Run();
+ v8::Script::Compile(
+ v8::String::NewFromUtf8(env->GetIsolate(),
+ js_native1_js_native2_js_test_source))->Run();
v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(
- env->Global()->Get(v8::String::New("start")));
+ env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start")));
int32_t duration_ms = 20;
v8::Handle<v8::Value> args[] = { v8::Integer::New(duration_ms) };
@@ -1316,24 +1385,29 @@ TEST(JsNative1JsNative2JsSample) {
const v8::CpuProfileNode* root = profile->GetTopDownRoot();
ScopedVector<v8::Handle<v8::String> > names(3);
- names[0] = v8::String::New(ProfileGenerator::kGarbageCollectorEntryName);
- names[1] = v8::String::New(ProfileGenerator::kProgramEntryName);
- names[2] = v8::String::New("start");
+ names[0] = v8::String::NewFromUtf8(
+ env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName);
+ names[1] = v8::String::NewFromUtf8(env->GetIsolate(),
+ ProfileGenerator::kProgramEntryName);
+ names[2] = v8::String::NewFromUtf8(env->GetIsolate(), "start");
CheckChildrenNames(root, names);
- const v8::CpuProfileNode* startNode = GetChild(root, "start");
+ const v8::CpuProfileNode* startNode =
+ GetChild(env->GetIsolate(), root, "start");
CHECK_EQ(1, startNode->GetChildrenCount());
const v8::CpuProfileNode* nativeNode1 =
- GetChild(startNode, "CallJsFunction1");
+ GetChild(env->GetIsolate(), startNode, "CallJsFunction1");
CHECK_EQ(1, nativeNode1->GetChildrenCount());
- const v8::CpuProfileNode* barNode = GetChild(nativeNode1, "bar");
+ const v8::CpuProfileNode* barNode =
+ GetChild(env->GetIsolate(), nativeNode1, "bar");
CHECK_EQ(1, barNode->GetChildrenCount());
- const v8::CpuProfileNode* nativeNode2 = GetChild(barNode, "CallJsFunction2");
+ const v8::CpuProfileNode* nativeNode2 =
+ GetChild(env->GetIsolate(), barNode, "CallJsFunction2");
CHECK_EQ(1, nativeNode2->GetChildrenCount());
- GetChild(nativeNode2, "foo");
+ GetChild(env->GetIsolate(), nativeNode2, "foo");
v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
cpu_profiler->DeleteAllCpuProfiles();
@@ -1349,7 +1423,8 @@ TEST(IdleTime) {
v8::HandleScope scope(env->GetIsolate());
v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
- v8::Local<v8::String> profile_name = v8::String::New("my_profile");
+ v8::Local<v8::String> profile_name =
+ v8::String::NewFromUtf8(env->GetIsolate(), "my_profile");
cpu_profiler->StartCpuProfiling(profile_name);
i::Isolate* isolate = CcTest::i_isolate();
@@ -1374,18 +1449,21 @@ TEST(IdleTime) {
const v8::CpuProfileNode* root = profile->GetTopDownRoot();
ScopedVector<v8::Handle<v8::String> > names(3);
- names[0] = v8::String::New(ProfileGenerator::kGarbageCollectorEntryName);
- names[1] = v8::String::New(ProfileGenerator::kProgramEntryName);
- names[2] = v8::String::New(ProfileGenerator::kIdleEntryName);
+ names[0] = v8::String::NewFromUtf8(
+ env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName);
+ names[1] = v8::String::NewFromUtf8(env->GetIsolate(),
+ ProfileGenerator::kProgramEntryName);
+ names[2] = v8::String::NewFromUtf8(env->GetIsolate(),
+ ProfileGenerator::kIdleEntryName);
CheckChildrenNames(root, names);
const v8::CpuProfileNode* programNode =
- GetChild(root, ProfileGenerator::kProgramEntryName);
+ GetChild(env->GetIsolate(), root, ProfileGenerator::kProgramEntryName);
CHECK_EQ(0, programNode->GetChildrenCount());
CHECK_GE(programNode->GetHitCount(), 3);
const v8::CpuProfileNode* idleNode =
- GetChild(root, ProfileGenerator::kIdleEntryName);
+ GetChild(env->GetIsolate(), root, ProfileGenerator::kIdleEntryName);
CHECK_EQ(0, idleNode->GetChildrenCount());
CHECK_GE(idleNode->GetHitCount(), 3);
@@ -1393,11 +1471,14 @@ TEST(IdleTime) {
}
-static void CheckFunctionDetails(const v8::CpuProfileNode* node,
- const char* name, const char* script_name, int script_id,
- int line, int column) {
- CHECK_EQ(v8::String::New(name), node->GetFunctionName());
- CHECK_EQ(v8::String::New(script_name), node->GetScriptResourceName());
+static void CheckFunctionDetails(v8::Isolate* isolate,
+ const v8::CpuProfileNode* node,
+ const char* name, const char* script_name,
+ int script_id, int line, int column) {
+ CHECK_EQ(v8::String::NewFromUtf8(isolate, name),
+ node->GetFunctionName());
+ CHECK_EQ(v8::String::NewFromUtf8(isolate, script_name),
+ node->GetScriptResourceName());
CHECK_EQ(script_id, node->GetScriptId());
CHECK_EQ(line, node->GetLineNumber());
CHECK_EQ(column, node->GetColumnNumber());
@@ -1412,14 +1493,20 @@ TEST(FunctionDetails) {
v8::CpuProfiler* profiler = env->GetIsolate()->GetCpuProfiler();
CHECK_EQ(0, profiler->GetProfileCount());
- v8::Handle<v8::Script> script_a = v8::Script::Compile(v8::String::New(
- " function foo\n() { try { bar(); } catch(e) {} }\n"
- " function bar() { startProfiling(); }\n"), v8::String::New("script_a"));
+ v8::Handle<v8::Script> script_a = v8::Script::Compile(
+ v8::String::NewFromUtf8(
+ env->GetIsolate(),
+ " function foo\n() { try { bar(); } catch(e) {} }\n"
+ " function bar() { startProfiling(); }\n"),
+ v8::String::NewFromUtf8(env->GetIsolate(), "script_a"));
script_a->Run();
- v8::Handle<v8::Script> script_b = v8::Script::Compile(v8::String::New(
- "\n\n function baz() { try { foo(); } catch(e) {} }\n"
- "\n\nbaz();\n"
- "stopProfiling();\n"), v8::String::New("script_b"));
+ v8::Handle<v8::Script> script_b = v8::Script::Compile(
+ v8::String::NewFromUtf8(
+ env->GetIsolate(),
+ "\n\n function baz() { try { foo(); } catch(e) {} }\n"
+ "\n\nbaz();\n"
+ "stopProfiling();\n"),
+ v8::String::NewFromUtf8(env->GetIsolate(), "script_b"));
script_b->Run();
CHECK_EQ(1, profiler->GetProfileCount());
const v8::CpuProfile* profile = profiler->GetCpuProfile(0);
@@ -1433,14 +1520,18 @@ TEST(FunctionDetails) {
// 0 foo 18 #4 TryCatchStatement script_a:2
// 1 bar 18 #5 no reason script_a:3
const v8::CpuProfileNode* root = profile->GetTopDownRoot();
- const v8::CpuProfileNode* script = GetChild(root,
+ const v8::CpuProfileNode* script = GetChild(env->GetIsolate(), root,
ProfileGenerator::kAnonymousFunctionName);
- CheckFunctionDetails(script, ProfileGenerator::kAnonymousFunctionName,
- "script_b", script_b->GetId(), 1, 1);
- const v8::CpuProfileNode* baz = GetChild(script, "baz");
- CheckFunctionDetails(baz, "baz", "script_b", script_b->GetId(), 3, 16);
- const v8::CpuProfileNode* foo = GetChild(baz, "foo");
- CheckFunctionDetails(foo, "foo", "script_a", script_a->GetId(), 2, 1);
- const v8::CpuProfileNode* bar = GetChild(foo, "bar");
- CheckFunctionDetails(bar, "bar", "script_a", script_a->GetId(), 3, 14);
+ CheckFunctionDetails(env->GetIsolate(), script,
+ ProfileGenerator::kAnonymousFunctionName, "script_b",
+ script_b->GetId(), 1, 1);
+ const v8::CpuProfileNode* baz = GetChild(env->GetIsolate(), script, "baz");
+ CheckFunctionDetails(env->GetIsolate(), baz, "baz", "script_b",
+ script_b->GetId(), 3, 16);
+ const v8::CpuProfileNode* foo = GetChild(env->GetIsolate(), baz, "foo");
+ CheckFunctionDetails(env->GetIsolate(), foo, "foo", "script_a",
+ script_a->GetId(), 2, 1);
+ const v8::CpuProfileNode* bar = GetChild(env->GetIsolate(), foo, "bar");
+ CheckFunctionDetails(env->GetIsolate(), bar, "bar", "script_a",
+ script_a->GetId(), 3, 14);
}
« no previous file with comments | « test/cctest/test-compiler.cc ('k') | test/cctest/test-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698