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/fixed-array-inl.h"
12 #include "src/objects/map-inl.h"
13 #include "src/objects/maybe-object.h"
14 #include "src/objects/objects-inl.h"
15 #include "src/objects/struct-inl.h"
16
17 // Has to be the last include (doesn't have include guards):
18 #include "src/objects/object-macros.h"
19
20 namespace v8 {
21 namespace internal {
22
23 #include "torque-generated/src/objects/prototype-info-tq-inl.inc"
24
TQ_OBJECT_CONSTRUCTORS_IMPL(PrototypeInfo)25 TQ_OBJECT_CONSTRUCTORS_IMPL(PrototypeInfo)
26
27 Map PrototypeInfo::ObjectCreateMap() {
28 return Map::cast(object_create_map()->GetHeapObjectAssumeWeak());
29 }
30
31 // static
SetObjectCreateMap(Handle<PrototypeInfo> info,Handle<Map> map)32 void PrototypeInfo::SetObjectCreateMap(Handle<PrototypeInfo> info,
33 Handle<Map> map) {
34 info->set_object_create_map(HeapObjectReference::Weak(*map));
35 }
36
HasObjectCreateMap()37 bool PrototypeInfo::HasObjectCreateMap() {
38 MaybeObject cache = object_create_map();
39 return cache->IsWeak();
40 }
41
BOOL_ACCESSORS(PrototypeInfo,bit_field,should_be_fast_map,ShouldBeFastBit::kShift)42 BOOL_ACCESSORS(PrototypeInfo, bit_field, should_be_fast_map,
43 ShouldBeFastBit::kShift)
44
45 void PrototypeUsers::MarkSlotEmpty(WeakArrayList array, int index) {
46 DCHECK_GT(index, 0);
47 DCHECK_LT(index, array.length());
48 // Chain the empty slots into a linked list (each empty slot contains the
49 // index of the next empty slot).
50 array.Set(index, MaybeObject::FromObject(empty_slot_index(array)));
51 set_empty_slot_index(array, index);
52 }
53
empty_slot_index(WeakArrayList array)54 Smi PrototypeUsers::empty_slot_index(WeakArrayList array) {
55 return array.Get(kEmptySlotIndex).ToSmi();
56 }
57
set_empty_slot_index(WeakArrayList array,int index)58 void PrototypeUsers::set_empty_slot_index(WeakArrayList array, int index) {
59 array.Set(kEmptySlotIndex, MaybeObject::FromObject(Smi::FromInt(index)));
60 }
61
62 } // namespace internal
63 } // namespace v8
64
65 #include "src/objects/object-macros-undef.h"
66
67 #endif // V8_OBJECTS_PROTOTYPE_INFO_INL_H_
68