v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
literal-objects-inl.h
Go to the documentation of this file.
1// Copyright 2017 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_LITERAL_OBJECTS_INL_H_
6#define V8_OBJECTS_LITERAL_OBJECTS_INL_H_
7
9// Include the non-inl header before the rest of the headers.
10
11#include <optional>
12
14
15// Has to be the last include (doesn't have include guards):
17
18namespace v8::internal {
19
20#include "torque-generated/src/objects/literal-objects-tq-inl.inc"
21
22//
23// ObjectBoilerplateDescription
24//
25
26// static
27template <class IsolateT>
29 IsolateT* isolate, int boilerplate, int all_properties, int index_keys,
30 bool has_seen_proto, AllocationType allocation) {
31 DCHECK_GE(boilerplate, 0);
32 DCHECK_GE(all_properties, index_keys);
33 DCHECK_GE(index_keys, 0);
34
35 int capacity = boilerplate * kElementsPerEntry;
36 CHECK_LE(static_cast<unsigned>(capacity), kMaxCapacity);
37
39 all_properties - index_keys - (has_seen_proto ? 1 : 0);
41
42 // Note we explicitly do NOT canonicalize to the
43 // empty_object_boilerplate_description here since `flags` may be modified
44 // even on empty descriptions.
45
46 std::optional<DisallowGarbageCollection> no_gc;
48 Allocate(isolate, capacity, &no_gc, allocation));
49 result->set_flags(0);
50 result->set_backing_store_size(backing_store_size);
51 MemsetTagged((*result)->RawFieldOfFirstElement(),
52 ReadOnlyRoots{isolate}.undefined_value(), capacity);
53 return result;
54}
55
57 return backing_store_size_.load().value();
58}
60 backing_store_size_.store(this, Smi::FromInt(value));
61}
63 return flags_.load().value();
64}
66 flags_.store(this, Smi::FromInt(value));
67}
68
70 return get(NameIndex(index));
71}
72
74 return get(ValueIndex(index));
75}
76
78 Tagged<Object> value) {
79 DCHECK_LT(static_cast<unsigned>(index), boilerplate_properties_count());
80 set(NameIndex(index), key);
81 set(ValueIndex(index), value);
82}
83
88
89//
90// ClassBoilerplate
91//
92
94
95SMI_ACCESSORS(ClassBoilerplate, arguments_count, kArgumentsCountOffset)
96ACCESSORS(ClassBoilerplate, static_properties_template, Tagged<Object>,
97 kStaticPropertiesTemplateOffset)
99 kStaticElementsTemplateOffset)
100ACCESSORS(ClassBoilerplate, static_computed_properties, Tagged<FixedArray>,
101 kStaticComputedPropertiesOffset)
103 kInstancePropertiesTemplateOffset)
104ACCESSORS(ClassBoilerplate, instance_elements_template, Tagged<Object>,
105 kInstanceElementsTemplateOffset)
107 kInstanceComputedPropertiesOffset)
108
109//
110// ArrayBoilerplateDescription
111//
112
114
116 return static_cast<ElementsKind>(flags());
117}
118
122
124 return constant_elements()->length() == 0;
125}
126
127//
128// RegExpBoilerplateDescription
129//
130
133 kDataOffset, kRegExpDataIndirectPointerTag)
136
137} // namespace v8::internal
138
140
141#endif // V8_OBJECTS_LITERAL_OBJECTS_INL_H_
Builtins::Kind kind
Definition builtins.cc:40
Tagged< Object > name(int index) const
void set_backing_store_size(int backing_store_size)
static Handle< ObjectBoilerplateDescription > New(IsolateT *isolate, int boilerplate, int all_properties, int index_keys, bool has_seen_proto, AllocationType allocation=AllocationType::kYoung)
Tagged< Object > value(int index) const
void set_key_value(int index, Tagged< Object > key, Tagged< Object > value)
static constexpr Tagged< Smi > FromInt(int value)
Definition smi.h:38
static Handle< ObjectBoilerplateDescription > Allocate(IsolateT *isolate, int capacity, std::optional< DisallowGarbageCollection > *no_gc_out, AllocationType allocation=AllocationType::kYoung)
void set(int index, Tagged< ElementT > value, WriteBarrierMode mode=kDefaultMode)
JSRegExp::Flags flags_
ZoneVector< RpoNumber > & result
kStaticElementsTemplateOffset kInstancePropertiesTemplateOffset instance_computed_properties
void MemsetTagged(Tagged_t *start, Tagged< MaybeObject > value, size_t counter)
Definition slots-inl.h:486
Flag flags[]
Definition flags.cc:3797
kStaticElementsTemplateOffset instance_properties_template
Tagged< To > Cast(Tagged< From > value, const v8::SourceLocation &loc=INIT_SOURCE_LOCATION_IN_DEBUG)
Definition casting.h:150
#define OBJECT_CONSTRUCTORS_IMPL(Type, Super)
#define ACCESSORS(holder, name, type, offset)
#define TRUSTED_POINTER_ACCESSORS(holder, name, type, offset, tag)
#define TQ_OBJECT_CONSTRUCTORS_IMPL(Type)
#define SMI_ACCESSORS(holder, name, offset)
#define CHECK_LE(lhs, rhs)
#define DCHECK_GE(v1, v2)
Definition logging.h:488
#define DCHECK_LT(v1, v2)
Definition logging.h:489
#define DCHECK_EQ(v1, v2)
Definition logging.h:485