5#ifndef V8_OBJECTS_TEMPLATES_INL_H_
6#define V8_OBJECTS_TEMPLATES_INL_H_
23#include "torque-generated/src/objects/templates-tq-inl.inc"
36 is_object_template_call_handler,
37 IsObjectTemplateCallHandlerBit::kShift)
39 HasSideEffectsBit::kShift)
41 UndetectableBit::kShift)
43 NeedsAccessCheckBit::kShift)
45 ReadOnlyPrototypeBit::kShift)
47 RemovePrototypeBit::kShift)
49 AcceptAnyReceiverBit::kShift)
55void FunctionTemplateInfo::set_published(
bool value) {
57 if (published())
return;
65 allowed_receiver_instance_type_range_start,
66 FunctionTemplateInfo::AllowedReceiverInstanceTypeRangeStartBits)
70 FunctionTemplateInfo::AllowedReceiverInstanceTypeRangeEndBits)
91 init_maybe_redirected_callback(isolate, initial_value);
99 set_maybe_redirected_callback(isolate, value);
108 Address value = maybe_redirected_callback(isolate);
112 set_maybe_redirected_callback(isolate, value);
119 set_maybe_redirected_callback(isolate, value);
126template <
class IsolateT>
128 return !IsTheHole(callback_data(
kAcquireLoad), isolate);
135 DirectHandle<FunctionTemplateInfo> function_template_info) {
137 function_template_info->rare_data(isolate,
kAcquireLoad);
138 if (IsUndefined(extra, isolate)) {
145#define RARE_ACCESSORS(Name, CamelName, Default, ...) \
146 DEF_GETTER(FunctionTemplateInfo, Get##CamelName, Tagged<__VA_ARGS__>) { \
147 Tagged<HeapObject> extra = rare_data(cage_base, kAcquireLoad); \
148 Tagged<Undefined> undefined = GetReadOnlyRoots().undefined_value(); \
149 return extra == undefined ? Default \
150 : Cast<FunctionTemplateRareData>(extra)->Name(); \
152 inline void FunctionTemplateInfo::Set##CamelName( \
154 DirectHandle<FunctionTemplateInfo> function_template_info, \
155 DirectHandle<__VA_ARGS__> Name) { \
156 Tagged<FunctionTemplateRareData> rare_data = \
157 EnsureFunctionTemplateRareData(isolate, function_template_info); \
158 rare_data->set_##Name(*Name); \
181InstanceType FunctionTemplateInfo::GetInstanceType()
const {
182 int type = instance_type();
196 static_assert(kNoJSApiObjectType == 0);
203 int api_instance_type_start,
int api_instance_type_end) {
209 DCHECK_LE(api_instance_type_start, api_instance_type_end);
212 static_assert(kNoJSApiObjectType == 0);
214 set_allowed_receiver_instance_type_range_start(
static_cast<InstanceType>(
216 set_allowed_receiver_instance_type_range_end(
static_cast<InstanceType>(
223 FunctionTemplateInfo::AllowedReceiverInstanceTypeRangeStartBits::is_valid(
224 LAST_JS_API_OBJECT_TYPE));
226 FunctionTemplateInfo::AllowedReceiverInstanceTypeRangeEndBits::is_valid(
227 LAST_JS_API_OBJECT_TYPE));
230 return IsSharedFunctionInfo(shared_function_info());
235 if (IsSharedFunctionInfo(maybe_shared)) {
237 return shared->BreakAtEntry(isolate);
254 constructor = constructor->GetParent(isolate);
257 if (!IsUndefined(maybe_obj, isolate)) {
264int ObjectTemplateInfo::embedder_field_count()
const {
265 return EmbedderFieldCountBits::decode(
data());
268void ObjectTemplateInfo::set_embedder_field_count(
int count) {
270 return set_data(EmbedderFieldCountBits::update(
data(), count));
273bool ObjectTemplateInfo::immutable_proto()
const {
274 return IsImmutablePrototypeBit::decode(
data());
277void ObjectTemplateInfo::set_immutable_proto(
bool immutable) {
278 return set_data(IsImmutablePrototypeBit::update(
data(), immutable));
281bool ObjectTemplateInfo::code_like()
const {
282 return IsCodeKindBit::decode(
data());
285void ObjectTemplateInfo::set_code_like(
bool is_code_like) {
286 return set_data(IsCodeKindBit::update(
data(), is_code_like));
296 if (isolate_value !=
nullptr) {
297 *isolate = isolate_value;
309bool TemplateInfo::is_cacheable()
const {
310 return IsCacheableBit::decode(template_info_flags());
312void TemplateInfo::set_is_cacheable(
bool is_cacheable) {
313 set_template_info_flags(
314 IsCacheableBit::update(template_info_flags(), is_cacheable));
317bool TemplateInfo::should_promote_to_read_only()
const {
318 return ShouldPromoteToReadOnlyBit::decode(template_info_flags());
320void TemplateInfo::set_should_promote_to_read_only(
321 bool should_promote_to_read_only) {
322 DCHECK(should_promote_to_read_only);
323 set_template_info_flags(ShouldPromoteToReadOnlyBit::update(
324 template_info_flags(), should_promote_to_read_only));
327uint32_t TemplateInfo::serial_number()
const {
328 return SerialNumberBits::decode(template_info_flags());
330void TemplateInfo::set_serial_number(uint32_t value) {
331 set_template_info_flags(
332 SerialNumberBits::update(template_info_flags(), value));
336 uint32_t serial_number = this->serial_number();
339 serial_number = isolate->heap()->GetNextTemplateSerialNumber();
340 set_serial_number(serial_number);
342 return serial_number;
356 DCHECK(info->is_cacheable());
358 uint32_t serial_number = info->serial_number();
367 if (IsTheHole(
object, isolate)) {
370 return handle(
object, isolate);
376 uint32_t hash = info->GetHash();
377 InternalIndex entry = cache->FindEntry(isolate, roots, info, hash);
379 return handle(cache->ValueAt(entry), isolate);
389 DCHECK(info->is_cacheable());
391 uint32_t serial_number = info->EnsureHasSerialNumber(isolate);
396 fast_cache->set(serial_number, *
object);
405 uint32_t hash = info->GetHash();
407 EphemeronHashTable::Put(isolate, cache, info,
object, hash);
408 if (*new_cache != *cache) {
409 native_context->set_slow_template_instantiations_cache(*new_cache);
418 int serial_number = info->serial_number();
424 DCHECK(!IsUndefined(fast_cache->get(serial_number), isolate));
425 fast_cache->set(serial_number,
ReadOnlyRoots{isolate}.the_hole_value(),
432 uint32_t hash = info->GetHash();
433 bool was_present =
false;
435 EphemeronHashTable::Remove(isolate, cache, info, &was_present, hash);
437 if (!new_cache.is_identical_to(cache)) {
438 native_context->set_slow_template_instantiations_cache(*new_cache);
union v8::internal::@341::BuiltinMetadata::KindSpecificData data
static Isolate * TryGetCurrent()
static bool get(int value, int bit_position)
static int set(int value, int bit_position, bool v)
static Address Redirect(Address external_function, Type type=ExternalReference::BUILTIN_CALL)
static Address UnwrapRedirection(Address redirection_trampoline)
void SetAllowedReceiverInstanceTypeRange(int api_instance_type_start, int api_instance_type_end)
void SetInstanceType(int api_instance_type)
static Tagged< FunctionTemplateRareData > EnsureFunctionTemplateRareData(Isolate *isolate, DirectHandle< FunctionTemplateInfo > function_template_info)
bool BreakAtEntry(Isolate *isolate)
void set_relaxed_flag(int32_t flags)
void init_callback_redirection(i::IsolateForSandbox isolate)
bool has_callback(IsolateT *isolate) const
bool IsTemplateFor(Tagged< JSObject > object) const
void remove_callback_redirection(i::IsolateForSandbox isolate)
static Tagged< FunctionTemplateRareData > AllocateFunctionTemplateRareData(Isolate *isolate, DirectHandle< FunctionTemplateInfo > function_template_info)
Tagged< FunctionTemplateInfo > GetParent(Isolate *isolate)
static V8_INLINE bool InReadOnlySpace(Tagged< HeapObject > object)
static const int kFirstEmbedderJSApiObjectType
static const int kLastJSApiObjectType
static const int kFirstJSApiObjectType
static const int kLastEmbedderJSApiObjectType
static const int kMaxEmbedderFields
NEVER_READ_ONLY_SPACE Tagged< ObjectTemplateInfo > GetParent(Isolate *isolate)
static constexpr int kMaxValue
static void CacheTemplateInstantiation(Isolate *isolate, DirectHandle< NativeContext > native_context, DirectHandle< TemplateInfo > info, CachingMode caching_mode, DirectHandle< Object > object)
static constexpr int kMaxTemplateInstantiationsCacheSize
Isolate * GetIsolateChecked() const
static void UncacheTemplateInstantiation(Isolate *isolate, DirectHandle< NativeContext > native_context, DirectHandle< TemplateInfo > info, CachingMode caching_mode)
bool TryGetIsolate(Isolate **isolate) const
static const int kUninitializedSerialNumber
static const int kFastTemplateInstantiationsCacheSize
uint32_t EnsureHasSerialNumber(Isolate *isolate)
static MaybeHandle< ReturnType > ProbeInstantiationsCache(Isolate *isolate, DirectHandle< NativeContext > native_context, DirectHandle< TemplateInfo > info, CachingMode caching_mode)
#define USE_SIMULATOR_BOOL
ZoneVector< RpoNumber > & result
constexpr bool IsInRange(T value, U lower_limit, U higher_limit)
V8_INLINE IndirectHandle< T > handle(Tagged< T > object, Isolate *isolate)
HasSideEffectsBit::kShift NeedsAccessCheckBit::kShift remove_prototype
ReadOnlyRoots GetReadOnlyRoots()
Tagged(T object) -> Tagged< T >
uint32_t ComputeUnseededHash(uint32_t key)
V8_INLINE bool GetIsolateFromHeapObject(Tagged< HeapObject > object, Isolate **isolate)
kInterpreterTrampolineOffset Tagged< HeapObject >
HasSideEffectsBit::kShift needs_access_check
typename detail::FlattenUnionHelper< Union<>, Ts... >::type UnionOf
@ kFunctionTemplateInfoCallbackTag
PrototypeProviderTemplate
static constexpr Address kNullAddress
UnionOf< Undefined, FunctionTemplateInfo > NamedPropertyHandler
UnionOf< Undefined, FunctionTemplateInfo > UnionOf< Undefined, InterceptorInfo > InstanceTemplate
allowed_receiver_instance_type_range_end
!IsContextMap !IsContextMap native_context
Tagged< To > Cast(Tagged< From > value, const v8::SourceLocation &loc=INIT_SOURCE_LOCATION_IN_DEBUG)
static constexpr RelaxedLoadTag kRelaxedLoad
static constexpr RelaxedStoreTag kRelaxedStore
static constexpr AcquireLoadTag kAcquireLoad
#define BOOL_ACCESSORS(holder, field, name, offset)
#define TQ_OBJECT_CONSTRUCTORS_IMPL(Type)
#define EXTERNAL_POINTER_ACCESSORS_MAYBE_READ_ONLY_HOST(holder, name, type, offset, tag)
#define BIT_FIELD_ACCESSORS(holder, field, name, BitField)
#define RELAXED_UINT32_ACCESSORS(holder, name, offset)
#define NEVER_READ_ONLY_SPACE_IMPL(Type)
#define DCHECK_LE(v1, v2)
#define DCHECK(condition)
#define RARE_ACCESSORS(Name, CamelName, Default,...)