• 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/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 
CAST_ACCESSOR(PrototypeInfo)20 CAST_ACCESSOR(PrototypeInfo)
21 
22 Map* PrototypeInfo::ObjectCreateMap() {
23   return Map::cast(object_create_map()->ToWeakHeapObject());
24 }
25 
26 // static
SetObjectCreateMap(Handle<PrototypeInfo> info,Handle<Map> map)27 void PrototypeInfo::SetObjectCreateMap(Handle<PrototypeInfo> info,
28                                        Handle<Map> map) {
29   info->set_object_create_map(HeapObjectReference::Weak(*map));
30 }
31 
HasObjectCreateMap()32 bool PrototypeInfo::HasObjectCreateMap() {
33   MaybeObject* cache = object_create_map();
34   return cache->IsWeakHeapObject();
35 }
36 
ACCESSORS(PrototypeInfo,module_namespace,Object,kJSModuleNamespaceOffset)37 ACCESSORS(PrototypeInfo, module_namespace, Object, kJSModuleNamespaceOffset)
38 ACCESSORS(PrototypeInfo, prototype_users, Object, kPrototypeUsersOffset)
39 WEAK_ACCESSORS(PrototypeInfo, object_create_map, kObjectCreateMapOffset)
40 SMI_ACCESSORS(PrototypeInfo, registry_slot, kRegistrySlotOffset)
41 SMI_ACCESSORS(PrototypeInfo, bit_field, kBitFieldOffset)
42 BOOL_ACCESSORS(PrototypeInfo, bit_field, should_be_fast_map, kShouldBeFastBit)
43 
44 void PrototypeUsers::MarkSlotEmpty(WeakArrayList* array, int index) {
45   DCHECK_GT(index, 0);
46   DCHECK_LT(index, array->length());
47   // Chain the empty slots into a linked list (each empty slot contains the
48   // index of the next empty slot).
49   array->Set(index, MaybeObject::FromObject(empty_slot_index(array)));
50   set_empty_slot_index(array, index);
51 }
52 
empty_slot_index(WeakArrayList * array)53 Smi* PrototypeUsers::empty_slot_index(WeakArrayList* array) {
54   return array->Get(kEmptySlotIndex)->ToSmi();
55 }
56 
set_empty_slot_index(WeakArrayList * array,int index)57 void PrototypeUsers::set_empty_slot_index(WeakArrayList* array, int index) {
58   array->Set(kEmptySlotIndex, MaybeObject::FromObject(Smi::FromInt(index)));
59 }
60 
61 }  // namespace internal
62 }  // namespace v8
63 
64 #include "src/objects/object-macros-undef.h"
65 
66 #endif  // V8_OBJECTS_PROTOTYPE_INFO_INL_H_
67