Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(224)

Side by Side Diff: test/cctest/test-lockers.cc

Issue 8536042: Extension state made per-siolate in genesis (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: More CR feedback Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/serialize.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 {
660 v8::Isolate::Scope isolate_scope(isolate);
661 CHECK(!i::Isolate::Current()->has_installed_extensions());
662 v8::ExtensionConfiguration extensions(count_, extension_names_);
663 v8::Persistent<v8::Context> context = v8::Context::New(&extensions);
664 CHECK(i::Isolate::Current()->has_installed_extensions());
665 context.Dispose();
666 }
667 isolate->Dispose();
668 }
669 private:
670 int count_;
671 const char** extension_names_;
672 };
673
674 // Test installing extensions in separate isolates concurrently.
675 // http://code.google.com/p/v8/issues/detail?id=1821
676 TEST(ExtensionsRegistration) {
677 const int kNThreads = 40;
678 v8::RegisterExtension(new v8::Extension("test0",
679 kSimpleExtensionSource));
680 v8::RegisterExtension(new v8::Extension("test1",
681 kSimpleExtensionSource));
682 v8::RegisterExtension(new v8::Extension("test2",
683 kSimpleExtensionSource));
684 v8::RegisterExtension(new v8::Extension("test3",
685 kSimpleExtensionSource));
686 v8::RegisterExtension(new v8::Extension("test4",
687 kSimpleExtensionSource));
688 v8::RegisterExtension(new v8::Extension("test5",
689 kSimpleExtensionSource));
690 v8::RegisterExtension(new v8::Extension("test6",
691 kSimpleExtensionSource));
692 v8::RegisterExtension(new v8::Extension("test7",
693 kSimpleExtensionSource));
694 const char* extension_names[] = { "test0", "test1",
695 "test2", "test3", "test4",
696 "test5", "test6", "test7" };
697 i::List<JoinableThread*> threads(kNThreads);
698 for (int i = 0; i < kNThreads; i++) {
699 threads.Add(new IsolateGenesisThread(8, extension_names));
700 }
701 StartJoinAndDeleteThreads(threads);
702 }
OLDNEW
« no previous file with comments | « src/serialize.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698