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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 : Thread("KangarooThread"), | 66 : Thread("KangarooThread"), |
67 isolate_(isolate), | 67 isolate_(isolate), |
68 context_(isolate, context) {} | 68 context_(isolate, context) {} |
69 | 69 |
70 void Run() { | 70 void Run() { |
71 { | 71 { |
72 v8::Locker locker(isolate_); | 72 v8::Locker locker(isolate_); |
73 v8::Isolate::Scope isolate_scope(isolate_); | 73 v8::Isolate::Scope isolate_scope(isolate_); |
74 CHECK_EQ(isolate_, v8::internal::Isolate::Current()); | 74 CHECK_EQ(isolate_, v8::internal::Isolate::Current()); |
75 v8::HandleScope scope(isolate_); | 75 v8::HandleScope scope(isolate_); |
76 v8::Context::Scope context_scope(isolate_, context_); | 76 v8::Local<v8::Context> context = |
| 77 v8::Local<v8::Context>::New(isolate_, context_); |
| 78 v8::Context::Scope context_scope(context); |
77 Local<Value> v = CompileRun("getValue()"); | 79 Local<Value> v = CompileRun("getValue()"); |
78 CHECK(v->IsNumber()); | 80 CHECK(v->IsNumber()); |
79 CHECK_EQ(30, static_cast<int>(v->NumberValue())); | 81 CHECK_EQ(30, static_cast<int>(v->NumberValue())); |
80 } | 82 } |
81 { | 83 { |
82 v8::Locker locker(isolate_); | 84 v8::Locker locker(isolate_); |
83 v8::Isolate::Scope isolate_scope(isolate_); | 85 v8::Isolate::Scope isolate_scope(isolate_); |
84 v8::HandleScope scope(isolate_); | 86 v8::HandleScope scope(isolate_); |
85 v8::Context::Scope context_scope(isolate_, context_); | 87 v8::Local<v8::Context> context = |
| 88 v8::Local<v8::Context>::New(isolate_, context_); |
| 89 v8::Context::Scope context_scope(context); |
86 Local<Value> v = CompileRun("getValue()"); | 90 Local<Value> v = CompileRun("getValue()"); |
87 CHECK(v->IsNumber()); | 91 CHECK(v->IsNumber()); |
88 CHECK_EQ(30, static_cast<int>(v->NumberValue())); | 92 CHECK_EQ(30, static_cast<int>(v->NumberValue())); |
89 } | 93 } |
90 isolate_->Dispose(); | 94 isolate_->Dispose(); |
91 } | 95 } |
92 | 96 |
93 private: | 97 private: |
94 v8::Isolate* isolate_; | 98 v8::Isolate* isolate_; |
95 Persistent<v8::Context> context_; | 99 Persistent<v8::Context> context_; |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 v8::Isolate* isolate, v8::Handle<v8::Context> context) | 349 v8::Isolate* isolate, v8::Handle<v8::Context> context) |
346 : JoinableThread("LockIsolateAndCalculateFibThread"), | 350 : JoinableThread("LockIsolateAndCalculateFibThread"), |
347 isolate_(isolate), | 351 isolate_(isolate), |
348 context_(isolate, context) { | 352 context_(isolate, context) { |
349 } | 353 } |
350 | 354 |
351 virtual void Run() { | 355 virtual void Run() { |
352 v8::Locker lock(isolate_); | 356 v8::Locker lock(isolate_); |
353 v8::Isolate::Scope isolate_scope(isolate_); | 357 v8::Isolate::Scope isolate_scope(isolate_); |
354 HandleScope handle_scope(isolate_); | 358 HandleScope handle_scope(isolate_); |
355 v8::Context::Scope context_scope(isolate_, context_); | 359 v8::Local<v8::Context> context = |
| 360 v8::Local<v8::Context>::New(isolate_, context_); |
| 361 v8::Context::Scope context_scope(context); |
356 CalcFibAndCheck(); | 362 CalcFibAndCheck(); |
357 } | 363 } |
358 private: | 364 private: |
359 v8::Isolate* isolate_; | 365 v8::Isolate* isolate_; |
360 Persistent<v8::Context> context_; | 366 Persistent<v8::Context> context_; |
361 }; | 367 }; |
362 | 368 |
363 class LockerUnlockerThread : public JoinableThread { | 369 class LockerUnlockerThread : public JoinableThread { |
364 public: | 370 public: |
365 explicit LockerUnlockerThread(v8::Isolate* isolate) | 371 explicit LockerUnlockerThread(v8::Isolate* isolate) |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 context_(isolate, context) { | 539 context_(isolate, context) { |
534 } | 540 } |
535 | 541 |
536 virtual void Run() { | 542 virtual void Run() { |
537 v8::Locker lock1(isolate_); | 543 v8::Locker lock1(isolate_); |
538 CHECK(v8::Locker::IsLocked(isolate_)); | 544 CHECK(v8::Locker::IsLocked(isolate_)); |
539 CHECK(!v8::Locker::IsLocked(CcTest::default_isolate())); | 545 CHECK(!v8::Locker::IsLocked(CcTest::default_isolate())); |
540 { | 546 { |
541 v8::Isolate::Scope isolate_scope(isolate_); | 547 v8::Isolate::Scope isolate_scope(isolate_); |
542 v8::HandleScope handle_scope(isolate_); | 548 v8::HandleScope handle_scope(isolate_); |
543 v8::Context::Scope context_scope(isolate_, context_); | 549 v8::Local<v8::Context> context = |
| 550 v8::Local<v8::Context>::New(isolate_, context_); |
| 551 v8::Context::Scope context_scope(context); |
544 CalcFibAndCheck(); | 552 CalcFibAndCheck(); |
545 } | 553 } |
546 { | 554 { |
547 v8::Unlocker unlock1(isolate_); | 555 v8::Unlocker unlock1(isolate_); |
548 CHECK(!v8::Locker::IsLocked(isolate_)); | 556 CHECK(!v8::Locker::IsLocked(isolate_)); |
549 CHECK(!v8::Locker::IsLocked(CcTest::default_isolate())); | 557 CHECK(!v8::Locker::IsLocked(CcTest::default_isolate())); |
550 { | 558 { |
551 v8::Locker lock2(isolate_); | 559 v8::Locker lock2(isolate_); |
552 v8::Isolate::Scope isolate_scope(isolate_); | 560 v8::Isolate::Scope isolate_scope(isolate_); |
553 v8::HandleScope handle_scope(isolate_); | 561 v8::HandleScope handle_scope(isolate_); |
554 CHECK(v8::Locker::IsLocked(isolate_)); | 562 CHECK(v8::Locker::IsLocked(isolate_)); |
555 CHECK(!v8::Locker::IsLocked(CcTest::default_isolate())); | 563 CHECK(!v8::Locker::IsLocked(CcTest::default_isolate())); |
556 v8::Context::Scope context_scope(isolate_, context_); | 564 v8::Local<v8::Context> context = |
| 565 v8::Local<v8::Context>::New(isolate_, context_); |
| 566 v8::Context::Scope context_scope(context); |
557 CalcFibAndCheck(); | 567 CalcFibAndCheck(); |
558 } | 568 } |
559 } | 569 } |
560 } | 570 } |
561 | 571 |
562 private: | 572 private: |
563 v8::Isolate* isolate_; | 573 v8::Isolate* isolate_; |
564 v8::Persistent<v8::Context> context_; | 574 v8::Persistent<v8::Context> context_; |
565 }; | 575 }; |
566 | 576 |
(...skipping 23 matching lines...) Expand all Loading... |
590 class LockUnlockLockDefaultIsolateThread : public JoinableThread { | 600 class LockUnlockLockDefaultIsolateThread : public JoinableThread { |
591 public: | 601 public: |
592 explicit LockUnlockLockDefaultIsolateThread(v8::Handle<v8::Context> context) | 602 explicit LockUnlockLockDefaultIsolateThread(v8::Handle<v8::Context> context) |
593 : JoinableThread("LockUnlockLockDefaultIsolateThread"), | 603 : JoinableThread("LockUnlockLockDefaultIsolateThread"), |
594 context_(CcTest::default_isolate(), context) {} | 604 context_(CcTest::default_isolate(), context) {} |
595 | 605 |
596 virtual void Run() { | 606 virtual void Run() { |
597 v8::Locker lock1(CcTest::default_isolate()); | 607 v8::Locker lock1(CcTest::default_isolate()); |
598 { | 608 { |
599 v8::HandleScope handle_scope(CcTest::default_isolate()); | 609 v8::HandleScope handle_scope(CcTest::default_isolate()); |
600 v8::Context::Scope context_scope(CcTest::default_isolate(), context_); | 610 v8::Local<v8::Context> context = |
| 611 v8::Local<v8::Context>::New(CcTest::default_isolate(), context_); |
| 612 v8::Context::Scope context_scope(context); |
601 CalcFibAndCheck(); | 613 CalcFibAndCheck(); |
602 } | 614 } |
603 { | 615 { |
604 v8::Unlocker unlock1(CcTest::default_isolate()); | 616 v8::Unlocker unlock1(CcTest::default_isolate()); |
605 { | 617 { |
606 v8::Locker lock2(CcTest::default_isolate()); | 618 v8::Locker lock2(CcTest::default_isolate()); |
607 v8::HandleScope handle_scope(CcTest::default_isolate()); | 619 v8::HandleScope handle_scope(CcTest::default_isolate()); |
608 v8::Context::Scope context_scope(CcTest::default_isolate(), context_); | 620 v8::Local<v8::Context> context = |
| 621 v8::Local<v8::Context>::New(CcTest::default_isolate(), context_); |
| 622 v8::Context::Scope context_scope(context); |
609 CalcFibAndCheck(); | 623 CalcFibAndCheck(); |
610 } | 624 } |
611 } | 625 } |
612 } | 626 } |
613 | 627 |
614 private: | 628 private: |
615 v8::Persistent<v8::Context> context_; | 629 v8::Persistent<v8::Context> context_; |
616 }; | 630 }; |
617 | 631 |
618 // Locker inside an Unlocker inside a Locker for default isolate. | 632 // Locker inside an Unlocker inside a Locker for default isolate. |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
711 kSimpleExtensionSource)); | 725 kSimpleExtensionSource)); |
712 const char* extension_names[] = { "test0", "test1", | 726 const char* extension_names[] = { "test0", "test1", |
713 "test2", "test3", "test4", | 727 "test2", "test3", "test4", |
714 "test5", "test6", "test7" }; | 728 "test5", "test6", "test7" }; |
715 i::List<JoinableThread*> threads(kNThreads); | 729 i::List<JoinableThread*> threads(kNThreads); |
716 for (int i = 0; i < kNThreads; i++) { | 730 for (int i = 0; i < kNThreads; i++) { |
717 threads.Add(new IsolateGenesisThread(8, extension_names)); | 731 threads.Add(new IsolateGenesisThread(8, extension_names)); |
718 } | 732 } |
719 StartJoinAndDeleteThreads(threads); | 733 StartJoinAndDeleteThreads(threads); |
720 } | 734 } |
OLD | NEW |