| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 12 matching lines...) Expand all Loading... |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #ifndef V8_HEAP_H_ | 28 #ifndef V8_HEAP_H_ |
| 29 #define V8_HEAP_H_ | 29 #define V8_HEAP_H_ |
| 30 | 30 |
| 31 #include <math.h> | 31 #include <math.h> |
| 32 | 32 |
| 33 #include "globals.h" |
| 34 #include "list.h" |
| 33 #include "spaces.h" | 35 #include "spaces.h" |
| 34 #include "splay-tree-inl.h" | 36 #include "splay-tree-inl.h" |
| 35 #include "v8-counters.h" | 37 #include "v8-counters.h" |
| 36 | 38 |
| 37 namespace v8 { | 39 namespace v8 { |
| 38 namespace internal { | 40 namespace internal { |
| 39 | 41 |
| 40 | 42 |
| 41 // Defines all the roots in Heap. | 43 // Defines all the roots in Heap. |
| 42 #define UNCONDITIONAL_STRONG_ROOT_LIST(V) \ | 44 #define STRONG_ROOT_LIST(V) \ |
| 43 /* Put the byte array map early. We need it to be in place by the time */ \ | 45 /* Put the byte array map early. We need it to be in place by the time */ \ |
| 44 /* the deserializer hits the next page, since it wants to put a byte */ \ | 46 /* the deserializer hits the next page, since it wants to put a byte */ \ |
| 45 /* array in the unused space at the end of the page. */ \ | 47 /* array in the unused space at the end of the page. */ \ |
| 46 V(Map, byte_array_map, ByteArrayMap) \ | 48 V(Map, byte_array_map, ByteArrayMap) \ |
| 47 V(Map, one_pointer_filler_map, OnePointerFillerMap) \ | 49 V(Map, one_pointer_filler_map, OnePointerFillerMap) \ |
| 48 V(Map, two_pointer_filler_map, TwoPointerFillerMap) \ | 50 V(Map, two_pointer_filler_map, TwoPointerFillerMap) \ |
| 49 /* Cluster the most popular ones in a few cache lines here at the top. */ \ | 51 /* Cluster the most popular ones in a few cache lines here at the top. */ \ |
| 50 V(Smi, stack_limit, StackLimit) \ | |
| 51 V(Smi, store_buffer_top, StoreBufferTop) \ | 52 V(Smi, store_buffer_top, StoreBufferTop) \ |
| 52 V(Object, undefined_value, UndefinedValue) \ | 53 V(Object, undefined_value, UndefinedValue) \ |
| 53 V(Object, the_hole_value, TheHoleValue) \ | 54 V(Object, the_hole_value, TheHoleValue) \ |
| 54 V(Object, null_value, NullValue) \ | 55 V(Object, null_value, NullValue) \ |
| 55 V(Object, true_value, TrueValue) \ | 56 V(Object, true_value, TrueValue) \ |
| 56 V(Object, false_value, FalseValue) \ | 57 V(Object, false_value, FalseValue) \ |
| 57 V(Object, arguments_marker, ArgumentsMarker) \ | 58 V(Object, arguments_marker, ArgumentsMarker) \ |
| 58 V(Map, heap_number_map, HeapNumberMap) \ | 59 V(Map, heap_number_map, HeapNumberMap) \ |
| 59 V(Map, global_context_map, GlobalContextMap) \ | 60 V(Map, global_context_map, GlobalContextMap) \ |
| 60 V(Map, fixed_array_map, FixedArrayMap) \ | 61 V(Map, fixed_array_map, FixedArrayMap) \ |
| 61 V(Map, fixed_cow_array_map, FixedCOWArrayMap) \ | 62 V(Map, fixed_cow_array_map, FixedCOWArrayMap) \ |
| 62 V(Object, no_interceptor_result_sentinel, NoInterceptorResultSentinel) \ | 63 V(Object, no_interceptor_result_sentinel, NoInterceptorResultSentinel) \ |
| 63 V(Map, meta_map, MetaMap) \ | 64 V(Map, meta_map, MetaMap) \ |
| 65 V(Map, hash_table_map, HashTableMap) \ |
| 66 V(Smi, stack_limit, StackLimit) \ |
| 67 V(FixedArray, number_string_cache, NumberStringCache) \ |
| 68 V(Object, instanceof_cache_function, InstanceofCacheFunction) \ |
| 69 V(Object, instanceof_cache_map, InstanceofCacheMap) \ |
| 70 V(Object, instanceof_cache_answer, InstanceofCacheAnswer) \ |
| 71 V(FixedArray, single_character_string_cache, SingleCharacterStringCache) \ |
| 64 V(Object, termination_exception, TerminationException) \ | 72 V(Object, termination_exception, TerminationException) \ |
| 65 V(Map, hash_table_map, HashTableMap) \ | |
| 66 V(FixedArray, empty_fixed_array, EmptyFixedArray) \ | 73 V(FixedArray, empty_fixed_array, EmptyFixedArray) \ |
| 67 V(ByteArray, empty_byte_array, EmptyByteArray) \ | 74 V(ByteArray, empty_byte_array, EmptyByteArray) \ |
| 75 V(String, empty_string, EmptyString) \ |
| 76 V(DescriptorArray, empty_descriptor_array, EmptyDescriptorArray) \ |
| 68 V(Map, string_map, StringMap) \ | 77 V(Map, string_map, StringMap) \ |
| 69 V(Map, ascii_string_map, AsciiStringMap) \ | 78 V(Map, ascii_string_map, AsciiStringMap) \ |
| 70 V(Map, symbol_map, SymbolMap) \ | 79 V(Map, symbol_map, SymbolMap) \ |
| 80 V(Map, cons_string_map, ConsStringMap) \ |
| 81 V(Map, cons_ascii_string_map, ConsAsciiStringMap) \ |
| 71 V(Map, ascii_symbol_map, AsciiSymbolMap) \ | 82 V(Map, ascii_symbol_map, AsciiSymbolMap) \ |
| 72 V(Map, cons_symbol_map, ConsSymbolMap) \ | 83 V(Map, cons_symbol_map, ConsSymbolMap) \ |
| 73 V(Map, cons_ascii_symbol_map, ConsAsciiSymbolMap) \ | 84 V(Map, cons_ascii_symbol_map, ConsAsciiSymbolMap) \ |
| 74 V(Map, external_symbol_map, ExternalSymbolMap) \ | 85 V(Map, external_symbol_map, ExternalSymbolMap) \ |
| 75 V(Map, external_symbol_with_ascii_data_map, ExternalSymbolWithAsciiDataMap) \ | 86 V(Map, external_symbol_with_ascii_data_map, ExternalSymbolWithAsciiDataMap) \ |
| 76 V(Map, external_ascii_symbol_map, ExternalAsciiSymbolMap) \ | 87 V(Map, external_ascii_symbol_map, ExternalAsciiSymbolMap) \ |
| 77 V(Map, cons_string_map, ConsStringMap) \ | |
| 78 V(Map, cons_ascii_string_map, ConsAsciiStringMap) \ | |
| 79 V(Map, external_string_map, ExternalStringMap) \ | 88 V(Map, external_string_map, ExternalStringMap) \ |
| 80 V(Map, external_string_with_ascii_data_map, ExternalStringWithAsciiDataMap) \ | 89 V(Map, external_string_with_ascii_data_map, ExternalStringWithAsciiDataMap) \ |
| 81 V(Map, external_ascii_string_map, ExternalAsciiStringMap) \ | 90 V(Map, external_ascii_string_map, ExternalAsciiStringMap) \ |
| 82 V(Map, undetectable_string_map, UndetectableStringMap) \ | 91 V(Map, undetectable_string_map, UndetectableStringMap) \ |
| 83 V(Map, undetectable_ascii_string_map, UndetectableAsciiStringMap) \ | 92 V(Map, undetectable_ascii_string_map, UndetectableAsciiStringMap) \ |
| 84 V(Map, pixel_array_map, PixelArrayMap) \ | 93 V(Map, external_pixel_array_map, ExternalPixelArrayMap) \ |
| 85 V(Map, external_byte_array_map, ExternalByteArrayMap) \ | 94 V(Map, external_byte_array_map, ExternalByteArrayMap) \ |
| 86 V(Map, external_unsigned_byte_array_map, ExternalUnsignedByteArrayMap) \ | 95 V(Map, external_unsigned_byte_array_map, ExternalUnsignedByteArrayMap) \ |
| 87 V(Map, external_short_array_map, ExternalShortArrayMap) \ | 96 V(Map, external_short_array_map, ExternalShortArrayMap) \ |
| 88 V(Map, external_unsigned_short_array_map, ExternalUnsignedShortArrayMap) \ | 97 V(Map, external_unsigned_short_array_map, ExternalUnsignedShortArrayMap) \ |
| 89 V(Map, external_int_array_map, ExternalIntArrayMap) \ | 98 V(Map, external_int_array_map, ExternalIntArrayMap) \ |
| 90 V(Map, external_unsigned_int_array_map, ExternalUnsignedIntArrayMap) \ | 99 V(Map, external_unsigned_int_array_map, ExternalUnsignedIntArrayMap) \ |
| 91 V(Map, external_float_array_map, ExternalFloatArrayMap) \ | 100 V(Map, external_float_array_map, ExternalFloatArrayMap) \ |
| 92 V(Map, context_map, ContextMap) \ | 101 V(Map, context_map, ContextMap) \ |
| 93 V(Map, catch_context_map, CatchContextMap) \ | 102 V(Map, catch_context_map, CatchContextMap) \ |
| 94 V(Map, code_map, CodeMap) \ | 103 V(Map, code_map, CodeMap) \ |
| 95 V(Map, oddball_map, OddballMap) \ | 104 V(Map, oddball_map, OddballMap) \ |
| 96 V(Map, global_property_cell_map, GlobalPropertyCellMap) \ | 105 V(Map, global_property_cell_map, GlobalPropertyCellMap) \ |
| 97 V(Map, shared_function_info_map, SharedFunctionInfoMap) \ | 106 V(Map, shared_function_info_map, SharedFunctionInfoMap) \ |
| 98 V(Map, message_object_map, JSMessageObjectMap) \ | 107 V(Map, message_object_map, JSMessageObjectMap) \ |
| 99 V(Map, proxy_map, ProxyMap) \ | 108 V(Map, proxy_map, ProxyMap) \ |
| 100 V(Object, nan_value, NanValue) \ | 109 V(Object, nan_value, NanValue) \ |
| 101 V(Object, minus_zero_value, MinusZeroValue) \ | 110 V(Object, minus_zero_value, MinusZeroValue) \ |
| 102 V(Object, instanceof_cache_function, InstanceofCacheFunction) \ | |
| 103 V(Object, instanceof_cache_map, InstanceofCacheMap) \ | |
| 104 V(Object, instanceof_cache_answer, InstanceofCacheAnswer) \ | |
| 105 V(String, empty_string, EmptyString) \ | |
| 106 V(DescriptorArray, empty_descriptor_array, EmptyDescriptorArray) \ | |
| 107 V(Map, neander_map, NeanderMap) \ | 111 V(Map, neander_map, NeanderMap) \ |
| 108 V(JSObject, message_listeners, MessageListeners) \ | 112 V(JSObject, message_listeners, MessageListeners) \ |
| 109 V(Proxy, prototype_accessors, PrototypeAccessors) \ | 113 V(Proxy, prototype_accessors, PrototypeAccessors) \ |
| 110 V(NumberDictionary, code_stubs, CodeStubs) \ | 114 V(NumberDictionary, code_stubs, CodeStubs) \ |
| 111 V(NumberDictionary, non_monomorphic_cache, NonMonomorphicCache) \ | 115 V(NumberDictionary, non_monomorphic_cache, NonMonomorphicCache) \ |
| 112 V(Code, js_entry_code, JsEntryCode) \ | 116 V(Code, js_entry_code, JsEntryCode) \ |
| 113 V(Code, js_construct_entry_code, JsConstructEntryCode) \ | 117 V(Code, js_construct_entry_code, JsConstructEntryCode) \ |
| 114 V(Code, c_entry_code, CEntryCode) \ | |
| 115 V(FixedArray, number_string_cache, NumberStringCache) \ | |
| 116 V(FixedArray, single_character_string_cache, SingleCharacterStringCache) \ | |
| 117 V(FixedArray, natives_source_cache, NativesSourceCache) \ | 118 V(FixedArray, natives_source_cache, NativesSourceCache) \ |
| 118 V(Object, last_script_id, LastScriptId) \ | 119 V(Object, last_script_id, LastScriptId) \ |
| 119 V(Script, empty_script, EmptyScript) \ | 120 V(Script, empty_script, EmptyScript) \ |
| 120 V(Smi, real_stack_limit, RealStackLimit) \ | 121 V(Smi, real_stack_limit, RealStackLimit) \ |
| 121 V(StringDictionary, intrinsic_function_names, IntrinsicFunctionNames) \ | 122 V(StringDictionary, intrinsic_function_names, IntrinsicFunctionNames) \ |
| 122 | 123 |
| 123 #if V8_TARGET_ARCH_ARM && !V8_INTERPRETED_REGEXP | |
| 124 #define STRONG_ROOT_LIST(V) \ | |
| 125 UNCONDITIONAL_STRONG_ROOT_LIST(V) \ | |
| 126 V(Code, re_c_entry_code, RegExpCEntryCode) \ | |
| 127 V(Code, direct_c_entry_code, DirectCEntryCode) | |
| 128 #elif V8_TARGET_ARCH_ARM | |
| 129 #define STRONG_ROOT_LIST(V) \ | |
| 130 UNCONDITIONAL_STRONG_ROOT_LIST(V) \ | |
| 131 V(Code, direct_c_entry_code, DirectCEntryCode) | |
| 132 #else | |
| 133 #define STRONG_ROOT_LIST(V) UNCONDITIONAL_STRONG_ROOT_LIST(V) | |
| 134 #endif | |
| 135 | |
| 136 #define ROOT_LIST(V) \ | 124 #define ROOT_LIST(V) \ |
| 137 STRONG_ROOT_LIST(V) \ | 125 STRONG_ROOT_LIST(V) \ |
| 138 V(SymbolTable, symbol_table, SymbolTable) | 126 V(SymbolTable, symbol_table, SymbolTable) |
| 139 | 127 |
| 140 #define SYMBOL_LIST(V) \ | 128 #define SYMBOL_LIST(V) \ |
| 141 V(Array_symbol, "Array") \ | 129 V(Array_symbol, "Array") \ |
| 142 V(Object_symbol, "Object") \ | 130 V(Object_symbol, "Object") \ |
| 143 V(Proto_symbol, "__proto__") \ | 131 V(Proto_symbol, "__proto__") \ |
| 144 V(StringImpl_symbol, "StringImpl") \ | 132 V(StringImpl_symbol, "StringImpl") \ |
| 145 V(arguments_symbol, "arguments") \ | 133 V(arguments_symbol, "arguments") \ |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 V(Date_symbol, "Date") \ | 165 V(Date_symbol, "Date") \ |
| 178 V(this_symbol, "this") \ | 166 V(this_symbol, "this") \ |
| 179 V(to_string_symbol, "toString") \ | 167 V(to_string_symbol, "toString") \ |
| 180 V(char_at_symbol, "CharAt") \ | 168 V(char_at_symbol, "CharAt") \ |
| 181 V(undefined_symbol, "undefined") \ | 169 V(undefined_symbol, "undefined") \ |
| 182 V(value_of_symbol, "valueOf") \ | 170 V(value_of_symbol, "valueOf") \ |
| 183 V(InitializeVarGlobal_symbol, "InitializeVarGlobal") \ | 171 V(InitializeVarGlobal_symbol, "InitializeVarGlobal") \ |
| 184 V(InitializeConstGlobal_symbol, "InitializeConstGlobal") \ | 172 V(InitializeConstGlobal_symbol, "InitializeConstGlobal") \ |
| 185 V(KeyedLoadSpecialized_symbol, "KeyedLoadSpecialized") \ | 173 V(KeyedLoadSpecialized_symbol, "KeyedLoadSpecialized") \ |
| 186 V(KeyedStoreSpecialized_symbol, "KeyedStoreSpecialized") \ | 174 V(KeyedStoreSpecialized_symbol, "KeyedStoreSpecialized") \ |
| 187 V(KeyedLoadPixelArray_symbol, "KeyedLoadPixelArray") \ | |
| 188 V(KeyedStorePixelArray_symbol, "KeyedStorePixelArray") \ | |
| 189 V(stack_overflow_symbol, "kStackOverflowBoilerplate") \ | 175 V(stack_overflow_symbol, "kStackOverflowBoilerplate") \ |
| 190 V(illegal_access_symbol, "illegal access") \ | 176 V(illegal_access_symbol, "illegal access") \ |
| 191 V(out_of_memory_symbol, "out-of-memory") \ | 177 V(out_of_memory_symbol, "out-of-memory") \ |
| 192 V(illegal_execution_state_symbol, "illegal execution state") \ | 178 V(illegal_execution_state_symbol, "illegal execution state") \ |
| 193 V(get_symbol, "get") \ | 179 V(get_symbol, "get") \ |
| 194 V(set_symbol, "set") \ | 180 V(set_symbol, "set") \ |
| 195 V(function_class_symbol, "Function") \ | 181 V(function_class_symbol, "Function") \ |
| 196 V(illegal_argument_symbol, "illegal argument") \ | 182 V(illegal_argument_symbol, "illegal argument") \ |
| 197 V(MakeReferenceError_symbol, "MakeReferenceError") \ | 183 V(MakeReferenceError_symbol, "MakeReferenceError") \ |
| 198 V(MakeSyntaxError_symbol, "MakeSyntaxError") \ | 184 V(MakeSyntaxError_symbol, "MakeSyntaxError") \ |
| 199 V(MakeTypeError_symbol, "MakeTypeError") \ | 185 V(MakeTypeError_symbol, "MakeTypeError") \ |
| 200 V(invalid_lhs_in_assignment_symbol, "invalid_lhs_in_assignment") \ | 186 V(invalid_lhs_in_assignment_symbol, "invalid_lhs_in_assignment") \ |
| 201 V(invalid_lhs_in_for_in_symbol, "invalid_lhs_in_for_in") \ | 187 V(invalid_lhs_in_for_in_symbol, "invalid_lhs_in_for_in") \ |
| 202 V(invalid_lhs_in_postfix_op_symbol, "invalid_lhs_in_postfix_op") \ | 188 V(invalid_lhs_in_postfix_op_symbol, "invalid_lhs_in_postfix_op") \ |
| 203 V(invalid_lhs_in_prefix_op_symbol, "invalid_lhs_in_prefix_op") \ | 189 V(invalid_lhs_in_prefix_op_symbol, "invalid_lhs_in_prefix_op") \ |
| 204 V(illegal_return_symbol, "illegal_return") \ | 190 V(illegal_return_symbol, "illegal_return") \ |
| 205 V(illegal_break_symbol, "illegal_break") \ | 191 V(illegal_break_symbol, "illegal_break") \ |
| 206 V(illegal_continue_symbol, "illegal_continue") \ | 192 V(illegal_continue_symbol, "illegal_continue") \ |
| 207 V(unknown_label_symbol, "unknown_label") \ | 193 V(unknown_label_symbol, "unknown_label") \ |
| 208 V(redeclaration_symbol, "redeclaration") \ | 194 V(redeclaration_symbol, "redeclaration") \ |
| 209 V(failure_symbol, "<failure>") \ | 195 V(failure_symbol, "<failure>") \ |
| 210 V(space_symbol, " ") \ | 196 V(space_symbol, " ") \ |
| 211 V(exec_symbol, "exec") \ | 197 V(exec_symbol, "exec") \ |
| 212 V(zero_symbol, "0") \ | 198 V(zero_symbol, "0") \ |
| 213 V(global_eval_symbol, "GlobalEval") \ | 199 V(global_eval_symbol, "GlobalEval") \ |
| 214 V(identity_hash_symbol, "v8::IdentityHash") \ | 200 V(identity_hash_symbol, "v8::IdentityHash") \ |
| 215 V(closure_symbol, "(closure)") \ | 201 V(closure_symbol, "(closure)") \ |
| 216 V(use_strict, "use strict") \ | 202 V(use_strict, "use strict") \ |
| 217 V(KeyedLoadExternalArray_symbol, "KeyedLoadExternalArray") \ | 203 V(KeyedLoadExternalByteArray_symbol, "KeyedLoadExternalByteArray") \ |
| 218 V(KeyedStoreExternalArray_symbol, "KeyedStoreExternalArray") | 204 V(KeyedLoadExternalUnsignedByteArray_symbol, \ |
| 219 | 205 "KeyedLoadExternalUnsignedByteArray") \ |
| 206 V(KeyedLoadExternalShortArray_symbol, \ |
| 207 "KeyedLoadExternalShortArray") \ |
| 208 V(KeyedLoadExternalUnsignedShortArray_symbol, \ |
| 209 "KeyedLoadExternalUnsignedShortArray") \ |
| 210 V(KeyedLoadExternalIntArray_symbol, "KeyedLoadExternalIntArray") \ |
| 211 V(KeyedLoadExternalUnsignedIntArray_symbol, \ |
| 212 "KeyedLoadExternalUnsignedIntArray") \ |
| 213 V(KeyedLoadExternalFloatArray_symbol, "KeyedLoadExternalFloatArray") \ |
| 214 V(KeyedLoadExternalPixelArray_symbol, "KeyedLoadExternalPixelArray") \ |
| 215 V(KeyedStoreExternalByteArray_symbol, "KeyedStoreExternalByteArray") \ |
| 216 V(KeyedStoreExternalUnsignedByteArray_symbol, \ |
| 217 "KeyedStoreExternalUnsignedByteArray") \ |
| 218 V(KeyedStoreExternalShortArray_symbol, "KeyedStoreExternalShortArray") \ |
| 219 V(KeyedStoreExternalUnsignedShortArray_symbol, \ |
| 220 "KeyedStoreExternalUnsignedShortArray") \ |
| 221 V(KeyedStoreExternalIntArray_symbol, "KeyedStoreExternalIntArray") \ |
| 222 V(KeyedStoreExternalUnsignedIntArray_symbol, \ |
| 223 "KeyedStoreExternalUnsignedIntArray") \ |
| 224 V(KeyedStoreExternalFloatArray_symbol, "KeyedStoreExternalFloatArray") \ |
| 225 V(KeyedStoreExternalPixelArray_symbol, "KeyedStoreExternalPixelArray") |
| 220 | 226 |
| 221 // Forward declarations. | 227 // Forward declarations. |
| 222 class GCTracer; | 228 class GCTracer; |
| 223 class HeapStats; | 229 class HeapStats; |
| 224 class WeakObjectRetainer; | 230 class WeakObjectRetainer; |
| 225 | 231 |
| 226 | 232 |
| 227 typedef String* (*ExternalStringTableUpdaterCallback)(Object** pointer); | 233 typedef String* (*ExternalStringTableUpdaterCallback)(Object** pointer); |
| 228 | 234 |
| 229 typedef void (*PointerRegionCallback)(Address start, | 235 typedef void (*PointerRegionCallback)(Address start, |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 // Please note this does not perform a garbage collection. | 493 // Please note this does not perform a garbage collection. |
| 488 MUST_USE_RESULT static MaybeObject* AllocateByteArray(int length, | 494 MUST_USE_RESULT static MaybeObject* AllocateByteArray(int length, |
| 489 PretenureFlag pretenure); | 495 PretenureFlag pretenure); |
| 490 | 496 |
| 491 // Allocate a non-tenured byte array of the specified length | 497 // Allocate a non-tenured byte array of the specified length |
| 492 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation | 498 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| 493 // failed. | 499 // failed. |
| 494 // Please note this does not perform a garbage collection. | 500 // Please note this does not perform a garbage collection. |
| 495 MUST_USE_RESULT static MaybeObject* AllocateByteArray(int length); | 501 MUST_USE_RESULT static MaybeObject* AllocateByteArray(int length); |
| 496 | 502 |
| 497 // Allocate a pixel array of the specified length | |
| 498 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation | |
| 499 // failed. | |
| 500 // Please note this does not perform a garbage collection. | |
| 501 MUST_USE_RESULT static MaybeObject* AllocatePixelArray(int length, | |
| 502 uint8_t* external_pointer, | |
| 503 PretenureFlag pretenure); | |
| 504 | |
| 505 // Allocates an external array of the specified length and type. | 503 // Allocates an external array of the specified length and type. |
| 506 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation | 504 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| 507 // failed. | 505 // failed. |
| 508 // Please note this does not perform a garbage collection. | 506 // Please note this does not perform a garbage collection. |
| 509 MUST_USE_RESULT static MaybeObject* AllocateExternalArray( | 507 MUST_USE_RESULT static MaybeObject* AllocateExternalArray( |
| 510 int length, | 508 int length, |
| 511 ExternalArrayType array_type, | 509 ExternalArrayType array_type, |
| 512 void* external_pointer, | 510 void* external_pointer, |
| 513 PretenureFlag pretenure); | 511 PretenureFlag pretenure); |
| 514 | 512 |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 698 static void CreateFillerObjectAt(Address addr, int size); | 696 static void CreateFillerObjectAt(Address addr, int size); |
| 699 | 697 |
| 700 // Makes a new native code object | 698 // Makes a new native code object |
| 701 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation | 699 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| 702 // failed. On success, the pointer to the Code object is stored in the | 700 // failed. On success, the pointer to the Code object is stored in the |
| 703 // self_reference. This allows generated code to reference its own Code | 701 // self_reference. This allows generated code to reference its own Code |
| 704 // object by containing this pointer. | 702 // object by containing this pointer. |
| 705 // Please note this function does not perform a garbage collection. | 703 // Please note this function does not perform a garbage collection. |
| 706 MUST_USE_RESULT static MaybeObject* CreateCode(const CodeDesc& desc, | 704 MUST_USE_RESULT static MaybeObject* CreateCode(const CodeDesc& desc, |
| 707 Code::Flags flags, | 705 Code::Flags flags, |
| 708 Handle<Object> self_reference); | 706 Handle<Object> self_reference, |
| 707 bool immovable = false); |
| 709 | 708 |
| 710 MUST_USE_RESULT static MaybeObject* CopyCode(Code* code); | 709 MUST_USE_RESULT static MaybeObject* CopyCode(Code* code); |
| 711 | 710 |
| 712 // Copy the code and scope info part of the code object, but insert | 711 // Copy the code and scope info part of the code object, but insert |
| 713 // the provided data as the relocation information. | 712 // the provided data as the relocation information. |
| 714 MUST_USE_RESULT static MaybeObject* CopyCode(Code* code, | 713 MUST_USE_RESULT static MaybeObject* CopyCode(Code* code, |
| 715 Vector<byte> reloc_info); | 714 Vector<byte> reloc_info); |
| 716 | 715 |
| 717 // Finds the symbol for string in the symbol table. | 716 // Finds the symbol for string in the symbol table. |
| 718 // If not found, a new symbol is added to the table and returned. | 717 // If not found, a new symbol is added to the table and returned. |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1152 | 1151 |
| 1153 static void ClearJSFunctionResultCaches(); | 1152 static void ClearJSFunctionResultCaches(); |
| 1154 | 1153 |
| 1155 static void ClearNormalizedMapCaches(); | 1154 static void ClearNormalizedMapCaches(); |
| 1156 | 1155 |
| 1157 static GCTracer* tracer() { return tracer_; } | 1156 static GCTracer* tracer() { return tracer_; } |
| 1158 | 1157 |
| 1159 // Returns the size of objects residing in non new spaces. | 1158 // Returns the size of objects residing in non new spaces. |
| 1160 static intptr_t PromotedSpaceSize(); | 1159 static intptr_t PromotedSpaceSize(); |
| 1161 | 1160 |
| 1161 static void CallGlobalGCPrologueCallback() { |
| 1162 if (global_gc_prologue_callback_ != NULL) global_gc_prologue_callback_(); |
| 1163 } |
| 1164 |
| 1165 static void CallGlobalGCEpilogueCallback() { |
| 1166 if (global_gc_epilogue_callback_ != NULL) global_gc_epilogue_callback_(); |
| 1167 } |
| 1168 |
| 1162 private: | 1169 private: |
| 1163 static int reserved_semispace_size_; | 1170 static int reserved_semispace_size_; |
| 1164 static int max_semispace_size_; | 1171 static int max_semispace_size_; |
| 1165 static int initial_semispace_size_; | 1172 static int initial_semispace_size_; |
| 1166 static intptr_t max_old_generation_size_; | 1173 static intptr_t max_old_generation_size_; |
| 1167 static intptr_t max_executable_size_; | 1174 static intptr_t max_executable_size_; |
| 1168 static intptr_t code_range_size_; | 1175 static intptr_t code_range_size_; |
| 1169 | 1176 |
| 1170 // For keeping track of how much data has survived | 1177 // For keeping track of how much data has survived |
| 1171 // scavenge since last new space expansion. | 1178 // scavenge since last new space expansion. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1190 static MapSpace* map_space_; | 1197 static MapSpace* map_space_; |
| 1191 static CellSpace* cell_space_; | 1198 static CellSpace* cell_space_; |
| 1192 static LargeObjectSpace* lo_space_; | 1199 static LargeObjectSpace* lo_space_; |
| 1193 static HeapState gc_state_; | 1200 static HeapState gc_state_; |
| 1194 | 1201 |
| 1195 // Returns the amount of external memory registered since last global gc. | 1202 // Returns the amount of external memory registered since last global gc. |
| 1196 static int PromotedExternalMemorySize(); | 1203 static int PromotedExternalMemorySize(); |
| 1197 | 1204 |
| 1198 static int mc_count_; // how many mark-compact collections happened | 1205 static int mc_count_; // how many mark-compact collections happened |
| 1199 static int ms_count_; // how many mark-sweep collections happened | 1206 static int ms_count_; // how many mark-sweep collections happened |
| 1200 static int gc_count_; // how many gc happened | 1207 static unsigned int gc_count_; // how many gc happened |
| 1201 | 1208 |
| 1202 // Total length of the strings we failed to flatten since the last GC. | 1209 // Total length of the strings we failed to flatten since the last GC. |
| 1203 static int unflattened_strings_length_; | 1210 static int unflattened_strings_length_; |
| 1204 | 1211 |
| 1205 #define ROOT_ACCESSOR(type, name, camel_name) \ | 1212 #define ROOT_ACCESSOR(type, name, camel_name) \ |
| 1206 static inline void set_##name(type* value) { \ | 1213 static inline void set_##name(type* value) { \ |
| 1207 roots_[k##camel_name##RootIndex] = value; \ | 1214 roots_[k##camel_name##RootIndex] = value; \ |
| 1208 } | 1215 } |
| 1209 ROOT_LIST(ROOT_ACCESSOR) | 1216 ROOT_LIST(ROOT_ACCESSOR) |
| 1210 #undef ROOT_ACCESSOR | 1217 #undef ROOT_ACCESSOR |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1334 MUST_USE_RESULT static inline MaybeObject* AllocateRawCell(); | 1341 MUST_USE_RESULT static inline MaybeObject* AllocateRawCell(); |
| 1335 | 1342 |
| 1336 // Initializes a JSObject based on its map. | 1343 // Initializes a JSObject based on its map. |
| 1337 static void InitializeJSObjectFromMap(JSObject* obj, | 1344 static void InitializeJSObjectFromMap(JSObject* obj, |
| 1338 FixedArray* properties, | 1345 FixedArray* properties, |
| 1339 Map* map); | 1346 Map* map); |
| 1340 | 1347 |
| 1341 static bool CreateInitialMaps(); | 1348 static bool CreateInitialMaps(); |
| 1342 static bool CreateInitialObjects(); | 1349 static bool CreateInitialObjects(); |
| 1343 | 1350 |
| 1344 // These five Create*EntryStub functions are here and forced to not be inlined | 1351 // These two Create*EntryStub functions are here and forced to not be inlined |
| 1345 // because of a gcc-4.4 bug that assigns wrong vtable entries. | 1352 // because of a gcc-4.4 bug that assigns wrong vtable entries. |
| 1346 NO_INLINE(static void CreateCEntryStub()); | |
| 1347 NO_INLINE(static void CreateJSEntryStub()); | 1353 NO_INLINE(static void CreateJSEntryStub()); |
| 1348 NO_INLINE(static void CreateJSConstructEntryStub()); | 1354 NO_INLINE(static void CreateJSConstructEntryStub()); |
| 1349 NO_INLINE(static void CreateRegExpCEntryStub()); | |
| 1350 NO_INLINE(static void CreateDirectCEntryStub()); | |
| 1351 | 1355 |
| 1352 static void CreateFixedStubs(); | 1356 static void CreateFixedStubs(); |
| 1353 | 1357 |
| 1354 MUST_USE_RESULT static MaybeObject* CreateOddball(const char* to_string, | 1358 MUST_USE_RESULT static MaybeObject* CreateOddball(const char* to_string, |
| 1355 Object* to_number); | 1359 Object* to_number); |
| 1356 | 1360 |
| 1357 // Allocate empty fixed array. | 1361 // Allocate empty fixed array. |
| 1358 MUST_USE_RESULT static MaybeObject* AllocateEmptyFixedArray(); | 1362 MUST_USE_RESULT static MaybeObject* AllocateEmptyFixedArray(); |
| 1359 | 1363 |
| 1360 // Performs a minor collection in new generation. | 1364 // Performs a minor collection in new generation. |
| (...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1892 double start_time_; | 1896 double start_time_; |
| 1893 }; | 1897 }; |
| 1894 | 1898 |
| 1895 GCTracer(); | 1899 GCTracer(); |
| 1896 ~GCTracer(); | 1900 ~GCTracer(); |
| 1897 | 1901 |
| 1898 // Sets the collector. | 1902 // Sets the collector. |
| 1899 void set_collector(GarbageCollector collector) { collector_ = collector; } | 1903 void set_collector(GarbageCollector collector) { collector_ = collector; } |
| 1900 | 1904 |
| 1901 // Sets the GC count. | 1905 // Sets the GC count. |
| 1902 void set_gc_count(int count) { gc_count_ = count; } | 1906 void set_gc_count(unsigned int count) { gc_count_ = count; } |
| 1903 | 1907 |
| 1904 // Sets the full GC count. | 1908 // Sets the full GC count. |
| 1905 void set_full_gc_count(int count) { full_gc_count_ = count; } | 1909 void set_full_gc_count(int count) { full_gc_count_ = count; } |
| 1906 | 1910 |
| 1907 // Sets the flag that this is a compacting full GC. | 1911 // Sets the flag that this is a compacting full GC. |
| 1908 void set_is_compacting() { is_compacting_ = true; } | 1912 void set_is_compacting() { is_compacting_ = true; } |
| 1909 bool is_compacting() const { return is_compacting_; } | 1913 bool is_compacting() const { return is_compacting_; } |
| 1910 | 1914 |
| 1911 // Increment and decrement the count of marked objects. | 1915 // Increment and decrement the count of marked objects. |
| 1912 void increment_marked_count() { ++marked_count_; } | 1916 void increment_marked_count() { ++marked_count_; } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1935 double SizeOfHeapObjects() { | 1939 double SizeOfHeapObjects() { |
| 1936 return (static_cast<double>(Heap::SizeOfObjects())) / MB; | 1940 return (static_cast<double>(Heap::SizeOfObjects())) / MB; |
| 1937 } | 1941 } |
| 1938 | 1942 |
| 1939 double start_time_; // Timestamp set in the constructor. | 1943 double start_time_; // Timestamp set in the constructor. |
| 1940 intptr_t start_size_; // Size of objects in heap set in constructor. | 1944 intptr_t start_size_; // Size of objects in heap set in constructor. |
| 1941 GarbageCollector collector_; // Type of collector. | 1945 GarbageCollector collector_; // Type of collector. |
| 1942 | 1946 |
| 1943 // A count (including this one, eg, the first collection is 1) of the | 1947 // A count (including this one, eg, the first collection is 1) of the |
| 1944 // number of garbage collections. | 1948 // number of garbage collections. |
| 1945 int gc_count_; | 1949 unsigned int gc_count_; |
| 1946 | 1950 |
| 1947 // A count (including this one) of the number of full garbage collections. | 1951 // A count (including this one) of the number of full garbage collections. |
| 1948 int full_gc_count_; | 1952 int full_gc_count_; |
| 1949 | 1953 |
| 1950 // True if the current GC is a compacting full collection, false | 1954 // True if the current GC is a compacting full collection, false |
| 1951 // otherwise. | 1955 // otherwise. |
| 1952 bool is_compacting_; | 1956 bool is_compacting_; |
| 1953 | 1957 |
| 1954 // True if the *previous* full GC cwas a compacting collection (will be | 1958 // True if the *previous* full GC cwas a compacting collection (will be |
| 1955 // false if there has not been a previous full GC). | 1959 // false if there has not been a previous full GC). |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2170 Map* map = MapWord::FromRawValue(map_word | kNotMarkedBit).ToMap(); | 2174 Map* map = MapWord::FromRawValue(map_word | kNotMarkedBit).ToMap(); |
| 2171 return object->SizeFromMap(map); | 2175 return object->SizeFromMap(map); |
| 2172 } | 2176 } |
| 2173 | 2177 |
| 2174 private: | 2178 private: |
| 2175 static const uintptr_t kNotMarkedBit = 0x1; | 2179 static const uintptr_t kNotMarkedBit = 0x1; |
| 2176 STATIC_ASSERT((kHeapObjectTag & kNotMarkedBit) != 0); | 2180 STATIC_ASSERT((kHeapObjectTag & kNotMarkedBit) != 0); |
| 2177 }; | 2181 }; |
| 2178 | 2182 |
| 2179 | 2183 |
| 2184 #if defined(DEBUG) || defined(LIVE_OBJECT_LIST) |
| 2185 // Helper class for tracing paths to a search target Object from all roots. |
| 2186 // The TracePathFrom() method can be used to trace paths from a specific |
| 2187 // object to the search target object. |
| 2188 class PathTracer : public ObjectVisitor { |
| 2189 public: |
| 2190 enum WhatToFind { |
| 2191 FIND_ALL, // Will find all matches. |
| 2192 FIND_FIRST // Will stop the search after first match. |
| 2193 }; |
| 2194 |
| 2195 // For the WhatToFind arg, if FIND_FIRST is specified, tracing will stop |
| 2196 // after the first match. If FIND_ALL is specified, then tracing will be |
| 2197 // done for all matches. |
| 2198 PathTracer(Object* search_target, |
| 2199 WhatToFind what_to_find, |
| 2200 VisitMode visit_mode) |
| 2201 : search_target_(search_target), |
| 2202 found_target_(false), |
| 2203 found_target_in_trace_(false), |
| 2204 what_to_find_(what_to_find), |
| 2205 visit_mode_(visit_mode), |
| 2206 object_stack_(20), |
| 2207 no_alloc() {} |
| 2208 |
| 2209 virtual void VisitPointers(Object** start, Object** end); |
| 2210 |
| 2211 void Reset(); |
| 2212 void TracePathFrom(Object** root); |
| 2213 |
| 2214 bool found() const { return found_target_; } |
| 2215 |
| 2216 static Object* const kAnyGlobalObject; |
| 2217 |
| 2218 protected: |
| 2219 class MarkVisitor; |
| 2220 class UnmarkVisitor; |
| 2221 |
| 2222 void MarkRecursively(Object** p, MarkVisitor* mark_visitor); |
| 2223 void UnmarkRecursively(Object** p, UnmarkVisitor* unmark_visitor); |
| 2224 virtual void ProcessResults(); |
| 2225 |
| 2226 // Tags 0, 1, and 3 are used. Use 2 for marking visited HeapObject. |
| 2227 static const int kMarkTag = 2; |
| 2228 |
| 2229 Object* search_target_; |
| 2230 bool found_target_; |
| 2231 bool found_target_in_trace_; |
| 2232 WhatToFind what_to_find_; |
| 2233 VisitMode visit_mode_; |
| 2234 List<Object*> object_stack_; |
| 2235 |
| 2236 AssertNoAllocation no_alloc; // i.e. no gc allowed. |
| 2237 |
| 2238 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); |
| 2239 }; |
| 2240 #endif // DEBUG || LIVE_OBJECT_LIST |
| 2241 |
| 2180 } } // namespace v8::internal | 2242 } } // namespace v8::internal |
| 2181 | 2243 |
| 2182 #endif // V8_HEAP_H_ | 2244 #endif // V8_HEAP_H_ |
| OLD | NEW |