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

Side by Side Diff: test/cctest/test-api.cc

Issue 153953005: A64: Synchronize with r16993. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/cctest/test-accessors.cc ('k') | test/cctest/test-debug.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 Local<Context> local_env; 197 Local<Context> local_env;
198 { 198 {
199 LocalContext env; 199 LocalContext env;
200 local_env = env.local(); 200 local_env = env.local();
201 } 201 }
202 202
203 // Local context should still be live. 203 // Local context should still be live.
204 CHECK(!local_env.IsEmpty()); 204 CHECK(!local_env.IsEmpty());
205 local_env->Enter(); 205 local_env->Enter();
206 206
207 v8::Handle<v8::Primitive> undef = v8::Undefined(); 207 v8::Handle<v8::Primitive> undef = v8::Undefined(CcTest::isolate());
208 CHECK(!undef.IsEmpty()); 208 CHECK(!undef.IsEmpty());
209 CHECK(undef->IsUndefined()); 209 CHECK(undef->IsUndefined());
210 210
211 const char* c_source = "1 + 2 + 3"; 211 const char* c_source = "1 + 2 + 3";
212 Local<String> source = String::New(c_source); 212 Local<String> source = String::New(c_source);
213 Local<Script> script = Script::Compile(source); 213 Local<Script> script = Script::Compile(source);
214 CHECK_EQ(6, script->Run()->Int32Value()); 214 CHECK_EQ(6, script->Run()->Int32Value());
215 215
216 local_env->Exit(); 216 local_env->Exit();
217 } 217 }
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 CHECK(value7->IsTrue()); 384 CHECK(value7->IsTrue());
385 385
386 v8::Handle<Value> value8 = CompileRun( 386 v8::Handle<Value> value8 = CompileRun(
387 "Fun2(new Cons1(), new Cons2()) == '[object Cons1],[object Cons2]'"); 387 "Fun2(new Cons1(), new Cons2()) == '[object Cons1],[object Cons2]'");
388 CHECK(value8->IsTrue()); 388 CHECK(value8->IsTrue());
389 } 389 }
390 390
391 391
392 THREADED_TEST(HulIgennem) { 392 THREADED_TEST(HulIgennem) {
393 LocalContext env; 393 LocalContext env;
394 v8::HandleScope scope(env->GetIsolate()); 394 v8::Isolate* isolate = env->GetIsolate();
395 v8::Handle<v8::Primitive> undef = v8::Undefined(); 395 v8::HandleScope scope(isolate);
396 v8::Handle<v8::Primitive> undef = v8::Undefined(isolate);
396 Local<String> undef_str = undef->ToString(); 397 Local<String> undef_str = undef->ToString();
397 char* value = i::NewArray<char>(undef_str->Utf8Length() + 1); 398 char* value = i::NewArray<char>(undef_str->Utf8Length() + 1);
398 undef_str->WriteUtf8(value); 399 undef_str->WriteUtf8(value);
399 CHECK_EQ(0, strcmp(value, "undefined")); 400 CHECK_EQ(0, strcmp(value, "undefined"));
400 i::DeleteArray(value); 401 i::DeleteArray(value);
401 } 402 }
402 403
403 404
404 THREADED_TEST(Access) { 405 THREADED_TEST(Access) {
405 LocalContext env; 406 LocalContext env;
406 v8::HandleScope scope(env->GetIsolate()); 407 v8::Isolate* isolate = env->GetIsolate();
408 v8::HandleScope scope(isolate);
407 Local<v8::Object> obj = v8::Object::New(); 409 Local<v8::Object> obj = v8::Object::New();
408 Local<Value> foo_before = obj->Get(v8_str("foo")); 410 Local<Value> foo_before = obj->Get(v8_str("foo"));
409 CHECK(foo_before->IsUndefined()); 411 CHECK(foo_before->IsUndefined());
410 Local<String> bar_str = v8_str("bar"); 412 Local<String> bar_str = v8_str("bar");
411 obj->Set(v8_str("foo"), bar_str); 413 obj->Set(v8_str("foo"), bar_str);
412 Local<Value> foo_after = obj->Get(v8_str("foo")); 414 Local<Value> foo_after = obj->Get(v8_str("foo"));
413 CHECK(!foo_after->IsUndefined()); 415 CHECK(!foo_after->IsUndefined());
414 CHECK(foo_after->IsString()); 416 CHECK(foo_after->IsString());
415 CHECK_EQ(bar_str, foo_after); 417 CHECK_EQ(bar_str, foo_after);
416 } 418 }
(...skipping 1265 matching lines...) Expand 10 before | Expand all | Expand 10 after
1682 LocalContext env; 1684 LocalContext env;
1683 v8::HandleScope scope(env->GetIsolate()); 1685 v8::HandleScope scope(env->GetIsolate());
1684 double PI = 3.1415926; 1686 double PI = 3.1415926;
1685 Local<v8::Number> pi_obj = v8::Number::New(PI); 1687 Local<v8::Number> pi_obj = v8::Number::New(PI);
1686 CHECK_EQ(PI, pi_obj->NumberValue()); 1688 CHECK_EQ(PI, pi_obj->NumberValue());
1687 } 1689 }
1688 1690
1689 1691
1690 THREADED_TEST(ToNumber) { 1692 THREADED_TEST(ToNumber) {
1691 LocalContext env; 1693 LocalContext env;
1692 v8::HandleScope scope(env->GetIsolate()); 1694 v8::Isolate* isolate = CcTest::isolate();
1695 v8::HandleScope scope(isolate);
1693 Local<String> str = v8_str("3.1415926"); 1696 Local<String> str = v8_str("3.1415926");
1694 CHECK_EQ(3.1415926, str->NumberValue()); 1697 CHECK_EQ(3.1415926, str->NumberValue());
1695 v8::Handle<v8::Boolean> t = v8::True(); 1698 v8::Handle<v8::Boolean> t = v8::True(isolate);
1696 CHECK_EQ(1.0, t->NumberValue()); 1699 CHECK_EQ(1.0, t->NumberValue());
1697 v8::Handle<v8::Boolean> f = v8::False(); 1700 v8::Handle<v8::Boolean> f = v8::False(isolate);
1698 CHECK_EQ(0.0, f->NumberValue()); 1701 CHECK_EQ(0.0, f->NumberValue());
1699 } 1702 }
1700 1703
1701 1704
1702 THREADED_TEST(Date) { 1705 THREADED_TEST(Date) {
1703 LocalContext env; 1706 LocalContext env;
1704 v8::HandleScope scope(env->GetIsolate()); 1707 v8::HandleScope scope(env->GetIsolate());
1705 double PI = 3.1415926; 1708 double PI = 3.1415926;
1706 Local<Value> date = v8::Date::New(PI); 1709 Local<Value> date = v8::Date::New(PI);
1707 CHECK_EQ(3.0, date->NumberValue()); 1710 CHECK_EQ(3.0, date->NumberValue());
1708 date.As<v8::Date>()->Set(v8_str("property"), v8::Integer::New(42)); 1711 date.As<v8::Date>()->Set(v8_str("property"), v8::Integer::New(42));
1709 CHECK_EQ(42, date.As<v8::Date>()->Get(v8_str("property"))->Int32Value()); 1712 CHECK_EQ(42, date.As<v8::Date>()->Get(v8_str("property"))->Int32Value());
1710 } 1713 }
1711 1714
1712 1715
1713 THREADED_TEST(Boolean) { 1716 THREADED_TEST(Boolean) {
1714 LocalContext env; 1717 LocalContext env;
1715 v8::HandleScope scope(env->GetIsolate()); 1718 v8::HandleScope scope(env->GetIsolate());
1716 v8::Handle<v8::Boolean> t = v8::True(); 1719 v8::Handle<v8::Boolean> t = v8::True(CcTest::isolate());
1717 CHECK(t->Value()); 1720 CHECK(t->Value());
1718 v8::Handle<v8::Boolean> f = v8::False(); 1721 v8::Handle<v8::Boolean> f = v8::False(CcTest::isolate());
1719 CHECK(!f->Value()); 1722 CHECK(!f->Value());
1720 v8::Handle<v8::Primitive> u = v8::Undefined(); 1723 v8::Handle<v8::Primitive> u = v8::Undefined(CcTest::isolate());
1721 CHECK(!u->BooleanValue()); 1724 CHECK(!u->BooleanValue());
1722 v8::Handle<v8::Primitive> n = v8::Null(); 1725 v8::Handle<v8::Primitive> n = v8::Null(CcTest::isolate());
1723 CHECK(!n->BooleanValue()); 1726 CHECK(!n->BooleanValue());
1724 v8::Handle<String> str1 = v8_str(""); 1727 v8::Handle<String> str1 = v8_str("");
1725 CHECK(!str1->BooleanValue()); 1728 CHECK(!str1->BooleanValue());
1726 v8::Handle<String> str2 = v8_str("x"); 1729 v8::Handle<String> str2 = v8_str("x");
1727 CHECK(str2->BooleanValue()); 1730 CHECK(str2->BooleanValue());
1728 CHECK(!v8::Number::New(0)->BooleanValue()); 1731 CHECK(!v8::Number::New(0)->BooleanValue());
1729 CHECK(v8::Number::New(-1)->BooleanValue()); 1732 CHECK(v8::Number::New(-1)->BooleanValue());
1730 CHECK(v8::Number::New(1)->BooleanValue()); 1733 CHECK(v8::Number::New(1)->BooleanValue());
1731 CHECK(v8::Number::New(42)->BooleanValue()); 1734 CHECK(v8::Number::New(42)->BooleanValue());
1732 CHECK(!v8_compile("NaN")->Run()->BooleanValue()); 1735 CHECK(!v8_compile("NaN")->Run()->BooleanValue());
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after
2444 2447
2445 env->Global()->Set(v8_str("depth"), v8::Integer::New(0)); 2448 env->Global()->Set(v8_str("depth"), v8::Integer::New(0));
2446 Script::Compile(v8_str("callFunctionRecursively()"))->Run(); 2449 Script::Compile(v8_str("callFunctionRecursively()"))->Run();
2447 } 2450 }
2448 2451
2449 2452
2450 static void ThrowingPropertyHandlerGet( 2453 static void ThrowingPropertyHandlerGet(
2451 Local<String> key, 2454 Local<String> key,
2452 const v8::PropertyCallbackInfo<v8::Value>& info) { 2455 const v8::PropertyCallbackInfo<v8::Value>& info) {
2453 ApiTestFuzzer::Fuzz(); 2456 ApiTestFuzzer::Fuzz();
2454 info.GetReturnValue().Set(v8::ThrowException(key)); 2457 info.GetReturnValue().Set(info.GetIsolate()->ThrowException(key));
2455 } 2458 }
2456 2459
2457 2460
2458 static void ThrowingPropertyHandlerSet( 2461 static void ThrowingPropertyHandlerSet(
2459 Local<String> key, 2462 Local<String> key,
2460 Local<Value>, 2463 Local<Value>,
2461 const v8::PropertyCallbackInfo<v8::Value>& info) { 2464 const v8::PropertyCallbackInfo<v8::Value>& info) {
2462 v8::ThrowException(key); 2465 info.GetIsolate()->ThrowException(key);
2463 info.GetReturnValue().SetUndefined(); // not the same as empty handle 2466 info.GetReturnValue().SetUndefined(); // not the same as empty handle
2464 } 2467 }
2465 2468
2466 2469
2467 THREADED_TEST(CallbackExceptionRegression) { 2470 THREADED_TEST(CallbackExceptionRegression) {
2468 v8::HandleScope scope(CcTest::isolate()); 2471 v8::HandleScope scope(CcTest::isolate());
2469 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); 2472 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New();
2470 obj->SetNamedPropertyHandler(ThrowingPropertyHandlerGet, 2473 obj->SetNamedPropertyHandler(ThrowingPropertyHandlerGet,
2471 ThrowingPropertyHandlerSet); 2474 ThrowingPropertyHandlerSet);
2472 LocalContext env; 2475 LocalContext env;
(...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after
3247 CHECK(global.IsEmpty()); 3250 CHECK(global.IsEmpty());
3248 CHECK_EQ(global_handles->global_handles_count(), initial_handle_count + 1); 3251 CHECK_EQ(global_handles->global_handles_count(), initial_handle_count + 1);
3249 global_handles->Destroy(reinterpret_cast<i::Object**>(str)); 3252 global_handles->Destroy(reinterpret_cast<i::Object**>(str));
3250 CHECK_EQ(global_handles->global_handles_count(), initial_handle_count); 3253 CHECK_EQ(global_handles->global_handles_count(), initial_handle_count);
3251 } 3254 }
3252 3255
3253 3256
3254 THREADED_TEST(GlobalHandleUpcast) { 3257 THREADED_TEST(GlobalHandleUpcast) {
3255 v8::Isolate* isolate = CcTest::isolate(); 3258 v8::Isolate* isolate = CcTest::isolate();
3256 v8::HandleScope scope(isolate); 3259 v8::HandleScope scope(isolate);
3257 v8::Local<String> local = v8::Local<String>::New(v8_str("str")); 3260 v8::Local<String> local = v8::Local<String>::New(isolate, v8_str("str"));
3258 v8::Persistent<String> global_string(isolate, local); 3261 v8::Persistent<String> global_string(isolate, local);
3259 v8::Persistent<Value>& global_value = 3262 v8::Persistent<Value>& global_value =
3260 v8::Persistent<Value>::Cast(global_string); 3263 v8::Persistent<Value>::Cast(global_string);
3261 CHECK(v8::Local<v8::Value>::New(isolate, global_value)->IsString()); 3264 CHECK(v8::Local<v8::Value>::New(isolate, global_value)->IsString());
3262 CHECK(global_string == v8::Persistent<String>::Cast(global_value)); 3265 CHECK(global_string == v8::Persistent<String>::Cast(global_value));
3263 global_string.Dispose(); 3266 global_string.Dispose();
3264 } 3267 }
3265 3268
3266 3269
3267 THREADED_TEST(HandleEquality) { 3270 THREADED_TEST(HandleEquality) {
(...skipping 29 matching lines...) Expand all
3297 CHECK_EQ(local1 == anotherLocal1, true); 3300 CHECK_EQ(local1 == anotherLocal1, true);
3298 CHECK_EQ(local1 != anotherLocal1, false); 3301 CHECK_EQ(local1 != anotherLocal1, false);
3299 } 3302 }
3300 global1.Dispose(); 3303 global1.Dispose();
3301 global2.Dispose(); 3304 global2.Dispose();
3302 } 3305 }
3303 3306
3304 3307
3305 THREADED_TEST(LocalHandle) { 3308 THREADED_TEST(LocalHandle) {
3306 v8::HandleScope scope(CcTest::isolate()); 3309 v8::HandleScope scope(CcTest::isolate());
3307 v8::Local<String> local = v8::Local<String>::New(v8_str("str")); 3310 v8::Local<String> local =
3308 CHECK_EQ(local->Length(), 3); 3311 v8::Local<String>::New(CcTest::isolate(), v8_str("str"));
3309
3310 local = v8::Local<String>::New(CcTest::isolate(), v8_str("str"));
3311 CHECK_EQ(local->Length(), 3); 3312 CHECK_EQ(local->Length(), 3);
3312 } 3313 }
3313 3314
3314 3315
3315 class WeakCallCounter { 3316 class WeakCallCounter {
3316 public: 3317 public:
3317 explicit WeakCallCounter(int id) : id_(id), number_of_weak_calls_(0) { } 3318 explicit WeakCallCounter(int id) : id_(id), number_of_weak_calls_(0) { }
3318 int id() { return id_; } 3319 int id() { return id_; }
3319 void increment() { number_of_weak_calls_++; } 3320 void increment() { number_of_weak_calls_++; }
3320 int NumberOfWeakCalls() { return number_of_weak_calls_; } 3321 int NumberOfWeakCalls() { return number_of_weak_calls_; }
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
3755 static void check_message_3(v8::Handle<v8::Message> message, 3756 static void check_message_3(v8::Handle<v8::Message> message,
3756 v8::Handle<Value> data) { 3757 v8::Handle<Value> data) {
3757 CHECK(message->IsSharedCrossOrigin()); 3758 CHECK(message->IsSharedCrossOrigin());
3758 CHECK_EQ(6.75, message->GetScriptResourceName()->NumberValue()); 3759 CHECK_EQ(6.75, message->GetScriptResourceName()->NumberValue());
3759 message_received = true; 3760 message_received = true;
3760 } 3761 }
3761 3762
3762 3763
3763 TEST(MessageHandler3) { 3764 TEST(MessageHandler3) {
3764 message_received = false; 3765 message_received = false;
3765 v8::HandleScope scope(CcTest::isolate()); 3766 v8::Isolate* isolate = CcTest::isolate();
3767 v8::HandleScope scope(isolate);
3766 CHECK(!message_received); 3768 CHECK(!message_received);
3767 v8::V8::AddMessageListener(check_message_3); 3769 v8::V8::AddMessageListener(check_message_3);
3768 LocalContext context; 3770 LocalContext context;
3769 v8::ScriptOrigin origin = 3771 v8::ScriptOrigin origin =
3770 v8::ScriptOrigin(v8_str("6.75"), 3772 v8::ScriptOrigin(v8_str("6.75"),
3771 v8::Integer::New(1), 3773 v8::Integer::New(1, isolate),
3772 v8::Integer::New(2), 3774 v8::Integer::New(2, isolate),
3773 v8::True()); 3775 v8::True(isolate));
3774 v8::Handle<v8::Script> script = Script::Compile(v8_str("throw 'error'"), 3776 v8::Handle<v8::Script> script = Script::Compile(v8_str("throw 'error'"),
3775 &origin); 3777 &origin);
3776 script->Run(); 3778 script->Run();
3777 CHECK(message_received); 3779 CHECK(message_received);
3778 // clear out the message listener 3780 // clear out the message listener
3779 v8::V8::RemoveMessageListeners(check_message_3); 3781 v8::V8::RemoveMessageListeners(check_message_3);
3780 } 3782 }
3781 3783
3782 3784
3783 static void check_message_4(v8::Handle<v8::Message> message, 3785 static void check_message_4(v8::Handle<v8::Message> message,
3784 v8::Handle<Value> data) { 3786 v8::Handle<Value> data) {
3785 CHECK(!message->IsSharedCrossOrigin()); 3787 CHECK(!message->IsSharedCrossOrigin());
3786 CHECK_EQ(6.75, message->GetScriptResourceName()->NumberValue()); 3788 CHECK_EQ(6.75, message->GetScriptResourceName()->NumberValue());
3787 message_received = true; 3789 message_received = true;
3788 } 3790 }
3789 3791
3790 3792
3791 TEST(MessageHandler4) { 3793 TEST(MessageHandler4) {
3792 message_received = false; 3794 message_received = false;
3793 v8::HandleScope scope(CcTest::isolate()); 3795 v8::Isolate* isolate = CcTest::isolate();
3796 v8::HandleScope scope(isolate);
3794 CHECK(!message_received); 3797 CHECK(!message_received);
3795 v8::V8::AddMessageListener(check_message_4); 3798 v8::V8::AddMessageListener(check_message_4);
3796 LocalContext context; 3799 LocalContext context;
3797 v8::ScriptOrigin origin = 3800 v8::ScriptOrigin origin =
3798 v8::ScriptOrigin(v8_str("6.75"), 3801 v8::ScriptOrigin(v8_str("6.75"),
3799 v8::Integer::New(1), 3802 v8::Integer::New(1, isolate),
3800 v8::Integer::New(2), 3803 v8::Integer::New(2, isolate),
3801 v8::False()); 3804 v8::False(isolate));
3802 v8::Handle<v8::Script> script = Script::Compile(v8_str("throw 'error'"), 3805 v8::Handle<v8::Script> script = Script::Compile(v8_str("throw 'error'"),
3803 &origin); 3806 &origin);
3804 script->Run(); 3807 script->Run();
3805 CHECK(message_received); 3808 CHECK(message_received);
3806 // clear out the message listener 3809 // clear out the message listener
3807 v8::V8::RemoveMessageListeners(check_message_4); 3810 v8::V8::RemoveMessageListeners(check_message_4);
3808 } 3811 }
3809 3812
3810 3813
3811 static void check_message_5a(v8::Handle<v8::Message> message, 3814 static void check_message_5a(v8::Handle<v8::Message> message,
3812 v8::Handle<Value> data) { 3815 v8::Handle<Value> data) {
3813 CHECK(message->IsSharedCrossOrigin()); 3816 CHECK(message->IsSharedCrossOrigin());
3814 CHECK_EQ(6.75, message->GetScriptResourceName()->NumberValue()); 3817 CHECK_EQ(6.75, message->GetScriptResourceName()->NumberValue());
3815 message_received = true; 3818 message_received = true;
3816 } 3819 }
3817 3820
3818 3821
3819 static void check_message_5b(v8::Handle<v8::Message> message, 3822 static void check_message_5b(v8::Handle<v8::Message> message,
3820 v8::Handle<Value> data) { 3823 v8::Handle<Value> data) {
3821 CHECK(!message->IsSharedCrossOrigin()); 3824 CHECK(!message->IsSharedCrossOrigin());
3822 CHECK_EQ(6.75, message->GetScriptResourceName()->NumberValue()); 3825 CHECK_EQ(6.75, message->GetScriptResourceName()->NumberValue());
3823 message_received = true; 3826 message_received = true;
3824 } 3827 }
3825 3828
3826 3829
3827 TEST(MessageHandler5) { 3830 TEST(MessageHandler5) {
3828 message_received = false; 3831 message_received = false;
3829 v8::HandleScope scope(CcTest::isolate()); 3832 v8::Isolate* isolate = CcTest::isolate();
3833 v8::HandleScope scope(isolate);
3830 CHECK(!message_received); 3834 CHECK(!message_received);
3831 v8::V8::AddMessageListener(check_message_5a); 3835 v8::V8::AddMessageListener(check_message_5a);
3832 LocalContext context; 3836 LocalContext context;
3833 v8::ScriptOrigin origin = 3837 v8::ScriptOrigin origin =
3834 v8::ScriptOrigin(v8_str("6.75"), 3838 v8::ScriptOrigin(v8_str("6.75"),
3835 v8::Integer::New(1), 3839 v8::Integer::New(1, isolate),
3836 v8::Integer::New(2), 3840 v8::Integer::New(2, isolate),
3837 v8::True()); 3841 v8::True(isolate));
3838 v8::Handle<v8::Script> script = Script::Compile(v8_str("throw 'error'"), 3842 v8::Handle<v8::Script> script = Script::Compile(v8_str("throw 'error'"),
3839 &origin); 3843 &origin);
3840 script->Run(); 3844 script->Run();
3841 CHECK(message_received); 3845 CHECK(message_received);
3842 // clear out the message listener 3846 // clear out the message listener
3843 v8::V8::RemoveMessageListeners(check_message_5a); 3847 v8::V8::RemoveMessageListeners(check_message_5a);
3844 3848
3845 message_received = false; 3849 message_received = false;
3846 v8::V8::AddMessageListener(check_message_5b); 3850 v8::V8::AddMessageListener(check_message_5b);
3847 origin = 3851 origin =
3848 v8::ScriptOrigin(v8_str("6.75"), 3852 v8::ScriptOrigin(v8_str("6.75"),
3849 v8::Integer::New(1), 3853 v8::Integer::New(1, isolate),
3850 v8::Integer::New(2), 3854 v8::Integer::New(2, isolate),
3851 v8::False()); 3855 v8::False(isolate));
3852 script = Script::Compile(v8_str("throw 'error'"), 3856 script = Script::Compile(v8_str("throw 'error'"),
3853 &origin); 3857 &origin);
3854 script->Run(); 3858 script->Run();
3855 CHECK(message_received); 3859 CHECK(message_received);
3856 // clear out the message listener 3860 // clear out the message listener
3857 v8::V8::RemoveMessageListeners(check_message_5b); 3861 v8::V8::RemoveMessageListeners(check_message_5b);
3858 } 3862 }
3859 3863
3860 3864
3861 THREADED_TEST(GetSetProperty) { 3865 THREADED_TEST(GetSetProperty) {
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
4314 // Positive zero 4318 // Positive zero
4315 CompileRun("var obj = -0.0;"); 4319 CompileRun("var obj = -0.0;");
4316 obj = env->Global()->Get(v8_str("obj")); 4320 obj = env->Global()->Get(v8_str("obj"));
4317 CHECK(!obj->IsInt32()); 4321 CHECK(!obj->IsInt32());
4318 CHECK(!obj->IsUint32()); 4322 CHECK(!obj->IsUint32());
4319 } 4323 }
4320 4324
4321 4325
4322 THREADED_TEST(ConversionException) { 4326 THREADED_TEST(ConversionException) {
4323 LocalContext env; 4327 LocalContext env;
4324 v8::HandleScope scope(env->GetIsolate()); 4328 v8::Isolate* isolate = env->GetIsolate();
4329 v8::HandleScope scope(isolate);
4325 CompileRun( 4330 CompileRun(
4326 "function TestClass() { };" 4331 "function TestClass() { };"
4327 "TestClass.prototype.toString = function () { throw 'uncle?'; };" 4332 "TestClass.prototype.toString = function () { throw 'uncle?'; };"
4328 "var obj = new TestClass();"); 4333 "var obj = new TestClass();");
4329 Local<Value> obj = env->Global()->Get(v8_str("obj")); 4334 Local<Value> obj = env->Global()->Get(v8_str("obj"));
4330 4335
4331 v8::TryCatch try_catch; 4336 v8::TryCatch try_catch;
4332 4337
4333 Local<Value> to_string_result = obj->ToString(); 4338 Local<Value> to_string_result = obj->ToString();
4334 CHECK(to_string_result.IsEmpty()); 4339 CHECK(to_string_result.IsEmpty());
4335 CheckUncle(&try_catch); 4340 CheckUncle(&try_catch);
4336 4341
4337 Local<Value> to_number_result = obj->ToNumber(); 4342 Local<Value> to_number_result = obj->ToNumber();
4338 CHECK(to_number_result.IsEmpty()); 4343 CHECK(to_number_result.IsEmpty());
4339 CheckUncle(&try_catch); 4344 CheckUncle(&try_catch);
4340 4345
4341 Local<Value> to_integer_result = obj->ToInteger(); 4346 Local<Value> to_integer_result = obj->ToInteger();
4342 CHECK(to_integer_result.IsEmpty()); 4347 CHECK(to_integer_result.IsEmpty());
4343 CheckUncle(&try_catch); 4348 CheckUncle(&try_catch);
4344 4349
4345 Local<Value> to_uint32_result = obj->ToUint32(); 4350 Local<Value> to_uint32_result = obj->ToUint32();
4346 CHECK(to_uint32_result.IsEmpty()); 4351 CHECK(to_uint32_result.IsEmpty());
4347 CheckUncle(&try_catch); 4352 CheckUncle(&try_catch);
4348 4353
4349 Local<Value> to_int32_result = obj->ToInt32(); 4354 Local<Value> to_int32_result = obj->ToInt32();
4350 CHECK(to_int32_result.IsEmpty()); 4355 CHECK(to_int32_result.IsEmpty());
4351 CheckUncle(&try_catch); 4356 CheckUncle(&try_catch);
4352 4357
4353 Local<Value> to_object_result = v8::Undefined()->ToObject(); 4358 Local<Value> to_object_result = v8::Undefined(isolate)->ToObject();
4354 CHECK(to_object_result.IsEmpty()); 4359 CHECK(to_object_result.IsEmpty());
4355 CHECK(try_catch.HasCaught()); 4360 CHECK(try_catch.HasCaught());
4356 try_catch.Reset(); 4361 try_catch.Reset();
4357 4362
4358 int32_t int32_value = obj->Int32Value(); 4363 int32_t int32_value = obj->Int32Value();
4359 CHECK_EQ(0, int32_value); 4364 CHECK_EQ(0, int32_value);
4360 CheckUncle(&try_catch); 4365 CheckUncle(&try_catch);
4361 4366
4362 uint32_t uint32_value = obj->Uint32Value(); 4367 uint32_t uint32_value = obj->Uint32Value();
4363 CHECK_EQ(0, uint32_value); 4368 CHECK_EQ(0, uint32_value);
4364 CheckUncle(&try_catch); 4369 CheckUncle(&try_catch);
4365 4370
4366 double number_value = obj->NumberValue(); 4371 double number_value = obj->NumberValue();
4367 CHECK_NE(0, std::isnan(number_value)); 4372 CHECK_NE(0, std::isnan(number_value));
4368 CheckUncle(&try_catch); 4373 CheckUncle(&try_catch);
4369 4374
4370 int64_t integer_value = obj->IntegerValue(); 4375 int64_t integer_value = obj->IntegerValue();
4371 CHECK_EQ(0.0, static_cast<double>(integer_value)); 4376 CHECK_EQ(0.0, static_cast<double>(integer_value));
4372 CheckUncle(&try_catch); 4377 CheckUncle(&try_catch);
4373 } 4378 }
4374 4379
4375 4380
4376 void ThrowFromC(const v8::FunctionCallbackInfo<v8::Value>& args) { 4381 void ThrowFromC(const v8::FunctionCallbackInfo<v8::Value>& args) {
4377 ApiTestFuzzer::Fuzz(); 4382 ApiTestFuzzer::Fuzz();
4378 v8::ThrowException(v8_str("konto")); 4383 args.GetIsolate()->ThrowException(v8_str("konto"));
4379 } 4384 }
4380 4385
4381 4386
4382 void CCatcher(const v8::FunctionCallbackInfo<v8::Value>& args) { 4387 void CCatcher(const v8::FunctionCallbackInfo<v8::Value>& args) {
4383 if (args.Length() < 1) { 4388 if (args.Length() < 1) {
4384 args.GetReturnValue().Set(false); 4389 args.GetReturnValue().Set(false);
4385 return; 4390 return;
4386 } 4391 }
4387 v8::HandleScope scope(args.GetIsolate()); 4392 v8::HandleScope scope(args.GetIsolate());
4388 v8::TryCatch try_catch; 4393 v8::TryCatch try_catch;
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
4651 } 4656 }
4652 4657
4653 4658
4654 4659
4655 void CThrowCountDown(const v8::FunctionCallbackInfo<v8::Value>& args) { 4660 void CThrowCountDown(const v8::FunctionCallbackInfo<v8::Value>& args) {
4656 ApiTestFuzzer::Fuzz(); 4661 ApiTestFuzzer::Fuzz();
4657 CHECK_EQ(4, args.Length()); 4662 CHECK_EQ(4, args.Length());
4658 int count = args[0]->Int32Value(); 4663 int count = args[0]->Int32Value();
4659 int cInterval = args[2]->Int32Value(); 4664 int cInterval = args[2]->Int32Value();
4660 if (count == 0) { 4665 if (count == 0) {
4661 v8::ThrowException(v8_str("FromC")); 4666 args.GetIsolate()->ThrowException(v8_str("FromC"));
4662 return; 4667 return;
4663 } else { 4668 } else {
4664 Local<v8::Object> global = 4669 Local<v8::Object> global =
4665 args.GetIsolate()->GetCurrentContext()->Global(); 4670 args.GetIsolate()->GetCurrentContext()->Global();
4666 Local<Value> fun = global->Get(v8_str("JSThrowCountDown")); 4671 Local<Value> fun = global->Get(v8_str("JSThrowCountDown"));
4667 v8::Handle<Value> argv[] = { v8_num(count - 1), 4672 v8::Handle<Value> argv[] = { v8_num(count - 1),
4668 args[1], 4673 args[1],
4669 args[2], 4674 args[2],
4670 args[3] }; 4675 args[3] };
4671 if (count % cInterval == 0) { 4676 if (count % cInterval == 0) {
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
4791 4796
4792 // JS[6] C[5] *JS[4] @C[3] JS[2] C[1] JS[0] 4797 // JS[6] C[5] *JS[4] @C[3] JS[2] C[1] JS[0]
4793 v8::Handle<Value> a5[argc] = { v8_num(6), v8_num(4), v8_num(3), v8_num(3) }; 4798 v8::Handle<Value> a5[argc] = { v8_num(6), v8_num(4), v8_num(3), v8_num(3) };
4794 fun->Call(fun, argc, a5); 4799 fun->Call(fun, argc, a5);
4795 } 4800 }
4796 4801
4797 4802
4798 void ThrowValue(const v8::FunctionCallbackInfo<v8::Value>& args) { 4803 void ThrowValue(const v8::FunctionCallbackInfo<v8::Value>& args) {
4799 ApiTestFuzzer::Fuzz(); 4804 ApiTestFuzzer::Fuzz();
4800 CHECK_EQ(1, args.Length()); 4805 CHECK_EQ(1, args.Length());
4801 v8::ThrowException(args[0]); 4806 args.GetIsolate()->ThrowException(args[0]);
4802 } 4807 }
4803 4808
4804 4809
4805 THREADED_TEST(ThrowValues) { 4810 THREADED_TEST(ThrowValues) {
4806 v8::HandleScope scope(CcTest::isolate()); 4811 v8::HandleScope scope(CcTest::isolate());
4807 Local<ObjectTemplate> templ = ObjectTemplate::New(); 4812 Local<ObjectTemplate> templ = ObjectTemplate::New();
4808 templ->Set(v8_str("Throw"), v8::FunctionTemplate::New(ThrowValue)); 4813 templ->Set(v8_str("Throw"), v8::FunctionTemplate::New(ThrowValue));
4809 LocalContext context(0, templ); 4814 LocalContext context(0, templ);
4810 v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun( 4815 v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun(
4811 "function Run(obj) {" 4816 "function Run(obj) {"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
4889 4894
4890 4895
4891 static void TryCatchNestedHelper(int depth) { 4896 static void TryCatchNestedHelper(int depth) {
4892 if (depth > 0) { 4897 if (depth > 0) {
4893 v8::TryCatch try_catch; 4898 v8::TryCatch try_catch;
4894 try_catch.SetVerbose(true); 4899 try_catch.SetVerbose(true);
4895 TryCatchNestedHelper(depth - 1); 4900 TryCatchNestedHelper(depth - 1);
4896 CHECK(try_catch.HasCaught()); 4901 CHECK(try_catch.HasCaught());
4897 try_catch.ReThrow(); 4902 try_catch.ReThrow();
4898 } else { 4903 } else {
4899 v8::ThrowException(v8_str("back")); 4904 CcTest::isolate()->ThrowException(v8_str("back"));
4900 } 4905 }
4901 } 4906 }
4902 4907
4903 4908
4904 TEST(TryCatchNested) { 4909 TEST(TryCatchNested) {
4905 v8::V8::Initialize(); 4910 v8::V8::Initialize();
4906 LocalContext context; 4911 LocalContext context;
4907 v8::HandleScope scope(context->GetIsolate()); 4912 v8::HandleScope scope(context->GetIsolate());
4908 v8::TryCatch try_catch; 4913 v8::TryCatch try_catch;
4909 TryCatchNestedHelper(5); 4914 TryCatchNestedHelper(5);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
4966 CHECK_EQ(v8_num(1), v8_num(1)); 4971 CHECK_EQ(v8_num(1), v8_num(1));
4967 CHECK_EQ(v8_num(1.00), v8_num(1)); 4972 CHECK_EQ(v8_num(1.00), v8_num(1));
4968 CHECK_NE(v8_num(1), v8_num(2)); 4973 CHECK_NE(v8_num(1), v8_num(2));
4969 4974
4970 // Assume String is not internalized. 4975 // Assume String is not internalized.
4971 CHECK(v8_str("a")->StrictEquals(v8_str("a"))); 4976 CHECK(v8_str("a")->StrictEquals(v8_str("a")));
4972 CHECK(!v8_str("a")->StrictEquals(v8_str("b"))); 4977 CHECK(!v8_str("a")->StrictEquals(v8_str("b")));
4973 CHECK(!v8_str("5")->StrictEquals(v8_num(5))); 4978 CHECK(!v8_str("5")->StrictEquals(v8_num(5)));
4974 CHECK(v8_num(1)->StrictEquals(v8_num(1))); 4979 CHECK(v8_num(1)->StrictEquals(v8_num(1)));
4975 CHECK(!v8_num(1)->StrictEquals(v8_num(2))); 4980 CHECK(!v8_num(1)->StrictEquals(v8_num(2)));
4976 CHECK(v8_num(0)->StrictEquals(v8_num(-0))); 4981 CHECK(v8_num(0.0)->StrictEquals(v8_num(-0.0)));
4977 Local<Value> not_a_number = v8_num(i::OS::nan_value()); 4982 Local<Value> not_a_number = v8_num(i::OS::nan_value());
4978 CHECK(!not_a_number->StrictEquals(not_a_number)); 4983 CHECK(!not_a_number->StrictEquals(not_a_number));
4979 CHECK(v8::False()->StrictEquals(v8::False())); 4984 CHECK(v8::False(isolate)->StrictEquals(v8::False(isolate)));
4980 CHECK(!v8::False()->StrictEquals(v8::Undefined())); 4985 CHECK(!v8::False(isolate)->StrictEquals(v8::Undefined(isolate)));
4981 4986
4982 v8::Handle<v8::Object> obj = v8::Object::New(); 4987 v8::Handle<v8::Object> obj = v8::Object::New();
4983 v8::Persistent<v8::Object> alias(isolate, obj); 4988 v8::Persistent<v8::Object> alias(isolate, obj);
4984 CHECK(v8::Local<v8::Object>::New(isolate, alias)->StrictEquals(obj)); 4989 CHECK(v8::Local<v8::Object>::New(isolate, alias)->StrictEquals(obj));
4985 alias.Dispose(); 4990 alias.Dispose();
4991
4992 CHECK(v8_str("a")->SameValue(v8_str("a")));
4993 CHECK(!v8_str("a")->SameValue(v8_str("b")));
4994 CHECK(!v8_str("5")->SameValue(v8_num(5)));
4995 CHECK(v8_num(1)->SameValue(v8_num(1)));
4996 CHECK(!v8_num(1)->SameValue(v8_num(2)));
4997 CHECK(!v8_num(0.0)->SameValue(v8_num(-0.0)));
4998 CHECK(not_a_number->SameValue(not_a_number));
4999 CHECK(v8::False(isolate)->SameValue(v8::False(isolate)));
5000 CHECK(!v8::False(isolate)->SameValue(v8::Undefined(isolate)));
4986 } 5001 }
4987 5002
4988 5003
4989 THREADED_TEST(MultiRun) { 5004 THREADED_TEST(MultiRun) {
4990 LocalContext context; 5005 LocalContext context;
4991 v8::HandleScope scope(context->GetIsolate()); 5006 v8::HandleScope scope(context->GetIsolate());
4992 Local<Script> script = Script::Compile(v8_str("x")); 5007 Local<Script> script = Script::Compile(v8_str("x"));
4993 for (int i = 0; i < 10; i++) 5008 for (int i = 0; i < 10; i++)
4994 script->Run(); 5009 script->Run();
4995 } 5010 }
(...skipping 1660 matching lines...) Expand 10 before | Expand all | Expand 10 after
6656 last_location = NULL; 6671 last_location = NULL;
6657 script->Run(); 6672 script->Run();
6658 6673
6659 CHECK(false); // Should not return. 6674 CHECK(false); // Should not return.
6660 } 6675 }
6661 6676
6662 6677
6663 static void MissingScriptInfoMessageListener(v8::Handle<v8::Message> message, 6678 static void MissingScriptInfoMessageListener(v8::Handle<v8::Message> message,
6664 v8::Handle<Value> data) { 6679 v8::Handle<Value> data) {
6665 CHECK(message->GetScriptResourceName()->IsUndefined()); 6680 CHECK(message->GetScriptResourceName()->IsUndefined());
6666 CHECK_EQ(v8::Undefined(), message->GetScriptResourceName()); 6681 CHECK_EQ(v8::Undefined(CcTest::isolate()), message->GetScriptResourceName());
6667 message->GetLineNumber(); 6682 message->GetLineNumber();
6668 message->GetSourceLine(); 6683 message->GetSourceLine();
6669 } 6684 }
6670 6685
6671 6686
6672 THREADED_TEST(ErrorWithMissingScriptInfo) { 6687 THREADED_TEST(ErrorWithMissingScriptInfo) {
6673 LocalContext context; 6688 LocalContext context;
6674 v8::HandleScope scope(context->GetIsolate()); 6689 v8::HandleScope scope(context->GetIsolate());
6675 v8::V8::AddMessageListener(MissingScriptInfoMessageListener); 6690 v8::V8::AddMessageListener(MissingScriptInfoMessageListener);
6676 Script::Compile(v8_str("throw Error()"))->Run(); 6691 Script::Compile(v8_str("throw Error()"))->Run();
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
6893 } 6908 }
6894 } 6909 }
6895 6910
6896 6911
6897 v8::Handle<Function> args_fun; 6912 v8::Handle<Function> args_fun;
6898 6913
6899 6914
6900 static void ArgumentsTestCallback( 6915 static void ArgumentsTestCallback(
6901 const v8::FunctionCallbackInfo<v8::Value>& args) { 6916 const v8::FunctionCallbackInfo<v8::Value>& args) {
6902 ApiTestFuzzer::Fuzz(); 6917 ApiTestFuzzer::Fuzz();
6918 v8::Isolate* isolate = args.GetIsolate();
6903 CHECK_EQ(args_fun, args.Callee()); 6919 CHECK_EQ(args_fun, args.Callee());
6904 CHECK_EQ(3, args.Length()); 6920 CHECK_EQ(3, args.Length());
6905 CHECK_EQ(v8::Integer::New(1), args[0]); 6921 CHECK_EQ(v8::Integer::New(1, isolate), args[0]);
6906 CHECK_EQ(v8::Integer::New(2), args[1]); 6922 CHECK_EQ(v8::Integer::New(2, isolate), args[1]);
6907 CHECK_EQ(v8::Integer::New(3), args[2]); 6923 CHECK_EQ(v8::Integer::New(3, isolate), args[2]);
6908 CHECK_EQ(v8::Undefined(), args[3]); 6924 CHECK_EQ(v8::Undefined(isolate), args[3]);
6909 v8::HandleScope scope(args.GetIsolate()); 6925 v8::HandleScope scope(args.GetIsolate());
6910 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); 6926 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags);
6911 } 6927 }
6912 6928
6913 6929
6914 THREADED_TEST(Arguments) { 6930 THREADED_TEST(Arguments) {
6915 v8::HandleScope scope(CcTest::isolate()); 6931 v8::HandleScope scope(CcTest::isolate());
6916 v8::Handle<v8::ObjectTemplate> global = ObjectTemplate::New(); 6932 v8::Handle<v8::ObjectTemplate> global = ObjectTemplate::New();
6917 global->Set(v8_str("f"), v8::FunctionTemplate::New(ArgumentsTestCallback)); 6933 global->Set(v8_str("f"), v8::FunctionTemplate::New(ArgumentsTestCallback));
6918 LocalContext context(NULL, global); 6934 LocalContext context(NULL, global);
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
7146 v8::HandleScope scope(CcTest::isolate()); 7162 v8::HandleScope scope(CcTest::isolate());
7147 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); 7163 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New();
7148 obj->SetNamedPropertyHandler(PGetter2); 7164 obj->SetNamedPropertyHandler(PGetter2);
7149 p_getter_count2 = 0; 7165 p_getter_count2 = 0;
7150 RunHolderTest(obj); 7166 RunHolderTest(obj);
7151 CHECK_EQ(40, p_getter_count2); 7167 CHECK_EQ(40, p_getter_count2);
7152 } 7168 }
7153 7169
7154 7170
7155 THREADED_TEST(ObjectInstantiation) { 7171 THREADED_TEST(ObjectInstantiation) {
7156 v8::HandleScope scope(CcTest::isolate()); 7172 v8::Isolate* isolate = CcTest::isolate();
7173 v8::HandleScope scope(isolate);
7157 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); 7174 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
7158 templ->SetAccessor(v8_str("t"), PGetter2); 7175 templ->SetAccessor(v8_str("t"), PGetter2);
7159 LocalContext context; 7176 LocalContext context;
7160 context->Global()->Set(v8_str("o"), templ->NewInstance()); 7177 context->Global()->Set(v8_str("o"), templ->NewInstance());
7161 for (int i = 0; i < 100; i++) { 7178 for (int i = 0; i < 100; i++) {
7162 v8::HandleScope inner_scope(CcTest::isolate()); 7179 v8::HandleScope inner_scope(CcTest::isolate());
7163 v8::Handle<v8::Object> obj = templ->NewInstance(); 7180 v8::Handle<v8::Object> obj = templ->NewInstance();
7164 CHECK_NE(obj, context->Global()->Get(v8_str("o"))); 7181 CHECK_NE(obj, context->Global()->Get(v8_str("o")));
7165 context->Global()->Set(v8_str("o2"), obj); 7182 context->Global()->Set(v8_str("o2"), obj);
7166 v8::Handle<Value> value = 7183 v8::Handle<Value> value =
7167 Script::Compile(v8_str("o.__proto__ === o2.__proto__"))->Run(); 7184 Script::Compile(v8_str("o.__proto__ === o2.__proto__"))->Run();
7168 CHECK_EQ(v8::True(), value); 7185 CHECK_EQ(v8::True(isolate), value);
7169 context->Global()->Set(v8_str("o"), obj); 7186 context->Global()->Set(v8_str("o"), obj);
7170 } 7187 }
7171 } 7188 }
7172 7189
7173 7190
7174 static int StrCmp16(uint16_t* a, uint16_t* b) { 7191 static int StrCmp16(uint16_t* a, uint16_t* b) {
7175 while (true) { 7192 while (true) {
7176 if (*a == 0 && *b == 0) return 0; 7193 if (*a == 0 && *b == 0) return 0;
7177 if (*a != *b) return 0 + *a - *b; 7194 if (*a != *b) return 0 + *a - *b;
7178 a++; 7195 a++;
(...skipping 2598 matching lines...) Expand 10 before | Expand all | Expand 10 after
9777 9794
9778 static void FakeConstructorCallback( 9795 static void FakeConstructorCallback(
9779 const v8::FunctionCallbackInfo<v8::Value>& args) { 9796 const v8::FunctionCallbackInfo<v8::Value>& args) {
9780 ApiTestFuzzer::Fuzz(); 9797 ApiTestFuzzer::Fuzz();
9781 args.GetReturnValue().Set(args[0]); 9798 args.GetReturnValue().Set(args[0]);
9782 } 9799 }
9783 9800
9784 9801
9785 THREADED_TEST(ConstructorForObject) { 9802 THREADED_TEST(ConstructorForObject) {
9786 LocalContext context; 9803 LocalContext context;
9787 v8::HandleScope handle_scope(context->GetIsolate()); 9804 v8::Isolate* isolate = context->GetIsolate();
9805 v8::HandleScope handle_scope(isolate);
9788 9806
9789 { Local<ObjectTemplate> instance_template = ObjectTemplate::New(); 9807 { Local<ObjectTemplate> instance_template = ObjectTemplate::New();
9790 instance_template->SetCallAsFunctionHandler(ConstructorCallback); 9808 instance_template->SetCallAsFunctionHandler(ConstructorCallback);
9791 Local<Object> instance = instance_template->NewInstance(); 9809 Local<Object> instance = instance_template->NewInstance();
9792 context->Global()->Set(v8_str("obj"), instance); 9810 context->Global()->Set(v8_str("obj"), instance);
9793 v8::TryCatch try_catch; 9811 v8::TryCatch try_catch;
9794 Local<Value> value; 9812 Local<Value> value;
9795 CHECK(!try_catch.HasCaught()); 9813 CHECK(!try_catch.HasCaught());
9796 9814
9797 // Call the Object's constructor with a 32-bit signed integer. 9815 // Call the Object's constructor with a 32-bit signed integer.
(...skipping 28 matching lines...) Expand all
9826 CHECK(value->IsString()); 9844 CHECK(value->IsString());
9827 String::Utf8Value string_value2(value->ToString()); 9845 String::Utf8Value string_value2(value->ToString());
9828 CHECK_EQ("tipli", *string_value2); 9846 CHECK_EQ("tipli", *string_value2);
9829 9847
9830 // Call the Object's constructor with a Boolean. 9848 // Call the Object's constructor with a Boolean.
9831 value = CompileRun("(function() { var o = new obj(true); return o.a; })()"); 9849 value = CompileRun("(function() { var o = new obj(true); return o.a; })()");
9832 CHECK(!try_catch.HasCaught()); 9850 CHECK(!try_catch.HasCaught());
9833 CHECK(value->IsBoolean()); 9851 CHECK(value->IsBoolean());
9834 CHECK_EQ(true, value->BooleanValue()); 9852 CHECK_EQ(true, value->BooleanValue());
9835 9853
9836 Handle<Value> args3[] = { v8::True() }; 9854 Handle<Value> args3[] = { v8::True(isolate) };
9837 Local<Value> value_obj3 = instance->CallAsConstructor(1, args3); 9855 Local<Value> value_obj3 = instance->CallAsConstructor(1, args3);
9838 CHECK(value_obj3->IsObject()); 9856 CHECK(value_obj3->IsObject());
9839 Local<Object> object3 = Local<Object>::Cast(value_obj3); 9857 Local<Object> object3 = Local<Object>::Cast(value_obj3);
9840 value = object3->Get(v8_str("a")); 9858 value = object3->Get(v8_str("a"));
9841 CHECK(!try_catch.HasCaught()); 9859 CHECK(!try_catch.HasCaught());
9842 CHECK(value->IsBoolean()); 9860 CHECK(value->IsBoolean());
9843 CHECK_EQ(true, value->BooleanValue()); 9861 CHECK_EQ(true, value->BooleanValue());
9844 9862
9845 // Call the Object's constructor with undefined. 9863 // Call the Object's constructor with undefined.
9846 Handle<Value> args4[] = { v8::Undefined() }; 9864 Handle<Value> args4[] = { v8::Undefined(isolate) };
9847 Local<Value> value_obj4 = instance->CallAsConstructor(1, args4); 9865 Local<Value> value_obj4 = instance->CallAsConstructor(1, args4);
9848 CHECK(value_obj4->IsObject()); 9866 CHECK(value_obj4->IsObject());
9849 Local<Object> object4 = Local<Object>::Cast(value_obj4); 9867 Local<Object> object4 = Local<Object>::Cast(value_obj4);
9850 value = object4->Get(v8_str("a")); 9868 value = object4->Get(v8_str("a"));
9851 CHECK(!try_catch.HasCaught()); 9869 CHECK(!try_catch.HasCaught());
9852 CHECK(value->IsUndefined()); 9870 CHECK(value->IsUndefined());
9853 9871
9854 // Call the Object's constructor with null. 9872 // Call the Object's constructor with null.
9855 Handle<Value> args5[] = { v8::Null() }; 9873 Handle<Value> args5[] = { v8::Null(isolate) };
9856 Local<Value> value_obj5 = instance->CallAsConstructor(1, args5); 9874 Local<Value> value_obj5 = instance->CallAsConstructor(1, args5);
9857 CHECK(value_obj5->IsObject()); 9875 CHECK(value_obj5->IsObject());
9858 Local<Object> object5 = Local<Object>::Cast(value_obj5); 9876 Local<Object> object5 = Local<Object>::Cast(value_obj5);
9859 value = object5->Get(v8_str("a")); 9877 value = object5->Get(v8_str("a"));
9860 CHECK(!try_catch.HasCaught()); 9878 CHECK(!try_catch.HasCaught());
9861 CHECK(value->IsNull()); 9879 CHECK(value->IsNull());
9862 } 9880 }
9863 9881
9864 // Check exception handling when there is no constructor set for the Object. 9882 // Check exception handling when there is no constructor set for the Object.
9865 { Local<ObjectTemplate> instance_template = ObjectTemplate::New(); 9883 { Local<ObjectTemplate> instance_template = ObjectTemplate::New();
(...skipping 1376 matching lines...) Expand 10 before | Expand all | Expand 10 after
11242 " for (var i = 1; i <= 30; i++) {" 11260 " for (var i = 1; i <= 30; i++) {"
11243 " nativeobject.callback();" 11261 " nativeobject.callback();"
11244 " }" 11262 " }"
11245 "}" 11263 "}"
11246 "f();"); 11264 "f();");
11247 } 11265 }
11248 11266
11249 11267
11250 void ThrowingDirectApiCallback( 11268 void ThrowingDirectApiCallback(
11251 const v8::FunctionCallbackInfo<v8::Value>& args) { 11269 const v8::FunctionCallbackInfo<v8::Value>& args) {
11252 v8::ThrowException(v8_str("g")); 11270 args.GetIsolate()->ThrowException(v8_str("g"));
11253 } 11271 }
11254 11272
11255 11273
11256 THREADED_TEST(CallICFastApi_DirectCall_Throw) { 11274 THREADED_TEST(CallICFastApi_DirectCall_Throw) {
11257 LocalContext context; 11275 LocalContext context;
11258 v8::HandleScope scope(context->GetIsolate()); 11276 v8::HandleScope scope(context->GetIsolate());
11259 v8::Handle<v8::ObjectTemplate> nativeobject_templ = v8::ObjectTemplate::New(); 11277 v8::Handle<v8::ObjectTemplate> nativeobject_templ = v8::ObjectTemplate::New();
11260 nativeobject_templ->Set("callback", 11278 nativeobject_templ->Set("callback",
11261 v8::FunctionTemplate::New(ThrowingDirectApiCallback)); 11279 v8::FunctionTemplate::New(ThrowingDirectApiCallback));
11262 v8::Local<v8::Object> nativeobject_obj = nativeobject_templ->NewInstance(); 11280 v8::Local<v8::Object> nativeobject_obj = nativeobject_templ->NewInstance();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
11310 11328
11311 11329
11312 THREADED_PROFILED_TEST(LoadICFastApi_DirectCall_GCMoveStub) { 11330 THREADED_PROFILED_TEST(LoadICFastApi_DirectCall_GCMoveStub) {
11313 LoadICFastApi_DirectCall_GCMoveStub(DirectGetterCallback); 11331 LoadICFastApi_DirectCall_GCMoveStub(DirectGetterCallback);
11314 } 11332 }
11315 11333
11316 11334
11317 void ThrowingDirectGetterCallback( 11335 void ThrowingDirectGetterCallback(
11318 Local<String> name, 11336 Local<String> name,
11319 const v8::PropertyCallbackInfo<v8::Value>& info) { 11337 const v8::PropertyCallbackInfo<v8::Value>& info) {
11320 v8::ThrowException(v8_str("g")); 11338 info.GetIsolate()->ThrowException(v8_str("g"));
11321 } 11339 }
11322 11340
11323 11341
11324 THREADED_TEST(LoadICFastApi_DirectCall_Throw) { 11342 THREADED_TEST(LoadICFastApi_DirectCall_Throw) {
11325 LocalContext context; 11343 LocalContext context;
11326 v8::HandleScope scope(context->GetIsolate()); 11344 v8::HandleScope scope(context->GetIsolate());
11327 v8::Handle<v8::ObjectTemplate> obj = v8::ObjectTemplate::New(); 11345 v8::Handle<v8::ObjectTemplate> obj = v8::ObjectTemplate::New();
11328 obj->SetAccessor(v8_str("p1"), ThrowingDirectGetterCallback); 11346 obj->SetAccessor(v8_str("p1"), ThrowingDirectGetterCallback);
11329 context->Global()->Set(v8_str("o1"), obj->NewInstance()); 11347 context->Global()->Set(v8_str("o1"), obj->NewInstance());
11330 v8::Handle<Value> result = CompileRun( 11348 v8::Handle<Value> result = CompileRun(
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after
11921 static int interceptor_ic_exception_get_count = 0; 11939 static int interceptor_ic_exception_get_count = 0;
11922 11940
11923 static void InterceptorICExceptionGetter( 11941 static void InterceptorICExceptionGetter(
11924 Local<String> name, 11942 Local<String> name,
11925 const v8::PropertyCallbackInfo<v8::Value>& info) { 11943 const v8::PropertyCallbackInfo<v8::Value>& info) {
11926 ApiTestFuzzer::Fuzz(); 11944 ApiTestFuzzer::Fuzz();
11927 if (v8_str("x")->Equals(name) && ++interceptor_ic_exception_get_count < 20) { 11945 if (v8_str("x")->Equals(name) && ++interceptor_ic_exception_get_count < 20) {
11928 info.GetReturnValue().Set(call_ic_function3); 11946 info.GetReturnValue().Set(call_ic_function3);
11929 } 11947 }
11930 if (interceptor_ic_exception_get_count == 20) { 11948 if (interceptor_ic_exception_get_count == 20) {
11931 v8::ThrowException(v8_num(42)); 11949 info.GetIsolate()->ThrowException(v8_num(42));
11932 return; 11950 return;
11933 } 11951 }
11934 } 11952 }
11935 11953
11936 11954
11937 // Test interceptor load/call IC where the interceptor throws an 11955 // Test interceptor load/call IC where the interceptor throws an
11938 // exception once in a while. 11956 // exception once in a while.
11939 THREADED_TEST(InterceptorICGetterExceptions) { 11957 THREADED_TEST(InterceptorICGetterExceptions) {
11940 interceptor_ic_exception_get_count = 0; 11958 interceptor_ic_exception_get_count = 0;
11941 v8::HandleScope scope(CcTest::isolate()); 11959 v8::HandleScope scope(CcTest::isolate());
(...skipping 24 matching lines...) Expand all
11966 11984
11967 11985
11968 static int interceptor_ic_exception_set_count = 0; 11986 static int interceptor_ic_exception_set_count = 0;
11969 11987
11970 static void InterceptorICExceptionSetter( 11988 static void InterceptorICExceptionSetter(
11971 Local<String> key, 11989 Local<String> key,
11972 Local<Value> value, 11990 Local<Value> value,
11973 const v8::PropertyCallbackInfo<v8::Value>& info) { 11991 const v8::PropertyCallbackInfo<v8::Value>& info) {
11974 ApiTestFuzzer::Fuzz(); 11992 ApiTestFuzzer::Fuzz();
11975 if (++interceptor_ic_exception_set_count > 20) { 11993 if (++interceptor_ic_exception_set_count > 20) {
11976 v8::ThrowException(v8_num(42)); 11994 info.GetIsolate()->ThrowException(v8_num(42));
11977 } 11995 }
11978 } 11996 }
11979 11997
11980 11998
11981 // Test interceptor store IC where the interceptor throws an exception 11999 // Test interceptor store IC where the interceptor throws an exception
11982 // once in a while. 12000 // once in a while.
11983 THREADED_TEST(InterceptorICSetterExceptions) { 12001 THREADED_TEST(InterceptorICSetterExceptions) {
11984 interceptor_ic_exception_set_count = 0; 12002 interceptor_ic_exception_set_count = 0;
11985 v8::HandleScope scope(CcTest::isolate()); 12003 v8::HandleScope scope(CcTest::isolate());
11986 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); 12004 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
12038 env->Global()->Set(v8_str("obj"), 12056 env->Global()->Set(v8_str("obj"),
12039 templ->GetFunction()->NewInstance()); 12057 templ->GetFunction()->NewInstance());
12040 ExpectTrue("obj.x === 42"); 12058 ExpectTrue("obj.x === 42");
12041 ExpectTrue("!obj.propertyIsEnumerable('x')"); 12059 ExpectTrue("!obj.propertyIsEnumerable('x')");
12042 } 12060 }
12043 12061
12044 12062
12045 static void ThrowingGetter(Local<String> name, 12063 static void ThrowingGetter(Local<String> name,
12046 const v8::PropertyCallbackInfo<v8::Value>& info) { 12064 const v8::PropertyCallbackInfo<v8::Value>& info) {
12047 ApiTestFuzzer::Fuzz(); 12065 ApiTestFuzzer::Fuzz();
12048 ThrowException(Handle<Value>()); 12066 info.GetIsolate()->ThrowException(Handle<Value>());
12049 info.GetReturnValue().SetUndefined(); 12067 info.GetReturnValue().SetUndefined();
12050 } 12068 }
12051 12069
12052 12070
12053 THREADED_TEST(VariousGetPropertiesAndThrowingCallbacks) { 12071 THREADED_TEST(VariousGetPropertiesAndThrowingCallbacks) {
12054 LocalContext context; 12072 LocalContext context;
12055 HandleScope scope(context->GetIsolate()); 12073 HandleScope scope(context->GetIsolate());
12056 12074
12057 Local<FunctionTemplate> templ = FunctionTemplate::New(); 12075 Local<FunctionTemplate> templ = FunctionTemplate::New();
12058 Local<ObjectTemplate> instance_templ = templ->InstanceTemplate(); 12076 Local<ObjectTemplate> instance_templ = templ->InstanceTemplate();
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
12123 TryCatch try_catch; 12141 TryCatch try_catch;
12124 } 12142 }
12125 12143
12126 12144
12127 static void ThrowFromJS(Handle<Message> message, Handle<Value> data) { 12145 static void ThrowFromJS(Handle<Message> message, Handle<Value> data) {
12128 if (--call_depth) CompileRun("throw 'ThrowInJS';"); 12146 if (--call_depth) CompileRun("throw 'ThrowInJS';");
12129 } 12147 }
12130 12148
12131 12149
12132 static void ThrowViaApi(Handle<Message> message, Handle<Value> data) { 12150 static void ThrowViaApi(Handle<Message> message, Handle<Value> data) {
12133 if (--call_depth) ThrowException(v8_str("ThrowViaApi")); 12151 if (--call_depth) CcTest::isolate()->ThrowException(v8_str("ThrowViaApi"));
12134 } 12152 }
12135 12153
12136 12154
12137 static void WebKitLike(Handle<Message> message, Handle<Value> data) { 12155 static void WebKitLike(Handle<Message> message, Handle<Value> data) {
12138 Handle<String> errorMessageString = message->Get(); 12156 Handle<String> errorMessageString = message->Get();
12139 CHECK(!errorMessageString.IsEmpty()); 12157 CHECK(!errorMessageString.IsEmpty());
12140 message->GetStackTrace(); 12158 message->GetStackTrace();
12141 message->GetScriptResourceName(); 12159 message->GetScriptResourceName();
12142 } 12160 }
12143 12161
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
12482 v8::Isolate::Scope scope(CcTest::isolate()); 12500 v8::Isolate::Scope scope(CcTest::isolate());
12483 if (kLogThreading) 12501 if (kLogThreading)
12484 printf("Start test %d\n", test_number_); 12502 printf("Start test %d\n", test_number_);
12485 CallTestNumber(test_number_); 12503 CallTestNumber(test_number_);
12486 if (kLogThreading) 12504 if (kLogThreading)
12487 printf("End test %d\n", test_number_); 12505 printf("End test %d\n", test_number_);
12488 } 12506 }
12489 12507
12490 12508
12491 static void ThrowInJS(const v8::FunctionCallbackInfo<v8::Value>& args) { 12509 static void ThrowInJS(const v8::FunctionCallbackInfo<v8::Value>& args) {
12492 CHECK(v8::Locker::IsLocked(CcTest::isolate())); 12510 v8::Isolate* isolate = args.GetIsolate();
12511 CHECK(v8::Locker::IsLocked(isolate));
12493 ApiTestFuzzer::Fuzz(); 12512 ApiTestFuzzer::Fuzz();
12494 v8::Unlocker unlocker(CcTest::isolate()); 12513 v8::Unlocker unlocker(isolate);
12495 const char* code = "throw 7;"; 12514 const char* code = "throw 7;";
12496 { 12515 {
12497 v8::Locker nested_locker(CcTest::isolate()); 12516 v8::Locker nested_locker(isolate);
12498 v8::HandleScope scope(args.GetIsolate()); 12517 v8::HandleScope scope(isolate);
12499 v8::Handle<Value> exception; 12518 v8::Handle<Value> exception;
12500 { v8::TryCatch try_catch; 12519 { v8::TryCatch try_catch;
12501 v8::Handle<Value> value = CompileRun(code); 12520 v8::Handle<Value> value = CompileRun(code);
12502 CHECK(value.IsEmpty()); 12521 CHECK(value.IsEmpty());
12503 CHECK(try_catch.HasCaught()); 12522 CHECK(try_catch.HasCaught());
12504 // Make sure to wrap the exception in a new handle because 12523 // Make sure to wrap the exception in a new handle because
12505 // the handle returned from the TryCatch is destroyed 12524 // the handle returned from the TryCatch is destroyed
12506 // when the TryCatch is destroyed. 12525 // when the TryCatch is destroyed.
12507 exception = Local<Value>::New(try_catch.Exception()); 12526 exception = Local<Value>::New(isolate, try_catch.Exception());
12508 } 12527 }
12509 v8::ThrowException(exception); 12528 args.GetIsolate()->ThrowException(exception);
12510 } 12529 }
12511 } 12530 }
12512 12531
12513 12532
12514 static void ThrowInJSNoCatch(const v8::FunctionCallbackInfo<v8::Value>& args) { 12533 static void ThrowInJSNoCatch(const v8::FunctionCallbackInfo<v8::Value>& args) {
12515 CHECK(v8::Locker::IsLocked(CcTest::isolate())); 12534 CHECK(v8::Locker::IsLocked(CcTest::isolate()));
12516 ApiTestFuzzer::Fuzz(); 12535 ApiTestFuzzer::Fuzz();
12517 v8::Unlocker unlocker(CcTest::isolate()); 12536 v8::Unlocker unlocker(CcTest::isolate());
12518 const char* code = "throw 7;"; 12537 const char* code = "throw 7;";
12519 { 12538 {
(...skipping 1195 matching lines...) Expand 10 before | Expand all | Expand 10 after
13715 static bool IndexedSetAccessBlocker(Local<v8::Object> obj, 13734 static bool IndexedSetAccessBlocker(Local<v8::Object> obj,
13716 uint32_t key, 13735 uint32_t key,
13717 v8::AccessType type, 13736 v8::AccessType type,
13718 Local<Value> data) { 13737 Local<Value> data) {
13719 return type != v8::ACCESS_SET; 13738 return type != v8::ACCESS_SET;
13720 } 13739 }
13721 13740
13722 13741
13723 THREADED_TEST(DisableAccessChecksWhileConfiguring) { 13742 THREADED_TEST(DisableAccessChecksWhileConfiguring) {
13724 LocalContext context; 13743 LocalContext context;
13725 v8::HandleScope scope(context->GetIsolate()); 13744 v8::Isolate* isolate = context->GetIsolate();
13745 v8::HandleScope scope(isolate);
13726 Local<ObjectTemplate> templ = ObjectTemplate::New(); 13746 Local<ObjectTemplate> templ = ObjectTemplate::New();
13727 templ->SetAccessCheckCallbacks(NamedSetAccessBlocker, 13747 templ->SetAccessCheckCallbacks(NamedSetAccessBlocker,
13728 IndexedSetAccessBlocker); 13748 IndexedSetAccessBlocker);
13729 templ->Set(v8_str("x"), v8::True()); 13749 templ->Set(v8_str("x"), v8::True(isolate));
13730 Local<v8::Object> instance = templ->NewInstance(); 13750 Local<v8::Object> instance = templ->NewInstance();
13731 context->Global()->Set(v8_str("obj"), instance); 13751 context->Global()->Set(v8_str("obj"), instance);
13732 Local<Value> value = CompileRun("obj.x"); 13752 Local<Value> value = CompileRun("obj.x");
13733 CHECK(value->BooleanValue()); 13753 CHECK(value->BooleanValue());
13734 } 13754 }
13735 13755
13736 13756
13737 static bool NamedGetAccessBlocker(Local<v8::Object> obj, 13757 static bool NamedGetAccessBlocker(Local<v8::Object> obj,
13738 Local<Value> name, 13758 Local<Value> name,
13739 v8::AccessType type, 13759 v8::AccessType type,
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
14136 // This tests that we do not allow dictionary load/call inline caches 14156 // This tests that we do not allow dictionary load/call inline caches
14137 // to use functions that have not yet been compiled. The potential 14157 // to use functions that have not yet been compiled. The potential
14138 // problem of loading a function that has not yet been compiled can 14158 // problem of loading a function that has not yet been compiled can
14139 // arise because we share code between contexts via the compilation 14159 // arise because we share code between contexts via the compilation
14140 // cache. 14160 // cache.
14141 THREADED_TEST(DictionaryICLoadedFunction) { 14161 THREADED_TEST(DictionaryICLoadedFunction) {
14142 v8::HandleScope scope(CcTest::isolate()); 14162 v8::HandleScope scope(CcTest::isolate());
14143 // Test LoadIC. 14163 // Test LoadIC.
14144 for (int i = 0; i < 2; i++) { 14164 for (int i = 0; i < 2; i++) {
14145 LocalContext context; 14165 LocalContext context;
14146 context->Global()->Set(v8_str("tmp"), v8::True()); 14166 context->Global()->Set(v8_str("tmp"), v8::True(CcTest::isolate()));
14147 context->Global()->Delete(v8_str("tmp")); 14167 context->Global()->Delete(v8_str("tmp"));
14148 CompileRun("for (var j = 0; j < 10; j++) new RegExp('');"); 14168 CompileRun("for (var j = 0; j < 10; j++) new RegExp('');");
14149 } 14169 }
14150 // Test CallIC. 14170 // Test CallIC.
14151 for (int i = 0; i < 2; i++) { 14171 for (int i = 0; i < 2; i++) {
14152 LocalContext context; 14172 LocalContext context;
14153 context->Global()->Set(v8_str("tmp"), v8::True()); 14173 context->Global()->Set(v8_str("tmp"), v8::True(CcTest::isolate()));
14154 context->Global()->Delete(v8_str("tmp")); 14174 context->Global()->Delete(v8_str("tmp"));
14155 CompileRun("for (var j = 0; j < 10; j++) RegExp('')"); 14175 CompileRun("for (var j = 0; j < 10; j++) RegExp('')");
14156 } 14176 }
14157 } 14177 }
14158 14178
14159 14179
14160 // Test that cross-context new calls use the context of the callee to 14180 // Test that cross-context new calls use the context of the callee to
14161 // create the new JavaScript object. 14181 // create the new JavaScript object.
14162 THREADED_TEST(CrossContextNew) { 14182 THREADED_TEST(CrossContextNew) {
14163 v8::Isolate* isolate = CcTest::isolate(); 14183 v8::Isolate* isolate = CcTest::isolate();
(...skipping 27 matching lines...) Expand all
14191 public: 14211 public:
14192 RegExpInterruptTest() : block_(0) {} 14212 RegExpInterruptTest() : block_(0) {}
14193 ~RegExpInterruptTest() {} 14213 ~RegExpInterruptTest() {}
14194 void RunTest() { 14214 void RunTest() {
14195 gc_count_ = 0; 14215 gc_count_ = 0;
14196 gc_during_regexp_ = 0; 14216 gc_during_regexp_ = 0;
14197 regexp_success_ = false; 14217 regexp_success_ = false;
14198 gc_success_ = false; 14218 gc_success_ = false;
14199 GCThread gc_thread(this); 14219 GCThread gc_thread(this);
14200 gc_thread.Start(); 14220 gc_thread.Start();
14201 v8::Locker::StartPreemption(1); 14221 v8::Isolate* isolate = CcTest::isolate();
14222 v8::Locker::StartPreemption(isolate, 1);
14202 14223
14203 LongRunningRegExp(); 14224 LongRunningRegExp();
14204 { 14225 {
14205 v8::Unlocker unlock(CcTest::isolate()); 14226 v8::Unlocker unlock(isolate);
14206 gc_thread.Join(); 14227 gc_thread.Join();
14207 } 14228 }
14208 v8::Locker::StopPreemption(); 14229 v8::Locker::StopPreemption(isolate);
14209 CHECK(regexp_success_); 14230 CHECK(regexp_success_);
14210 CHECK(gc_success_); 14231 CHECK(gc_success_);
14211 } 14232 }
14212 14233
14213 private: 14234 private:
14214 // Number of garbage collections required. 14235 // Number of garbage collections required.
14215 static const int kRequiredGCs = 5; 14236 static const int kRequiredGCs = 5;
14216 14237
14217 class GCThread : public i::Thread { 14238 class GCThread : public i::Thread {
14218 public: 14239 public:
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
14313 public: 14334 public:
14314 ApplyInterruptTest() : block_(0) {} 14335 ApplyInterruptTest() : block_(0) {}
14315 ~ApplyInterruptTest() {} 14336 ~ApplyInterruptTest() {}
14316 void RunTest() { 14337 void RunTest() {
14317 gc_count_ = 0; 14338 gc_count_ = 0;
14318 gc_during_apply_ = 0; 14339 gc_during_apply_ = 0;
14319 apply_success_ = false; 14340 apply_success_ = false;
14320 gc_success_ = false; 14341 gc_success_ = false;
14321 GCThread gc_thread(this); 14342 GCThread gc_thread(this);
14322 gc_thread.Start(); 14343 gc_thread.Start();
14323 v8::Locker::StartPreemption(1); 14344 v8::Isolate* isolate = CcTest::isolate();
14345 v8::Locker::StartPreemption(isolate, 1);
14324 14346
14325 LongRunningApply(); 14347 LongRunningApply();
14326 { 14348 {
14327 v8::Unlocker unlock(CcTest::isolate()); 14349 v8::Unlocker unlock(isolate);
14328 gc_thread.Join(); 14350 gc_thread.Join();
14329 } 14351 }
14330 v8::Locker::StopPreemption(); 14352 v8::Locker::StopPreemption(isolate);
14331 CHECK(apply_success_); 14353 CHECK(apply_success_);
14332 CHECK(gc_success_); 14354 CHECK(gc_success_);
14333 } 14355 }
14334 14356
14335 private: 14357 private:
14336 // Number of garbage collections required. 14358 // Number of garbage collections required.
14337 static const int kRequiredGCs = 2; 14359 static const int kRequiredGCs = 2;
14338 14360
14339 class GCThread : public i::Thread { 14361 class GCThread : public i::Thread {
14340 public: 14362 public:
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
14600 class RegExpStringModificationTest { 14622 class RegExpStringModificationTest {
14601 public: 14623 public:
14602 RegExpStringModificationTest() 14624 RegExpStringModificationTest()
14603 : block_(0), 14625 : block_(0),
14604 morphs_(0), 14626 morphs_(0),
14605 morphs_during_regexp_(0), 14627 morphs_during_regexp_(0),
14606 ascii_resource_(i::Vector<const char>("aaaaaaaaaaaaaab", 15)), 14628 ascii_resource_(i::Vector<const char>("aaaaaaaaaaaaaab", 15)),
14607 uc16_resource_(i::Vector<const uint16_t>(two_byte_content_, 15)) {} 14629 uc16_resource_(i::Vector<const uint16_t>(two_byte_content_, 15)) {}
14608 ~RegExpStringModificationTest() {} 14630 ~RegExpStringModificationTest() {}
14609 void RunTest() { 14631 void RunTest() {
14632 v8::Isolate* isolate = CcTest::isolate();
14610 i::Factory* factory = CcTest::i_isolate()->factory(); 14633 i::Factory* factory = CcTest::i_isolate()->factory();
14611 14634
14612 regexp_success_ = false; 14635 regexp_success_ = false;
14613 morph_success_ = false; 14636 morph_success_ = false;
14614 14637
14615 // Initialize the contents of two_byte_content_ to be a uc16 representation 14638 // Initialize the contents of two_byte_content_ to be a uc16 representation
14616 // of "aaaaaaaaaaaaaab". 14639 // of "aaaaaaaaaaaaaab".
14617 for (int i = 0; i < 14; i++) { 14640 for (int i = 0; i < 14; i++) {
14618 two_byte_content_[i] = 'a'; 14641 two_byte_content_[i] = 'a';
14619 } 14642 }
14620 two_byte_content_[14] = 'b'; 14643 two_byte_content_[14] = 'b';
14621 14644
14622 // Create the input string for the regexp - the one we are going to change 14645 // Create the input string for the regexp - the one we are going to change
14623 // properties of. 14646 // properties of.
14624 input_ = factory->NewExternalStringFromAscii(&ascii_resource_); 14647 input_ = factory->NewExternalStringFromAscii(&ascii_resource_);
14625 14648
14626 // Inject the input as a global variable. 14649 // Inject the input as a global variable.
14627 i::Handle<i::String> input_name = 14650 i::Handle<i::String> input_name =
14628 factory->NewStringFromAscii(i::Vector<const char>("input", 5)); 14651 factory->NewStringFromAscii(i::Vector<const char>("input", 5));
14629 i::JSReceiver::SetProperty( 14652 i::JSReceiver::SetProperty(
14630 i::handle(CcTest::i_isolate()->native_context()->global_object()), 14653 i::handle(CcTest::i_isolate()->native_context()->global_object()),
14631 input_name, 14654 input_name,
14632 input_, 14655 input_,
14633 NONE, 14656 NONE,
14634 i::kNonStrictMode); 14657 i::kNonStrictMode);
14635 14658
14636 MorphThread morph_thread(this); 14659 MorphThread morph_thread(this);
14637 morph_thread.Start(); 14660 morph_thread.Start();
14638 v8::Locker::StartPreemption(1); 14661 v8::Locker::StartPreemption(isolate, 1);
14639 LongRunningRegExp(); 14662 LongRunningRegExp();
14640 { 14663 {
14641 v8::Unlocker unlock(CcTest::isolate()); 14664 v8::Unlocker unlock(isolate);
14642 morph_thread.Join(); 14665 morph_thread.Join();
14643 } 14666 }
14644 v8::Locker::StopPreemption(); 14667 v8::Locker::StopPreemption(isolate);
14645 CHECK(regexp_success_); 14668 CHECK(regexp_success_);
14646 CHECK(morph_success_); 14669 CHECK(morph_success_);
14647 } 14670 }
14648 14671
14649 private: 14672 private:
14650 // Number of string modifications required. 14673 // Number of string modifications required.
14651 static const int kRequiredModifications = 5; 14674 static const int kRequiredModifications = 5;
14652 static const int kMaxModifications = 100; 14675 static const int kMaxModifications = 100;
14653 14676
14654 class MorphThread : public i::Thread { 14677 class MorphThread : public i::Thread {
(...skipping 4722 matching lines...) Expand 10 before | Expand all | Expand 10 after
19377 global_template->Set(v8_str("proxy"), proxy_object); 19400 global_template->Set(v8_str("proxy"), proxy_object);
19378 global_template->Set(v8_str("hidden"), object_with_hidden); 19401 global_template->Set(v8_str("hidden"), object_with_hidden);
19379 global_template->Set(v8_str("phidden"), object_with_protected_hidden); 19402 global_template->Set(v8_str("phidden"), object_with_protected_hidden);
19380 19403
19381 LocalContext context2(NULL, global_template); 19404 LocalContext context2(NULL, global_template);
19382 19405
19383 Local<Value> result1 = CompileRun("Object.getPrototypeOf(simple)"); 19406 Local<Value> result1 = CompileRun("Object.getPrototypeOf(simple)");
19384 CHECK(result1->Equals(simple_object->GetPrototype())); 19407 CHECK(result1->Equals(simple_object->GetPrototype()));
19385 19408
19386 Local<Value> result2 = CompileRun("Object.getPrototypeOf(protected)"); 19409 Local<Value> result2 = CompileRun("Object.getPrototypeOf(protected)");
19387 CHECK(result2->Equals(Undefined())); 19410 CHECK(result2->Equals(Undefined(isolate)));
19388 19411
19389 Local<Value> result3 = CompileRun("Object.getPrototypeOf(global)"); 19412 Local<Value> result3 = CompileRun("Object.getPrototypeOf(global)");
19390 CHECK(result3->Equals(global_object->GetPrototype())); 19413 CHECK(result3->Equals(global_object->GetPrototype()));
19391 19414
19392 Local<Value> result4 = CompileRun("Object.getPrototypeOf(proxy)"); 19415 Local<Value> result4 = CompileRun("Object.getPrototypeOf(proxy)");
19393 CHECK(result4->Equals(Undefined())); 19416 CHECK(result4->Equals(Undefined(isolate)));
19394 19417
19395 Local<Value> result5 = CompileRun("Object.getPrototypeOf(hidden)"); 19418 Local<Value> result5 = CompileRun("Object.getPrototypeOf(hidden)");
19396 CHECK(result5->Equals( 19419 CHECK(result5->Equals(
19397 object_with_hidden->GetPrototype()->ToObject()->GetPrototype())); 19420 object_with_hidden->GetPrototype()->ToObject()->GetPrototype()));
19398 19421
19399 Local<Value> result6 = CompileRun("Object.getPrototypeOf(phidden)"); 19422 Local<Value> result6 = CompileRun("Object.getPrototypeOf(phidden)");
19400 CHECK(result6->Equals(Undefined())); 19423 CHECK(result6->Equals(Undefined(isolate)));
19401 } 19424 }
19402 19425
19403 19426
19404 THREADED_TEST(Regress125988) { 19427 THREADED_TEST(Regress125988) {
19405 v8::HandleScope scope(CcTest::isolate()); 19428 v8::HandleScope scope(CcTest::isolate());
19406 Handle<FunctionTemplate> intercept = FunctionTemplate::New(); 19429 Handle<FunctionTemplate> intercept = FunctionTemplate::New();
19407 AddInterceptor(intercept, EmptyInterceptorGetter, EmptyInterceptorSetter); 19430 AddInterceptor(intercept, EmptyInterceptorGetter, EmptyInterceptorSetter);
19408 LocalContext env; 19431 LocalContext env;
19409 env->Global()->Set(v8_str("Intercept"), intercept->GetFunction()); 19432 env->Global()->Set(v8_str("Intercept"), intercept->GetFunction());
19410 CompileRun("var a = new Object();" 19433 CompileRun("var a = new Object();"
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
19689 StubCacheHelper(false); 19712 StubCacheHelper(false);
19690 } 19713 }
19691 19714
19692 19715
19693 TEST(StaticGetters) { 19716 TEST(StaticGetters) {
19694 LocalContext context; 19717 LocalContext context;
19695 i::Factory* factory = CcTest::i_isolate()->factory(); 19718 i::Factory* factory = CcTest::i_isolate()->factory();
19696 v8::Isolate* isolate = CcTest::isolate(); 19719 v8::Isolate* isolate = CcTest::isolate();
19697 v8::HandleScope scope(isolate); 19720 v8::HandleScope scope(isolate);
19698 i::Handle<i::Object> undefined_value = factory->undefined_value(); 19721 i::Handle<i::Object> undefined_value = factory->undefined_value();
19699 CHECK(*v8::Utils::OpenHandle(*v8::Undefined()) == *undefined_value);
19700 CHECK(*v8::Utils::OpenHandle(*v8::Undefined(isolate)) == *undefined_value); 19722 CHECK(*v8::Utils::OpenHandle(*v8::Undefined(isolate)) == *undefined_value);
19701 i::Handle<i::Object> null_value = factory->null_value(); 19723 i::Handle<i::Object> null_value = factory->null_value();
19702 CHECK(*v8::Utils::OpenHandle(*v8::Null()) == *null_value);
19703 CHECK(*v8::Utils::OpenHandle(*v8::Null(isolate)) == *null_value); 19724 CHECK(*v8::Utils::OpenHandle(*v8::Null(isolate)) == *null_value);
19704 i::Handle<i::Object> true_value = factory->true_value(); 19725 i::Handle<i::Object> true_value = factory->true_value();
19705 CHECK(*v8::Utils::OpenHandle(*v8::True()) == *true_value);
19706 CHECK(*v8::Utils::OpenHandle(*v8::True(isolate)) == *true_value); 19726 CHECK(*v8::Utils::OpenHandle(*v8::True(isolate)) == *true_value);
19707 i::Handle<i::Object> false_value = factory->false_value(); 19727 i::Handle<i::Object> false_value = factory->false_value();
19708 CHECK(*v8::Utils::OpenHandle(*v8::False()) == *false_value);
19709 CHECK(*v8::Utils::OpenHandle(*v8::False(isolate)) == *false_value); 19728 CHECK(*v8::Utils::OpenHandle(*v8::False(isolate)) == *false_value);
19710 } 19729 }
19711 19730
19712 19731
19713 UNINITIALIZED_TEST(IsolateEmbedderData) { 19732 UNINITIALIZED_TEST(IsolateEmbedderData) {
19714 CcTest::DisableAutomaticDispose(); 19733 CcTest::DisableAutomaticDispose();
19715 v8::Isolate* isolate = v8::Isolate::New(); 19734 v8::Isolate* isolate = v8::Isolate::New();
19716 isolate->Enter(); 19735 isolate->Enter();
19717 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 19736 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
19718 CHECK_EQ(NULL, isolate->GetData()); 19737 CHECK_EQ(NULL, isolate->GetData());
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
20141 Local<Object> set_object(Local<Object>::Cast(set_value)); 20160 Local<Object> set_object(Local<Object>::Cast(set_value));
20142 CHECK_EQ(0, set_object->InternalFieldCount()); 20161 CHECK_EQ(0, set_object->InternalFieldCount());
20143 Local<Value> map_value = CompileRun("new Map();"); 20162 Local<Value> map_value = CompileRun("new Map();");
20144 Local<Object> map_object(Local<Object>::Cast(map_value)); 20163 Local<Object> map_object(Local<Object>::Cast(map_value));
20145 CHECK_EQ(0, map_object->InternalFieldCount()); 20164 CHECK_EQ(0, map_object->InternalFieldCount());
20146 } 20165 }
20147 20166
20148 20167
20149 THREADED_TEST(Regress2746) { 20168 THREADED_TEST(Regress2746) {
20150 LocalContext context; 20169 LocalContext context;
20151 v8::HandleScope scope(context->GetIsolate()); 20170 v8::Isolate* isolate = context->GetIsolate();
20171 v8::HandleScope scope(isolate);
20152 Local<Object> obj = Object::New(); 20172 Local<Object> obj = Object::New();
20153 Local<String> key = String::New("key"); 20173 Local<String> key = String::New("key");
20154 obj->SetHiddenValue(key, v8::Undefined()); 20174 obj->SetHiddenValue(key, v8::Undefined(isolate));
20155 Local<Value> value = obj->GetHiddenValue(key); 20175 Local<Value> value = obj->GetHiddenValue(key);
20156 CHECK(!value.IsEmpty()); 20176 CHECK(!value.IsEmpty());
20157 CHECK(value->IsUndefined()); 20177 CHECK(value->IsUndefined());
20158 } 20178 }
20159 20179
20160 20180
20161 THREADED_TEST(Regress260106) { 20181 THREADED_TEST(Regress260106) {
20162 LocalContext context; 20182 LocalContext context;
20163 v8::HandleScope scope(context->GetIsolate()); 20183 v8::HandleScope scope(context->GetIsolate());
20164 Local<FunctionTemplate> templ = FunctionTemplate::New(DummyCallHandler); 20184 Local<FunctionTemplate> templ = FunctionTemplate::New(DummyCallHandler);
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
20324 bool access_check_fail_thrown = false; 20344 bool access_check_fail_thrown = false;
20325 bool catch_callback_called = false; 20345 bool catch_callback_called = false;
20326 20346
20327 20347
20328 // Failed access check callback that performs a GC on each invocation. 20348 // Failed access check callback that performs a GC on each invocation.
20329 void FailedAccessCheckThrows(Local<v8::Object> target, 20349 void FailedAccessCheckThrows(Local<v8::Object> target,
20330 v8::AccessType type, 20350 v8::AccessType type,
20331 Local<v8::Value> data) { 20351 Local<v8::Value> data) {
20332 access_check_fail_thrown = true; 20352 access_check_fail_thrown = true;
20333 i::PrintF("Access check failed. Error thrown.\n"); 20353 i::PrintF("Access check failed. Error thrown.\n");
20334 v8::ThrowException(v8::Exception::Error(v8_str("cross context"))); 20354 CcTest::isolate()->ThrowException(
20355 v8::Exception::Error(v8_str("cross context")));
20335 } 20356 }
20336 20357
20337 20358
20338 void CatcherCallback(const v8::FunctionCallbackInfo<v8::Value>& args) { 20359 void CatcherCallback(const v8::FunctionCallbackInfo<v8::Value>& args) {
20339 for (int i = 0; i < args.Length(); i++) { 20360 for (int i = 0; i < args.Length(); i++) {
20340 i::PrintF("%s\n", *String::Utf8Value(args[i])); 20361 i::PrintF("%s\n", *String::Utf8Value(args[i]));
20341 } 20362 }
20342 catch_callback_called = true; 20363 catch_callback_called = true;
20343 } 20364 }
20344 20365
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
20567 Local<Object> data2 = v8::Object::New(); 20588 Local<Object> data2 = v8::Object::New();
20568 function_new_expected_env = data2; 20589 function_new_expected_env = data2;
20569 Local<Function> func2 = Function::New(isolate, FunctionNewCallback, data2); 20590 Local<Function> func2 = Function::New(isolate, FunctionNewCallback, data2);
20570 CHECK(!func2->IsNull()); 20591 CHECK(!func2->IsNull());
20571 CHECK_NE(func, func2); 20592 CHECK_NE(func, func2);
20572 env->Global()->Set(v8_str("func2"), func2); 20593 env->Global()->Set(v8_str("func2"), func2);
20573 Local<Value> result2 = CompileRun("func2();"); 20594 Local<Value> result2 = CompileRun("func2();");
20574 CHECK_EQ(v8::Integer::New(17, isolate), result2); 20595 CHECK_EQ(v8::Integer::New(17, isolate), result2);
20575 } 20596 }
20576 20597
20598
20599 TEST(EscapeableHandleScope) {
20600 HandleScope outer_scope(CcTest::isolate());
20601 LocalContext context;
20602 const int runs = 10;
20603 Local<String> values[runs];
20604 for (int i = 0; i < runs; i++) {
20605 v8::EscapableHandleScope inner_scope(CcTest::isolate());
20606 Local<String> value;
20607 if (i != 0) value = v8_str("escape value");
20608 values[i] = inner_scope.Escape(value);
20609 }
20610 for (int i = 0; i < runs; i++) {
20611 Local<String> expected;
20612 if (i != 0) {
20613 CHECK_EQ(v8_str("escape value"), values[i]);
20614 } else {
20615 CHECK(values[i].IsEmpty());
20616 }
20617 }
20618 }
OLDNEW
« no previous file with comments | « test/cctest/test-accessors.cc ('k') | test/cctest/test-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698