prototype-info-inl.h 2.34 KB
Newer Older
1 2 3 4 5 6 7 8 9
// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef V8_OBJECTS_PROTOTYPE_INFO_INL_H_
#define V8_OBJECTS_PROTOTYPE_INFO_INL_H_

#include "src/objects/prototype-info.h"

10
#include "src/heap/heap-write-barrier-inl.h"
11 12
#include "src/objects/fixed-array-inl.h"
#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 18 19 20 21 22
// Has to be the last include (doesn't have include guards):
#include "src/objects/object-macros.h"

namespace v8 {
namespace internal {

23 24
#include "torque-generated/src/objects/prototype-info-tq-inl.inc"

25
TQ_OBJECT_CONSTRUCTORS_IMPL(PrototypeInfo)
26

27 28 29 30 31 32 33
DEF_GETTER(PrototypeInfo, object_create_map, MaybeObject) {
  return TaggedField<MaybeObject, kObjectCreateMapOffset>::load(cage_base,
                                                                *this);
}
RELEASE_ACQUIRE_WEAK_ACCESSORS(PrototypeInfo, object_create_map,
                               kObjectCreateMapOffset)

34
Map PrototypeInfo::ObjectCreateMap() {
35
  return Map::cast(object_create_map()->GetHeapObjectAssumeWeak());
36 37 38 39 40
}

// static
void PrototypeInfo::SetObjectCreateMap(Handle<PrototypeInfo> info,
                                       Handle<Map> map) {
41
  info->set_object_create_map(HeapObjectReference::Weak(*map), kReleaseStore);
42 43 44
}

bool PrototypeInfo::HasObjectCreateMap() {
45
  MaybeObject cache = object_create_map();
46
  return cache->IsWeak();
47 48
}

49 50
BOOL_ACCESSORS(PrototypeInfo, bit_field, should_be_fast_map,
               ShouldBeFastBit::kShift)
51

52
void PrototypeUsers::MarkSlotEmpty(WeakArrayList array, int index) {
53
  DCHECK_GT(index, 0);
54
  DCHECK_LT(index, array.length());
55 56
  // Chain the empty slots into a linked list (each empty slot contains the
  // index of the next empty slot).
57
  array.Set(index, MaybeObject::FromObject(empty_slot_index(array)));
58 59 60
  set_empty_slot_index(array, index);
}

61
Smi PrototypeUsers::empty_slot_index(WeakArrayList array) {
62
  return array.Get(kEmptySlotIndex).ToSmi();
63 64
}

65
void PrototypeUsers::set_empty_slot_index(WeakArrayList array, int index) {
66
  array.Set(kEmptySlotIndex, MaybeObject::FromObject(Smi::FromInt(index)));
67 68
}

69 70 71 72 73 74
}  // namespace internal
}  // namespace v8

#include "src/objects/object-macros-undef.h"

#endif  // V8_OBJECTS_PROTOTYPE_INFO_INL_H_