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 @@
'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': [
{
......
......@@ -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();
}
......
......@@ -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;"
......
......@@ -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();
}
......
This diff is collapsed.
......@@ -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; };"
"}"
......
This diff is collapsed.
This diff is collapsed.
......@@ -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];
......
......@@ -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;
......
......@@ -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());
}
......
......@@ -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"
......
......@@ -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);
......
......@@ -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());
}
......
......@@ -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);
......
......@@ -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);
......
......@@ -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()) {
......
......@@ -250,7 +250,7 @@ static void WeakPointerCallback(v8::Isolate* isolate,
void* id) {
ASSERT(id == reinterpret_cast<void*>(1234));
NumberOfWeakCalls++;
handle->Dispose();
handle->Reset();
}
......
This diff is collapsed.
......@@ -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.",
......
......@@ -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);
......
......@@ -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);
......
......@@ -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.
......
This diff is collapsed.
......@@ -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;"
......
......@@ -69,7 +69,7 @@ static void WeakPointerCallback(v8::Isolate* isolate,
void* id) {
ASSERT(id == reinterpret_cast<void*>(1234));
NumberOfWeakCalls++;
handle->Dispose();
handle->Reset();
}
......
......@@ -69,7 +69,7 @@ static void WeakPointerCallback(v8::Isolate* isolate,
void* id) {
ASSERT(id == reinterpret_cast<void*>(1234));
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