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 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 { | 642 { |
643 v8::Locker lock(isolate); | 643 v8::Locker lock(isolate); |
644 v8::Isolate::Scope isolate_scope(isolate); | 644 v8::Isolate::Scope isolate_scope(isolate); |
645 v8::HandleScope handle_scope; | 645 v8::HandleScope handle_scope; |
646 v8::Persistent<Context> context = v8::Context::New(); | 646 v8::Persistent<Context> context = v8::Context::New(); |
647 v8::Context::Scope context_scope(context); | 647 v8::Context::Scope context_scope(context); |
648 v8::Handle<String> source = v8::String::New("1+1"); | 648 v8::Handle<String> source = v8::String::New("1+1"); |
649 v8::Handle<Script> script = v8::Script::Compile(source); | 649 v8::Handle<Script> script = v8::Script::Compile(source); |
650 v8::Handle<Value> result = script->Run(); | 650 v8::Handle<Value> result = script->Run(); |
651 v8::String::AsciiValue ascii(result); | 651 v8::String::AsciiValue ascii(result); |
652 context.Dispose(); | 652 context.Dispose(isolate); |
653 } | 653 } |
654 isolate->Dispose(); | 654 isolate->Dispose(); |
655 } | 655 } |
656 } | 656 } |
657 | 657 |
658 | 658 |
659 static const char* kSimpleExtensionSource = | 659 static const char* kSimpleExtensionSource = |
660 "(function Foo() {" | 660 "(function Foo() {" |
661 " return 4;" | 661 " return 4;" |
662 "})() "; | 662 "})() "; |
663 | 663 |
664 class IsolateGenesisThread : public JoinableThread { | 664 class IsolateGenesisThread : public JoinableThread { |
665 public: | 665 public: |
666 IsolateGenesisThread(int count, const char* extension_names[]) | 666 IsolateGenesisThread(int count, const char* extension_names[]) |
667 : JoinableThread("IsolateGenesisThread"), | 667 : JoinableThread("IsolateGenesisThread"), |
668 count_(count), | 668 count_(count), |
669 extension_names_(extension_names) | 669 extension_names_(extension_names) |
670 {} | 670 {} |
671 | 671 |
672 virtual void Run() { | 672 virtual void Run() { |
673 v8::Isolate* isolate = v8::Isolate::New(); | 673 v8::Isolate* isolate = v8::Isolate::New(); |
674 { | 674 { |
675 v8::Isolate::Scope isolate_scope(isolate); | 675 v8::Isolate::Scope isolate_scope(isolate); |
676 CHECK(!i::Isolate::Current()->has_installed_extensions()); | 676 CHECK(!i::Isolate::Current()->has_installed_extensions()); |
677 v8::ExtensionConfiguration extensions(count_, extension_names_); | 677 v8::ExtensionConfiguration extensions(count_, extension_names_); |
678 v8::Persistent<v8::Context> context = v8::Context::New(&extensions); | 678 v8::Persistent<v8::Context> context = v8::Context::New(&extensions); |
679 CHECK(i::Isolate::Current()->has_installed_extensions()); | 679 CHECK(i::Isolate::Current()->has_installed_extensions()); |
680 context.Dispose(); | 680 context.Dispose(isolate); |
681 } | 681 } |
682 isolate->Dispose(); | 682 isolate->Dispose(); |
683 } | 683 } |
684 private: | 684 private: |
685 int count_; | 685 int count_; |
686 const char** extension_names_; | 686 const char** extension_names_; |
687 }; | 687 }; |
688 | 688 |
689 // Test installing extensions in separate isolates concurrently. | 689 // Test installing extensions in separate isolates concurrently. |
690 // http://code.google.com/p/v8/issues/detail?id=1821 | 690 // http://code.google.com/p/v8/issues/detail?id=1821 |
(...skipping 21 matching lines...) Expand all Loading... |
712 kSimpleExtensionSource)); | 712 kSimpleExtensionSource)); |
713 const char* extension_names[] = { "test0", "test1", | 713 const char* extension_names[] = { "test0", "test1", |
714 "test2", "test3", "test4", | 714 "test2", "test3", "test4", |
715 "test5", "test6", "test7" }; | 715 "test5", "test6", "test7" }; |
716 i::List<JoinableThread*> threads(kNThreads); | 716 i::List<JoinableThread*> threads(kNThreads); |
717 for (int i = 0; i < kNThreads; i++) { | 717 for (int i = 0; i < kNThreads; i++) { |
718 threads.Add(new IsolateGenesisThread(8, extension_names)); | 718 threads.Add(new IsolateGenesisThread(8, extension_names)); |
719 } | 719 } |
720 StartJoinAndDeleteThreads(threads); | 720 StartJoinAndDeleteThreads(threads); |
721 } | 721 } |
OLD | NEW |