don't use to-be-deprecated Value::To* without isolate parameter

R=svenpanne@chromium.org

BUG=

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

Cr-Commit-Position: refs/heads/master@{#25473}
This commit is contained in:
dcarney 2014-11-24 02:30:39 -08:00 committed by Commit bot
parent c1bfc3485d
commit b1667fca63
8 changed files with 154 additions and 134 deletions

View File

@ -25,7 +25,8 @@ static void AssertInlineCount(const v8::FunctionCallbackInfo<v8::Value>& args) {
frames_seen++;
it.Advance();
}
CHECK_EQ(args[0]->ToInt32()->Value(), topmost->GetInlineCount());
CHECK_EQ(args[0]->ToInt32(args.GetIsolate())->Value(),
topmost->GetInlineCount());
}

View File

@ -185,7 +185,8 @@ THREADED_TEST(IsolateOfContext) {
}
static void TestSignature(const char* loop_js, Local<Value> receiver) {
static void TestSignature(const char* loop_js, Local<Value> receiver,
v8::Isolate* isolate) {
i::ScopedVector<char> source(200);
i::SNPrintF(source,
"for (var i = 0; i < 10; i++) {"
@ -202,7 +203,7 @@ static void TestSignature(const char* loop_js, Local<Value> receiver) {
CHECK_EQ(10, signature_callback_count);
} else {
CHECK_EQ(v8_str("TypeError: Illegal invocation"),
try_catch.Exception()->ToString());
try_catch.Exception()->ToString(isolate));
}
}
@ -267,17 +268,17 @@ THREADED_TEST(ReceiverSignature) {
i::SNPrintF(
source, "var test_object = %s; test_object", test_objects[i]);
Local<Value> test_object = CompileRun(source.start());
TestSignature("test_object.prop();", test_object);
TestSignature("test_object.accessor;", test_object);
TestSignature("test_object[accessor_key];", test_object);
TestSignature("test_object.accessor = 1;", test_object);
TestSignature("test_object[accessor_key] = 1;", test_object);
TestSignature("test_object.prop();", test_object, isolate);
TestSignature("test_object.accessor;", test_object, isolate);
TestSignature("test_object[accessor_key];", test_object, isolate);
TestSignature("test_object.accessor = 1;", test_object, isolate);
TestSignature("test_object[accessor_key] = 1;", test_object, isolate);
if (i >= bad_signature_start_offset) test_object = Local<Value>();
TestSignature("test_object.prop_sig();", test_object);
TestSignature("test_object.accessor_sig;", test_object);
TestSignature("test_object[accessor_sig_key];", test_object);
TestSignature("test_object.accessor_sig = 1;", test_object);
TestSignature("test_object[accessor_sig_key] = 1;", test_object);
TestSignature("test_object.prop_sig();", test_object, isolate);
TestSignature("test_object.accessor_sig;", test_object, isolate);
TestSignature("test_object[accessor_sig_key];", test_object, isolate);
TestSignature("test_object.accessor_sig = 1;", test_object, isolate);
TestSignature("test_object[accessor_sig_key] = 1;", test_object, isolate);
}
}
@ -356,7 +357,7 @@ THREADED_TEST(HulIgennem) {
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope scope(isolate);
v8::Handle<v8::Primitive> undef = v8::Undefined(isolate);
Local<String> undef_str = undef->ToString();
Local<String> undef_str = undef->ToString(isolate);
char* value = i::NewArray<char>(undef_str->Utf8Length() + 1);
undef_str->WriteUtf8(value);
CHECK_EQ(0, strcmp(value, "undefined"));
@ -1233,7 +1234,8 @@ Handle<Value> TestFastReturnValues() {
THREADED_PROFILED_TEST(FastReturnValues) {
LocalContext env;
v8::HandleScope scope(CcTest::isolate());
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope scope(isolate);
v8::Handle<v8::Value> value;
// check int32_t and uint32_t
int32_t int_values[] = {
@ -1258,13 +1260,13 @@ THREADED_PROFILED_TEST(FastReturnValues) {
// check double
value = TestFastReturnValues<double>();
CHECK(value->IsNumber());
CHECK_EQ(kFastReturnValueDouble, value->ToNumber()->Value());
CHECK_EQ(kFastReturnValueDouble, value->ToNumber(isolate)->Value());
// check bool values
for (int i = 0; i < 2; i++) {
fast_return_value_bool = i == 0;
value = TestFastReturnValues<bool>();
CHECK(value->IsBoolean());
CHECK_EQ(fast_return_value_bool, value->ToBoolean()->Value());
CHECK_EQ(fast_return_value_bool, value->ToBoolean(isolate)->Value());
}
// check oddballs
ReturnValueOddball oddballs[] = {
@ -4387,13 +4389,14 @@ THREADED_TEST(ScriptException) {
TEST(TryCatchCustomException) {
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope scope(isolate);
v8::TryCatch try_catch;
CompileRun("function CustomError() { this.a = 'b'; }"
"(function f() { throw new CustomError(); })();");
CHECK(try_catch.HasCaught());
CHECK(try_catch.Exception()->ToObject()->
Get(v8_str("a"))->Equals(v8_str("b")));
CHECK(try_catch.Exception()->ToObject(isolate)->Get(v8_str("a"))->Equals(
v8_str("b")));
}
@ -4887,49 +4890,51 @@ static void CheckUncle(v8::TryCatch* try_catch) {
THREADED_TEST(ConversionNumber) {
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope scope(isolate);
// Very large number.
CompileRun("var obj = Math.pow(2,32) * 1237;");
Local<Value> obj = env->Global()->Get(v8_str("obj"));
CHECK_EQ(5312874545152.0, obj->ToNumber()->Value());
CHECK_EQ(0, obj->ToInt32()->Value());
CHECK(0u == obj->ToUint32()->Value()); // NOLINT - no CHECK_EQ for unsigned.
CHECK_EQ(5312874545152.0, obj->ToNumber(isolate)->Value());
CHECK_EQ(0, obj->ToInt32(isolate)->Value());
CHECK(0u ==
obj->ToUint32(isolate)->Value()); // NOLINT - no CHECK_EQ for unsigned.
// Large number.
CompileRun("var obj = -1234567890123;");
obj = env->Global()->Get(v8_str("obj"));
CHECK_EQ(-1234567890123.0, obj->ToNumber()->Value());
CHECK_EQ(-1912276171, obj->ToInt32()->Value());
CHECK(2382691125u == obj->ToUint32()->Value()); // NOLINT
CHECK_EQ(-1234567890123.0, obj->ToNumber(isolate)->Value());
CHECK_EQ(-1912276171, obj->ToInt32(isolate)->Value());
CHECK(2382691125u == obj->ToUint32(isolate)->Value()); // NOLINT
// Small positive integer.
CompileRun("var obj = 42;");
obj = env->Global()->Get(v8_str("obj"));
CHECK_EQ(42.0, obj->ToNumber()->Value());
CHECK_EQ(42, obj->ToInt32()->Value());
CHECK(42u == obj->ToUint32()->Value()); // NOLINT
CHECK_EQ(42.0, obj->ToNumber(isolate)->Value());
CHECK_EQ(42, obj->ToInt32(isolate)->Value());
CHECK(42u == obj->ToUint32(isolate)->Value()); // NOLINT
// Negative integer.
CompileRun("var obj = -37;");
obj = env->Global()->Get(v8_str("obj"));
CHECK_EQ(-37.0, obj->ToNumber()->Value());
CHECK_EQ(-37, obj->ToInt32()->Value());
CHECK(4294967259u == obj->ToUint32()->Value()); // NOLINT
CHECK_EQ(-37.0, obj->ToNumber(isolate)->Value());
CHECK_EQ(-37, obj->ToInt32(isolate)->Value());
CHECK(4294967259u == obj->ToUint32(isolate)->Value()); // NOLINT
// Positive non-int32 integer.
CompileRun("var obj = 0x81234567;");
obj = env->Global()->Get(v8_str("obj"));
CHECK_EQ(2166572391.0, obj->ToNumber()->Value());
CHECK_EQ(-2128394905, obj->ToInt32()->Value());
CHECK(2166572391u == obj->ToUint32()->Value()); // NOLINT
CHECK_EQ(2166572391.0, obj->ToNumber(isolate)->Value());
CHECK_EQ(-2128394905, obj->ToInt32(isolate)->Value());
CHECK(2166572391u == obj->ToUint32(isolate)->Value()); // NOLINT
// Fraction.
CompileRun("var obj = 42.3;");
obj = env->Global()->Get(v8_str("obj"));
CHECK_EQ(42.3, obj->ToNumber()->Value());
CHECK_EQ(42, obj->ToInt32()->Value());
CHECK(42u == obj->ToUint32()->Value()); // NOLINT
CHECK_EQ(42.3, obj->ToNumber(isolate)->Value());
CHECK_EQ(42, obj->ToInt32(isolate)->Value());
CHECK(42u == obj->ToUint32(isolate)->Value()); // NOLINT
// Large negative fraction.
CompileRun("var obj = -5726623061.75;");
obj = env->Global()->Get(v8_str("obj"));
CHECK_EQ(-5726623061.75, obj->ToNumber()->Value());
CHECK_EQ(-1431655765, obj->ToInt32()->Value());
CHECK(2863311531u == obj->ToUint32()->Value()); // NOLINT
CHECK_EQ(-5726623061.75, obj->ToNumber(isolate)->Value());
CHECK_EQ(-1431655765, obj->ToInt32(isolate)->Value());
CHECK(2863311531u == obj->ToUint32(isolate)->Value()); // NOLINT
}
@ -4994,29 +4999,29 @@ THREADED_TEST(ConversionException) {
"var obj = new TestClass();");
Local<Value> obj = env->Global()->Get(v8_str("obj"));
v8::TryCatch try_catch;
v8::TryCatch try_catch(isolate);
Local<Value> to_string_result = obj->ToString();
Local<Value> to_string_result = obj->ToString(isolate);
CHECK(to_string_result.IsEmpty());
CheckUncle(&try_catch);
Local<Value> to_number_result = obj->ToNumber();
Local<Value> to_number_result = obj->ToNumber(isolate);
CHECK(to_number_result.IsEmpty());
CheckUncle(&try_catch);
Local<Value> to_integer_result = obj->ToInteger();
Local<Value> to_integer_result = obj->ToInteger(isolate);
CHECK(to_integer_result.IsEmpty());
CheckUncle(&try_catch);
Local<Value> to_uint32_result = obj->ToUint32();
Local<Value> to_uint32_result = obj->ToUint32(isolate);
CHECK(to_uint32_result.IsEmpty());
CheckUncle(&try_catch);
Local<Value> to_int32_result = obj->ToInt32();
Local<Value> to_int32_result = obj->ToInt32(isolate);
CHECK(to_int32_result.IsEmpty());
CheckUncle(&try_catch);
Local<Value> to_object_result = v8::Undefined(isolate)->ToObject();
Local<Value> to_object_result = v8::Undefined(isolate)->ToObject(isolate);
CHECK(to_object_result.IsEmpty());
CHECK(try_catch.HasCaught());
try_catch.Reset();
@ -5052,7 +5057,7 @@ void CCatcher(const v8::FunctionCallbackInfo<v8::Value>& args) {
}
v8::HandleScope scope(args.GetIsolate());
v8::TryCatch try_catch;
Local<Value> result = CompileRun(args[0]->ToString());
Local<Value> result = CompileRun(args[0]->ToString(args.GetIsolate()));
CHECK(!try_catch.HasCaught() || result.IsEmpty());
args.GetReturnValue().Set(try_catch.HasCaught());
}
@ -6331,7 +6336,7 @@ THREADED_TEST(IndexedInterceptorUnboxedDoubleWithIndexedAccessor) {
"for (x in obj) {key_count++;};"
"obj;");
Local<Value> result = create_unboxed_double_script->Run();
CHECK(result->ToObject()->HasRealIndexedProperty(2000));
CHECK(result->ToObject(isolate)->HasRealIndexedProperty(2000));
Local<Script> key_count_check = v8_compile("key_count;");
result = key_count_check->Run();
CHECK_EQ(v8_num(40013), result);
@ -8918,7 +8923,7 @@ TEST(TryCatchFinallyUsingTryCatchHandler) {
void CEvaluate(const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::HandleScope scope(args.GetIsolate());
CompileRun(args[0]->ToString());
CompileRun(args[0]->ToString(args.GetIsolate()));
}
@ -9192,11 +9197,11 @@ TEST(SecurityTestGCAllowed) {
CHECK(indexed_security_check_with_gc_called);
named_security_check_with_gc_called = false;
CHECK(CompileRun("obj.foo")->ToString()->Equals(v8_str("1001")));
CHECK(CompileRun("obj.foo")->ToString(isolate)->Equals(v8_str("1001")));
CHECK(named_security_check_with_gc_called);
indexed_security_check_with_gc_called = false;
CHECK(CompileRun("obj[0]")->ToString()->Equals(v8_str("1002")));
CHECK(CompileRun("obj[0]")->ToString(isolate)->Equals(v8_str("1002")));
CHECK(indexed_security_check_with_gc_called);
}
@ -11057,7 +11062,7 @@ THREADED_TEST(ConstructorForObject) {
"(function() { var o = new obj('tipli'); return o.a; })()");
CHECK(!try_catch.HasCaught());
CHECK(value->IsString());
String::Utf8Value string_value1(value->ToString());
String::Utf8Value string_value1(value->ToString(isolate));
CHECK_EQ("tipli", *string_value1);
Local<Value> args2[] = { v8_str("tipli") };
@ -11067,7 +11072,7 @@ THREADED_TEST(ConstructorForObject) {
value = object2->Get(v8_str("a"));
CHECK(!try_catch.HasCaught());
CHECK(value->IsString());
String::Utf8Value string_value2(value->ToString());
String::Utf8Value string_value2(value->ToString(isolate));
CHECK_EQ("tipli", *string_value2);
// Call the Object's constructor with a Boolean.
@ -12863,7 +12868,7 @@ THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss3) {
CHECK(try_catch.HasCaught());
// TODO(verwaest): Adjust message.
CHECK_EQ(v8_str("TypeError: undefined is not a function"),
try_catch.Exception()->ToString());
try_catch.Exception()->ToString(isolate));
CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value());
CHECK_GE(interceptor_call_count, 50);
}
@ -12905,7 +12910,7 @@ THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_TypeError) {
"}");
CHECK(try_catch.HasCaught());
CHECK_EQ(v8_str("TypeError: Illegal invocation"),
try_catch.Exception()->ToString());
try_catch.Exception()->ToString(isolate));
CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value());
CHECK_GE(interceptor_call_count, 50);
}
@ -13038,7 +13043,7 @@ THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature_Miss2) {
CHECK(try_catch.HasCaught());
// TODO(verwaest): Adjust message.
CHECK_EQ(v8_str("TypeError: undefined is not a function"),
try_catch.Exception()->ToString());
try_catch.Exception()->ToString(isolate));
CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value());
}
@ -13076,7 +13081,7 @@ THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature_TypeError) {
"}");
CHECK(try_catch.HasCaught());
CHECK_EQ(v8_str("TypeError: Illegal invocation"),
try_catch.Exception()->ToString());
try_catch.Exception()->ToString(isolate));
CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value());
}
@ -13663,7 +13668,7 @@ THREADED_TEST(ObjectProtoToString) {
// Normal ToString call should call replaced Object.prototype.toString
Local<v8::Object> instance = templ->GetFunction()->NewInstance();
Local<String> value = instance->ToString();
Local<String> value = instance->ToString(isolate);
CHECK(value->IsString() && value->Equals(customized_tostring));
// ObjectProtoToString should not call replace toString function.
@ -13700,7 +13705,7 @@ TEST(ObjectProtoToStringES6) {
// Normal ToString call should call replaced Object.prototype.toString
Local<v8::Object> instance = templ->GetFunction()->NewInstance();
Local<String> value = instance->ToString();
Local<String> value = instance->ToString(isolate);
CHECK(value->IsString() && value->Equals(customized_tostring));
// ObjectProtoToString should not call replace toString function.
@ -13799,8 +13804,9 @@ TEST(ObjectProtoToStringES6) {
THREADED_TEST(ObjectGetConstructorName) {
v8::Isolate* isolate = CcTest::isolate();
LocalContext context;
v8::HandleScope scope(context->GetIsolate());
v8::HandleScope scope(isolate);
v8_compile("function Parent() {};"
"function Child() {};"
"Child.prototype = new Parent();"
@ -13810,15 +13816,16 @@ THREADED_TEST(ObjectGetConstructorName) {
"var x = new outer.inner();")->Run();
Local<v8::Value> p = context->Global()->Get(v8_str("p"));
CHECK(p->IsObject() && p->ToObject()->GetConstructorName()->Equals(
v8_str("Parent")));
CHECK(p->IsObject() &&
p->ToObject(isolate)->GetConstructorName()->Equals(v8_str("Parent")));
Local<v8::Value> c = context->Global()->Get(v8_str("c"));
CHECK(c->IsObject() && c->ToObject()->GetConstructorName()->Equals(
v8_str("Child")));
CHECK(c->IsObject() &&
c->ToObject(isolate)->GetConstructorName()->Equals(v8_str("Child")));
Local<v8::Value> x = context->Global()->Get(v8_str("x"));
CHECK(x->IsObject() && x->ToObject()->GetConstructorName()->Equals(
CHECK(x->IsObject() &&
x->ToObject(isolate)->GetConstructorName()->Equals(
v8_str("outer.inner")));
}
@ -14367,7 +14374,7 @@ THREADED_TEST(NestedHandleScopeAndContexts) {
v8::Local<Context> env = Context::New(isolate);
env->Enter();
v8::Handle<Value> value = NestedScope(env);
v8::Handle<String> str(value->ToString());
v8::Handle<String> str(value->ToString(isolate));
CHECK(!str.IsEmpty());
env->Exit();
}
@ -18802,10 +18809,11 @@ class VisitorImpl : public v8::ExternalResourceVisitor {
TEST(ExternalizeOldSpaceTwoByteCons) {
v8::Isolate* isolate = CcTest::isolate();
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
v8::HandleScope scope(isolate);
v8::Local<v8::String> cons =
CompileRun("'Romeo Montague ' + 'Juliet Capulet'")->ToString();
CompileRun("'Romeo Montague ' + 'Juliet Capulet'")->ToString(isolate);
CHECK(v8::Utils::OpenHandle(*cons)->IsConsString());
CcTest::heap()->CollectAllAvailableGarbage();
CHECK(CcTest::heap()->old_pointer_space()->Contains(
@ -18824,10 +18832,11 @@ TEST(ExternalizeOldSpaceTwoByteCons) {
TEST(ExternalizeOldSpaceOneByteCons) {
v8::Isolate* isolate = CcTest::isolate();
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
v8::HandleScope scope(isolate);
v8::Local<v8::String> cons =
CompileRun("'Romeo Montague ' + 'Juliet Capulet'")->ToString();
CompileRun("'Romeo Montague ' + 'Juliet Capulet'")->ToString(isolate);
CHECK(v8::Utils::OpenHandle(*cons)->IsConsString());
CcTest::heap()->CollectAllAvailableGarbage();
CHECK(CcTest::heap()->old_pointer_space()->Contains(
@ -18846,8 +18855,9 @@ TEST(ExternalizeOldSpaceOneByteCons) {
TEST(VisitExternalStrings) {
v8::Isolate* isolate = CcTest::isolate();
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
v8::HandleScope scope(isolate);
const char* string = "Some string";
uint16_t* two_byte_string = AsciiToTwoByteString(string);
TestResource* resource[4];
@ -18917,7 +18927,7 @@ TEST(ExternalInternalizedStringCollectedAtTearDown) {
const char* s = "One string to test them all";
TestOneByteResource* inscription =
new TestOneByteResource(i::StrDup(s), &destroyed);
v8::Local<v8::String> ring = CompileRun("ring")->ToString();
v8::Local<v8::String> ring = CompileRun("ring")->ToString(isolate);
CHECK(v8::Utils::OpenHandle(*ring)->IsInternalizedString());
ring->MakeExternal(inscription);
// Ring is still alive. Orcs are roaming freely across our lands.
@ -18939,7 +18949,7 @@ TEST(ExternalInternalizedStringCollectedAtGC) {
const char* s = "One string to test them all";
TestOneByteResource* inscription =
new TestOneByteResource(i::StrDup(s), &destroyed);
v8::Local<v8::String> ring = CompileRun("ring")->ToString();
v8::Local<v8::String> ring = CompileRun("ring").As<v8::String>();
CHECK(v8::Utils::OpenHandle(*ring)->IsInternalizedString());
ring->MakeExternal(inscription);
// Ring is still alive. Orcs are roaming freely across our lands.
@ -19078,7 +19088,7 @@ static void SpaghettiIncident(
const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::HandleScope scope(args.GetIsolate());
v8::TryCatch tc;
v8::Handle<v8::String> str(args[0]->ToString());
v8::Handle<v8::String> str(args[0]->ToString(args.GetIsolate()));
USE(str);
if (tc.HasCaught())
tc.ReThrow();
@ -21013,7 +21023,7 @@ TEST(HasOwnProperty) {
"Bar.prototype = new Foo();"
"new Bar();");
CHECK(value->IsObject());
Handle<Object> object = value->ToObject();
Handle<Object> object = value->ToObject(isolate);
CHECK(object->Has(v8_str("foo")));
CHECK(!object->HasOwnProperty(v8_str("foo")));
CHECK(object->HasOwnProperty(v8_str("bar")));
@ -21263,12 +21273,11 @@ static bool BlockProtoNamedSecurityTestCallback(Local<v8::Object> global,
v8::AccessType type,
Local<Value> data) {
// Only block read access to __proto__.
if (type == v8::ACCESS_GET &&
name->IsString() &&
name->ToString()->Length() == 9 &&
name->ToString()->Utf8Length() == 9) {
if (type == v8::ACCESS_GET && name->IsString() &&
name.As<v8::String>()->Length() == 9 &&
name.As<v8::String>()->Utf8Length() == 9) {
char buffer[10];
CHECK_EQ(10, name->ToString()->WriteUtf8(buffer));
CHECK_EQ(10, name.As<v8::String>()->WriteUtf8(buffer));
return strncmp(buffer, "__proto__", 9) != 0;
}
@ -21315,8 +21324,7 @@ THREADED_TEST(Regress93759) {
context->Global();
// Global object, the prototype of proxy_object. No security checks.
Local<Object> global_object =
proxy_object->GetPrototype()->ToObject();
Local<Object> global_object = proxy_object->GetPrototype()->ToObject(isolate);
// Hidden prototype without security check.
Local<Object> hidden_prototype =
@ -21360,7 +21368,7 @@ THREADED_TEST(Regress93759) {
Local<Value> result5 = CompileRun("Object.getPrototypeOf(hidden)");
CHECK(result5->Equals(
object_with_hidden->GetPrototype()->ToObject()->GetPrototype()));
object_with_hidden->GetPrototype()->ToObject(isolate)->GetPrototype()));
Local<Value> result6 = CompileRun("Object.getPrototypeOf(phidden)");
CHECK(result6.IsEmpty());
@ -21396,8 +21404,8 @@ static void TestReceiver(Local<Value> expected_result,
const char* code) {
Local<Value> result = CompileRun(code);
CHECK(result->IsObject());
CHECK(expected_receiver->Equals(result->ToObject()->Get(1)));
CHECK(expected_result->Equals(result->ToObject()->Get(0)));
CHECK(expected_receiver->Equals(result.As<v8::Object>()->Get(1)));
CHECK(expected_result->Equals(result.As<v8::Object>()->Get(0)));
}
@ -21785,8 +21793,8 @@ static void DebugEventInObserver(const v8::Debug::EventDetails& event_details) {
Handle<Object> exec_state = event_details.GetExecutionState();
Handle<Value> break_id = exec_state->Get(v8_str("break_id"));
CompileRun("function f(id) { new FrameDetails(id, 0); }");
Handle<Function> fun = Handle<Function>::Cast(
CcTest::global()->Get(v8_str("f"))->ToObject());
Handle<Function> fun =
Handle<Function>::Cast(CcTest::global()->Get(v8_str("f")));
fun->Call(CcTest::global(), 1, &break_id);
}
@ -22597,7 +22605,8 @@ void CatcherCallback(const v8::FunctionCallbackInfo<v8::Value>& args) {
void HasOwnPropertyCallback(const v8::FunctionCallbackInfo<v8::Value>& args) {
args[0]->ToObject()->HasOwnProperty(args[1]->ToString());
args[0]->ToObject(args.GetIsolate())->HasOwnProperty(
args[1]->ToString(args.GetIsolate()));
}

View File

@ -621,7 +621,7 @@ static void DebugEventBreakPointHitCount(
last_function_hit[0] = '\0';
} else {
CHECK(result->IsString());
v8::Handle<v8::String> function_name(result->ToString());
v8::Handle<v8::String> function_name(result.As<v8::String>());
function_name->WriteUtf8(last_function_hit);
}
}
@ -656,7 +656,7 @@ static void DebugEventBreakPointHitCount(
last_script_name_hit[0] = '\0';
} else {
CHECK(result->IsString());
v8::Handle<v8::String> script_name(result->ToString());
v8::Handle<v8::String> script_name(result.As<v8::String>());
script_name->WriteUtf8(last_script_name_hit);
}
}
@ -775,7 +775,7 @@ static void DebugEventEvaluate(
v8::Handle<v8::Value> result =
evaluate_check_function->Call(exec_state, argc, argv);
if (!result->IsTrue()) {
v8::String::Utf8Value utf8(checks[i].expected->ToString());
v8::String::Utf8Value utf8(checks[i].expected);
V8_Fatal(__FILE__, __LINE__, "%s != %s", checks[i].expr, *utf8);
}
}
@ -849,7 +849,7 @@ static void DebugEventStepSequence(
v8::Handle<v8::Value> result = frame_function_name->Call(exec_state,
argc, argv);
CHECK(result->IsString());
v8::String::Utf8Value function_name(result->ToString());
v8::String::Utf8Value function_name(result->ToString(CcTest::isolate()));
CHECK_EQ(1, StrLength(*function_name));
CHECK_EQ((*function_name)[0],
expected_step_sequence[break_point_hit_count]);
@ -6159,7 +6159,8 @@ static void DebugEventDebugBreak(
last_function_hit[0] = '\0';
} else {
CHECK(result->IsString());
v8::Handle<v8::String> function_name(result->ToString());
v8::Handle<v8::String> function_name(
result->ToString(CcTest::isolate()));
function_name->WriteUtf8(last_function_hit);
}
}
@ -7042,7 +7043,8 @@ static void DebugEventBreakDeoptimize(
if (!result->IsUndefined()) {
char fn[80];
CHECK(result->IsString());
v8::Handle<v8::String> function_name(result->ToString());
v8::Handle<v8::String> function_name(
result->ToString(CcTest::isolate()));
function_name->WriteUtf8(fn);
if (strcmp(fn, "bar") == 0) {
i::Deoptimizer::DeoptimizeAll(CcTest::i_isolate());
@ -7107,12 +7109,12 @@ static void DebugEventBreakWithOptimizedStack(
v8::Handle<v8::Value> result =
frame_function_name->Call(exec_state, argc, argv);
CHECK(result->IsString());
v8::Handle<v8::String> function_name(result->ToString());
v8::Handle<v8::String> function_name(result->ToString(isolate));
CHECK(function_name->Equals(v8::String::NewFromUtf8(isolate, "loop")));
// Get the name of the first argument in frame i.
result = frame_argument_name->Call(exec_state, argc, argv);
CHECK(result->IsString());
v8::Handle<v8::String> argument_name(result->ToString());
v8::Handle<v8::String> argument_name(result->ToString(isolate));
CHECK(argument_name->Equals(v8::String::NewFromUtf8(isolate, "count")));
// Get the value of the first argument in frame i. If the
// funtion is optimized the value will be undefined, otherwise
@ -7125,7 +7127,7 @@ static void DebugEventBreakWithOptimizedStack(
// Get the name of the first local variable.
result = frame_local_name->Call(exec_state, argc, argv);
CHECK(result->IsString());
v8::Handle<v8::String> local_name(result->ToString());
v8::Handle<v8::String> local_name(result->ToString(isolate));
CHECK(local_name->Equals(v8::String::NewFromUtf8(isolate, "local")));
// Get the value of the first local variable. If the function
// is optimized the value will be undefined, otherwise it will

View File

@ -890,9 +890,10 @@ class OneByteResource : public v8::String::ExternalOneByteStringResource {
} // namespace
TEST(HeapSnapshotJSONSerialization) {
v8::Isolate* isolate = CcTest::isolate();
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
v8::HandleScope scope(isolate);
v8::HeapProfiler* heap_profiler = isolate->GetHeapProfiler();
#define STRING_LITERAL_FOR_TEST \
"\"String \\n\\r\\u0008\\u0081\\u0101\\u0801\\u8001\""
@ -923,7 +924,7 @@ TEST(HeapSnapshotJSONSerialization) {
// Verify that snapshot object has required fields.
v8::Local<v8::Object> parsed_snapshot =
env->Global()->Get(v8_str("parsed"))->ToObject();
env->Global()->Get(v8_str("parsed"))->ToObject(isolate);
CHECK(parsed_snapshot->Has(v8_str("snapshot")));
CHECK(parsed_snapshot->Has(v8_str("nodes")));
CHECK(parsed_snapshot->Has(v8_str("edges")));
@ -979,17 +980,18 @@ TEST(HeapSnapshotJSONSerialization) {
" \"s\", property_type)");
CHECK(!string_obj_pos_val.IsEmpty());
int string_obj_pos =
static_cast<int>(string_obj_pos_val->ToNumber()->Value());
static_cast<int>(string_obj_pos_val->ToNumber(isolate)->Value());
v8::Local<v8::Object> nodes_array =
parsed_snapshot->Get(v8_str("nodes"))->ToObject();
parsed_snapshot->Get(v8_str("nodes"))->ToObject(isolate);
int string_index = static_cast<int>(
nodes_array->Get(string_obj_pos + 1)->ToNumber()->Value());
nodes_array->Get(string_obj_pos + 1)->ToNumber(isolate)->Value());
CHECK_GT(string_index, 0);
v8::Local<v8::Object> strings_array =
parsed_snapshot->Get(v8_str("strings"))->ToObject();
v8::Local<v8::String> string = strings_array->Get(string_index)->ToString();
parsed_snapshot->Get(v8_str("strings"))->ToObject(isolate);
v8::Local<v8::String> string =
strings_array->Get(string_index)->ToString(isolate);
v8::Local<v8::String> ref_string =
CompileRun(STRING_LITERAL_FOR_TEST)->ToString();
CompileRun(STRING_LITERAL_FOR_TEST)->ToString(isolate);
#undef STRING_LITERAL_FOR_TEST
CHECK_EQ(*v8::String::Utf8Value(ref_string),
*v8::String::Utf8Value(string));
@ -1949,9 +1951,10 @@ TEST(SlowCaseAccessors) {
TEST(HiddenPropertiesFastCase) {
v8::Isolate* isolate = CcTest::isolate();
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
v8::HandleScope scope(isolate);
v8::HeapProfiler* heap_profiler = isolate->GetHeapProfiler();
CompileRun(
"function C(x) { this.a = this; this.b = x; }\n"
@ -1970,7 +1973,7 @@ TEST(HiddenPropertiesFastCase) {
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"));
cHandle->ToObject(isolate)->SetHiddenValue(v8_str("key"), v8_str("val"));
snapshot = heap_profiler->TakeHeapSnapshot(
v8_str("HiddenPropertiesFastCase2"));

View File

@ -2338,7 +2338,8 @@ TEST(OptimizedAllocationAlwaysInNewSpace) {
"f(1); f(2); f(3);"
"%OptimizeFunctionOnNextCall(f);"
"f(4);");
CHECK_EQ(4, res->ToObject()->GetRealNamedProperty(v8_str("x"))->Int32Value());
CHECK_EQ(
4, res.As<v8::Object>()->GetRealNamedProperty(v8_str("x"))->Int32Value());
Handle<JSObject> o =
v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
@ -4297,7 +4298,7 @@ void CheckWeakness(const char* source) {
v8::Persistent<v8::Object> garbage;
{
v8::HandleScope scope(isolate);
garbage.Reset(isolate, CompileRun(source)->ToObject());
garbage.Reset(isolate, CompileRun(source)->ToObject(isolate));
}
weak_ic_cleared = false;
garbage.SetWeak(static_cast<void*>(&garbage), &ClearWeakIC);
@ -4542,7 +4543,7 @@ TEST(Regress357137) {
"eval('function f() {' + locals + 'return function() { return v0; }; }');"
"interrupt();" // This triggers a fake stack overflow in f.
"f()()");
CHECK_EQ(42.0, result->ToNumber()->Value());
CHECK_EQ(42.0, result->ToNumber(isolate)->Value());
}

View File

@ -496,7 +496,7 @@ TEST(EquivalenceOfLoggingAndTraversal) {
}
// The result either be a "true" literal or problem description.
if (!result->IsTrue()) {
v8::Local<v8::String> s = result->ToString();
v8::Local<v8::String> s = result->ToString(isolate);
i::ScopedVector<char> data(s->Utf8Length() + 1);
CHECK_NE(NULL, data.start());
s->WriteUtf8(data.start());

View File

@ -946,11 +946,14 @@ TEST(SerializeToplevelThreeBigStrings) {
CHECK_EQ(600000 + 700000, CompileRun("(a + b).length")->Int32Value());
CHECK_EQ(500000 + 600000, CompileRun("(b + c).length")->Int32Value());
Heap* heap = isolate->heap();
CHECK(heap->InSpace(*v8::Utils::OpenHandle(*CompileRun("a")->ToString()),
CHECK(heap->InSpace(
*v8::Utils::OpenHandle(*CompileRun("a")->ToString(CcTest::isolate())),
OLD_DATA_SPACE));
CHECK(heap->InSpace(*v8::Utils::OpenHandle(*CompileRun("b")->ToString()),
CHECK(heap->InSpace(
*v8::Utils::OpenHandle(*CompileRun("b")->ToString(CcTest::isolate())),
OLD_DATA_SPACE));
CHECK(heap->InSpace(*v8::Utils::OpenHandle(*CompileRun("c")->ToString()),
CHECK(heap->InSpace(
*v8::Utils::OpenHandle(*CompileRun("c")->ToString(CcTest::isolate())),
OLD_DATA_SPACE));
delete cache;
@ -1208,7 +1211,7 @@ TEST(SerializeToplevelIsolates) {
buffer, data->length, v8::ScriptCompiler::CachedData::BufferOwned);
v8::Local<v8::Value> result = script->BindToCurrentContext()->Run();
CHECK(result->ToString()->Equals(v8_str("abcdef")));
CHECK(result->ToString(isolate1)->Equals(v8_str("abcdef")));
}
isolate1->Dispose();
@ -1233,7 +1236,7 @@ TEST(SerializeToplevelIsolates) {
}
CHECK(!cache->rejected);
v8::Local<v8::Value> result = script->BindToCurrentContext()->Run();
CHECK(result->ToString()->Equals(v8_str("abcdef")));
CHECK(result->ToString(isolate2)->Equals(v8_str("abcdef")));
}
DCHECK(toplevel_test_code_event_found);
isolate2->Dispose();
@ -1274,7 +1277,7 @@ TEST(SerializeWithHarmonyScoping) {
buffer, data->length, v8::ScriptCompiler::CachedData::BufferOwned);
v8::Local<v8::Value> result = script->BindToCurrentContext()->Run();
CHECK(result->ToString()->Equals(v8_str("XY")));
CHECK(result->ToString(isolate1)->Equals(v8_str("XY")));
}
isolate1->Dispose();
@ -1299,7 +1302,7 @@ TEST(SerializeWithHarmonyScoping) {
isolate2, &source, v8::ScriptCompiler::kConsumeCodeCache);
}
v8::Local<v8::Value> result = script->BindToCurrentContext()->Run();
CHECK(result->ToString()->Equals(v8_str("XY")));
CHECK(result->ToString(isolate2)->Equals(v8_str("XY")));
}
isolate2->Dispose();
}

View File

@ -1020,11 +1020,12 @@ TEST(JSONStringifySliceMadeExternal) {
// into a two-byte external string. Check that JSON.stringify works.
v8::HandleScope handle_scope(CcTest::isolate());
v8::Handle<v8::String> underlying =
CompileRun("var underlying = 'abcdefghijklmnopqrstuvwxyz';"
"underlying")->ToString();
v8::Handle<v8::String> slice =
CompileRun("var slice = underlying.slice(1);"
"slice")->ToString();
CompileRun(
"var underlying = 'abcdefghijklmnopqrstuvwxyz';"
"underlying")->ToString(CcTest::isolate());
v8::Handle<v8::String> slice = CompileRun(
"var slice = underlying.slice(1);"
"slice")->ToString(CcTest::isolate());
CHECK(v8::Utils::OpenHandle(*slice)->IsSlicedString());
CHECK(v8::Utils::OpenHandle(*underlying)->IsSeqOneByteString());
@ -1082,7 +1083,7 @@ TEST(CachedHashOverflow) {
CHECK_EQ(results[i]->IsNumber(), result->IsNumber());
if (result->IsNumber()) {
CHECK_EQ(Object::ToSmi(isolate, results[i]).ToHandleChecked()->value(),
result->ToInt32()->Value());
result->ToInt32(CcTest::isolate())->Value());
}
}
}
@ -1313,7 +1314,7 @@ TEST(CountBreakIterator) {
" return iterator.next();"
"})();");
CHECK(result->IsNumber());
int uses = result->ToInt32()->Value() == 0 ? 0 : 1;
int uses = result->ToInt32(CcTest::isolate())->Value() == 0 ? 0 : 1;
CHECK_EQ(uses, use_counts[v8::Isolate::kBreakIterator]);
// Make sure GC cleans up the break iterator, so we don't get a memory leak
// reported by ASAN.