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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 AllocationSpace retry_space) { | 69 AllocationSpace retry_space) { |
70 ASSERT(allocation_allowed_ && gc_state_ == NOT_IN_GC); | 70 ASSERT(allocation_allowed_ && gc_state_ == NOT_IN_GC); |
71 ASSERT(space != NEW_SPACE || | 71 ASSERT(space != NEW_SPACE || |
72 retry_space == OLD_POINTER_SPACE || | 72 retry_space == OLD_POINTER_SPACE || |
73 retry_space == OLD_DATA_SPACE || | 73 retry_space == OLD_DATA_SPACE || |
74 retry_space == LO_SPACE); | 74 retry_space == LO_SPACE); |
75 #ifdef DEBUG | 75 #ifdef DEBUG |
76 if (FLAG_gc_interval >= 0 && | 76 if (FLAG_gc_interval >= 0 && |
77 !disallow_allocation_failure_ && | 77 !disallow_allocation_failure_ && |
78 Heap::allocation_timeout_-- <= 0) { | 78 Heap::allocation_timeout_-- <= 0) { |
79 return Failure::RetryAfterGC(size_in_bytes, space); | 79 return Failure::RetryAfterGC(space); |
80 } | 80 } |
81 Counters::objs_since_last_full.Increment(); | 81 Counters::objs_since_last_full.Increment(); |
82 Counters::objs_since_last_young.Increment(); | 82 Counters::objs_since_last_young.Increment(); |
83 #endif | 83 #endif |
84 Object* result; | 84 Object* result; |
85 if (NEW_SPACE == space) { | 85 if (NEW_SPACE == space) { |
86 result = new_space_.AllocateRaw(size_in_bytes); | 86 result = new_space_.AllocateRaw(size_in_bytes); |
87 if (always_allocate() && result->IsFailure()) { | 87 if (always_allocate() && result->IsFailure()) { |
88 space = retry_space; | 88 space = retry_space; |
89 } else { | 89 } else { |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 ASSERT(amount_of_external_allocated_memory_ >= 0); | 382 ASSERT(amount_of_external_allocated_memory_ >= 0); |
383 return amount_of_external_allocated_memory_; | 383 return amount_of_external_allocated_memory_; |
384 } | 384 } |
385 | 385 |
386 | 386 |
387 void Heap::SetLastScriptId(Object* last_script_id) { | 387 void Heap::SetLastScriptId(Object* last_script_id) { |
388 roots_[kLastScriptIdRootIndex] = last_script_id; | 388 roots_[kLastScriptIdRootIndex] = last_script_id; |
389 } | 389 } |
390 | 390 |
391 | 391 |
| 392 #ifdef DEBUG |
392 #define GC_GREEDY_CHECK() \ | 393 #define GC_GREEDY_CHECK() \ |
393 ASSERT(!FLAG_gc_greedy || v8::internal::Heap::GarbageCollectionGreedyCheck()) | 394 if (FLAG_gc_greedy) v8::internal::Heap::GarbageCollectionGreedyCheck() |
| 395 #else |
| 396 #define GC_GREEDY_CHECK() { } |
| 397 #endif |
394 | 398 |
395 | 399 |
396 // Calls the FUNCTION_CALL function and retries it up to three times | 400 // Calls the FUNCTION_CALL function and retries it up to three times |
397 // to guarantee that any allocations performed during the call will | 401 // to guarantee that any allocations performed during the call will |
398 // succeed if there's enough memory. | 402 // succeed if there's enough memory. |
399 | 403 |
400 // Warning: Do not use the identifiers __object__ or __scope__ in a | 404 // Warning: Do not use the identifiers __object__ or __scope__ in a |
401 // call to this macro. | 405 // call to this macro. |
402 | 406 |
403 #define CALL_AND_RETRY(FUNCTION_CALL, RETURN_VALUE, RETURN_EMPTY) \ | 407 #define CALL_AND_RETRY(FUNCTION_CALL, RETURN_VALUE, RETURN_EMPTY) \ |
404 do { \ | 408 do { \ |
405 GC_GREEDY_CHECK(); \ | 409 GC_GREEDY_CHECK(); \ |
406 Object* __object__ = FUNCTION_CALL; \ | 410 Object* __object__ = FUNCTION_CALL; \ |
407 if (!__object__->IsFailure()) RETURN_VALUE; \ | 411 if (!__object__->IsFailure()) RETURN_VALUE; \ |
408 if (__object__->IsOutOfMemoryFailure()) { \ | 412 if (__object__->IsOutOfMemoryFailure()) { \ |
409 v8::internal::V8::FatalProcessOutOfMemory("CALL_AND_RETRY_0", true);\ | 413 v8::internal::V8::FatalProcessOutOfMemory("CALL_AND_RETRY_0", true);\ |
410 } \ | 414 } \ |
411 if (!__object__->IsRetryAfterGC()) RETURN_EMPTY; \ | 415 if (!__object__->IsRetryAfterGC()) RETURN_EMPTY; \ |
412 Heap::CollectGarbage(Failure::cast(__object__)->requested(), \ | 416 Heap::CollectGarbage(Failure::cast(__object__)->allocation_space()); \ |
413 Failure::cast(__object__)->allocation_space()); \ | |
414 __object__ = FUNCTION_CALL; \ | 417 __object__ = FUNCTION_CALL; \ |
415 if (!__object__->IsFailure()) RETURN_VALUE; \ | 418 if (!__object__->IsFailure()) RETURN_VALUE; \ |
416 if (__object__->IsOutOfMemoryFailure()) { \ | 419 if (__object__->IsOutOfMemoryFailure()) { \ |
417 v8::internal::V8::FatalProcessOutOfMemory("CALL_AND_RETRY_1", true);\ | 420 v8::internal::V8::FatalProcessOutOfMemory("CALL_AND_RETRY_1", true);\ |
418 } \ | 421 } \ |
419 if (!__object__->IsRetryAfterGC()) RETURN_EMPTY; \ | 422 if (!__object__->IsRetryAfterGC()) RETURN_EMPTY; \ |
420 Counters::gc_last_resort_from_handles.Increment(); \ | 423 Counters::gc_last_resort_from_handles.Increment(); \ |
421 Heap::CollectAllAvailableGarbage(); \ | 424 Heap::CollectAllAvailableGarbage(); \ |
422 { \ | 425 { \ |
423 AlwaysAllocateScope __scope__; \ | 426 AlwaysAllocateScope __scope__; \ |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 | 503 |
501 | 504 |
502 void ExternalStringTable::ShrinkNewStrings(int position) { | 505 void ExternalStringTable::ShrinkNewStrings(int position) { |
503 new_space_strings_.Rewind(position); | 506 new_space_strings_.Rewind(position); |
504 Verify(); | 507 Verify(); |
505 } | 508 } |
506 | 509 |
507 } } // namespace v8::internal | 510 } } // namespace v8::internal |
508 | 511 |
509 #endif // V8_HEAP_INL_H_ | 512 #endif // V8_HEAP_INL_H_ |
OLD | NEW |