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

Side by Side Diff: src/isolate.cc

Issue 6749029: Make the preparser standalone library and process build in debug mode. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review comment. Created 9 years, 8 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
« no previous file with comments | « src/isolate.h ('k') | src/objects.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2010 the V8 project authors. All rights reserved. 1 // Copyright 2006-2010 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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 161
162 void Isolate::PreallocatedMemoryThreadStop() { 162 void Isolate::PreallocatedMemoryThreadStop() {
163 if (preallocated_memory_thread_ == NULL) return; 163 if (preallocated_memory_thread_ == NULL) return;
164 preallocated_memory_thread_->StopThread(); 164 preallocated_memory_thread_->StopThread();
165 // Done with the thread entirely. 165 // Done with the thread entirely.
166 delete preallocated_memory_thread_; 166 delete preallocated_memory_thread_;
167 preallocated_memory_thread_ = NULL; 167 preallocated_memory_thread_ = NULL;
168 } 168 }
169 169
170 170
171 void Isolate::PreallocatedStorageInit(size_t size) {
172 ASSERT(free_list_.next_ == &free_list_);
173 ASSERT(free_list_.previous_ == &free_list_);
174 PreallocatedStorage* free_chunk =
175 reinterpret_cast<PreallocatedStorage*>(new char[size]);
176 free_list_.next_ = free_list_.previous_ = free_chunk;
177 free_chunk->next_ = free_chunk->previous_ = &free_list_;
178 free_chunk->size_ = size - sizeof(PreallocatedStorage);
179 preallocated_storage_preallocated_ = true;
180 }
181
182
183 void* Isolate::PreallocatedStorageNew(size_t size) {
184 if (!preallocated_storage_preallocated_) {
185 return FreeStoreAllocationPolicy::New(size);
186 }
187 ASSERT(free_list_.next_ != &free_list_);
188 ASSERT(free_list_.previous_ != &free_list_);
189
190 size = (size + kPointerSize - 1) & ~(kPointerSize - 1);
191 // Search for exact fit.
192 for (PreallocatedStorage* storage = free_list_.next_;
193 storage != &free_list_;
194 storage = storage->next_) {
195 if (storage->size_ == size) {
196 storage->Unlink();
197 storage->LinkTo(&in_use_list_);
198 return reinterpret_cast<void*>(storage + 1);
199 }
200 }
201 // Search for first fit.
202 for (PreallocatedStorage* storage = free_list_.next_;
203 storage != &free_list_;
204 storage = storage->next_) {
205 if (storage->size_ >= size + sizeof(PreallocatedStorage)) {
206 storage->Unlink();
207 storage->LinkTo(&in_use_list_);
208 PreallocatedStorage* left_over =
209 reinterpret_cast<PreallocatedStorage*>(
210 reinterpret_cast<char*>(storage + 1) + size);
211 left_over->size_ = storage->size_ - size - sizeof(PreallocatedStorage);
212 ASSERT(size + left_over->size_ + sizeof(PreallocatedStorage) ==
213 storage->size_);
214 storage->size_ = size;
215 left_over->LinkTo(&free_list_);
216 return reinterpret_cast<void*>(storage + 1);
217 }
218 }
219 // Allocation failure.
220 ASSERT(false);
221 return NULL;
222 }
223
224
225 // We don't attempt to coalesce.
226 void Isolate::PreallocatedStorageDelete(void* p) {
227 if (p == NULL) {
228 return;
229 }
230 if (!preallocated_storage_preallocated_) {
231 FreeStoreAllocationPolicy::Delete(p);
232 return;
233 }
234 PreallocatedStorage* storage = reinterpret_cast<PreallocatedStorage*>(p) - 1;
235 ASSERT(storage->next_->previous_ == storage);
236 ASSERT(storage->previous_->next_ == storage);
237 storage->Unlink();
238 storage->LinkTo(&free_list_);
239 }
240
241
171 Isolate* Isolate::default_isolate_ = NULL; 242 Isolate* Isolate::default_isolate_ = NULL;
172 Thread::LocalStorageKey Isolate::isolate_key_; 243 Thread::LocalStorageKey Isolate::isolate_key_;
173 Thread::LocalStorageKey Isolate::thread_id_key_; 244 Thread::LocalStorageKey Isolate::thread_id_key_;
174 Thread::LocalStorageKey Isolate::per_isolate_thread_data_key_; 245 Thread::LocalStorageKey Isolate::per_isolate_thread_data_key_;
175 Mutex* Isolate::process_wide_mutex_ = OS::CreateMutex(); 246 Mutex* Isolate::process_wide_mutex_ = OS::CreateMutex();
176 Isolate::ThreadDataTable* Isolate::thread_data_table_ = NULL; 247 Isolate::ThreadDataTable* Isolate::thread_data_table_ = NULL;
177 Isolate::ThreadId Isolate::highest_thread_id_ = 0; 248 Isolate::ThreadId Isolate::highest_thread_id_ = 0;
178 249
179 250
180 class IsolateInitializer { 251 class IsolateInitializer {
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after
815 886
816 #ifdef DEBUG 887 #ifdef DEBUG
817 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ 888 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \
818 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); 889 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_);
819 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) 890 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET)
820 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) 891 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET)
821 #undef ISOLATE_FIELD_OFFSET 892 #undef ISOLATE_FIELD_OFFSET
822 #endif 893 #endif
823 894
824 } } // namespace v8::internal 895 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/isolate.h ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698