Line data Source code
1 : // Copyright 2018 the V8 project authors. All rights reserved.
2 : // Use of this source code is governed by a BSD-style license that can be
3 : // found in the LICENSE file.
4 :
5 : #ifndef V8_OBJECTS_JS_GENERATOR_INL_H_
6 : #define V8_OBJECTS_JS_GENERATOR_INL_H_
7 :
8 : #include "src/objects/js-generator.h"
9 : #include "src/objects/js-promise-inl.h"
10 :
11 : #include "src/objects-inl.h" // Needed for write barriers
12 :
13 : // Has to be the last include (doesn't have include guards):
14 : #include "src/objects/object-macros.h"
15 :
16 : namespace v8 {
17 : namespace internal {
18 :
19 : OBJECT_CONSTRUCTORS_IMPL(JSGeneratorObject, JSObject)
20 : OBJECT_CONSTRUCTORS_IMPL(JSAsyncFunctionObject, JSGeneratorObject)
21 : OBJECT_CONSTRUCTORS_IMPL(JSAsyncGeneratorObject, JSGeneratorObject)
22 : OBJECT_CONSTRUCTORS_IMPL(AsyncGeneratorRequest, Struct)
23 :
24 : CAST_ACCESSOR(JSAsyncFunctionObject)
25 : CAST_ACCESSOR(JSAsyncGeneratorObject)
26 : CAST_ACCESSOR(JSGeneratorObject)
27 : CAST_ACCESSOR(AsyncGeneratorRequest)
28 :
29 53177 : ACCESSORS(JSGeneratorObject, function, JSFunction, kFunctionOffset)
30 44800 : ACCESSORS(JSGeneratorObject, context, Context, kContextOffset)
31 44815 : ACCESSORS(JSGeneratorObject, receiver, Object, kReceiverOffset)
32 2848 : ACCESSORS(JSGeneratorObject, input_or_debug_pos, Object, kInputOrDebugPosOffset)
33 : SMI_ACCESSORS(JSGeneratorObject, resume_mode, kResumeModeOffset)
34 14356 : SMI_ACCESSORS(JSGeneratorObject, continuation, kContinuationOffset)
35 43916 : ACCESSORS(JSGeneratorObject, parameters_and_registers, FixedArray,
36 : kParametersAndRegistersOffset)
37 :
38 : ACCESSORS(AsyncGeneratorRequest, next, Object, kNextOffset)
39 : SMI_ACCESSORS(AsyncGeneratorRequest, resume_mode, kResumeModeOffset)
40 : ACCESSORS(AsyncGeneratorRequest, value, Object, kValueOffset)
41 207 : ACCESSORS(AsyncGeneratorRequest, promise, Object, kPromiseOffset)
42 :
43 : bool JSGeneratorObject::is_suspended() const {
44 : DCHECK_LT(kGeneratorExecuting, 0);
45 : DCHECK_LT(kGeneratorClosed, 0);
46 100 : return continuation() >= 0;
47 : }
48 :
49 : bool JSGeneratorObject::is_closed() const {
50 : return continuation() == kGeneratorClosed;
51 : }
52 :
53 : bool JSGeneratorObject::is_executing() const {
54 : return continuation() == kGeneratorExecuting;
55 : }
56 :
57 2175 : ACCESSORS(JSAsyncFunctionObject, promise, JSPromise, kPromiseOffset)
58 :
59 207 : ACCESSORS(JSAsyncGeneratorObject, queue, HeapObject, kQueueOffset)
60 1375 : SMI_ACCESSORS(JSAsyncGeneratorObject, is_awaiting, kIsAwaitingOffset)
61 :
62 : } // namespace internal
63 : } // namespace v8
64 :
65 : #include "src/objects/object-macros-undef.h"
66 :
67 : #endif // V8_OBJECTS_JS_GENERATOR_INL_H_
|