| 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 |
| 11 // with the distribution. | 11 // with the distribution. |
| 12 // * Neither the name of Google Inc. nor the names of its | 12 // * Neither the name of Google Inc. nor the names of its |
| 13 // contributors may be used to endorse or promote products derived | 13 // contributors may be used to endorse or promote products derived |
| 14 // from this software without specific prior written permission. | 14 // from this software without specific prior written permission. |
| 15 // | 15 // |
| 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #include <limits.h> | 28 #include <limits.h> |
| 29 | 29 |
| 30 // TODO(dcarney): remove |
| 31 #define V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT |
| 32 |
| 30 #include "v8.h" | 33 #include "v8.h" |
| 31 | 34 |
| 32 #include "api.h" | 35 #include "api.h" |
| 33 #include "isolate.h" | 36 #include "isolate.h" |
| 34 #include "compilation-cache.h" | 37 #include "compilation-cache.h" |
| 35 #include "execution.h" | 38 #include "execution.h" |
| 36 #include "smart-pointers.h" | 39 #include "smart-pointers.h" |
| 37 #include "snapshot.h" | 40 #include "snapshot.h" |
| 38 #include "platform.h" | 41 #include "platform.h" |
| 39 #include "utils.h" | 42 #include "utils.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 63 : Thread("KangarooThread"), | 66 : Thread("KangarooThread"), |
| 64 isolate_(isolate), | 67 isolate_(isolate), |
| 65 context_(isolate, context) {} | 68 context_(isolate, context) {} |
| 66 | 69 |
| 67 void Run() { | 70 void Run() { |
| 68 { | 71 { |
| 69 v8::Locker locker(isolate_); | 72 v8::Locker locker(isolate_); |
| 70 v8::Isolate::Scope isolate_scope(isolate_); | 73 v8::Isolate::Scope isolate_scope(isolate_); |
| 71 CHECK_EQ(isolate_, v8::internal::Isolate::Current()); | 74 CHECK_EQ(isolate_, v8::internal::Isolate::Current()); |
| 72 v8::HandleScope scope(isolate_); | 75 v8::HandleScope scope(isolate_); |
| 73 v8::Context::Scope context_scope(context_); | 76 v8::Context::Scope context_scope(isolate_, context_); |
| 74 Local<Value> v = CompileRun("getValue()"); | 77 Local<Value> v = CompileRun("getValue()"); |
| 75 CHECK(v->IsNumber()); | 78 CHECK(v->IsNumber()); |
| 76 CHECK_EQ(30, static_cast<int>(v->NumberValue())); | 79 CHECK_EQ(30, static_cast<int>(v->NumberValue())); |
| 77 } | 80 } |
| 78 { | 81 { |
| 79 v8::Locker locker(isolate_); | 82 v8::Locker locker(isolate_); |
| 80 v8::Isolate::Scope isolate_scope(isolate_); | 83 v8::Isolate::Scope isolate_scope(isolate_); |
| 81 v8::Context::Scope context_scope(context_); | |
| 82 v8::HandleScope scope(isolate_); | 84 v8::HandleScope scope(isolate_); |
| 85 v8::Context::Scope context_scope(isolate_, context_); |
| 83 Local<Value> v = CompileRun("getValue()"); | 86 Local<Value> v = CompileRun("getValue()"); |
| 84 CHECK(v->IsNumber()); | 87 CHECK(v->IsNumber()); |
| 85 CHECK_EQ(30, static_cast<int>(v->NumberValue())); | 88 CHECK_EQ(30, static_cast<int>(v->NumberValue())); |
| 86 } | 89 } |
| 87 isolate_->Dispose(); | 90 isolate_->Dispose(); |
| 88 } | 91 } |
| 89 | 92 |
| 90 private: | 93 private: |
| 91 v8::Isolate* isolate_; | 94 v8::Isolate* isolate_; |
| 92 Persistent<v8::Context> context_; | 95 Persistent<v8::Context> context_; |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 public: | 224 public: |
| 222 explicit IsolateNonlockingThread() | 225 explicit IsolateNonlockingThread() |
| 223 : JoinableThread("IsolateNonlockingThread") { | 226 : JoinableThread("IsolateNonlockingThread") { |
| 224 } | 227 } |
| 225 | 228 |
| 226 virtual void Run() { | 229 virtual void Run() { |
| 227 v8::Isolate* isolate = v8::Isolate::New(); | 230 v8::Isolate* isolate = v8::Isolate::New(); |
| 228 { | 231 { |
| 229 v8::Isolate::Scope isolate_scope(isolate); | 232 v8::Isolate::Scope isolate_scope(isolate); |
| 230 v8::HandleScope handle_scope(isolate); | 233 v8::HandleScope handle_scope(isolate); |
| 231 v8::Handle<v8::Context> context = v8::Context::New(); | 234 v8::Handle<v8::Context> context = v8::Context::New(isolate); |
| 232 v8::Context::Scope context_scope(context); | 235 v8::Context::Scope context_scope(context); |
| 233 CHECK_EQ(isolate, v8::internal::Isolate::Current()); | 236 CHECK_EQ(isolate, v8::internal::Isolate::Current()); |
| 234 CalcFibAndCheck(); | 237 CalcFibAndCheck(); |
| 235 } | 238 } |
| 236 isolate->Dispose(); | 239 isolate->Dispose(); |
| 237 } | 240 } |
| 238 private: | 241 private: |
| 239 }; | 242 }; |
| 240 | 243 |
| 241 // Run many threads each accessing its own isolate without locking | 244 // Run many threads each accessing its own isolate without locking |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 v8::Isolate* isolate, v8::Handle<v8::Context> context) | 345 v8::Isolate* isolate, v8::Handle<v8::Context> context) |
| 343 : JoinableThread("LockIsolateAndCalculateFibThread"), | 346 : JoinableThread("LockIsolateAndCalculateFibThread"), |
| 344 isolate_(isolate), | 347 isolate_(isolate), |
| 345 context_(isolate, context) { | 348 context_(isolate, context) { |
| 346 } | 349 } |
| 347 | 350 |
| 348 virtual void Run() { | 351 virtual void Run() { |
| 349 v8::Locker lock(isolate_); | 352 v8::Locker lock(isolate_); |
| 350 v8::Isolate::Scope isolate_scope(isolate_); | 353 v8::Isolate::Scope isolate_scope(isolate_); |
| 351 HandleScope handle_scope(isolate_); | 354 HandleScope handle_scope(isolate_); |
| 352 v8::Context::Scope context_scope(context_); | 355 v8::Context::Scope context_scope(isolate_, context_); |
| 353 CalcFibAndCheck(); | 356 CalcFibAndCheck(); |
| 354 } | 357 } |
| 355 private: | 358 private: |
| 356 v8::Isolate* isolate_; | 359 v8::Isolate* isolate_; |
| 357 Persistent<v8::Context> context_; | 360 Persistent<v8::Context> context_; |
| 358 }; | 361 }; |
| 359 | 362 |
| 360 class LockerUnlockerThread : public JoinableThread { | 363 class LockerUnlockerThread : public JoinableThread { |
| 361 public: | 364 public: |
| 362 explicit LockerUnlockerThread(v8::Isolate* isolate) | 365 explicit LockerUnlockerThread(v8::Isolate* isolate) |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 class LockAndUnlockDifferentIsolatesThread : public JoinableThread { | 466 class LockAndUnlockDifferentIsolatesThread : public JoinableThread { |
| 464 public: | 467 public: |
| 465 LockAndUnlockDifferentIsolatesThread(v8::Isolate* isolate1, | 468 LockAndUnlockDifferentIsolatesThread(v8::Isolate* isolate1, |
| 466 v8::Isolate* isolate2) | 469 v8::Isolate* isolate2) |
| 467 : JoinableThread("LockAndUnlockDifferentIsolatesThread"), | 470 : JoinableThread("LockAndUnlockDifferentIsolatesThread"), |
| 468 isolate1_(isolate1), | 471 isolate1_(isolate1), |
| 469 isolate2_(isolate2) { | 472 isolate2_(isolate2) { |
| 470 } | 473 } |
| 471 | 474 |
| 472 virtual void Run() { | 475 virtual void Run() { |
| 473 Persistent<v8::Context> context1; | 476 v8::Handle<v8::Context> context1; |
| 474 Persistent<v8::Context> context2; | 477 v8::Handle<v8::Context> context2; |
| 475 v8::Locker lock1(isolate1_); | 478 v8::Locker lock1(isolate1_); |
| 476 CHECK(v8::Locker::IsLocked(isolate1_)); | 479 CHECK(v8::Locker::IsLocked(isolate1_)); |
| 477 CHECK(!v8::Locker::IsLocked(isolate2_)); | 480 CHECK(!v8::Locker::IsLocked(isolate2_)); |
| 478 { | 481 { |
| 479 v8::Isolate::Scope isolate_scope(isolate1_); | 482 v8::Isolate::Scope isolate_scope(isolate1_); |
| 480 v8::HandleScope handle_scope(isolate1_); | 483 v8::HandleScope handle_scope(isolate1_); |
| 481 context1 = v8::Context::New(); | 484 context1 = v8::Context::New(isolate1_); |
| 482 { | 485 { |
| 483 v8::Context::Scope context_scope(context1); | 486 v8::Context::Scope context_scope(context1); |
| 484 CalcFibAndCheck(); | 487 CalcFibAndCheck(); |
| 485 } | 488 } |
| 486 } | 489 } |
| 487 v8::Locker lock2(isolate2_); | 490 v8::Locker lock2(isolate2_); |
| 488 CHECK(v8::Locker::IsLocked(isolate1_)); | 491 CHECK(v8::Locker::IsLocked(isolate1_)); |
| 489 CHECK(v8::Locker::IsLocked(isolate2_)); | 492 CHECK(v8::Locker::IsLocked(isolate2_)); |
| 490 { | 493 { |
| 491 v8::Isolate::Scope isolate_scope(isolate2_); | 494 v8::Isolate::Scope isolate_scope(isolate2_); |
| 492 v8::HandleScope handle_scope(isolate2_); | 495 v8::HandleScope handle_scope(isolate2_); |
| 493 context2 = v8::Context::New(); | 496 context2 = v8::Context::New(isolate2_); |
| 494 { | 497 { |
| 495 v8::Context::Scope context_scope(context2); | 498 v8::Context::Scope context_scope(context2); |
| 496 CalcFibAndCheck(); | 499 CalcFibAndCheck(); |
| 497 } | 500 } |
| 498 } | 501 } |
| 499 { | 502 { |
| 500 i::SmartPointer<LockIsolateAndCalculateFibSharedContextThread> thread; | 503 i::SmartPointer<LockIsolateAndCalculateFibSharedContextThread> thread; |
| 501 { | 504 { |
| 502 CHECK(v8::Locker::IsLocked(isolate1_)); | 505 CHECK(v8::Locker::IsLocked(isolate1_)); |
| 503 v8::Isolate::Scope isolate_scope(isolate1_); | 506 v8::Isolate::Scope isolate_scope(isolate1_); |
| 504 v8::HandleScope handle_scope(isolate1_); | 507 v8::HandleScope handle_scope(isolate1_); |
| 505 thread.Reset(new LockIsolateAndCalculateFibSharedContextThread( | 508 thread.Reset(new LockIsolateAndCalculateFibSharedContextThread( |
| 506 isolate1_, v8::Local<v8::Context>::New(isolate1_, context1))); | 509 isolate1_, context1)); |
| 507 } | 510 } |
| 508 v8::Unlocker unlock1(isolate1_); | 511 v8::Unlocker unlock1(isolate1_); |
| 509 CHECK(!v8::Locker::IsLocked(isolate1_)); | 512 CHECK(!v8::Locker::IsLocked(isolate1_)); |
| 510 CHECK(v8::Locker::IsLocked(isolate2_)); | 513 CHECK(v8::Locker::IsLocked(isolate2_)); |
| 511 v8::Isolate::Scope isolate_scope(isolate2_); | 514 v8::Isolate::Scope isolate_scope(isolate2_); |
| 512 v8::HandleScope handle_scope(isolate2_); | 515 v8::HandleScope handle_scope(isolate2_); |
| 513 v8::Context::Scope context_scope(context2); | 516 v8::Context::Scope context_scope(context2); |
| 514 thread->Start(); | 517 thread->Start(); |
| 515 CalcFibAndCheck(); | 518 CalcFibAndCheck(); |
| 516 thread->Join(); | 519 thread->Join(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 528 v8::Isolate* isolate2 = v8::Isolate::New(); | 531 v8::Isolate* isolate2 = v8::Isolate::New(); |
| 529 LockAndUnlockDifferentIsolatesThread thread(isolate1, isolate2); | 532 LockAndUnlockDifferentIsolatesThread thread(isolate1, isolate2); |
| 530 thread.Start(); | 533 thread.Start(); |
| 531 thread.Join(); | 534 thread.Join(); |
| 532 isolate2->Dispose(); | 535 isolate2->Dispose(); |
| 533 isolate1->Dispose(); | 536 isolate1->Dispose(); |
| 534 } | 537 } |
| 535 | 538 |
| 536 class LockUnlockLockThread : public JoinableThread { | 539 class LockUnlockLockThread : public JoinableThread { |
| 537 public: | 540 public: |
| 538 LockUnlockLockThread(v8::Isolate* isolate, v8::Local<v8::Context> context) | 541 LockUnlockLockThread(v8::Isolate* isolate, v8::Handle<v8::Context> context) |
| 539 : JoinableThread("LockUnlockLockThread"), | 542 : JoinableThread("LockUnlockLockThread"), |
| 540 isolate_(isolate), | 543 isolate_(isolate), |
| 541 context_(isolate, context) { | 544 context_(isolate, context) { |
| 542 } | 545 } |
| 543 | 546 |
| 544 virtual void Run() { | 547 virtual void Run() { |
| 545 v8::Locker lock1(isolate_); | 548 v8::Locker lock1(isolate_); |
| 546 CHECK(v8::Locker::IsLocked(isolate_)); | 549 CHECK(v8::Locker::IsLocked(isolate_)); |
| 547 CHECK(!v8::Locker::IsLocked(CcTest::default_isolate())); | 550 CHECK(!v8::Locker::IsLocked(CcTest::default_isolate())); |
| 548 { | 551 { |
| 549 v8::Isolate::Scope isolate_scope(isolate_); | 552 v8::Isolate::Scope isolate_scope(isolate_); |
| 550 v8::HandleScope handle_scope(isolate_); | 553 v8::HandleScope handle_scope(isolate_); |
| 551 v8::Context::Scope context_scope(context_); | 554 v8::Context::Scope context_scope(isolate_, context_); |
| 552 CalcFibAndCheck(); | 555 CalcFibAndCheck(); |
| 553 } | 556 } |
| 554 { | 557 { |
| 555 v8::Unlocker unlock1(isolate_); | 558 v8::Unlocker unlock1(isolate_); |
| 556 CHECK(!v8::Locker::IsLocked(isolate_)); | 559 CHECK(!v8::Locker::IsLocked(isolate_)); |
| 557 CHECK(!v8::Locker::IsLocked(CcTest::default_isolate())); | 560 CHECK(!v8::Locker::IsLocked(CcTest::default_isolate())); |
| 558 { | 561 { |
| 559 v8::Locker lock2(isolate_); | 562 v8::Locker lock2(isolate_); |
| 560 v8::Isolate::Scope isolate_scope(isolate_); | 563 v8::Isolate::Scope isolate_scope(isolate_); |
| 561 v8::HandleScope handle_scope(isolate_); | 564 v8::HandleScope handle_scope(isolate_); |
| 562 CHECK(v8::Locker::IsLocked(isolate_)); | 565 CHECK(v8::Locker::IsLocked(isolate_)); |
| 563 CHECK(!v8::Locker::IsLocked(CcTest::default_isolate())); | 566 CHECK(!v8::Locker::IsLocked(CcTest::default_isolate())); |
| 564 v8::Context::Scope context_scope(context_); | 567 v8::Context::Scope context_scope(isolate_, context_); |
| 565 CalcFibAndCheck(); | 568 CalcFibAndCheck(); |
| 566 } | 569 } |
| 567 } | 570 } |
| 568 } | 571 } |
| 569 | 572 |
| 570 private: | 573 private: |
| 571 v8::Isolate* isolate_; | 574 v8::Isolate* isolate_; |
| 572 v8::Persistent<v8::Context> context_; | 575 v8::Persistent<v8::Context> context_; |
| 573 }; | 576 }; |
| 574 | 577 |
| 575 // Locker inside an Unlocker inside a Locker. | 578 // Locker inside an Unlocker inside a Locker. |
| 576 TEST(LockUnlockLockMultithreaded) { | 579 TEST(LockUnlockLockMultithreaded) { |
| 577 #ifdef V8_TARGET_ARCH_MIPS | 580 #ifdef V8_TARGET_ARCH_MIPS |
| 578 const int kNThreads = 50; | 581 const int kNThreads = 50; |
| 579 #else | 582 #else |
| 580 const int kNThreads = 100; | 583 const int kNThreads = 100; |
| 581 #endif | 584 #endif |
| 582 v8::Isolate* isolate = v8::Isolate::New(); | 585 v8::Isolate* isolate = v8::Isolate::New(); |
| 583 Persistent<v8::Context> context; | |
| 584 i::List<JoinableThread*> threads(kNThreads); | 586 i::List<JoinableThread*> threads(kNThreads); |
| 585 { | 587 { |
| 586 v8::Locker locker_(isolate); | 588 v8::Locker locker_(isolate); |
| 587 v8::Isolate::Scope isolate_scope(isolate); | 589 v8::Isolate::Scope isolate_scope(isolate); |
| 588 v8::HandleScope handle_scope(isolate); | 590 v8::HandleScope handle_scope(isolate); |
| 589 context = v8::Context::New(); | 591 v8::Handle<v8::Context> context = v8::Context::New(isolate); |
| 590 for (int i = 0; i < kNThreads; i++) { | 592 for (int i = 0; i < kNThreads; i++) { |
| 591 threads.Add(new LockUnlockLockThread( | 593 threads.Add(new LockUnlockLockThread( |
| 592 isolate, v8::Local<v8::Context>::New(isolate, context))); | 594 isolate, context)); |
| 593 } | 595 } |
| 594 } | 596 } |
| 595 StartJoinAndDeleteThreads(threads); | 597 StartJoinAndDeleteThreads(threads); |
| 596 isolate->Dispose(); | 598 isolate->Dispose(); |
| 597 } | 599 } |
| 598 | 600 |
| 599 class LockUnlockLockDefaultIsolateThread : public JoinableThread { | 601 class LockUnlockLockDefaultIsolateThread : public JoinableThread { |
| 600 public: | 602 public: |
| 601 explicit LockUnlockLockDefaultIsolateThread(v8::Local<v8::Context> context) | 603 explicit LockUnlockLockDefaultIsolateThread(v8::Handle<v8::Context> context) |
| 602 : JoinableThread("LockUnlockLockDefaultIsolateThread"), | 604 : JoinableThread("LockUnlockLockDefaultIsolateThread"), |
| 603 context_(CcTest::default_isolate(), context) {} | 605 context_(CcTest::default_isolate(), context) {} |
| 604 | 606 |
| 605 virtual void Run() { | 607 virtual void Run() { |
| 606 v8::Locker lock1(CcTest::default_isolate()); | 608 v8::Locker lock1(CcTest::default_isolate()); |
| 607 { | 609 { |
| 608 v8::HandleScope handle_scope(CcTest::default_isolate()); | 610 v8::HandleScope handle_scope(CcTest::default_isolate()); |
| 609 v8::Context::Scope context_scope(context_); | 611 v8::Context::Scope context_scope(CcTest::default_isolate(), context_); |
| 610 CalcFibAndCheck(); | 612 CalcFibAndCheck(); |
| 611 } | 613 } |
| 612 { | 614 { |
| 613 v8::Unlocker unlock1(CcTest::default_isolate()); | 615 v8::Unlocker unlock1(CcTest::default_isolate()); |
| 614 { | 616 { |
| 615 v8::Locker lock2(CcTest::default_isolate()); | 617 v8::Locker lock2(CcTest::default_isolate()); |
| 616 v8::HandleScope handle_scope(CcTest::default_isolate()); | 618 v8::HandleScope handle_scope(CcTest::default_isolate()); |
| 617 v8::Context::Scope context_scope(context_); | 619 v8::Context::Scope context_scope(CcTest::default_isolate(), context_); |
| 618 CalcFibAndCheck(); | 620 CalcFibAndCheck(); |
| 619 } | 621 } |
| 620 } | 622 } |
| 621 } | 623 } |
| 622 | 624 |
| 623 private: | 625 private: |
| 624 v8::Persistent<v8::Context> context_; | 626 v8::Persistent<v8::Context> context_; |
| 625 }; | 627 }; |
| 626 | 628 |
| 627 // Locker inside an Unlocker inside a Locker for default isolate. | 629 // Locker inside an Unlocker inside a Locker for default isolate. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 646 } | 648 } |
| 647 | 649 |
| 648 | 650 |
| 649 TEST(Regress1433) { | 651 TEST(Regress1433) { |
| 650 for (int i = 0; i < 10; i++) { | 652 for (int i = 0; i < 10; i++) { |
| 651 v8::Isolate* isolate = v8::Isolate::New(); | 653 v8::Isolate* isolate = v8::Isolate::New(); |
| 652 { | 654 { |
| 653 v8::Locker lock(isolate); | 655 v8::Locker lock(isolate); |
| 654 v8::Isolate::Scope isolate_scope(isolate); | 656 v8::Isolate::Scope isolate_scope(isolate); |
| 655 v8::HandleScope handle_scope(isolate); | 657 v8::HandleScope handle_scope(isolate); |
| 656 v8::Persistent<Context> context = v8::Context::New(); | 658 v8::Handle<Context> context = v8::Context::New(isolate); |
| 657 v8::Context::Scope context_scope(context); | 659 v8::Context::Scope context_scope(context); |
| 658 v8::Handle<String> source = v8::String::New("1+1"); | 660 v8::Handle<String> source = v8::String::New("1+1"); |
| 659 v8::Handle<Script> script = v8::Script::Compile(source); | 661 v8::Handle<Script> script = v8::Script::Compile(source); |
| 660 v8::Handle<Value> result = script->Run(); | 662 v8::Handle<Value> result = script->Run(); |
| 661 v8::String::AsciiValue ascii(result); | 663 v8::String::AsciiValue ascii(result); |
| 662 context.Dispose(isolate); | |
| 663 } | 664 } |
| 664 isolate->Dispose(); | 665 isolate->Dispose(); |
| 665 } | 666 } |
| 666 } | 667 } |
| 667 | 668 |
| 668 | 669 |
| 669 static const char* kSimpleExtensionSource = | 670 static const char* kSimpleExtensionSource = |
| 670 "(function Foo() {" | 671 "(function Foo() {" |
| 671 " return 4;" | 672 " return 4;" |
| 672 "})() "; | 673 "})() "; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 722 kSimpleExtensionSource)); | 723 kSimpleExtensionSource)); |
| 723 const char* extension_names[] = { "test0", "test1", | 724 const char* extension_names[] = { "test0", "test1", |
| 724 "test2", "test3", "test4", | 725 "test2", "test3", "test4", |
| 725 "test5", "test6", "test7" }; | 726 "test5", "test6", "test7" }; |
| 726 i::List<JoinableThread*> threads(kNThreads); | 727 i::List<JoinableThread*> threads(kNThreads); |
| 727 for (int i = 0; i < kNThreads; i++) { | 728 for (int i = 0; i < kNThreads; i++) { |
| 728 threads.Add(new IsolateGenesisThread(8, extension_names)); | 729 threads.Add(new IsolateGenesisThread(8, extension_names)); |
| 729 } | 730 } |
| 730 StartJoinAndDeleteThreads(threads); | 731 StartJoinAndDeleteThreads(threads); |
| 731 } | 732 } |
| OLD | NEW |