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

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

Issue 146213004: A64: Synchronize with r16849. (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-liveedit.cc ('k') | test/cctest/test-log.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 2007-2011 the V8 project authors. All rights reserved. 1 // Copyright 2007-2011 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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 public: 176 public:
177 explicit IsolateLockingThreadWithLocalContext(v8::Isolate* isolate) 177 explicit IsolateLockingThreadWithLocalContext(v8::Isolate* isolate)
178 : JoinableThread("IsolateLockingThread"), 178 : JoinableThread("IsolateLockingThread"),
179 isolate_(isolate) { 179 isolate_(isolate) {
180 } 180 }
181 181
182 virtual void Run() { 182 virtual void Run() {
183 v8::Locker locker(isolate_); 183 v8::Locker locker(isolate_);
184 v8::Isolate::Scope isolate_scope(isolate_); 184 v8::Isolate::Scope isolate_scope(isolate_);
185 v8::HandleScope handle_scope(isolate_); 185 v8::HandleScope handle_scope(isolate_);
186 LocalContext local_context; 186 LocalContext local_context(isolate_);
187 CHECK_EQ(isolate_, v8::internal::Isolate::Current()); 187 CHECK_EQ(isolate_, v8::internal::Isolate::Current());
188 CalcFibAndCheck(); 188 CalcFibAndCheck();
189 } 189 }
190 private: 190 private:
191 v8::Isolate* isolate_; 191 v8::Isolate* isolate_;
192 }; 192 };
193 193
194 194
195 static void StartJoinAndDeleteThreads(const i::List<JoinableThread*>& threads) { 195 static void StartJoinAndDeleteThreads(const i::List<JoinableThread*>& threads) {
196 for (int i = 0; i < threads.length(); i++) { 196 for (int i = 0; i < threads.length(); i++) {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 260
261 class IsolateNestedLockingThread : public JoinableThread { 261 class IsolateNestedLockingThread : public JoinableThread {
262 public: 262 public:
263 explicit IsolateNestedLockingThread(v8::Isolate* isolate) 263 explicit IsolateNestedLockingThread(v8::Isolate* isolate)
264 : JoinableThread("IsolateNestedLocking"), isolate_(isolate) { 264 : JoinableThread("IsolateNestedLocking"), isolate_(isolate) {
265 } 265 }
266 virtual void Run() { 266 virtual void Run() {
267 v8::Locker lock(isolate_); 267 v8::Locker lock(isolate_);
268 v8::Isolate::Scope isolate_scope(isolate_); 268 v8::Isolate::Scope isolate_scope(isolate_);
269 v8::HandleScope handle_scope(isolate_); 269 v8::HandleScope handle_scope(isolate_);
270 LocalContext local_context; 270 LocalContext local_context(isolate_);
271 { 271 {
272 v8::Locker another_lock(isolate_); 272 v8::Locker another_lock(isolate_);
273 CalcFibAndCheck(); 273 CalcFibAndCheck();
274 } 274 }
275 { 275 {
276 v8::Locker another_lock(isolate_); 276 v8::Locker another_lock(isolate_);
277 CalcFibAndCheck(); 277 CalcFibAndCheck();
278 } 278 }
279 } 279 }
280 private: 280 private:
(...skipping 23 matching lines...) Expand all
304 SeparateIsolatesLocksNonexclusiveThread(v8::Isolate* isolate1, 304 SeparateIsolatesLocksNonexclusiveThread(v8::Isolate* isolate1,
305 v8::Isolate* isolate2) 305 v8::Isolate* isolate2)
306 : JoinableThread("SeparateIsolatesLocksNonexclusiveThread"), 306 : JoinableThread("SeparateIsolatesLocksNonexclusiveThread"),
307 isolate1_(isolate1), isolate2_(isolate2) { 307 isolate1_(isolate1), isolate2_(isolate2) {
308 } 308 }
309 309
310 virtual void Run() { 310 virtual void Run() {
311 v8::Locker lock(isolate1_); 311 v8::Locker lock(isolate1_);
312 v8::Isolate::Scope isolate_scope(isolate1_); 312 v8::Isolate::Scope isolate_scope(isolate1_);
313 v8::HandleScope handle_scope(isolate1_); 313 v8::HandleScope handle_scope(isolate1_);
314 LocalContext local_context; 314 LocalContext local_context(isolate1_);
315 315
316 IsolateLockingThreadWithLocalContext threadB(isolate2_); 316 IsolateLockingThreadWithLocalContext threadB(isolate2_);
317 threadB.Start(); 317 threadB.Start();
318 CalcFibAndCheck(); 318 CalcFibAndCheck();
319 threadB.Join(); 319 threadB.Join();
320 } 320 }
321 private: 321 private:
322 v8::Isolate* isolate1_; 322 v8::Isolate* isolate1_;
323 v8::Isolate* isolate2_; 323 v8::Isolate* isolate2_;
324 }; 324 };
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 public: 538 public:
539 LockUnlockLockThread(v8::Isolate* isolate, v8::Handle<v8::Context> context) 539 LockUnlockLockThread(v8::Isolate* isolate, v8::Handle<v8::Context> context)
540 : JoinableThread("LockUnlockLockThread"), 540 : JoinableThread("LockUnlockLockThread"),
541 isolate_(isolate), 541 isolate_(isolate),
542 context_(isolate, context) { 542 context_(isolate, context) {
543 } 543 }
544 544
545 virtual void Run() { 545 virtual void Run() {
546 v8::Locker lock1(isolate_); 546 v8::Locker lock1(isolate_);
547 CHECK(v8::Locker::IsLocked(isolate_)); 547 CHECK(v8::Locker::IsLocked(isolate_));
548 CHECK(!v8::Locker::IsLocked(CcTest::default_isolate())); 548 CHECK(!v8::Locker::IsLocked(CcTest::isolate()));
549 { 549 {
550 v8::Isolate::Scope isolate_scope(isolate_); 550 v8::Isolate::Scope isolate_scope(isolate_);
551 v8::HandleScope handle_scope(isolate_); 551 v8::HandleScope handle_scope(isolate_);
552 v8::Local<v8::Context> context = 552 v8::Local<v8::Context> context =
553 v8::Local<v8::Context>::New(isolate_, context_); 553 v8::Local<v8::Context>::New(isolate_, context_);
554 v8::Context::Scope context_scope(context); 554 v8::Context::Scope context_scope(context);
555 CalcFibAndCheck(); 555 CalcFibAndCheck();
556 } 556 }
557 { 557 {
558 v8::Unlocker unlock1(isolate_); 558 v8::Unlocker unlock1(isolate_);
559 CHECK(!v8::Locker::IsLocked(isolate_)); 559 CHECK(!v8::Locker::IsLocked(isolate_));
560 CHECK(!v8::Locker::IsLocked(CcTest::default_isolate())); 560 CHECK(!v8::Locker::IsLocked(CcTest::isolate()));
561 { 561 {
562 v8::Locker lock2(isolate_); 562 v8::Locker lock2(isolate_);
563 v8::Isolate::Scope isolate_scope(isolate_); 563 v8::Isolate::Scope isolate_scope(isolate_);
564 v8::HandleScope handle_scope(isolate_); 564 v8::HandleScope handle_scope(isolate_);
565 CHECK(v8::Locker::IsLocked(isolate_)); 565 CHECK(v8::Locker::IsLocked(isolate_));
566 CHECK(!v8::Locker::IsLocked(CcTest::default_isolate())); 566 CHECK(!v8::Locker::IsLocked(CcTest::isolate()));
567 v8::Local<v8::Context> context = 567 v8::Local<v8::Context> context =
568 v8::Local<v8::Context>::New(isolate_, context_); 568 v8::Local<v8::Context>::New(isolate_, context_);
569 v8::Context::Scope context_scope(context); 569 v8::Context::Scope context_scope(context);
570 CalcFibAndCheck(); 570 CalcFibAndCheck();
571 } 571 }
572 } 572 }
573 } 573 }
574 574
575 private: 575 private:
576 v8::Isolate* isolate_; 576 v8::Isolate* isolate_;
(...skipping 21 matching lines...) Expand all
598 } 598 }
599 } 599 }
600 StartJoinAndDeleteThreads(threads); 600 StartJoinAndDeleteThreads(threads);
601 isolate->Dispose(); 601 isolate->Dispose();
602 } 602 }
603 603
604 class LockUnlockLockDefaultIsolateThread : public JoinableThread { 604 class LockUnlockLockDefaultIsolateThread : public JoinableThread {
605 public: 605 public:
606 explicit LockUnlockLockDefaultIsolateThread(v8::Handle<v8::Context> context) 606 explicit LockUnlockLockDefaultIsolateThread(v8::Handle<v8::Context> context)
607 : JoinableThread("LockUnlockLockDefaultIsolateThread"), 607 : JoinableThread("LockUnlockLockDefaultIsolateThread"),
608 context_(CcTest::default_isolate(), context) {} 608 context_(CcTest::isolate(), context) {}
609 609
610 virtual void Run() { 610 virtual void Run() {
611 v8::Locker lock1(CcTest::default_isolate()); 611 v8::Locker lock1(CcTest::isolate());
612 { 612 {
613 v8::HandleScope handle_scope(CcTest::default_isolate()); 613 v8::HandleScope handle_scope(CcTest::isolate());
614 v8::Local<v8::Context> context = 614 v8::Local<v8::Context> context =
615 v8::Local<v8::Context>::New(CcTest::default_isolate(), context_); 615 v8::Local<v8::Context>::New(CcTest::isolate(), context_);
616 v8::Context::Scope context_scope(context); 616 v8::Context::Scope context_scope(context);
617 CalcFibAndCheck(); 617 CalcFibAndCheck();
618 } 618 }
619 { 619 {
620 v8::Unlocker unlock1(CcTest::default_isolate()); 620 v8::Unlocker unlock1(CcTest::isolate());
621 { 621 {
622 v8::Locker lock2(CcTest::default_isolate()); 622 v8::Locker lock2(CcTest::isolate());
623 v8::HandleScope handle_scope(CcTest::default_isolate()); 623 v8::HandleScope handle_scope(CcTest::isolate());
624 v8::Local<v8::Context> context = 624 v8::Local<v8::Context> context =
625 v8::Local<v8::Context>::New(CcTest::default_isolate(), context_); 625 v8::Local<v8::Context>::New(CcTest::isolate(), context_);
626 v8::Context::Scope context_scope(context); 626 v8::Context::Scope context_scope(context);
627 CalcFibAndCheck(); 627 CalcFibAndCheck();
628 } 628 }
629 } 629 }
630 } 630 }
631 631
632 private: 632 private:
633 v8::Persistent<v8::Context> context_; 633 v8::Persistent<v8::Context> context_;
634 }; 634 };
635 635
636 636
637 // Locker inside an Unlocker inside a Locker for default isolate. 637 // Locker inside an Unlocker inside a Locker for default isolate.
638 TEST(LockUnlockLockDefaultIsolateMultithreaded) { 638 UNINITIALIZED_TEST(LockUnlockLockDefaultIsolateMultithreaded) {
639 #if V8_TARGET_ARCH_MIPS 639 #if V8_TARGET_ARCH_MIPS
640 const int kNThreads = 50; 640 const int kNThreads = 50;
641 #else 641 #else
642 const int kNThreads = 100; 642 const int kNThreads = 100;
643 #endif 643 #endif
644 Local<v8::Context> context; 644 Local<v8::Context> context;
645 i::List<JoinableThread*> threads(kNThreads); 645 i::List<JoinableThread*> threads(kNThreads);
646 { 646 {
647 v8::Locker locker_(CcTest::default_isolate()); 647 v8::Locker locker_(CcTest::isolate());
648 v8::HandleScope handle_scope(CcTest::default_isolate()); 648 v8::HandleScope handle_scope(CcTest::isolate());
649 context = v8::Context::New(CcTest::default_isolate()); 649 context = v8::Context::New(CcTest::isolate());
650 for (int i = 0; i < kNThreads; i++) { 650 for (int i = 0; i < kNThreads; i++) {
651 threads.Add(new LockUnlockLockDefaultIsolateThread(context)); 651 threads.Add(new LockUnlockLockDefaultIsolateThread(context));
652 } 652 }
653 } 653 }
654 StartJoinAndDeleteThreads(threads); 654 StartJoinAndDeleteThreads(threads);
655 } 655 }
656 656
657 657
658 TEST(Regress1433) { 658 TEST(Regress1433) {
659 for (int i = 0; i < 10; i++) { 659 for (int i = 0; i < 10; i++) {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 kSimpleExtensionSource)); 731 kSimpleExtensionSource));
732 const char* extension_names[] = { "test0", "test1", 732 const char* extension_names[] = { "test0", "test1",
733 "test2", "test3", "test4", 733 "test2", "test3", "test4",
734 "test5", "test6", "test7" }; 734 "test5", "test6", "test7" };
735 i::List<JoinableThread*> threads(kNThreads); 735 i::List<JoinableThread*> threads(kNThreads);
736 for (int i = 0; i < kNThreads; i++) { 736 for (int i = 0; i < kNThreads; i++) {
737 threads.Add(new IsolateGenesisThread(8, extension_names)); 737 threads.Add(new IsolateGenesisThread(8, extension_names));
738 } 738 }
739 StartJoinAndDeleteThreads(threads); 739 StartJoinAndDeleteThreads(threads);
740 } 740 }
OLDNEW
« no previous file with comments | « test/cctest/test-liveedit.cc ('k') | test/cctest/test-log.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698