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

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

Issue 11970009: Make the Isolate parameter mandatory in Locker and Unlocker classes. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased. Added TODO. Created 7 years, 11 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-api.cc ('k') | test/cctest/test-thread-termination.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 518 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 public: 529 public:
530 LockUnlockLockThread(v8::Isolate* isolate, v8::Handle<v8::Context> context) 530 LockUnlockLockThread(v8::Isolate* isolate, v8::Handle<v8::Context> context)
531 : JoinableThread("LockUnlockLockThread"), 531 : JoinableThread("LockUnlockLockThread"),
532 isolate_(isolate), 532 isolate_(isolate),
533 context_(context) { 533 context_(context) {
534 } 534 }
535 535
536 virtual void Run() { 536 virtual void Run() {
537 v8::Locker lock1(isolate_); 537 v8::Locker lock1(isolate_);
538 CHECK(v8::Locker::IsLocked(isolate_)); 538 CHECK(v8::Locker::IsLocked(isolate_));
539 CHECK(!v8::Locker::IsLocked()); 539 CHECK(!v8::Locker::IsLocked(CcTest::default_isolate()));
540 { 540 {
541 v8::Isolate::Scope isolate_scope(isolate_); 541 v8::Isolate::Scope isolate_scope(isolate_);
542 v8::HandleScope handle_scope; 542 v8::HandleScope handle_scope;
543 v8::Context::Scope context_scope(context_); 543 v8::Context::Scope context_scope(context_);
544 CalcFibAndCheck(); 544 CalcFibAndCheck();
545 } 545 }
546 { 546 {
547 v8::Unlocker unlock1(isolate_); 547 v8::Unlocker unlock1(isolate_);
548 CHECK(!v8::Locker::IsLocked(isolate_)); 548 CHECK(!v8::Locker::IsLocked(isolate_));
549 CHECK(!v8::Locker::IsLocked()); 549 CHECK(!v8::Locker::IsLocked(CcTest::default_isolate()));
550 { 550 {
551 v8::Locker lock2(isolate_); 551 v8::Locker lock2(isolate_);
552 v8::Isolate::Scope isolate_scope(isolate_); 552 v8::Isolate::Scope isolate_scope(isolate_);
553 v8::HandleScope handle_scope; 553 v8::HandleScope handle_scope;
554 CHECK(v8::Locker::IsLocked(isolate_)); 554 CHECK(v8::Locker::IsLocked(isolate_));
555 CHECK(!v8::Locker::IsLocked()); 555 CHECK(!v8::Locker::IsLocked(CcTest::default_isolate()));
556 v8::Context::Scope context_scope(context_); 556 v8::Context::Scope context_scope(context_);
557 CalcFibAndCheck(); 557 CalcFibAndCheck();
558 } 558 }
559 } 559 }
560 } 560 }
561 561
562 private: 562 private:
563 v8::Isolate* isolate_; 563 v8::Isolate* isolate_;
564 v8::Persistent<v8::Context> context_; 564 v8::Persistent<v8::Context> context_;
565 }; 565 };
(...skipping 21 matching lines...) Expand all
587 } 587 }
588 588
589 class LockUnlockLockDefaultIsolateThread : public JoinableThread { 589 class LockUnlockLockDefaultIsolateThread : public JoinableThread {
590 public: 590 public:
591 explicit LockUnlockLockDefaultIsolateThread(v8::Handle<v8::Context> context) 591 explicit LockUnlockLockDefaultIsolateThread(v8::Handle<v8::Context> context)
592 : JoinableThread("LockUnlockLockDefaultIsolateThread"), 592 : JoinableThread("LockUnlockLockDefaultIsolateThread"),
593 context_(context) { 593 context_(context) {
594 } 594 }
595 595
596 virtual void Run() { 596 virtual void Run() {
597 v8::Locker lock1; 597 v8::Locker lock1(CcTest::default_isolate());
598 { 598 {
599 v8::HandleScope handle_scope; 599 v8::HandleScope handle_scope;
600 v8::Context::Scope context_scope(context_); 600 v8::Context::Scope context_scope(context_);
601 CalcFibAndCheck(); 601 CalcFibAndCheck();
602 } 602 }
603 { 603 {
604 v8::Unlocker unlock1; 604 v8::Unlocker unlock1(CcTest::default_isolate());
605 { 605 {
606 v8::Locker lock2; 606 v8::Locker lock2(CcTest::default_isolate());
607 v8::HandleScope handle_scope; 607 v8::HandleScope handle_scope;
608 v8::Context::Scope context_scope(context_); 608 v8::Context::Scope context_scope(context_);
609 CalcFibAndCheck(); 609 CalcFibAndCheck();
610 } 610 }
611 } 611 }
612 } 612 }
613 613
614 private: 614 private:
615 v8::Persistent<v8::Context> context_; 615 v8::Persistent<v8::Context> context_;
616 }; 616 };
617 617
618 // Locker inside an Unlocker inside a Locker for default isolate. 618 // Locker inside an Unlocker inside a Locker for default isolate.
619 TEST(LockUnlockLockDefaultIsolateMultithreaded) { 619 TEST(LockUnlockLockDefaultIsolateMultithreaded) {
620 #ifdef V8_TARGET_ARCH_MIPS 620 #ifdef V8_TARGET_ARCH_MIPS
621 const int kNThreads = 50; 621 const int kNThreads = 50;
622 #else 622 #else
623 const int kNThreads = 100; 623 const int kNThreads = 100;
624 #endif 624 #endif
625 Persistent<v8::Context> context; 625 Persistent<v8::Context> context;
626 { 626 {
627 v8::Locker locker_; 627 v8::Locker locker_(CcTest::default_isolate());
628 v8::HandleScope handle_scope; 628 v8::HandleScope handle_scope;
629 context = v8::Context::New(); 629 context = v8::Context::New();
630 } 630 }
631 i::List<JoinableThread*> threads(kNThreads); 631 i::List<JoinableThread*> threads(kNThreads);
632 for (int i = 0; i < kNThreads; i++) { 632 for (int i = 0; i < kNThreads; i++) {
633 threads.Add(new LockUnlockLockDefaultIsolateThread(context)); 633 threads.Add(new LockUnlockLockDefaultIsolateThread(context));
634 } 634 }
635 StartJoinAndDeleteThreads(threads); 635 StartJoinAndDeleteThreads(threads);
636 } 636 }
637 637
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 kSimpleExtensionSource)); 712 kSimpleExtensionSource));
713 const char* extension_names[] = { "test0", "test1", 713 const char* extension_names[] = { "test0", "test1",
714 "test2", "test3", "test4", 714 "test2", "test3", "test4",
715 "test5", "test6", "test7" }; 715 "test5", "test6", "test7" };
716 i::List<JoinableThread*> threads(kNThreads); 716 i::List<JoinableThread*> threads(kNThreads);
717 for (int i = 0; i < kNThreads; i++) { 717 for (int i = 0; i < kNThreads; i++) {
718 threads.Add(new IsolateGenesisThread(8, extension_names)); 718 threads.Add(new IsolateGenesisThread(8, extension_names));
719 } 719 }
720 StartJoinAndDeleteThreads(threads); 720 StartJoinAndDeleteThreads(threads);
721 } 721 }
OLDNEW
« no previous file with comments | « test/cctest/test-api.cc ('k') | test/cctest/test-thread-termination.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698