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_PROTOTYPE_INFO_INL_H_
6 : #define V8_OBJECTS_PROTOTYPE_INFO_INL_H_
7 :
8 : #include "src/objects/prototype-info.h"
9 :
10 : #include "src/heap/heap-write-barrier-inl.h"
11 : #include "src/objects/map.h"
12 : #include "src/objects/maybe-object.h"
13 :
14 : // Has to be the last include (doesn't have include guards):
15 : #include "src/objects/object-macros.h"
16 :
17 : namespace v8 {
18 : namespace internal {
19 :
20 86776560 : OBJECT_CONSTRUCTORS_IMPL(PrototypeInfo, Struct)
21 :
22 43388334 : CAST_ACCESSOR(PrototypeInfo)
23 :
24 131 : Map PrototypeInfo::ObjectCreateMap() {
25 262 : return Map::cast(object_create_map()->GetHeapObjectAssumeWeak());
26 : }
27 :
28 : // static
29 118775 : void PrototypeInfo::SetObjectCreateMap(Handle<PrototypeInfo> info,
30 : Handle<Map> map) {
31 237550 : info->set_object_create_map(HeapObjectReference::Weak(*map));
32 118775 : }
33 :
34 : bool PrototypeInfo::HasObjectCreateMap() {
35 : MaybeObject cache = object_create_map();
36 : return cache->IsWeak();
37 : }
38 :
39 3407756 : ACCESSORS(PrototypeInfo, module_namespace, Object, kJSModuleNamespaceOffset)
40 27013435 : ACCESSORS(PrototypeInfo, prototype_users, Object, kPrototypeUsersOffset)
41 742234 : WEAK_ACCESSORS(PrototypeInfo, object_create_map, kObjectCreateMapOffset)
42 7603018 : SMI_ACCESSORS(PrototypeInfo, registry_slot, kRegistrySlotOffset)
43 59877002 : SMI_ACCESSORS(PrototypeInfo, bit_field, kBitFieldOffset)
44 58553213 : BOOL_ACCESSORS(PrototypeInfo, bit_field, should_be_fast_map, kShouldBeFastBit)
45 :
46 125659 : void PrototypeUsers::MarkSlotEmpty(WeakArrayList array, int index) {
47 : DCHECK_GT(index, 0);
48 : DCHECK_LT(index, array->length());
49 : // Chain the empty slots into a linked list (each empty slot contains the
50 : // index of the next empty slot).
51 125659 : array->Set(index, MaybeObject::FromObject(empty_slot_index(array)));
52 : set_empty_slot_index(array, index);
53 125658 : }
54 :
55 238237 : Smi PrototypeUsers::empty_slot_index(WeakArrayList array) {
56 238237 : return array->Get(kEmptySlotIndex).ToSmi();
57 : }
58 :
59 : void PrototypeUsers::set_empty_slot_index(WeakArrayList array, int index) {
60 342100 : array->Set(kEmptySlotIndex, MaybeObject::FromObject(Smi::FromInt(index)));
61 : }
62 :
63 : } // namespace internal
64 : } // namespace v8
65 :
66 : #include "src/objects/object-macros-undef.h"
67 :
68 : #endif // V8_OBJECTS_PROTOTYPE_INFO_INL_H_
|