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

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

Issue 23748003: Cleanup Semaphore class. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Build fix for Mac OS X. Created 7 years, 3 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.gyp ('k') | test/cctest/test-circular-queue.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 12219 matching lines...) Expand 10 before | Expand all | Expand 10 after
12230 CHECK(c->IsObject() && c->ToObject()->GetConstructorName()->Equals( 12230 CHECK(c->IsObject() && c->ToObject()->GetConstructorName()->Equals(
12231 v8_str("Child"))); 12231 v8_str("Child")));
12232 12232
12233 Local<v8::Value> x = context->Global()->Get(v8_str("x")); 12233 Local<v8::Value> x = context->Global()->Get(v8_str("x"));
12234 CHECK(x->IsObject() && x->ToObject()->GetConstructorName()->Equals( 12234 CHECK(x->IsObject() && x->ToObject()->GetConstructorName()->Equals(
12235 v8_str("outer.inner"))); 12235 v8_str("outer.inner")));
12236 } 12236 }
12237 12237
12238 12238
12239 bool ApiTestFuzzer::fuzzing_ = false; 12239 bool ApiTestFuzzer::fuzzing_ = false;
12240 i::Semaphore* ApiTestFuzzer::all_tests_done_= 12240 i::Semaphore ApiTestFuzzer::all_tests_done_(0);
12241 i::OS::CreateSemaphore(0);
12242 int ApiTestFuzzer::active_tests_; 12241 int ApiTestFuzzer::active_tests_;
12243 int ApiTestFuzzer::tests_being_run_; 12242 int ApiTestFuzzer::tests_being_run_;
12244 int ApiTestFuzzer::current_; 12243 int ApiTestFuzzer::current_;
12245 12244
12246 12245
12247 // We are in a callback and want to switch to another thread (if we 12246 // We are in a callback and want to switch to another thread (if we
12248 // are currently running the thread fuzzing test). 12247 // are currently running the thread fuzzing test).
12249 void ApiTestFuzzer::Fuzz() { 12248 void ApiTestFuzzer::Fuzz() {
12250 if (!fuzzing_) return; 12249 if (!fuzzing_) return;
12251 ApiTestFuzzer* test = RegisterThreadedTest::nth(current_)->fuzzer_; 12250 ApiTestFuzzer* test = RegisterThreadedTest::nth(current_)->fuzzer_;
(...skipping 10 matching lines...) Expand all
12262 if (kLogThreading) 12261 if (kLogThreading)
12263 printf("Stay with %s\n", test_name); 12262 printf("Stay with %s\n", test_name);
12264 return false; 12263 return false;
12265 } 12264 }
12266 if (kLogThreading) { 12265 if (kLogThreading) {
12267 printf("Switch from %s to %s\n", 12266 printf("Switch from %s to %s\n",
12268 test_name, 12267 test_name,
12269 RegisterThreadedTest::nth(test_position)->name()); 12268 RegisterThreadedTest::nth(test_position)->name());
12270 } 12269 }
12271 current_ = test_position; 12270 current_ = test_position;
12272 RegisterThreadedTest::nth(current_)->fuzzer_->gate_->Signal(); 12271 RegisterThreadedTest::nth(current_)->fuzzer_->gate_.Signal();
12273 return true; 12272 return true;
12274 } 12273 }
12275 12274
12276 12275
12277 void ApiTestFuzzer::Run() { 12276 void ApiTestFuzzer::Run() {
12278 // When it is our turn... 12277 // When it is our turn...
12279 gate_->Wait(); 12278 gate_.Wait();
12280 { 12279 {
12281 // ... get the V8 lock and start running the test. 12280 // ... get the V8 lock and start running the test.
12282 v8::Locker locker(CcTest::default_isolate()); 12281 v8::Locker locker(CcTest::default_isolate());
12283 CallTest(); 12282 CallTest();
12284 } 12283 }
12285 // This test finished. 12284 // This test finished.
12286 active_ = false; 12285 active_ = false;
12287 active_tests_--; 12286 active_tests_--;
12288 // If it was the last then signal that fact. 12287 // If it was the last then signal that fact.
12289 if (active_tests_ == 0) { 12288 if (active_tests_ == 0) {
12290 all_tests_done_->Signal(); 12289 all_tests_done_.Signal();
12291 } else { 12290 } else {
12292 // Otherwise select a new test and start that. 12291 // Otherwise select a new test and start that.
12293 NextThread(); 12292 NextThread();
12294 } 12293 }
12295 } 12294 }
12296 12295
12297 12296
12298 static unsigned linear_congruential_generator; 12297 static unsigned linear_congruential_generator;
12299 12298
12300 12299
(...skipping 16 matching lines...) Expand all
12317 static void CallTestNumber(int test_number) { 12316 static void CallTestNumber(int test_number) {
12318 (RegisterThreadedTest::nth(test_number)->callback())(); 12317 (RegisterThreadedTest::nth(test_number)->callback())();
12319 } 12318 }
12320 12319
12321 12320
12322 void ApiTestFuzzer::RunAllTests() { 12321 void ApiTestFuzzer::RunAllTests() {
12323 // Set off the first test. 12322 // Set off the first test.
12324 current_ = -1; 12323 current_ = -1;
12325 NextThread(); 12324 NextThread();
12326 // Wait till they are all done. 12325 // Wait till they are all done.
12327 all_tests_done_->Wait(); 12326 all_tests_done_.Wait();
12328 } 12327 }
12329 12328
12330 12329
12331 int ApiTestFuzzer::GetNextTestNumber() { 12330 int ApiTestFuzzer::GetNextTestNumber() {
12332 int next_test; 12331 int next_test;
12333 do { 12332 do {
12334 next_test = (linear_congruential_generator >> 16) % tests_being_run_; 12333 next_test = (linear_congruential_generator >> 16) % tests_being_run_;
12335 linear_congruential_generator *= 1664525u; 12334 linear_congruential_generator *= 1664525u;
12336 linear_congruential_generator += 1013904223u; 12335 linear_congruential_generator += 1013904223u;
12337 } while (!RegisterThreadedTest::nth(next_test)->fuzzer_->active_); 12336 } while (!RegisterThreadedTest::nth(next_test)->fuzzer_->active_);
12338 return next_test; 12337 return next_test;
12339 } 12338 }
12340 12339
12341 12340
12342 void ApiTestFuzzer::ContextSwitch() { 12341 void ApiTestFuzzer::ContextSwitch() {
12343 // If the new thread is the same as the current thread there is nothing to do. 12342 // If the new thread is the same as the current thread there is nothing to do.
12344 if (NextThread()) { 12343 if (NextThread()) {
12345 // Now it can start. 12344 // Now it can start.
12346 v8::Unlocker unlocker(CcTest::default_isolate()); 12345 v8::Unlocker unlocker(CcTest::default_isolate());
12347 // Wait till someone starts us again. 12346 // Wait till someone starts us again.
12348 gate_->Wait(); 12347 gate_.Wait();
12349 // And we're off. 12348 // And we're off.
12350 } 12349 }
12351 } 12350 }
12352 12351
12353 12352
12354 void ApiTestFuzzer::TearDown() { 12353 void ApiTestFuzzer::TearDown() {
12355 fuzzing_ = false; 12354 fuzzing_ = false;
12356 for (int i = 0; i < RegisterThreadedTest::count(); i++) { 12355 for (int i = 0; i < RegisterThreadedTest::count(); i++) {
12357 ApiTestFuzzer *fuzzer = RegisterThreadedTest::nth(i)->fuzzer_; 12356 ApiTestFuzzer *fuzzer = RegisterThreadedTest::nth(i)->fuzzer_;
12358 if (fuzzer != NULL) fuzzer->Join(); 12357 if (fuzzer != NULL) fuzzer->Join();
(...skipping 1695 matching lines...) Expand 10 before | Expand all | Expand 10 after
14054 context1->Global()->Set(v8_str("other"), context0->Global()); 14053 context1->Global()->Set(v8_str("other"), context0->Global());
14055 Local<Value> value = CompileRun("var instance = new other.C(); instance.x"); 14054 Local<Value> value = CompileRun("var instance = new other.C(); instance.x");
14056 CHECK(value->IsInt32()); 14055 CHECK(value->IsInt32());
14057 CHECK_EQ(42, value->Int32Value()); 14056 CHECK_EQ(42, value->Int32Value());
14058 context1->Exit(); 14057 context1->Exit();
14059 } 14058 }
14060 14059
14061 14060
14062 class RegExpInterruptTest { 14061 class RegExpInterruptTest {
14063 public: 14062 public:
14064 RegExpInterruptTest() : block_(NULL) {} 14063 RegExpInterruptTest() : block_(0) {}
14065 ~RegExpInterruptTest() { delete block_; } 14064 ~RegExpInterruptTest() {}
14066 void RunTest() { 14065 void RunTest() {
14067 block_ = i::OS::CreateSemaphore(0);
14068 gc_count_ = 0; 14066 gc_count_ = 0;
14069 gc_during_regexp_ = 0; 14067 gc_during_regexp_ = 0;
14070 regexp_success_ = false; 14068 regexp_success_ = false;
14071 gc_success_ = false; 14069 gc_success_ = false;
14072 GCThread gc_thread(this); 14070 GCThread gc_thread(this);
14073 gc_thread.Start(); 14071 gc_thread.Start();
14074 v8::Locker::StartPreemption(1); 14072 v8::Locker::StartPreemption(1);
14075 14073
14076 LongRunningRegExp(); 14074 LongRunningRegExp();
14077 { 14075 {
(...skipping 14 matching lines...) Expand all
14092 explicit GCThread(RegExpInterruptTest* test) 14090 explicit GCThread(RegExpInterruptTest* test)
14093 : Thread("GCThread"), test_(test) {} 14091 : Thread("GCThread"), test_(test) {}
14094 virtual void Run() { 14092 virtual void Run() {
14095 test_->CollectGarbage(); 14093 test_->CollectGarbage();
14096 } 14094 }
14097 private: 14095 private:
14098 RegExpInterruptTest* test_; 14096 RegExpInterruptTest* test_;
14099 }; 14097 };
14100 14098
14101 void CollectGarbage() { 14099 void CollectGarbage() {
14102 block_->Wait(); 14100 block_.Wait();
14103 while (gc_during_regexp_ < kRequiredGCs) { 14101 while (gc_during_regexp_ < kRequiredGCs) {
14104 { 14102 {
14105 v8::Locker lock(CcTest::default_isolate()); 14103 v8::Locker lock(CcTest::default_isolate());
14106 // TODO(lrn): Perhaps create some garbage before collecting. 14104 // TODO(lrn): Perhaps create some garbage before collecting.
14107 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); 14105 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
14108 gc_count_++; 14106 gc_count_++;
14109 } 14107 }
14110 i::OS::Sleep(1); 14108 i::OS::Sleep(1);
14111 } 14109 }
14112 gc_success_ = true; 14110 gc_success_ = true;
14113 } 14111 }
14114 14112
14115 void LongRunningRegExp() { 14113 void LongRunningRegExp() {
14116 block_->Signal(); // Enable garbage collection thread on next preemption. 14114 block_.Signal(); // Enable garbage collection thread on next preemption.
14117 int rounds = 0; 14115 int rounds = 0;
14118 while (gc_during_regexp_ < kRequiredGCs) { 14116 while (gc_during_regexp_ < kRequiredGCs) {
14119 int gc_before = gc_count_; 14117 int gc_before = gc_count_;
14120 { 14118 {
14121 // Match 15-30 "a"'s against 14 and a "b". 14119 // Match 15-30 "a"'s against 14 and a "b".
14122 const char* c_source = 14120 const char* c_source =
14123 "/a?a?a?a?a?a?a?a?a?a?a?a?a?a?aaaaaaaaaaaaaaaa/" 14121 "/a?a?a?a?a?a?a?a?a?a?a?a?a?a?aaaaaaaaaaaaaaaa/"
14124 ".exec('aaaaaaaaaaaaaaab') === null"; 14122 ".exec('aaaaaaaaaaaaaaab') === null";
14125 Local<String> source = String::New(c_source); 14123 Local<String> source = String::New(c_source);
14126 Local<Script> script = Script::Compile(source); 14124 Local<Script> script = Script::Compile(source);
(...skipping 17 matching lines...) Expand all
14144 } 14142 }
14145 } 14143 }
14146 int gc_after = gc_count_; 14144 int gc_after = gc_count_;
14147 gc_during_regexp_ += gc_after - gc_before; 14145 gc_during_regexp_ += gc_after - gc_before;
14148 rounds++; 14146 rounds++;
14149 i::OS::Sleep(1); 14147 i::OS::Sleep(1);
14150 } 14148 }
14151 regexp_success_ = true; 14149 regexp_success_ = true;
14152 } 14150 }
14153 14151
14154 i::Semaphore* block_; 14152 i::Semaphore block_;
14155 int gc_count_; 14153 int gc_count_;
14156 int gc_during_regexp_; 14154 int gc_during_regexp_;
14157 bool regexp_success_; 14155 bool regexp_success_;
14158 bool gc_success_; 14156 bool gc_success_;
14159 }; 14157 };
14160 14158
14161 14159
14162 // Test that a regular expression execution can be interrupted and 14160 // Test that a regular expression execution can be interrupted and
14163 // survive a garbage collection. 14161 // survive a garbage collection.
14164 TEST(RegExpInterruption) { 14162 TEST(RegExpInterruption) {
(...skipping 12 matching lines...) Expand all
14177 14175
14178 // Should complete without problems. 14176 // Should complete without problems.
14179 RegExpInterruptTest().RunTest(); 14177 RegExpInterruptTest().RunTest();
14180 14178
14181 local_env->Exit(); 14179 local_env->Exit();
14182 } 14180 }
14183 14181
14184 14182
14185 class ApplyInterruptTest { 14183 class ApplyInterruptTest {
14186 public: 14184 public:
14187 ApplyInterruptTest() : block_(NULL) {} 14185 ApplyInterruptTest() : block_(0) {}
14188 ~ApplyInterruptTest() { delete block_; } 14186 ~ApplyInterruptTest() {}
14189 void RunTest() { 14187 void RunTest() {
14190 block_ = i::OS::CreateSemaphore(0);
14191 gc_count_ = 0; 14188 gc_count_ = 0;
14192 gc_during_apply_ = 0; 14189 gc_during_apply_ = 0;
14193 apply_success_ = false; 14190 apply_success_ = false;
14194 gc_success_ = false; 14191 gc_success_ = false;
14195 GCThread gc_thread(this); 14192 GCThread gc_thread(this);
14196 gc_thread.Start(); 14193 gc_thread.Start();
14197 v8::Locker::StartPreemption(1); 14194 v8::Locker::StartPreemption(1);
14198 14195
14199 LongRunningApply(); 14196 LongRunningApply();
14200 { 14197 {
(...skipping 14 matching lines...) Expand all
14215 explicit GCThread(ApplyInterruptTest* test) 14212 explicit GCThread(ApplyInterruptTest* test)
14216 : Thread("GCThread"), test_(test) {} 14213 : Thread("GCThread"), test_(test) {}
14217 virtual void Run() { 14214 virtual void Run() {
14218 test_->CollectGarbage(); 14215 test_->CollectGarbage();
14219 } 14216 }
14220 private: 14217 private:
14221 ApplyInterruptTest* test_; 14218 ApplyInterruptTest* test_;
14222 }; 14219 };
14223 14220
14224 void CollectGarbage() { 14221 void CollectGarbage() {
14225 block_->Wait(); 14222 block_.Wait();
14226 while (gc_during_apply_ < kRequiredGCs) { 14223 while (gc_during_apply_ < kRequiredGCs) {
14227 { 14224 {
14228 v8::Locker lock(CcTest::default_isolate()); 14225 v8::Locker lock(CcTest::default_isolate());
14229 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); 14226 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
14230 gc_count_++; 14227 gc_count_++;
14231 } 14228 }
14232 i::OS::Sleep(1); 14229 i::OS::Sleep(1);
14233 } 14230 }
14234 gc_success_ = true; 14231 gc_success_ = true;
14235 } 14232 }
14236 14233
14237 void LongRunningApply() { 14234 void LongRunningApply() {
14238 block_->Signal(); 14235 block_.Signal();
14239 int rounds = 0; 14236 int rounds = 0;
14240 while (gc_during_apply_ < kRequiredGCs) { 14237 while (gc_during_apply_ < kRequiredGCs) {
14241 int gc_before = gc_count_; 14238 int gc_before = gc_count_;
14242 { 14239 {
14243 const char* c_source = 14240 const char* c_source =
14244 "function do_very_little(bar) {" 14241 "function do_very_little(bar) {"
14245 " this.foo = bar;" 14242 " this.foo = bar;"
14246 "}" 14243 "}"
14247 "for (var i = 0; i < 100000; i++) {" 14244 "for (var i = 0; i < 100000; i++) {"
14248 " do_very_little.apply(this, ['bar']);" 14245 " do_very_little.apply(this, ['bar']);"
14249 "}"; 14246 "}";
14250 Local<String> source = String::New(c_source); 14247 Local<String> source = String::New(c_source);
14251 Local<Script> script = Script::Compile(source); 14248 Local<Script> script = Script::Compile(source);
14252 Local<Value> result = script->Run(); 14249 Local<Value> result = script->Run();
14253 // Check that no exception was thrown. 14250 // Check that no exception was thrown.
14254 CHECK(!result.IsEmpty()); 14251 CHECK(!result.IsEmpty());
14255 } 14252 }
14256 int gc_after = gc_count_; 14253 int gc_after = gc_count_;
14257 gc_during_apply_ += gc_after - gc_before; 14254 gc_during_apply_ += gc_after - gc_before;
14258 rounds++; 14255 rounds++;
14259 } 14256 }
14260 apply_success_ = true; 14257 apply_success_ = true;
14261 } 14258 }
14262 14259
14263 i::Semaphore* block_; 14260 i::Semaphore block_;
14264 int gc_count_; 14261 int gc_count_;
14265 int gc_during_apply_; 14262 int gc_during_apply_;
14266 bool apply_success_; 14263 bool apply_success_;
14267 bool gc_success_; 14264 bool gc_success_;
14268 }; 14265 };
14269 14266
14270 14267
14271 // Test that nothing bad happens if we get a preemption just when we were 14268 // Test that nothing bad happens if we get a preemption just when we were
14272 // about to do an apply(). 14269 // about to do an apply().
14273 TEST(ApplyInterruption) { 14270 TEST(ApplyInterruption) {
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
14466 v8::Local<v8::String> source = v8::String::NewExternal(&uc16_resource); 14463 v8::Local<v8::String> source = v8::String::NewExternal(&uc16_resource);
14467 v8::Script::Compile(source); 14464 v8::Script::Compile(source);
14468 i::DeleteArray(two_byte_string); 14465 i::DeleteArray(two_byte_string);
14469 } 14466 }
14470 } 14467 }
14471 14468
14472 14469
14473 class RegExpStringModificationTest { 14470 class RegExpStringModificationTest {
14474 public: 14471 public:
14475 RegExpStringModificationTest() 14472 RegExpStringModificationTest()
14476 : block_(i::OS::CreateSemaphore(0)), 14473 : block_(0),
14477 morphs_(0), 14474 morphs_(0),
14478 morphs_during_regexp_(0), 14475 morphs_during_regexp_(0),
14479 ascii_resource_(i::Vector<const char>("aaaaaaaaaaaaaab", 15)), 14476 ascii_resource_(i::Vector<const char>("aaaaaaaaaaaaaab", 15)),
14480 uc16_resource_(i::Vector<const uint16_t>(two_byte_content_, 15)) {} 14477 uc16_resource_(i::Vector<const uint16_t>(two_byte_content_, 15)) {}
14481 ~RegExpStringModificationTest() { delete block_; } 14478 ~RegExpStringModificationTest() {}
14482 void RunTest() { 14479 void RunTest() {
14483 i::Factory* factory = i::Isolate::Current()->factory(); 14480 i::Factory* factory = i::Isolate::Current()->factory();
14484 14481
14485 regexp_success_ = false; 14482 regexp_success_ = false;
14486 morph_success_ = false; 14483 morph_success_ = false;
14487 14484
14488 // Initialize the contents of two_byte_content_ to be a uc16 representation 14485 // Initialize the contents of two_byte_content_ to be a uc16 representation
14489 // of "aaaaaaaaaaaaaab". 14486 // of "aaaaaaaaaaaaaab".
14490 for (int i = 0; i < 14; i++) { 14487 for (int i = 0; i < 14; i++) {
14491 two_byte_content_[i] = 'a'; 14488 two_byte_content_[i] = 'a';
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
14528 explicit MorphThread(RegExpStringModificationTest* test) 14525 explicit MorphThread(RegExpStringModificationTest* test)
14529 : Thread("MorphThread"), test_(test) {} 14526 : Thread("MorphThread"), test_(test) {}
14530 virtual void Run() { 14527 virtual void Run() {
14531 test_->MorphString(); 14528 test_->MorphString();
14532 } 14529 }
14533 private: 14530 private:
14534 RegExpStringModificationTest* test_; 14531 RegExpStringModificationTest* test_;
14535 }; 14532 };
14536 14533
14537 void MorphString() { 14534 void MorphString() {
14538 block_->Wait(); 14535 block_.Wait();
14539 while (morphs_during_regexp_ < kRequiredModifications && 14536 while (morphs_during_regexp_ < kRequiredModifications &&
14540 morphs_ < kMaxModifications) { 14537 morphs_ < kMaxModifications) {
14541 { 14538 {
14542 v8::Locker lock(CcTest::default_isolate()); 14539 v8::Locker lock(CcTest::default_isolate());
14543 // Swap string between ascii and two-byte representation. 14540 // Swap string between ascii and two-byte representation.
14544 i::String* string = *input_; 14541 i::String* string = *input_;
14545 MorphAString(string, &ascii_resource_, &uc16_resource_); 14542 MorphAString(string, &ascii_resource_, &uc16_resource_);
14546 morphs_++; 14543 morphs_++;
14547 } 14544 }
14548 i::OS::Sleep(1); 14545 i::OS::Sleep(1);
14549 } 14546 }
14550 morph_success_ = true; 14547 morph_success_ = true;
14551 } 14548 }
14552 14549
14553 void LongRunningRegExp() { 14550 void LongRunningRegExp() {
14554 block_->Signal(); // Enable morphing thread on next preemption. 14551 block_.Signal(); // Enable morphing thread on next preemption.
14555 while (morphs_during_regexp_ < kRequiredModifications && 14552 while (morphs_during_regexp_ < kRequiredModifications &&
14556 morphs_ < kMaxModifications) { 14553 morphs_ < kMaxModifications) {
14557 int morphs_before = morphs_; 14554 int morphs_before = morphs_;
14558 { 14555 {
14559 v8::HandleScope scope(v8::Isolate::GetCurrent()); 14556 v8::HandleScope scope(v8::Isolate::GetCurrent());
14560 // Match 15-30 "a"'s against 14 and a "b". 14557 // Match 15-30 "a"'s against 14 and a "b".
14561 const char* c_source = 14558 const char* c_source =
14562 "/a?a?a?a?a?a?a?a?a?a?a?a?a?a?aaaaaaaaaaaaaaaa/" 14559 "/a?a?a?a?a?a?a?a?a?a?a?a?a?a?aaaaaaaaaaaaaaaa/"
14563 ".exec(input) === null"; 14560 ".exec(input) === null";
14564 Local<String> source = String::New(c_source); 14561 Local<String> source = String::New(c_source);
14565 Local<Script> script = Script::Compile(source); 14562 Local<Script> script = Script::Compile(source);
14566 Local<Value> result = script->Run(); 14563 Local<Value> result = script->Run();
14567 CHECK(result->IsTrue()); 14564 CHECK(result->IsTrue());
14568 } 14565 }
14569 int morphs_after = morphs_; 14566 int morphs_after = morphs_;
14570 morphs_during_regexp_ += morphs_after - morphs_before; 14567 morphs_during_regexp_ += morphs_after - morphs_before;
14571 } 14568 }
14572 regexp_success_ = true; 14569 regexp_success_ = true;
14573 } 14570 }
14574 14571
14575 i::uc16 two_byte_content_[15]; 14572 i::uc16 two_byte_content_[15];
14576 i::Semaphore* block_; 14573 i::Semaphore block_;
14577 int morphs_; 14574 int morphs_;
14578 int morphs_during_regexp_; 14575 int morphs_during_regexp_;
14579 bool regexp_success_; 14576 bool regexp_success_;
14580 bool morph_success_; 14577 bool morph_success_;
14581 i::Handle<i::String> input_; 14578 i::Handle<i::String> input_;
14582 AsciiVectorResource ascii_resource_; 14579 AsciiVectorResource ascii_resource_;
14583 UC16VectorResource uc16_resource_; 14580 UC16VectorResource uc16_resource_;
14584 }; 14581 };
14585 14582
14586 14583
(...skipping 5476 matching lines...) Expand 10 before | Expand all | Expand 10 after
20063 Local<Value> obj = v8::JSON::Parse(v8_str("42")); 20060 Local<Value> obj = v8::JSON::Parse(v8_str("42"));
20064 Handle<Object> global = context->Global(); 20061 Handle<Object> global = context->Global();
20065 global->Set(v8_str("obj"), obj); 20062 global->Set(v8_str("obj"), obj);
20066 ExpectString("JSON.stringify(obj)", "42"); 20063 ExpectString("JSON.stringify(obj)", "42");
20067 } 20064 }
20068 20065
20069 20066
20070 #if V8_OS_POSIX 20067 #if V8_OS_POSIX
20071 class ThreadInterruptTest { 20068 class ThreadInterruptTest {
20072 public: 20069 public:
20073 ThreadInterruptTest() : sem_(NULL), sem_value_(0) { } 20070 ThreadInterruptTest() : sem_(0), sem_value_(0) { }
20074 ~ThreadInterruptTest() { delete sem_; } 20071 ~ThreadInterruptTest() {}
20075 20072
20076 void RunTest() { 20073 void RunTest() {
20077 sem_ = i::OS::CreateSemaphore(0);
20078
20079 InterruptThread i_thread(this); 20074 InterruptThread i_thread(this);
20080 i_thread.Start(); 20075 i_thread.Start();
20081 20076
20082 sem_->Wait(); 20077 sem_.Wait();
20083 CHECK_EQ(kExpectedValue, sem_value_); 20078 CHECK_EQ(kExpectedValue, sem_value_);
20084 } 20079 }
20085 20080
20086 private: 20081 private:
20087 static const int kExpectedValue = 1; 20082 static const int kExpectedValue = 1;
20088 20083
20089 class InterruptThread : public i::Thread { 20084 class InterruptThread : public i::Thread {
20090 public: 20085 public:
20091 explicit InterruptThread(ThreadInterruptTest* test) 20086 explicit InterruptThread(ThreadInterruptTest* test)
20092 : Thread("InterruptThread"), test_(test) {} 20087 : Thread("InterruptThread"), test_(test) {}
(...skipping 10 matching lines...) Expand all
20103 sigaction(SIGCHLD, &action, NULL); 20098 sigaction(SIGCHLD, &action, NULL);
20104 20099
20105 // Send signal 20100 // Send signal
20106 kill(getpid(), SIGCHLD); 20101 kill(getpid(), SIGCHLD);
20107 20102
20108 // Ensure that if wait has returned because of error 20103 // Ensure that if wait has returned because of error
20109 i::OS::Sleep(100); 20104 i::OS::Sleep(100);
20110 20105
20111 // Set value and signal semaphore 20106 // Set value and signal semaphore
20112 test_->sem_value_ = 1; 20107 test_->sem_value_ = 1;
20113 test_->sem_->Signal(); 20108 test_->sem_.Signal();
20114 } 20109 }
20115 20110
20116 static void SignalHandler(int signal) { 20111 static void SignalHandler(int signal) {
20117 } 20112 }
20118 20113
20119 private: 20114 private:
20120 ThreadInterruptTest* test_; 20115 ThreadInterruptTest* test_;
20121 }; 20116 };
20122 20117
20123 i::Semaphore* sem_; 20118 i::Semaphore sem_;
20124 volatile int sem_value_; 20119 volatile int sem_value_;
20125 }; 20120 };
20126 20121
20127 20122
20128 THREADED_TEST(SemaphoreInterruption) { 20123 THREADED_TEST(SemaphoreInterruption) {
20129 ThreadInterruptTest().RunTest(); 20124 ThreadInterruptTest().RunTest();
20130 } 20125 }
20131 20126
20132 20127
20133 static bool NamedAccessAlwaysBlocked(Local<v8::Object> global, 20128 static bool NamedAccessAlwaysBlocked(Local<v8::Object> global,
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
20303 CheckCorrectThrow("%GetLocalPropertyNames(other, true)"); 20298 CheckCorrectThrow("%GetLocalPropertyNames(other, true)");
20304 CheckCorrectThrow("%DefineOrRedefineAccessorProperty(" 20299 CheckCorrectThrow("%DefineOrRedefineAccessorProperty("
20305 "other, 'x', null, null, 1)"); 20300 "other, 'x', null, null, 1)");
20306 20301
20307 // Reset the failed access check callback so it does not influence 20302 // Reset the failed access check callback so it does not influence
20308 // the other tests. 20303 // the other tests.
20309 v8::V8::SetFailedAccessCheckCallbackFunction(NULL); 20304 v8::V8::SetFailedAccessCheckCallbackFunction(NULL);
20310 } 20305 }
20311 20306
20312 #endif // V8_OS_POSIX 20307 #endif // V8_OS_POSIX
OLDNEW
« no previous file with comments | « test/cctest/cctest.gyp ('k') | test/cctest/test-circular-queue.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698