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

Side by Side Diff: src/objects.h

Issue 299703004: Use SameValueZero for Map and Set (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « src/collection.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 "allocation.h" 8 #include "allocation.h"
9 #include "assert-scope.h" 9 #include "assert-scope.h"
10 #include "builtins.h" 10 #include "builtins.h"
(...skipping 1493 matching lines...) Expand 10 before | Expand all | Expand 10 after
1504 // Returns the permanent hash code associated with this object depending on 1504 // Returns the permanent hash code associated with this object depending on
1505 // the actual object type. May create and store a hash code if needed and none 1505 // the actual object type. May create and store a hash code if needed and none
1506 // exists. 1506 // exists.
1507 static Handle<Smi> GetOrCreateHash(Isolate* isolate, Handle<Object> object); 1507 static Handle<Smi> GetOrCreateHash(Isolate* isolate, Handle<Object> object);
1508 1508
1509 // Checks whether this object has the same value as the given one. This 1509 // Checks whether this object has the same value as the given one. This
1510 // function is implemented according to ES5, section 9.12 and can be used 1510 // function is implemented according to ES5, section 9.12 and can be used
1511 // to implement the Harmony "egal" function. 1511 // to implement the Harmony "egal" function.
1512 bool SameValue(Object* other); 1512 bool SameValue(Object* other);
1513 1513
1514 // Checks whether this object has the same value as the given one.
1515 // +0 and -0 are treated equal. Everything else is the same as SameValue.
1516 // This function is implemented according to ES6, section 7.2.4 and is used
1517 // by ES6 Map and Set.
1518 bool SameValueZero(Object* other);
1519
1514 // Tries to convert an object to an array index. Returns true and sets 1520 // Tries to convert an object to an array index. Returns true and sets
1515 // the output parameter if it succeeds. 1521 // the output parameter if it succeeds.
1516 inline bool ToArrayIndex(uint32_t* index); 1522 inline bool ToArrayIndex(uint32_t* index);
1517 1523
1518 // Returns true if this is a JSValue containing a string and the index is 1524 // Returns true if this is a JSValue containing a string and the index is
1519 // < the length of the string. Used to implement [] on strings. 1525 // < the length of the string. Used to implement [] on strings.
1520 inline bool IsStringObjectWithCharacterAt(uint32_t index); 1526 inline bool IsStringObjectWithCharacterAt(uint32_t index);
1521 1527
1522 DECLARE_VERIFIER(Object) 1528 DECLARE_VERIFIER(Object)
1523 #ifdef VERIFY_HEAP 1529 #ifdef VERIFY_HEAP
(...skipping 2611 matching lines...) Expand 10 before | Expand all | Expand 10 after
4135 static inline int EntryToValueIndex(int entry) { 4141 static inline int EntryToValueIndex(int entry) {
4136 return EntryToIndex(entry) + 1; 4142 return EntryToIndex(entry) + 1;
4137 } 4143 }
4138 }; 4144 };
4139 4145
4140 4146
4141 // OrderedHashTable is a HashTable with Object keys that preserves 4147 // OrderedHashTable is a HashTable with Object keys that preserves
4142 // insertion order. There are Map and Set interfaces (OrderedHashMap 4148 // insertion order. There are Map and Set interfaces (OrderedHashMap
4143 // and OrderedHashTable, below). It is meant to be used by JSMap/JSSet. 4149 // and OrderedHashTable, below). It is meant to be used by JSMap/JSSet.
4144 // 4150 //
4145 // Only Object* keys are supported, with Object::SameValue() used as the 4151 // Only Object* keys are supported, with Object::SameValueZero() used as the
4146 // equality operator and Object::GetHash() for the hash function. 4152 // equality operator and Object::GetHash() for the hash function.
4147 // 4153 //
4148 // Based on the "Deterministic Hash Table" as described by Jason Orendorff at 4154 // Based on the "Deterministic Hash Table" as described by Jason Orendorff at
4149 // https://wiki.mozilla.org/User:Jorend/Deterministic_hash_tables 4155 // https://wiki.mozilla.org/User:Jorend/Deterministic_hash_tables
4150 // Originally attributed to Tyler Close. 4156 // Originally attributed to Tyler Close.
4151 // 4157 //
4152 // Memory layout: 4158 // Memory layout:
4153 // [0]: bucket count 4159 // [0]: bucket count
4154 // [1]: element count 4160 // [1]: element count
4155 // [2]: deleted element count 4161 // [2]: deleted element count
(...skipping 6954 matching lines...) Expand 10 before | Expand all | Expand 10 after
11110 } else { 11116 } else {
11111 value &= ~(1 << bit_position); 11117 value &= ~(1 << bit_position);
11112 } 11118 }
11113 return value; 11119 return value;
11114 } 11120 }
11115 }; 11121 };
11116 11122
11117 } } // namespace v8::internal 11123 } } // namespace v8::internal
11118 11124
11119 #endif // V8_OBJECTS_H_ 11125 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/collection.js ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698