| 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 i::SmartPointer<LockIsolateAndCalculateFibSharedContextThread> thread; |
| 474 Persistent<v8::Context> context2; | |
| 475 v8::Locker lock1(isolate1_); | 477 v8::Locker lock1(isolate1_); |
| 476 CHECK(v8::Locker::IsLocked(isolate1_)); | 478 CHECK(v8::Locker::IsLocked(isolate1_)); |
| 477 CHECK(!v8::Locker::IsLocked(isolate2_)); | 479 CHECK(!v8::Locker::IsLocked(isolate2_)); |
| 478 { | 480 { |
| 479 v8::Isolate::Scope isolate_scope(isolate1_); | 481 v8::Isolate::Scope isolate_scope(isolate1_); |
| 480 v8::HandleScope handle_scope(isolate1_); | 482 v8::HandleScope handle_scope(isolate1_); |
| 481 context1 = v8::Context::New(); | 483 v8::Handle<v8::Context> context1 = v8::Context::New(isolate1_); |
| 482 { | 484 { |
| 483 v8::Context::Scope context_scope(context1); | 485 v8::Context::Scope context_scope(context1); |
| 484 CalcFibAndCheck(); | 486 CalcFibAndCheck(); |
| 485 } | 487 } |
| 488 thread.Reset(new LockIsolateAndCalculateFibSharedContextThread( |
| 489 isolate1_, context1)); |
| 486 } | 490 } |
| 487 v8::Locker lock2(isolate2_); | 491 v8::Locker lock2(isolate2_); |
| 488 CHECK(v8::Locker::IsLocked(isolate1_)); | 492 CHECK(v8::Locker::IsLocked(isolate1_)); |
| 489 CHECK(v8::Locker::IsLocked(isolate2_)); | 493 CHECK(v8::Locker::IsLocked(isolate2_)); |
| 490 { | 494 { |
| 491 v8::Isolate::Scope isolate_scope(isolate2_); | 495 v8::Isolate::Scope isolate_scope(isolate2_); |
| 492 v8::HandleScope handle_scope(isolate2_); | 496 v8::HandleScope handle_scope(isolate2_); |
| 493 context2 = v8::Context::New(); | 497 v8::Handle<v8::Context> context2 = v8::Context::New(isolate2_); |
| 494 { | 498 { |
| 495 v8::Context::Scope context_scope(context2); | 499 v8::Context::Scope context_scope(context2); |
| 496 CalcFibAndCheck(); | 500 CalcFibAndCheck(); |
| 497 } | 501 } |
| 498 } | |
| 499 { | |
| 500 i::SmartPointer<LockIsolateAndCalculateFibSharedContextThread> thread; | |
| 501 { | |
| 502 CHECK(v8::Locker::IsLocked(isolate1_)); | |
| 503 v8::Isolate::Scope isolate_scope(isolate1_); | |
| 504 v8::HandleScope handle_scope(isolate1_); | |
| 505 thread.Reset(new LockIsolateAndCalculateFibSharedContextThread( | |
| 506 isolate1_, v8::Local<v8::Context>::New(isolate1_, context1))); | |
| 507 } | |
| 508 v8::Unlocker unlock1(isolate1_); | 502 v8::Unlocker unlock1(isolate1_); |
| 509 CHECK(!v8::Locker::IsLocked(isolate1_)); | 503 CHECK(!v8::Locker::IsLocked(isolate1_)); |
| 510 CHECK(v8::Locker::IsLocked(isolate2_)); | 504 CHECK(v8::Locker::IsLocked(isolate2_)); |
| 511 v8::Isolate::Scope isolate_scope(isolate2_); | |
| 512 v8::HandleScope handle_scope(isolate2_); | |
| 513 v8::Context::Scope context_scope(context2); | 505 v8::Context::Scope context_scope(context2); |
| 514 thread->Start(); | 506 thread->Start(); |
| 515 CalcFibAndCheck(); | 507 CalcFibAndCheck(); |
| 516 thread->Join(); | 508 thread->Join(); |
| 517 } | 509 } |
| 518 } | 510 } |
| 519 | 511 |
| 520 private: | 512 private: |
| 521 v8::Isolate* isolate1_; | 513 v8::Isolate* isolate1_; |
| 522 v8::Isolate* isolate2_; | 514 v8::Isolate* isolate2_; |
| 523 }; | 515 }; |
| 524 | 516 |
| 525 // Lock two isolates and unlock one of them. | 517 // Lock two isolates and unlock one of them. |
| 526 TEST(LockAndUnlockDifferentIsolates) { | 518 TEST(LockAndUnlockDifferentIsolates) { |
| 527 v8::Isolate* isolate1 = v8::Isolate::New(); | 519 v8::Isolate* isolate1 = v8::Isolate::New(); |
| 528 v8::Isolate* isolate2 = v8::Isolate::New(); | 520 v8::Isolate* isolate2 = v8::Isolate::New(); |
| 529 LockAndUnlockDifferentIsolatesThread thread(isolate1, isolate2); | 521 LockAndUnlockDifferentIsolatesThread thread(isolate1, isolate2); |
| 530 thread.Start(); | 522 thread.Start(); |
| 531 thread.Join(); | 523 thread.Join(); |
| 532 isolate2->Dispose(); | 524 isolate2->Dispose(); |
| 533 isolate1->Dispose(); | 525 isolate1->Dispose(); |
| 534 } | 526 } |
| 535 | 527 |
| 536 class LockUnlockLockThread : public JoinableThread { | 528 class LockUnlockLockThread : public JoinableThread { |
| 537 public: | 529 public: |
| 538 LockUnlockLockThread(v8::Isolate* isolate, v8::Local<v8::Context> context) | 530 LockUnlockLockThread(v8::Isolate* isolate, v8::Handle<v8::Context> context) |
| 539 : JoinableThread("LockUnlockLockThread"), | 531 : JoinableThread("LockUnlockLockThread"), |
| 540 isolate_(isolate), | 532 isolate_(isolate), |
| 541 context_(isolate, context) { | 533 context_(isolate, context) { |
| 542 } | 534 } |
| 543 | 535 |
| 544 virtual void Run() { | 536 virtual void Run() { |
| 545 v8::Locker lock1(isolate_); | 537 v8::Locker lock1(isolate_); |
| 546 CHECK(v8::Locker::IsLocked(isolate_)); | 538 CHECK(v8::Locker::IsLocked(isolate_)); |
| 547 CHECK(!v8::Locker::IsLocked(CcTest::default_isolate())); | 539 CHECK(!v8::Locker::IsLocked(CcTest::default_isolate())); |
| 548 { | 540 { |
| 549 v8::Isolate::Scope isolate_scope(isolate_); | 541 v8::Isolate::Scope isolate_scope(isolate_); |
| 550 v8::HandleScope handle_scope(isolate_); | 542 v8::HandleScope handle_scope(isolate_); |
| 551 v8::Context::Scope context_scope(context_); | 543 v8::Context::Scope context_scope(isolate_, context_); |
| 552 CalcFibAndCheck(); | 544 CalcFibAndCheck(); |
| 553 } | 545 } |
| 554 { | 546 { |
| 555 v8::Unlocker unlock1(isolate_); | 547 v8::Unlocker unlock1(isolate_); |
| 556 CHECK(!v8::Locker::IsLocked(isolate_)); | 548 CHECK(!v8::Locker::IsLocked(isolate_)); |
| 557 CHECK(!v8::Locker::IsLocked(CcTest::default_isolate())); | 549 CHECK(!v8::Locker::IsLocked(CcTest::default_isolate())); |
| 558 { | 550 { |
| 559 v8::Locker lock2(isolate_); | 551 v8::Locker lock2(isolate_); |
| 560 v8::Isolate::Scope isolate_scope(isolate_); | 552 v8::Isolate::Scope isolate_scope(isolate_); |
| 561 v8::HandleScope handle_scope(isolate_); | 553 v8::HandleScope handle_scope(isolate_); |
| 562 CHECK(v8::Locker::IsLocked(isolate_)); | 554 CHECK(v8::Locker::IsLocked(isolate_)); |
| 563 CHECK(!v8::Locker::IsLocked(CcTest::default_isolate())); | 555 CHECK(!v8::Locker::IsLocked(CcTest::default_isolate())); |
| 564 v8::Context::Scope context_scope(context_); | 556 v8::Context::Scope context_scope(isolate_, context_); |
| 565 CalcFibAndCheck(); | 557 CalcFibAndCheck(); |
| 566 } | 558 } |
| 567 } | 559 } |
| 568 } | 560 } |
| 569 | 561 |
| 570 private: | 562 private: |
| 571 v8::Isolate* isolate_; | 563 v8::Isolate* isolate_; |
| 572 v8::Persistent<v8::Context> context_; | 564 v8::Persistent<v8::Context> context_; |
| 573 }; | 565 }; |
| 574 | 566 |
| 575 // Locker inside an Unlocker inside a Locker. | 567 // Locker inside an Unlocker inside a Locker. |
| 576 TEST(LockUnlockLockMultithreaded) { | 568 TEST(LockUnlockLockMultithreaded) { |
| 577 #ifdef V8_TARGET_ARCH_MIPS | 569 #ifdef V8_TARGET_ARCH_MIPS |
| 578 const int kNThreads = 50; | 570 const int kNThreads = 50; |
| 579 #else | 571 #else |
| 580 const int kNThreads = 100; | 572 const int kNThreads = 100; |
| 581 #endif | 573 #endif |
| 582 v8::Isolate* isolate = v8::Isolate::New(); | 574 v8::Isolate* isolate = v8::Isolate::New(); |
| 583 Persistent<v8::Context> context; | |
| 584 i::List<JoinableThread*> threads(kNThreads); | 575 i::List<JoinableThread*> threads(kNThreads); |
| 585 { | 576 { |
| 586 v8::Locker locker_(isolate); | 577 v8::Locker locker_(isolate); |
| 587 v8::Isolate::Scope isolate_scope(isolate); | 578 v8::Isolate::Scope isolate_scope(isolate); |
| 588 v8::HandleScope handle_scope(isolate); | 579 v8::HandleScope handle_scope(isolate); |
| 589 context = v8::Context::New(); | 580 v8::Handle<v8::Context> context = v8::Context::New(isolate); |
| 590 for (int i = 0; i < kNThreads; i++) { | 581 for (int i = 0; i < kNThreads; i++) { |
| 591 threads.Add(new LockUnlockLockThread( | 582 threads.Add(new LockUnlockLockThread( |
| 592 isolate, v8::Local<v8::Context>::New(isolate, context))); | 583 isolate, context)); |
| 593 } | 584 } |
| 594 } | 585 } |
| 595 StartJoinAndDeleteThreads(threads); | 586 StartJoinAndDeleteThreads(threads); |
| 596 isolate->Dispose(); | 587 isolate->Dispose(); |
| 597 } | 588 } |
| 598 | 589 |
| 599 class LockUnlockLockDefaultIsolateThread : public JoinableThread { | 590 class LockUnlockLockDefaultIsolateThread : public JoinableThread { |
| 600 public: | 591 public: |
| 601 explicit LockUnlockLockDefaultIsolateThread(v8::Local<v8::Context> context) | 592 explicit LockUnlockLockDefaultIsolateThread(v8::Handle<v8::Context> context) |
| 602 : JoinableThread("LockUnlockLockDefaultIsolateThread"), | 593 : JoinableThread("LockUnlockLockDefaultIsolateThread"), |
| 603 context_(CcTest::default_isolate(), context) {} | 594 context_(CcTest::default_isolate(), context) {} |
| 604 | 595 |
| 605 virtual void Run() { | 596 virtual void Run() { |
| 606 v8::Locker lock1(CcTest::default_isolate()); | 597 v8::Locker lock1(CcTest::default_isolate()); |
| 607 { | 598 { |
| 608 v8::HandleScope handle_scope(CcTest::default_isolate()); | 599 v8::HandleScope handle_scope(CcTest::default_isolate()); |
| 609 v8::Context::Scope context_scope(context_); | 600 v8::Context::Scope context_scope(CcTest::default_isolate(), context_); |
| 610 CalcFibAndCheck(); | 601 CalcFibAndCheck(); |
| 611 } | 602 } |
| 612 { | 603 { |
| 613 v8::Unlocker unlock1(CcTest::default_isolate()); | 604 v8::Unlocker unlock1(CcTest::default_isolate()); |
| 614 { | 605 { |
| 615 v8::Locker lock2(CcTest::default_isolate()); | 606 v8::Locker lock2(CcTest::default_isolate()); |
| 616 v8::HandleScope handle_scope(CcTest::default_isolate()); | 607 v8::HandleScope handle_scope(CcTest::default_isolate()); |
| 617 v8::Context::Scope context_scope(context_); | 608 v8::Context::Scope context_scope(CcTest::default_isolate(), context_); |
| 618 CalcFibAndCheck(); | 609 CalcFibAndCheck(); |
| 619 } | 610 } |
| 620 } | 611 } |
| 621 } | 612 } |
| 622 | 613 |
| 623 private: | 614 private: |
| 624 v8::Persistent<v8::Context> context_; | 615 v8::Persistent<v8::Context> context_; |
| 625 }; | 616 }; |
| 626 | 617 |
| 627 // Locker inside an Unlocker inside a Locker for default isolate. | 618 // Locker inside an Unlocker inside a Locker for default isolate. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 646 } | 637 } |
| 647 | 638 |
| 648 | 639 |
| 649 TEST(Regress1433) { | 640 TEST(Regress1433) { |
| 650 for (int i = 0; i < 10; i++) { | 641 for (int i = 0; i < 10; i++) { |
| 651 v8::Isolate* isolate = v8::Isolate::New(); | 642 v8::Isolate* isolate = v8::Isolate::New(); |
| 652 { | 643 { |
| 653 v8::Locker lock(isolate); | 644 v8::Locker lock(isolate); |
| 654 v8::Isolate::Scope isolate_scope(isolate); | 645 v8::Isolate::Scope isolate_scope(isolate); |
| 655 v8::HandleScope handle_scope(isolate); | 646 v8::HandleScope handle_scope(isolate); |
| 656 v8::Persistent<Context> context = v8::Context::New(); | 647 v8::Handle<Context> context = v8::Context::New(isolate); |
| 657 v8::Context::Scope context_scope(context); | 648 v8::Context::Scope context_scope(context); |
| 658 v8::Handle<String> source = v8::String::New("1+1"); | 649 v8::Handle<String> source = v8::String::New("1+1"); |
| 659 v8::Handle<Script> script = v8::Script::Compile(source); | 650 v8::Handle<Script> script = v8::Script::Compile(source); |
| 660 v8::Handle<Value> result = script->Run(); | 651 v8::Handle<Value> result = script->Run(); |
| 661 v8::String::AsciiValue ascii(result); | 652 v8::String::AsciiValue ascii(result); |
| 662 context.Dispose(isolate); | |
| 663 } | 653 } |
| 664 isolate->Dispose(); | 654 isolate->Dispose(); |
| 665 } | 655 } |
| 666 } | 656 } |
| 667 | 657 |
| 668 | 658 |
| 669 static const char* kSimpleExtensionSource = | 659 static const char* kSimpleExtensionSource = |
| 670 "(function Foo() {" | 660 "(function Foo() {" |
| 671 " return 4;" | 661 " return 4;" |
| 672 "})() "; | 662 "})() "; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 722 kSimpleExtensionSource)); | 712 kSimpleExtensionSource)); |
| 723 const char* extension_names[] = { "test0", "test1", | 713 const char* extension_names[] = { "test0", "test1", |
| 724 "test2", "test3", "test4", | 714 "test2", "test3", "test4", |
| 725 "test5", "test6", "test7" }; | 715 "test5", "test6", "test7" }; |
| 726 i::List<JoinableThread*> threads(kNThreads); | 716 i::List<JoinableThread*> threads(kNThreads); |
| 727 for (int i = 0; i < kNThreads; i++) { | 717 for (int i = 0; i < kNThreads; i++) { |
| 728 threads.Add(new IsolateGenesisThread(8, extension_names)); | 718 threads.Add(new IsolateGenesisThread(8, extension_names)); |
| 729 } | 719 } |
| 730 StartJoinAndDeleteThreads(threads); | 720 StartJoinAndDeleteThreads(threads); |
| 731 } | 721 } |
| OLD | NEW |