Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(112)

Side by Side Diff: src/heap.h

Issue 157503002: A64: Synchronize with r18444. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/harmony-math.js ('k') | src/heap.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 V(Map, code_map, CodeMap) \ 70 V(Map, code_map, CodeMap) \
71 V(Map, scope_info_map, ScopeInfoMap) \ 71 V(Map, scope_info_map, ScopeInfoMap) \
72 V(Map, fixed_cow_array_map, FixedCOWArrayMap) \ 72 V(Map, fixed_cow_array_map, FixedCOWArrayMap) \
73 V(Map, fixed_double_array_map, FixedDoubleArrayMap) \ 73 V(Map, fixed_double_array_map, FixedDoubleArrayMap) \
74 V(Map, constant_pool_array_map, ConstantPoolArrayMap) \ 74 V(Map, constant_pool_array_map, ConstantPoolArrayMap) \
75 V(Object, no_interceptor_result_sentinel, NoInterceptorResultSentinel) \ 75 V(Object, no_interceptor_result_sentinel, NoInterceptorResultSentinel) \
76 V(Map, hash_table_map, HashTableMap) \ 76 V(Map, hash_table_map, HashTableMap) \
77 V(FixedArray, empty_fixed_array, EmptyFixedArray) \ 77 V(FixedArray, empty_fixed_array, EmptyFixedArray) \
78 V(ByteArray, empty_byte_array, EmptyByteArray) \ 78 V(ByteArray, empty_byte_array, EmptyByteArray) \
79 V(DescriptorArray, empty_descriptor_array, EmptyDescriptorArray) \ 79 V(DescriptorArray, empty_descriptor_array, EmptyDescriptorArray) \
80 V(ConstantPoolArray, empty_constant_pool_array, EmptyConstantPoolArray) \
80 V(Smi, stack_limit, StackLimit) \ 81 V(Smi, stack_limit, StackLimit) \
81 V(Oddball, arguments_marker, ArgumentsMarker) \ 82 V(Oddball, arguments_marker, ArgumentsMarker) \
82 /* The roots above this line should be boring from a GC point of view. */ \ 83 /* The roots above this line should be boring from a GC point of view. */ \
83 /* This means they are never in new space and never on a page that is */ \ 84 /* This means they are never in new space and never on a page that is */ \
84 /* being compacted. */ \ 85 /* being compacted. */ \
85 V(FixedArray, number_string_cache, NumberStringCache) \ 86 V(FixedArray, number_string_cache, NumberStringCache) \
86 V(Object, instanceof_cache_function, InstanceofCacheFunction) \ 87 V(Object, instanceof_cache_function, InstanceofCacheFunction) \
87 V(Object, instanceof_cache_map, InstanceofCacheMap) \ 88 V(Object, instanceof_cache_map, InstanceofCacheMap) \
88 V(Object, instanceof_cache_answer, InstanceofCacheAnswer) \ 89 V(Object, instanceof_cache_answer, InstanceofCacheAnswer) \
89 V(FixedArray, single_character_string_cache, SingleCharacterStringCache) \ 90 V(FixedArray, single_character_string_cache, SingleCharacterStringCache) \
(...skipping 974 matching lines...) Expand 10 before | Expand all | Expand 10 after
1064 // Please note that this does not perform a garbage collection. 1065 // Please note that this does not perform a garbage collection.
1065 MUST_USE_RESULT MaybeObject* AllocateJSMessageObject( 1066 MUST_USE_RESULT MaybeObject* AllocateJSMessageObject(
1066 String* type, 1067 String* type,
1067 JSArray* arguments, 1068 JSArray* arguments,
1068 int start_position, 1069 int start_position,
1069 int end_position, 1070 int end_position,
1070 Object* script, 1071 Object* script,
1071 Object* stack_trace, 1072 Object* stack_trace,
1072 Object* stack_frames); 1073 Object* stack_frames);
1073 1074
1074 // Allocates a new cons string object.
1075 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
1076 // failed.
1077 // Please note this does not perform a garbage collection.
1078 MUST_USE_RESULT MaybeObject* AllocateConsString(String* first,
1079 String* second);
1080
1081 // Allocates a new sub string object which is a substring of an underlying
1082 // string buffer stretching from the index start (inclusive) to the index
1083 // end (exclusive).
1084 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
1085 // failed.
1086 // Please note this does not perform a garbage collection.
1087 MUST_USE_RESULT MaybeObject* AllocateSubString(
1088 String* buffer,
1089 int start,
1090 int end,
1091 PretenureFlag pretenure = NOT_TENURED);
1092
1093 // Allocate a new external string object, which is backed by a string 1075 // Allocate a new external string object, which is backed by a string
1094 // resource that resides outside the V8 heap. 1076 // resource that resides outside the V8 heap.
1095 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation 1077 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
1096 // failed. 1078 // failed.
1097 // Please note this does not perform a garbage collection. 1079 // Please note this does not perform a garbage collection.
1098 MUST_USE_RESULT MaybeObject* AllocateExternalStringFromAscii( 1080 MUST_USE_RESULT MaybeObject* AllocateExternalStringFromAscii(
1099 const ExternalAsciiString::Resource* resource); 1081 const ExternalAsciiString::Resource* resource);
1100 MUST_USE_RESULT MaybeObject* AllocateExternalStringFromTwoByte( 1082 MUST_USE_RESULT MaybeObject* AllocateExternalStringFromTwoByte(
1101 const ExternalTwoByteString::Resource* resource); 1083 const ExternalTwoByteString::Resource* resource);
1102 1084
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
1409 return FLAG_verify_heap; 1391 return FLAG_verify_heap;
1410 #else 1392 #else
1411 return false; 1393 return false;
1412 #endif 1394 #endif
1413 #endif 1395 #endif
1414 } 1396 }
1415 1397
1416 // Print short heap statistics. 1398 // Print short heap statistics.
1417 void PrintShortHeapStatistics(); 1399 void PrintShortHeapStatistics();
1418 1400
1419 // Makes a new internalized string object
1420 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
1421 // failed.
1422 // Please note this function does not perform a garbage collection.
1423 MUST_USE_RESULT MaybeObject* CreateInternalizedString(
1424 const char* str, int length, int hash);
1425 MUST_USE_RESULT MaybeObject* CreateInternalizedString(String* str);
1426
1427 // Write barrier support for address[offset] = o. 1401 // Write barrier support for address[offset] = o.
1428 INLINE(void RecordWrite(Address address, int offset)); 1402 INLINE(void RecordWrite(Address address, int offset));
1429 1403
1430 // Write barrier support for address[start : start + len[ = o. 1404 // Write barrier support for address[start : start + len[ = o.
1431 INLINE(void RecordWrites(Address address, int start, int len)); 1405 INLINE(void RecordWrites(Address address, int start, int len));
1432 1406
1433 enum HeapState { NOT_IN_GC, SCAVENGE, MARK_COMPACT }; 1407 enum HeapState { NOT_IN_GC, SCAVENGE, MARK_COMPACT };
1434 inline HeapState gc_state() { return gc_state_; } 1408 inline HeapState gc_state() { return gc_state_; }
1435 1409
1436 inline bool IsInGCPostProcessing() { return gc_post_processing_depth_ > 0; } 1410 inline bool IsInGCPostProcessing() { return gc_post_processing_depth_ > 0; }
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after
2058 void MarkMapPointersAsEncoded(bool encoded) { 2032 void MarkMapPointersAsEncoded(bool encoded) {
2059 ASSERT(!encoded); 2033 ASSERT(!encoded);
2060 gc_safe_size_of_old_object_ = &GcSafeSizeOfOldObject; 2034 gc_safe_size_of_old_object_ = &GcSafeSizeOfOldObject;
2061 } 2035 }
2062 2036
2063 // Code that should be run before and after each GC. Includes some 2037 // Code that should be run before and after each GC. Includes some
2064 // reporting/verification activities when compiled with DEBUG set. 2038 // reporting/verification activities when compiled with DEBUG set.
2065 void GarbageCollectionPrologue(); 2039 void GarbageCollectionPrologue();
2066 void GarbageCollectionEpilogue(); 2040 void GarbageCollectionEpilogue();
2067 2041
2042 // Pretenuring decisions are made based on feedback collected during new
2043 // space evacuation. Note that between feedback collection and calling this
2044 // method object in old space must not move.
2045 void ProcessPretenuringFeedback();
2046
2068 // Checks whether a global GC is necessary 2047 // Checks whether a global GC is necessary
2069 GarbageCollector SelectGarbageCollector(AllocationSpace space, 2048 GarbageCollector SelectGarbageCollector(AllocationSpace space,
2070 const char** reason); 2049 const char** reason);
2071 2050
2072 // Performs garbage collection operation. 2051 // Performs garbage collection operation.
2073 // Returns whether there is a chance that another major GC could 2052 // Returns whether there is a chance that another major GC could
2074 // collect more garbage. 2053 // collect more garbage.
2075 bool CollectGarbage(AllocationSpace space, 2054 bool CollectGarbage(AllocationSpace space,
2076 GarbageCollector collector, 2055 GarbageCollector collector,
2077 const char* gc_reason, 2056 const char* gc_reason,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
2138 // Allocate empty fixed array. 2117 // Allocate empty fixed array.
2139 MUST_USE_RESULT MaybeObject* AllocateEmptyFixedArray(); 2118 MUST_USE_RESULT MaybeObject* AllocateEmptyFixedArray();
2140 2119
2141 // Allocate empty external array of given type. 2120 // Allocate empty external array of given type.
2142 MUST_USE_RESULT MaybeObject* AllocateEmptyExternalArray( 2121 MUST_USE_RESULT MaybeObject* AllocateEmptyExternalArray(
2143 ExternalArrayType array_type); 2122 ExternalArrayType array_type);
2144 2123
2145 // Allocate empty fixed double array. 2124 // Allocate empty fixed double array.
2146 MUST_USE_RESULT MaybeObject* AllocateEmptyFixedDoubleArray(); 2125 MUST_USE_RESULT MaybeObject* AllocateEmptyFixedDoubleArray();
2147 2126
2127 // Allocate empty constant pool array.
2128 MUST_USE_RESULT MaybeObject* AllocateEmptyConstantPoolArray();
2129
2148 // Allocate a tenured simple cell. 2130 // Allocate a tenured simple cell.
2149 MUST_USE_RESULT MaybeObject* AllocateCell(Object* value); 2131 MUST_USE_RESULT MaybeObject* AllocateCell(Object* value);
2150 2132
2151 // Allocate a tenured JS global property cell initialized with the hole. 2133 // Allocate a tenured JS global property cell initialized with the hole.
2152 MUST_USE_RESULT MaybeObject* AllocatePropertyCell(); 2134 MUST_USE_RESULT MaybeObject* AllocatePropertyCell();
2153 2135
2154 // Allocate Box. 2136 // Allocate Box.
2155 MUST_USE_RESULT MaybeObject* AllocateBox(Object* value, 2137 MUST_USE_RESULT MaybeObject* AllocateBox(Object* value,
2156 PretenureFlag pretenure); 2138 PretenureFlag pretenure);
2157 2139
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
2384 2366
2385 // If the --deopt_every_n_garbage_collections flag is set to a positive value, 2367 // If the --deopt_every_n_garbage_collections flag is set to a positive value,
2386 // this variable holds the number of garbage collections since the last 2368 // this variable holds the number of garbage collections since the last
2387 // deoptimization triggered by garbage collection. 2369 // deoptimization triggered by garbage collection.
2388 int gcs_since_last_deopt_; 2370 int gcs_since_last_deopt_;
2389 2371
2390 #ifdef VERIFY_HEAP 2372 #ifdef VERIFY_HEAP
2391 int no_weak_object_verification_scope_depth_; 2373 int no_weak_object_verification_scope_depth_;
2392 #endif 2374 #endif
2393 2375
2376
2377 static const int kAllocationSiteScratchpadSize = 256;
2378 int allocation_sites_scratchpad_length;
2379 AllocationSite* allocation_sites_scratchpad[kAllocationSiteScratchpadSize];
2380
2394 static const int kMaxMarkSweepsInIdleRound = 7; 2381 static const int kMaxMarkSweepsInIdleRound = 7;
2395 static const int kIdleScavengeThreshold = 5; 2382 static const int kIdleScavengeThreshold = 5;
2396 2383
2397 // Shared state read by the scavenge collector and set by ScavengeObject. 2384 // Shared state read by the scavenge collector and set by ScavengeObject.
2398 PromotionQueue promotion_queue_; 2385 PromotionQueue promotion_queue_;
2399 2386
2400 // Flag is set when the heap has been configured. The heap can be repeatedly 2387 // Flag is set when the heap has been configured. The heap can be repeatedly
2401 // configured through the API until it is set up. 2388 // configured through the API until it is set up.
2402 bool configured_; 2389 bool configured_;
2403 2390
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
2895 static const int kRegExpResultsCacheSize = 0x100; 2882 static const int kRegExpResultsCacheSize = 0x100;
2896 2883
2897 private: 2884 private:
2898 static const int kArrayEntriesPerCacheEntry = 4; 2885 static const int kArrayEntriesPerCacheEntry = 4;
2899 static const int kStringOffset = 0; 2886 static const int kStringOffset = 0;
2900 static const int kPatternOffset = 1; 2887 static const int kPatternOffset = 1;
2901 static const int kArrayOffset = 2; 2888 static const int kArrayOffset = 2;
2902 }; 2889 };
2903 2890
2904 2891
2905 class TranscendentalCache {
2906 public:
2907 enum Type { LOG, kNumberOfCaches};
2908 static const int kTranscendentalTypeBits = 3;
2909 STATIC_ASSERT((1 << kTranscendentalTypeBits) >= kNumberOfCaches);
2910
2911 // Returns a heap number with f(input), where f is a math function specified
2912 // by the 'type' argument.
2913 MUST_USE_RESULT inline MaybeObject* Get(Type type, double input);
2914
2915 // The cache contains raw Object pointers. This method disposes of
2916 // them before a garbage collection.
2917 void Clear();
2918
2919 private:
2920 class SubCache {
2921 static const int kCacheSize = 512;
2922
2923 explicit SubCache(Isolate* isolate, Type t);
2924
2925 MUST_USE_RESULT inline MaybeObject* Get(double input);
2926
2927 inline double Calculate(double input);
2928
2929 struct Element {
2930 uint32_t in[2];
2931 Object* output;
2932 };
2933
2934 union Converter {
2935 double dbl;
2936 uint32_t integers[2];
2937 };
2938
2939 inline static int Hash(const Converter& c) {
2940 uint32_t hash = (c.integers[0] ^ c.integers[1]);
2941 hash ^= static_cast<int32_t>(hash) >> 16;
2942 hash ^= static_cast<int32_t>(hash) >> 8;
2943 return (hash & (kCacheSize - 1));
2944 }
2945
2946 Element elements_[kCacheSize];
2947 Type type_;
2948 Isolate* isolate_;
2949
2950 // Allow access to the caches_ array as an ExternalReference.
2951 friend class ExternalReference;
2952 // Inline implementation of the cache.
2953 friend class TranscendentalCacheStub;
2954 // For evaluating value.
2955 friend class TranscendentalCache;
2956
2957 DISALLOW_COPY_AND_ASSIGN(SubCache);
2958 };
2959
2960 explicit TranscendentalCache(Isolate* isolate) : isolate_(isolate) {
2961 for (int i = 0; i < kNumberOfCaches; ++i) caches_[i] = NULL;
2962 }
2963
2964 ~TranscendentalCache() {
2965 for (int i = 0; i < kNumberOfCaches; ++i) delete caches_[i];
2966 }
2967
2968 // Used to create an external reference.
2969 inline Address cache_array_address();
2970
2971 // Instantiation
2972 friend class Isolate;
2973 // Inline implementation of the caching.
2974 friend class TranscendentalCacheStub;
2975 // Allow access to the caches_ array as an ExternalReference.
2976 friend class ExternalReference;
2977
2978 Isolate* isolate_;
2979 SubCache* caches_[kNumberOfCaches];
2980 DISALLOW_COPY_AND_ASSIGN(TranscendentalCache);
2981 };
2982
2983
2984 // Abstract base class for checking whether a weak object should be retained. 2892 // Abstract base class for checking whether a weak object should be retained.
2985 class WeakObjectRetainer { 2893 class WeakObjectRetainer {
2986 public: 2894 public:
2987 virtual ~WeakObjectRetainer() {} 2895 virtual ~WeakObjectRetainer() {}
2988 2896
2989 // Return whether this object should be retained. If NULL is returned the 2897 // Return whether this object should be retained. If NULL is returned the
2990 // object has no references. Otherwise the address of the retained object 2898 // object has no references. Otherwise the address of the retained object
2991 // should be returned as in some GC situations the object has been moved. 2899 // should be returned as in some GC situations the object has been moved.
2992 virtual Object* RetainAs(Object* object) = 0; 2900 virtual Object* RetainAs(Object* object) = 0;
2993 }; 2901 };
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
3088 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. 2996 DisallowHeapAllocation no_allocation; // i.e. no gc allowed.
3089 2997
3090 private: 2998 private:
3091 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); 2999 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer);
3092 }; 3000 };
3093 #endif // DEBUG 3001 #endif // DEBUG
3094 3002
3095 } } // namespace v8::internal 3003 } } // namespace v8::internal
3096 3004
3097 #endif // V8_HEAP_H_ 3005 #endif // V8_HEAP_H_
OLDNEW
« no previous file with comments | « src/harmony-math.js ('k') | src/heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698