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

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

Issue 142693005: A64: Synchronize with r16918. (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/cctest.status ('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 4643 matching lines...) Expand 10 before | Expand all | Expand 10 after
4654 4654
4655 void CThrowCountDown(const v8::FunctionCallbackInfo<v8::Value>& args) { 4655 void CThrowCountDown(const v8::FunctionCallbackInfo<v8::Value>& args) {
4656 ApiTestFuzzer::Fuzz(); 4656 ApiTestFuzzer::Fuzz();
4657 CHECK_EQ(4, args.Length()); 4657 CHECK_EQ(4, args.Length());
4658 int count = args[0]->Int32Value(); 4658 int count = args[0]->Int32Value();
4659 int cInterval = args[2]->Int32Value(); 4659 int cInterval = args[2]->Int32Value();
4660 if (count == 0) { 4660 if (count == 0) {
4661 v8::ThrowException(v8_str("FromC")); 4661 v8::ThrowException(v8_str("FromC"));
4662 return; 4662 return;
4663 } else { 4663 } else {
4664 Local<v8::Object> global = Context::GetCurrent()->Global(); 4664 Local<v8::Object> global =
4665 args.GetIsolate()->GetCurrentContext()->Global();
4665 Local<Value> fun = global->Get(v8_str("JSThrowCountDown")); 4666 Local<Value> fun = global->Get(v8_str("JSThrowCountDown"));
4666 v8::Handle<Value> argv[] = { v8_num(count - 1), 4667 v8::Handle<Value> argv[] = { v8_num(count - 1),
4667 args[1], 4668 args[1],
4668 args[2], 4669 args[2],
4669 args[3] }; 4670 args[3] };
4670 if (count % cInterval == 0) { 4671 if (count % cInterval == 0) {
4671 v8::TryCatch try_catch; 4672 v8::TryCatch try_catch;
4672 Local<Value> result = fun.As<Function>()->Call(global, 4, argv); 4673 Local<Value> result = fun.As<Function>()->Call(global, 4, argv);
4673 int expected = args[3]->Int32Value(); 4674 int expected = args[3]->Int32Value();
4674 if (try_catch.HasCaught()) { 4675 if (try_catch.HasCaught()) {
(...skipping 2396 matching lines...) Expand 10 before | Expand all | Expand 10 after
7071 7072
7072 7073
7073 int p_getter_count; 7074 int p_getter_count;
7074 int p_getter_count2; 7075 int p_getter_count2;
7075 7076
7076 7077
7077 static void PGetter(Local<String> name, 7078 static void PGetter(Local<String> name,
7078 const v8::PropertyCallbackInfo<v8::Value>& info) { 7079 const v8::PropertyCallbackInfo<v8::Value>& info) {
7079 ApiTestFuzzer::Fuzz(); 7080 ApiTestFuzzer::Fuzz();
7080 p_getter_count++; 7081 p_getter_count++;
7081 v8::Handle<v8::Object> global = Context::GetCurrent()->Global(); 7082 v8::Handle<v8::Object> global =
7083 info.GetIsolate()->GetCurrentContext()->Global();
7082 CHECK_EQ(info.Holder(), global->Get(v8_str("o1"))); 7084 CHECK_EQ(info.Holder(), global->Get(v8_str("o1")));
7083 if (name->Equals(v8_str("p1"))) { 7085 if (name->Equals(v8_str("p1"))) {
7084 CHECK_EQ(info.This(), global->Get(v8_str("o1"))); 7086 CHECK_EQ(info.This(), global->Get(v8_str("o1")));
7085 } else if (name->Equals(v8_str("p2"))) { 7087 } else if (name->Equals(v8_str("p2"))) {
7086 CHECK_EQ(info.This(), global->Get(v8_str("o2"))); 7088 CHECK_EQ(info.This(), global->Get(v8_str("o2")));
7087 } else if (name->Equals(v8_str("p3"))) { 7089 } else if (name->Equals(v8_str("p3"))) {
7088 CHECK_EQ(info.This(), global->Get(v8_str("o3"))); 7090 CHECK_EQ(info.This(), global->Get(v8_str("o3")));
7089 } else if (name->Equals(v8_str("p4"))) { 7091 } else if (name->Equals(v8_str("p4"))) {
7090 CHECK_EQ(info.This(), global->Get(v8_str("o4"))); 7092 CHECK_EQ(info.This(), global->Get(v8_str("o4")));
7091 } 7093 }
(...skipping 13 matching lines...) Expand all
7105 "for (var i = 0; i < 10; i++) o3.p3;" 7107 "for (var i = 0; i < 10; i++) o3.p3;"
7106 "for (var i = 0; i < 10; i++) o2.p2;" 7108 "for (var i = 0; i < 10; i++) o2.p2;"
7107 "for (var i = 0; i < 10; i++) o1.p1;"); 7109 "for (var i = 0; i < 10; i++) o1.p1;");
7108 } 7110 }
7109 7111
7110 7112
7111 static void PGetter2(Local<String> name, 7113 static void PGetter2(Local<String> name,
7112 const v8::PropertyCallbackInfo<v8::Value>& info) { 7114 const v8::PropertyCallbackInfo<v8::Value>& info) {
7113 ApiTestFuzzer::Fuzz(); 7115 ApiTestFuzzer::Fuzz();
7114 p_getter_count2++; 7116 p_getter_count2++;
7115 v8::Handle<v8::Object> global = Context::GetCurrent()->Global(); 7117 v8::Handle<v8::Object> global =
7118 info.GetIsolate()->GetCurrentContext()->Global();
7116 CHECK_EQ(info.Holder(), global->Get(v8_str("o1"))); 7119 CHECK_EQ(info.Holder(), global->Get(v8_str("o1")));
7117 if (name->Equals(v8_str("p1"))) { 7120 if (name->Equals(v8_str("p1"))) {
7118 CHECK_EQ(info.This(), global->Get(v8_str("o1"))); 7121 CHECK_EQ(info.This(), global->Get(v8_str("o1")));
7119 } else if (name->Equals(v8_str("p2"))) { 7122 } else if (name->Equals(v8_str("p2"))) {
7120 CHECK_EQ(info.This(), global->Get(v8_str("o2"))); 7123 CHECK_EQ(info.This(), global->Get(v8_str("o2")));
7121 } else if (name->Equals(v8_str("p3"))) { 7124 } else if (name->Equals(v8_str("p3"))) {
7122 CHECK_EQ(info.This(), global->Get(v8_str("o3"))); 7125 CHECK_EQ(info.This(), global->Get(v8_str("o3")));
7123 } else if (name->Equals(v8_str("p4"))) { 7126 } else if (name->Equals(v8_str("p4"))) {
7124 CHECK_EQ(info.This(), global->Get(v8_str("o4"))); 7127 CHECK_EQ(info.This(), global->Get(v8_str("o4")));
7125 } 7128 }
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
7211 CompileRun( 7214 CompileRun(
7212 "var left = '';" 7215 "var left = '';"
7213 "for (var i = 0; i < 0xd800; i += 4) {" 7216 "for (var i = 0; i < 0xd800; i += 4) {"
7214 " left = left + String.fromCharCode(i);" 7217 " left = left + String.fromCharCode(i);"
7215 "}"); 7218 "}");
7216 CompileRun( 7219 CompileRun(
7217 "var right = '';" 7220 "var right = '';"
7218 "for (var i = 0; i < 0xd800; i += 4) {" 7221 "for (var i = 0; i < 0xd800; i += 4) {"
7219 " right = String.fromCharCode(i) + right;" 7222 " right = String.fromCharCode(i) + right;"
7220 "}"); 7223 "}");
7221 v8::Handle<v8::Object> global = Context::GetCurrent()->Global(); 7224 v8::Handle<v8::Object> global = context->Global();
7222 Handle<String> left_tree = global->Get(v8_str("left")).As<String>(); 7225 Handle<String> left_tree = global->Get(v8_str("left")).As<String>();
7223 Handle<String> right_tree = global->Get(v8_str("right")).As<String>(); 7226 Handle<String> right_tree = global->Get(v8_str("right")).As<String>();
7224 7227
7225 CHECK_EQ(5, str2->Length()); 7228 CHECK_EQ(5, str2->Length());
7226 CHECK_EQ(0xd800 / kStride, left_tree->Length()); 7229 CHECK_EQ(0xd800 / kStride, left_tree->Length());
7227 CHECK_EQ(0xd800 / kStride, right_tree->Length()); 7230 CHECK_EQ(0xd800 / kStride, right_tree->Length());
7228 7231
7229 char buf[100]; 7232 char buf[100];
7230 char utf8buf[0xd800 * 3]; 7233 char utf8buf[0xd800 * 3];
7231 uint16_t wbuf[100]; 7234 uint16_t wbuf[100];
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
7798 return g_security_callback_result; 7801 return g_security_callback_result;
7799 } 7802 }
7800 7803
7801 7804
7802 static int trouble_nesting = 0; 7805 static int trouble_nesting = 0;
7803 static void TroubleCallback(const v8::FunctionCallbackInfo<v8::Value>& args) { 7806 static void TroubleCallback(const v8::FunctionCallbackInfo<v8::Value>& args) {
7804 ApiTestFuzzer::Fuzz(); 7807 ApiTestFuzzer::Fuzz();
7805 trouble_nesting++; 7808 trouble_nesting++;
7806 7809
7807 // Call a JS function that throws an uncaught exception. 7810 // Call a JS function that throws an uncaught exception.
7808 Local<v8::Object> arg_this = Context::GetCurrent()->Global(); 7811 Local<v8::Object> arg_this =
7812 args.GetIsolate()->GetCurrentContext()->Global();
7809 Local<Value> trouble_callee = (trouble_nesting == 3) ? 7813 Local<Value> trouble_callee = (trouble_nesting == 3) ?
7810 arg_this->Get(v8_str("trouble_callee")) : 7814 arg_this->Get(v8_str("trouble_callee")) :
7811 arg_this->Get(v8_str("trouble_caller")); 7815 arg_this->Get(v8_str("trouble_caller"));
7812 CHECK(trouble_callee->IsFunction()); 7816 CHECK(trouble_callee->IsFunction());
7813 args.GetReturnValue().Set( 7817 args.GetReturnValue().Set(
7814 Function::Cast(*trouble_callee)->Call(arg_this, 0, NULL)); 7818 Function::Cast(*trouble_callee)->Call(arg_this, 0, NULL));
7815 } 7819 }
7816 7820
7817 7821
7818 static int report_count = 0; 7822 static int report_count = 0;
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
8320 CHECK(result->IsInt32()); 8324 CHECK(result->IsInt32());
8321 CHECK_EQ(42, result->Int32Value()); 8325 CHECK_EQ(42, result->Int32Value());
8322 } 8326 }
8323 8327
8324 8328
8325 static bool allowed_access_type[v8::ACCESS_KEYS + 1] = { false }; 8329 static bool allowed_access_type[v8::ACCESS_KEYS + 1] = { false };
8326 static bool NamedAccessBlocker(Local<v8::Object> global, 8330 static bool NamedAccessBlocker(Local<v8::Object> global,
8327 Local<Value> name, 8331 Local<Value> name,
8328 v8::AccessType type, 8332 v8::AccessType type,
8329 Local<Value> data) { 8333 Local<Value> data) {
8330 return Context::GetCurrent()->Global()->Equals(global) || 8334 return CcTest::isolate()->GetCurrentContext()->Global()->Equals(global) ||
8331 allowed_access_type[type]; 8335 allowed_access_type[type];
8332 } 8336 }
8333 8337
8334 8338
8335 static bool IndexedAccessBlocker(Local<v8::Object> global, 8339 static bool IndexedAccessBlocker(Local<v8::Object> global,
8336 uint32_t key, 8340 uint32_t key,
8337 v8::AccessType type, 8341 v8::AccessType type,
8338 Local<Value> data) { 8342 Local<Value> data) {
8339 return Context::GetCurrent()->Global()->Equals(global) || 8343 return CcTest::isolate()->GetCurrentContext()->Global()->Equals(global) ||
8340 allowed_access_type[type]; 8344 allowed_access_type[type];
8341 } 8345 }
8342 8346
8343 8347
8344 static int g_echo_value_1 = -1; 8348 static int g_echo_value_1 = -1;
8345 static int g_echo_value_2 = -1; 8349 static int g_echo_value_2 = -1;
8346 8350
8347 8351
8348 static void EchoGetter( 8352 static void EchoGetter(
8349 Local<String> name, 8353 Local<String> name,
(...skipping 4089 matching lines...) Expand 10 before | Expand all | Expand 10 after
12439 void ApiTestFuzzer::TearDown() { 12443 void ApiTestFuzzer::TearDown() {
12440 fuzzing_ = false; 12444 fuzzing_ = false;
12441 for (int i = 0; i < RegisterThreadedTest::count(); i++) { 12445 for (int i = 0; i < RegisterThreadedTest::count(); i++) {
12442 ApiTestFuzzer *fuzzer = RegisterThreadedTest::nth(i)->fuzzer_; 12446 ApiTestFuzzer *fuzzer = RegisterThreadedTest::nth(i)->fuzzer_;
12443 if (fuzzer != NULL) fuzzer->Join(); 12447 if (fuzzer != NULL) fuzzer->Join();
12444 } 12448 }
12445 } 12449 }
12446 12450
12447 12451
12448 // Lets not be needlessly self-referential. 12452 // Lets not be needlessly self-referential.
12449 UNINITIALIZED_TEST(Threading1) { 12453 TEST(Threading1) {
12450 ApiTestFuzzer::SetUp(ApiTestFuzzer::FIRST_PART); 12454 ApiTestFuzzer::SetUp(ApiTestFuzzer::FIRST_PART);
12451 ApiTestFuzzer::RunAllTests(); 12455 ApiTestFuzzer::RunAllTests();
12452 ApiTestFuzzer::TearDown(); 12456 ApiTestFuzzer::TearDown();
12453 } 12457 }
12454 12458
12455 12459
12456 UNINITIALIZED_TEST(Threading2) { 12460 TEST(Threading2) {
12457 ApiTestFuzzer::SetUp(ApiTestFuzzer::SECOND_PART); 12461 ApiTestFuzzer::SetUp(ApiTestFuzzer::SECOND_PART);
12458 ApiTestFuzzer::RunAllTests(); 12462 ApiTestFuzzer::RunAllTests();
12459 ApiTestFuzzer::TearDown(); 12463 ApiTestFuzzer::TearDown();
12460 } 12464 }
12461 12465
12462 12466
12463 UNINITIALIZED_TEST(Threading3) { 12467 TEST(Threading3) {
12464 ApiTestFuzzer::SetUp(ApiTestFuzzer::THIRD_PART); 12468 ApiTestFuzzer::SetUp(ApiTestFuzzer::THIRD_PART);
12465 ApiTestFuzzer::RunAllTests(); 12469 ApiTestFuzzer::RunAllTests();
12466 ApiTestFuzzer::TearDown(); 12470 ApiTestFuzzer::TearDown();
12467 } 12471 }
12468 12472
12469 12473
12470 UNINITIALIZED_TEST(Threading4) { 12474 TEST(Threading4) {
12471 ApiTestFuzzer::SetUp(ApiTestFuzzer::FOURTH_PART); 12475 ApiTestFuzzer::SetUp(ApiTestFuzzer::FOURTH_PART);
12472 ApiTestFuzzer::RunAllTests(); 12476 ApiTestFuzzer::RunAllTests();
12473 ApiTestFuzzer::TearDown(); 12477 ApiTestFuzzer::TearDown();
12474 } 12478 }
12475 12479
12476 12480
12477 void ApiTestFuzzer::CallTest() { 12481 void ApiTestFuzzer::CallTest() {
12482 v8::Isolate::Scope scope(CcTest::isolate());
12478 if (kLogThreading) 12483 if (kLogThreading)
12479 printf("Start test %d\n", test_number_); 12484 printf("Start test %d\n", test_number_);
12480 CallTestNumber(test_number_); 12485 CallTestNumber(test_number_);
12481 if (kLogThreading) 12486 if (kLogThreading)
12482 printf("End test %d\n", test_number_); 12487 printf("End test %d\n", test_number_);
12483 } 12488 }
12484 12489
12485 12490
12486 static void ThrowInJS(const v8::FunctionCallbackInfo<v8::Value>& args) { 12491 static void ThrowInJS(const v8::FunctionCallbackInfo<v8::Value>& args) {
12487 CHECK(v8::Locker::IsLocked(CcTest::isolate())); 12492 CHECK(v8::Locker::IsLocked(CcTest::isolate()));
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
12668 const char* extension_list[] = { "v8/gc" }; 12673 const char* extension_list[] = { "v8/gc" };
12669 v8::ExtensionConfiguration extensions(1, extension_list); 12674 v8::ExtensionConfiguration extensions(1, extension_list);
12670 LocalContext context(&extensions); 12675 LocalContext context(&extensions);
12671 v8_compile("gc();")->Run(); 12676 v8_compile("gc();")->Run();
12672 } 12677 }
12673 v8::V8::ContextDisposedNotification(); 12678 v8::V8::ContextDisposedNotification();
12674 CheckSurvivingGlobalObjectsCount(0); 12679 CheckSurvivingGlobalObjectsCount(0);
12675 } 12680 }
12676 } 12681 }
12677 12682
12678 template<class T>
12679 struct CopyablePersistentTraits {
12680 typedef Persistent<T, CopyablePersistentTraits<T> > CopyablePersistent;
12681 static const bool kResetInDestructor = true;
12682 template<class S, class M>
12683 static V8_INLINE void Copy(const Persistent<S, M>& source,
12684 CopyablePersistent* dest) {
12685 // do nothing, just allow copy
12686 }
12687 };
12688
12689 12683
12690 TEST(CopyablePersistent) { 12684 TEST(CopyablePersistent) {
12691 LocalContext context; 12685 LocalContext context;
12692 v8::Isolate* isolate = context->GetIsolate(); 12686 v8::Isolate* isolate = context->GetIsolate();
12693 i::GlobalHandles* globals = 12687 i::GlobalHandles* globals =
12694 reinterpret_cast<i::Isolate*>(isolate)->global_handles(); 12688 reinterpret_cast<i::Isolate*>(isolate)->global_handles();
12695 int initial_handles = globals->global_handles_count(); 12689 int initial_handles = globals->global_handles_count();
12690 typedef v8::Persistent<v8::Object, v8::CopyablePersistentTraits<v8::Object> >
12691 CopyableObject;
12696 { 12692 {
12697 v8::Persistent<v8::Object, CopyablePersistentTraits<v8::Object> > handle1; 12693 CopyableObject handle1;
12698 { 12694 {
12699 v8::HandleScope scope(isolate); 12695 v8::HandleScope scope(isolate);
12700 handle1.Reset(isolate, v8::Object::New()); 12696 handle1.Reset(isolate, v8::Object::New());
12701 } 12697 }
12702 CHECK_EQ(initial_handles + 1, globals->global_handles_count()); 12698 CHECK_EQ(initial_handles + 1, globals->global_handles_count());
12703 v8::Persistent<v8::Object, CopyablePersistentTraits<v8::Object> > handle2; 12699 CopyableObject handle2;
12704 handle2 = handle1; 12700 handle2 = handle1;
12705 CHECK(handle1 == handle2); 12701 CHECK(handle1 == handle2);
12706 CHECK_EQ(initial_handles + 2, globals->global_handles_count()); 12702 CHECK_EQ(initial_handles + 2, globals->global_handles_count());
12707 v8::Persistent<v8::Object, CopyablePersistentTraits<v8::Object> > 12703 CopyableObject handle3(handle2);
12708 handle3(handle2);
12709 CHECK(handle1 == handle3); 12704 CHECK(handle1 == handle3);
12710 CHECK_EQ(initial_handles + 3, globals->global_handles_count()); 12705 CHECK_EQ(initial_handles + 3, globals->global_handles_count());
12711 } 12706 }
12712 // Verify autodispose 12707 // Verify autodispose
12713 CHECK_EQ(initial_handles, globals->global_handles_count()); 12708 CHECK_EQ(initial_handles, globals->global_handles_count());
12714 } 12709 }
12715 12710
12716 12711
12717 static void WeakApiCallback( 12712 static void WeakApiCallback(
12718 const v8::WeakCallbackData<v8::Object, Persistent<v8::Object> >& data) { 12713 const v8::WeakCallbackData<v8::Object, Persistent<v8::Object> >& data) {
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after
13476 CHECK(!env.IsEmpty()); 13471 CHECK(!env.IsEmpty());
13477 const intptr_t kSize = 1024*1024; 13472 const intptr_t kSize = 1024*1024;
13478 int64_t baseline = cast(isolate->AdjustAmountOfExternalAllocatedMemory(0)); 13473 int64_t baseline = cast(isolate->AdjustAmountOfExternalAllocatedMemory(0));
13479 CHECK_EQ(baseline + cast(kSize), 13474 CHECK_EQ(baseline + cast(kSize),
13480 cast(isolate->AdjustAmountOfExternalAllocatedMemory(kSize))); 13475 cast(isolate->AdjustAmountOfExternalAllocatedMemory(kSize)));
13481 CHECK_EQ(baseline, 13476 CHECK_EQ(baseline,
13482 cast(isolate->AdjustAmountOfExternalAllocatedMemory(-kSize))); 13477 cast(isolate->AdjustAmountOfExternalAllocatedMemory(-kSize)));
13483 } 13478 }
13484 13479
13485 13480
13486 THREADED_TEST(DisposeEnteredContext) {
13487 LocalContext outer;
13488 v8::Isolate* isolate = outer->GetIsolate();
13489 v8::Persistent<v8::Context> inner;
13490 {
13491 v8::HandleScope scope(isolate);
13492 inner.Reset(isolate, v8::Context::New(isolate));
13493 }
13494 v8::HandleScope scope(isolate);
13495 {
13496 // Don't want a handle here, so do this unsafely
13497 v8::Handle<v8::Context> inner_local =
13498 v8::Utils::Convert<i::Object, v8::Context>(
13499 v8::Utils::OpenPersistent(inner));
13500 inner_local->Enter();
13501 inner.Dispose();
13502 inner.Clear();
13503 inner_local->Exit();
13504 }
13505 }
13506
13507
13508 // Regression test for issue 54, object templates with internal fields 13481 // Regression test for issue 54, object templates with internal fields
13509 // but no accessors or interceptors did not get their internal field 13482 // but no accessors or interceptors did not get their internal field
13510 // count set on instances. 13483 // count set on instances.
13511 THREADED_TEST(Regress54) { 13484 THREADED_TEST(Regress54) {
13512 LocalContext context; 13485 LocalContext context;
13513 v8::Isolate* isolate = context->GetIsolate(); 13486 v8::Isolate* isolate = context->GetIsolate();
13514 v8::HandleScope outer(isolate); 13487 v8::HandleScope outer(isolate);
13515 static v8::Persistent<v8::ObjectTemplate> templ; 13488 static v8::Persistent<v8::ObjectTemplate> templ;
13516 if (templ.IsEmpty()) { 13489 if (templ.IsEmpty()) {
13517 v8::HandleScope inner(isolate); 13490 v8::HandleScope inner(isolate);
(...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after
14250 } 14223 }
14251 private: 14224 private:
14252 RegExpInterruptTest* test_; 14225 RegExpInterruptTest* test_;
14253 }; 14226 };
14254 14227
14255 void CollectGarbage() { 14228 void CollectGarbage() {
14256 block_.Wait(); 14229 block_.Wait();
14257 while (gc_during_regexp_ < kRequiredGCs) { 14230 while (gc_during_regexp_ < kRequiredGCs) {
14258 { 14231 {
14259 v8::Locker lock(CcTest::isolate()); 14232 v8::Locker lock(CcTest::isolate());
14233 v8::Isolate::Scope isolate_scope(CcTest::isolate());
14260 // TODO(lrn): Perhaps create some garbage before collecting. 14234 // TODO(lrn): Perhaps create some garbage before collecting.
14261 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); 14235 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags);
14262 gc_count_++; 14236 gc_count_++;
14263 } 14237 }
14264 i::OS::Sleep(1); 14238 i::OS::Sleep(1);
14265 } 14239 }
14266 gc_success_ = true; 14240 gc_success_ = true;
14267 } 14241 }
14268 14242
14269 void LongRunningRegExp() { 14243 void LongRunningRegExp() {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
14308 i::Semaphore block_; 14282 i::Semaphore block_;
14309 int gc_count_; 14283 int gc_count_;
14310 int gc_during_regexp_; 14284 int gc_during_regexp_;
14311 bool regexp_success_; 14285 bool regexp_success_;
14312 bool gc_success_; 14286 bool gc_success_;
14313 }; 14287 };
14314 14288
14315 14289
14316 // Test that a regular expression execution can be interrupted and 14290 // Test that a regular expression execution can be interrupted and
14317 // survive a garbage collection. 14291 // survive a garbage collection.
14318 UNINITIALIZED_TEST(RegExpInterruption) { 14292 TEST(RegExpInterruption) {
14319 v8::Locker lock(CcTest::isolate()); 14293 v8::Locker lock(CcTest::isolate());
14320 v8::V8::Initialize();
14321 v8::HandleScope scope(CcTest::isolate()); 14294 v8::HandleScope scope(CcTest::isolate());
14322 Local<Context> local_env; 14295 Local<Context> local_env;
14323 { 14296 {
14324 LocalContext env; 14297 LocalContext env;
14325 local_env = env.local(); 14298 local_env = env.local();
14326 } 14299 }
14327 14300
14328 // Local context should still be live. 14301 // Local context should still be live.
14329 CHECK(!local_env.IsEmpty()); 14302 CHECK(!local_env.IsEmpty());
14330 local_env->Enter(); 14303 local_env->Enter();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
14372 } 14345 }
14373 private: 14346 private:
14374 ApplyInterruptTest* test_; 14347 ApplyInterruptTest* test_;
14375 }; 14348 };
14376 14349
14377 void CollectGarbage() { 14350 void CollectGarbage() {
14378 block_.Wait(); 14351 block_.Wait();
14379 while (gc_during_apply_ < kRequiredGCs) { 14352 while (gc_during_apply_ < kRequiredGCs) {
14380 { 14353 {
14381 v8::Locker lock(CcTest::isolate()); 14354 v8::Locker lock(CcTest::isolate());
14355 v8::Isolate::Scope isolate_scope(CcTest::isolate());
14382 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); 14356 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags);
14383 gc_count_++; 14357 gc_count_++;
14384 } 14358 }
14385 i::OS::Sleep(1); 14359 i::OS::Sleep(1);
14386 } 14360 }
14387 gc_success_ = true; 14361 gc_success_ = true;
14388 } 14362 }
14389 14363
14390 void LongRunningApply() { 14364 void LongRunningApply() {
14391 block_.Signal(); 14365 block_.Signal();
(...skipping 24 matching lines...) Expand all
14416 i::Semaphore block_; 14390 i::Semaphore block_;
14417 int gc_count_; 14391 int gc_count_;
14418 int gc_during_apply_; 14392 int gc_during_apply_;
14419 bool apply_success_; 14393 bool apply_success_;
14420 bool gc_success_; 14394 bool gc_success_;
14421 }; 14395 };
14422 14396
14423 14397
14424 // Test that nothing bad happens if we get a preemption just when we were 14398 // Test that nothing bad happens if we get a preemption just when we were
14425 // about to do an apply(). 14399 // about to do an apply().
14426 UNINITIALIZED_TEST(ApplyInterruption) { 14400 TEST(ApplyInterruption) {
14427 v8::Locker lock(CcTest::isolate()); 14401 v8::Locker lock(CcTest::isolate());
14428 v8::V8::Initialize(); 14402 v8::V8::Initialize();
14429 v8::HandleScope scope(CcTest::isolate()); 14403 v8::HandleScope scope(CcTest::isolate());
14430 Local<Context> local_env; 14404 Local<Context> local_env;
14431 { 14405 {
14432 LocalContext env; 14406 LocalContext env;
14433 local_env = env.local(); 14407 local_env = env.local();
14434 } 14408 }
14435 14409
14436 // Local context should still be live. 14410 // Local context should still be live.
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
14687 private: 14661 private:
14688 RegExpStringModificationTest* test_; 14662 RegExpStringModificationTest* test_;
14689 }; 14663 };
14690 14664
14691 void MorphString() { 14665 void MorphString() {
14692 block_.Wait(); 14666 block_.Wait();
14693 while (morphs_during_regexp_ < kRequiredModifications && 14667 while (morphs_during_regexp_ < kRequiredModifications &&
14694 morphs_ < kMaxModifications) { 14668 morphs_ < kMaxModifications) {
14695 { 14669 {
14696 v8::Locker lock(CcTest::isolate()); 14670 v8::Locker lock(CcTest::isolate());
14671 v8::Isolate::Scope isolate_scope(CcTest::isolate());
14697 // Swap string between ascii and two-byte representation. 14672 // Swap string between ascii and two-byte representation.
14698 i::String* string = *input_; 14673 i::String* string = *input_;
14699 MorphAString(string, &ascii_resource_, &uc16_resource_); 14674 MorphAString(string, &ascii_resource_, &uc16_resource_);
14700 morphs_++; 14675 morphs_++;
14701 } 14676 }
14702 i::OS::Sleep(1); 14677 i::OS::Sleep(1);
14703 } 14678 }
14704 morph_success_ = true; 14679 morph_success_ = true;
14705 } 14680 }
14706 14681
(...skipping 26 matching lines...) Expand all
14733 bool regexp_success_; 14708 bool regexp_success_;
14734 bool morph_success_; 14709 bool morph_success_;
14735 i::Handle<i::String> input_; 14710 i::Handle<i::String> input_;
14736 AsciiVectorResource ascii_resource_; 14711 AsciiVectorResource ascii_resource_;
14737 UC16VectorResource uc16_resource_; 14712 UC16VectorResource uc16_resource_;
14738 }; 14713 };
14739 14714
14740 14715
14741 // Test that a regular expression execution can be interrupted and 14716 // Test that a regular expression execution can be interrupted and
14742 // the string changed without failing. 14717 // the string changed without failing.
14743 UNINITIALIZED_TEST(RegExpStringModification) { 14718 TEST(RegExpStringModification) {
14744 v8::Locker lock(CcTest::isolate()); 14719 v8::Locker lock(CcTest::isolate());
14745 v8::V8::Initialize();
14746 v8::HandleScope scope(CcTest::isolate()); 14720 v8::HandleScope scope(CcTest::isolate());
14747 Local<Context> local_env; 14721 Local<Context> local_env;
14748 { 14722 {
14749 LocalContext env; 14723 LocalContext env;
14750 local_env = env.local(); 14724 local_env = env.local();
14751 } 14725 }
14752 14726
14753 // Local context should still be live. 14727 // Local context should still be live.
14754 CHECK(!local_env.IsEmpty()); 14728 CHECK(!local_env.IsEmpty());
14755 local_env->Enter(); 14729 local_env->Enter();
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
15032 static v8::Local<Context> calling_context1; 15006 static v8::Local<Context> calling_context1;
15033 static v8::Local<Context> calling_context2; 15007 static v8::Local<Context> calling_context2;
15034 15008
15035 15009
15036 // Check that the call to the callback is initiated in 15010 // Check that the call to the callback is initiated in
15037 // calling_context2, the directly calling context is calling_context1 15011 // calling_context2, the directly calling context is calling_context1
15038 // and the callback itself is in calling_context0. 15012 // and the callback itself is in calling_context0.
15039 static void GetCallingContextCallback( 15013 static void GetCallingContextCallback(
15040 const v8::FunctionCallbackInfo<v8::Value>& args) { 15014 const v8::FunctionCallbackInfo<v8::Value>& args) {
15041 ApiTestFuzzer::Fuzz(); 15015 ApiTestFuzzer::Fuzz();
15042 CHECK(Context::GetCurrent() == calling_context0);
15043 CHECK(args.GetIsolate()->GetCurrentContext() == calling_context0); 15016 CHECK(args.GetIsolate()->GetCurrentContext() == calling_context0);
15044 CHECK(Context::GetCalling() == calling_context1); 15017 CHECK(args.GetIsolate()->GetCallingContext() == calling_context1);
15045 CHECK(Context::GetEntered() == calling_context2); 15018 CHECK(args.GetIsolate()->GetEnteredContext() == calling_context2);
15046 args.GetReturnValue().Set(42); 15019 args.GetReturnValue().Set(42);
15047 } 15020 }
15048 15021
15049 15022
15050 THREADED_TEST(GetCurrentContextWhenNotInContext) { 15023 THREADED_TEST(GetCurrentContextWhenNotInContext) {
15051 i::Isolate* isolate = CcTest::i_isolate(); 15024 i::Isolate* isolate = CcTest::i_isolate();
15052 CHECK(isolate != NULL); 15025 CHECK(isolate != NULL);
15053 CHECK(isolate->context() == NULL); 15026 CHECK(isolate->context() == NULL);
15054 v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate); 15027 v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate);
15055 v8::HandleScope scope(v8_isolate); 15028 v8::HandleScope scope(v8_isolate);
(...skipping 4675 matching lines...) Expand 10 before | Expand all | Expand 10 after
19731 i::Handle<i::Object> true_value = factory->true_value(); 19704 i::Handle<i::Object> true_value = factory->true_value();
19732 CHECK(*v8::Utils::OpenHandle(*v8::True()) == *true_value); 19705 CHECK(*v8::Utils::OpenHandle(*v8::True()) == *true_value);
19733 CHECK(*v8::Utils::OpenHandle(*v8::True(isolate)) == *true_value); 19706 CHECK(*v8::Utils::OpenHandle(*v8::True(isolate)) == *true_value);
19734 i::Handle<i::Object> false_value = factory->false_value(); 19707 i::Handle<i::Object> false_value = factory->false_value();
19735 CHECK(*v8::Utils::OpenHandle(*v8::False()) == *false_value); 19708 CHECK(*v8::Utils::OpenHandle(*v8::False()) == *false_value);
19736 CHECK(*v8::Utils::OpenHandle(*v8::False(isolate)) == *false_value); 19709 CHECK(*v8::Utils::OpenHandle(*v8::False(isolate)) == *false_value);
19737 } 19710 }
19738 19711
19739 19712
19740 UNINITIALIZED_TEST(IsolateEmbedderData) { 19713 UNINITIALIZED_TEST(IsolateEmbedderData) {
19741 v8::Isolate* isolate = CcTest::isolate(); 19714 CcTest::DisableAutomaticDispose();
19715 v8::Isolate* isolate = v8::Isolate::New();
19716 isolate->Enter();
19742 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 19717 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
19743 CHECK_EQ(NULL, isolate->GetData()); 19718 CHECK_EQ(NULL, isolate->GetData());
19744 CHECK_EQ(NULL, i_isolate->GetData()); 19719 CHECK_EQ(NULL, i_isolate->GetData());
19745 static void* data1 = reinterpret_cast<void*>(0xacce55ed); 19720 static void* data1 = reinterpret_cast<void*>(0xacce55ed);
19746 isolate->SetData(data1); 19721 isolate->SetData(data1);
19747 CHECK_EQ(data1, isolate->GetData()); 19722 CHECK_EQ(data1, isolate->GetData());
19748 CHECK_EQ(data1, i_isolate->GetData()); 19723 CHECK_EQ(data1, i_isolate->GetData());
19749 static void* data2 = reinterpret_cast<void*>(0xdecea5ed); 19724 static void* data2 = reinterpret_cast<void*>(0xdecea5ed);
19750 i_isolate->SetData(data2); 19725 i_isolate->SetData(data2);
19751 CHECK_EQ(data2, isolate->GetData()); 19726 CHECK_EQ(data2, isolate->GetData());
19752 CHECK_EQ(data2, i_isolate->GetData()); 19727 CHECK_EQ(data2, i_isolate->GetData());
19753 i_isolate->TearDown(); 19728 isolate->Exit();
19754 CHECK_EQ(data2, isolate->GetData()); 19729 isolate->Dispose();
19755 CHECK_EQ(data2, i_isolate->GetData());
19756 } 19730 }
19757 19731
19758 19732
19759 TEST(StringEmpty) { 19733 TEST(StringEmpty) {
19760 LocalContext context; 19734 LocalContext context;
19761 i::Factory* factory = CcTest::i_isolate()->factory(); 19735 i::Factory* factory = CcTest::i_isolate()->factory();
19762 v8::Isolate* isolate = CcTest::isolate(); 19736 v8::Isolate* isolate = CcTest::isolate();
19763 v8::HandleScope scope(isolate); 19737 v8::HandleScope scope(isolate);
19764 i::Handle<i::Object> empty_string = factory->empty_string(); 19738 i::Handle<i::Object> empty_string = factory->empty_string();
19765 CHECK(*v8::Utils::OpenHandle(*v8::String::Empty()) == *empty_string); 19739 CHECK(*v8::Utils::OpenHandle(*v8::String::Empty()) == *empty_string);
(...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after
20593 Local<Object> data2 = v8::Object::New(); 20567 Local<Object> data2 = v8::Object::New();
20594 function_new_expected_env = data2; 20568 function_new_expected_env = data2;
20595 Local<Function> func2 = Function::New(isolate, FunctionNewCallback, data2); 20569 Local<Function> func2 = Function::New(isolate, FunctionNewCallback, data2);
20596 CHECK(!func2->IsNull()); 20570 CHECK(!func2->IsNull());
20597 CHECK_NE(func, func2); 20571 CHECK_NE(func, func2);
20598 env->Global()->Set(v8_str("func2"), func2); 20572 env->Global()->Set(v8_str("func2"), func2);
20599 Local<Value> result2 = CompileRun("func2();"); 20573 Local<Value> result2 = CompileRun("func2();");
20600 CHECK_EQ(v8::Integer::New(17, isolate), result2); 20574 CHECK_EQ(v8::Integer::New(17, isolate), result2);
20601 } 20575 }
20602 20576
OLDNEW
« no previous file with comments | « test/cctest/cctest.status ('k') | test/cctest/test-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698