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

Unified Diff: src/objects.h

Issue 2622833002: WIP [esnext] implement async iteration proposal (Closed)
Patch Set: simplify AsyncIteratorValueUnwrap Created 3 years, 11 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/messages.h ('k') | src/objects.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 b76d3357a32e9f4c2fc3750895f75471d3fd5909..ede48953b7b5998aca3998f17df4b71ff1e1c63a 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -390,6 +390,7 @@ const int kStubMinorKeyBits = kSmiValueSize - kStubMajorKeyBits - 1;
V(PROMISE_REACTION_JOB_INFO_TYPE) \
V(DEBUG_INFO_TYPE) \
V(BREAK_POINT_INFO_TYPE) \
+ V(ASYNC_GENERATOR_REQUEST_TYPE) \
V(PROTOTYPE_INFO_TYPE) \
V(TUPLE2_TYPE) \
V(TUPLE3_TYPE) \
@@ -416,6 +417,8 @@ const int kStubMinorKeyBits = kSmiValueSize - kStubMajorKeyBits - 1;
V(JS_ARGUMENTS_TYPE) \
V(JS_CONTEXT_EXTENSION_OBJECT_TYPE) \
V(JS_GENERATOR_OBJECT_TYPE) \
+ V(JS_ASYNC_GENERATOR_OBJECT_TYPE) \
+ V(JS_ASYNC_FROM_SYNC_ITERATOR_TYPE) \
V(JS_MODULE_NAMESPACE_TYPE) \
V(JS_ARRAY_TYPE) \
V(JS_ARRAY_BUFFER_TYPE) \
@@ -565,7 +568,8 @@ const int kStubMinorKeyBits = kSmiValueSize - kStubMajorKeyBits - 1;
V(CONTEXT_EXTENSION, ContextExtension, context_extension) \
V(CONSTANT_ELEMENTS_PAIR, ConstantElementsPair, constant_elements_pair) \
V(MODULE, Module, module) \
- V(MODULE_INFO_ENTRY, ModuleInfoEntry, module_info_entry)
+ V(MODULE_INFO_ENTRY, ModuleInfoEntry, module_info_entry) \
+ V(ASYNC_GENERATOR_REQUEST, AsyncGeneratorRequest, async_generator_request)
// We use the full 8 bits of the instance_type field to encode heap object
// instance types. The high-order bit (bit 7) is set if the object is not a
@@ -729,6 +733,7 @@ enum InstanceType {
BOX_TYPE,
PROMISE_RESOLVE_THENABLE_JOB_INFO_TYPE,
PROMISE_REACTION_JOB_INFO_TYPE,
+ ASYNC_GENERATOR_REQUEST_TYPE,
DEBUG_INFO_TYPE,
BREAK_POINT_INFO_TYPE,
PROTOTYPE_INFO_TYPE,
@@ -764,6 +769,8 @@ enum InstanceType {
JS_ARGUMENTS_TYPE,
JS_CONTEXT_EXTENSION_OBJECT_TYPE,
JS_GENERATOR_OBJECT_TYPE,
+ JS_ASYNC_GENERATOR_OBJECT_TYPE,
+ JS_ASYNC_FROM_SYNC_ITERATOR_TYPE,
JS_MODULE_NAMESPACE_TYPE,
JS_ARRAY_TYPE,
JS_ARRAY_BUFFER_TYPE,
@@ -1054,8 +1061,10 @@ template <class C> inline bool Is(Object* obj);
V(JSReceiver) \
V(JSObject) \
V(JSArgumentsObject) \
+ V(JSAsyncFromSyncIterator) \
V(JSContextExtensionObject) \
V(JSGeneratorObject) \
+ V(JSAsyncGeneratorObject) \
V(JSModuleNamespace) \
V(Map) \
V(DescriptorArray) \
@@ -2763,6 +2772,27 @@ class JSIteratorResult: public JSObject {
DISALLOW_IMPLICIT_CONSTRUCTORS(JSIteratorResult);
};
+class JSAsyncFromSyncIterator : public JSObject {
+ public:
+ DECLARE_CAST(JSAsyncFromSyncIterator)
+
+ DECLARE_PRINTER(JSAsyncFromSyncIterator)
+ DECLARE_VERIFIER(JSAsyncFromSyncIterator)
+
+ // Async-from-Sync Iterator instances are ordinary objects that inherit
+ // properties from the %AsyncFromSyncIteratorPrototype% intrinsic object.
+ // Async-from-Sync Iterator instances are initially created with the internal
+ // slots listed in Table 4.
+ // (proposal-async-iteration/#table-async-from-sync-iterator-internal-slots)
+ DECL_ACCESSORS(sync_iterator, HeapObject)
+
+ // Offsets of object fields.
+ static const int kSyncIteratorOffset = JSObject::kHeaderSize;
+ static const int kSize = kSyncIteratorOffset + kPointerSize;
+
+ private:
+ DISALLOW_IMPLICIT_CONSTRUCTORS(JSAsyncFromSyncIterator);
+};
// Common superclass for JSSloppyArgumentsObject and JSStrictArgumentsObject.
class JSArgumentsObject: public JSObject {
@@ -6642,6 +6672,28 @@ class PromiseReactionJobInfo : public Struct {
DISALLOW_IMPLICIT_CONSTRUCTORS(PromiseReactionJobInfo);
};
+class AsyncGeneratorRequest : public Struct {
+ public:
+ // Holds an AsyncGeneratorRequest, or Undefined.
+ DECL_ACCESSORS(next, Object)
+ DECL_INT_ACCESSORS(resume_mode)
+ DECL_ACCESSORS(value, Object)
+ DECL_ACCESSORS(promise, Object)
+
+ static const int kNextOffset = Struct::kHeaderSize;
+ static const int kResumeModeOffset = kNextOffset + kPointerSize;
+ static const int kValueOffset = kResumeModeOffset + kPointerSize;
+ static const int kPromiseOffset = kValueOffset + kPointerSize;
+ static const int kSize = kPromiseOffset + kPointerSize;
+
+ DECLARE_CAST(AsyncGeneratorRequest)
+ DECLARE_PRINTER(AsyncGeneratorRequest)
+ DECLARE_VERIFIER(AsyncGeneratorRequest)
+
+ private:
+ DISALLOW_IMPLICIT_CONSTRUCTORS(AsyncGeneratorRequest);
+};
+
// A simple one-element struct, useful where smis need to be boxed.
class Box : public Struct {
public:
@@ -7935,6 +7987,38 @@ class JSGeneratorObject: public JSObject {
DISALLOW_IMPLICIT_CONSTRUCTORS(JSGeneratorObject);
};
+class JSAsyncGeneratorObject : public JSGeneratorObject {
+ public:
+ DECLARE_CAST(JSAsyncGeneratorObject)
+
+ // Dispatched behavior.
+ DECLARE_VERIFIER(JSAsyncGeneratorObject)
+
+ // [queue]
+ // Pointer to the head of a singly linked list of AsyncGeneratorRequest, or
+ // undefined.
+ DECL_ACCESSORS(queue, HeapObject)
+
+ // [await_input]
+ // Holds the value to resume generator with after an Await(), in order to
+ // avoid clobbering function.sent. If awaited_promise is not undefined, holds
+ // current bytecode offset for debugging instead.
+ DECL_ACCESSORS(await_input, Object)
+
+ // [awaited_promise]
+ // A reference to the Promise of an AwaitExpression.
+ DECL_ACCESSORS(awaited_promise, HeapObject)
+
+ // Layout description.
+ static const int kQueueOffset = JSGeneratorObject::kSize;
+ static const int kAwaitInputOffset = kQueueOffset + kPointerSize;
+ static const int kAwaitedPromiseOffset = kAwaitInputOffset + kPointerSize;
+ static const int kSize = kAwaitedPromiseOffset + kPointerSize;
+
+ private:
+ DISALLOW_IMPLICIT_CONSTRUCTORS(JSAsyncGeneratorObject);
+};
+
class ModuleInfoEntry : public Struct {
public:
DECLARE_CAST(ModuleInfoEntry)
« no previous file with comments | « src/messages.h ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698