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

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

Issue 358363002: Move platform abstraction to base library (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: updates Created 6 years, 5 months 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
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 12 matching lines...) Expand all
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 #include "src/v8.h" 30 #include "src/v8.h"
31 31
32 #include "src/api.h" 32 #include "src/api.h"
33 #include "src/base/platform/platform.h"
33 #include "src/compilation-cache.h" 34 #include "src/compilation-cache.h"
34 #include "src/execution.h" 35 #include "src/execution.h"
35 #include "src/isolate.h" 36 #include "src/isolate.h"
36 #include "src/parser.h" 37 #include "src/parser.h"
37 #include "src/platform.h"
38 #include "src/smart-pointers.h" 38 #include "src/smart-pointers.h"
39 #include "src/snapshot.h" 39 #include "src/snapshot.h"
40 #include "src/unicode-inl.h" 40 #include "src/unicode-inl.h"
41 #include "src/utils.h" 41 #include "src/utils.h"
42 #include "test/cctest/cctest.h" 42 #include "test/cctest/cctest.h"
43 43
44 using ::v8::Context; 44 using ::v8::Context;
45 using ::v8::Extension; 45 using ::v8::Extension;
46 using ::v8::Function; 46 using ::v8::Function;
47 using ::v8::HandleScope; 47 using ::v8::HandleScope;
48 using ::v8::Local; 48 using ::v8::Local;
49 using ::v8::Object; 49 using ::v8::Object;
50 using ::v8::ObjectTemplate; 50 using ::v8::ObjectTemplate;
51 using ::v8::Persistent; 51 using ::v8::Persistent;
52 using ::v8::Script; 52 using ::v8::Script;
53 using ::v8::String; 53 using ::v8::String;
54 using ::v8::Value; 54 using ::v8::Value;
55 using ::v8::V8; 55 using ::v8::V8;
56 56
57 57
58 // Migrating an isolate 58 // Migrating an isolate
59 class KangarooThread : public v8::internal::Thread { 59 class KangarooThread : public v8::base::Thread {
60 public: 60 public:
61 KangarooThread(v8::Isolate* isolate, v8::Handle<v8::Context> context) 61 KangarooThread(v8::Isolate* isolate, v8::Handle<v8::Context> context)
62 : Thread("KangarooThread"), 62 : Thread("KangarooThread"),
63 isolate_(isolate), 63 isolate_(isolate),
64 context_(isolate, context) {} 64 context_(isolate, context) {}
65 65
66 void Run() { 66 void Run() {
67 { 67 {
68 v8::Locker locker(isolate_); 68 v8::Locker locker(isolate_);
69 v8::Isolate::Scope isolate_scope(isolate_); 69 v8::Isolate::Scope isolate_scope(isolate_);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 thread_.Start(); 139 thread_.Start();
140 } 140 }
141 141
142 void Join() { 142 void Join() {
143 semaphore_.Wait(); 143 semaphore_.Wait();
144 } 144 }
145 145
146 virtual void Run() = 0; 146 virtual void Run() = 0;
147 147
148 private: 148 private:
149 class ThreadWithSemaphore : public i::Thread { 149 class ThreadWithSemaphore : public v8::base::Thread {
150 public: 150 public:
151 explicit ThreadWithSemaphore(JoinableThread* joinable_thread) 151 explicit ThreadWithSemaphore(JoinableThread* joinable_thread)
152 : Thread(joinable_thread->name_), 152 : Thread(joinable_thread->name_),
153 joinable_thread_(joinable_thread) { 153 joinable_thread_(joinable_thread) {
154 } 154 }
155 155
156 virtual void Run() { 156 virtual void Run() {
157 joinable_thread_->Run(); 157 joinable_thread_->Run();
158 joinable_thread_->semaphore_.Signal(); 158 joinable_thread_->semaphore_.Signal();
159 } 159 }
160 160
161 private: 161 private:
162 JoinableThread* joinable_thread_; 162 JoinableThread* joinable_thread_;
163 }; 163 };
164 164
165 const char* name_; 165 const char* name_;
166 i::Semaphore semaphore_; 166 v8::base::Semaphore semaphore_;
167 ThreadWithSemaphore thread_; 167 ThreadWithSemaphore thread_;
168 168
169 friend class ThreadWithSemaphore; 169 friend class ThreadWithSemaphore;
170 170
171 DISALLOW_COPY_AND_ASSIGN(JoinableThread); 171 DISALLOW_COPY_AND_ASSIGN(JoinableThread);
172 }; 172 };
173 173
174 174
175 class IsolateLockingThreadWithLocalContext : public JoinableThread { 175 class IsolateLockingThreadWithLocalContext : public JoinableThread {
176 public: 176 public:
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 kSimpleExtensionSource)); 738 kSimpleExtensionSource));
739 const char* extension_names[] = { "test0", "test1", 739 const char* extension_names[] = { "test0", "test1",
740 "test2", "test3", "test4", 740 "test2", "test3", "test4",
741 "test5", "test6", "test7" }; 741 "test5", "test6", "test7" };
742 i::List<JoinableThread*> threads(kNThreads); 742 i::List<JoinableThread*> threads(kNThreads);
743 for (int i = 0; i < kNThreads; i++) { 743 for (int i = 0; i < kNThreads; i++) {
744 threads.Add(new IsolateGenesisThread(8, extension_names)); 744 threads.Add(new IsolateGenesisThread(8, extension_names));
745 } 745 }
746 StartJoinAndDeleteThreads(threads); 746 StartJoinAndDeleteThreads(threads);
747 } 747 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698