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

Side by Side Diff: src/isolate.cc

Issue 7003108: "Deiceolate" Thread classes. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 6 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 2011 the V8 project authors. All rights reserved. 1 // Copyright 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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 } 183 }
184 184
185 // Make sure we access the buffer after the wait to remove all possibility 185 // Make sure we access the buffer after the wait to remove all possibility
186 // of it being optimized away. 186 // of it being optimized away.
187 OS::StrNCpy(local_buffer, "PreallocatedMemoryThread shutting down.\n", 187 OS::StrNCpy(local_buffer, "PreallocatedMemoryThread shutting down.\n",
188 local_buffer.length()); 188 local_buffer.length());
189 } 189 }
190 190
191 191
192 private: 192 private:
193 explicit PreallocatedMemoryThread(Isolate* isolate) 193 PreallocatedMemoryThread()
194 : Thread(isolate, "v8:PreallocMem"), 194 : Thread("v8:PreallocMem"),
195 keep_running_(true), 195 keep_running_(true),
196 wait_for_ever_semaphore_(OS::CreateSemaphore(0)), 196 wait_for_ever_semaphore_(OS::CreateSemaphore(0)),
197 data_ready_semaphore_(OS::CreateSemaphore(0)), 197 data_ready_semaphore_(OS::CreateSemaphore(0)),
198 data_(NULL), 198 data_(NULL),
199 length_(0) { 199 length_(0) {
200 } 200 }
201 201
202 // Used to make sure that the thread keeps looping even for spurious wakeups. 202 // Used to make sure that the thread keeps looping even for spurious wakeups.
203 bool keep_running_; 203 bool keep_running_;
204 204
205 // This semaphore is used by the PreallocatedMemoryThread to wait for ever. 205 // This semaphore is used by the PreallocatedMemoryThread to wait for ever.
206 Semaphore* wait_for_ever_semaphore_; 206 Semaphore* wait_for_ever_semaphore_;
207 // Semaphore to signal that the data has been initialized. 207 // Semaphore to signal that the data has been initialized.
208 Semaphore* data_ready_semaphore_; 208 Semaphore* data_ready_semaphore_;
209 209
210 // Location and size of the preallocated memory block. 210 // Location and size of the preallocated memory block.
211 char* data_; 211 char* data_;
212 unsigned length_; 212 unsigned length_;
213 213
214 friend class Isolate; 214 friend class Isolate;
215 215
216 DISALLOW_COPY_AND_ASSIGN(PreallocatedMemoryThread); 216 DISALLOW_COPY_AND_ASSIGN(PreallocatedMemoryThread);
217 }; 217 };
218 218
219 219
220 void Isolate::PreallocatedMemoryThreadStart() { 220 void Isolate::PreallocatedMemoryThreadStart() {
221 if (preallocated_memory_thread_ != NULL) return; 221 if (preallocated_memory_thread_ != NULL) return;
222 preallocated_memory_thread_ = new PreallocatedMemoryThread(this); 222 preallocated_memory_thread_ = new PreallocatedMemoryThread();
223 preallocated_memory_thread_->Start(); 223 preallocated_memory_thread_->Start();
224 } 224 }
225 225
226 226
227 void Isolate::PreallocatedMemoryThreadStop() { 227 void Isolate::PreallocatedMemoryThreadStop() {
228 if (preallocated_memory_thread_ == NULL) return; 228 if (preallocated_memory_thread_ == NULL) return;
229 preallocated_memory_thread_->StopThread(); 229 preallocated_memory_thread_->StopThread();
230 // Done with the thread entirely. 230 // Done with the thread entirely.
231 delete preallocated_memory_thread_; 231 delete preallocated_memory_thread_;
232 preallocated_memory_thread_ = NULL; 232 preallocated_memory_thread_ = NULL;
(...skipping 1377 matching lines...) Expand 10 before | Expand all | Expand 10 after
1610 1610
1611 1611
1612 bool Isolate::PreInit() { 1612 bool Isolate::PreInit() {
1613 if (state_ != UNINITIALIZED) return true; 1613 if (state_ != UNINITIALIZED) return true;
1614 1614
1615 TRACE_ISOLATE(preinit); 1615 TRACE_ISOLATE(preinit);
1616 1616
1617 ASSERT(Isolate::Current() == this); 1617 ASSERT(Isolate::Current() == this);
1618 #ifdef ENABLE_DEBUGGER_SUPPORT 1618 #ifdef ENABLE_DEBUGGER_SUPPORT
1619 debug_ = new Debug(this); 1619 debug_ = new Debug(this);
1620 debugger_ = new Debugger(); 1620 debugger_ = new Debugger(this);
1621 debugger_->isolate_ = this;
1622 #endif 1621 #endif
1623 1622
1624 memory_allocator_ = new MemoryAllocator(); 1623 memory_allocator_ = new MemoryAllocator();
1625 memory_allocator_->isolate_ = this; 1624 memory_allocator_->isolate_ = this;
1626 code_range_ = new CodeRange(); 1625 code_range_ = new CodeRange();
1627 code_range_->isolate_ = this; 1626 code_range_->isolate_ = this;
1628 1627
1629 // Safe after setting Heap::isolate_, initializing StackGuard and 1628 // Safe after setting Heap::isolate_, initializing StackGuard and
1630 // ensuring that Isolate::Current() == this. 1629 // ensuring that Isolate::Current() == this.
1631 heap_.SetStackLimits(); 1630 heap_.SetStackLimits();
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
1877 1876
1878 #ifdef DEBUG 1877 #ifdef DEBUG
1879 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ 1878 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \
1880 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); 1879 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_);
1881 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) 1880 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET)
1882 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) 1881 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET)
1883 #undef ISOLATE_FIELD_OFFSET 1882 #undef ISOLATE_FIELD_OFFSET
1884 #endif 1883 #endif
1885 1884
1886 } } // namespace v8::internal 1885 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698