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

Side by Side Diff: src/objects.h

Issue 329253004: Optimize Map/Set.prototype.forEach (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Unhandlify Created 6 years, 6 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') | src/objects.cc » ('J')
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 "src/allocation.h" 8 #include "src/allocation.h"
9 #include "src/assert-scope.h" 9 #include "src/assert-scope.h"
10 #include "src/builtins.h" 10 #include "src/builtins.h"
(...skipping 4491 matching lines...) Expand 10 before | Expand all | Expand 10 after
4502 ASSERT(obj->IsOrderedHashTable()); 4502 ASSERT(obj->IsOrderedHashTable());
4503 return reinterpret_cast<OrderedHashMap*>(obj); 4503 return reinterpret_cast<OrderedHashMap*>(obj);
4504 } 4504 }
4505 4505
4506 Object* Lookup(Handle<Object> key); 4506 Object* Lookup(Handle<Object> key);
4507 static Handle<OrderedHashMap> Put( 4507 static Handle<OrderedHashMap> Put(
4508 Handle<OrderedHashMap> table, 4508 Handle<OrderedHashMap> table,
4509 Handle<Object> key, 4509 Handle<Object> key,
4510 Handle<Object> value); 4510 Handle<Object> value);
4511 4511
4512 private:
4513 Object* ValueAt(int entry) { 4512 Object* ValueAt(int entry) {
4514 return get(EntryToIndex(entry) + kValueOffset); 4513 return get(EntryToIndex(entry) + kValueOffset);
4515 } 4514 }
4516 4515
4516 private:
4517 static const int kValueOffset = 1; 4517 static const int kValueOffset = 1;
4518 }; 4518 };
4519 4519
4520 4520
4521 template <int entrysize> 4521 template <int entrysize>
4522 class WeakHashTableShape : public BaseShape<Handle<Object> > { 4522 class WeakHashTableShape : public BaseShape<Handle<Object> > {
4523 public: 4523 public:
4524 static inline bool IsMatch(Handle<Object> key, Object* other); 4524 static inline bool IsMatch(Handle<Object> key, Object* other);
4525 static inline uint32_t Hash(Handle<Object> key); 4525 static inline uint32_t Hash(Handle<Object> key);
4526 static inline uint32_t HashForObject(Handle<Object> key, Object* object); 4526 static inline uint32_t HashForObject(Handle<Object> key, Object* object);
(...skipping 5665 matching lines...) Expand 10 before | Expand all | Expand 10 after
10192 kKindKeys = 1, 10192 kKindKeys = 1,
10193 kKindValues = 2, 10193 kKindValues = 2,
10194 kKindEntries = 3 10194 kKindEntries = 3
10195 }; 10195 };
10196 10196
10197 // Returns an iterator result object: {value: any, done: boolean} and moves 10197 // Returns an iterator result object: {value: any, done: boolean} and moves
10198 // the index to the next valid entry. Closes the iterator if moving past the 10198 // the index to the next valid entry. Closes the iterator if moving past the
10199 // end. 10199 // end.
10200 static Handle<JSObject> Next(Handle<Derived> iterator); 10200 static Handle<JSObject> Next(Handle<Derived> iterator);
10201 10201
10202 // Whether the iterator has more elements. This needs to be called before
10203 // calling |CurrentKey| and/or |CurrentValue|.
10204 static bool HasMore(Handle<Derived> iterator);
10205
10206 // Move the index forward one.
10207 void MoveNext() {
10208 set_index(Smi::FromInt(Smi::cast(index())->value() + 1));
10209 }
10210
10211 // Returns the current key of the iterator. This should only be called when
10212 // |HasMore| returns true.
10213 inline Object* CurrentKey();
10214
10202 private: 10215 private:
10203 // Transitions the iterator to the non obsolote backing store. This is a NOP 10216 // Transitions the iterator to the non obsolete backing store. This is a NOP
10204 // if the [table] is not obsolete. 10217 // if the [table] is not obsolete.
10205 void Transition(); 10218 void Transition();
10206 10219
10207 DISALLOW_IMPLICIT_CONSTRUCTORS(OrderedHashTableIterator); 10220 DISALLOW_IMPLICIT_CONSTRUCTORS(OrderedHashTableIterator);
10208 }; 10221 };
10209 10222
10210 10223
10211 class JSSetIterator: public OrderedHashTableIterator<JSSetIterator, 10224 class JSSetIterator: public OrderedHashTableIterator<JSSetIterator,
10212 OrderedHashSet> { 10225 OrderedHashSet> {
10213 public: 10226 public:
10214 // Dispatched behavior. 10227 // Dispatched behavior.
10215 DECLARE_PRINTER(JSSetIterator) 10228 DECLARE_PRINTER(JSSetIterator)
10216 DECLARE_VERIFIER(JSSetIterator) 10229 DECLARE_VERIFIER(JSSetIterator)
10217 10230
10218 // Casting. 10231 // Casting.
10219 static inline JSSetIterator* cast(Object* obj); 10232 static inline JSSetIterator* cast(Object* obj);
10220 10233
10221 static Handle<Object> ValueForKind( 10234 // Returns the iterator result value at the current |index| taking the |kind|
10222 Handle<JSSetIterator> iterator, 10235 // into account. This should only be called when |HasMore| returns true.
10223 int entry_index); 10236 static Handle<Object> CurrentIteratorResultValue(
10237 Handle<JSSetIterator> iterator);
10224 10238
10225 private: 10239 private:
10226 DISALLOW_IMPLICIT_CONSTRUCTORS(JSSetIterator); 10240 DISALLOW_IMPLICIT_CONSTRUCTORS(JSSetIterator);
10227 }; 10241 };
10228 10242
10229 10243
10230 class JSMapIterator: public OrderedHashTableIterator<JSMapIterator, 10244 class JSMapIterator: public OrderedHashTableIterator<JSMapIterator,
10231 OrderedHashMap> { 10245 OrderedHashMap> {
10232 public: 10246 public:
10233 // Dispatched behavior. 10247 // Dispatched behavior.
10234 DECLARE_PRINTER(JSMapIterator) 10248 DECLARE_PRINTER(JSMapIterator)
10235 DECLARE_VERIFIER(JSMapIterator) 10249 DECLARE_VERIFIER(JSMapIterator)
10236 10250
10237 // Casting. 10251 // Casting.
10238 static inline JSMapIterator* cast(Object* obj); 10252 static inline JSMapIterator* cast(Object* obj);
10239 10253
10240 static Handle<Object> ValueForKind( 10254 // Returns the iterator result value at the current |index| taking the |kind|
10241 Handle<JSMapIterator> iterator, 10255 // into account. This should only be called when |HasMore| returns true.
10242 int entry_index); 10256 static Handle<Object> CurrentIteratorResultValue(
10257 Handle<JSMapIterator> iterator);
10258
10259 // Returns the current value of the iterator. This should only be called when
10260 // |HasMore| returns true.
10261 inline Object* CurrentValue();
10243 10262
10244 private: 10263 private:
10245 DISALLOW_IMPLICIT_CONSTRUCTORS(JSMapIterator); 10264 DISALLOW_IMPLICIT_CONSTRUCTORS(JSMapIterator);
10246 }; 10265 };
10247 10266
10248 10267
10249 // Base class for both JSWeakMap and JSWeakSet 10268 // Base class for both JSWeakMap and JSWeakSet
10250 class JSWeakCollection: public JSObject { 10269 class JSWeakCollection: public JSObject {
10251 public: 10270 public:
10252 // [table]: the backing hash table mapping keys to values. 10271 // [table]: the backing hash table mapping keys to values.
(...skipping 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after
11269 } else { 11288 } else {
11270 value &= ~(1 << bit_position); 11289 value &= ~(1 << bit_position);
11271 } 11290 }
11272 return value; 11291 return value;
11273 } 11292 }
11274 }; 11293 };
11275 11294
11276 } } // namespace v8::internal 11295 } } // namespace v8::internal
11277 11296
11278 #endif // V8_OBJECTS_H_ 11297 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/collection.js ('k') | src/objects.cc » ('j') | src/objects.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698