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

Side by Side Diff: src/heap.h

Issue 6580038: [Isolates] Merge from bleeding_edge, revisions 5934-6100. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: '' Created 9 years, 9 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/globals.h ('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 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 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 // - ...FromTwoByte initializes the string from a buffer that is two-byte 483 // - ...FromTwoByte initializes the string from a buffer that is two-byte
484 // encoded. If the characters are all single-byte characters, the 484 // encoded. If the characters are all single-byte characters, the
485 // result will be converted to ASCII, otherwise it will be left as 485 // result will be converted to ASCII, otherwise it will be left as
486 // two-byte. 486 // two-byte.
487 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation 487 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
488 // failed. 488 // failed.
489 // Please note this does not perform a garbage collection. 489 // Please note this does not perform a garbage collection.
490 MUST_USE_RESULT MaybeObject* AllocateStringFromAscii( 490 MUST_USE_RESULT MaybeObject* AllocateStringFromAscii(
491 Vector<const char> str, 491 Vector<const char> str,
492 PretenureFlag pretenure = NOT_TENURED); 492 PretenureFlag pretenure = NOT_TENURED);
493 MUST_USE_RESULT MaybeObject* AllocateStringFromUtf8( 493 MUST_USE_RESULT inline MaybeObject* AllocateStringFromUtf8(
494 Vector<const char> str,
495 PretenureFlag pretenure = NOT_TENURED);
496 MUST_USE_RESULT MaybeObject* AllocateStringFromUtf8Slow(
494 Vector<const char> str, 497 Vector<const char> str,
495 PretenureFlag pretenure = NOT_TENURED); 498 PretenureFlag pretenure = NOT_TENURED);
496 MUST_USE_RESULT MaybeObject* AllocateStringFromTwoByte( 499 MUST_USE_RESULT MaybeObject* AllocateStringFromTwoByte(
497 Vector<const uc16> str, 500 Vector<const uc16> str,
498 PretenureFlag pretenure = NOT_TENURED); 501 PretenureFlag pretenure = NOT_TENURED);
499 502
500 // Allocates a symbol in old space based on the character stream. 503 // Allocates a symbol in old space based on the character stream.
501 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation 504 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
502 // failed. 505 // failed.
503 // Please note this function does not perform a garbage collection. 506 // Please note this function does not perform a garbage collection.
(...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after
1204 // scavenge since last new space expansion. 1207 // scavenge since last new space expansion.
1205 int survived_since_last_expansion_; 1208 int survived_since_last_expansion_;
1206 1209
1207 int always_allocate_scope_depth_; 1210 int always_allocate_scope_depth_;
1208 int linear_allocation_scope_depth_; 1211 int linear_allocation_scope_depth_;
1209 1212
1210 // For keeping track of context disposals. 1213 // For keeping track of context disposals.
1211 int contexts_disposed_; 1214 int contexts_disposed_;
1212 1215
1213 #if defined(V8_TARGET_ARCH_X64) 1216 #if defined(V8_TARGET_ARCH_X64)
1217 static const int kMaxObjectSizeInNewSpace = 1024*KB;
1218 #else
1214 static const int kMaxObjectSizeInNewSpace = 512*KB; 1219 static const int kMaxObjectSizeInNewSpace = 512*KB;
1215 #else
1216 static const int kMaxObjectSizeInNewSpace = 256*KB;
1217 #endif 1220 #endif
1218 1221
1219 NewSpace new_space_; 1222 NewSpace new_space_;
1220 OldSpace* old_pointer_space_; 1223 OldSpace* old_pointer_space_;
1221 OldSpace* old_data_space_; 1224 OldSpace* old_data_space_;
1222 OldSpace* code_space_; 1225 OldSpace* code_space_;
1223 MapSpace* map_space_; 1226 MapSpace* map_space_;
1224 CellSpace* cell_space_; 1227 CellSpace* cell_space_;
1225 LargeObjectSpace* lo_space_; 1228 LargeObjectSpace* lo_space_;
1226 HeapState gc_state_; 1229 HeapState gc_state_;
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
1717 1720
1718 // A HeapIterator provides iteration over the whole heap. It 1721 // A HeapIterator provides iteration over the whole heap. It
1719 // aggregates the specific iterators for the different spaces as 1722 // aggregates the specific iterators for the different spaces as
1720 // these can only iterate over one space only. 1723 // these can only iterate over one space only.
1721 // 1724 //
1722 // HeapIterator can skip free list nodes (that is, de-allocated heap 1725 // HeapIterator can skip free list nodes (that is, de-allocated heap
1723 // objects that still remain in the heap). As implementation of free 1726 // objects that still remain in the heap). As implementation of free
1724 // nodes filtering uses GC marks, it can't be used during MS/MC GC 1727 // nodes filtering uses GC marks, it can't be used during MS/MC GC
1725 // phases. Also, it is forbidden to interrupt iteration in this mode, 1728 // phases. Also, it is forbidden to interrupt iteration in this mode,
1726 // as this will leave heap objects marked (and thus, unusable). 1729 // as this will leave heap objects marked (and thus, unusable).
1727 class FreeListNodesFilter; 1730 class HeapObjectsFilter;
1728 1731
1729 class HeapIterator BASE_EMBEDDED { 1732 class HeapIterator BASE_EMBEDDED {
1730 public: 1733 public:
1731 enum FreeListNodesFiltering { 1734 enum HeapObjectsFiltering {
1732 kNoFiltering, 1735 kNoFiltering,
1733 kPreciseFiltering 1736 kFilterFreeListNodes,
1737 kFilterUnreachable
1734 }; 1738 };
1735 1739
1736 HeapIterator(); 1740 HeapIterator();
1737 explicit HeapIterator(FreeListNodesFiltering filtering); 1741 explicit HeapIterator(HeapObjectsFiltering filtering);
1738 ~HeapIterator(); 1742 ~HeapIterator();
1739 1743
1740 HeapObject* next(); 1744 HeapObject* next();
1741 void reset(); 1745 void reset();
1742 1746
1743 private: 1747 private:
1744 // Perform the initialization. 1748 // Perform the initialization.
1745 void Init(); 1749 void Init();
1746 // Perform all necessary shutdown (destruction) work. 1750 // Perform all necessary shutdown (destruction) work.
1747 void Shutdown(); 1751 void Shutdown();
1748 HeapObject* NextObject(); 1752 HeapObject* NextObject();
1749 1753
1750 FreeListNodesFiltering filtering_; 1754 HeapObjectsFiltering filtering_;
1751 FreeListNodesFilter* filter_; 1755 HeapObjectsFilter* filter_;
1752 // Space iterator for iterating all the spaces. 1756 // Space iterator for iterating all the spaces.
1753 SpaceIterator* space_iterator_; 1757 SpaceIterator* space_iterator_;
1754 // Object iterator for the space currently being iterated. 1758 // Object iterator for the space currently being iterated.
1755 ObjectIterator* object_iterator_; 1759 ObjectIterator* object_iterator_;
1756 }; 1760 };
1757 1761
1758 1762
1759 // Cache for mapping (map, property name) into field offset. 1763 // Cache for mapping (map, property name) into field offset.
1760 // Cleared at startup and prior to mark sweep collection. 1764 // Cleared at startup and prior to mark sweep collection.
1761 class KeyedLookupCache { 1765 class KeyedLookupCache {
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
2055 // Size of objects promoted during the current collection. 2059 // Size of objects promoted during the current collection.
2056 intptr_t promoted_objects_size_; 2060 intptr_t promoted_objects_size_;
2057 2061
2058 Heap* heap_; 2062 Heap* heap_;
2059 }; 2063 };
2060 2064
2061 2065
2062 class TranscendentalCache { 2066 class TranscendentalCache {
2063 public: 2067 public:
2064 enum Type {ACOS, ASIN, ATAN, COS, EXP, LOG, SIN, TAN, kNumberOfCaches}; 2068 enum Type {ACOS, ASIN, ATAN, COS, EXP, LOG, SIN, TAN, kNumberOfCaches};
2069 static const int kTranscendentalTypeBits = 3;
2070 STATIC_ASSERT((1 << kTranscendentalTypeBits) >= kNumberOfCaches);
2065 2071
2066 // Returns a heap number with f(input), where f is a math function specified 2072 // Returns a heap number with f(input), where f is a math function specified
2067 // by the 'type' argument. 2073 // by the 'type' argument.
2068 MUST_USE_RESULT inline MaybeObject* Get(Type type, double input); 2074 MUST_USE_RESULT inline MaybeObject* Get(Type type, double input);
2069 2075
2070 // The cache contains raw Object pointers. This method disposes of 2076 // The cache contains raw Object pointers. This method disposes of
2071 // them before a garbage collection. 2077 // them before a garbage collection.
2072 void Clear(); 2078 void Clear();
2073 2079
2074 private: 2080 private:
2075 class SubCache { 2081 class SubCache {
2076 static const int kCacheSize = 512; 2082 static const int kCacheSize = 512;
2077 2083
2078 explicit SubCache(Type t); 2084 explicit SubCache(Type t);
2079 2085
2080 MUST_USE_RESULT inline MaybeObject* Get(double input); 2086 MUST_USE_RESULT inline MaybeObject* Get(double input);
2081 2087
2082 inline double Calculate(double input) { 2088 inline double Calculate(double input);
2083 switch (type_) {
2084 case ACOS:
2085 return acos(input);
2086 case ASIN:
2087 return asin(input);
2088 case ATAN:
2089 return atan(input);
2090 case COS:
2091 return cos(input);
2092 case EXP:
2093 return exp(input);
2094 case LOG:
2095 return log(input);
2096 case SIN:
2097 return sin(input);
2098 case TAN:
2099 return tan(input);
2100 default:
2101 return 0.0; // Never happens.
2102 }
2103 }
2104 2089
2105 struct Element { 2090 struct Element {
2106 uint32_t in[2]; 2091 uint32_t in[2];
2107 Object* output; 2092 Object* output;
2108 }; 2093 };
2109 2094
2110 union Converter { 2095 union Converter {
2111 double dbl; 2096 double dbl;
2112 uint32_t integers[2]; 2097 uint32_t integers[2];
2113 }; 2098 };
2114 2099
2115 inline static int Hash(const Converter& c) { 2100 inline static int Hash(const Converter& c) {
2116 uint32_t hash = (c.integers[0] ^ c.integers[1]); 2101 uint32_t hash = (c.integers[0] ^ c.integers[1]);
2117 hash ^= static_cast<int32_t>(hash) >> 16; 2102 hash ^= static_cast<int32_t>(hash) >> 16;
2118 hash ^= static_cast<int32_t>(hash) >> 8; 2103 hash ^= static_cast<int32_t>(hash) >> 8;
2119 return (hash & (kCacheSize - 1)); 2104 return (hash & (kCacheSize - 1));
2120 } 2105 }
2121 2106
2122 // Inline implementation of the caching.
2123 friend class TranscendentalCacheStub;
2124
2125 // For evaluating value.
2126 friend class TranscendentalCache;
2127
2128 Element elements_[kCacheSize]; 2107 Element elements_[kCacheSize];
2129 Type type_; 2108 Type type_;
2130 Isolate* isolate_; 2109 Isolate* isolate_;
2131 2110
2111 // Allow access to the caches_ array as an ExternalReference.
2112 friend class ExternalReference;
2113 // Inline implementation of the cache.
2114 friend class TranscendentalCacheStub;
2115 // For evaluating value.
2116 friend class TranscendentalCache;
2117
2132 DISALLOW_COPY_AND_ASSIGN(SubCache); 2118 DISALLOW_COPY_AND_ASSIGN(SubCache);
2133 }; 2119 };
2134 2120
2135 TranscendentalCache() { 2121 TranscendentalCache() {
2136 for (int i = 0; i < kNumberOfCaches; ++i) caches_[i] = NULL; 2122 for (int i = 0; i < kNumberOfCaches; ++i) caches_[i] = NULL;
2137 } 2123 }
2138 2124
2139 // Used to create an external reference. 2125 // Used to create an external reference.
2140 inline Address cache_array_address(); 2126 inline Address cache_array_address();
2141 2127
(...skipping 19 matching lines...) Expand all
2161 // should be returned as in some GC situations the object has been moved. 2147 // should be returned as in some GC situations the object has been moved.
2162 virtual Object* RetainAs(Object* object) = 0; 2148 virtual Object* RetainAs(Object* object) = 0;
2163 }; 2149 };
2164 2150
2165 2151
2166 } } // namespace v8::internal 2152 } } // namespace v8::internal
2167 2153
2168 #undef HEAP 2154 #undef HEAP
2169 2155
2170 #endif // V8_HEAP_H_ 2156 #endif // V8_HEAP_H_
OLDNEW
« no previous file with comments | « src/globals.h ('k') | src/heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698