Chromium Code Reviews| 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 20 matching lines...) Expand all Loading... | |
| 31 #include <math.h> | 31 #include <math.h> |
| 32 | 32 |
| 33 #include "zone-inl.h" | 33 #include "zone-inl.h" |
| 34 | 34 |
| 35 | 35 |
| 36 namespace v8 { | 36 namespace v8 { |
| 37 namespace internal { | 37 namespace internal { |
| 38 | 38 |
| 39 // Defines all the roots in Heap. | 39 // Defines all the roots in Heap. |
| 40 #define UNCONDITIONAL_STRONG_ROOT_LIST(V) \ | 40 #define UNCONDITIONAL_STRONG_ROOT_LIST(V) \ |
| 41 /* Cluster the most popular ones in a few cache lines here at the top. */ \ | 41 /* Put the byte array map early. We need it to be in place by the time */ \ |
| 42 /* the deserializer hits the next page, since it wants to put a byte */ \ | |
| 43 /* array in the unused space at the end of the page. */ \ | |
| 44 V(Map, byte_array_map, ByteArrayMap) \ | |
| 45 V(Map, one_pointer_filler_map, OnePointerFillerMap) \ | |
| 46 V(Map, two_pointer_filler_map, TwoPointerFillerMap) \ | |
| 47 /* Cluster the most popular ones in a few cache lines here at the top. */ \ | |
| 42 V(Smi, stack_limit, StackLimit) \ | 48 V(Smi, stack_limit, StackLimit) \ |
| 43 V(Object, undefined_value, UndefinedValue) \ | 49 V(Object, undefined_value, UndefinedValue) \ |
| 44 V(Object, the_hole_value, TheHoleValue) \ | 50 V(Object, the_hole_value, TheHoleValue) \ |
| 45 V(Object, null_value, NullValue) \ | 51 V(Object, null_value, NullValue) \ |
| 46 V(Object, true_value, TrueValue) \ | 52 V(Object, true_value, TrueValue) \ |
| 47 V(Object, false_value, FalseValue) \ | 53 V(Object, false_value, FalseValue) \ |
| 48 V(Map, heap_number_map, HeapNumberMap) \ | 54 V(Map, heap_number_map, HeapNumberMap) \ |
| 49 V(Map, global_context_map, GlobalContextMap) \ | 55 V(Map, global_context_map, GlobalContextMap) \ |
| 50 V(Map, fixed_array_map, FixedArrayMap) \ | 56 V(Map, fixed_array_map, FixedArrayMap) \ |
| 51 V(Object, no_interceptor_result_sentinel, NoInterceptorResultSentinel) \ | 57 V(Object, no_interceptor_result_sentinel, NoInterceptorResultSentinel) \ |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 102 V(Map, medium_external_ascii_string_map, MediumExternalAsciiStringMap) \ | 108 V(Map, medium_external_ascii_string_map, MediumExternalAsciiStringMap) \ |
| 103 V(Map, long_external_ascii_string_map, LongExternalAsciiStringMap) \ | 109 V(Map, long_external_ascii_string_map, LongExternalAsciiStringMap) \ |
| 104 V(Map, undetectable_short_string_map, UndetectableShortStringMap) \ | 110 V(Map, undetectable_short_string_map, UndetectableShortStringMap) \ |
| 105 V(Map, undetectable_medium_string_map, UndetectableMediumStringMap) \ | 111 V(Map, undetectable_medium_string_map, UndetectableMediumStringMap) \ |
| 106 V(Map, undetectable_long_string_map, UndetectableLongStringMap) \ | 112 V(Map, undetectable_long_string_map, UndetectableLongStringMap) \ |
| 107 V(Map, undetectable_short_ascii_string_map, UndetectableShortAsciiStringMap) \ | 113 V(Map, undetectable_short_ascii_string_map, UndetectableShortAsciiStringMap) \ |
| 108 V(Map, \ | 114 V(Map, \ |
| 109 undetectable_medium_ascii_string_map, \ | 115 undetectable_medium_ascii_string_map, \ |
| 110 UndetectableMediumAsciiStringMap) \ | 116 UndetectableMediumAsciiStringMap) \ |
| 111 V(Map, undetectable_long_ascii_string_map, UndetectableLongAsciiStringMap) \ | 117 V(Map, undetectable_long_ascii_string_map, UndetectableLongAsciiStringMap) \ |
| 112 V(Map, byte_array_map, ByteArrayMap) \ | |
| 113 V(Map, pixel_array_map, PixelArrayMap) \ | 118 V(Map, pixel_array_map, PixelArrayMap) \ |
| 114 V(Map, external_byte_array_map, ExternalByteArrayMap) \ | 119 V(Map, external_byte_array_map, ExternalByteArrayMap) \ |
| 115 V(Map, external_unsigned_byte_array_map, ExternalUnsignedByteArrayMap) \ | 120 V(Map, external_unsigned_byte_array_map, ExternalUnsignedByteArrayMap) \ |
| 116 V(Map, external_short_array_map, ExternalShortArrayMap) \ | 121 V(Map, external_short_array_map, ExternalShortArrayMap) \ |
| 117 V(Map, external_unsigned_short_array_map, ExternalUnsignedShortArrayMap) \ | 122 V(Map, external_unsigned_short_array_map, ExternalUnsignedShortArrayMap) \ |
| 118 V(Map, external_int_array_map, ExternalIntArrayMap) \ | 123 V(Map, external_int_array_map, ExternalIntArrayMap) \ |
| 119 V(Map, external_unsigned_int_array_map, ExternalUnsignedIntArrayMap) \ | 124 V(Map, external_unsigned_int_array_map, ExternalUnsignedIntArrayMap) \ |
| 120 V(Map, external_float_array_map, ExternalFloatArrayMap) \ | 125 V(Map, external_float_array_map, ExternalFloatArrayMap) \ |
| 121 V(Map, context_map, ContextMap) \ | 126 V(Map, context_map, ContextMap) \ |
| 122 V(Map, catch_context_map, CatchContextMap) \ | 127 V(Map, catch_context_map, CatchContextMap) \ |
| 123 V(Map, code_map, CodeMap) \ | 128 V(Map, code_map, CodeMap) \ |
| 124 V(Map, oddball_map, OddballMap) \ | 129 V(Map, oddball_map, OddballMap) \ |
| 125 V(Map, global_property_cell_map, GlobalPropertyCellMap) \ | 130 V(Map, global_property_cell_map, GlobalPropertyCellMap) \ |
| 126 V(Map, boilerplate_function_map, BoilerplateFunctionMap) \ | 131 V(Map, boilerplate_function_map, BoilerplateFunctionMap) \ |
| 127 V(Map, shared_function_info_map, SharedFunctionInfoMap) \ | 132 V(Map, shared_function_info_map, SharedFunctionInfoMap) \ |
| 128 V(Map, proxy_map, ProxyMap) \ | 133 V(Map, proxy_map, ProxyMap) \ |
| 129 V(Map, one_pointer_filler_map, OnePointerFillerMap) \ | |
| 130 V(Map, two_pointer_filler_map, TwoPointerFillerMap) \ | |
| 131 V(Object, nan_value, NanValue) \ | 134 V(Object, nan_value, NanValue) \ |
| 132 V(Object, minus_zero_value, MinusZeroValue) \ | 135 V(Object, minus_zero_value, MinusZeroValue) \ |
| 133 V(String, empty_string, EmptyString) \ | 136 V(String, empty_string, EmptyString) \ |
| 134 V(DescriptorArray, empty_descriptor_array, EmptyDescriptorArray) \ | 137 V(DescriptorArray, empty_descriptor_array, EmptyDescriptorArray) \ |
| 135 V(Map, neander_map, NeanderMap) \ | 138 V(Map, neander_map, NeanderMap) \ |
| 136 V(JSObject, message_listeners, MessageListeners) \ | 139 V(JSObject, message_listeners, MessageListeners) \ |
| 137 V(Proxy, prototype_accessors, PrototypeAccessors) \ | 140 V(Proxy, prototype_accessors, PrototypeAccessors) \ |
| 138 V(NumberDictionary, code_stubs, CodeStubs) \ | 141 V(NumberDictionary, code_stubs, CodeStubs) \ |
| 139 V(NumberDictionary, non_monomorphic_cache, NonMonomorphicCache) \ | 142 V(NumberDictionary, non_monomorphic_cache, NonMonomorphicCache) \ |
| 140 V(Code, js_entry_code, JsEntryCode) \ | 143 V(Code, js_entry_code, JsEntryCode) \ |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 294 | 297 |
| 295 static NewSpace* new_space() { return &new_space_; } | 298 static NewSpace* new_space() { return &new_space_; } |
| 296 static OldSpace* old_pointer_space() { return old_pointer_space_; } | 299 static OldSpace* old_pointer_space() { return old_pointer_space_; } |
| 297 static OldSpace* old_data_space() { return old_data_space_; } | 300 static OldSpace* old_data_space() { return old_data_space_; } |
| 298 static OldSpace* code_space() { return code_space_; } | 301 static OldSpace* code_space() { return code_space_; } |
| 299 static MapSpace* map_space() { return map_space_; } | 302 static MapSpace* map_space() { return map_space_; } |
| 300 static CellSpace* cell_space() { return cell_space_; } | 303 static CellSpace* cell_space() { return cell_space_; } |
| 301 static LargeObjectSpace* lo_space() { return lo_space_; } | 304 static LargeObjectSpace* lo_space() { return lo_space_; } |
| 302 | 305 |
| 303 static bool always_allocate() { return always_allocate_scope_depth_ != 0; } | 306 static bool always_allocate() { return always_allocate_scope_depth_ != 0; } |
| 307 static bool linear_allocation() { | |
|
Mads Ager (chromium)
2009/10/26 11:14:05
Move this one after the other always_allocate_* ge
| |
| 308 return linear_allocation_scope_depth_ != 0; | |
| 309 } | |
| 304 static Address always_allocate_scope_depth_address() { | 310 static Address always_allocate_scope_depth_address() { |
| 305 return reinterpret_cast<Address>(&always_allocate_scope_depth_); | 311 return reinterpret_cast<Address>(&always_allocate_scope_depth_); |
| 306 } | 312 } |
| 307 | 313 |
| 308 static Address* NewSpaceAllocationTopAddress() { | 314 static Address* NewSpaceAllocationTopAddress() { |
| 309 return new_space_.allocation_top_address(); | 315 return new_space_.allocation_top_address(); |
| 310 } | 316 } |
| 311 static Address* NewSpaceAllocationLimitAddress() { | 317 static Address* NewSpaceAllocationLimitAddress() { |
| 312 return new_space_.allocation_limit_address(); | 318 return new_space_.allocation_limit_address(); |
| 313 } | 319 } |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 742 static inline bool InNewSpace(Object* object); | 748 static inline bool InNewSpace(Object* object); |
| 743 static inline bool InFromSpace(Object* object); | 749 static inline bool InFromSpace(Object* object); |
| 744 static inline bool InToSpace(Object* object); | 750 static inline bool InToSpace(Object* object); |
| 745 | 751 |
| 746 // Checks whether an address/object in the heap (including auxiliary | 752 // Checks whether an address/object in the heap (including auxiliary |
| 747 // area and unused area). | 753 // area and unused area). |
| 748 static bool Contains(Address addr); | 754 static bool Contains(Address addr); |
| 749 static bool Contains(HeapObject* value); | 755 static bool Contains(HeapObject* value); |
| 750 | 756 |
| 751 // Checks whether an address/object in a space. | 757 // Checks whether an address/object in a space. |
| 752 // Currently used by tests and heap verification only. | 758 // Currently used by tests, serialization and heap verification only. |
| 753 static bool InSpace(Address addr, AllocationSpace space); | 759 static bool InSpace(Address addr, AllocationSpace space); |
| 754 static bool InSpace(HeapObject* value, AllocationSpace space); | 760 static bool InSpace(HeapObject* value, AllocationSpace space); |
| 755 | 761 |
| 756 // Finds out which space an object should get promoted to based on its type. | 762 // Finds out which space an object should get promoted to based on its type. |
| 757 static inline OldSpace* TargetSpace(HeapObject* object); | 763 static inline OldSpace* TargetSpace(HeapObject* object); |
| 758 static inline AllocationSpace TargetSpaceId(InstanceType type); | 764 static inline AllocationSpace TargetSpaceId(InstanceType type); |
| 759 | 765 |
| 760 // Sets the stub_cache_ (only used when expanding the dictionary). | 766 // Sets the stub_cache_ (only used when expanding the dictionary). |
| 761 static void public_set_code_stubs(NumberDictionary* value) { | 767 static void public_set_code_stubs(NumberDictionary* value) { |
| 762 roots_[kCodeStubsRootIndex] = value; | 768 roots_[kCodeStubsRootIndex] = value; |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 913 static int max_semispace_size_; | 919 static int max_semispace_size_; |
| 914 static int initial_semispace_size_; | 920 static int initial_semispace_size_; |
| 915 static int max_old_generation_size_; | 921 static int max_old_generation_size_; |
| 916 static size_t code_range_size_; | 922 static size_t code_range_size_; |
| 917 | 923 |
| 918 // For keeping track of how much data has survived | 924 // For keeping track of how much data has survived |
| 919 // scavenge since last new space expansion. | 925 // scavenge since last new space expansion. |
| 920 static int survived_since_last_expansion_; | 926 static int survived_since_last_expansion_; |
| 921 | 927 |
| 922 static int always_allocate_scope_depth_; | 928 static int always_allocate_scope_depth_; |
| 929 static int linear_allocation_scope_depth_; | |
| 923 static bool context_disposed_pending_; | 930 static bool context_disposed_pending_; |
| 924 | 931 |
| 925 static const int kMaxMapSpaceSize = 8*MB; | 932 static const int kMaxMapSpaceSize = 8*MB; |
| 926 | 933 |
| 927 #if defined(V8_TARGET_ARCH_X64) | 934 #if defined(V8_TARGET_ARCH_X64) |
| 928 static const int kMaxObjectSizeInNewSpace = 512*KB; | 935 static const int kMaxObjectSizeInNewSpace = 512*KB; |
| 929 #else | 936 #else |
| 930 static const int kMaxObjectSizeInNewSpace = 256*KB; | 937 static const int kMaxObjectSizeInNewSpace = 256*KB; |
| 931 #endif | 938 #endif |
| 932 | 939 |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1128 static inline Object* InitializeFunction(JSFunction* function, | 1135 static inline Object* InitializeFunction(JSFunction* function, |
| 1129 SharedFunctionInfo* shared, | 1136 SharedFunctionInfo* shared, |
| 1130 Object* prototype); | 1137 Object* prototype); |
| 1131 | 1138 |
| 1132 static const int kInitialSymbolTableSize = 2048; | 1139 static const int kInitialSymbolTableSize = 2048; |
| 1133 static const int kInitialEvalCacheSize = 64; | 1140 static const int kInitialEvalCacheSize = 64; |
| 1134 | 1141 |
| 1135 friend class Factory; | 1142 friend class Factory; |
| 1136 friend class DisallowAllocationFailure; | 1143 friend class DisallowAllocationFailure; |
| 1137 friend class AlwaysAllocateScope; | 1144 friend class AlwaysAllocateScope; |
| 1145 friend class LinearAllocationScope; | |
| 1138 }; | 1146 }; |
| 1139 | 1147 |
| 1140 | 1148 |
| 1141 class AlwaysAllocateScope { | 1149 class AlwaysAllocateScope { |
| 1142 public: | 1150 public: |
| 1143 AlwaysAllocateScope() { | 1151 AlwaysAllocateScope() { |
| 1144 // We shouldn't hit any nested scopes, because that requires | 1152 // We shouldn't hit any nested scopes, because that requires |
| 1145 // non-handle code to call handle code. The code still works but | 1153 // non-handle code to call handle code. The code still works but |
| 1146 // performance will degrade, so we want to catch this situation | 1154 // performance will degrade, so we want to catch this situation |
| 1147 // in debug mode. | 1155 // in debug mode. |
| 1148 ASSERT(Heap::always_allocate_scope_depth_ == 0); | 1156 ASSERT(Heap::always_allocate_scope_depth_ == 0); |
| 1149 Heap::always_allocate_scope_depth_++; | 1157 Heap::always_allocate_scope_depth_++; |
| 1150 } | 1158 } |
| 1151 | 1159 |
| 1152 ~AlwaysAllocateScope() { | 1160 ~AlwaysAllocateScope() { |
| 1153 Heap::always_allocate_scope_depth_--; | 1161 Heap::always_allocate_scope_depth_--; |
| 1154 ASSERT(Heap::always_allocate_scope_depth_ == 0); | 1162 ASSERT(Heap::always_allocate_scope_depth_ == 0); |
| 1155 } | 1163 } |
| 1156 }; | 1164 }; |
| 1157 | 1165 |
| 1158 | 1166 |
| 1167 class LinearAllocationScope { | |
| 1168 public: | |
| 1169 LinearAllocationScope() { | |
| 1170 Heap::linear_allocation_scope_depth_++; | |
| 1171 } | |
| 1172 | |
| 1173 ~LinearAllocationScope() { | |
| 1174 Heap::linear_allocation_scope_depth_--; | |
| 1175 ASSERT(Heap::linear_allocation_scope_depth_ >= 0); | |
| 1176 } | |
| 1177 }; | |
| 1178 | |
| 1179 | |
| 1159 #ifdef DEBUG | 1180 #ifdef DEBUG |
| 1160 // Visitor class to verify interior pointers that do not have remembered set | 1181 // Visitor class to verify interior pointers that do not have remembered set |
| 1161 // bits. All heap object pointers have to point into the heap to a location | 1182 // bits. All heap object pointers have to point into the heap to a location |
| 1162 // that has a map pointer at its first word. Caveat: Heap::Contains is an | 1183 // that has a map pointer at its first word. Caveat: Heap::Contains is an |
| 1163 // approximation because it can return true for objects in a heap space but | 1184 // approximation because it can return true for objects in a heap space but |
| 1164 // above the allocation pointer. | 1185 // above the allocation pointer. |
| 1165 class VerifyPointersVisitor: public ObjectVisitor { | 1186 class VerifyPointersVisitor: public ObjectVisitor { |
| 1166 public: | 1187 public: |
| 1167 void VisitPointers(Object** start, Object** end) { | 1188 void VisitPointers(Object** start, Object** end) { |
| 1168 for (Object** current = start; current < end; current++) { | 1189 for (Object** current = start; current < end; current++) { |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1616 } | 1637 } |
| 1617 static TranscendentalCache* caches_[kNumberOfCaches]; | 1638 static TranscendentalCache* caches_[kNumberOfCaches]; |
| 1618 Element elements_[kCacheSize]; | 1639 Element elements_[kCacheSize]; |
| 1619 Type type_; | 1640 Type type_; |
| 1620 }; | 1641 }; |
| 1621 | 1642 |
| 1622 | 1643 |
| 1623 } } // namespace v8::internal | 1644 } } // namespace v8::internal |
| 1624 | 1645 |
| 1625 #endif // V8_HEAP_H_ | 1646 #endif // V8_HEAP_H_ |
| OLD | NEW |