29 return instance_type() != kNoJSApiObjectType;
36 if (IsSharedFunctionInfo(current_info)) {
41 if (maybe_name.
ToHandle(&name) && IsString(*name)) {
43 }
else if (IsString(info->class_name())) {
46 name_string = isolate->factory()->empty_string();
49 if (info->remove_prototype()) {
55 isolate->factory()->NewSharedFunctionInfoForApiFunction(name_string, info,
57 DCHECK(sfi->IsApiFunction());
58 info->set_shared_function_info(*sfi);
64 LocalHeap::Current() ==
nullptr
65 ? GetIsolateChecked()->counters()->runtime_call_stats()
67 RuntimeCallCounterId::kIsTemplateFor);
70 if (!IsJSObjectMap(map))
return false;
72 if (
v8_flags.experimental_embedder_instance_types) {
76 allowed_receiver_instance_type_range_start(),
85 if (IsJSFunction(cons_obj)) {
87 if (!fun->shared()->IsApiFunction())
return false;
88 type = fun->shared()->api_func_data();
89 }
else if (IsFunctionTemplateInfo(cons_obj)) {
94 DCHECK(IsFunctionTemplateInfo(type));
97 while (IsFunctionTemplateInfo(type)) {
98 if (type == *
this)
return true;
109 if (!IsJSApiObject(
object)) {
116 if (IsJSFunction(constructor_obj)) {
118 result = (*
this == fun->shared()->api_func_data());
119 }
else if (IsFunctionTemplateInfo(constructor_obj)) {
120 result = (*
this == constructor_obj);
129 if (info->should_promote_to_read_only())
return;
132 info->EnsureHasSerialNumber(isolate);
135 isolate->factory()->empty_string());
137 info->set_should_promote_to_read_only(
true);
138 info->set_published(
true);
148 isolate->factory()->NewFunctionTemplateRareData();
149 function_template_info->set_rare_data(*rare_data,
kReleaseStore);
156 if (!IsFunctionTemplateInfo(
getter)) {
157 if (!IsJSFunction(
getter))
return {};
159 if (!info->IsApiFunction())
return {};
160 getter = info->api_func_data();
165 if (IsTheHole(maybe_name, isolate))
return {};
196 uint32_t unused_array_index;
197 for (
const std::string_view& name : names) {
199 isolate->factory()->InternalizeString(
202 CHECK(!internalized_name->AsArrayIndex(&unused_array_index));
203 property_names->set(index, *internalized_name);
206 return isolate->factory()->NewDictionaryTemplateInfo(property_names);
214 int num_properties_set) {
216 isolate->slow_object_with_object_prototype_map(), num_properties_set,
219 for (
int i = 0; i < static_cast<int>(property_values.size()); ++
i) {
221 if (!property_values[
i].
ToLocal(&property_value)) {
224 properties = PropertyDictionary::Add(
229 object->set_raw_properties_or_hash(*properties);
240 Isolate* isolate = context->GetIsolate();
243 const int property_names_len = property_names->length();
244 CHECK_EQ(property_names_len,
static_cast<int>(property_values.size()));
245 const int num_properties_set =
static_cast<int>(std::count_if(
246 property_values.begin(), property_values.end(),
247 [](
const auto& maybe_value) { return !maybe_value.IsEmpty(); }));
250 return CreateSlowJSObjectWithProperties(
251 isolate, property_names, property_values, num_properties_set);
254 const bool can_use_map_cache = num_properties_set == property_names_len;
262 DCHECK(!cached_map->is_dictionary_map());
263 bool can_use_cached_map = !cached_map->is_deprecated();
266 auto descriptors =
handle(cached_map->instance_descriptors(), isolate);
267 for (
int i = 0; i < static_cast<int>(property_values.size()); ++
i) {
271 const auto details = descriptors->GetDetails(descriptor);
276 can_use_cached_map =
false;
291 CHECK(!cached_map->is_deprecated());
292 CHECK_EQ(context->object_function_prototype(), cached_map->prototype());
293 auto object = isolate->factory()->NewJSObjectFromMap(
296 for (
int i = 0; i < static_cast<int>(property_values.size()); ++
i) {
297 Local<Value> property_value = property_values[
i].ToLocalChecked();
301 object->FastPropertyAtPut(index, *value,
317 context, num_properties_set);
319 isolate->factory()->NewJSObjectFromMap(current_map);
320 int current_property_index = 0;
321 for (
int i = 0; i < static_cast<int>(property_values.size()); ++
i) {
323 if (!property_values[
i].
ToLocal(&property_value)) {
331 value, attributes, constness,
333 if (current_map->is_dictionary_map()) {
334 return CreateSlowJSObjectWithProperties(
335 isolate, property_names, property_values, num_properties_set);
338 PropertyDetails details = current_map->GetLastDescriptorDetails(isolate);
339 object->WriteToField(
InternalIndex(current_property_index), details,
341 current_property_index++;
static v8::internal::DirectHandle< To > OpenDirectHandle(v8::Local< From > handle)
static DirectHandle< JSObject > NewInstance(DirectHandle< NativeContext > context, DirectHandle< DictionaryTemplateInfo > self, const MemorySpan< MaybeLocal< Value > > &property_values)
static DirectHandle< DictionaryTemplateInfo > Create(Isolate *isolate, const v8::MemorySpan< const std::string_view > &names)
static FieldIndex ForPropertyIndex(Tagged< Map > map, int index, Representation representation=Representation::Tagged())
static bool NowContains(Tagged< FieldType > type, Tagged< Object > value)
static const int kFunctionOverloadEntrySize
const CFunctionInfo * GetCSignature(Isolate *isolate, int index) const
int GetCFunctionsCount() const
static std::optional< Tagged< Name > > TryGetCachedPropertyName(Isolate *isolate, Tagged< Object > getter)
static void SealAndPrepareForPromotionToReadOnly(Isolate *isolate, DirectHandle< FunctionTemplateInfo > info)
Address GetCFunction(Isolate *isolate, int index) const
bool IsLeafTemplateForApiObject(Tagged< Object > object) const
bool IsTemplateFor(Tagged< JSObject > object) const
static Handle< SharedFunctionInfo > GetOrCreateSharedFunctionInfo(Isolate *isolate, DirectHandle< FunctionTemplateInfo > info, MaybeDirectHandle< Name > maybe_name)
static Tagged< FunctionTemplateRareData > AllocateFunctionTemplateRareData(Isolate *isolate, DirectHandle< FunctionTemplateInfo > function_template_info)
static V8_INLINE bool InReadOnlySpace(Tagged< HeapObject > object)
static const int kMaxInObjectProperties
static V8_EXPORT_PRIVATE void MigrateToMap(Isolate *isolate, DirectHandle< JSObject > object, DirectHandle< Map > new_map, int expected_additional_properties=0)
static LocalIsolate * FromHeap(LocalHeap *heap)
static V8_EXPORT_PRIVATE DirectHandle< Map > TransitionToDataProperty(Isolate *isolate, DirectHandle< Map > map, DirectHandle< Name > name, DirectHandle< Object > value, PropertyAttributes attributes, PropertyConstness constness, StoreOrigin store_origin)
V8_WARN_UNUSED_RESULT V8_INLINE bool ToHandle(DirectHandle< S > *out) const
static double NumberValue(Tagged< Number > obj)
static bool FitsRepresentation(Tagged< Object > obj, Representation representation, bool allow_coercion=true)
static constexpr PropertyDetails Empty(PropertyCellType cell_type=PropertyCellType::kNoCell)
static constexpr Representation Double()
static constexpr Representation Tagged()
static void CacheTemplateInstantiation(Isolate *isolate, DirectHandle< NativeContext > native_context, DirectHandle< TemplateInfo > info, CachingMode caching_mode, DirectHandle< Object > object)
static void UncacheTemplateInstantiation(Isolate *isolate, DirectHandle< NativeContext > native_context, DirectHandle< TemplateInfo > info, CachingMode caching_mode)
static MaybeHandle< ReturnType > ProbeInstantiationsCache(Isolate *isolate, DirectHandle< NativeContext > native_context, DirectHandle< TemplateInfo > info, CachingMode caching_mode)
ZoneVector< RpoNumber > & result
constexpr bool IsInRange(T value, U lower_limit, U higher_limit)
V8_INLINE IndirectHandle< T > handle(Tagged< T > object, Isolate *isolate)
V8_INLINE DirectHandle< T > direct_handle(Tagged< T > object, Isolate *isolate)
too high values may cause the compiler to set high thresholds for inlining to as much as possible avoid inlined allocation of objects that cannot escape trace load stores from virtual maglev objects use TurboFan fast string builder analyze liveness of environment slots and zap dead values trace TurboFan load elimination emit data about basic block usage in builtins to this enable builtin reordering when run mksnapshot flag for emit warnings when applying builtin profile data verify register allocation in TurboFan randomly schedule instructions to stress dependency tracking enable store store elimination in TurboFan rewrite far to near simulate GC compiler thread race related to allow float parameters to be passed in simulator mode JS Wasm Run additional turbo_optimize_inlined_js_wasm_wrappers enable experimental feedback collection in generic lowering enable Turboshaft s WasmLoadElimination enable Turboshaft s low level load elimination for JS enable Turboshaft s escape analysis for string concatenation use enable Turbolev features that we want to ship in the not too far future trace individual Turboshaft reduction steps trace intermediate Turboshaft reduction steps invocation count threshold for early optimization Enables optimizations which favor memory size over execution speed Enables sampling allocation profiler with X as a sample interval min size of a semi the new space consists of two semi spaces max size of the Collect garbage after Collect garbage after keeps maps alive for< n > old space garbage collections print one detailed trace line in name
V8_EXPORT_PRIVATE FlagValues v8_flags
allowed_receiver_instance_type_range_end
Tagged< To > Cast(Tagged< From > value, const v8::SourceLocation &loc=INIT_SOURCE_LOCATION_IN_DEBUG)
static constexpr ReleaseStoreTag kReleaseStore
bool ToLocal(v8::internal::MaybeDirectHandle< v8::internal::Object > maybe, Local< T > *local)
v8::Local< T > ToApiHandle(v8::internal::DirectHandle< v8::internal::Object > obj)
T ToCData(i::Isolate *isolate, v8::internal::Tagged< v8::internal::Object > obj)
static constexpr AcquireLoadTag kAcquireLoad
#define DCHECK_IMPLIES(v1, v2)
#define CHECK_EQ(lhs, rhs)
#define DCHECK(condition)
#define V8_LIKELY(condition)
#define V8_UNLIKELY(condition)