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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 using ::v8::Value; | 54 using ::v8::Value; |
55 using ::v8::V8; | 55 using ::v8::V8; |
56 | 56 |
57 | 57 |
58 // Migrating an isolate | 58 // Migrating an isolate |
59 class KangarooThread : public v8::internal::Thread { | 59 class KangarooThread : public v8::internal::Thread { |
60 public: | 60 public: |
61 KangarooThread(v8::Isolate* isolate, | 61 KangarooThread(v8::Isolate* isolate, |
62 v8::Handle<v8::Context> context) | 62 v8::Handle<v8::Context> context) |
63 : Thread("KangarooThread"), | 63 : Thread("KangarooThread"), |
64 isolate_(isolate), context_(context) { | 64 isolate_(isolate), |
| 65 context_(v8::Persistent<v8::Context>::New(isolate, context)) { |
| 66 } |
| 67 |
| 68 virtual ~KangarooThread() { |
| 69 context_.Dispose(isolate_); |
| 70 context_.Clear(); |
65 } | 71 } |
66 | 72 |
67 void Run() { | 73 void Run() { |
68 { | 74 { |
69 v8::Locker locker(isolate_); | 75 v8::Locker locker(isolate_); |
70 v8::Isolate::Scope isolate_scope(isolate_); | 76 v8::Isolate::Scope isolate_scope(isolate_); |
71 CHECK_EQ(isolate_, v8::internal::Isolate::Current()); | 77 CHECK_EQ(isolate_, v8::internal::Isolate::Current()); |
72 v8::HandleScope scope(isolate_); | 78 v8::HandleScope scope(isolate_); |
73 v8::Context::Scope context_scope(context_); | 79 v8::Context::Scope context_scope(context_); |
74 Local<Value> v = CompileRun("getValue()"); | 80 Local<Value> v = CompileRun("getValue()"); |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 isolate2->Dispose(); | 341 isolate2->Dispose(); |
336 isolate1->Dispose(); | 342 isolate1->Dispose(); |
337 } | 343 } |
338 | 344 |
339 class LockIsolateAndCalculateFibSharedContextThread : public JoinableThread { | 345 class LockIsolateAndCalculateFibSharedContextThread : public JoinableThread { |
340 public: | 346 public: |
341 explicit LockIsolateAndCalculateFibSharedContextThread( | 347 explicit LockIsolateAndCalculateFibSharedContextThread( |
342 v8::Isolate* isolate, v8::Handle<v8::Context> context) | 348 v8::Isolate* isolate, v8::Handle<v8::Context> context) |
343 : JoinableThread("LockIsolateAndCalculateFibThread"), | 349 : JoinableThread("LockIsolateAndCalculateFibThread"), |
344 isolate_(isolate), | 350 isolate_(isolate), |
345 context_(context) { | 351 context_(v8::Persistent<v8::Context>::New(isolate, context)) { |
| 352 } |
| 353 virtual ~LockIsolateAndCalculateFibSharedContextThread() { |
| 354 context_.Dispose(isolate_); |
| 355 context_.Clear(); |
346 } | 356 } |
347 | 357 |
348 virtual void Run() { | 358 virtual void Run() { |
349 v8::Locker lock(isolate_); | 359 v8::Locker lock(isolate_); |
350 v8::Isolate::Scope isolate_scope(isolate_); | 360 v8::Isolate::Scope isolate_scope(isolate_); |
351 HandleScope handle_scope(isolate_); | 361 HandleScope handle_scope(isolate_); |
352 v8::Context::Scope context_scope(context_); | 362 v8::Context::Scope context_scope(context_); |
353 CalcFibAndCheck(); | 363 CalcFibAndCheck(); |
354 } | 364 } |
355 private: | 365 private: |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 thread.Join(); | 534 thread.Join(); |
525 isolate2->Dispose(); | 535 isolate2->Dispose(); |
526 isolate1->Dispose(); | 536 isolate1->Dispose(); |
527 } | 537 } |
528 | 538 |
529 class LockUnlockLockThread : public JoinableThread { | 539 class LockUnlockLockThread : public JoinableThread { |
530 public: | 540 public: |
531 LockUnlockLockThread(v8::Isolate* isolate, v8::Handle<v8::Context> context) | 541 LockUnlockLockThread(v8::Isolate* isolate, v8::Handle<v8::Context> context) |
532 : JoinableThread("LockUnlockLockThread"), | 542 : JoinableThread("LockUnlockLockThread"), |
533 isolate_(isolate), | 543 isolate_(isolate), |
534 context_(context) { | 544 context_(v8::Persistent<v8::Context>::New(isolate, context)) { |
| 545 } |
| 546 |
| 547 virtual ~LockUnlockLockThread() { |
| 548 context_.Dispose(isolate_); |
| 549 context_.Clear(); |
535 } | 550 } |
536 | 551 |
537 virtual void Run() { | 552 virtual void Run() { |
538 v8::Locker lock1(isolate_); | 553 v8::Locker lock1(isolate_); |
539 CHECK(v8::Locker::IsLocked(isolate_)); | 554 CHECK(v8::Locker::IsLocked(isolate_)); |
540 CHECK(!v8::Locker::IsLocked(CcTest::default_isolate())); | 555 CHECK(!v8::Locker::IsLocked(CcTest::default_isolate())); |
541 { | 556 { |
542 v8::Isolate::Scope isolate_scope(isolate_); | 557 v8::Isolate::Scope isolate_scope(isolate_); |
543 v8::HandleScope handle_scope(isolate_); | 558 v8::HandleScope handle_scope(isolate_); |
544 v8::Context::Scope context_scope(context_); | 559 v8::Context::Scope context_scope(context_); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 for (int i = 0; i < kNThreads; i++) { | 599 for (int i = 0; i < kNThreads; i++) { |
585 threads.Add(new LockUnlockLockThread(isolate, context)); | 600 threads.Add(new LockUnlockLockThread(isolate, context)); |
586 } | 601 } |
587 StartJoinAndDeleteThreads(threads); | 602 StartJoinAndDeleteThreads(threads); |
588 isolate->Dispose(); | 603 isolate->Dispose(); |
589 } | 604 } |
590 | 605 |
591 class LockUnlockLockDefaultIsolateThread : public JoinableThread { | 606 class LockUnlockLockDefaultIsolateThread : public JoinableThread { |
592 public: | 607 public: |
593 explicit LockUnlockLockDefaultIsolateThread(v8::Handle<v8::Context> context) | 608 explicit LockUnlockLockDefaultIsolateThread(v8::Handle<v8::Context> context) |
594 : JoinableThread("LockUnlockLockDefaultIsolateThread"), | 609 : JoinableThread("LockUnlockLockDefaultIsolateThread"), |
595 context_(context) { | 610 context_(v8::Persistent<v8::Context>::New(CcTest::default_isolate(), |
| 611 context)) { |
| 612 } |
| 613 |
| 614 virtual ~LockUnlockLockDefaultIsolateThread() { |
| 615 context_.Dispose(CcTest::default_isolate()); |
| 616 context_.Clear(); |
596 } | 617 } |
597 | 618 |
598 virtual void Run() { | 619 virtual void Run() { |
599 v8::Locker lock1(CcTest::default_isolate()); | 620 v8::Locker lock1(CcTest::default_isolate()); |
600 { | 621 { |
601 v8::HandleScope handle_scope(CcTest::default_isolate()); | 622 v8::HandleScope handle_scope(CcTest::default_isolate()); |
602 v8::Context::Scope context_scope(context_); | 623 v8::Context::Scope context_scope(context_); |
603 CalcFibAndCheck(); | 624 CalcFibAndCheck(); |
604 } | 625 } |
605 { | 626 { |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
714 kSimpleExtensionSource)); | 735 kSimpleExtensionSource)); |
715 const char* extension_names[] = { "test0", "test1", | 736 const char* extension_names[] = { "test0", "test1", |
716 "test2", "test3", "test4", | 737 "test2", "test3", "test4", |
717 "test5", "test6", "test7" }; | 738 "test5", "test6", "test7" }; |
718 i::List<JoinableThread*> threads(kNThreads); | 739 i::List<JoinableThread*> threads(kNThreads); |
719 for (int i = 0; i < kNThreads; i++) { | 740 for (int i = 0; i < kNThreads; i++) { |
720 threads.Add(new IsolateGenesisThread(8, extension_names)); | 741 threads.Add(new IsolateGenesisThread(8, extension_names)); |
721 } | 742 } |
722 StartJoinAndDeleteThreads(threads); | 743 StartJoinAndDeleteThreads(threads); |
723 } | 744 } |
OLD | NEW |