| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 V(Map, free_space_map, FreeSpaceMap) \ | 57 V(Map, free_space_map, FreeSpaceMap) \ |
| 58 V(Map, one_pointer_filler_map, OnePointerFillerMap) \ | 58 V(Map, one_pointer_filler_map, OnePointerFillerMap) \ |
| 59 V(Map, two_pointer_filler_map, TwoPointerFillerMap) \ | 59 V(Map, two_pointer_filler_map, TwoPointerFillerMap) \ |
| 60 /* Cluster the most popular ones in a few cache lines here at the top. */ \ | 60 /* Cluster the most popular ones in a few cache lines here at the top. */ \ |
| 61 V(Smi, store_buffer_top, StoreBufferTop) \ | 61 V(Smi, store_buffer_top, StoreBufferTop) \ |
| 62 V(Oddball, undefined_value, UndefinedValue) \ | 62 V(Oddball, undefined_value, UndefinedValue) \ |
| 63 V(Oddball, the_hole_value, TheHoleValue) \ | 63 V(Oddball, the_hole_value, TheHoleValue) \ |
| 64 V(Oddball, null_value, NullValue) \ | 64 V(Oddball, null_value, NullValue) \ |
| 65 V(Oddball, true_value, TrueValue) \ | 65 V(Oddball, true_value, TrueValue) \ |
| 66 V(Oddball, false_value, FalseValue) \ | 66 V(Oddball, false_value, FalseValue) \ |
| 67 V(Oddball, arguments_marker, ArgumentsMarker) \ | 67 V(Map, global_property_cell_map, GlobalPropertyCellMap) \ |
| 68 V(Oddball, frame_alignment_marker, FrameAlignmentMarker) \ | 68 V(Map, shared_function_info_map, SharedFunctionInfoMap) \ |
| 69 V(Map, meta_map, MetaMap) \ |
| 70 V(Map, ascii_symbol_map, AsciiSymbolMap) \ |
| 71 V(Map, ascii_string_map, AsciiStringMap) \ |
| 69 V(Map, heap_number_map, HeapNumberMap) \ | 72 V(Map, heap_number_map, HeapNumberMap) \ |
| 70 V(Map, global_context_map, GlobalContextMap) \ | 73 V(Map, global_context_map, GlobalContextMap) \ |
| 71 V(Map, fixed_array_map, FixedArrayMap) \ | 74 V(Map, fixed_array_map, FixedArrayMap) \ |
| 75 V(Map, code_map, CodeMap) \ |
| 72 V(Map, serialized_scope_info_map, SerializedScopeInfoMap) \ | 76 V(Map, serialized_scope_info_map, SerializedScopeInfoMap) \ |
| 73 V(Map, fixed_cow_array_map, FixedCOWArrayMap) \ | 77 V(Map, fixed_cow_array_map, FixedCOWArrayMap) \ |
| 74 V(Map, fixed_double_array_map, FixedDoubleArrayMap) \ | 78 V(Map, fixed_double_array_map, FixedDoubleArrayMap) \ |
| 75 V(Object, no_interceptor_result_sentinel, NoInterceptorResultSentinel) \ | 79 V(Object, no_interceptor_result_sentinel, NoInterceptorResultSentinel) \ |
| 76 V(Map, meta_map, MetaMap) \ | |
| 77 V(Map, hash_table_map, HashTableMap) \ | 80 V(Map, hash_table_map, HashTableMap) \ |
| 81 V(FixedArray, empty_fixed_array, EmptyFixedArray) \ |
| 82 V(ByteArray, empty_byte_array, EmptyByteArray) \ |
| 83 V(FixedDoubleArray, empty_fixed_double_array, EmptyFixedDoubleArray) \ |
| 84 V(String, empty_string, EmptyString) \ |
| 85 V(DescriptorArray, empty_descriptor_array, EmptyDescriptorArray) \ |
| 78 V(Smi, stack_limit, StackLimit) \ | 86 V(Smi, stack_limit, StackLimit) \ |
| 87 V(Oddball, frame_alignment_marker, FrameAlignmentMarker) \ |
| 88 V(Oddball, arguments_marker, ArgumentsMarker) \ |
| 89 /* The first 32 roots above this line should be boring from a GC point of */ \ |
| 90 /* view. This means they are never in new space and never on a page that */ \ |
| 91 /* is being compacted. */ \ |
| 79 V(FixedArray, number_string_cache, NumberStringCache) \ | 92 V(FixedArray, number_string_cache, NumberStringCache) \ |
| 80 V(Object, instanceof_cache_function, InstanceofCacheFunction) \ | 93 V(Object, instanceof_cache_function, InstanceofCacheFunction) \ |
| 81 V(Object, instanceof_cache_map, InstanceofCacheMap) \ | 94 V(Object, instanceof_cache_map, InstanceofCacheMap) \ |
| 82 V(Object, instanceof_cache_answer, InstanceofCacheAnswer) \ | 95 V(Object, instanceof_cache_answer, InstanceofCacheAnswer) \ |
| 83 V(FixedArray, single_character_string_cache, SingleCharacterStringCache) \ | 96 V(FixedArray, single_character_string_cache, SingleCharacterStringCache) \ |
| 84 V(FixedArray, string_split_cache, StringSplitCache) \ | 97 V(FixedArray, string_split_cache, StringSplitCache) \ |
| 85 V(Object, termination_exception, TerminationException) \ | 98 V(Object, termination_exception, TerminationException) \ |
| 86 V(FixedArray, empty_fixed_array, EmptyFixedArray) \ | |
| 87 V(ByteArray, empty_byte_array, EmptyByteArray) \ | |
| 88 V(FixedDoubleArray, empty_fixed_double_array, EmptyFixedDoubleArray) \ | |
| 89 V(String, empty_string, EmptyString) \ | |
| 90 V(DescriptorArray, empty_descriptor_array, EmptyDescriptorArray) \ | |
| 91 V(Map, string_map, StringMap) \ | 99 V(Map, string_map, StringMap) \ |
| 92 V(Map, ascii_string_map, AsciiStringMap) \ | |
| 93 V(Map, symbol_map, SymbolMap) \ | 100 V(Map, symbol_map, SymbolMap) \ |
| 94 V(Map, cons_string_map, ConsStringMap) \ | 101 V(Map, cons_string_map, ConsStringMap) \ |
| 95 V(Map, cons_ascii_string_map, ConsAsciiStringMap) \ | 102 V(Map, cons_ascii_string_map, ConsAsciiStringMap) \ |
| 96 V(Map, sliced_string_map, SlicedStringMap) \ | 103 V(Map, sliced_string_map, SlicedStringMap) \ |
| 97 V(Map, sliced_ascii_string_map, SlicedAsciiStringMap) \ | 104 V(Map, sliced_ascii_string_map, SlicedAsciiStringMap) \ |
| 98 V(Map, ascii_symbol_map, AsciiSymbolMap) \ | |
| 99 V(Map, cons_symbol_map, ConsSymbolMap) \ | 105 V(Map, cons_symbol_map, ConsSymbolMap) \ |
| 100 V(Map, cons_ascii_symbol_map, ConsAsciiSymbolMap) \ | 106 V(Map, cons_ascii_symbol_map, ConsAsciiSymbolMap) \ |
| 101 V(Map, external_symbol_map, ExternalSymbolMap) \ | 107 V(Map, external_symbol_map, ExternalSymbolMap) \ |
| 102 V(Map, external_symbol_with_ascii_data_map, ExternalSymbolWithAsciiDataMap) \ | 108 V(Map, external_symbol_with_ascii_data_map, ExternalSymbolWithAsciiDataMap) \ |
| 103 V(Map, external_ascii_symbol_map, ExternalAsciiSymbolMap) \ | 109 V(Map, external_ascii_symbol_map, ExternalAsciiSymbolMap) \ |
| 104 V(Map, external_string_map, ExternalStringMap) \ | 110 V(Map, external_string_map, ExternalStringMap) \ |
| 105 V(Map, external_string_with_ascii_data_map, ExternalStringWithAsciiDataMap) \ | 111 V(Map, external_string_with_ascii_data_map, ExternalStringWithAsciiDataMap) \ |
| 106 V(Map, external_ascii_string_map, ExternalAsciiStringMap) \ | 112 V(Map, external_ascii_string_map, ExternalAsciiStringMap) \ |
| 107 V(Map, undetectable_string_map, UndetectableStringMap) \ | 113 V(Map, undetectable_string_map, UndetectableStringMap) \ |
| 108 V(Map, undetectable_ascii_string_map, UndetectableAsciiStringMap) \ | 114 V(Map, undetectable_ascii_string_map, UndetectableAsciiStringMap) \ |
| 109 V(Map, external_pixel_array_map, ExternalPixelArrayMap) \ | 115 V(Map, external_pixel_array_map, ExternalPixelArrayMap) \ |
| 110 V(Map, external_byte_array_map, ExternalByteArrayMap) \ | 116 V(Map, external_byte_array_map, ExternalByteArrayMap) \ |
| 111 V(Map, external_unsigned_byte_array_map, ExternalUnsignedByteArrayMap) \ | 117 V(Map, external_unsigned_byte_array_map, ExternalUnsignedByteArrayMap) \ |
| 112 V(Map, external_short_array_map, ExternalShortArrayMap) \ | 118 V(Map, external_short_array_map, ExternalShortArrayMap) \ |
| 113 V(Map, external_unsigned_short_array_map, ExternalUnsignedShortArrayMap) \ | 119 V(Map, external_unsigned_short_array_map, ExternalUnsignedShortArrayMap) \ |
| 114 V(Map, external_int_array_map, ExternalIntArrayMap) \ | 120 V(Map, external_int_array_map, ExternalIntArrayMap) \ |
| 115 V(Map, external_unsigned_int_array_map, ExternalUnsignedIntArrayMap) \ | 121 V(Map, external_unsigned_int_array_map, ExternalUnsignedIntArrayMap) \ |
| 116 V(Map, external_float_array_map, ExternalFloatArrayMap) \ | 122 V(Map, external_float_array_map, ExternalFloatArrayMap) \ |
| 117 V(Map, external_double_array_map, ExternalDoubleArrayMap) \ | 123 V(Map, external_double_array_map, ExternalDoubleArrayMap) \ |
| 118 V(Map, non_strict_arguments_elements_map, NonStrictArgumentsElementsMap) \ | 124 V(Map, non_strict_arguments_elements_map, NonStrictArgumentsElementsMap) \ |
| 119 V(Map, function_context_map, FunctionContextMap) \ | 125 V(Map, function_context_map, FunctionContextMap) \ |
| 120 V(Map, catch_context_map, CatchContextMap) \ | 126 V(Map, catch_context_map, CatchContextMap) \ |
| 121 V(Map, with_context_map, WithContextMap) \ | 127 V(Map, with_context_map, WithContextMap) \ |
| 122 V(Map, block_context_map, BlockContextMap) \ | 128 V(Map, block_context_map, BlockContextMap) \ |
| 123 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) \ | |
| 126 V(Map, shared_function_info_map, SharedFunctionInfoMap) \ | |
| 127 V(Map, message_object_map, JSMessageObjectMap) \ | 130 V(Map, message_object_map, JSMessageObjectMap) \ |
| 128 V(Map, foreign_map, ForeignMap) \ | 131 V(Map, foreign_map, ForeignMap) \ |
| 129 V(HeapNumber, nan_value, NanValue) \ | 132 V(HeapNumber, nan_value, NanValue) \ |
| 130 V(HeapNumber, infinity_value, InfinityValue) \ | 133 V(HeapNumber, infinity_value, InfinityValue) \ |
| 131 V(HeapNumber, minus_zero_value, MinusZeroValue) \ | 134 V(HeapNumber, minus_zero_value, MinusZeroValue) \ |
| 132 V(Map, neander_map, NeanderMap) \ | 135 V(Map, neander_map, NeanderMap) \ |
| 133 V(JSObject, message_listeners, MessageListeners) \ | 136 V(JSObject, message_listeners, MessageListeners) \ |
| 134 V(Foreign, prototype_accessors, PrototypeAccessors) \ | 137 V(Foreign, prototype_accessors, PrototypeAccessors) \ |
| 135 V(NumberDictionary, code_stubs, CodeStubs) \ | 138 V(NumberDictionary, code_stubs, CodeStubs) \ |
| 136 V(NumberDictionary, non_monomorphic_cache, NonMonomorphicCache) \ | 139 V(NumberDictionary, non_monomorphic_cache, NonMonomorphicCache) \ |
| (...skipping 953 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1090 } | 1093 } |
| 1091 | 1094 |
| 1092 void public_set_store_buffer_top(Address* top) { | 1095 void public_set_store_buffer_top(Address* top) { |
| 1093 roots_[kStoreBufferTopRootIndex] = reinterpret_cast<Smi*>(top); | 1096 roots_[kStoreBufferTopRootIndex] = reinterpret_cast<Smi*>(top); |
| 1094 } | 1097 } |
| 1095 | 1098 |
| 1096 // Update the next script id. | 1099 // Update the next script id. |
| 1097 inline void SetLastScriptId(Object* last_script_id); | 1100 inline void SetLastScriptId(Object* last_script_id); |
| 1098 | 1101 |
| 1099 // Generated code can embed this address to get access to the roots. | 1102 // Generated code can embed this address to get access to the roots. |
| 1100 Object** roots_address() { return roots_; } | 1103 Object** roots_array_start() { return roots_; } |
| 1101 | 1104 |
| 1102 Address* store_buffer_top_address() { | 1105 Address* store_buffer_top_address() { |
| 1103 return reinterpret_cast<Address*>(&roots_[kStoreBufferTopRootIndex]); | 1106 return reinterpret_cast<Address*>(&roots_[kStoreBufferTopRootIndex]); |
| 1104 } | 1107 } |
| 1105 | 1108 |
| 1106 // Get address of global contexts list for serialization support. | 1109 // Get address of global contexts list for serialization support. |
| 1107 Object** global_contexts_list_address() { | 1110 Object** global_contexts_list_address() { |
| 1108 return &global_contexts_list_; | 1111 return &global_contexts_list_; |
| 1109 } | 1112 } |
| 1110 | 1113 |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1412 scavenging_visitors_table_.GetVisitor(map)(map, slot, obj); | 1415 scavenging_visitors_table_.GetVisitor(map)(map, slot, obj); |
| 1413 } | 1416 } |
| 1414 | 1417 |
| 1415 void QueueMemoryChunkForFree(MemoryChunk* chunk); | 1418 void QueueMemoryChunkForFree(MemoryChunk* chunk); |
| 1416 void FreeQueuedChunks(); | 1419 void FreeQueuedChunks(); |
| 1417 | 1420 |
| 1418 // Completely clear the Instanceof cache (to stop it keeping objects alive | 1421 // Completely clear the Instanceof cache (to stop it keeping objects alive |
| 1419 // around a GC). | 1422 // around a GC). |
| 1420 inline void CompletelyClearInstanceofCache(); | 1423 inline void CompletelyClearInstanceofCache(); |
| 1421 | 1424 |
| 1425 // The roots that have an index less than this are always in old space. |
| 1426 static const int kOldSpaceRoots = 0x20; |
| 1427 |
| 1422 private: | 1428 private: |
| 1423 Heap(); | 1429 Heap(); |
| 1424 | 1430 |
| 1425 // This can be calculated directly from a pointer to the heap; however, it is | 1431 // This can be calculated directly from a pointer to the heap; however, it is |
| 1426 // more expedient to get at the isolate directly from within Heap methods. | 1432 // more expedient to get at the isolate directly from within Heap methods. |
| 1427 Isolate* isolate_; | 1433 Isolate* isolate_; |
| 1428 | 1434 |
| 1429 intptr_t code_range_size_; | 1435 intptr_t code_range_size_; |
| 1430 int reserved_semispace_size_; | 1436 int reserved_semispace_size_; |
| 1431 int max_semispace_size_; | 1437 int max_semispace_size_; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1467 // Returns the amount of external memory registered since last global gc. | 1473 // Returns the amount of external memory registered since last global gc. |
| 1468 int PromotedExternalMemorySize(); | 1474 int PromotedExternalMemorySize(); |
| 1469 | 1475 |
| 1470 int ms_count_; // how many mark-sweep collections happened | 1476 int ms_count_; // how many mark-sweep collections happened |
| 1471 unsigned int gc_count_; // how many gc happened | 1477 unsigned int gc_count_; // how many gc happened |
| 1472 | 1478 |
| 1473 // Total length of the strings we failed to flatten since the last GC. | 1479 // Total length of the strings we failed to flatten since the last GC. |
| 1474 int unflattened_strings_length_; | 1480 int unflattened_strings_length_; |
| 1475 | 1481 |
| 1476 #define ROOT_ACCESSOR(type, name, camel_name) \ | 1482 #define ROOT_ACCESSOR(type, name, camel_name) \ |
| 1477 inline void set_##name(type* value) { \ | 1483 inline void set_##name(type* value) { \ |
| 1484 /* The deserializer makes use of the fact that these common roots are */ \ |
| 1485 /* never in new space and never on a page that is being compacted. */ \ |
| 1486 ASSERT(k##camel_name##RootIndex >= kOldSpaceRoots || !InNewSpace(value)); \ |
| 1478 roots_[k##camel_name##RootIndex] = value; \ | 1487 roots_[k##camel_name##RootIndex] = value; \ |
| 1479 } | 1488 } |
| 1480 ROOT_LIST(ROOT_ACCESSOR) | 1489 ROOT_LIST(ROOT_ACCESSOR) |
| 1481 #undef ROOT_ACCESSOR | 1490 #undef ROOT_ACCESSOR |
| 1482 | 1491 |
| 1483 #ifdef DEBUG | 1492 #ifdef DEBUG |
| 1484 bool allocation_allowed_; | 1493 bool allocation_allowed_; |
| 1485 | 1494 |
| 1486 // If the --gc-interval flag is set to a positive value, this | 1495 // If the --gc-interval flag is set to a positive value, this |
| 1487 // variable holds the value indicating the number of allocations | 1496 // variable holds the value indicating the number of allocations |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1947 // objects that still remain in the heap). As implementation of free | 1956 // objects that still remain in the heap). As implementation of free |
| 1948 // nodes filtering uses GC marks, it can't be used during MS/MC GC | 1957 // nodes filtering uses GC marks, it can't be used during MS/MC GC |
| 1949 // phases. Also, it is forbidden to interrupt iteration in this mode, | 1958 // phases. Also, it is forbidden to interrupt iteration in this mode, |
| 1950 // as this will leave heap objects marked (and thus, unusable). | 1959 // as this will leave heap objects marked (and thus, unusable). |
| 1951 class HeapObjectsFilter; | 1960 class HeapObjectsFilter; |
| 1952 | 1961 |
| 1953 class HeapIterator BASE_EMBEDDED { | 1962 class HeapIterator BASE_EMBEDDED { |
| 1954 public: | 1963 public: |
| 1955 enum HeapObjectsFiltering { | 1964 enum HeapObjectsFiltering { |
| 1956 kNoFiltering, | 1965 kNoFiltering, |
| 1957 kFilterFreeListNodes, | |
| 1958 kFilterUnreachable | 1966 kFilterUnreachable |
| 1959 }; | 1967 }; |
| 1960 | 1968 |
| 1961 HeapIterator(); | 1969 HeapIterator(); |
| 1962 explicit HeapIterator(HeapObjectsFiltering filtering); | 1970 explicit HeapIterator(HeapObjectsFiltering filtering); |
| 1963 ~HeapIterator(); | 1971 ~HeapIterator(); |
| 1964 | 1972 |
| 1965 HeapObject* next(); | 1973 HeapObject* next(); |
| 1966 void reset(); | 1974 void reset(); |
| 1967 | 1975 |
| (...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2468 | 2476 |
| 2469 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); | 2477 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); |
| 2470 }; | 2478 }; |
| 2471 #endif // DEBUG || LIVE_OBJECT_LIST | 2479 #endif // DEBUG || LIVE_OBJECT_LIST |
| 2472 | 2480 |
| 2473 } } // namespace v8::internal | 2481 } } // namespace v8::internal |
| 2474 | 2482 |
| 2475 #undef HEAP | 2483 #undef HEAP |
| 2476 | 2484 |
| 2477 #endif // V8_HEAP_H_ | 2485 #endif // V8_HEAP_H_ |
| OLD | NEW |