1// Copyright 2019 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 5bitfield struct MapBitFields1 extends uint8 { 6 has_non_instance_prototype: bool: 1 bit; 7 is_callable: bool: 1 bit; 8 has_named_interceptor: bool: 1 bit; 9 has_indexed_interceptor: bool: 1 bit; 10 is_undetectable: bool: 1 bit; 11 is_access_check_needed: bool: 1 bit; 12 is_constructor: bool: 1 bit; 13 has_prototype_slot: bool: 1 bit; 14} 15 16bitfield struct MapBitFields2 extends uint8 { 17 new_target_is_base: bool: 1 bit; 18 is_immutable_prototype: bool: 1 bit; 19 elements_kind: ElementsKind: 6 bit; 20} 21 22bitfield struct MapBitFields3 extends uint32 { 23 enum_length: int32: 10 bit; 24 number_of_own_descriptors: int32: 10 bit; 25 is_prototype_map: bool: 1 bit; 26 is_dictionary_map: bool: 1 bit; 27 owns_descriptors: bool: 1 bit; 28 is_in_retained_map_list: bool: 1 bit; 29 is_deprecated: bool: 1 bit; 30 is_unstable: bool: 1 bit; 31 is_migration_target: bool: 1 bit; 32 is_extensible: bool: 1 bit; 33 may_have_interesting_symbols: bool: 1 bit; 34 construction_counter: int32: 3 bit; 35} 36 37extern class Map extends HeapObject { 38 macro PrototypeInfo(): PrototypeInfo labels HasNoPrototypeInfo { 39 typeswitch (this.transitions_or_prototype_info) { 40 case (Weak<Map>): { 41 goto HasNoPrototypeInfo; 42 } 43 case (Smi): { 44 goto HasNoPrototypeInfo; 45 } 46 case (info: PrototypeInfo): { 47 return info; 48 } 49 case (Map | TransitionArray): { 50 goto HasNoPrototypeInfo; 51 } 52 } 53 } 54 55 macro IsUndetectable(): bool { 56 return this.bit_field.is_undetectable; 57 } 58 59 instance_size_in_words: uint8; 60 inobject_properties_start_or_constructor_function_index: uint8; 61 used_or_unused_instance_size_in_words: uint8; 62 visitor_id: uint8; 63 instance_type: InstanceType; 64 bit_field: MapBitFields1; 65 bit_field2: MapBitFields2; 66 bit_field3: MapBitFields3; 67 68 @if(TAGGED_SIZE_8_BYTES) optional_padding: uint32; 69 @ifnot(TAGGED_SIZE_8_BYTES) optional_padding: void; 70 71 prototype: JSReceiver|Null; 72 constructor_or_back_pointer_or_native_context: Object; 73 instance_descriptors: DescriptorArray; 74 dependent_code: DependentCode; 75 prototype_validity_cell: Smi|Cell; 76 transitions_or_prototype_info: Map|Weak<Map>|TransitionArray|PrototypeInfo| 77 Smi; 78} 79 80@export 81macro LoadMapPrototypeInfo(m: Map): PrototypeInfo labels HasNoPrototypeInfo { 82 return m.PrototypeInfo() otherwise HasNoPrototypeInfo; 83} 84 85// Returns true if the map corresponds to non-special fast or dictionary 86// object. 87@export 88macro IsSimpleObjectMap(map: Map): bool { 89 if (IsSpecialReceiverInstanceType(map.instance_type)) { 90 return false; 91 } 92 const bitField = map.bit_field; 93 // Using & instead of && enables Turbofan to merge the two checks into one. 94 return !bitField.has_named_interceptor & !bitField.is_access_check_needed; 95} 96 97extern macro IsSpecialReceiverInstanceType(InstanceType): bool; 98