Remove usage of deprecated APIs from cctests

Also turn on deprecation warnings

BUG=v8:3023
R=svenpanne@chromium.org, dcarney@chromium.org
LOG=n

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@18011 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
jochen@chromium.org 2013-11-22 12:43:17 +00:00
parent 6aec0d39ae
commit c0c5efb9e7
27 changed files with 1427 additions and 1003 deletions

View File

@ -30,12 +30,6 @@
'v8_code': 1,
'generated_file': '<(SHARED_INTERMEDIATE_DIR)/resources.cc',
},
'target_defaults': {
'variables': {
# TODO(jochen): enable warnings.
'v8_deprecation_warnings': 0,
},
},
'includes': ['../../build/toolchain.gypi', '../../build/features.gypi'],
'targets': [
{

View File

@ -255,7 +255,7 @@ class LocalContext {
virtual ~LocalContext() {
v8::HandleScope scope(isolate_);
v8::Local<v8::Context>::New(isolate_, context_)->Exit();
context_.Dispose();
context_.Reset();
}
v8::Context* operator->() {
@ -294,7 +294,7 @@ static inline v8::Local<v8::Value> v8_num(double x) {
static inline v8::Local<v8::String> v8_str(const char* x) {
return v8::String::New(x);
return v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), x);
}
@ -305,7 +305,8 @@ static inline v8::Local<v8::Script> v8_compile(const char* x) {
// Helper function that compiles and runs the source.
static inline v8::Local<v8::Value> CompileRun(const char* source) {
return v8::Script::Compile(v8::String::New(source))->Run();
return v8::Script::Compile(
v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), source))->Run();
}
@ -314,10 +315,12 @@ static inline v8::Local<v8::Value> CompileRunWithOrigin(const char* source,
const char* origin_url,
int line_number,
int column_number) {
v8::ScriptOrigin origin(v8::String::New(origin_url),
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::ScriptOrigin origin(v8::String::NewFromUtf8(isolate, origin_url),
v8::Integer::New(line_number),
v8::Integer::New(column_number));
return v8::Script::Compile(v8::String::New(source), &origin)->Run();
return v8::Script::Compile(v8::String::NewFromUtf8(isolate, source), &origin)
->Run();
}

View File

@ -277,8 +277,8 @@ static void HandleAllocatingGetter(
const v8::PropertyCallbackInfo<v8::Value>& info) {
ApiTestFuzzer::Fuzz();
for (int i = 0; i < C; i++)
v8::String::New("foo");
info.GetReturnValue().Set(v8::String::New("foo"));
v8::String::NewFromUtf8(info.GetIsolate(), "foo");
info.GetReturnValue().Set(v8::String::NewFromUtf8(info.GetIsolate(), "foo"));
}
@ -289,7 +289,8 @@ THREADED_TEST(HandleScopePop) {
obj->SetAccessor(v8_str("one"), HandleAllocatingGetter<1>);
obj->SetAccessor(v8_str("many"), HandleAllocatingGetter<1024>);
v8::Handle<v8::Object> inst = obj->NewInstance();
context->Global()->Set(v8::String::New("obj"), inst);
context->Global()->Set(v8::String::NewFromUtf8(context->GetIsolate(), "obj"),
inst);
i::Isolate* isolate = CcTest::i_isolate();
int count_before = i::HandleScope::NumberOfHandles(isolate);
{
@ -309,15 +310,18 @@ static void CheckAccessorArgsCorrect(
const v8::PropertyCallbackInfo<v8::Value>& info) {
CHECK(info.GetIsolate() == CcTest::isolate());
CHECK(info.This() == info.Holder());
CHECK(info.Data()->Equals(v8::String::New("data")));
CHECK(
info.Data()->Equals(v8::String::NewFromUtf8(CcTest::isolate(), "data")));
ApiTestFuzzer::Fuzz();
CHECK(info.GetIsolate() == CcTest::isolate());
CHECK(info.This() == info.Holder());
CHECK(info.Data()->Equals(v8::String::New("data")));
CHECK(
info.Data()->Equals(v8::String::NewFromUtf8(CcTest::isolate(), "data")));
CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags);
CHECK(info.GetIsolate() == CcTest::isolate());
CHECK(info.This() == info.Holder());
CHECK(info.Data()->Equals(v8::String::New("data")));
CHECK(
info.Data()->Equals(v8::String::NewFromUtf8(CcTest::isolate(), "data")));
info.GetReturnValue().Set(17);
}
@ -329,10 +333,12 @@ THREADED_TEST(DirectCall) {
obj->SetAccessor(v8_str("xxx"),
CheckAccessorArgsCorrect,
NULL,
v8::String::New("data"));
v8::String::NewFromUtf8(context->GetIsolate(), "data"));
v8::Handle<v8::Object> inst = obj->NewInstance();
context->Global()->Set(v8::String::New("obj"), inst);
Local<Script> scr = v8::Script::Compile(v8::String::New("obj.xxx"));
context->Global()->Set(v8::String::NewFromUtf8(context->GetIsolate(), "obj"),
inst);
Local<Script> scr = v8::Script::Compile(
v8::String::NewFromUtf8(context->GetIsolate(), "obj.xxx"));
for (int i = 0; i < 10; i++) {
Local<Value> result = scr->Run();
CHECK(!result.IsEmpty());
@ -354,10 +360,12 @@ THREADED_TEST(EmptyResult) {
v8::Isolate* isolate = context->GetIsolate();
v8::HandleScope scope(isolate);
v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New();
obj->SetAccessor(v8_str("xxx"), EmptyGetter, NULL, v8::String::New("data"));
obj->SetAccessor(v8_str("xxx"), EmptyGetter, NULL,
v8::String::NewFromUtf8(isolate, "data"));
v8::Handle<v8::Object> inst = obj->NewInstance();
context->Global()->Set(v8::String::New("obj"), inst);
Local<Script> scr = v8::Script::Compile(v8::String::New("obj.xxx"));
context->Global()->Set(v8::String::NewFromUtf8(isolate, "obj"), inst);
Local<Script> scr =
v8::Script::Compile(v8::String::NewFromUtf8(isolate, "obj.xxx"));
for (int i = 0; i < 10; i++) {
Local<Value> result = scr->Run();
CHECK(result == v8::Undefined(isolate));
@ -372,11 +380,13 @@ THREADED_TEST(NoReuseRegress) {
v8::HandleScope scope(isolate);
{
v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New();
obj->SetAccessor(v8_str("xxx"), EmptyGetter, NULL, v8::String::New("data"));
obj->SetAccessor(v8_str("xxx"), EmptyGetter, NULL,
v8::String::NewFromUtf8(isolate, "data"));
LocalContext context;
v8::Handle<v8::Object> inst = obj->NewInstance();
context->Global()->Set(v8::String::New("obj"), inst);
Local<Script> scr = v8::Script::Compile(v8::String::New("obj.xxx"));
context->Global()->Set(v8::String::NewFromUtf8(isolate, "obj"), inst);
Local<Script> scr =
v8::Script::Compile(v8::String::NewFromUtf8(isolate, "obj.xxx"));
for (int i = 0; i < 2; i++) {
Local<Value> result = scr->Run();
CHECK(result == v8::Undefined(isolate));
@ -387,11 +397,12 @@ THREADED_TEST(NoReuseRegress) {
obj->SetAccessor(v8_str("xxx"),
CheckAccessorArgsCorrect,
NULL,
v8::String::New("data"));
v8::String::NewFromUtf8(isolate, "data"));
LocalContext context;
v8::Handle<v8::Object> inst = obj->NewInstance();
context->Global()->Set(v8::String::New("obj"), inst);
Local<Script> scr = v8::Script::Compile(v8::String::New("obj.xxx"));
context->Global()->Set(v8::String::NewFromUtf8(isolate, "obj"), inst);
Local<Script> scr =
v8::Script::Compile(v8::String::NewFromUtf8(isolate, "obj.xxx"));
for (int i = 0; i < 10; i++) {
Local<Value> result = scr->Run();
CHECK(!result.IsEmpty());
@ -436,7 +447,8 @@ THREADED_TEST(Regress1054726) {
"}; result"))->Run();
CHECK_EQ(v8_str("ggggg"), result);
result = Script::Compile(String::New(
result = Script::Compile(String::NewFromUtf8(
env->GetIsolate(),
"var result = '';"
"for (var i = 0; i < 5; i++) {"
" try { obj.x = i; } catch (e) { result += e; }"
@ -458,7 +470,8 @@ THREADED_TEST(Gc) {
v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New();
obj->SetAccessor(v8_str("xxx"), AllocGetter);
env->Global()->Set(v8_str("obj"), obj->NewInstance());
Script::Compile(String::New(
Script::Compile(String::NewFromUtf8(
env->GetIsolate(),
"var last = [];"
"for (var i = 0; i < 2048; i++) {"
" var result = obj.xxx;"
@ -491,7 +504,8 @@ THREADED_TEST(StackIteration) {
i::StringStream::ClearMentionedObjectCache(isolate);
obj->SetAccessor(v8_str("xxx"), StackCheck);
env->Global()->Set(v8_str("obj"), obj->NewInstance());
Script::Compile(String::New(
Script::Compile(String::NewFromUtf8(
env->GetIsolate(),
"function foo() {"
" return obj.xxx;"
"}"
@ -518,7 +532,8 @@ THREADED_TEST(HandleScopeSegment) {
v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New();
obj->SetAccessor(v8_str("xxx"), AllocateHandles);
env->Global()->Set(v8_str("obj"), obj->NewInstance());
v8::Handle<v8::Value> result = Script::Compile(String::New(
v8::Handle<v8::Value> result = Script::Compile(String::NewFromUtf8(
env->GetIsolate(),
"var result;"
"for (var i = 0; i < 4; i++)"
" result = obj.xxx;"

View File

@ -148,10 +148,11 @@ TEST(StressJS) {
map->AppendDescriptor(&d, witness);
// Add the Foo constructor the global object.
env->Global()->Set(v8::String::New("Foo"), v8::Utils::ToLocal(function));
env->Global()->Set(v8::String::NewFromUtf8(CcTest::isolate(), "Foo"),
v8::Utils::ToLocal(function));
// Call the accessor through JavaScript.
v8::Handle<v8::Value> result =
v8::Script::Compile(v8::String::New("(new Foo).get"))->Run();
v8::Handle<v8::Value> result = v8::Script::Compile(
v8::String::NewFromUtf8(CcTest::isolate(), "(new Foo).get"))->Run();
CHECK_EQ(42, result->Int32Value());
env->Exit();
}

File diff suppressed because it is too large Load Diff

View File

@ -331,7 +331,8 @@ TEST(Regression236) {
TEST(GetScriptLineNumber) {
LocalContext context;
v8::HandleScope scope(CcTest::isolate());
v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::New("test"));
v8::ScriptOrigin origin =
v8::ScriptOrigin(v8::String::NewFromUtf8(CcTest::isolate(), "test"));
const char function_f[] = "function f() {}";
const int max_rows = 1000;
const int buffer_size = max_rows + sizeof(function_f);
@ -343,10 +344,12 @@ TEST(GetScriptLineNumber) {
if (i > 0)
buffer[i - 1] = '\n';
OS::MemCopy(&buffer[i], function_f, sizeof(function_f) - 1);
v8::Handle<v8::String> script_body = v8::String::New(buffer.start());
v8::Handle<v8::String> script_body =
v8::String::NewFromUtf8(CcTest::isolate(), buffer.start());
v8::Script::Compile(script_body, &origin)->Run();
v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(
context->Global()->Get(v8::String::New("f")));
v8::Local<v8::Function> f =
v8::Local<v8::Function>::Cast(context->Global()->Get(
v8::String::NewFromUtf8(CcTest::isolate(), "f")));
CHECK_EQ(i, f->GetScriptLineNumber());
}
}
@ -364,7 +367,8 @@ TEST(OptimizedCodeSharing) {
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));
env->Global()->Set(v8::String::NewFromUtf8(CcTest::isolate(), "x"),
v8::Integer::New(i));
CompileRun("function MakeClosure() {"
" return function() { return x; };"
"}"

View File

@ -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);
}

File diff suppressed because it is too large Load Diff

View File

@ -42,8 +42,7 @@ class HandleArray : public Malloced {
void Reset() {
for (unsigned i = 0; i < kArraySize; i++) {
if (handles_[i].IsEmpty()) continue;
handles_[i].Dispose();
handles_[i].Clear();
handles_[i].Reset();
}
}
v8::Persistent<v8::Value> handles_[kArraySize];

View File

@ -56,7 +56,7 @@ class DeclarationContext {
HandleScope scope(isolate);
Local<Context> context = Local<Context>::New(isolate, context_);
context->Exit();
context_.Dispose();
context_.Reset();
}
}
@ -147,7 +147,8 @@ void DeclarationContext::Check(const char* source,
HandleScope scope(CcTest::isolate());
TryCatch catcher;
catcher.SetVerbose(true);
Local<Script> script = Script::Compile(String::New(source));
Local<Script> script =
Script::Compile(String::NewFromUtf8(CcTest::isolate(), source));
if (expectations == EXPECT_ERROR) {
CHECK(script.IsEmpty());
return;
@ -729,7 +730,8 @@ class SimpleContext {
HandleScope scope(context_->GetIsolate());
TryCatch catcher;
catcher.SetVerbose(true);
Local<Script> script = Script::Compile(String::New(source));
Local<Script> script =
Script::Compile(String::NewFromUtf8(context_->GetIsolate(), source));
if (expectations == EXPECT_ERROR) {
CHECK(script.IsEmpty());
return;

View File

@ -235,8 +235,8 @@ TEST(DeoptimizeRecursive) {
CHECK_EQ(11, env->Global()->Get(v8_str("calls"))->Int32Value());
CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(CcTest::i_isolate()));
v8::Local<v8::Function> fun =
v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f")));
v8::Local<v8::Function> fun = v8::Local<v8::Function>::Cast(
env->Global()->Get(v8::String::NewFromUtf8(CcTest::isolate(), "f")));
CHECK(!fun.IsEmpty());
}

View File

@ -94,8 +94,8 @@ static void CheckFunctionName(v8::Handle<v8::Script> script,
}
static v8::Handle<v8::Script> Compile(const char* src) {
return v8::Script::Compile(v8::String::New(src));
static v8::Handle<v8::Script> Compile(v8::Isolate* isolate, const char* src) {
return v8::Script::Compile(v8::String::NewFromUtf8(isolate, src));
}
@ -104,6 +104,7 @@ TEST(GlobalProperty) {
v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile(
CcTest::isolate(),
"fun1 = function() { return 1; }\n"
"fun2 = function() { return 2; }\n");
CheckFunctionName(script, "return 1", "fun1");
@ -116,6 +117,7 @@ TEST(GlobalVar) {
v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile(
CcTest::isolate(),
"var fun1 = function() { return 1; }\n"
"var fun2 = function() { return 2; }\n");
CheckFunctionName(script, "return 1", "fun1");
@ -128,6 +130,7 @@ TEST(LocalVar) {
v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile(
CcTest::isolate(),
"function outer() {\n"
" var fun1 = function() { return 1; }\n"
" var fun2 = function() { return 2; }\n"
@ -142,6 +145,7 @@ TEST(InConstructor) {
v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile(
CcTest::isolate(),
"function MyClass() {\n"
" this.method1 = function() { return 1; }\n"
" this.method2 = function() { return 2; }\n"
@ -156,6 +160,7 @@ TEST(Factory) {
v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile(
CcTest::isolate(),
"function createMyObj() {\n"
" var obj = {};\n"
" obj.method1 = function() { return 1; }\n"
@ -172,6 +177,7 @@ TEST(Static) {
v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile(
CcTest::isolate(),
"function MyClass() {}\n"
"MyClass.static1 = function() { return 1; }\n"
"MyClass.static2 = function() { return 2; }\n"
@ -190,6 +196,7 @@ TEST(Prototype) {
v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile(
CcTest::isolate(),
"function MyClass() {}\n"
"MyClass.prototype.method1 = function() { return 1; }\n"
"MyClass.prototype.method2 = function() { return 2; }\n"
@ -208,6 +215,7 @@ TEST(ObjectLiteral) {
v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile(
CcTest::isolate(),
"function MyClass() {}\n"
"MyClass.prototype = {\n"
" method1: function() { return 1; },\n"
@ -222,6 +230,7 @@ TEST(AsParameter) {
v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile(
CcTest::isolate(),
"function f1(a) { return a(); }\n"
"function f2(a, b) { return a() + b(); }\n"
"var result1 = f1(function() { return 1; })\n"
@ -238,6 +247,7 @@ TEST(MultipleFuncsConditional) {
v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile(
CcTest::isolate(),
"fun1 = 0 ?\n"
" function() { return 1; } :\n"
" function() { return 2; }");
@ -251,6 +261,7 @@ TEST(MultipleFuncsInLiteral) {
v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile(
CcTest::isolate(),
"function MyClass() {}\n"
"MyClass.prototype = {\n"
" method1: 0 ? function() { return 1; } :\n"
@ -265,6 +276,7 @@ TEST(AnonymousInAnonymousClosure1) {
v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile(
CcTest::isolate(),
"(function() {\n"
" (function() {\n"
" var a = 1;\n"
@ -284,6 +296,7 @@ TEST(AnonymousInAnonymousClosure2) {
v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile(
CcTest::isolate(),
"(function() {\n"
" (function() {\n"
" var a = 1;\n"
@ -300,6 +313,7 @@ TEST(NamedInAnonymousClosure) {
v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile(
CcTest::isolate(),
"var foo = function() {\n"
" (function named() {\n"
" var a = 1;\n"
@ -317,6 +331,7 @@ TEST(Issue380) {
v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile(
CcTest::isolate(),
"function a() {\n"
"var result = function(p,a,c,k,e,d)"
"{return p}(\"if blah blah\",62,1976,\'a|b\'.split(\'|\'),0,{})\n"
@ -330,6 +345,7 @@ TEST(MultipleAssignments) {
v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile(
CcTest::isolate(),
"var fun1 = fun2 = function () { return 1; }\n"
"var bar1 = bar2 = bar3 = function () { return 2; }\n"
"foo1 = foo2 = function () { return 3; }\n"
@ -346,6 +362,7 @@ TEST(AsConstructorParameter) {
v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile(
CcTest::isolate(),
"function Foo() {}\n"
"var foo = new Foo(function() { return 1; })\n"
"var bar = new Foo(function() { return 2; }, function() { return 3; })");
@ -360,6 +377,7 @@ TEST(FactoryHashmap) {
v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile(
CcTest::isolate(),
"function createMyObj() {\n"
" var obj = {};\n"
" obj[\"method1\"] = function() { return 1; }\n"
@ -376,6 +394,7 @@ TEST(FactoryHashmapVariable) {
v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile(
CcTest::isolate(),
"function createMyObj() {\n"
" var obj = {};\n"
" var methodName = \"method1\";\n"
@ -395,6 +414,7 @@ TEST(FactoryHashmapConditional) {
v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile(
CcTest::isolate(),
"function createMyObj() {\n"
" var obj = {};\n"
" obj[0 ? \"method1\" : \"method2\"] = function() { return 1; }\n"
@ -410,6 +430,7 @@ TEST(GlobalAssignmentAndCall) {
v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile(
CcTest::isolate(),
"var Foo = function() {\n"
" return 1;\n"
"}();\n"
@ -428,6 +449,7 @@ TEST(AssignmentAndCall) {
v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile(
CcTest::isolate(),
"(function Enclosing() {\n"
" var Foo;\n"
" Foo = function() {\n"
@ -451,6 +473,7 @@ TEST(MethodAssignmentInAnonymousFunctionCall) {
v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile(
CcTest::isolate(),
"(function () {\n"
" var EventSource = function () { };\n"
" EventSource.prototype.addListener = function () {\n"
@ -467,6 +490,7 @@ TEST(ReturnAnonymousFunction) {
v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile(
CcTest::isolate(),
"(function() {\n"
" function wrapCode() {\n"
" return function () {\n"

View File

@ -255,7 +255,8 @@ TEST(BoundFunctionInSnapshot) {
const v8::HeapGraphNode* f =
GetProperty(global, v8::HeapGraphEdge::kProperty, "boundFunction");
CHECK(f);
CHECK_EQ(v8::String::New("native_bind"), f->GetName());
CHECK_EQ(v8::String::NewFromUtf8(env->GetIsolate(), "native_bind"),
f->GetName());
const v8::HeapGraphNode* bindings =
GetProperty(f, v8::HeapGraphEdge::kInternal, "bindings");
CHECK_NE(NULL, bindings);
@ -1083,8 +1084,8 @@ TEST(HeapSnapshotGetSnapshotObjectId) {
GetProperty(global, v8::HeapGraphEdge::kProperty, "globalObject");
CHECK(global_object);
v8::Local<v8::Value> globalObjectHandle =
env->Global()->Get(v8::String::New("globalObject"));
v8::Local<v8::Value> globalObjectHandle = env->Global()->Get(
v8::String::NewFromUtf8(env->GetIsolate(), "globalObject"));
CHECK(!globalObjectHandle.IsEmpty());
CHECK(globalObjectHandle->IsObject());
@ -1719,7 +1720,8 @@ TEST(HiddenPropertiesFastCase) {
GetProperty(c, v8::HeapGraphEdge::kInternal, "hidden_properties");
CHECK_EQ(NULL, hidden_props);
v8::Handle<v8::Value> cHandle = env->Global()->Get(v8::String::New("c"));
v8::Handle<v8::Value> cHandle =
env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "c"));
CHECK(!cHandle.IsEmpty() && cHandle->IsObject());
cHandle->ToObject()->SetHiddenValue(v8_str("key"), v8_str("val"));
@ -1763,7 +1765,7 @@ bool HasWeakGlobalHandle() {
static void PersistentHandleCallback(v8::Isolate* isolate,
v8::Persistent<v8::Value>* handle,
void*) {
handle->Dispose();
handle->Reset();
}
@ -2036,7 +2038,8 @@ const char* HeapProfilerExtension::kSource =
v8::Handle<v8::FunctionTemplate> HeapProfilerExtension::GetNativeFunction(
v8::Handle<v8::String> name) {
if (name->Equals(v8::String::New("findUntrackedObjects"))) {
if (name->Equals(v8::String::NewFromUtf8(v8::Isolate::GetCurrent(),
"findUntrackedObjects"))) {
return v8::FunctionTemplate::New(
HeapProfilerExtension::FindUntrackedObjects);
} else {
@ -2212,7 +2215,7 @@ TEST(TrackHeapAllocations) {
CompileRun(record_trace_tree_source);
const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(
v8::String::New("Test"));
v8::String::NewFromUtf8(env->GetIsolate(), "Test"));
i::HeapSnapshotsCollection* collection = ToInternal(snapshot)->collection();
AllocationTracker* tracker = collection->allocation_tracker();
CHECK_NE(NULL, tracker);
@ -2265,7 +2268,7 @@ TEST(TrackBumpPointerAllocations) {
CompileRun(inline_heap_allocation_source);
const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(
v8::String::New("Test2"));
v8::String::NewFromUtf8(env->GetIsolate(), "Test2"));
i::HeapSnapshotsCollection* collection = ToInternal(snapshot)->collection();
AllocationTracker* tracker = collection->allocation_tracker();
CHECK_NE(NULL, tracker);
@ -2293,7 +2296,7 @@ TEST(TrackBumpPointerAllocations) {
CompileRun(inline_heap_allocation_source);
const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(
v8::String::New("Test1"));
v8::String::NewFromUtf8(env->GetIsolate(), "Test1"));
i::HeapSnapshotsCollection* collection = ToInternal(snapshot)->collection();
AllocationTracker* tracker = collection->allocation_tracker();
CHECK_NE(NULL, tracker);

View File

@ -397,7 +397,7 @@ static void TestWeakGlobalHandleCallback(v8::Isolate* isolate,
v8::Persistent<v8::Value>* handle,
void* id) {
if (1234 == reinterpret_cast<intptr_t>(id)) WeakPointerCleared = true;
handle->Dispose();
handle->Reset();
}
@ -1787,12 +1787,12 @@ TEST(LeakNativeContextViaMap) {
ctx2->Global()->Set(v8_str("o"), v8::Int32::New(0));
ctx2->Exit();
v8::Local<v8::Context>::New(isolate, ctx1)->Exit();
ctx1p.Dispose();
ctx1p.Reset();
v8::V8::ContextDisposedNotification();
}
CcTest::heap()->CollectAllAvailableGarbage();
CHECK_EQ(2, NumberOfGlobalObjects());
ctx2p.Dispose();
ctx2p.Reset();
CcTest::heap()->CollectAllAvailableGarbage();
CHECK_EQ(0, NumberOfGlobalObjects());
}
@ -1833,12 +1833,12 @@ TEST(LeakNativeContextViaFunction) {
ctx2->Global()->Set(v8_str("o"), v8::Int32::New(0));
ctx2->Exit();
ctx1->Exit();
ctx1p.Dispose();
ctx1p.Reset();
v8::V8::ContextDisposedNotification();
}
CcTest::heap()->CollectAllAvailableGarbage();
CHECK_EQ(2, NumberOfGlobalObjects());
ctx2p.Dispose();
ctx2p.Reset();
CcTest::heap()->CollectAllAvailableGarbage();
CHECK_EQ(0, NumberOfGlobalObjects());
}
@ -1877,12 +1877,12 @@ TEST(LeakNativeContextViaMapKeyed) {
ctx2->Global()->Set(v8_str("o"), v8::Int32::New(0));
ctx2->Exit();
ctx1->Exit();
ctx1p.Dispose();
ctx1p.Reset();
v8::V8::ContextDisposedNotification();
}
CcTest::heap()->CollectAllAvailableGarbage();
CHECK_EQ(2, NumberOfGlobalObjects());
ctx2p.Dispose();
ctx2p.Reset();
CcTest::heap()->CollectAllAvailableGarbage();
CHECK_EQ(0, NumberOfGlobalObjects());
}
@ -1925,12 +1925,12 @@ TEST(LeakNativeContextViaMapProto) {
ctx2->Global()->Set(v8_str("o"), v8::Int32::New(0));
ctx2->Exit();
ctx1->Exit();
ctx1p.Dispose();
ctx1p.Reset();
v8::V8::ContextDisposedNotification();
}
CcTest::heap()->CollectAllAvailableGarbage();
CHECK_EQ(2, NumberOfGlobalObjects());
ctx2p.Dispose();
ctx2p.Reset();
CcTest::heap()->CollectAllAvailableGarbage();
CHECK_EQ(0, NumberOfGlobalObjects());
}

View File

@ -667,7 +667,7 @@ TEST(Regress1433) {
v8::HandleScope handle_scope(isolate);
v8::Handle<Context> context = v8::Context::New(isolate);
v8::Context::Scope context_scope(context);
v8::Handle<String> source = v8::String::New("1+1");
v8::Handle<String> source = v8::String::NewFromUtf8(isolate, "1+1");
v8::Handle<Script> script = v8::Script::Compile(source);
v8::Handle<Value> result = script->Run();
v8::String::Utf8Value utf8(result);

View File

@ -113,13 +113,16 @@ const char* TraceExtension::kSource =
v8::Handle<v8::FunctionTemplate> TraceExtension::GetNativeFunction(
v8::Handle<String> name) {
if (name->Equals(String::New("trace"))) {
if (name->Equals(String::NewFromUtf8(v8::Isolate::GetCurrent(), "trace"))) {
return v8::FunctionTemplate::New(TraceExtension::Trace);
} else if (name->Equals(String::New("js_trace"))) {
} else if (name->Equals(
String::NewFromUtf8(v8::Isolate::GetCurrent(), "js_trace"))) {
return v8::FunctionTemplate::New(TraceExtension::JSTrace);
} else if (name->Equals(String::New("js_entry_sp"))) {
} else if (name->Equals(String::NewFromUtf8(v8::Isolate::GetCurrent(),
"js_entry_sp"))) {
return v8::FunctionTemplate::New(TraceExtension::JSEntrySP);
} else if (name->Equals(String::New("js_entry_sp_level2"))) {
} else if (name->Equals(String::NewFromUtf8(v8::Isolate::GetCurrent(),
"js_entry_sp_level2"))) {
return v8::FunctionTemplate::New(TraceExtension::JSEntrySPLevel2);
} else {
CHECK(false);

View File

@ -307,7 +307,8 @@ TEST(Issue23768) {
SimpleExternalString source_ext_str("(function ext() {})();");
v8::Local<v8::String> source = v8::String::NewExternal(&source_ext_str);
// Script needs to have a name in order to trigger InitLineEnds execution.
v8::Handle<v8::String> origin = v8::String::New("issue-23768-test");
v8::Handle<v8::String> origin =
v8::String::NewFromUtf8(CcTest::isolate(), "issue-23768-test");
v8::Handle<v8::Script> evil_script = v8::Script::Compile(source, origin);
CHECK(!evil_script.IsEmpty());
CHECK(!evil_script->Run().IsEmpty());
@ -451,12 +452,14 @@ TEST(EquivalenceOfLoggingAndTraversal) {
i::Vector<const char> log(
i::ReadFile(initialize_logger.StopLoggingGetTempFile(), &exists, true));
CHECK(exists);
v8::Handle<v8::String> log_str = v8::String::New(log.start(), log.length());
v8::Handle<v8::String> log_str = v8::String::NewFromUtf8(
CcTest::isolate(), log.start(), v8::String::kNormalString, log.length());
initialize_logger.env()->Global()->Set(v8_str("_log"), log_str);
i::Vector<const unsigned char> source = TestSources::GetScriptsSource();
v8::Handle<v8::String> source_str = v8::String::New(
reinterpret_cast<const char*>(source.start()), source.length());
v8::Handle<v8::String> source_str = v8::String::NewFromUtf8(
CcTest::isolate(), reinterpret_cast<const char*>(source.start()),
v8::String::kNormalString, source.length());
v8::TryCatch try_catch;
v8::Handle<v8::Script> script = v8::Script::Compile(source_str, v8_str(""));
if (script.IsEmpty()) {

View File

@ -250,7 +250,7 @@ static void WeakPointerCallback(v8::Isolate* isolate,
void* id) {
ASSERT(id == reinterpret_cast<void*>(1234));
NumberOfWeakCalls++;
handle->Dispose();
handle->Reset();
}

View File

@ -72,23 +72,29 @@ TEST(PerIsolateState) {
Handle<Value> notify_fun2;
{
LocalContext context2(isolate.GetIsolate());
context2->Global()->Set(String::New("obj"), obj);
context2->Global()->Set(String::NewFromUtf8(isolate.GetIsolate(), "obj"),
obj);
notify_fun2 = CompileRun(
"(function() { obj.foo = 'baz'; })");
}
Handle<Value> notify_fun3;
{
LocalContext context3(isolate.GetIsolate());
context3->Global()->Set(String::New("obj"), obj);
context3->Global()->Set(String::NewFromUtf8(isolate.GetIsolate(), "obj"),
obj);
notify_fun3 = CompileRun(
"(function() { obj.foo = 'bat'; })");
}
{
LocalContext context4(isolate.GetIsolate());
context4->Global()->Set(String::New("observer"), observer);
context4->Global()->Set(String::New("fun1"), notify_fun1);
context4->Global()->Set(String::New("fun2"), notify_fun2);
context4->Global()->Set(String::New("fun3"), notify_fun3);
context4->Global()->Set(
String::NewFromUtf8(isolate.GetIsolate(), "observer"), observer);
context4->Global()->Set(String::NewFromUtf8(isolate.GetIsolate(), "fun1"),
notify_fun1);
context4->Global()->Set(String::NewFromUtf8(isolate.GetIsolate(), "fun2"),
notify_fun2);
context4->Global()->Set(String::NewFromUtf8(isolate.GetIsolate(), "fun3"),
notify_fun3);
CompileRun("fun1(); fun2(); fun3(); Object.deliverChangeRecords(observer)");
}
CHECK_EQ(1, CompileRun("calls")->Int32Value());
@ -211,8 +217,10 @@ TEST(ObjectHashTableGrowth) {
{
// As does initializing this context.
LocalContext context2(isolate.GetIsolate());
context2->Global()->Set(String::New("obj"), obj);
context2->Global()->Set(String::New("observer"), observer);
context2->Global()->Set(String::NewFromUtf8(isolate.GetIsolate(), "obj"),
obj);
context2->Global()->Set(
String::NewFromUtf8(isolate.GetIsolate(), "observer"), observer);
CompileRun(
"var objArr = [];"
// 100 objects should be enough to make the hash table grow
@ -300,7 +308,8 @@ struct RecordExpectation {
// TODO(adamk): Use this helper elsewhere in this file.
static void ExpectRecords(Handle<Value> records,
static void ExpectRecords(v8::Isolate* isolate,
Handle<Value> records,
const RecordExpectation expectations[],
int num) {
CHECK(records->IsArray());
@ -311,22 +320,23 @@ static void ExpectRecords(Handle<Value> records,
CHECK(record->IsObject());
Handle<Object> recordObj = record.As<Object>();
CHECK(expectations[i].object->StrictEquals(
recordObj->Get(String::New("object"))));
CHECK(String::New(expectations[i].type)->Equals(
recordObj->Get(String::New("type"))));
recordObj->Get(String::NewFromUtf8(isolate, "object"))));
CHECK(String::NewFromUtf8(isolate, expectations[i].type)->Equals(
recordObj->Get(String::NewFromUtf8(isolate, "type"))));
if (strcmp("splice", expectations[i].type) != 0) {
CHECK(String::New(expectations[i].name)->Equals(
recordObj->Get(String::New("name"))));
CHECK(String::NewFromUtf8(isolate, expectations[i].name)->Equals(
recordObj->Get(String::NewFromUtf8(isolate, "name"))));
if (!expectations[i].old_value.IsEmpty()) {
CHECK(expectations[i].old_value->Equals(
recordObj->Get(String::New("oldValue"))));
recordObj->Get(String::NewFromUtf8(isolate, "oldValue"))));
}
}
}
}
#define EXPECT_RECORDS(records, expectations) \
ExpectRecords(records, expectations, ARRAY_SIZE(expectations))
#define EXPECT_RECORDS(records, expectations) \
ExpectRecords(isolate.GetIsolate(), records, expectations, \
ARRAY_SIZE(expectations))
TEST(APITestBasicMutation) {
HarmonyIsolate isolate;
@ -338,16 +348,17 @@ TEST(APITestBasicMutation) {
"function observer(r) { [].push.apply(records, r); };"
"Object.observe(obj, observer);"
"obj"));
obj->Set(String::New("foo"), Number::New(7));
obj->Set(String::NewFromUtf8(isolate.GetIsolate(), "foo"), Number::New(7));
obj->Set(1, Number::New(2));
// ForceSet should work just as well as Set
obj->ForceSet(String::New("foo"), Number::New(3));
obj->ForceSet(String::NewFromUtf8(isolate.GetIsolate(), "foo"),
Number::New(3));
obj->ForceSet(Number::New(1), Number::New(4));
// Setting an indexed element via the property setting method
obj->Set(Number::New(1), Number::New(5));
// Setting with a non-String, non-uint32 key
obj->Set(Number::New(1.1), Number::New(6), DontDelete);
obj->Delete(String::New("foo"));
obj->Delete(String::NewFromUtf8(isolate.GetIsolate(), "foo"));
obj->Delete(1);
obj->ForceDelete(Number::New(1.1));
@ -378,12 +389,14 @@ TEST(HiddenPrototypeObservation) {
LocalContext context(isolate.GetIsolate());
Handle<FunctionTemplate> tmpl = FunctionTemplate::New();
tmpl->SetHiddenPrototype(true);
tmpl->InstanceTemplate()->Set(String::New("foo"), Number::New(75));
tmpl->InstanceTemplate()->Set(
String::NewFromUtf8(isolate.GetIsolate(), "foo"), Number::New(75));
Handle<Object> proto = tmpl->GetFunction()->NewInstance();
Handle<Object> obj = Object::New();
obj->SetPrototype(proto);
context->Global()->Set(String::New("obj"), obj);
context->Global()->Set(String::New("proto"), proto);
context->Global()->Set(String::NewFromUtf8(isolate.GetIsolate(), "obj"), obj);
context->Global()->Set(String::NewFromUtf8(isolate.GetIsolate(), "proto"),
proto);
CompileRun(
"var records;"
"function observer(r) { records = r; };"
@ -504,6 +517,7 @@ static bool BlockAccessKeys(Local<Object> host, Local<Value> key,
static Handle<Object> CreateAccessCheckedObject(
v8::Isolate* isolate,
NamedSecurityCallback namedCallback,
IndexedSecurityCallback indexedCallback,
Handle<Value> data = Handle<Value>()) {
@ -511,7 +525,7 @@ static Handle<Object> CreateAccessCheckedObject(
tmpl->SetAccessCheckCallbacks(namedCallback, indexedCallback, data);
Handle<Object> instance = tmpl->NewInstance();
Handle<Object> global = instance->CreationContext()->Global();
global->Set(String::New("obj"), instance);
global->Set(String::NewFromUtf8(isolate, "obj"), instance);
global->Set(kBlockedContextIndex, v8::True());
return instance;
}
@ -525,9 +539,10 @@ TEST(NamedAccessCheck) {
LocalContext context(isolate.GetIsolate());
g_access_block_type = types[i];
Handle<Object> instance = CreateAccessCheckedObject(
isolate.GetIsolate(),
NamedAccessAllowUnlessBlocked,
IndexedAccessAlwaysAllowed,
String::New("foo"));
String::NewFromUtf8(isolate.GetIsolate(), "foo"));
CompileRun("var records = null;"
"var objNoCheck = {};"
"var observer = function(r) { records = r };"
@ -536,8 +551,11 @@ TEST(NamedAccessCheck) {
Handle<Value> obj_no_check = CompileRun("objNoCheck");
{
LocalContext context2(isolate.GetIsolate());
context2->Global()->Set(String::New("obj"), instance);
context2->Global()->Set(String::New("objNoCheck"), obj_no_check);
context2->Global()->Set(String::NewFromUtf8(isolate.GetIsolate(), "obj"),
instance);
context2->Global()->Set(
String::NewFromUtf8(isolate.GetIsolate(), "objNoCheck"),
obj_no_check);
CompileRun("var records2 = null;"
"var observer2 = function(r) { records2 = r };"
"Object.observe(obj, observer2);"
@ -549,7 +567,8 @@ TEST(NamedAccessCheck) {
"objNoCheck.baz = 'quux'");
const RecordExpectation expected_records2[] = {
{ instance, "add", "foo", Handle<Value>() },
{ instance, "update", "foo", String::New("bar") },
{ instance, "update", "foo",
String::NewFromUtf8(isolate.GetIsolate(), "bar") },
{ instance, "reconfigure", "foo", Number::New(5) },
{ instance, "add", "bar", Handle<Value>() },
{ obj_no_check, "add", "baz", Handle<Value>() },
@ -573,8 +592,8 @@ TEST(IndexedAccessCheck) {
LocalContext context(isolate.GetIsolate());
g_access_block_type = types[i];
Handle<Object> instance = CreateAccessCheckedObject(
NamedAccessAlwaysAllowed, IndexedAccessAllowUnlessBlocked,
Number::New(7));
isolate.GetIsolate(), NamedAccessAlwaysAllowed,
IndexedAccessAllowUnlessBlocked, Number::New(7));
CompileRun("var records = null;"
"var objNoCheck = {};"
"var observer = function(r) { records = r };"
@ -583,8 +602,11 @@ TEST(IndexedAccessCheck) {
Handle<Value> obj_no_check = CompileRun("objNoCheck");
{
LocalContext context2(isolate.GetIsolate());
context2->Global()->Set(String::New("obj"), instance);
context2->Global()->Set(String::New("objNoCheck"), obj_no_check);
context2->Global()->Set(String::NewFromUtf8(isolate.GetIsolate(), "obj"),
instance);
context2->Global()->Set(
String::NewFromUtf8(isolate.GetIsolate(), "objNoCheck"),
obj_no_check);
CompileRun("var records2 = null;"
"var observer2 = function(r) { records2 = r };"
"Object.observe(obj, observer2);"
@ -596,7 +618,8 @@ TEST(IndexedAccessCheck) {
"objNoCheck[42] = 'quux'");
const RecordExpectation expected_records2[] = {
{ instance, "add", "7", Handle<Value>() },
{ instance, "update", "7", String::New("foo") },
{ instance, "update", "7",
String::NewFromUtf8(isolate.GetIsolate(), "foo") },
{ instance, "reconfigure", "7", Number::New(5) },
{ instance, "add", "8", Handle<Value>() },
{ obj_no_check, "add", "42", Handle<Value>() }
@ -618,8 +641,8 @@ TEST(SpliceAccessCheck) {
LocalContext context(isolate.GetIsolate());
g_access_block_type = ACCESS_GET;
Handle<Object> instance = CreateAccessCheckedObject(
NamedAccessAlwaysAllowed, IndexedAccessAllowUnlessBlocked,
Number::New(1));
isolate.GetIsolate(), NamedAccessAlwaysAllowed,
IndexedAccessAllowUnlessBlocked, Number::New(1));
CompileRun("var records = null;"
"obj[1] = 'foo';"
"obj.length = 2;"
@ -630,8 +653,10 @@ TEST(SpliceAccessCheck) {
Handle<Value> obj_no_check = CompileRun("objNoCheck");
{
LocalContext context2(isolate.GetIsolate());
context2->Global()->Set(String::New("obj"), instance);
context2->Global()->Set(String::New("objNoCheck"), obj_no_check);
context2->Global()->Set(String::NewFromUtf8(isolate.GetIsolate(), "obj"),
instance);
context2->Global()->Set(
String::NewFromUtf8(isolate.GetIsolate(), "objNoCheck"), obj_no_check);
CompileRun("var records2 = null;"
"var observer2 = function(r) { records2 = r };"
"Array.observe(obj, observer2);"
@ -662,7 +687,7 @@ TEST(DisallowAllForAccessKeys) {
HandleScope scope(isolate.GetIsolate());
LocalContext context(isolate.GetIsolate());
Handle<Object> instance = CreateAccessCheckedObject(
BlockAccessKeys, IndexedAccessAlwaysAllowed);
isolate.GetIsolate(), BlockAccessKeys, IndexedAccessAlwaysAllowed);
CompileRun("var records = null;"
"var objNoCheck = {};"
"var observer = function(r) { records = r };"
@ -671,8 +696,10 @@ TEST(DisallowAllForAccessKeys) {
Handle<Value> obj_no_check = CompileRun("objNoCheck");
{
LocalContext context2(isolate.GetIsolate());
context2->Global()->Set(String::New("obj"), instance);
context2->Global()->Set(String::New("objNoCheck"), obj_no_check);
context2->Global()->Set(String::NewFromUtf8(isolate.GetIsolate(), "obj"),
instance);
context2->Global()->Set(
String::NewFromUtf8(isolate.GetIsolate(), "objNoCheck"), obj_no_check);
CompileRun("var records2 = null;"
"var observer2 = function(r) { records2 = r };"
"Object.observe(obj, observer2);"
@ -699,18 +726,20 @@ TEST(AccessCheckDisallowApiModifications) {
HandleScope scope(isolate.GetIsolate());
LocalContext context(isolate.GetIsolate());
Handle<Object> instance = CreateAccessCheckedObject(
BlockAccessKeys, IndexedAccessAlwaysAllowed);
isolate.GetIsolate(), BlockAccessKeys, IndexedAccessAlwaysAllowed);
CompileRun("var records = null;"
"var observer = function(r) { records = r };"
"Object.observe(obj, observer);");
{
LocalContext context2(isolate.GetIsolate());
context2->Global()->Set(String::New("obj"), instance);
context2->Global()->Set(String::NewFromUtf8(isolate.GetIsolate(), "obj"),
instance);
CompileRun("var records2 = null;"
"var observer2 = function(r) { records2 = r };"
"Object.observe(obj, observer2);");
instance->Set(5, String::New("bar"));
instance->Set(String::New("foo"), String::New("bar"));
instance->Set(5, String::NewFromUtf8(isolate.GetIsolate(), "bar"));
instance->Set(String::NewFromUtf8(isolate.GetIsolate(), "foo"),
String::NewFromUtf8(isolate.GetIsolate(), "bar"));
CompileRun(""); // trigger delivery
const RecordExpectation expected_records2[] = {
{ instance, "add", "5", Handle<Value>() },
@ -730,8 +759,10 @@ TEST(HiddenPropertiesLeakage) {
"var records = null;"
"var observer = function(r) { records = r };"
"Object.observe(obj, observer);");
Handle<Value> obj = context->Global()->Get(String::New("obj"));
Handle<Object>::Cast(obj)->SetHiddenValue(String::New("foo"), Null());
Handle<Value> obj =
context->Global()->Get(String::NewFromUtf8(isolate.GetIsolate(), "obj"));
Handle<Object>::Cast(obj)->SetHiddenValue(
String::NewFromUtf8(isolate.GetIsolate(), "foo"), Null());
CompileRun(""); // trigger delivery
CHECK(CompileRun("records")->IsNull());
}

View File

@ -1050,15 +1050,14 @@ i::Handle<i::String> FormatMessage(i::ScriptDataImpl* data) {
i::Factory* factory = isolate->factory();
const char* message = data->BuildMessage();
i::Handle<i::String> format = v8::Utils::OpenHandle(
*v8::String::New(message));
*v8::String::NewFromUtf8(CcTest::isolate(), message));
i::Vector<const char*> args = data->BuildArgs();
i::Handle<i::JSArray> args_array = factory->NewJSArray(args.length());
for (int i = 0; i < args.length(); i++) {
i::JSArray::SetElement(args_array,
i,
v8::Utils::OpenHandle(*v8::String::New(args[i])),
NONE,
i::kNonStrictMode);
i::JSArray::SetElement(
args_array, i, v8::Utils::OpenHandle(*v8::String::NewFromUtf8(
CcTest::isolate(), args[i])),
NONE, i::kNonStrictMode);
}
i::Handle<i::JSObject> builtins(isolate->js_builtins_object());
i::Handle<i::Object> format_fun =
@ -1329,7 +1328,7 @@ TEST(PreparserStrictOctal) {
" 01; \n"
" }; \n"
"}; \n";
v8::Script::Compile(v8::String::New(script));
v8::Script::Compile(v8::String::NewFromUtf8(CcTest::isolate(), script));
CHECK(try_catch.HasCaught());
v8::String::Utf8Value exception(try_catch.Exception());
CHECK_EQ("SyntaxError: Octal literals are not allowed in strict mode.",

View File

@ -556,9 +556,11 @@ const char* ProfilerExtension::kSource =
v8::Handle<v8::FunctionTemplate> ProfilerExtension::GetNativeFunction(
v8::Handle<v8::String> name) {
if (name->Equals(v8::String::New("startProfiling"))) {
if (name->Equals(v8::String::NewFromUtf8(v8::Isolate::GetCurrent(),
"startProfiling"))) {
return v8::FunctionTemplate::New(ProfilerExtension::StartProfiling);
} else if (name->Equals(v8::String::New("stopProfiling"))) {
} else if (name->Equals(v8::String::NewFromUtf8(v8::Isolate::GetCurrent(),
"stopProfiling"))) {
return v8::FunctionTemplate::New(ProfilerExtension::StopProfiling);
} else {
CHECK(false);
@ -573,7 +575,8 @@ void ProfilerExtension::StartProfiling(
if (args.Length() > 0)
cpu_profiler->StartCpuProfiling(args[0].As<v8::String>());
else
cpu_profiler->StartCpuProfiling(v8::String::New(""));
cpu_profiler->StartCpuProfiling(
v8::String::NewFromUtf8(args.GetIsolate(), ""));
}
@ -583,7 +586,8 @@ void ProfilerExtension::StopProfiling(
if (args.Length() > 0)
cpu_profiler->StopCpuProfiling(args[0].As<v8::String>());
else
cpu_profiler->StopCpuProfiling(v8::String::New(""));
cpu_profiler->StopCpuProfiling(
v8::String::NewFromUtf8(args.GetIsolate(), ""));
}
@ -673,7 +677,7 @@ static const v8::CpuProfileNode* PickChild(const v8::CpuProfileNode* parent,
const char* name) {
for (int i = 0; i < parent->GetChildrenCount(); ++i) {
const v8::CpuProfileNode* child = parent->GetChild(i);
v8::String::AsciiValue function_name(child->GetFunctionName());
v8::String::Utf8Value function_name(child->GetFunctionName());
if (strcmp(*function_name, name) == 0) return child;
}
return NULL;
@ -692,13 +696,14 @@ TEST(ProfileNodeScriptId) {
v8::CpuProfiler* profiler = env->GetIsolate()->GetCpuProfiler();
CHECK_EQ(0, profiler->GetProfileCount());
v8::Handle<v8::Script> script_a = v8::Script::Compile(v8::String::New(
"function a() { startProfiling(); }\n"));
v8::Handle<v8::Script> script_a = v8::Script::Compile(v8::String::NewFromUtf8(
env->GetIsolate(), "function a() { startProfiling(); }\n"));
script_a->Run();
v8::Handle<v8::Script> script_b = v8::Script::Compile(v8::String::New(
"function b() { a(); }\n"
"b();\n"
"stopProfiling();\n"));
v8::Handle<v8::Script> script_b =
v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(),
"function b() { a(); }\n"
"b();\n"
"stopProfiling();\n"));
script_b->Run();
CHECK_EQ(1, profiler->GetProfileCount());
const v8::CpuProfile* profile = profiler->GetCpuProfile(0);
@ -793,19 +798,20 @@ TEST(BailoutReason) {
v8::CpuProfiler* profiler = env->GetIsolate()->GetCpuProfiler();
CHECK_EQ(0, profiler->GetProfileCount());
v8::Handle<v8::Script> script = v8::Script::Compile(v8::String::New(
"function TryCatch() {\n"
" try {\n"
" startProfiling();\n"
" } catch (e) { };\n"
"}\n"
"function TryFinally() {\n"
" try {\n"
" TryCatch();\n"
" } finally { };\n"
"}\n"
"TryFinally();\n"
"stopProfiling();"));
v8::Handle<v8::Script> script =
v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(),
"function TryCatch() {\n"
" try {\n"
" startProfiling();\n"
" } catch (e) { };\n"
"}\n"
"function TryFinally() {\n"
" try {\n"
" TryCatch();\n"
" } finally { };\n"
"}\n"
"TryFinally();\n"
"stopProfiling();"));
script->Run();
CHECK_EQ(1, profiler->GetProfileCount());
const v8::CpuProfile* profile = profiler->GetCpuProfile(0);

View File

@ -347,7 +347,7 @@ DEPENDENT_TEST(DeserializeAndRunScript2, Serialize) {
env->Enter();
const char* c_source = "\"1234\".length";
v8::Local<v8::String> source = v8::String::New(c_source);
v8::Local<v8::String> source = v8::String::NewFromUtf8(isolate, c_source);
v8::Local<v8::Script> script = v8::Script::Compile(source);
CHECK_EQ(4, script->Run()->Int32Value());
}
@ -365,7 +365,7 @@ DEPENDENT_TEST(DeserializeFromSecondSerializationAndRunScript2,
env->Enter();
const char* c_source = "\"1234\".length";
v8::Local<v8::String> source = v8::String::New(c_source);
v8::Local<v8::String> source = v8::String::NewFromUtf8(isolate, c_source);
v8::Local<v8::Script> script = v8::Script::Compile(source);
CHECK_EQ(4, script->Run()->Int32Value());
}
@ -402,7 +402,7 @@ TEST(PartialSerialization) {
Object* raw_foo;
{
v8::HandleScope handle_scope(v8_isolate);
v8::Local<v8::String> foo = v8::String::New("foo");
v8::Local<v8::String> foo = v8::String::NewFromUtf8(v8_isolate, "foo");
ASSERT(!foo.IsEmpty());
raw_foo = *(v8::Utils::OpenHandle(*foo));
}
@ -415,7 +415,7 @@ TEST(PartialSerialization) {
v8::HandleScope handle_scope(v8_isolate);
v8::Local<v8::Context>::New(v8_isolate, env)->Exit();
}
env.Dispose();
env.Reset();
FileByteSink startup_sink(startup_name.start());
StartupSerializer startup_serializer(isolate, &startup_sink);
@ -562,7 +562,7 @@ TEST(ContextSerialization) {
i::Object* raw_context = *v8::Utils::OpenPersistent(env);
env.Dispose();
env.Reset();
FileByteSink startup_sink(startup_name.start());
StartupSerializer startup_serializer(isolate, &startup_sink);

View File

@ -889,9 +889,9 @@ TEST(Utf8Conversion) {
v8::HandleScope handle_scope(CcTest::isolate());
// A simple ascii string
const char* ascii_string = "abcdef12345";
int len =
v8::String::New(ascii_string,
StrLength(ascii_string))->Utf8Length();
int len = v8::String::NewFromUtf8(CcTest::isolate(), ascii_string,
v8::String::kNormalString,
StrLength(ascii_string))->Utf8Length();
CHECK_EQ(StrLength(ascii_string), len);
// A mixed ascii and non-ascii string
// U+02E4 -> CB A4
@ -906,7 +906,8 @@ TEST(Utf8Conversion) {
// The number of bytes expected to be written for each length
const int lengths[12] = {0, 0, 2, 3, 3, 3, 6, 7, 7, 7, 10, 11};
const int char_lengths[12] = {0, 0, 1, 2, 2, 2, 3, 4, 4, 4, 5, 5};
v8::Handle<v8::String> mixed = v8::String::New(mixed_string, 5);
v8::Handle<v8::String> mixed = v8::String::NewFromTwoByte(
CcTest::isolate(), mixed_string, v8::String::kNormalString, 5);
CHECK_EQ(10, mixed->Utf8Length());
// Try encoding the string with all capacities
char buffer[11];
@ -1083,8 +1084,8 @@ TEST(CachedHashOverflow) {
const char* line;
for (int i = 0; (line = lines[i]); i++) {
printf("%s\n", line);
v8::Local<v8::Value> result =
v8::Script::Compile(v8::String::New(line))->Run();
v8::Local<v8::Value> result = v8::Script::Compile(
v8::String::NewFromUtf8(CcTest::isolate(), line))->Run();
CHECK_EQ(results[i]->IsUndefined(), result->IsUndefined());
CHECK_EQ(results[i]->IsNumber(), result->IsNumber());
if (result->IsNumber()) {
@ -1230,8 +1231,8 @@ TEST(AsciiArrayJoin) {
v8::HandleScope scope(CcTest::isolate());
LocalContext context;
v8::V8::IgnoreOutOfMemoryException();
v8::Local<v8::Script> script =
v8::Script::Compile(v8::String::New(join_causing_out_of_memory));
v8::Local<v8::Script> script = v8::Script::Compile(
v8::String::NewFromUtf8(CcTest::isolate(), join_causing_out_of_memory));
v8::Local<v8::Value> result = script->Run();
// Check for out of memory state.

View File

@ -51,8 +51,8 @@ void Fail(const v8::FunctionCallbackInfo<v8::Value>& args) {
void Loop(const v8::FunctionCallbackInfo<v8::Value>& args) {
CHECK(!v8::V8::IsExecutionTerminating(args.GetIsolate()));
v8::Handle<v8::String> source =
v8::String::New("try { doloop(); fail(); } catch(e) { fail(); }");
v8::Handle<v8::String> source = v8::String::NewFromUtf8(
args.GetIsolate(), "try { doloop(); fail(); } catch(e) { fail(); }");
v8::Handle<v8::Value> result = v8::Script::Compile(source)->Run();
CHECK(result.IsEmpty());
CHECK(v8::V8::IsExecutionTerminating(args.GetIsolate()));
@ -62,19 +62,20 @@ void Loop(const v8::FunctionCallbackInfo<v8::Value>& args) {
void DoLoop(const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::TryCatch try_catch;
CHECK(!v8::V8::IsExecutionTerminating(args.GetIsolate()));
v8::Script::Compile(v8::String::New("function f() {"
" var term = true;"
" try {"
" while(true) {"
" if (term) terminate();"
" term = false;"
" }"
" fail();"
" } catch(e) {"
" fail();"
" }"
"}"
"f()"))->Run();
v8::Script::Compile(v8::String::NewFromUtf8(args.GetIsolate(),
"function f() {"
" var term = true;"
" try {"
" while(true) {"
" if (term) terminate();"
" term = false;"
" }"
" fail();"
" } catch(e) {"
" fail();"
" }"
"}"
"f()"))->Run();
CHECK(try_catch.HasCaught());
CHECK(try_catch.Exception()->IsNull());
CHECK(try_catch.Message().IsEmpty());
@ -86,11 +87,12 @@ void DoLoop(const v8::FunctionCallbackInfo<v8::Value>& args) {
void DoLoopNoCall(const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::TryCatch try_catch;
CHECK(!v8::V8::IsExecutionTerminating(args.GetIsolate()));
v8::Script::Compile(v8::String::New("var term = true;"
"while(true) {"
" if (term) terminate();"
" term = false;"
"}"))->Run();
v8::Script::Compile(v8::String::NewFromUtf8(args.GetIsolate(),
"var term = true;"
"while(true) {"
" if (term) terminate();"
" term = false;"
"}"))->Run();
CHECK(try_catch.HasCaught());
CHECK(try_catch.Exception()->IsNull());
CHECK(try_catch.Message().IsEmpty());
@ -100,14 +102,18 @@ void DoLoopNoCall(const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Handle<v8::ObjectTemplate> CreateGlobalTemplate(
v8::Isolate* isolate,
v8::FunctionCallback terminate,
v8::FunctionCallback doloop) {
v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New();
global->Set(v8::String::New("terminate"),
global->Set(v8::String::NewFromUtf8(isolate, "terminate"),
v8::FunctionTemplate::New(terminate));
global->Set(v8::String::New("fail"), v8::FunctionTemplate::New(Fail));
global->Set(v8::String::New("loop"), v8::FunctionTemplate::New(Loop));
global->Set(v8::String::New("doloop"), v8::FunctionTemplate::New(doloop));
global->Set(v8::String::NewFromUtf8(isolate, "fail"),
v8::FunctionTemplate::New(Fail));
global->Set(v8::String::NewFromUtf8(isolate, "loop"),
v8::FunctionTemplate::New(Loop));
global->Set(v8::String::NewFromUtf8(isolate, "doloop"),
v8::FunctionTemplate::New(doloop));
return global;
}
@ -117,14 +123,14 @@ v8::Handle<v8::ObjectTemplate> CreateGlobalTemplate(
TEST(TerminateOnlyV8ThreadFromThreadItself) {
v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::ObjectTemplate> global =
CreateGlobalTemplate(TerminateCurrentThread, DoLoop);
CreateGlobalTemplate(CcTest::isolate(), TerminateCurrentThread, DoLoop);
v8::Handle<v8::Context> context =
v8::Context::New(CcTest::isolate(), NULL, global);
v8::Context::Scope context_scope(context);
CHECK(!v8::V8::IsExecutionTerminating(CcTest::isolate()));
// Run a loop that will be infinite if thread termination does not work.
v8::Handle<v8::String> source =
v8::String::New("try { loop(); fail(); } catch(e) { fail(); }");
v8::Handle<v8::String> source = v8::String::NewFromUtf8(
CcTest::isolate(), "try { loop(); fail(); } catch(e) { fail(); }");
v8::Script::Compile(source)->Run();
// Test that we can run the code again after thread termination.
CHECK(!v8::V8::IsExecutionTerminating(CcTest::isolate()));
@ -136,15 +142,15 @@ TEST(TerminateOnlyV8ThreadFromThreadItself) {
// itself in a loop that performs no calls.
TEST(TerminateOnlyV8ThreadFromThreadItselfNoLoop) {
v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::ObjectTemplate> global =
CreateGlobalTemplate(TerminateCurrentThread, DoLoopNoCall);
v8::Handle<v8::ObjectTemplate> global = CreateGlobalTemplate(
CcTest::isolate(), TerminateCurrentThread, DoLoopNoCall);
v8::Handle<v8::Context> context =
v8::Context::New(CcTest::isolate(), NULL, global);
v8::Context::Scope context_scope(context);
CHECK(!v8::V8::IsExecutionTerminating(CcTest::isolate()));
// Run a loop that will be infinite if thread termination does not work.
v8::Handle<v8::String> source =
v8::String::New("try { loop(); fail(); } catch(e) { fail(); }");
v8::Handle<v8::String> source = v8::String::NewFromUtf8(
CcTest::isolate(), "try { loop(); fail(); } catch(e) { fail(); }");
v8::Script::Compile(source)->Run();
CHECK(!v8::V8::IsExecutionTerminating(CcTest::isolate()));
// Test that we can run the code again after thread termination.
@ -176,14 +182,15 @@ TEST(TerminateOnlyV8ThreadFromOtherThread) {
thread.Start();
v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::ObjectTemplate> global = CreateGlobalTemplate(Signal, DoLoop);
v8::Handle<v8::ObjectTemplate> global =
CreateGlobalTemplate(CcTest::isolate(), Signal, DoLoop);
v8::Handle<v8::Context> context =
v8::Context::New(CcTest::isolate(), NULL, global);
v8::Context::Scope context_scope(context);
CHECK(!v8::V8::IsExecutionTerminating(CcTest::isolate()));
// Run a loop that will be infinite if thread termination does not work.
v8::Handle<v8::String> source =
v8::String::New("try { loop(); fail(); } catch(e) { fail(); }");
v8::Handle<v8::String> source = v8::String::NewFromUtf8(
CcTest::isolate(), "try { loop(); fail(); } catch(e) { fail(); }");
v8::Script::Compile(source)->Run();
thread.Join();
@ -202,7 +209,8 @@ void TerminateOrReturnObject(const v8::FunctionCallbackInfo<v8::Value>& args) {
return;
}
v8::Local<v8::Object> result = v8::Object::New();
result->Set(v8::String::New("x"), v8::Integer::New(42));
result->Set(v8::String::NewFromUtf8(args.GetIsolate(), "x"),
v8::Integer::New(42));
args.GetReturnValue().Set(result);
}
@ -210,17 +218,19 @@ void TerminateOrReturnObject(const v8::FunctionCallbackInfo<v8::Value>& args) {
void LoopGetProperty(const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::TryCatch try_catch;
CHECK(!v8::V8::IsExecutionTerminating(args.GetIsolate()));
v8::Script::Compile(v8::String::New("function f() {"
" try {"
" while(true) {"
" terminate_or_return_object().x;"
" }"
" fail();"
" } catch(e) {"
" fail();"
" }"
"}"
"f()"))->Run();
v8::Script::Compile(
v8::String::NewFromUtf8(args.GetIsolate(),
"function f() {"
" try {"
" while(true) {"
" terminate_or_return_object().x;"
" }"
" fail();"
" } catch(e) {"
" fail();"
" }"
"}"
"f()"))->Run();
CHECK(try_catch.HasCaught());
CHECK(try_catch.Exception()->IsNull());
CHECK(try_catch.Message().IsEmpty());
@ -234,10 +244,12 @@ void LoopGetProperty(const v8::FunctionCallbackInfo<v8::Value>& args) {
TEST(TerminateLoadICException) {
v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New();
global->Set(v8::String::New("terminate_or_return_object"),
v8::FunctionTemplate::New(TerminateOrReturnObject));
global->Set(v8::String::New("fail"), v8::FunctionTemplate::New(Fail));
global->Set(v8::String::New("loop"),
global->Set(
v8::String::NewFromUtf8(CcTest::isolate(), "terminate_or_return_object"),
v8::FunctionTemplate::New(TerminateOrReturnObject));
global->Set(v8::String::NewFromUtf8(CcTest::isolate(), "fail"),
v8::FunctionTemplate::New(Fail));
global->Set(v8::String::NewFromUtf8(CcTest::isolate(), "loop"),
v8::FunctionTemplate::New(LoopGetProperty));
v8::Handle<v8::Context> context =
@ -245,8 +257,8 @@ TEST(TerminateLoadICException) {
v8::Context::Scope context_scope(context);
CHECK(!v8::V8::IsExecutionTerminating(CcTest::isolate()));
// Run a loop that will be infinite if thread termination does not work.
v8::Handle<v8::String> source =
v8::String::New("try { loop(); fail(); } catch(e) { fail(); }");
v8::Handle<v8::String> source = v8::String::NewFromUtf8(
CcTest::isolate(), "try { loop(); fail(); } catch(e) { fail(); }");
call_count = 0;
v8::Script::Compile(source)->Run();
// Test that we can run the code again after thread termination.
@ -259,25 +271,28 @@ TEST(TerminateLoadICException) {
void ReenterAfterTermination(const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::TryCatch try_catch;
CHECK(!v8::V8::IsExecutionTerminating(args.GetIsolate()));
v8::Script::Compile(v8::String::New("function f() {"
" var term = true;"
" try {"
" while(true) {"
" if (term) terminate();"
" term = false;"
" }"
" fail();"
" } catch(e) {"
" fail();"
" }"
"}"
"f()"))->Run();
v8::Script::Compile(v8::String::NewFromUtf8(args.GetIsolate(),
"function f() {"
" var term = true;"
" try {"
" while(true) {"
" if (term) terminate();"
" term = false;"
" }"
" fail();"
" } catch(e) {"
" fail();"
" }"
"}"
"f()"))->Run();
CHECK(try_catch.HasCaught());
CHECK(try_catch.Exception()->IsNull());
CHECK(try_catch.Message().IsEmpty());
CHECK(!try_catch.CanContinue());
CHECK(v8::V8::IsExecutionTerminating(args.GetIsolate()));
v8::Script::Compile(v8::String::New("function f() { fail(); } f()"))->Run();
v8::Script::Compile(v8::String::NewFromUtf8(args.GetIsolate(),
"function f() { fail(); } f()"))
->Run();
}
@ -285,31 +300,36 @@ void ReenterAfterTermination(const v8::FunctionCallbackInfo<v8::Value>& args) {
// (has not yet unwound the 0-level JS frame) does not crash.
TEST(TerminateAndReenterFromThreadItself) {
v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::ObjectTemplate> global =
CreateGlobalTemplate(TerminateCurrentThread, ReenterAfterTermination);
v8::Handle<v8::ObjectTemplate> global = CreateGlobalTemplate(
CcTest::isolate(), TerminateCurrentThread, ReenterAfterTermination);
v8::Handle<v8::Context> context =
v8::Context::New(CcTest::isolate(), NULL, global);
v8::Context::Scope context_scope(context);
CHECK(!v8::V8::IsExecutionTerminating());
v8::Handle<v8::String> source =
v8::String::New("try { loop(); fail(); } catch(e) { fail(); }");
v8::Handle<v8::String> source = v8::String::NewFromUtf8(
CcTest::isolate(), "try { loop(); fail(); } catch(e) { fail(); }");
v8::Script::Compile(source)->Run();
CHECK(!v8::V8::IsExecutionTerminating(CcTest::isolate()));
// Check we can run JS again after termination.
CHECK(v8::Script::Compile(v8::String::New("function f() { return true; }"
"f()"))->Run()->IsTrue());
CHECK(v8::Script::Compile(
v8::String::NewFromUtf8(CcTest::isolate(),
"function f() { return true; }"
"f()"))
->Run()
->IsTrue());
}
void DoLoopCancelTerminate(const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::TryCatch try_catch;
CHECK(!v8::V8::IsExecutionTerminating());
v8::Script::Compile(v8::String::New("var term = true;"
"while(true) {"
" if (term) terminate();"
" term = false;"
"}"
"fail();"))->Run();
v8::Script::Compile(v8::String::NewFromUtf8(args.GetIsolate(),
"var term = true;"
"while(true) {"
" if (term) terminate();"
" term = false;"
"}"
"fail();"))->Run();
CHECK(try_catch.HasCaught());
CHECK(try_catch.Exception()->IsNull());
CHECK(try_catch.Message().IsEmpty());
@ -326,13 +346,13 @@ void DoLoopCancelTerminate(const v8::FunctionCallbackInfo<v8::Value>& args) {
TEST(TerminateCancelTerminateFromThreadItself) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
v8::Handle<v8::ObjectTemplate> global =
CreateGlobalTemplate(TerminateCurrentThread, DoLoopCancelTerminate);
v8::Handle<v8::ObjectTemplate> global = CreateGlobalTemplate(
isolate, TerminateCurrentThread, DoLoopCancelTerminate);
v8::Handle<v8::Context> context = v8::Context::New(isolate, NULL, global);
v8::Context::Scope context_scope(context);
CHECK(!v8::V8::IsExecutionTerminating(CcTest::isolate()));
v8::Handle<v8::String> source =
v8::String::New("try { doloop(); } catch(e) { fail(); } 'completed';");
v8::Handle<v8::String> source = v8::String::NewFromUtf8(
isolate, "try { doloop(); } catch(e) { fail(); } 'completed';");
// Check that execution completed with correct return value.
CHECK(v8::Script::Compile(source)->Run()->Equals(v8_str("completed")));
}

View File

@ -58,7 +58,8 @@ class ThreadA : public v8::internal::Thread {
// Fill String.search cache.
v8::Handle<v8::Script> script = v8::Script::Compile(
v8::String::New(
v8::String::NewFromUtf8(
isolate,
"for (var i = 0; i < 3; i++) {"
" var result = \"a\".search(\"a\");"
" if (result != 0) throw \"result: \" + result + \" @\" + i;"

View File

@ -69,7 +69,7 @@ static void WeakPointerCallback(v8::Isolate* isolate,
void* id) {
ASSERT(id == reinterpret_cast<void*>(1234));
NumberOfWeakCalls++;
handle->Dispose();
handle->Reset();
}

View File

@ -69,7 +69,7 @@ static void WeakPointerCallback(v8::Isolate* isolate,
void* id) {
ASSERT(id == reinterpret_cast<void*>(1234));
NumberOfWeakCalls++;
handle->Dispose();
handle->Reset();
}