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

Side by Side Diff: src/heap-inl.h

Issue 155916: Introduce a external allocation limit.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 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
« no previous file with comments | « src/heap.cc ('k') | test/cctest/test-api.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-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 if (first_word.IsForwardingAddress()) { 221 if (first_word.IsForwardingAddress()) {
222 *p = first_word.ToForwardingAddress(); 222 *p = first_word.ToForwardingAddress();
223 return; 223 return;
224 } 224 }
225 225
226 // Call the slow part of scavenge object. 226 // Call the slow part of scavenge object.
227 return ScavengeObjectSlow(p, object); 227 return ScavengeObjectSlow(p, object);
228 } 228 }
229 229
230 230
231 int Heap::AdjustAmountOfExternalAllocatedMemory(int change_in_bytes) {
232 ASSERT(HasBeenSetup());
233 int amount = amount_of_external_allocated_memory_ + change_in_bytes;
234 if (change_in_bytes >= 0) {
235 // Avoid overflow.
236 if (amount > amount_of_external_allocated_memory_) {
237 amount_of_external_allocated_memory_ = amount;
238 }
239 int amount_since_last_global_gc =
240 amount_of_external_allocated_memory_ -
241 amount_of_external_allocated_memory_at_last_global_gc_;
242 if (amount_since_last_global_gc > external_allocation_limit_) {
243 CollectAllGarbage();
244 }
245 } else {
246 // Avoid underflow.
247 if (amount >= 0) {
248 amount_of_external_allocated_memory_ = amount;
249 }
250 }
251 ASSERT(amount_of_external_allocated_memory_ >= 0);
252 return amount_of_external_allocated_memory_;
253 }
254
255
231 void Heap::SetLastScriptId(Object* last_script_id) { 256 void Heap::SetLastScriptId(Object* last_script_id) {
232 roots_[kLastScriptIdRootIndex] = last_script_id; 257 roots_[kLastScriptIdRootIndex] = last_script_id;
233 } 258 }
234 259
235 260
236 #define GC_GREEDY_CHECK() \ 261 #define GC_GREEDY_CHECK() \
237 ASSERT(!FLAG_gc_greedy || v8::internal::Heap::GarbageCollectionGreedyCheck()) 262 ASSERT(!FLAG_gc_greedy || v8::internal::Heap::GarbageCollectionGreedyCheck())
238 263
239 264
240 // Calls the FUNCTION_CALL function and retries it up to three times 265 // Calls the FUNCTION_CALL function and retries it up to three times
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 allocation_allowed_ = new_state; 319 allocation_allowed_ = new_state;
295 return old; 320 return old;
296 } 321 }
297 322
298 #endif 323 #endif
299 324
300 325
301 } } // namespace v8::internal 326 } } // namespace v8::internal
302 327
303 #endif // V8_HEAP_INL_H_ 328 #endif // V8_HEAP_INL_H_
OLDNEW
« no previous file with comments | « src/heap.cc ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698