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

Side by Side Diff: src/objects.h

Issue 1149863005: Move hash code from hidden string to a private symbol (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix merge Created 5 years, 7 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
« no previous file with comments | « src/object-observe.js ('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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_OBJECTS_H_ 5 #ifndef V8_OBJECTS_H_
6 #define V8_OBJECTS_H_ 6 #define V8_OBJECTS_H_
7 7
8 #include <iosfwd> 8 #include <iosfwd>
9 9
10 #include "src/allocation.h" 10 #include "src/allocation.h"
(...skipping 1205 matching lines...) Expand 10 before | Expand all | Expand 10 after
1216 Isolate* isolate, Handle<Object> object, Handle<Object> receiver, 1216 Isolate* isolate, Handle<Object> object, Handle<Object> receiver,
1217 uint32_t index, Handle<Object> value, LanguageMode language_mode); 1217 uint32_t index, Handle<Object> value, LanguageMode language_mode);
1218 1218
1219 static inline Handle<Object> GetPrototypeSkipHiddenPrototypes( 1219 static inline Handle<Object> GetPrototypeSkipHiddenPrototypes(
1220 Isolate* isolate, Handle<Object> receiver); 1220 Isolate* isolate, Handle<Object> receiver);
1221 1221
1222 // Returns the permanent hash code associated with this object. May return 1222 // Returns the permanent hash code associated with this object. May return
1223 // undefined if not yet created. 1223 // undefined if not yet created.
1224 Object* GetHash(); 1224 Object* GetHash();
1225 1225
1226 // Returns undefined for JSObjects, but returns the hash code for simple
1227 // objects. This avoids a double lookup in the cases where we know we will
1228 // add the hash to the JSObject if it does not already exist.
1229 Object* GetSimpleHash();
1230
1226 // Returns the permanent hash code associated with this object depending on 1231 // Returns the permanent hash code associated with this object depending on
1227 // the actual object type. May create and store a hash code if needed and none 1232 // the actual object type. May create and store a hash code if needed and none
1228 // exists. 1233 // exists.
1229 static Handle<Smi> GetOrCreateHash(Isolate* isolate, Handle<Object> object); 1234 static Handle<Smi> GetOrCreateHash(Isolate* isolate, Handle<Object> object);
1230 1235
1231 // Checks whether this object has the same value as the given one. This 1236 // Checks whether this object has the same value as the given one. This
1232 // function is implemented according to ES5, section 9.12 and can be used 1237 // function is implemented according to ES5, section 9.12 and can be used
1233 // to implement the Harmony "egal" function. 1238 // to implement the Harmony "egal" function.
1234 bool SameValue(Object* other); 1239 bool SameValue(Object* other);
1235 1240
(...skipping 2191 matching lines...) Expand 10 before | Expand all | Expand 10 after
3427 PretenureFlag pretenure = NOT_TENURED); 3432 PretenureFlag pretenure = NOT_TENURED);
3428 3433
3429 DECLARE_CAST(HashTable) 3434 DECLARE_CAST(HashTable)
3430 3435
3431 // Garbage collection support. 3436 // Garbage collection support.
3432 void IteratePrefix(ObjectVisitor* visitor); 3437 void IteratePrefix(ObjectVisitor* visitor);
3433 void IterateElements(ObjectVisitor* visitor); 3438 void IterateElements(ObjectVisitor* visitor);
3434 3439
3435 // Find entry for key otherwise return kNotFound. 3440 // Find entry for key otherwise return kNotFound.
3436 inline int FindEntry(Key key); 3441 inline int FindEntry(Key key);
3442 inline int FindEntry(Isolate* isolate, Key key, int32_t hash);
3437 int FindEntry(Isolate* isolate, Key key); 3443 int FindEntry(Isolate* isolate, Key key);
3438 3444
3439 // Rehashes the table in-place. 3445 // Rehashes the table in-place.
3440 void Rehash(Key key); 3446 void Rehash(Key key);
3441 3447
3442 // Returns the key at entry. 3448 // Returns the key at entry.
3443 Object* KeyAt(int entry) { return get(EntryToIndex(entry)); } 3449 Object* KeyAt(int entry) { return get(EntryToIndex(entry)); }
3444 3450
3445 static const int kElementsStartIndex = kPrefixStartIndex + Shape::kPrefixSize; 3451 static const int kElementsStartIndex = kPrefixStartIndex + Shape::kPrefixSize;
3446 static const int kEntrySize = Shape::kEntrySize; 3452 static const int kEntrySize = Shape::kEntrySize;
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
3933 DECLARE_CAST(ObjectHashTable) 3939 DECLARE_CAST(ObjectHashTable)
3934 3940
3935 // Attempt to shrink hash table after removal of key. 3941 // Attempt to shrink hash table after removal of key.
3936 MUST_USE_RESULT static inline Handle<ObjectHashTable> Shrink( 3942 MUST_USE_RESULT static inline Handle<ObjectHashTable> Shrink(
3937 Handle<ObjectHashTable> table, 3943 Handle<ObjectHashTable> table,
3938 Handle<Object> key); 3944 Handle<Object> key);
3939 3945
3940 // Looks up the value associated with the given key. The hole value is 3946 // Looks up the value associated with the given key. The hole value is
3941 // returned in case the key is not present. 3947 // returned in case the key is not present.
3942 Object* Lookup(Handle<Object> key); 3948 Object* Lookup(Handle<Object> key);
3949 Object* Lookup(Handle<Object> key, int32_t hash);
3950 Object* Lookup(Isolate* isolate, Handle<Object> key, int32_t hash);
3943 3951
3944 // Adds (or overwrites) the value associated with the given key. 3952 // Adds (or overwrites) the value associated with the given key.
3945 static Handle<ObjectHashTable> Put(Handle<ObjectHashTable> table, 3953 static Handle<ObjectHashTable> Put(Handle<ObjectHashTable> table,
3946 Handle<Object> key, 3954 Handle<Object> key,
3947 Handle<Object> value); 3955 Handle<Object> value);
3956 static Handle<ObjectHashTable> Put(Handle<ObjectHashTable> table,
3957 Handle<Object> key, Handle<Object> value,
3958 int32_t hash);
3948 3959
3949 // Returns an ObjectHashTable (possibly |table|) where |key| has been removed. 3960 // Returns an ObjectHashTable (possibly |table|) where |key| has been removed.
3950 static Handle<ObjectHashTable> Remove(Handle<ObjectHashTable> table, 3961 static Handle<ObjectHashTable> Remove(Handle<ObjectHashTable> table,
3951 Handle<Object> key, 3962 Handle<Object> key,
3952 bool* was_present); 3963 bool* was_present);
3964 static Handle<ObjectHashTable> Remove(Handle<ObjectHashTable> table,
3965 Handle<Object> key, bool* was_present,
3966 int32_t hash);
3953 3967
3954 protected: 3968 protected:
3955 friend class MarkCompactCollector; 3969 friend class MarkCompactCollector;
3956 3970
3957 void AddEntry(int entry, Object* key, Object* value); 3971 void AddEntry(int entry, Object* key, Object* value);
3958 void RemoveEntry(int entry); 3972 void RemoveEntry(int entry);
3959 3973
3960 // Returns the index to the value of an entry. 3974 // Returns the index to the value of an entry.
3961 static inline int EntryToValueIndex(int entry) { 3975 static inline int EntryToValueIndex(int entry) {
3962 return EntryToIndex(entry) + 1; 3976 return EntryToIndex(entry) + 1;
(...skipping 7191 matching lines...) Expand 10 before | Expand all | Expand 10 after
11154 } else { 11168 } else {
11155 value &= ~(1 << bit_position); 11169 value &= ~(1 << bit_position);
11156 } 11170 }
11157 return value; 11171 return value;
11158 } 11172 }
11159 }; 11173 };
11160 11174
11161 } } // namespace v8::internal 11175 } } // namespace v8::internal
11162 11176
11163 #endif // V8_OBJECTS_H_ 11177 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/object-observe.js ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698