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 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
739 #endif | 739 #endif |
740 | 740 |
741 // Makes a new symbol object | 741 // Makes a new symbol object |
742 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation | 742 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
743 // failed. | 743 // failed. |
744 // Please note this function does not perform a garbage collection. | 744 // Please note this function does not perform a garbage collection. |
745 static Object* CreateSymbol(const char* str, int length, int hash); | 745 static Object* CreateSymbol(const char* str, int length, int hash); |
746 static Object* CreateSymbol(String* str); | 746 static Object* CreateSymbol(String* str); |
747 | 747 |
748 // Write barrier support for address[offset] = o. | 748 // Write barrier support for address[offset] = o. |
749 inline static void RecordWrite(Address address, int offset); | 749 static inline void RecordWrite(Address address, int offset); |
750 | 750 |
751 // Given an address occupied by a live code object, return that object. | 751 // Given an address occupied by a live code object, return that object. |
752 static Object* FindCodeObject(Address a); | 752 static Object* FindCodeObject(Address a); |
753 | 753 |
754 // Invoke Shrink on shrinkable spaces. | 754 // Invoke Shrink on shrinkable spaces. |
755 static void Shrink(); | 755 static void Shrink(); |
756 | 756 |
757 enum HeapState { NOT_IN_GC, SCAVENGE, MARK_COMPACT }; | 757 enum HeapState { NOT_IN_GC, SCAVENGE, MARK_COMPACT }; |
758 static inline HeapState gc_state() { return gc_state_; } | 758 static inline HeapState gc_state() { return gc_state_; } |
759 | 759 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
795 static Object* GetNumberStringCache(Object* number); | 795 static Object* GetNumberStringCache(Object* number); |
796 | 796 |
797 // Update the cache with a new number-string pair. | 797 // Update the cache with a new number-string pair. |
798 static void SetNumberStringCache(Object* number, String* str); | 798 static void SetNumberStringCache(Object* number, String* str); |
799 | 799 |
800 // Entries in the cache. Must be a power of 2. | 800 // Entries in the cache. Must be a power of 2. |
801 static const int kNumberStringCacheSize = 64; | 801 static const int kNumberStringCacheSize = 64; |
802 | 802 |
803 // Adjusts the amount of registered external memory. | 803 // Adjusts the amount of registered external memory. |
804 // Returns the adjusted value. | 804 // Returns the adjusted value. |
805 static int AdjustAmountOfExternalAllocatedMemory(int change_in_bytes) { | 805 static inline int AdjustAmountOfExternalAllocatedMemory(int change_in_bytes); |
806 int amount = amount_of_external_allocated_memory_ + change_in_bytes; | |
807 if (change_in_bytes >= 0) { | |
808 // Avoid overflow. | |
809 if (amount > amount_of_external_allocated_memory_) { | |
810 amount_of_external_allocated_memory_ = amount; | |
811 } | |
812 } else { | |
813 // Avoid underflow. | |
814 if (amount >= 0) { | |
815 amount_of_external_allocated_memory_ = amount; | |
816 } | |
817 } | |
818 ASSERT(amount_of_external_allocated_memory_ >= 0); | |
819 return amount_of_external_allocated_memory_; | |
820 } | |
821 | 806 |
822 // Allocate unitialized fixed array (pretenure == NON_TENURE). | 807 // Allocate unitialized fixed array (pretenure == NON_TENURE). |
823 static Object* AllocateRawFixedArray(int length); | 808 static Object* AllocateRawFixedArray(int length); |
824 | 809 |
825 // True if we have reached the allocation limit in the old generation that | 810 // True if we have reached the allocation limit in the old generation that |
826 // should force the next GC (caused normally) to be a full one. | 811 // should force the next GC (caused normally) to be a full one. |
827 static bool OldGenerationPromotionLimitReached() { | 812 static bool OldGenerationPromotionLimitReached() { |
828 return (PromotedSpaceSize() + PromotedExternalMemorySize()) | 813 return (PromotedSpaceSize() + PromotedExternalMemorySize()) |
829 > old_gen_promotion_limit_; | 814 > old_gen_promotion_limit_; |
830 } | 815 } |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
894 // Limit that triggers a global GC on the next (normally caused) GC. This | 879 // Limit that triggers a global GC on the next (normally caused) GC. This |
895 // is checked when we have already decided to do a GC to help determine | 880 // is checked when we have already decided to do a GC to help determine |
896 // which collector to invoke. | 881 // which collector to invoke. |
897 static int old_gen_promotion_limit_; | 882 static int old_gen_promotion_limit_; |
898 | 883 |
899 // Limit that triggers a global GC as soon as is reasonable. This is | 884 // Limit that triggers a global GC as soon as is reasonable. This is |
900 // checked before expanding a paged space in the old generation and on | 885 // checked before expanding a paged space in the old generation and on |
901 // every allocation in large object space. | 886 // every allocation in large object space. |
902 static int old_gen_allocation_limit_; | 887 static int old_gen_allocation_limit_; |
903 | 888 |
| 889 // Limit on the amount of externally allocated memory allowed |
| 890 // between global GCs. If reached a global GC is forced. |
| 891 static int external_allocation_limit_; |
| 892 |
904 // The amount of external memory registered through the API kept alive | 893 // The amount of external memory registered through the API kept alive |
905 // by global handles | 894 // by global handles |
906 static int amount_of_external_allocated_memory_; | 895 static int amount_of_external_allocated_memory_; |
907 | 896 |
908 // Caches the amount of external memory registered at the last global gc. | 897 // Caches the amount of external memory registered at the last global gc. |
909 static int amount_of_external_allocated_memory_at_last_global_gc_; | 898 static int amount_of_external_allocated_memory_at_last_global_gc_; |
910 | 899 |
911 // Indicates that an allocation has failed in the old generation since the | 900 // Indicates that an allocation has failed in the old generation since the |
912 // last GC. | 901 // last GC. |
913 static int old_gen_exhausted_; | 902 static int old_gen_exhausted_; |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1223 public: | 1212 public: |
1224 // Lookup field offset for (map, name). If absent, -1 is returned. | 1213 // Lookup field offset for (map, name). If absent, -1 is returned. |
1225 static int Lookup(Map* map, String* name); | 1214 static int Lookup(Map* map, String* name); |
1226 | 1215 |
1227 // Update an element in the cache. | 1216 // Update an element in the cache. |
1228 static void Update(Map* map, String* name, int field_offset); | 1217 static void Update(Map* map, String* name, int field_offset); |
1229 | 1218 |
1230 // Clear the cache. | 1219 // Clear the cache. |
1231 static void Clear(); | 1220 static void Clear(); |
1232 private: | 1221 private: |
1233 inline static int Hash(Map* map, String* name); | 1222 static inline int Hash(Map* map, String* name); |
1234 static const int kLength = 64; | 1223 static const int kLength = 64; |
1235 struct Key { | 1224 struct Key { |
1236 Map* map; | 1225 Map* map; |
1237 String* name; | 1226 String* name; |
1238 }; | 1227 }; |
1239 static Key keys_[kLength]; | 1228 static Key keys_[kLength]; |
1240 static int field_offsets_[kLength]; | 1229 static int field_offsets_[kLength]; |
1241 }; | 1230 }; |
1242 | 1231 |
1243 | 1232 |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1464 int marked_count_; | 1453 int marked_count_; |
1465 | 1454 |
1466 // The count from the end of the previous full GC. Will be zero if there | 1455 // The count from the end of the previous full GC. Will be zero if there |
1467 // was no previous full GC. | 1456 // was no previous full GC. |
1468 int previous_marked_count_; | 1457 int previous_marked_count_; |
1469 }; | 1458 }; |
1470 | 1459 |
1471 } } // namespace v8::internal | 1460 } } // namespace v8::internal |
1472 | 1461 |
1473 #endif // V8_HEAP_H_ | 1462 #endif // V8_HEAP_H_ |
OLD | NEW |