| OLD | NEW |
| 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 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 Loading... |
| 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 UNINITIALIZED_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 Loading... |
| 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 } |
| OLD | NEW |