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

Side by Side Diff: src/objects.h

Issue 9174023: Split NumberDictionary into a randomly seeded and an unseeded (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 8 years, 11 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/mips/macro-assembler-mips.cc ('k') | src/objects.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 1467 matching lines...) Expand 10 before | Expand all | Expand 10 after
1478 inline bool HasExternalByteElements(); 1478 inline bool HasExternalByteElements();
1479 inline bool HasExternalUnsignedByteElements(); 1479 inline bool HasExternalUnsignedByteElements();
1480 inline bool HasExternalShortElements(); 1480 inline bool HasExternalShortElements();
1481 inline bool HasExternalUnsignedShortElements(); 1481 inline bool HasExternalUnsignedShortElements();
1482 inline bool HasExternalIntElements(); 1482 inline bool HasExternalIntElements();
1483 inline bool HasExternalUnsignedIntElements(); 1483 inline bool HasExternalUnsignedIntElements();
1484 inline bool HasExternalFloatElements(); 1484 inline bool HasExternalFloatElements();
1485 inline bool HasExternalDoubleElements(); 1485 inline bool HasExternalDoubleElements();
1486 bool HasFastArgumentsElements(); 1486 bool HasFastArgumentsElements();
1487 bool HasDictionaryArgumentsElements(); 1487 bool HasDictionaryArgumentsElements();
1488 inline NumberDictionary* element_dictionary(); // Gets slow elements. 1488 inline SeededNumberDictionary* element_dictionary(); // Gets slow elements.
1489 1489
1490 inline void set_map_and_elements( 1490 inline void set_map_and_elements(
1491 Map* map, 1491 Map* map,
1492 FixedArrayBase* value, 1492 FixedArrayBase* value,
1493 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); 1493 WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
1494 1494
1495 // Requires: HasFastElements(). 1495 // Requires: HasFastElements().
1496 MUST_USE_RESULT inline MaybeObject* EnsureWritableFastElements(); 1496 MUST_USE_RESULT inline MaybeObject* EnsureWritableFastElements();
1497 1497
1498 // Collects elements starting at index 0. 1498 // Collects elements starting at index 0.
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
1901 // added this number can be indicated to have the backing store allocated to 1901 // added this number can be indicated to have the backing store allocated to
1902 // an initial capacity for holding these properties. 1902 // an initial capacity for holding these properties.
1903 static void NormalizeProperties(Handle<JSObject> object, 1903 static void NormalizeProperties(Handle<JSObject> object,
1904 PropertyNormalizationMode mode, 1904 PropertyNormalizationMode mode,
1905 int expected_additional_properties); 1905 int expected_additional_properties);
1906 1906
1907 MUST_USE_RESULT MaybeObject* NormalizeProperties( 1907 MUST_USE_RESULT MaybeObject* NormalizeProperties(
1908 PropertyNormalizationMode mode, 1908 PropertyNormalizationMode mode,
1909 int expected_additional_properties); 1909 int expected_additional_properties);
1910 1910
1911 // Convert and update the elements backing store to be a NumberDictionary 1911 // Convert and update the elements backing store to be a
1912 // dictionary. Returns the backing after conversion. 1912 // SeededNumberDictionary dictionary. Returns the backing after conversion.
1913 static Handle<NumberDictionary> NormalizeElements(Handle<JSObject> object); 1913 static Handle<SeededNumberDictionary> NormalizeElements(
1914 Handle<JSObject> object);
1914 1915
1915 MUST_USE_RESULT MaybeObject* NormalizeElements(); 1916 MUST_USE_RESULT MaybeObject* NormalizeElements();
1916 1917
1917 static void UpdateMapCodeCache(Handle<JSObject> object, 1918 static void UpdateMapCodeCache(Handle<JSObject> object,
1918 Handle<String> name, 1919 Handle<String> name,
1919 Handle<Code> code); 1920 Handle<Code> code);
1920 1921
1921 MUST_USE_RESULT MaybeObject* UpdateMapCodeCache(String* name, Code* code); 1922 MUST_USE_RESULT MaybeObject* UpdateMapCodeCache(String* name, Code* code);
1922 1923
1923 // Transform slow named properties to fast variants. 1924 // Transform slow named properties to fast variants.
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
2270 private: 2271 private:
2271 DISALLOW_IMPLICIT_CONSTRUCTORS(FixedArray); 2272 DISALLOW_IMPLICIT_CONSTRUCTORS(FixedArray);
2272 }; 2273 };
2273 2274
2274 2275
2275 // FixedDoubleArray describes fixed-sized arrays with element type double. 2276 // FixedDoubleArray describes fixed-sized arrays with element type double.
2276 class FixedDoubleArray: public FixedArrayBase { 2277 class FixedDoubleArray: public FixedArrayBase {
2277 public: 2278 public:
2278 inline void Initialize(FixedArray* from); 2279 inline void Initialize(FixedArray* from);
2279 inline void Initialize(FixedDoubleArray* from); 2280 inline void Initialize(FixedDoubleArray* from);
2280 inline void Initialize(NumberDictionary* from); 2281 inline void Initialize(SeededNumberDictionary* from);
2281 2282
2282 // Setter and getter for elements. 2283 // Setter and getter for elements.
2283 inline double get_scalar(int index); 2284 inline double get_scalar(int index);
2284 inline MaybeObject* get(int index); 2285 inline MaybeObject* get(int index);
2285 inline void set(int index, double value); 2286 inline void set(int index, double value);
2286 inline void set_the_hole(int index); 2287 inline void set_the_hole(int index);
2287 2288
2288 // Checking for the hole. 2289 // Checking for the hole.
2289 inline bool is_the_hole(int index); 2290 inline bool is_the_hole(int index);
2290 2291
(...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after
3031 int unused_property_fields); 3032 int unused_property_fields);
3032 3033
3033 // Find entry for key, otherwise return kNotFound. Optimized version of 3034 // Find entry for key, otherwise return kNotFound. Optimized version of
3034 // HashTable::FindEntry. 3035 // HashTable::FindEntry.
3035 int FindEntry(String* key); 3036 int FindEntry(String* key);
3036 }; 3037 };
3037 3038
3038 3039
3039 class NumberDictionaryShape : public BaseShape<uint32_t> { 3040 class NumberDictionaryShape : public BaseShape<uint32_t> {
3040 public: 3041 public:
3041 static const bool UsesSeed = true;
3042
3043 static inline bool IsMatch(uint32_t key, Object* other); 3042 static inline bool IsMatch(uint32_t key, Object* other);
3044 static inline uint32_t Hash(uint32_t key);
3045 static inline uint32_t SeededHash(uint32_t key, uint32_t seed);
3046 static inline uint32_t HashForObject(uint32_t key, Object* object);
3047 static inline uint32_t SeededHashForObject(uint32_t key,
3048 uint32_t seed,
3049 Object* object);
3050 MUST_USE_RESULT static inline MaybeObject* AsObject(uint32_t key); 3043 MUST_USE_RESULT static inline MaybeObject* AsObject(uint32_t key);
3051 static const int kPrefixSize = 2;
3052 static const int kEntrySize = 3; 3044 static const int kEntrySize = 3;
3053 static const bool kIsEnumerable = false; 3045 static const bool kIsEnumerable = false;
3054 }; 3046 };
3055 3047
3056 3048
3057 class NumberDictionary: public Dictionary<NumberDictionaryShape, uint32_t> { 3049 class SeededNumberDictionaryShape : public NumberDictionaryShape {
3058 public: 3050 public:
3059 static NumberDictionary* cast(Object* obj) { 3051 static const bool UsesSeed = true;
3052 static const int kPrefixSize = 2;
3053
3054 static inline uint32_t SeededHash(uint32_t key, uint32_t seed);
3055 static inline uint32_t SeededHashForObject(uint32_t key,
3056 uint32_t seed,
3057 Object* object);
3058 };
3059
3060
3061 class UnseededNumberDictionaryShape : public NumberDictionaryShape {
3062 public:
3063 static const int kPrefixSize = 0;
3064
3065 static inline uint32_t Hash(uint32_t key);
3066 static inline uint32_t HashForObject(uint32_t key, Object* object);
3067 };
3068
3069
3070 class SeededNumberDictionary
3071 : public Dictionary<SeededNumberDictionaryShape, uint32_t> {
3072 public:
3073 static SeededNumberDictionary* cast(Object* obj) {
3060 ASSERT(obj->IsDictionary()); 3074 ASSERT(obj->IsDictionary());
3061 return reinterpret_cast<NumberDictionary*>(obj); 3075 return reinterpret_cast<SeededNumberDictionary*>(obj);
3062 } 3076 }
3063 3077
3064 // Type specific at put (default NONE attributes is used when adding). 3078 // Type specific at put (default NONE attributes is used when adding).
3065 MUST_USE_RESULT MaybeObject* AtNumberPut(uint32_t key, Object* value); 3079 MUST_USE_RESULT MaybeObject* AtNumberPut(uint32_t key, Object* value);
3066 MUST_USE_RESULT MaybeObject* AddNumberEntry(uint32_t key, 3080 MUST_USE_RESULT MaybeObject* AddNumberEntry(uint32_t key,
3067 Object* value, 3081 Object* value,
3068 PropertyDetails details); 3082 PropertyDetails details);
3069 3083
3070 // Set an existing entry or add a new one if needed. 3084 // Set an existing entry or add a new one if needed.
3071 // Return the updated dictionary. 3085 // Return the updated dictionary.
3072 MUST_USE_RESULT static Handle<NumberDictionary> Set( 3086 MUST_USE_RESULT static Handle<SeededNumberDictionary> Set(
3073 Handle<NumberDictionary> dictionary, 3087 Handle<SeededNumberDictionary> dictionary,
3074 uint32_t index, 3088 uint32_t index,
3075 Handle<Object> value, 3089 Handle<Object> value,
3076 PropertyDetails details); 3090 PropertyDetails details);
3077 3091
3078 MUST_USE_RESULT MaybeObject* Set(uint32_t key, 3092 MUST_USE_RESULT MaybeObject* Set(uint32_t key,
3079 Object* value, 3093 Object* value,
3080 PropertyDetails details); 3094 PropertyDetails details);
3081 3095
3082 void UpdateMaxNumberKey(uint32_t key); 3096 void UpdateMaxNumberKey(uint32_t key);
3083 3097
(...skipping 10 matching lines...) Expand all
3094 // requires_slow_elements returns false. 3108 // requires_slow_elements returns false.
3095 inline uint32_t max_number_key(); 3109 inline uint32_t max_number_key();
3096 3110
3097 // Bit masks. 3111 // Bit masks.
3098 static const int kRequiresSlowElementsMask = 1; 3112 static const int kRequiresSlowElementsMask = 1;
3099 static const int kRequiresSlowElementsTagSize = 1; 3113 static const int kRequiresSlowElementsTagSize = 1;
3100 static const uint32_t kRequiresSlowElementsLimit = (1 << 29) - 1; 3114 static const uint32_t kRequiresSlowElementsLimit = (1 << 29) - 1;
3101 }; 3115 };
3102 3116
3103 3117
3118 class UnseededNumberDictionary
3119 : public Dictionary<UnseededNumberDictionaryShape, uint32_t> {
3120 public:
3121 static UnseededNumberDictionary* cast(Object* obj) {
3122 ASSERT(obj->IsDictionary());
3123 return reinterpret_cast<UnseededNumberDictionary*>(obj);
3124 }
3125
3126 // Type specific at put (default NONE attributes is used when adding).
3127 MUST_USE_RESULT MaybeObject* AtNumberPut(uint32_t key, Object* value);
3128 MUST_USE_RESULT MaybeObject* AddNumberEntry(uint32_t key, Object* value);
3129
3130 // Set an existing entry or add a new one if needed.
3131 // Return the updated dictionary.
3132 MUST_USE_RESULT static Handle<UnseededNumberDictionary> Set(
3133 Handle<UnseededNumberDictionary> dictionary,
3134 uint32_t index,
3135 Handle<Object> value);
3136
3137 MUST_USE_RESULT MaybeObject* Set(uint32_t key, Object* value);
3138 };
3139
3140
3104 template <int entrysize> 3141 template <int entrysize>
3105 class ObjectHashTableShape : public BaseShape<Object*> { 3142 class ObjectHashTableShape : public BaseShape<Object*> {
3106 public: 3143 public:
3107 static inline bool IsMatch(Object* key, Object* other); 3144 static inline bool IsMatch(Object* key, Object* other);
3108 static inline uint32_t Hash(Object* key); 3145 static inline uint32_t Hash(Object* key);
3109 static inline uint32_t HashForObject(Object* key, Object* object); 3146 static inline uint32_t HashForObject(Object* key, Object* object);
3110 MUST_USE_RESULT static inline MaybeObject* AsObject(Object* key); 3147 MUST_USE_RESULT static inline MaybeObject* AsObject(Object* key);
3111 static const int kPrefixSize = 0; 3148 static const int kPrefixSize = 0;
3112 static const int kEntrySize = entrysize; 3149 static const int kEntrySize = entrysize;
3113 }; 3150 };
(...skipping 5040 matching lines...) Expand 10 before | Expand all | Expand 10 after
8154 } else { 8191 } else {
8155 value &= ~(1 << bit_position); 8192 value &= ~(1 << bit_position);
8156 } 8193 }
8157 return value; 8194 return value;
8158 } 8195 }
8159 }; 8196 };
8160 8197
8161 } } // namespace v8::internal 8198 } } // namespace v8::internal
8162 8199
8163 #endif // V8_OBJECTS_H_ 8200 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/mips/macro-assembler-mips.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698