Commit c0c5efb9 authored by jochen@chromium.org's avatar jochen@chromium.org

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
parent 6aec0d39
...@@ -30,12 +30,6 @@ ...@@ -30,12 +30,6 @@
'v8_code': 1, 'v8_code': 1,
'generated_file': '<(SHARED_INTERMEDIATE_DIR)/resources.cc', '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'], 'includes': ['../../build/toolchain.gypi', '../../build/features.gypi'],
'targets': [ 'targets': [
{ {
......
...@@ -255,7 +255,7 @@ class LocalContext { ...@@ -255,7 +255,7 @@ class LocalContext {
virtual ~LocalContext() { virtual ~LocalContext() {
v8::HandleScope scope(isolate_); v8::HandleScope scope(isolate_);
v8::Local<v8::Context>::New(isolate_, context_)->Exit(); v8::Local<v8::Context>::New(isolate_, context_)->Exit();
context_.Dispose(); context_.Reset();
} }
v8::Context* operator->() { v8::Context* operator->() {
...@@ -294,7 +294,7 @@ static inline v8::Local<v8::Value> v8_num(double x) { ...@@ -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) { 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) { ...@@ -305,7 +305,8 @@ static inline v8::Local<v8::Script> v8_compile(const char* x) {
// Helper function that compiles and runs the source. // Helper function that compiles and runs the source.
static inline v8::Local<v8::Value> CompileRun(const char* 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, ...@@ -314,10 +315,12 @@ static inline v8::Local<v8::Value> CompileRunWithOrigin(const char* source,
const char* origin_url, const char* origin_url,
int line_number, int line_number,
int column_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(line_number),
v8::Integer::New(column_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();
} }
......
...@@ -277,8 +277,8 @@ static void HandleAllocatingGetter( ...@@ -277,8 +277,8 @@ static void HandleAllocatingGetter(
const v8::PropertyCallbackInfo<v8::Value>& info) { const v8::PropertyCallbackInfo<v8::Value>& info) {
ApiTestFuzzer::Fuzz(); ApiTestFuzzer::Fuzz();
for (int i = 0; i < C; i++) for (int i = 0; i < C; i++)
v8::String::New("foo"); v8::String::NewFromUtf8(info.GetIsolate(), "foo");
info.GetReturnValue().Set(v8::String::New("foo")); info.GetReturnValue().Set(v8::String::NewFromUtf8(info.GetIsolate(), "foo"));
} }
...@@ -289,7 +289,8 @@ THREADED_TEST(HandleScopePop) { ...@@ -289,7 +289,8 @@ THREADED_TEST(HandleScopePop) {
obj->SetAccessor(v8_str("one"), HandleAllocatingGetter<1>); obj->SetAccessor(v8_str("one"), HandleAllocatingGetter<1>);
obj->SetAccessor(v8_str("many"), HandleAllocatingGetter<1024>); obj->SetAccessor(v8_str("many"), HandleAllocatingGetter<1024>);
v8::Handle<v8::Object> inst = obj->NewInstance(); 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(); i::Isolate* isolate = CcTest::i_isolate();
int count_before = i::HandleScope::NumberOfHandles(isolate); int count_before = i::HandleScope::NumberOfHandles(isolate);
{ {
...@@ -309,15 +310,18 @@ static void CheckAccessorArgsCorrect( ...@@ -309,15 +310,18 @@ static void CheckAccessorArgsCorrect(
const v8::PropertyCallbackInfo<v8::Value>& info) { const v8::PropertyCallbackInfo<v8::Value>& info) {
CHECK(info.GetIsolate() == CcTest::isolate()); CHECK(info.GetIsolate() == CcTest::isolate());
CHECK(info.This() == info.Holder()); 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(); ApiTestFuzzer::Fuzz();
CHECK(info.GetIsolate() == CcTest::isolate()); CHECK(info.GetIsolate() == CcTest::isolate());
CHECK(info.This() == info.Holder()); 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); CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags);
CHECK(info.GetIsolate() == CcTest::isolate()); CHECK(info.GetIsolate() == CcTest::isolate());
CHECK(info.This() == info.Holder()); 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); info.GetReturnValue().Set(17);
} }
...@@ -329,10 +333,12 @@ THREADED_TEST(DirectCall) { ...@@ -329,10 +333,12 @@ THREADED_TEST(DirectCall) {
obj->SetAccessor(v8_str("xxx"), obj->SetAccessor(v8_str("xxx"),
CheckAccessorArgsCorrect, CheckAccessorArgsCorrect,
NULL, NULL,
v8::String::New("data")); v8::String::NewFromUtf8(context->GetIsolate(), "data"));
v8::Handle<v8::Object> inst = obj->NewInstance(); v8::Handle<v8::Object> inst = obj->NewInstance();
context->Global()->Set(v8::String::New("obj"), inst); context->Global()->Set(v8::String::NewFromUtf8(context->GetIsolate(), "obj"),
Local<Script> scr = v8::Script::Compile(v8::String::New("obj.xxx")); inst);
Local<Script> scr = v8::Script::Compile(
v8::String::NewFromUtf8(context->GetIsolate(), "obj.xxx"));
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
Local<Value> result = scr->Run(); Local<Value> result = scr->Run();
CHECK(!result.IsEmpty()); CHECK(!result.IsEmpty());
...@@ -354,10 +360,12 @@ THREADED_TEST(EmptyResult) { ...@@ -354,10 +360,12 @@ THREADED_TEST(EmptyResult) {
v8::Isolate* isolate = context->GetIsolate(); v8::Isolate* isolate = context->GetIsolate();
v8::HandleScope scope(isolate); v8::HandleScope scope(isolate);
v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); 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(); v8::Handle<v8::Object> inst = obj->NewInstance();
context->Global()->Set(v8::String::New("obj"), inst); context->Global()->Set(v8::String::NewFromUtf8(isolate, "obj"), inst);
Local<Script> scr = v8::Script::Compile(v8::String::New("obj.xxx")); Local<Script> scr =
v8::Script::Compile(v8::String::NewFromUtf8(isolate, "obj.xxx"));
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
Local<Value> result = scr->Run(); Local<Value> result = scr->Run();
CHECK(result == v8::Undefined(isolate)); CHECK(result == v8::Undefined(isolate));
...@@ -372,11 +380,13 @@ THREADED_TEST(NoReuseRegress) { ...@@ -372,11 +380,13 @@ THREADED_TEST(NoReuseRegress) {
v8::HandleScope scope(isolate); v8::HandleScope scope(isolate);
{ {
v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); 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; LocalContext context;
v8::Handle<v8::Object> inst = obj->NewInstance(); v8::Handle<v8::Object> inst = obj->NewInstance();
context->Global()->Set(v8::String::New("obj"), inst); context->Global()->Set(v8::String::NewFromUtf8(isolate, "obj"), inst);
Local<Script> scr = v8::Script::Compile(v8::String::New("obj.xxx")); Local<Script> scr =
v8::Script::Compile(v8::String::NewFromUtf8(isolate, "obj.xxx"));
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
Local<Value> result = scr->Run(); Local<Value> result = scr->Run();
CHECK(result == v8::Undefined(isolate)); CHECK(result == v8::Undefined(isolate));
...@@ -387,11 +397,12 @@ THREADED_TEST(NoReuseRegress) { ...@@ -387,11 +397,12 @@ THREADED_TEST(NoReuseRegress) {
obj->SetAccessor(v8_str("xxx"), obj->SetAccessor(v8_str("xxx"),
CheckAccessorArgsCorrect, CheckAccessorArgsCorrect,
NULL, NULL,
v8::String::New("data")); v8::String::NewFromUtf8(isolate, "data"));
LocalContext context; LocalContext context;
v8::Handle<v8::Object> inst = obj->NewInstance(); v8::Handle<v8::Object> inst = obj->NewInstance();
context->Global()->Set(v8::String::New("obj"), inst); context->Global()->Set(v8::String::NewFromUtf8(isolate, "obj"), inst);
Local<Script> scr = v8::Script::Compile(v8::String::New("obj.xxx")); Local<Script> scr =
v8::Script::Compile(v8::String::NewFromUtf8(isolate, "obj.xxx"));
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
Local<Value> result = scr->Run(); Local<Value> result = scr->Run();
CHECK(!result.IsEmpty()); CHECK(!result.IsEmpty());
...@@ -436,7 +447,8 @@ THREADED_TEST(Regress1054726) { ...@@ -436,7 +447,8 @@ THREADED_TEST(Regress1054726) {
"}; result"))->Run(); "}; result"))->Run();
CHECK_EQ(v8_str("ggggg"), result); CHECK_EQ(v8_str("ggggg"), result);
result = Script::Compile(String::New( result = Script::Compile(String::NewFromUtf8(
env->GetIsolate(),
"var result = '';" "var result = '';"
"for (var i = 0; i < 5; i++) {" "for (var i = 0; i < 5; i++) {"
" try { obj.x = i; } catch (e) { result += e; }" " try { obj.x = i; } catch (e) { result += e; }"
...@@ -458,7 +470,8 @@ THREADED_TEST(Gc) { ...@@ -458,7 +470,8 @@ THREADED_TEST(Gc) {
v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New();
obj->SetAccessor(v8_str("xxx"), AllocGetter); obj->SetAccessor(v8_str("xxx"), AllocGetter);
env->Global()->Set(v8_str("obj"), obj->NewInstance()); env->Global()->Set(v8_str("obj"), obj->NewInstance());
Script::Compile(String::New( Script::Compile(String::NewFromUtf8(
env->GetIsolate(),
"var last = [];" "var last = [];"
"for (var i = 0; i < 2048; i++) {" "for (var i = 0; i < 2048; i++) {"
" var result = obj.xxx;" " var result = obj.xxx;"
...@@ -491,7 +504,8 @@ THREADED_TEST(StackIteration) { ...@@ -491,7 +504,8 @@ THREADED_TEST(StackIteration) {
i::StringStream::ClearMentionedObjectCache(isolate); i::StringStream::ClearMentionedObjectCache(isolate);
obj->SetAccessor(v8_str("xxx"), StackCheck); obj->SetAccessor(v8_str("xxx"), StackCheck);
env->Global()->Set(v8_str("obj"), obj->NewInstance()); env->Global()->Set(v8_str("obj"), obj->NewInstance());
Script::Compile(String::New( Script::Compile(String::NewFromUtf8(
env->GetIsolate(),
"function foo() {" "function foo() {"
" return obj.xxx;" " return obj.xxx;"
"}" "}"
...@@ -518,7 +532,8 @@ THREADED_TEST(HandleScopeSegment) { ...@@ -518,7 +532,8 @@ THREADED_TEST(HandleScopeSegment) {
v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New();
obj->SetAccessor(v8_str("xxx"), AllocateHandles); obj->SetAccessor(v8_str("xxx"), AllocateHandles);
env->Global()->Set(v8_str("obj"), obj->NewInstance()); 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;" "var result;"
"for (var i = 0; i < 4; i++)" "for (var i = 0; i < 4; i++)"
" result = obj.xxx;" " result = obj.xxx;"
......
...@@ -148,10 +148,11 @@ TEST(StressJS) { ...@@ -148,10 +148,11 @@ TEST(StressJS) {
map->AppendDescriptor(&d, witness); map->AppendDescriptor(&d, witness);
// Add the Foo constructor the global object. // 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. // Call the accessor through JavaScript.
v8::Handle<v8::Value> result = v8::Handle<v8::Value> result = v8::Script::Compile(
v8::Script::Compile(v8::String::New("(new Foo).get"))->Run(); v8::String::NewFromUtf8(CcTest::isolate(), "(new Foo).get"))->Run();
CHECK_EQ(42, result->Int32Value()); CHECK_EQ(42, result->Int32Value());
env->Exit(); env->Exit();
} }
......
This diff is collapsed.
...@@ -331,7 +331,8 @@ TEST(Regression236) { ...@@ -331,7 +331,8 @@ TEST(Regression236) {
TEST(GetScriptLineNumber) { TEST(GetScriptLineNumber) {
LocalContext context; LocalContext context;
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::New("test")); v8::ScriptOrigin origin =
v8::ScriptOrigin(v8::String::NewFromUtf8(CcTest::isolate(), "test"));
const char function_f[] = "function f() {}"; const char function_f[] = "function f() {}";
const int max_rows = 1000; const int max_rows = 1000;
const int buffer_size = max_rows + sizeof(function_f); const int buffer_size = max_rows + sizeof(function_f);
...@@ -343,10 +344,12 @@ TEST(GetScriptLineNumber) { ...@@ -343,10 +344,12 @@ TEST(GetScriptLineNumber) {
if (i > 0) if (i > 0)
buffer[i - 1] = '\n'; buffer[i - 1] = '\n';
OS::MemCopy(&buffer[i], function_f, sizeof(function_f) - 1); 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::Script::Compile(script_body, &origin)->Run();
v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( v8::Local<v8::Function> f =
context->Global()->Get(v8::String::New("f"))); v8::Local<v8::Function>::Cast(context->Global()->Get(
v8::String::NewFromUtf8(CcTest::isolate(), "f")));
CHECK_EQ(i, f->GetScriptLineNumber()); CHECK_EQ(i, f->GetScriptLineNumber());
} }
} }
...@@ -364,7 +367,8 @@ TEST(OptimizedCodeSharing) { ...@@ -364,7 +367,8 @@ TEST(OptimizedCodeSharing) {
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
LocalContext env; 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() {" CompileRun("function MakeClosure() {"
" return function() { return x; };" " return function() { return x; };"
"}" "}"
......
This diff is collapsed.
This diff is collapsed.
...@@ -42,8 +42,7 @@ class HandleArray : public Malloced { ...@@ -42,8 +42,7 @@ class HandleArray : public Malloced {
void Reset() { void Reset() {
for (unsigned i = 0; i < kArraySize; i++) { for (unsigned i = 0; i < kArraySize; i++) {
if (handles_[i].IsEmpty()) continue; if (handles_[i].IsEmpty()) continue;
handles_[i].Dispose(); handles_[i].Reset();
handles_[i].Clear();
} }
} }
v8::Persistent<v8::Value> handles_[kArraySize]; v8::Persistent<v8::Value> handles_[kArraySize];
......
...@@ -56,7 +56,7 @@ class DeclarationContext { ...@@ -56,7 +56,7 @@ class DeclarationContext {
HandleScope scope(isolate); HandleScope scope(isolate);
Local<Context> context = Local<Context>::New(isolate, context_); Local<Context> context = Local<Context>::New(isolate, context_);
context->Exit(); context->Exit();
context_.Dispose(); context_.Reset();
} }
} }
...@@ -147,7 +147,8 @@ void DeclarationContext::Check(const char* source, ...@@ -147,7 +147,8 @@ void DeclarationContext::Check(const char* source,
HandleScope scope(CcTest::isolate()); HandleScope scope(CcTest::isolate());
TryCatch catcher; TryCatch catcher;
catcher.SetVerbose(true); 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) { if (expectations == EXPECT_ERROR) {
CHECK(script.IsEmpty()); CHECK(script.IsEmpty());
return; return;
...@@ -729,7 +730,8 @@ class SimpleContext { ...@@ -729,7 +730,8 @@ class SimpleContext {
HandleScope scope(context_->GetIsolate()); HandleScope scope(context_->GetIsolate());
TryCatch catcher; TryCatch catcher;
catcher.SetVerbose(true); 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) { if (expectations == EXPECT_ERROR) {
CHECK(script.IsEmpty()); CHECK(script.IsEmpty());
return; return;
......
...@@ -235,8 +235,8 @@ TEST(DeoptimizeRecursive) { ...@@ -235,8 +235,8 @@ TEST(DeoptimizeRecursive) {
CHECK_EQ(11, env->Global()->Get(v8_str("calls"))->Int32Value()); CHECK_EQ(11, env->Global()->Get(v8_str("calls"))->Int32Value());
CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(CcTest::i_isolate())); CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(CcTest::i_isolate()));
v8::Local<v8::Function> fun = v8::Local<v8::Function> fun = v8::Local<v8::Function>::Cast(
v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f"))); env->Global()->Get(v8::String::NewFromUtf8(CcTest::isolate(), "f")));
CHECK(!fun.IsEmpty()); CHECK(!fun.IsEmpty());
} }
......
...@@ -94,8 +94,8 @@ static void CheckFunctionName(v8::Handle<v8::Script> script, ...@@ -94,8 +94,8 @@ static void CheckFunctionName(v8::Handle<v8::Script> script,
} }
static v8::Handle<v8::Script> Compile(const char* src) { static v8::Handle<v8::Script> Compile(v8::Isolate* isolate, const char* src) {
return v8::Script::Compile(v8::String::New(src)); return v8::Script::Compile(v8::String::NewFromUtf8(isolate, src));
} }
...@@ -104,6 +104,7 @@ TEST(GlobalProperty) { ...@@ -104,6 +104,7 @@ TEST(GlobalProperty) {
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile( v8::Handle<v8::Script> script = Compile(
CcTest::isolate(),
"fun1 = function() { return 1; }\n" "fun1 = function() { return 1; }\n"
"fun2 = function() { return 2; }\n"); "fun2 = function() { return 2; }\n");
CheckFunctionName(script, "return 1", "fun1"); CheckFunctionName(script, "return 1", "fun1");
...@@ -116,6 +117,7 @@ TEST(GlobalVar) { ...@@ -116,6 +117,7 @@ TEST(GlobalVar) {
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile( v8::Handle<v8::Script> script = Compile(
CcTest::isolate(),
"var fun1 = function() { return 1; }\n" "var fun1 = function() { return 1; }\n"
"var fun2 = function() { return 2; }\n"); "var fun2 = function() { return 2; }\n");
CheckFunctionName(script, "return 1", "fun1"); CheckFunctionName(script, "return 1", "fun1");
...@@ -128,6 +130,7 @@ TEST(LocalVar) { ...@@ -128,6 +130,7 @@ TEST(LocalVar) {
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile( v8::Handle<v8::Script> script = Compile(
CcTest::isolate(),
"function outer() {\n" "function outer() {\n"
" var fun1 = function() { return 1; }\n" " var fun1 = function() { return 1; }\n"
" var fun2 = function() { return 2; }\n" " var fun2 = function() { return 2; }\n"
...@@ -142,6 +145,7 @@ TEST(InConstructor) { ...@@ -142,6 +145,7 @@ TEST(InConstructor) {
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile( v8::Handle<v8::Script> script = Compile(
CcTest::isolate(),
"function MyClass() {\n" "function MyClass() {\n"
" this.method1 = function() { return 1; }\n" " this.method1 = function() { return 1; }\n"
" this.method2 = function() { return 2; }\n" " this.method2 = function() { return 2; }\n"
...@@ -156,6 +160,7 @@ TEST(Factory) { ...@@ -156,6 +160,7 @@ TEST(Factory) {
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile( v8::Handle<v8::Script> script = Compile(
CcTest::isolate(),
"function createMyObj() {\n" "function createMyObj() {\n"
" var obj = {};\n" " var obj = {};\n"
" obj.method1 = function() { return 1; }\n" " obj.method1 = function() { return 1; }\n"
...@@ -172,6 +177,7 @@ TEST(Static) { ...@@ -172,6 +177,7 @@ TEST(Static) {
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile( v8::Handle<v8::Script> script = Compile(
CcTest::isolate(),
"function MyClass() {}\n" "function MyClass() {}\n"
"MyClass.static1 = function() { return 1; }\n" "MyClass.static1 = function() { return 1; }\n"
"MyClass.static2 = function() { return 2; }\n" "MyClass.static2 = function() { return 2; }\n"
...@@ -190,6 +196,7 @@ TEST(Prototype) { ...@@ -190,6 +196,7 @@ TEST(Prototype) {
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile( v8::Handle<v8::Script> script = Compile(
CcTest::isolate(),
"function MyClass() {}\n" "function MyClass() {}\n"
"MyClass.prototype.method1 = function() { return 1; }\n" "MyClass.prototype.method1 = function() { return 1; }\n"
"MyClass.prototype.method2 = function() { return 2; }\n" "MyClass.prototype.method2 = function() { return 2; }\n"
...@@ -208,6 +215,7 @@ TEST(ObjectLiteral) { ...@@ -208,6 +215,7 @@ TEST(ObjectLiteral) {
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile( v8::Handle<v8::Script> script = Compile(
CcTest::isolate(),
"function MyClass() {}\n" "function MyClass() {}\n"
"MyClass.prototype = {\n" "MyClass.prototype = {\n"
" method1: function() { return 1; },\n" " method1: function() { return 1; },\n"
...@@ -222,6 +230,7 @@ TEST(AsParameter) { ...@@ -222,6 +230,7 @@ TEST(AsParameter) {
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile( v8::Handle<v8::Script> script = Compile(
CcTest::isolate(),
"function f1(a) { return a(); }\n" "function f1(a) { return a(); }\n"
"function f2(a, b) { return a() + b(); }\n" "function f2(a, b) { return a() + b(); }\n"
"var result1 = f1(function() { return 1; })\n" "var result1 = f1(function() { return 1; })\n"
...@@ -238,6 +247,7 @@ TEST(MultipleFuncsConditional) { ...@@ -238,6 +247,7 @@ TEST(MultipleFuncsConditional) {
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile( v8::Handle<v8::Script> script = Compile(
CcTest::isolate(),
"fun1 = 0 ?\n" "fun1 = 0 ?\n"
" function() { return 1; } :\n" " function() { return 1; } :\n"
" function() { return 2; }"); " function() { return 2; }");
...@@ -251,6 +261,7 @@ TEST(MultipleFuncsInLiteral) { ...@@ -251,6 +261,7 @@ TEST(MultipleFuncsInLiteral) {
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile( v8::Handle<v8::Script> script = Compile(
CcTest::isolate(),
"function MyClass() {}\n" "function MyClass() {}\n"
"MyClass.prototype = {\n" "MyClass.prototype = {\n"
" method1: 0 ? function() { return 1; } :\n" " method1: 0 ? function() { return 1; } :\n"
...@@ -265,6 +276,7 @@ TEST(AnonymousInAnonymousClosure1) { ...@@ -265,6 +276,7 @@ TEST(AnonymousInAnonymousClosure1) {
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile( v8::Handle<v8::Script> script = Compile(
CcTest::isolate(),
"(function() {\n" "(function() {\n"
" (function() {\n" " (function() {\n"
" var a = 1;\n" " var a = 1;\n"
...@@ -284,6 +296,7 @@ TEST(AnonymousInAnonymousClosure2) { ...@@ -284,6 +296,7 @@ TEST(AnonymousInAnonymousClosure2) {
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile( v8::Handle<v8::Script> script = Compile(
CcTest::isolate(),
"(function() {\n" "(function() {\n"
" (function() {\n" " (function() {\n"
" var a = 1;\n" " var a = 1;\n"
...@@ -300,6 +313,7 @@ TEST(NamedInAnonymousClosure) { ...@@ -300,6 +313,7 @@ TEST(NamedInAnonymousClosure) {
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile( v8::Handle<v8::Script> script = Compile(
CcTest::isolate(),
"var foo = function() {\n" "var foo = function() {\n"
" (function named() {\n" " (function named() {\n"
" var a = 1;\n" " var a = 1;\n"
...@@ -317,6 +331,7 @@ TEST(Issue380) { ...@@ -317,6 +331,7 @@ TEST(Issue380) {
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile( v8::Handle<v8::Script> script = Compile(
CcTest::isolate(),
"function a() {\n" "function a() {\n"
"var result = function(p,a,c,k,e,d)" "var result = function(p,a,c,k,e,d)"
"{return p}(\"if blah blah\",62,1976,\'a|b\'.split(\'|\'),0,{})\n" "{return p}(\"if blah blah\",62,1976,\'a|b\'.split(\'|\'),0,{})\n"
...@@ -330,6 +345,7 @@ TEST(MultipleAssignments) { ...@@ -330,6 +345,7 @@ TEST(MultipleAssignments) {
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile( v8::Handle<v8::Script> script = Compile(
CcTest::isolate(),
"var fun1 = fun2 = function () { return 1; }\n" "var fun1 = fun2 = function () { return 1; }\n"
"var bar1 = bar2 = bar3 = function () { return 2; }\n" "var bar1 = bar2 = bar3 = function () { return 2; }\n"
"foo1 = foo2 = function () { return 3; }\n" "foo1 = foo2 = function () { return 3; }\n"
...@@ -346,6 +362,7 @@ TEST(AsConstructorParameter) { ...@@ -346,6 +362,7 @@ TEST(AsConstructorParameter) {
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile( v8::Handle<v8::Script> script = Compile(
CcTest::isolate(),
"function Foo() {}\n" "function Foo() {}\n"
"var foo = new Foo(function() { return 1; })\n" "var foo = new Foo(function() { return 1; })\n"
"var bar = new Foo(function() { return 2; }, function() { return 3; })"); "var bar = new Foo(function() { return 2; }, function() { return 3; })");
...@@ -360,6 +377,7 @@ TEST(FactoryHashmap) { ...@@ -360,6 +377,7 @@ TEST(FactoryHashmap) {
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile( v8::Handle<v8::Script> script = Compile(
CcTest::isolate(),
"function createMyObj() {\n" "function createMyObj() {\n"
" var obj = {};\n" " var obj = {};\n"
" obj[\"method1\"] = function() { return 1; }\n" " obj[\"method1\"] = function() { return 1; }\n"
...@@ -376,6 +394,7 @@ TEST(FactoryHashmapVariable) { ...@@ -376,6 +394,7 @@ TEST(FactoryHashmapVariable) {
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile( v8::Handle<v8::Script> script = Compile(
CcTest::isolate(),
"function createMyObj() {\n" "function createMyObj() {\n"
" var obj = {};\n" " var obj = {};\n"
" var methodName = \"method1\";\n" " var methodName = \"method1\";\n"
...@@ -395,6 +414,7 @@ TEST(FactoryHashmapConditional) { ...@@ -395,6 +414,7 @@ TEST(FactoryHashmapConditional) {
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile( v8::Handle<v8::Script> script = Compile(
CcTest::isolate(),
"function createMyObj() {\n" "function createMyObj() {\n"
" var obj = {};\n" " var obj = {};\n"
" obj[0 ? \"method1\" : \"method2\"] = function() { return 1; }\n" " obj[0 ? \"method1\" : \"method2\"] = function() { return 1; }\n"
...@@ -410,6 +430,7 @@ TEST(GlobalAssignmentAndCall) { ...@@ -410,6 +430,7 @@ TEST(GlobalAssignmentAndCall) {
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile( v8::Handle<v8::Script> script = Compile(
CcTest::isolate(),
"var Foo = function() {\n" "var Foo = function() {\n"
" return 1;\n" " return 1;\n"
"}();\n" "}();\n"
...@@ -428,6 +449,7 @@ TEST(AssignmentAndCall) { ...@@ -428,6 +449,7 @@ TEST(AssignmentAndCall) {
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile( v8::Handle<v8::Script> script = Compile(
CcTest::isolate(),
"(function Enclosing() {\n" "(function Enclosing() {\n"
" var Foo;\n" " var Foo;\n"
" Foo = function() {\n" " Foo = function() {\n"
...@@ -451,6 +473,7 @@ TEST(MethodAssignmentInAnonymousFunctionCall) { ...@@ -451,6 +473,7 @@ TEST(MethodAssignmentInAnonymousFunctionCall) {
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile( v8::Handle<v8::Script> script = Compile(
CcTest::isolate(),
"(function () {\n" "(function () {\n"
" var EventSource = function () { };\n" " var EventSource = function () { };\n"
" EventSource.prototype.addListener = function () {\n" " EventSource.prototype.addListener = function () {\n"
...@@ -467,6 +490,7 @@ TEST(ReturnAnonymousFunction) { ...@@ -467,6 +490,7 @@ TEST(ReturnAnonymousFunction) {
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Script> script = Compile( v8::Handle<v8::Script> script = Compile(
CcTest::isolate(),
"(function() {\n" "(function() {\n"
" function wrapCode() {\n" " function wrapCode() {\n"
" return function () {\n" " return function () {\n"
......
...@@ -255,7 +255,8 @@ TEST(BoundFunctionInSnapshot) { ...@@ -255,7 +255,8 @@ TEST(BoundFunctionInSnapshot) {
const v8::HeapGraphNode* f = const v8::HeapGraphNode* f =
GetProperty(global, v8::HeapGraphEdge::kProperty, "boundFunction"); GetProperty(global, v8::HeapGraphEdge::kProperty, "boundFunction");
CHECK(f); 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 = const v8::HeapGraphNode* bindings =
GetProperty(f, v8::HeapGraphEdge::kInternal, "bindings"); GetProperty(f, v8::HeapGraphEdge::kInternal, "bindings");
CHECK_NE(NULL, bindings); CHECK_NE(NULL, bindings);
...@@ -1083,8 +1084,8 @@ TEST(HeapSnapshotGetSnapshotObjectId) { ...@@ -1083,8 +1084,8 @@ TEST(HeapSnapshotGetSnapshotObjectId) {
GetProperty(global, v8::HeapGraphEdge::kProperty, "globalObject"); GetProperty(global, v8::HeapGraphEdge::kProperty, "globalObject");
CHECK(global_object); CHECK(global_object);
v8::Local<v8::Value> globalObjectHandle = v8::Local<v8::Value> globalObjectHandle = env->Global()->Get(
env->Global()->Get(v8::String::New("globalObject")); v8::String::NewFromUtf8(env->GetIsolate(), "globalObject"));
CHECK(!globalObjectHandle.IsEmpty()); CHECK(!globalObjectHandle.IsEmpty());
CHECK(globalObjectHandle->IsObject()); CHECK(globalObjectHandle->IsObject());
...@@ -1719,7 +1720,8 @@ TEST(HiddenPropertiesFastCase) { ...@@ -1719,7 +1720,8 @@ TEST(HiddenPropertiesFastCase) {
GetProperty(c, v8::HeapGraphEdge::kInternal, "hidden_properties"); GetProperty(c, v8::HeapGraphEdge::kInternal, "hidden_properties");
CHECK_EQ(NULL, hidden_props); 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()); CHECK(!cHandle.IsEmpty() && cHandle->IsObject());
cHandle->ToObject()->SetHiddenValue(v8_str("key"), v8_str("val")); cHandle->ToObject()->SetHiddenValue(v8_str("key"), v8_str("val"));
...@@ -1763,7 +1765,7 @@ bool HasWeakGlobalHandle() { ...@@ -1763,7 +1765,7 @@ bool HasWeakGlobalHandle() {
static void PersistentHandleCallback(v8::Isolate* isolate, static void PersistentHandleCallback(v8::Isolate* isolate,
v8::Persistent<v8::Value>* handle, v8::Persistent<v8::Value>* handle,
void*) { void*) {
handle->Dispose(); handle->Reset();
} }
...@@ -2036,7 +2038,8 @@ const char* HeapProfilerExtension::kSource = ...@@ -2036,7 +2038,8 @@ const char* HeapProfilerExtension::kSource =
v8::Handle<v8::FunctionTemplate> HeapProfilerExtension::GetNativeFunction( v8::Handle<v8::FunctionTemplate> HeapProfilerExtension::GetNativeFunction(
v8::Handle<v8::String> name) { 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( return v8::FunctionTemplate::New(
HeapProfilerExtension::FindUntrackedObjects); HeapProfilerExtension::FindUntrackedObjects);
} else { } else {
...@@ -2212,7 +2215,7 @@ TEST(TrackHeapAllocations) { ...@@ -2212,7 +2215,7 @@ TEST(TrackHeapAllocations) {
CompileRun(record_trace_tree_source); CompileRun(record_trace_tree_source);
const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot( const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(
v8::String::New("Test")); v8::String::NewFromUtf8(env->GetIsolate(), "Test"));
i::HeapSnapshotsCollection* collection = ToInternal(snapshot)->collection(); i::HeapSnapshotsCollection* collection = ToInternal(snapshot)->collection();
AllocationTracker* tracker = collection->allocation_tracker(); AllocationTracker* tracker = collection->allocation_tracker();
CHECK_NE(NULL, tracker); CHECK_NE(NULL, tracker);
...@@ -2265,7 +2268,7 @@ TEST(TrackBumpPointerAllocations) { ...@@ -2265,7 +2268,7 @@ TEST(TrackBumpPointerAllocations) {
CompileRun(inline_heap_allocation_source); CompileRun(inline_heap_allocation_source);
const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot( const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(
v8::String::New("Test2")); v8::String::NewFromUtf8(env->GetIsolate(), "Test2"));
i::HeapSnapshotsCollection* collection = ToInternal(snapshot)->collection(); i::HeapSnapshotsCollection* collection = ToInternal(snapshot)->collection();
AllocationTracker* tracker = collection->allocation_tracker(); AllocationTracker* tracker = collection->allocation_tracker();
CHECK_NE(NULL, tracker); CHECK_NE(NULL, tracker);
...@@ -2293,7 +2296,7 @@ TEST(TrackBumpPointerAllocations) { ...@@ -2293,7 +2296,7 @@ TEST(TrackBumpPointerAllocations) {
CompileRun(inline_heap_allocation_source); CompileRun(inline_heap_allocation_source);
const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot( const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(
v8::String::New("Test1")); v8::String::NewFromUtf8(env->GetIsolate(), "Test1"));
i::HeapSnapshotsCollection* collection = ToInternal(snapshot)->collection(); i::HeapSnapshotsCollection* collection = ToInternal(snapshot)->collection();
AllocationTracker* tracker = collection->allocation_tracker(); AllocationTracker* tracker = collection->allocation_tracker();
CHECK_NE(NULL, tracker); CHECK_NE(NULL, tracker);
......
...@@ -397,7 +397,7 @@ static void TestWeakGlobalHandleCallback(v8::Isolate* isolate, ...@@ -397,7 +397,7 @@ static void TestWeakGlobalHandleCallback(v8::Isolate* isolate,
v8::Persistent<v8::Value>* handle, v8::Persistent<v8::Value>* handle,
void* id) { void* id) {
if (1234 == reinterpret_cast<intptr_t>(id)) WeakPointerCleared = true; if (1234 == reinterpret_cast<intptr_t>(id)) WeakPointerCleared = true;
handle->Dispose(); handle->Reset();
} }
...@@ -1787,12 +1787,12 @@ TEST(LeakNativeContextViaMap) { ...@@ -1787,12 +1787,12 @@ TEST(LeakNativeContextViaMap) {
ctx2->Global()->Set(v8_str("o"), v8::Int32::New(0)); ctx2->Global()->Set(v8_str("o"), v8::Int32::New(0));
ctx2->Exit(); ctx2->Exit();
v8::Local<v8::Context>::New(isolate, ctx1)->Exit(); v8::Local<v8::Context>::New(isolate, ctx1)->Exit();
ctx1p.Dispose(); ctx1p.Reset();
v8::V8::ContextDisposedNotification(); v8::V8::ContextDisposedNotification();
} }
CcTest::heap()->CollectAllAvailableGarbage(); CcTest::heap()->CollectAllAvailableGarbage();
CHECK_EQ(2, NumberOfGlobalObjects()); CHECK_EQ(2, NumberOfGlobalObjects());
ctx2p.Dispose(); ctx2p.Reset();
CcTest::heap()->CollectAllAvailableGarbage(); CcTest::heap()->CollectAllAvailableGarbage();
CHECK_EQ(0, NumberOfGlobalObjects()); CHECK_EQ(0, NumberOfGlobalObjects());
} }
...@@ -1833,12 +1833,12 @@ TEST(LeakNativeContextViaFunction) { ...@@ -1833,12 +1833,12 @@ TEST(LeakNativeContextViaFunction) {
ctx2->Global()->Set(v8_str("o"), v8::Int32::New(0)); ctx2->Global()->Set(v8_str("o"), v8::Int32::New(0));
ctx2->Exit(); ctx2->Exit();
ctx1->Exit(); ctx1->Exit();
ctx1p.Dispose(); ctx1p.Reset();
v8::V8::ContextDisposedNotification(); v8::V8::ContextDisposedNotification();
} }
CcTest::heap()->CollectAllAvailableGarbage(); CcTest::heap()->CollectAllAvailableGarbage();
CHECK_EQ(2, NumberOfGlobalObjects()); CHECK_EQ(2, NumberOfGlobalObjects());
ctx2p.Dispose(); ctx2p.Reset();
CcTest::heap()->CollectAllAvailableGarbage(); CcTest::heap()->CollectAllAvailableGarbage();
CHECK_EQ(0, NumberOfGlobalObjects()); CHECK_EQ(0, NumberOfGlobalObjects());
} }
...@@ -1877,12 +1877,12 @@ TEST(LeakNativeContextViaMapKeyed) { ...@@ -1877,12 +1877,12 @@ TEST(LeakNativeContextViaMapKeyed) {
ctx2->Global()->Set(v8_str("o"), v8::Int32::New(0)); ctx2->Global()->Set(v8_str("o"), v8::Int32::New(0));
ctx2->Exit(); ctx2->Exit();
ctx1->Exit(); ctx1->Exit();
ctx1p.Dispose(); ctx1p.Reset();
v8::V8::ContextDisposedNotification(); v8::V8::ContextDisposedNotification();
} }
CcTest::heap()->CollectAllAvailableGarbage(); CcTest::heap()->CollectAllAvailableGarbage();
CHECK_EQ(2, NumberOfGlobalObjects()); CHECK_EQ(2, NumberOfGlobalObjects());
ctx2p.Dispose(); ctx2p.Reset();
CcTest::heap()->CollectAllAvailableGarbage(); CcTest::heap()->CollectAllAvailableGarbage();
CHECK_EQ(0, NumberOfGlobalObjects()); CHECK_EQ(0, NumberOfGlobalObjects());
} }
...@@ -1925,12 +1925,12 @@ TEST(LeakNativeContextViaMapProto) { ...@@ -1925,12 +1925,12 @@ TEST(LeakNativeContextViaMapProto) {
ctx2->Global()->Set(v8_str("o"), v8::Int32::New(0)); ctx2->Global()->Set(v8_str("o"), v8::Int32::New(0));
ctx2->Exit(); ctx2->Exit();
ctx1->Exit(); ctx1->Exit();
ctx1p.Dispose(); ctx1p.Reset();
v8::V8::ContextDisposedNotification(); v8::V8::ContextDisposedNotification();
} }
CcTest::heap()->CollectAllAvailableGarbage(); CcTest::heap()->CollectAllAvailableGarbage();
CHECK_EQ(2, NumberOfGlobalObjects()); CHECK_EQ(2, NumberOfGlobalObjects());
ctx2p.Dispose(); ctx2p.Reset();
CcTest::heap()->CollectAllAvailableGarbage(); CcTest::heap()->CollectAllAvailableGarbage();
CHECK_EQ(0, NumberOfGlobalObjects()); CHECK_EQ(0, NumberOfGlobalObjects());
} }
......
...@@ -667,7 +667,7 @@ TEST(Regress1433) { ...@@ -667,7 +667,7 @@ TEST(Regress1433) {
v8::HandleScope handle_scope(isolate); v8::HandleScope handle_scope(isolate);
v8::Handle<Context> context = v8::Context::New(isolate); v8::Handle<Context> context = v8::Context::New(isolate);
v8::Context::Scope context_scope(context); 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<Script> script = v8::Script::Compile(source);
v8::Handle<Value> result = script->Run(); v8::Handle<Value> result = script->Run();
v8::String::Utf8Value utf8(result); v8::String::Utf8Value utf8(result);
......
...@@ -113,13 +113,16 @@ const char* TraceExtension::kSource = ...@@ -113,13 +113,16 @@ const char* TraceExtension::kSource =
v8::Handle<v8::FunctionTemplate> TraceExtension::GetNativeFunction( v8::Handle<v8::FunctionTemplate> TraceExtension::GetNativeFunction(
v8::Handle<String> name) { 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); 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); 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); 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); return v8::FunctionTemplate::New(TraceExtension::JSEntrySPLevel2);
} else { } else {
CHECK(false); CHECK(false);
......
...@@ -307,7 +307,8 @@ TEST(Issue23768) { ...@@ -307,7 +307,8 @@ TEST(Issue23768) {
SimpleExternalString source_ext_str("(function ext() {})();"); SimpleExternalString source_ext_str("(function ext() {})();");
v8::Local<v8::String> source = v8::String::NewExternal(&source_ext_str); v8::Local<v8::String> source = v8::String::NewExternal(&source_ext_str);
// Script needs to have a name in order to trigger InitLineEnds execution. // 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); v8::Handle<v8::Script> evil_script = v8::Script::Compile(source, origin);
CHECK(!evil_script.IsEmpty()); CHECK(!evil_script.IsEmpty());
CHECK(!evil_script->Run().IsEmpty()); CHECK(!evil_script->Run().IsEmpty());
...@@ -451,12 +452,14 @@ TEST(EquivalenceOfLoggingAndTraversal) { ...@@ -451,12 +452,14 @@ TEST(EquivalenceOfLoggingAndTraversal) {
i::Vector<const char> log( i::Vector<const char> log(
i::ReadFile(initialize_logger.StopLoggingGetTempFile(), &exists, true)); i::ReadFile(initialize_logger.StopLoggingGetTempFile(), &exists, true));
CHECK(exists); 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); initialize_logger.env()->Global()->Set(v8_str("_log"), log_str);
i::Vector<const unsigned char> source = TestSources::GetScriptsSource(); i::Vector<const unsigned char> source = TestSources::GetScriptsSource();
v8::Handle<v8::String> source_str = v8::String::New( v8::Handle<v8::String> source_str = v8::String::NewFromUtf8(
reinterpret_cast<const char*>(source.start()), source.length()); CcTest::isolate(), reinterpret_cast<const char*>(source.start()),
v8::String::kNormalString, source.length());
v8::TryCatch try_catch; v8::TryCatch try_catch;
v8::Handle<v8::Script> script = v8::Script::Compile(source_str, v8_str("")); v8::Handle<v8::Script> script = v8::Script::Compile(source_str, v8_str(""));
if (script.IsEmpty()) { if (script.IsEmpty()) {
......
...@@ -250,7 +250,7 @@ static void WeakPointerCallback(v8::Isolate* isolate, ...@@ -250,7 +250,7 @@ static void WeakPointerCallback(v8::Isolate* isolate,
void* id) { void* id) {
ASSERT(id == reinterpret_cast<void*>(1234)); ASSERT(id == reinterpret_cast<void*>(1234));
NumberOfWeakCalls++; NumberOfWeakCalls++;
handle->Dispose(); handle->Reset();
} }
......
This diff is collapsed.
...@@ -1050,15 +1050,14 @@ i::Handle<i::String> FormatMessage(i::ScriptDataImpl* data) { ...@@ -1050,15 +1050,14 @@ i::Handle<i::String> FormatMessage(i::ScriptDataImpl* data) {
i::Factory* factory = isolate->factory(); i::Factory* factory = isolate->factory();
const char* message = data->BuildMessage(); const char* message = data->BuildMessage();
i::Handle<i::String> format = v8::Utils::OpenHandle( 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::Vector<const char*> args = data->BuildArgs();
i::Handle<i::JSArray> args_array = factory->NewJSArray(args.length()); i::Handle<i::JSArray> args_array = factory->NewJSArray(args.length());
for (int i = 0; i < args.length(); i++) { for (int i = 0; i < args.length(); i++) {
i::JSArray::SetElement(args_array, i::JSArray::SetElement(
i, args_array, i, v8::Utils::OpenHandle(*v8::String::NewFromUtf8(
v8::Utils::OpenHandle(*v8::String::New(args[i])), CcTest::isolate(), args[i])),
NONE, NONE, i::kNonStrictMode);
i::kNonStrictMode);
} }
i::Handle<i::JSObject> builtins(isolate->js_builtins_object()); i::Handle<i::JSObject> builtins(isolate->js_builtins_object());
i::Handle<i::Object> format_fun = i::Handle<i::Object> format_fun =
...@@ -1329,7 +1328,7 @@ TEST(PreparserStrictOctal) { ...@@ -1329,7 +1328,7 @@ TEST(PreparserStrictOctal) {
" 01; \n" " 01; \n"
" }; \n" " }; \n"
"}; \n"; "}; \n";
v8::Script::Compile(v8::String::New(script)); v8::Script::Compile(v8::String::NewFromUtf8(CcTest::isolate(), script));
CHECK(try_catch.HasCaught()); CHECK(try_catch.HasCaught());
v8::String::Utf8Value exception(try_catch.Exception()); v8::String::Utf8Value exception(try_catch.Exception());
CHECK_EQ("SyntaxError: Octal literals are not allowed in strict mode.", CHECK_EQ("SyntaxError: Octal literals are not allowed in strict mode.",
......
...@@ -556,9 +556,11 @@ const char* ProfilerExtension::kSource = ...@@ -556,9 +556,11 @@ const char* ProfilerExtension::kSource =
v8::Handle<v8::FunctionTemplate> ProfilerExtension::GetNativeFunction( v8::Handle<v8::FunctionTemplate> ProfilerExtension::GetNativeFunction(
v8::Handle<v8::String> name) { 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); 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); return v8::FunctionTemplate::New(ProfilerExtension::StopProfiling);
} else { } else {
CHECK(false); CHECK(false);
...@@ -573,7 +575,8 @@ void ProfilerExtension::StartProfiling( ...@@ -573,7 +575,8 @@ void ProfilerExtension::StartProfiling(
if (args.Length() > 0) if (args.Length() > 0)
cpu_profiler->StartCpuProfiling(args[0].As<v8::String>()); cpu_profiler->StartCpuProfiling(args[0].As<v8::String>());
else else
cpu_profiler->StartCpuProfiling(v8::String::New("")); cpu_profiler->StartCpuProfiling(
v8::String::NewFromUtf8(args.GetIsolate(), ""));
} }
...@@ -583,7 +586,8 @@ void ProfilerExtension::StopProfiling( ...@@ -583,7 +586,8 @@ void ProfilerExtension::StopProfiling(
if (args.Length() > 0) if (args.Length() > 0)
cpu_profiler->StopCpuProfiling(args[0].As<v8::String>()); cpu_profiler->StopCpuProfiling(args[0].As<v8::String>());
else 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, ...@@ -673,7 +677,7 @@ static const v8::CpuProfileNode* PickChild(const v8::CpuProfileNode* parent,
const char* name) { const char* name) {
for (int i = 0; i < parent->GetChildrenCount(); ++i) { for (int i = 0; i < parent->GetChildrenCount(); ++i) {
const v8::CpuProfileNode* child = parent->GetChild(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; if (strcmp(*function_name, name) == 0) return child;
} }
return NULL; return NULL;
...@@ -692,10 +696,11 @@ TEST(ProfileNodeScriptId) { ...@@ -692,10 +696,11 @@ TEST(ProfileNodeScriptId) {
v8::CpuProfiler* profiler = env->GetIsolate()->GetCpuProfiler(); v8::CpuProfiler* profiler = env->GetIsolate()->GetCpuProfiler();
CHECK_EQ(0, profiler->GetProfileCount()); CHECK_EQ(0, profiler->GetProfileCount());
v8::Handle<v8::Script> script_a = v8::Script::Compile(v8::String::New( v8::Handle<v8::Script> script_a = v8::Script::Compile(v8::String::NewFromUtf8(
"function a() { startProfiling(); }\n")); env->GetIsolate(), "function a() { startProfiling(); }\n"));
script_a->Run(); script_a->Run();
v8::Handle<v8::Script> script_b = v8::Script::Compile(v8::String::New( v8::Handle<v8::Script> script_b =
v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(),
"function b() { a(); }\n" "function b() { a(); }\n"
"b();\n" "b();\n"
"stopProfiling();\n")); "stopProfiling();\n"));
...@@ -793,7 +798,8 @@ TEST(BailoutReason) { ...@@ -793,7 +798,8 @@ TEST(BailoutReason) {
v8::CpuProfiler* profiler = env->GetIsolate()->GetCpuProfiler(); v8::CpuProfiler* profiler = env->GetIsolate()->GetCpuProfiler();
CHECK_EQ(0, profiler->GetProfileCount()); CHECK_EQ(0, profiler->GetProfileCount());
v8::Handle<v8::Script> script = v8::Script::Compile(v8::String::New( v8::Handle<v8::Script> script =
v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(),
"function TryCatch() {\n" "function TryCatch() {\n"
" try {\n" " try {\n"
" startProfiling();\n" " startProfiling();\n"
......
...@@ -347,7 +347,7 @@ DEPENDENT_TEST(DeserializeAndRunScript2, Serialize) { ...@@ -347,7 +347,7 @@ DEPENDENT_TEST(DeserializeAndRunScript2, Serialize) {
env->Enter(); env->Enter();
const char* c_source = "\"1234\".length"; 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); v8::Local<v8::Script> script = v8::Script::Compile(source);
CHECK_EQ(4, script->Run()->Int32Value()); CHECK_EQ(4, script->Run()->Int32Value());
} }
...@@ -365,7 +365,7 @@ DEPENDENT_TEST(DeserializeFromSecondSerializationAndRunScript2, ...@@ -365,7 +365,7 @@ DEPENDENT_TEST(DeserializeFromSecondSerializationAndRunScript2,
env->Enter(); env->Enter();
const char* c_source = "\"1234\".length"; 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); v8::Local<v8::Script> script = v8::Script::Compile(source);
CHECK_EQ(4, script->Run()->Int32Value()); CHECK_EQ(4, script->Run()->Int32Value());
} }
...@@ -402,7 +402,7 @@ TEST(PartialSerialization) { ...@@ -402,7 +402,7 @@ TEST(PartialSerialization) {
Object* raw_foo; Object* raw_foo;
{ {
v8::HandleScope handle_scope(v8_isolate); 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()); ASSERT(!foo.IsEmpty());
raw_foo = *(v8::Utils::OpenHandle(*foo)); raw_foo = *(v8::Utils::OpenHandle(*foo));
} }
...@@ -415,7 +415,7 @@ TEST(PartialSerialization) { ...@@ -415,7 +415,7 @@ TEST(PartialSerialization) {
v8::HandleScope handle_scope(v8_isolate); v8::HandleScope handle_scope(v8_isolate);
v8::Local<v8::Context>::New(v8_isolate, env)->Exit(); v8::Local<v8::Context>::New(v8_isolate, env)->Exit();
} }
env.Dispose(); env.Reset();
FileByteSink startup_sink(startup_name.start()); FileByteSink startup_sink(startup_name.start());
StartupSerializer startup_serializer(isolate, &startup_sink); StartupSerializer startup_serializer(isolate, &startup_sink);
...@@ -562,7 +562,7 @@ TEST(ContextSerialization) { ...@@ -562,7 +562,7 @@ TEST(ContextSerialization) {
i::Object* raw_context = *v8::Utils::OpenPersistent(env); i::Object* raw_context = *v8::Utils::OpenPersistent(env);
env.Dispose(); env.Reset();
FileByteSink startup_sink(startup_name.start()); FileByteSink startup_sink(startup_name.start());
StartupSerializer startup_serializer(isolate, &startup_sink); StartupSerializer startup_serializer(isolate, &startup_sink);
......
...@@ -889,8 +889,8 @@ TEST(Utf8Conversion) { ...@@ -889,8 +889,8 @@ TEST(Utf8Conversion) {
v8::HandleScope handle_scope(CcTest::isolate()); v8::HandleScope handle_scope(CcTest::isolate());
// A simple ascii string // A simple ascii string
const char* ascii_string = "abcdef12345"; const char* ascii_string = "abcdef12345";
int len = int len = v8::String::NewFromUtf8(CcTest::isolate(), ascii_string,
v8::String::New(ascii_string, v8::String::kNormalString,
StrLength(ascii_string))->Utf8Length(); StrLength(ascii_string))->Utf8Length();
CHECK_EQ(StrLength(ascii_string), len); CHECK_EQ(StrLength(ascii_string), len);
// A mixed ascii and non-ascii string // A mixed ascii and non-ascii string
...@@ -906,7 +906,8 @@ TEST(Utf8Conversion) { ...@@ -906,7 +906,8 @@ TEST(Utf8Conversion) {
// The number of bytes expected to be written for each length // 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 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}; 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()); CHECK_EQ(10, mixed->Utf8Length());
// Try encoding the string with all capacities // Try encoding the string with all capacities
char buffer[11]; char buffer[11];
...@@ -1083,8 +1084,8 @@ TEST(CachedHashOverflow) { ...@@ -1083,8 +1084,8 @@ TEST(CachedHashOverflow) {
const char* line; const char* line;
for (int i = 0; (line = lines[i]); i++) { for (int i = 0; (line = lines[i]); i++) {
printf("%s\n", line); printf("%s\n", line);
v8::Local<v8::Value> result = v8::Local<v8::Value> result = v8::Script::Compile(
v8::Script::Compile(v8::String::New(line))->Run(); v8::String::NewFromUtf8(CcTest::isolate(), line))->Run();
CHECK_EQ(results[i]->IsUndefined(), result->IsUndefined()); CHECK_EQ(results[i]->IsUndefined(), result->IsUndefined());
CHECK_EQ(results[i]->IsNumber(), result->IsNumber()); CHECK_EQ(results[i]->IsNumber(), result->IsNumber());
if (result->IsNumber()) { if (result->IsNumber()) {
...@@ -1230,8 +1231,8 @@ TEST(AsciiArrayJoin) { ...@@ -1230,8 +1231,8 @@ TEST(AsciiArrayJoin) {
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
LocalContext context; LocalContext context;
v8::V8::IgnoreOutOfMemoryException(); v8::V8::IgnoreOutOfMemoryException();
v8::Local<v8::Script> script = v8::Local<v8::Script> script = v8::Script::Compile(
v8::Script::Compile(v8::String::New(join_causing_out_of_memory)); v8::String::NewFromUtf8(CcTest::isolate(), join_causing_out_of_memory));
v8::Local<v8::Value> result = script->Run(); v8::Local<v8::Value> result = script->Run();
// Check for out of memory state. // Check for out of memory state.
......
This diff is collapsed.
...@@ -58,7 +58,8 @@ class ThreadA : public v8::internal::Thread { ...@@ -58,7 +58,8 @@ class ThreadA : public v8::internal::Thread {
// Fill String.search cache. // Fill String.search cache.
v8::Handle<v8::Script> script = v8::Script::Compile( v8::Handle<v8::Script> script = v8::Script::Compile(
v8::String::New( v8::String::NewFromUtf8(
isolate,
"for (var i = 0; i < 3; i++) {" "for (var i = 0; i < 3; i++) {"
" var result = \"a\".search(\"a\");" " var result = \"a\".search(\"a\");"
" if (result != 0) throw \"result: \" + result + \" @\" + i;" " if (result != 0) throw \"result: \" + result + \" @\" + i;"
......
...@@ -69,7 +69,7 @@ static void WeakPointerCallback(v8::Isolate* isolate, ...@@ -69,7 +69,7 @@ static void WeakPointerCallback(v8::Isolate* isolate,
void* id) { void* id) {
ASSERT(id == reinterpret_cast<void*>(1234)); ASSERT(id == reinterpret_cast<void*>(1234));
NumberOfWeakCalls++; NumberOfWeakCalls++;
handle->Dispose(); handle->Reset();
} }
......
...@@ -69,7 +69,7 @@ static void WeakPointerCallback(v8::Isolate* isolate, ...@@ -69,7 +69,7 @@ static void WeakPointerCallback(v8::Isolate* isolate,
void* id) { void* id) {
ASSERT(id == reinterpret_cast<void*>(1234)); ASSERT(id == reinterpret_cast<void*>(1234));
NumberOfWeakCalls++; NumberOfWeakCalls++;
handle->Dispose(); handle->Reset();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment