OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 unflattened_strings_length_ >= kFlattenLongThreshold) { | 534 unflattened_strings_length_ >= kFlattenLongThreshold) { |
535 return obj; | 535 return obj; |
536 } | 536 } |
537 if (obj->IsFailure()) { | 537 if (obj->IsFailure()) { |
538 unflattened_strings_length_ += length; | 538 unflattened_strings_length_ += length; |
539 } | 539 } |
540 return str; | 540 return str; |
541 } | 541 } |
542 | 542 |
543 | 543 |
544 intptr_t Heap::AdjustAmountOfExternalAllocatedMemory( | 544 int64_t Heap::AdjustAmountOfExternalAllocatedMemory( |
545 intptr_t change_in_bytes) { | 545 int64_t change_in_bytes) { |
546 ASSERT(HasBeenSetUp()); | 546 ASSERT(HasBeenSetUp()); |
547 intptr_t amount = amount_of_external_allocated_memory_ + change_in_bytes; | 547 int64_t amount = amount_of_external_allocated_memory_ + change_in_bytes; |
548 if (change_in_bytes > 0) { | 548 if (change_in_bytes > 0) { |
549 // Avoid overflow. | 549 // Avoid overflow. |
550 if (amount > amount_of_external_allocated_memory_) { | 550 if (amount > amount_of_external_allocated_memory_) { |
551 amount_of_external_allocated_memory_ = amount; | 551 amount_of_external_allocated_memory_ = amount; |
552 } else { | 552 } else { |
553 // Give up and reset the counters in case of an overflow. | 553 // Give up and reset the counters in case of an overflow. |
554 amount_of_external_allocated_memory_ = 0; | 554 amount_of_external_allocated_memory_ = 0; |
555 amount_of_external_allocated_memory_at_last_global_gc_ = 0; | 555 amount_of_external_allocated_memory_at_last_global_gc_ = 0; |
556 } | 556 } |
557 intptr_t amount_since_last_global_gc = PromotedExternalMemorySize(); | 557 int64_t amount_since_last_global_gc = PromotedExternalMemorySize(); |
558 if (amount_since_last_global_gc > external_allocation_limit_) { | 558 if (amount_since_last_global_gc > external_allocation_limit_) { |
559 CollectAllGarbage(kNoGCFlags, "external memory allocation limit reached"); | 559 CollectAllGarbage(kNoGCFlags, "external memory allocation limit reached"); |
560 } | 560 } |
561 } else { | 561 } else { |
562 // Avoid underflow. | 562 // Avoid underflow. |
563 if (amount >= 0) { | 563 if (amount >= 0) { |
564 amount_of_external_allocated_memory_ = amount; | 564 amount_of_external_allocated_memory_ = amount; |
565 } else { | 565 } else { |
566 // Give up and reset the counters in case of an underflow. | 566 // Give up and reset the counters in case of an underflow. |
567 amount_of_external_allocated_memory_ = 0; | 567 amount_of_external_allocated_memory_ = 0; |
568 amount_of_external_allocated_memory_at_last_global_gc_ = 0; | 568 amount_of_external_allocated_memory_at_last_global_gc_ = 0; |
569 } | 569 } |
570 } | 570 } |
571 if (FLAG_trace_external_memory) { | 571 if (FLAG_trace_external_memory) { |
572 PrintPID("%8.0f ms: ", isolate()->time_millis_since_init()); | 572 PrintPID("%8.0f ms: ", isolate()->time_millis_since_init()); |
573 PrintF("Adjust amount of external memory: delta=%6" V8_PTR_PREFIX "d KB, " | 573 PrintF("Adjust amount of external memory: delta=%6" V8_PTR_PREFIX "d KB, " |
574 "amount=%6" V8_PTR_PREFIX "d KB, since_gc=%6" V8_PTR_PREFIX "d KB, " | 574 "amount=%6" V8_PTR_PREFIX "d KB, since_gc=%6" V8_PTR_PREFIX "d KB, " |
575 "isolate=0x%08" V8PRIxPTR ".\n", | 575 "isolate=0x%08" V8PRIxPTR ".\n", |
576 change_in_bytes / KB, | 576 static_cast<intptr_t>(change_in_bytes / KB), |
577 amount_of_external_allocated_memory_ / KB, | 577 static_cast<intptr_t>(amount_of_external_allocated_memory_ / KB), |
578 PromotedExternalMemorySize() / KB, | 578 static_cast<intptr_t>(PromotedExternalMemorySize() / KB), |
579 reinterpret_cast<intptr_t>(isolate())); | 579 reinterpret_cast<intptr_t>(isolate())); |
580 } | 580 } |
581 ASSERT(amount_of_external_allocated_memory_ >= 0); | 581 ASSERT(amount_of_external_allocated_memory_ >= 0); |
582 return amount_of_external_allocated_memory_; | 582 return amount_of_external_allocated_memory_; |
583 } | 583 } |
584 | 584 |
585 | 585 |
586 Isolate* Heap::isolate() { | 586 Isolate* Heap::isolate() { |
587 return reinterpret_cast<Isolate*>(reinterpret_cast<intptr_t>(this) - | 587 return reinterpret_cast<Isolate*>(reinterpret_cast<intptr_t>(this) - |
588 reinterpret_cast<size_t>(reinterpret_cast<Isolate*>(4)->heap()) + 4); | 588 reinterpret_cast<size_t>(reinterpret_cast<Isolate*>(4)->heap()) + 4); |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
864 #ifdef DEBUG | 864 #ifdef DEBUG |
865 Isolate* isolate = Isolate::Current(); | 865 Isolate* isolate = Isolate::Current(); |
866 isolate->heap()->disallow_allocation_failure_ = old_state_; | 866 isolate->heap()->disallow_allocation_failure_ = old_state_; |
867 #endif | 867 #endif |
868 } | 868 } |
869 | 869 |
870 | 870 |
871 } } // namespace v8::internal | 871 } } // namespace v8::internal |
872 | 872 |
873 #endif // V8_HEAP_INL_H_ | 873 #endif // V8_HEAP_INL_H_ |
OLD | NEW |