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 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
632 v8::Context::Scope context_scope(context); | 632 v8::Context::Scope context_scope(context); |
633 v8::Handle<String> source = v8::String::New("1+1"); | 633 v8::Handle<String> source = v8::String::New("1+1"); |
634 v8::Handle<Script> script = v8::Script::Compile(source); | 634 v8::Handle<Script> script = v8::Script::Compile(source); |
635 v8::Handle<Value> result = script->Run(); | 635 v8::Handle<Value> result = script->Run(); |
636 v8::String::AsciiValue ascii(result); | 636 v8::String::AsciiValue ascii(result); |
637 context.Dispose(); | 637 context.Dispose(); |
638 } | 638 } |
639 isolate->Dispose(); | 639 isolate->Dispose(); |
640 } | 640 } |
641 } | 641 } |
642 | |
643 | |
644 static const char* kSimpleExtensionSource = | |
645 "(function Foo() {" | |
646 " return 4;" | |
647 "})() "; | |
648 | |
649 class IsolateGenesisThread : public JoinableThread { | |
650 public: | |
651 IsolateGenesisThread(int count, const char* extension_names[]) | |
652 : JoinableThread("IsolateGenesisThread"), | |
653 count_(count), | |
654 extension_names_(extension_names) | |
655 {} | |
656 | |
657 virtual void Run() { | |
658 v8::Isolate* isolate = v8::Isolate::New(); | |
659 v8::Isolate::Scope isolate_scope(isolate); | |
660 v8::ExtensionConfiguration extensions(count_, extension_names_); | |
661 v8::Persistent<v8::Context> context = v8::Context::New(&extensions); | |
662 context.Dispose(); | |
Vitaly Repeshko
2011/11/15 18:14:17
Dispose the isolate too?
| |
663 } | |
664 private: | |
665 int count_; | |
666 const char** extension_names_; | |
667 }; | |
668 | |
669 TEST(ExtensionsRegistration) { | |
Vitaly Repeshko
2011/11/15 18:14:17
Please describe what this tests and add a link to
| |
670 const int kNThreads = 40; | |
671 v8::RegisterExtension(new v8::Extension("test0", | |
672 kSimpleExtensionSource)); | |
673 v8::RegisterExtension(new v8::Extension("test1", | |
674 kSimpleExtensionSource)); | |
675 v8::RegisterExtension(new v8::Extension("test2", | |
676 kSimpleExtensionSource)); | |
677 v8::RegisterExtension(new v8::Extension("test3", | |
678 kSimpleExtensionSource)); | |
679 v8::RegisterExtension(new v8::Extension("test4", | |
680 kSimpleExtensionSource)); | |
681 v8::RegisterExtension(new v8::Extension("test5", | |
682 kSimpleExtensionSource)); | |
683 v8::RegisterExtension(new v8::Extension("test6", | |
684 kSimpleExtensionSource)); | |
685 v8::RegisterExtension(new v8::Extension("test7", | |
686 kSimpleExtensionSource)); | |
687 const char* extension_names[] = { "test0", "test1", | |
688 "test2", "test3", "test4", | |
689 "test5", "test6", "test7" }; | |
690 i::List<JoinableThread*> threads(kNThreads); | |
691 for (int i = 0; i < kNThreads; i++) { | |
692 threads.Add(new IsolateGenesisThread(8, extension_names)); | |
693 } | |
694 StartJoinAndDeleteThreads(threads); | |
695 } | |
OLD | NEW |