| OLD | NEW |
| 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 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 | 288 |
| 289 void Heap::CollectAllGarbage() { | 289 void Heap::CollectAllGarbage() { |
| 290 // Since we are ignoring the return value, the exact choice of space does | 290 // Since we are ignoring the return value, the exact choice of space does |
| 291 // not matter, so long as we do not specify NEW_SPACE, which would not | 291 // not matter, so long as we do not specify NEW_SPACE, which would not |
| 292 // cause a full GC. | 292 // cause a full GC. |
| 293 CollectGarbage(0, OLD_POINTER_SPACE); | 293 CollectGarbage(0, OLD_POINTER_SPACE); |
| 294 } | 294 } |
| 295 | 295 |
| 296 | 296 |
| 297 void Heap::CollectAllGarbageIfContextDisposed() { | 297 void Heap::CollectAllGarbageIfContextDisposed() { |
| 298 if (context_disposed_pending_) { | 298 // If the garbage collector interface is exposed through the global |
| 299 // gc() function, we avoid being clever about forcing GCs when |
| 300 // contexts are disposed and leave it to the embedder to make |
| 301 // informed decisions about when to force a collection. |
| 302 if (!FLAG_expose_gc && context_disposed_pending_) { |
| 299 StatsRateScope scope(&Counters::gc_context); | 303 StatsRateScope scope(&Counters::gc_context); |
| 300 CollectAllGarbage(); | 304 CollectAllGarbage(); |
| 301 context_disposed_pending_ = false; | |
| 302 } | 305 } |
| 306 context_disposed_pending_ = false; |
| 303 } | 307 } |
| 304 | 308 |
| 305 | 309 |
| 306 void Heap::NotifyContextDisposed() { | 310 void Heap::NotifyContextDisposed() { |
| 307 context_disposed_pending_ = true; | 311 context_disposed_pending_ = true; |
| 308 } | 312 } |
| 309 | 313 |
| 310 | 314 |
| 311 bool Heap::CollectGarbage(int requested_size, AllocationSpace space) { | 315 bool Heap::CollectGarbage(int requested_size, AllocationSpace space) { |
| 312 // The VM is in the GC state until exiting this function. | 316 // The VM is in the GC state until exiting this function. |
| (...skipping 3013 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3326 #ifdef DEBUG | 3330 #ifdef DEBUG |
| 3327 bool Heap::GarbageCollectionGreedyCheck() { | 3331 bool Heap::GarbageCollectionGreedyCheck() { |
| 3328 ASSERT(FLAG_gc_greedy); | 3332 ASSERT(FLAG_gc_greedy); |
| 3329 if (Bootstrapper::IsActive()) return true; | 3333 if (Bootstrapper::IsActive()) return true; |
| 3330 if (disallow_allocation_failure()) return true; | 3334 if (disallow_allocation_failure()) return true; |
| 3331 return CollectGarbage(0, NEW_SPACE); | 3335 return CollectGarbage(0, NEW_SPACE); |
| 3332 } | 3336 } |
| 3333 #endif | 3337 #endif |
| 3334 | 3338 |
| 3335 } } // namespace v8::internal | 3339 } } // namespace v8::internal |
| OLD | NEW |