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

Unified Diff: src/objects.h

Issue 329253004: Optimize Map/Set.prototype.forEach (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add the runtime-gen files 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/collection.js ('k') | src/objects.cc » ('j') | src/objects-inl.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index c1ba60e972ab35b3c6b72e783a04cf91d099e8c3..11e36412a6e7378115760e8e9a19443da3becbf9 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -4509,11 +4509,11 @@ class OrderedHashMap:public OrderedHashTable<
Handle<Object> key,
Handle<Object> value);
- private:
Object* ValueAt(int entry) {
return get(EntryToIndex(entry) + kValueOffset);
}
+ private:
static const int kValueOffset = 1;
};
@@ -10199,8 +10199,22 @@ class OrderedHashTableIterator: public JSObject {
// end.
static Handle<JSObject> Next(Handle<Derived> iterator);
+ // Whether the iterator has more elements. This needs to be called before
+ // calling |CurrentKey| and/or |CurrentValue|.
+ static bool HasMore(Handle<Derived> iterator);
+
+ // Move the index forward one.
+ static void MoveNext(Handle<Derived> iterator) {
+ iterator->set_index(
+ Smi::FromInt(Smi::cast(iterator->index())->value() + 1));
+ }
+
+ // Returns the current key of the iterator. This should only be called when
+ // |HasMore| returns true.
+ static inline Handle<Object> CurrentKey(Handle<Derived> iterator);
+
private:
- // Transitions the iterator to the non obsolote backing store. This is a NOP
+ // Transitions the iterator to the non obsolete backing store. This is a NOP
// if the [table] is not obsolete.
void Transition();
@@ -10218,9 +10232,10 @@ class JSSetIterator: public OrderedHashTableIterator<JSSetIterator,
// Casting.
static inline JSSetIterator* cast(Object* obj);
- static Handle<Object> ValueForKind(
- Handle<JSSetIterator> iterator,
- int entry_index);
+ // Returns the iterator result value at the current |index| taking the |kind|
+ // into account. This should only be called when |HasMore| returns true.
+ static Handle<Object> CurrentIteratorResultValue(
+ Handle<JSSetIterator> iterator);
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(JSSetIterator);
@@ -10237,9 +10252,14 @@ class JSMapIterator: public OrderedHashTableIterator<JSMapIterator,
// Casting.
static inline JSMapIterator* cast(Object* obj);
- static Handle<Object> ValueForKind(
- Handle<JSMapIterator> iterator,
- int entry_index);
+ // Returns the iterator result value at the current |index| taking the |kind|
+ // into account. This should only be called when |HasMore| returns true.
+ static Handle<Object> CurrentIteratorResultValue(
+ Handle<JSMapIterator> iterator);
+
+ // Returns the current value of the iterator. This should only be called when
+ // |HasMore| returns true.
+ static inline Handle<Object> CurrentValue(Handle<JSMapIterator> iterator);
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(JSMapIterator);
« no previous file with comments | « src/collection.js ('k') | src/objects.cc » ('j') | src/objects-inl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698