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

Unified Diff: src/objects.h

Issue 1302173007: [es6] Introduce a dedicated JSIteratorResult type. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 3 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/hydrogen.cc ('k') | src/objects-debug.cc » ('j') | no next file with comments »
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 869253741702f8596dd45b59517bb816437b3414..1a80140c393a0638207dde60567403ffba8d0739 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -431,6 +431,7 @@ const int kStubMinorKeyBits = kSmiValueSize - kStubMajorKeyBits - 1;
V(JS_MAP_TYPE) \
V(JS_SET_ITERATOR_TYPE) \
V(JS_MAP_ITERATOR_TYPE) \
+ V(JS_ITERATOR_RESULT_TYPE) \
V(JS_WEAK_MAP_TYPE) \
V(JS_WEAK_SET_TYPE) \
V(JS_REGEXP_TYPE) \
@@ -729,6 +730,7 @@ enum InstanceType {
JS_MAP_TYPE,
JS_SET_ITERATOR_TYPE,
JS_MAP_ITERATOR_TYPE,
+ JS_ITERATOR_RESULT_TYPE,
JS_WEAK_MAP_TYPE,
JS_WEAK_SET_TYPE,
JS_REGEXP_TYPE,
@@ -957,6 +959,7 @@ template <class C> inline bool Is(Object* obj);
V(JSMap) \
V(JSSetIterator) \
V(JSMapIterator) \
+ V(JSIteratorResult) \
V(JSWeakCollection) \
V(JSWeakMap) \
V(JSWeakSet) \
@@ -6851,17 +6854,6 @@ class JSGeneratorObject: public JSObject {
// Resume mode, for use by runtime functions.
enum ResumeMode { NEXT, THROW };
- // Yielding from a generator returns an object with the following inobject
- // properties. See Context::iterator_result_map() for the map.
- static const int kResultValuePropertyIndex = 0;
- static const int kResultDonePropertyIndex = 1;
- static const int kResultPropertyCount = 2;
-
- static const int kResultValuePropertyOffset = JSObject::kHeaderSize;
- static const int kResultDonePropertyOffset =
- kResultValuePropertyOffset + kPointerSize;
- static const int kResultSize = kResultDonePropertyOffset + kPointerSize;
-
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(JSGeneratorObject);
};
@@ -9480,6 +9472,40 @@ class JSMapIterator: public OrderedHashTableIterator<JSMapIterator,
};
+// ES6 section 25.1.1.3 The IteratorResult Interface
+class JSIteratorResult final : public JSObject {
+ public:
+ // [done]: This is the result status of an iterator next method call. If the
+ // end of the iterator was reached done is true. If the end was not reached
+ // done is false and a [value] is available.
+ DECL_ACCESSORS(done, Object)
+
+ // [value]: If [done] is false, this is the current iteration element value.
+ // If [done] is true, this is the return value of the iterator, if it supplied
+ // one. If the iterator does not have a return value, value is undefined.
+ // In that case, the value property may be absent from the conforming object
+ // if it does not inherit an explicit value property.
+ DECL_ACCESSORS(value, Object)
+
+ // Dispatched behavior.
+ DECLARE_PRINTER(JSIteratorResult)
+ DECLARE_VERIFIER(JSIteratorResult)
+
+ DECLARE_CAST(JSIteratorResult)
+
+ static const int kValueOffset = JSObject::kHeaderSize;
+ static const int kDoneOffset = kValueOffset + kPointerSize;
+ static const int kSize = kDoneOffset + kPointerSize;
+
+ // Indices of in-object properties.
+ static const int kValueIndex = 0;
+ static const int kDoneIndex = 1;
+
+ private:
+ DISALLOW_IMPLICIT_CONSTRUCTORS(JSIteratorResult);
+};
+
+
// Base class for both JSWeakMap and JSWeakSet
class JSWeakCollection: public JSObject {
public:
« no previous file with comments | « src/hydrogen.cc ('k') | src/objects-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698