• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
25 TQ_OBJECT_CONSTRUCTORS_IMPL(PrototypeInfo)
26 
DEF_GETTER(PrototypeInfo,object_create_map,MaybeObject)27 DEF_GETTER(PrototypeInfo, object_create_map, MaybeObject) {
28   return TaggedField<MaybeObject, kObjectCreateMapOffset>::load(cage_base,
29                                                                 *this);
30 }
RELEASE_ACQUIRE_WEAK_ACCESSORS(PrototypeInfo,object_create_map,kObjectCreateMapOffset)31 RELEASE_ACQUIRE_WEAK_ACCESSORS(PrototypeInfo, object_create_map,
32                                kObjectCreateMapOffset)
33 
34 Map PrototypeInfo::ObjectCreateMap() {
35   return Map::cast(object_create_map()->GetHeapObjectAssumeWeak());
36 }
37 
38 // static
SetObjectCreateMap(Handle<PrototypeInfo> info,Handle<Map> map)39 void PrototypeInfo::SetObjectCreateMap(Handle<PrototypeInfo> info,
40                                        Handle<Map> map) {
41   info->set_object_create_map(HeapObjectReference::Weak(*map), kReleaseStore);
42 }
43 
HasObjectCreateMap()44 bool PrototypeInfo::HasObjectCreateMap() {
45   MaybeObject cache = object_create_map();
46   return cache->IsWeak();
47 }
48 
BOOL_ACCESSORS(PrototypeInfo,bit_field,should_be_fast_map,ShouldBeFastBit::kShift)49 BOOL_ACCESSORS(PrototypeInfo, bit_field, should_be_fast_map,
50                ShouldBeFastBit::kShift)
51 
52 void PrototypeUsers::MarkSlotEmpty(WeakArrayList array, int index) {
53   DCHECK_GT(index, 0);
54   DCHECK_LT(index, array.length());
55   // Chain the empty slots into a linked list (each empty slot contains the
56   // index of the next empty slot).
57   array.Set(index, MaybeObject::FromObject(empty_slot_index(array)));
58   set_empty_slot_index(array, index);
59 }
60 
empty_slot_index(WeakArrayList array)61 Smi PrototypeUsers::empty_slot_index(WeakArrayList array) {
62   return array.Get(kEmptySlotIndex).ToSmi();
63 }
64 
set_empty_slot_index(WeakArrayList array,int index)65 void PrototypeUsers::set_empty_slot_index(WeakArrayList array, int index) {
66   array.Set(kEmptySlotIndex, MaybeObject::FromObject(Smi::FromInt(index)));
67 }
68 
69 }  // namespace internal
70 }  // namespace v8
71 
72 #include "src/objects/object-macros-undef.h"
73 
74 #endif  // V8_OBJECTS_PROTOTYPE_INFO_INL_H_
75