v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
prototype-info.h
Go to the documentation of this file.
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_H_
6#define V8_OBJECTS_PROTOTYPE_INFO_H_
7
10#include "src/objects/struct.h"
11#include "torque-generated/bit-fields.h"
12
13// Has to be the last include (doesn't have include guards):
15
16namespace v8 {
17namespace internal {
18
19#include "torque-generated/src/objects/prototype-info-tq.inc"
20
21// Container for metadata stored on each prototype map.
23 : public TorqueGeneratedPrototypeInfo<PrototypeInfo, Struct> {
24 public:
25 static const int UNREGISTERED = -1;
26
27 // For caching derived maps for Object.create, Reflect.construct and proxies.
28 DECL_GETTER(derived_maps, Tagged<HeapObject>)
30
31 static inline void SetObjectCreateMap(DirectHandle<PrototypeInfo> info,
33 Isolate* isolate);
36
37 static inline void AddDerivedMap(DirectHandle<PrototypeInfo> info,
38 DirectHandle<Map> to, Isolate* isolate);
40
41 static inline bool IsPrototypeInfoFast(Tagged<Object> object);
42
43 DECL_BOOLEAN_ACCESSORS(should_be_fast_map)
44
45 // Dispatched behavior.
48
49 // Bit field usage.
50 DEFINE_TORQUE_GENERATED_PROTOTYPE_INFO_FLAGS()
51
52 class BodyDescriptor;
53
55};
56
57// A growing array with an additional API for marking slots "empty". When adding
58// new elements, we reuse the empty slots instead of growing the array.
60 public:
61 static Handle<WeakArrayList> Add(Isolate* isolate,
64 int* assigned_index);
65
66 static inline void MarkSlotEmpty(Tagged<WeakArrayList> array, int index);
67
68 // The callback is called when a weak pointer to HeapObject "object" is moved
69 // from index "from_index" to index "to_index" during compaction. The callback
70 // must not cause GC.
71 using CompactionCallback = void (*)(Tagged<HeapObject> object, int from_index,
72 int to_index);
73 static Tagged<WeakArrayList> Compact(
77
78#ifdef VERIFY_HEAP
79 static void Verify(Tagged<WeakArrayList> array);
80#endif // VERIFY_HEAP
81
82 static const int kEmptySlotIndex = 0;
83 static const int kFirstIndex = 1;
84
85 static const int kNoEmptySlotsMarker = 0;
86
87 private:
88 static inline Tagged<Smi> empty_slot_index(Tagged<WeakArrayList> array);
89 static inline void set_empty_slot_index(Tagged<WeakArrayList> array,
90 int index);
91
92 static void ScanForEmptySlots(Tagged<WeakArrayList> array);
93
95};
96
97} // namespace internal
98} // namespace v8
99
101
102#endif // V8_OBJECTS_PROTOTYPE_INFO_H_
static void AddDerivedMap(DirectHandle< PrototypeInfo > info, DirectHandle< Map > to, Isolate *isolate)
Tagged< MaybeObject > GetDerivedMap(DirectHandle< Map > from)
static void SetObjectCreateMap(DirectHandle< PrototypeInfo > info, DirectHandle< Map > map, Isolate *isolate)
Tagged< MaybeObject > ObjectCreateMap()
static const int UNREGISTERED
static bool IsPrototypeInfoFast(Tagged< Object > object)
void(*)(Tagged< HeapObject > object, int from_index, int to_index) CompactionCallback
DISALLOW_IMPLICIT_CONSTRUCTORS(PrototypeUsers)
static void MarkSlotEmpty(Tagged< WeakArrayList > array, int index)
TNode< Object > callback
#define DECL_GETTER(name,...)
#define DECL_VERIFIER(Name)
#define DECL_BOOLEAN_ACCESSORS(name)
#define DECL_PRINTER(Name)
#define DECL_RELEASE_ACQUIRE_ACCESSORS(name,...)
#define TQ_OBJECT_CONSTRUCTORS(Type)
#define V8_EXPORT_PRIVATE
Definition macros.h:460