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

Side by Side Diff: src/objects-inl.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 unified diff | Download patch
« no previous file with comments | « src/objects-debug.cc ('k') | src/objects-printer.cc » ('j') | no next file with comments »
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 // Review notes: 5 // Review notes:
6 // 6 //
7 // - The use of macros in these inline functions may seem superfluous 7 // - The use of macros in these inline functions may seem superfluous
8 // but it is absolutely needed to make sure gcc generates optimal 8 // but it is absolutely needed to make sure gcc generates optimal
9 // code. gcc is not happy when attempting to inline too deep. 9 // code. gcc is not happy when attempting to inline too deep.
10 // 10 //
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 TYPE_CHECKER(BytecodeArray, BYTECODE_ARRAY_TYPE) 138 TYPE_CHECKER(BytecodeArray, BYTECODE_ARRAY_TYPE)
139 TYPE_CHECKER(Cell, CELL_TYPE) 139 TYPE_CHECKER(Cell, CELL_TYPE)
140 TYPE_CHECKER(Code, CODE_TYPE) 140 TYPE_CHECKER(Code, CODE_TYPE)
141 TYPE_CHECKER(FixedDoubleArray, FIXED_DOUBLE_ARRAY_TYPE) 141 TYPE_CHECKER(FixedDoubleArray, FIXED_DOUBLE_ARRAY_TYPE)
142 TYPE_CHECKER(Foreign, FOREIGN_TYPE) 142 TYPE_CHECKER(Foreign, FOREIGN_TYPE)
143 TYPE_CHECKER(FreeSpace, FREE_SPACE_TYPE) 143 TYPE_CHECKER(FreeSpace, FREE_SPACE_TYPE)
144 TYPE_CHECKER(HeapNumber, HEAP_NUMBER_TYPE) 144 TYPE_CHECKER(HeapNumber, HEAP_NUMBER_TYPE)
145 TYPE_CHECKER(JSArgumentsObject, JS_ARGUMENTS_TYPE) 145 TYPE_CHECKER(JSArgumentsObject, JS_ARGUMENTS_TYPE)
146 TYPE_CHECKER(JSArray, JS_ARRAY_TYPE) 146 TYPE_CHECKER(JSArray, JS_ARRAY_TYPE)
147 TYPE_CHECKER(JSArrayBuffer, JS_ARRAY_BUFFER_TYPE) 147 TYPE_CHECKER(JSArrayBuffer, JS_ARRAY_BUFFER_TYPE)
148 TYPE_CHECKER(JSAsyncFromSyncIterator, JS_ASYNC_FROM_SYNC_ITERATOR_TYPE)
149 TYPE_CHECKER(JSAsyncGeneratorObject, JS_ASYNC_GENERATOR_OBJECT_TYPE)
148 TYPE_CHECKER(JSBoundFunction, JS_BOUND_FUNCTION_TYPE) 150 TYPE_CHECKER(JSBoundFunction, JS_BOUND_FUNCTION_TYPE)
149 TYPE_CHECKER(JSContextExtensionObject, JS_CONTEXT_EXTENSION_OBJECT_TYPE) 151 TYPE_CHECKER(JSContextExtensionObject, JS_CONTEXT_EXTENSION_OBJECT_TYPE)
150 TYPE_CHECKER(JSDataView, JS_DATA_VIEW_TYPE) 152 TYPE_CHECKER(JSDataView, JS_DATA_VIEW_TYPE)
151 TYPE_CHECKER(JSDate, JS_DATE_TYPE) 153 TYPE_CHECKER(JSDate, JS_DATE_TYPE)
152 TYPE_CHECKER(JSError, JS_ERROR_TYPE) 154 TYPE_CHECKER(JSError, JS_ERROR_TYPE)
153 TYPE_CHECKER(JSFunction, JS_FUNCTION_TYPE) 155 TYPE_CHECKER(JSFunction, JS_FUNCTION_TYPE)
154 TYPE_CHECKER(JSGeneratorObject, JS_GENERATOR_OBJECT_TYPE)
155 TYPE_CHECKER(JSGlobalObject, JS_GLOBAL_OBJECT_TYPE) 156 TYPE_CHECKER(JSGlobalObject, JS_GLOBAL_OBJECT_TYPE)
156 TYPE_CHECKER(JSMap, JS_MAP_TYPE) 157 TYPE_CHECKER(JSMap, JS_MAP_TYPE)
157 TYPE_CHECKER(JSMapIterator, JS_MAP_ITERATOR_TYPE) 158 TYPE_CHECKER(JSMapIterator, JS_MAP_ITERATOR_TYPE)
158 TYPE_CHECKER(JSMessageObject, JS_MESSAGE_OBJECT_TYPE) 159 TYPE_CHECKER(JSMessageObject, JS_MESSAGE_OBJECT_TYPE)
159 TYPE_CHECKER(JSModuleNamespace, JS_MODULE_NAMESPACE_TYPE) 160 TYPE_CHECKER(JSModuleNamespace, JS_MODULE_NAMESPACE_TYPE)
160 TYPE_CHECKER(JSPromiseCapability, JS_PROMISE_CAPABILITY_TYPE) 161 TYPE_CHECKER(JSPromiseCapability, JS_PROMISE_CAPABILITY_TYPE)
161 TYPE_CHECKER(JSPromise, JS_PROMISE_TYPE) 162 TYPE_CHECKER(JSPromise, JS_PROMISE_TYPE)
162 TYPE_CHECKER(JSRegExp, JS_REGEXP_TYPE) 163 TYPE_CHECKER(JSRegExp, JS_REGEXP_TYPE)
163 TYPE_CHECKER(JSSet, JS_SET_TYPE) 164 TYPE_CHECKER(JSSet, JS_SET_TYPE)
164 TYPE_CHECKER(JSSetIterator, JS_SET_ITERATOR_TYPE) 165 TYPE_CHECKER(JSSetIterator, JS_SET_ITERATOR_TYPE)
(...skipping 28 matching lines...) Expand all
193 InstanceType instance_type = map()->instance_type(); 194 InstanceType instance_type = map()->instance_type();
194 return instance_type == FIXED_ARRAY_TYPE || 195 return instance_type == FIXED_ARRAY_TYPE ||
195 instance_type == TRANSITION_ARRAY_TYPE; 196 instance_type == TRANSITION_ARRAY_TYPE;
196 } 197 }
197 198
198 // External objects are not extensible, so the map check is enough. 199 // External objects are not extensible, so the map check is enough.
199 bool HeapObject::IsExternal() const { 200 bool HeapObject::IsExternal() const {
200 return map() == GetHeap()->external_map(); 201 return map() == GetHeap()->external_map();
201 } 202 }
202 203
204 bool HeapObject::IsJSGeneratorObject() const {
205 return map()->instance_type() == JS_GENERATOR_OBJECT_TYPE ||
206 IsJSAsyncGeneratorObject();
207 }
208
203 #define SIMD128_TYPE_CHECKER(TYPE, Type, type, lane_count, lane_type) \ 209 #define SIMD128_TYPE_CHECKER(TYPE, Type, type, lane_count, lane_type) \
204 bool HeapObject::Is##Type() const { return map() == GetHeap()->type##_map(); } 210 bool HeapObject::Is##Type() const { return map() == GetHeap()->type##_map(); }
205 SIMD128_TYPES(SIMD128_TYPE_CHECKER) 211 SIMD128_TYPES(SIMD128_TYPE_CHECKER)
206 #undef SIMD128_TYPE_CHECKER 212 #undef SIMD128_TYPE_CHECKER
207 213
208 #define IS_TYPE_FUNCTION_DEF(type_) \ 214 #define IS_TYPE_FUNCTION_DEF(type_) \
209 bool Object::Is##type_() const { \ 215 bool Object::Is##type_() const { \
210 return IsHeapObject() && HeapObject::cast(this)->Is##type_(); \ 216 return IsHeapObject() && HeapObject::cast(this)->Is##type_(); \
211 } 217 }
212 HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DEF) 218 HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DEF)
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 CAST_ACCESSOR(FrameArray) 646 CAST_ACCESSOR(FrameArray)
641 CAST_ACCESSOR(GlobalDictionary) 647 CAST_ACCESSOR(GlobalDictionary)
642 CAST_ACCESSOR(HandlerTable) 648 CAST_ACCESSOR(HandlerTable)
643 CAST_ACCESSOR(HeapObject) 649 CAST_ACCESSOR(HeapObject)
644 CAST_ACCESSOR(Int16x8) 650 CAST_ACCESSOR(Int16x8)
645 CAST_ACCESSOR(Int32x4) 651 CAST_ACCESSOR(Int32x4)
646 CAST_ACCESSOR(Int8x16) 652 CAST_ACCESSOR(Int8x16)
647 CAST_ACCESSOR(JSArray) 653 CAST_ACCESSOR(JSArray)
648 CAST_ACCESSOR(JSArrayBuffer) 654 CAST_ACCESSOR(JSArrayBuffer)
649 CAST_ACCESSOR(JSArrayBufferView) 655 CAST_ACCESSOR(JSArrayBufferView)
656 CAST_ACCESSOR(JSAsyncFromSyncIterator)
650 CAST_ACCESSOR(JSBoundFunction) 657 CAST_ACCESSOR(JSBoundFunction)
651 CAST_ACCESSOR(JSDataView) 658 CAST_ACCESSOR(JSDataView)
652 CAST_ACCESSOR(JSDate) 659 CAST_ACCESSOR(JSDate)
653 CAST_ACCESSOR(JSFunction) 660 CAST_ACCESSOR(JSFunction)
654 CAST_ACCESSOR(JSGeneratorObject) 661 CAST_ACCESSOR(JSGeneratorObject)
662 CAST_ACCESSOR(JSAsyncGeneratorObject)
655 CAST_ACCESSOR(JSGlobalObject) 663 CAST_ACCESSOR(JSGlobalObject)
656 CAST_ACCESSOR(JSGlobalProxy) 664 CAST_ACCESSOR(JSGlobalProxy)
657 CAST_ACCESSOR(JSMap) 665 CAST_ACCESSOR(JSMap)
658 CAST_ACCESSOR(JSMapIterator) 666 CAST_ACCESSOR(JSMapIterator)
659 CAST_ACCESSOR(JSMessageObject) 667 CAST_ACCESSOR(JSMessageObject)
660 CAST_ACCESSOR(JSModuleNamespace) 668 CAST_ACCESSOR(JSModuleNamespace)
661 CAST_ACCESSOR(JSObject) 669 CAST_ACCESSOR(JSObject)
662 CAST_ACCESSOR(JSProxy) 670 CAST_ACCESSOR(JSProxy)
663 CAST_ACCESSOR(JSReceiver) 671 CAST_ACCESSOR(JSReceiver)
664 CAST_ACCESSOR(JSRegExp) 672 CAST_ACCESSOR(JSRegExp)
(...skipping 1497 matching lines...) Expand 10 before | Expand all | Expand 10 after
2162 // Check for the most common kind of JavaScript object before 2170 // Check for the most common kind of JavaScript object before
2163 // falling into the generic switch. This speeds up the internal 2171 // falling into the generic switch. This speeds up the internal
2164 // field operations considerably on average. 2172 // field operations considerably on average.
2165 if (type == JS_OBJECT_TYPE) return JSObject::kHeaderSize; 2173 if (type == JS_OBJECT_TYPE) return JSObject::kHeaderSize;
2166 switch (type) { 2174 switch (type) {
2167 case JS_API_OBJECT_TYPE: 2175 case JS_API_OBJECT_TYPE:
2168 case JS_SPECIAL_API_OBJECT_TYPE: 2176 case JS_SPECIAL_API_OBJECT_TYPE:
2169 return JSObject::kHeaderSize; 2177 return JSObject::kHeaderSize;
2170 case JS_GENERATOR_OBJECT_TYPE: 2178 case JS_GENERATOR_OBJECT_TYPE:
2171 return JSGeneratorObject::kSize; 2179 return JSGeneratorObject::kSize;
2180 case JS_ASYNC_GENERATOR_OBJECT_TYPE:
2181 return JSAsyncGeneratorObject::kSize;
2172 case JS_GLOBAL_PROXY_TYPE: 2182 case JS_GLOBAL_PROXY_TYPE:
2173 return JSGlobalProxy::kSize; 2183 return JSGlobalProxy::kSize;
2174 case JS_GLOBAL_OBJECT_TYPE: 2184 case JS_GLOBAL_OBJECT_TYPE:
2175 return JSGlobalObject::kSize; 2185 return JSGlobalObject::kSize;
2176 case JS_BOUND_FUNCTION_TYPE: 2186 case JS_BOUND_FUNCTION_TYPE:
2177 return JSBoundFunction::kSize; 2187 return JSBoundFunction::kSize;
2178 case JS_FUNCTION_TYPE: 2188 case JS_FUNCTION_TYPE:
2179 return JSFunction::kSize; 2189 return JSFunction::kSize;
2180 case JS_VALUE_TYPE: 2190 case JS_VALUE_TYPE:
2181 return JSValue::kSize; 2191 return JSValue::kSize;
(...skipping 3581 matching lines...) Expand 10 before | Expand all | Expand 10 after
5763 ACCESSORS(PromiseReactionJobInfo, deferred_promise, Object, 5773 ACCESSORS(PromiseReactionJobInfo, deferred_promise, Object,
5764 kDeferredPromiseOffset); 5774 kDeferredPromiseOffset);
5765 ACCESSORS(PromiseReactionJobInfo, deferred_on_resolve, Object, 5775 ACCESSORS(PromiseReactionJobInfo, deferred_on_resolve, Object,
5766 kDeferredOnResolveOffset); 5776 kDeferredOnResolveOffset);
5767 ACCESSORS(PromiseReactionJobInfo, deferred_on_reject, Object, 5777 ACCESSORS(PromiseReactionJobInfo, deferred_on_reject, Object,
5768 kDeferredOnRejectOffset); 5778 kDeferredOnRejectOffset);
5769 SMI_ACCESSORS(PromiseReactionJobInfo, debug_id, kDebugIdOffset); 5779 SMI_ACCESSORS(PromiseReactionJobInfo, debug_id, kDebugIdOffset);
5770 SMI_ACCESSORS(PromiseReactionJobInfo, debug_name, kDebugNameOffset); 5780 SMI_ACCESSORS(PromiseReactionJobInfo, debug_name, kDebugNameOffset);
5771 ACCESSORS(PromiseReactionJobInfo, context, Context, kContextOffset); 5781 ACCESSORS(PromiseReactionJobInfo, context, Context, kContextOffset);
5772 5782
5783 ACCESSORS(AsyncGeneratorRequest, next, Object, kNextOffset)
5784 SMI_ACCESSORS(AsyncGeneratorRequest, resume_mode, kResumeModeOffset)
5785 ACCESSORS(AsyncGeneratorRequest, value, Object, kValueOffset)
5786 ACCESSORS(AsyncGeneratorRequest, promise, Object, kPromiseOffset)
5787
5773 Map* PrototypeInfo::ObjectCreateMap() { 5788 Map* PrototypeInfo::ObjectCreateMap() {
5774 return Map::cast(WeakCell::cast(object_create_map())->value()); 5789 return Map::cast(WeakCell::cast(object_create_map())->value());
5775 } 5790 }
5776 5791
5777 // static 5792 // static
5778 void PrototypeInfo::SetObjectCreateMap(Handle<PrototypeInfo> info, 5793 void PrototypeInfo::SetObjectCreateMap(Handle<PrototypeInfo> info,
5779 Handle<Map> map) { 5794 Handle<Map> map) {
5780 Handle<WeakCell> cell = Map::WeakCellForMap(map); 5795 Handle<WeakCell> cell = Map::WeakCellForMap(map);
5781 info->set_object_create_map(*cell); 5796 info->set_object_create_map(*cell);
5782 } 5797 }
(...skipping 1012 matching lines...) Expand 10 before | Expand all | Expand 10 after
6795 } 6810 }
6796 6811
6797 bool JSGeneratorObject::is_closed() const { 6812 bool JSGeneratorObject::is_closed() const {
6798 return continuation() == kGeneratorClosed; 6813 return continuation() == kGeneratorClosed;
6799 } 6814 }
6800 6815
6801 bool JSGeneratorObject::is_executing() const { 6816 bool JSGeneratorObject::is_executing() const {
6802 return continuation() == kGeneratorExecuting; 6817 return continuation() == kGeneratorExecuting;
6803 } 6818 }
6804 6819
6820 ACCESSORS(JSAsyncGeneratorObject, queue, HeapObject, kQueueOffset)
6821 ACCESSORS(JSAsyncGeneratorObject, await_input, Object, kAwaitInputOffset)
6822 ACCESSORS(JSAsyncGeneratorObject, awaited_promise, HeapObject,
6823 kAwaitedPromiseOffset)
6824
6805 ACCESSORS(JSValue, value, Object, kValueOffset) 6825 ACCESSORS(JSValue, value, Object, kValueOffset)
6806 6826
6807 6827
6808 HeapNumber* HeapNumber::cast(Object* object) { 6828 HeapNumber* HeapNumber::cast(Object* object) {
6809 SLOW_DCHECK(object->IsHeapNumber() || object->IsMutableHeapNumber()); 6829 SLOW_DCHECK(object->IsHeapNumber() || object->IsMutableHeapNumber());
6810 return reinterpret_cast<HeapNumber*>(object); 6830 return reinterpret_cast<HeapNumber*>(object);
6811 } 6831 }
6812 6832
6813 6833
6814 const HeapNumber* HeapNumber::cast(const Object* object) { 6834 const HeapNumber* HeapNumber::cast(const Object* object) {
(...skipping 1588 matching lines...) Expand 10 before | Expand all | Expand 10 after
8403 ACCESSORS(JSIteratorResult, value, Object, kValueOffset) 8423 ACCESSORS(JSIteratorResult, value, Object, kValueOffset)
8404 ACCESSORS(JSIteratorResult, done, Object, kDoneOffset) 8424 ACCESSORS(JSIteratorResult, done, Object, kDoneOffset)
8405 8425
8406 ACCESSORS(JSArrayIterator, object, Object, kIteratedObjectOffset) 8426 ACCESSORS(JSArrayIterator, object, Object, kIteratedObjectOffset)
8407 ACCESSORS(JSArrayIterator, index, Object, kNextIndexOffset) 8427 ACCESSORS(JSArrayIterator, index, Object, kNextIndexOffset)
8408 ACCESSORS(JSArrayIterator, object_map, Object, kIteratedObjectMapOffset) 8428 ACCESSORS(JSArrayIterator, object_map, Object, kIteratedObjectMapOffset)
8409 8429
8410 ACCESSORS(JSStringIterator, string, String, kStringOffset) 8430 ACCESSORS(JSStringIterator, string, String, kStringOffset)
8411 SMI_ACCESSORS(JSStringIterator, index, kNextIndexOffset) 8431 SMI_ACCESSORS(JSStringIterator, index, kNextIndexOffset)
8412 8432
8433 ACCESSORS(JSAsyncFromSyncIterator, sync_iterator, HeapObject,
8434 kSyncIteratorOffset)
8435
8413 #undef INT_ACCESSORS 8436 #undef INT_ACCESSORS
8414 #undef ACCESSORS 8437 #undef ACCESSORS
8415 #undef ACCESSORS_CHECKED 8438 #undef ACCESSORS_CHECKED
8416 #undef ACCESSORS_CHECKED2 8439 #undef ACCESSORS_CHECKED2
8417 #undef SMI_ACCESSORS 8440 #undef SMI_ACCESSORS
8418 #undef SYNCHRONIZED_SMI_ACCESSORS 8441 #undef SYNCHRONIZED_SMI_ACCESSORS
8419 #undef NOBARRIER_SMI_ACCESSORS 8442 #undef NOBARRIER_SMI_ACCESSORS
8420 #undef BOOL_GETTER 8443 #undef BOOL_GETTER
8421 #undef BOOL_ACCESSORS 8444 #undef BOOL_ACCESSORS
8422 #undef FIELD_ADDR 8445 #undef FIELD_ADDR
(...skipping 30 matching lines...) Expand all
8453 #undef WRITE_INT64_FIELD 8476 #undef WRITE_INT64_FIELD
8454 #undef READ_BYTE_FIELD 8477 #undef READ_BYTE_FIELD
8455 #undef WRITE_BYTE_FIELD 8478 #undef WRITE_BYTE_FIELD
8456 #undef NOBARRIER_READ_BYTE_FIELD 8479 #undef NOBARRIER_READ_BYTE_FIELD
8457 #undef NOBARRIER_WRITE_BYTE_FIELD 8480 #undef NOBARRIER_WRITE_BYTE_FIELD
8458 8481
8459 } // namespace internal 8482 } // namespace internal
8460 } // namespace v8 8483 } // namespace v8
8461 8484
8462 #endif // V8_OBJECTS_INL_H_ 8485 #endif // V8_OBJECTS_INL_H_
OLDNEW
« no previous file with comments | « src/objects-debug.cc ('k') | src/objects-printer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698