v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
builtins-object-gen.cc
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
6
7#include <optional>
8
13#include "src/common/globals.h"
23
24namespace v8 {
25namespace internal {
26
28
60
62 TNode<String> string) {
63 TNode<String> lhs = StringConstant("[object ");
65
67
68 Return(CallBuiltin(builtin, context,
69 CallBuiltin(builtin, context, lhs, string), rhs));
70}
71
74 TNode<BoolT> enumerable, TNode<BoolT> configurable) {
76 TNode<Map> map = CAST(LoadContextElement(
77 native_context, Context::ACCESSOR_PROPERTY_DESCRIPTOR_MAP_INDEX));
79
81 js_desc, JSAccessorPropertyDescriptor::kGetOffset, getter);
83 js_desc, JSAccessorPropertyDescriptor::kSetOffset, setter);
85 js_desc, JSAccessorPropertyDescriptor::kEnumerableOffset,
86 SelectBooleanConstant(enumerable));
88 js_desc, JSAccessorPropertyDescriptor::kConfigurableOffset,
89 SelectBooleanConstant(configurable));
90
91 return js_desc;
92}
93
95 TNode<Context> context, TNode<Object> value, TNode<BoolT> writable,
96 TNode<BoolT> enumerable, TNode<BoolT> configurable) {
98 TNode<Map> map = CAST(LoadContextElement(
99 native_context, Context::DATA_PROPERTY_DESCRIPTOR_MAP_INDEX));
101
103 JSDataPropertyDescriptor::kValueOffset, value);
105 JSDataPropertyDescriptor::kWritableOffset,
106 SelectBooleanConstant(writable));
108 JSDataPropertyDescriptor::kEnumerableOffset,
109 SelectBooleanConstant(enumerable));
111 JSDataPropertyDescriptor::kConfigurableOffset,
112 SelectBooleanConstant(configurable));
113
114 return js_desc;
115}
116
123
129
135
137 TNode<Context> context, TNode<Object> maybe_object,
138 CollectType collect_type) {
139 TNode<JSReceiver> receiver = ToObject_Inline(context, maybe_object);
140
141 Label if_call_runtime_with_fast_path(this, Label::kDeferred),
142 if_call_runtime(this, Label::kDeferred),
143 if_no_properties(this, Label::kDeferred);
144
146 GotoIfNot(IsJSObjectMap(map), &if_call_runtime);
147 GotoIfMapHasSlowProperties(map, &if_call_runtime);
148
149 TNode<JSObject> object = CAST(receiver);
150 TNode<FixedArrayBase> elements = LoadElements(object);
151 // If the object has elements, we treat it as slow case.
152 // So, we go to runtime call.
153 GotoIfNot(IsEmptyFixedArray(elements), &if_call_runtime_with_fast_path);
154
156 context, object, &if_call_runtime_with_fast_path, &if_no_properties,
157 collect_type);
158 Return(result);
159
160 BIND(&if_no_properties);
161 {
163 TNode<Map> array_map =
165 TNode<JSArray> empty_array = AllocateJSArray(
166 PACKED_ELEMENTS, array_map, IntPtrConstant(0), SmiConstant(0));
167 Return(empty_array);
168 }
169
170 BIND(&if_call_runtime_with_fast_path);
171 {
172 // In slow case, we simply call runtime.
173 if (collect_type == CollectType::kEntries) {
174 Return(CallRuntime(Runtime::kObjectEntries, context, object));
175 } else {
176 DCHECK(collect_type == CollectType::kValues);
177 Return(CallRuntime(Runtime::kObjectValues, context, object));
178 }
179 }
180
181 BIND(&if_call_runtime);
182 {
183 // In slow case, we simply call runtime.
184 if (collect_type == CollectType::kEntries) {
185 Return(
186 CallRuntime(Runtime::kObjectEntriesSkipFastPath, context, receiver));
187 } else {
188 DCHECK(collect_type == CollectType::kValues);
189 Return(
190 CallRuntime(Runtime::kObjectValuesSkipFastPath, context, receiver));
191 }
192 }
193}
194
196 TNode<Context> context, TNode<JSObject> object,
197 Label* if_call_runtime_with_fast_path, Label* if_no_properties,
198 CollectType collect_type) {
200 TNode<Map> array_map =
202 TNode<Map> map = LoadMap(object);
204
205 Label if_has_enum_cache(this), if_not_has_enum_cache(this),
206 collect_entries(this);
207 TNode<IntPtrT> object_enum_length =
209 TNode<BoolT> has_enum_cache = WordNotEqual(
210 object_enum_length, IntPtrConstant(kInvalidEnumCacheSentinel));
211
212 // In case, we found enum_cache in object,
213 // we use it as array_length because it has same size for
214 // Object.(entries/values) result array object length.
215 // So object_enum_length use less memory space than
216 // NumberOfOwnDescriptorsBits value.
217 // And in case, if enum_cache_not_found,
218 // we call runtime and initialize enum_cache for subsequent call of
219 // CSA fast path.
220 Branch(has_enum_cache, &if_has_enum_cache, if_call_runtime_with_fast_path);
221
222 BIND(&if_has_enum_cache);
223 {
224 GotoIf(WordEqual(object_enum_length, IntPtrConstant(0)), if_no_properties);
225 TNode<FixedArray> values_or_entries =
226 CAST(AllocateFixedArray(PACKED_ELEMENTS, object_enum_length));
227
228 // If in case we have enum_cache,
229 // we can't detect accessor of object until loop through descriptors.
230 // So if object might have accessor,
231 // we will remain invalid addresses of FixedArray.
232 // Because in that case, we need to jump to runtime call.
233 // So the array filled by the-hole even if enum_cache exists.
234 FillFixedArrayWithValue(PACKED_ELEMENTS, values_or_entries,
235 IntPtrConstant(0), object_enum_length,
236 RootIndex::kTheHoleValue);
237
238 TVARIABLE(IntPtrT, var_result_index, IntPtrConstant(0));
239 TVARIABLE(IntPtrT, var_descriptor_number, IntPtrConstant(0));
240 // Let desc be ? O.[[GetOwnProperty]](key).
242 Label loop(this, {&var_descriptor_number, &var_result_index}),
243 after_loop(this), next_descriptor(this);
244 Branch(IntPtrEqual(var_descriptor_number.value(), object_enum_length),
245 &after_loop, &loop);
246
247 // We dont use BuildFastLoop.
248 // Instead, we use hand-written loop
249 // because of we need to use 'continue' functionality.
250 BIND(&loop);
251 {
252 // Currently, we will not invoke getters,
253 // so, map will not be changed.
254 CSA_DCHECK(this, TaggedEqual(map, LoadMap(object)));
255 TNode<IntPtrT> descriptor_entry = var_descriptor_number.value();
256 TNode<Name> next_key =
257 LoadKeyByDescriptorEntry(descriptors, descriptor_entry);
258
259 // Skip Symbols.
260 GotoIf(IsSymbol(next_key), &next_descriptor);
261
262 TNode<Uint32T> details =
263 LoadDetailsByDescriptorEntry(descriptors, descriptor_entry);
264
266
267 // If property is accessor, we escape fast path and call runtime.
268 GotoIf(IsPropertyKindAccessor(kind), if_call_runtime_with_fast_path);
270
271 // If desc is not undefined and desc.[[Enumerable]] is true, then skip to
272 // the next descriptor.
273 GotoIfNot(IsPropertyEnumerable(details), &next_descriptor);
274
275 TVARIABLE(Object, var_property_value, UndefinedConstant());
276 TNode<IntPtrT> descriptor_name_index = ToKeyIndex<DescriptorArray>(
277 Unsigned(TruncateIntPtrToInt32(var_descriptor_number.value())));
278
279 // Let value be ? Get(O, key).
280 LoadPropertyFromFastObject(object, map, descriptors,
281 descriptor_name_index, details,
282 &var_property_value);
283
284 // If kind is "value", append value to properties.
285 TNode<Object> value = var_property_value.value();
286
287 if (collect_type == CollectType::kEntries) {
288 // Let entry be CreateArrayFromList(« key, value »).
289 TNode<JSArray> array;
290 TNode<FixedArrayBase> elements;
291 std::tie(array, elements) = AllocateUninitializedJSArrayWithElements(
292 PACKED_ELEMENTS, array_map, SmiConstant(2), std::nullopt,
293 IntPtrConstant(2));
294 StoreFixedArrayElement(CAST(elements), 0, next_key, SKIP_WRITE_BARRIER);
295 StoreFixedArrayElement(CAST(elements), 1, value, SKIP_WRITE_BARRIER);
296 value = array;
297 }
298
299 StoreFixedArrayElement(values_or_entries, var_result_index.value(),
300 value);
301 Increment(&var_result_index);
302 Goto(&next_descriptor);
303
304 BIND(&next_descriptor);
305 {
306 Increment(&var_descriptor_number);
307 Branch(IntPtrEqual(var_result_index.value(), object_enum_length),
308 &after_loop, &loop);
309 }
310 }
311 BIND(&after_loop);
312 return FinalizeValuesOrEntriesJSArray(context, values_or_entries,
313 var_result_index.value(), array_map,
314 if_no_properties);
315 }
316}
317
321 TNode<Map> array_map, Label* if_empty) {
322 CSA_DCHECK(this, IsJSArrayMap(array_map));
323
324 GotoIf(IntPtrEqual(size, IntPtrConstant(0)), if_empty);
325 TNode<JSArray> array = AllocateJSArray(array_map, result, SmiTag(size));
326 return array;
327}
328
329TF_BUILTIN(ObjectPrototypeHasOwnProperty, ObjectBuiltinsAssembler) {
330 auto object = Parameter<Object>(Descriptor::kReceiver);
331 auto key = Parameter<Object>(Descriptor::kKey);
332 auto context = Parameter<Context>(Descriptor::kContext);
333
334 Label call_runtime(this), return_true(this), return_false(this),
335 to_primitive(this);
336
337 // Smi receivers do not have own properties, just perform ToPrimitive on the
338 // key.
339 Label if_objectisnotsmi(this);
340 Branch(TaggedIsSmi(object), &to_primitive, &if_objectisnotsmi);
341 BIND(&if_objectisnotsmi);
342
343 TNode<HeapObject> heap_object = CAST(object);
344
345 TNode<Map> map = LoadMap(heap_object);
346 TNode<Uint16T> instance_type = LoadMapInstanceType(map);
347
348 {
349 TVARIABLE(IntPtrT, var_index);
350 TVARIABLE(Name, var_unique);
351
352 Label if_index(this, &var_index), if_unique_name(this),
353 if_notunique_name(this);
354 TryToName(key, &if_index, &var_index, &if_unique_name, &var_unique,
355 &call_runtime, &if_notunique_name);
356
357 BIND(&if_unique_name);
358 TryHasOwnProperty(heap_object, map, instance_type, var_unique.value(),
359 &return_true, &return_false, &call_runtime);
360
361 BIND(&if_index);
362 {
363 TryLookupElement(heap_object, map, instance_type, var_index.value(),
364 &return_true, &return_false, &return_false,
365 &call_runtime);
366 }
367
368 BIND(&if_notunique_name);
369 {
370 Label not_in_string_table(this);
371 TryInternalizeString(CAST(key), &if_index, &var_index, &if_unique_name,
372 &var_unique, &not_in_string_table, &call_runtime);
373
374 BIND(&not_in_string_table);
375 {
376 // If the string was not found in the string table, then no regular
377 // object can have a property with that name, so return |false|.
378 // "Special API objects" with interceptors must take the slow path.
379 Branch(IsSpecialReceiverInstanceType(instance_type), &call_runtime,
380 &return_false);
381 }
382 }
383 }
384 BIND(&to_primitive);
385 GotoIf(IsNumber(key), &return_false);
386 Branch(IsName(CAST(key)), &return_false, &call_runtime);
387
388 BIND(&return_true);
389 Return(TrueConstant());
390
391 BIND(&return_false);
392 Return(FalseConstant());
393
394 BIND(&call_runtime);
395 Return(CallRuntime(Runtime::kObjectHasOwnProperty, context, object, key));
396}
397
398// ES #sec-object.assign
400 TNode<IntPtrT> argc = ChangeInt32ToIntPtr(
401 UncheckedParameter<Int32T>(Descriptor::kJSActualArgumentsCount));
402 CodeStubArguments args(this, argc);
403
404 auto context = Parameter<Context>(Descriptor::kContext);
405 TNode<Object> target = args.GetOptionalArgumentValue(0);
406
407 TVARIABLE(IntPtrT, slow_path_index, IntPtrConstant(1));
408
409 // 1. Let to be ? ToObject(target).
410 TNode<JSReceiver> to = ToObject_Inline(context, target);
411
412 Label done(this);
413 // 2. If only one argument was passed, return to.
414 TNode<IntPtrT> args_length = args.GetLengthWithoutReceiver();
415 GotoIf(UintPtrLessThanOrEqual(args_length, IntPtrConstant(1)), &done);
416
417 // First let's try a fastpath specifically for when the target objects is an
418 // empty object literal.
419 // TODO(olivf): For the cases where we could detect that the object literal
420 // does not escape in the parser already, we should have a variant of this
421 // builtin where the target is not yet allocated at all.
422 Label done_fast_path(this), slow_path(this);
423 GotoIfForceSlowPath(&slow_path);
424 {
425 Label fall_through_slow_path(this);
426
427 // First, evaluate the first source object.
428 TNode<Object> source = args.GetOptionalArgumentValue(1);
429 GotoIf(IsNullOrUndefined(source), &done_fast_path);
430
431 TVARIABLE(IntPtrT, var_result_index, IntPtrConstant(0));
432 TNode<JSReceiver> from = ToObject_Inline(context, source);
433
434 TNode<Map> from_map = LoadMap(from);
435 // For the fast case we want the source to be a JSObject.
436 GotoIfNot(IsJSObjectMap(from_map), &slow_path);
437
438 TNode<Map> to_map = LoadMap(to);
439
440 // Chances that the fast cloning is possible is very low in case source
441 // and target maps belong to different native contexts (the only case
442 // it'd work is if the |from| object doesn't have enumerable properties)
443 // or if one of them is a remote JS object.
444 // TODO(olivf): Re-Evaluate this once we have a representation for "no
445 // enumerable properties" state in an Object.assign sidestep transition.
446 {
447 TNode<Map> to_meta_map = LoadMap(to_map);
448 GotoIfNot(TaggedEqual(LoadMap(from_map), to_meta_map), &slow_path);
449
450 // For the fast case we want the target to be a fresh empty object
451 // literal from current context.
452 // TODO(olivf): consider extending the fast path to a case when source
453 // and target objects are from the same context but not necessarily from
454 // current one.
455 TNode<NativeContext> native_context = LoadNativeContext(context);
456 TNode<Map> empty_object_literal_map =
457 LoadObjectFunctionInitialMap(native_context);
458 GotoIfNot(TaggedEqual(to_map, empty_object_literal_map), &slow_path);
459 // Double-check that the meta map is not contextless.
460 CSA_DCHECK(this,
461 TaggedEqual(native_context,
462 LoadMapConstructorOrBackPointerOrNativeContext(
463 to_meta_map)));
464 }
465
466 // Chances are very slim that cloning is possible if we have different
467 // instance sizes.
468 // TODO(olivf): Re-Evaluate this once we have a faster target map lookup
469 // that does not need to go through the runtime.
470 TNode<IntPtrT> from_inst_size = LoadMapInstanceSizeInWords(from_map);
471 TNode<IntPtrT> to_inst_size = LoadMapInstanceSizeInWords(to_map);
472 GotoIfNot(IntPtrEqual(from_inst_size, to_inst_size), &slow_path);
473
474 // Both source and target should be in fastmode, not a prototype and not
475 // deprecated.
476 constexpr uint32_t field3_exclusion_mask =
477 Map::Bits3::IsDictionaryMapBit::kMask |
478 Map::Bits3::IsDeprecatedBit::kMask |
479 Map::Bits3::IsPrototypeMapBit::kMask;
480
481 // Ensure the target is empty and extensible and has none of the exclusion
482 // bits set.
483 TNode<Uint32T> target_field3 = LoadMapBitField3(to_map);
484 TNode<Uint32T> field3_descriptors_and_extensible_mask = Uint32Constant(
485 Map::Bits3::NumberOfOwnDescriptorsBits::kMask |
486 Map::Bits3::IsExtensibleBit::kMask | field3_exclusion_mask);
487 // If the masked field3 equals the extensible bit, then the number of
488 // descriptors was 0 -- which is what we need here.
489 GotoIfNot(
490 Word32Equal(
491 Uint32Constant(Map::Bits3::IsExtensibleBit::encode(true)),
492 Word32And(target_field3, field3_descriptors_and_extensible_mask)),
493 &slow_path);
494
495 // Check that the source is in fastmode, not a prototype and not deprecated.
496 TNode<Uint32T> source_field3 = LoadMapBitField3(from_map);
497 TNode<Uint32T> field3_exclusion_mask_const =
498 Uint32Constant(field3_exclusion_mask);
499 GotoIfNot(
500 Word32Equal(Uint32Constant(0),
501 Word32And(source_field3, field3_exclusion_mask_const)),
502 &slow_path);
503 CSA_DCHECK(this, Word32BinaryNot(IsElementsKindInRange(
504 LoadElementsKind(to_map),
507
508 // TODO(olivf): We could support the case when the `to` has elements, but
509 // the source doesn't. But there is a danger of then caching an invalid
510 // transition when the converse happens later.
511 GotoIfNot(TaggedEqual(LoadElements(CAST(to)), EmptyFixedArrayConstant()),
512 &slow_path);
513
514 // Ensure the properties field is not used to store a hash.
515 TNode<Object> properties = LoadJSReceiverPropertiesOrHash(to);
516 GotoIf(TaggedIsSmi(properties), &slow_path);
517 CSA_DCHECK(this,
518 Word32Or(TaggedEqual(properties, EmptyFixedArrayConstant()),
519 IsPropertyArray(CAST(properties))));
520
521 Label continue_fast_path(this), runtime_map_lookup(this, Label::kDeferred);
522
523 // Check if our particular source->target combination is fast clonable.
524 // E.g., this ensures that we only have fast properties and in general that
525 // the binary layout is compatible for `FastCloneJSObject`.
526 // If such a clone map exists then it can be found in the transition array
527 // with object_assign_clone_transition_symbol as a key. If this transition
528 // slot is cleared, then the map is not clonable. If the key is missing
529 // from the transitions we rely on the runtime function
530 // ObjectAssignTryFastcase that does the actual computation.
531 TVARIABLE(Map, clone_map);
532 {
533 // First check if we have a transition array.
534 TNode<MaybeObject> maybe_transitions = LoadMaybeWeakObjectField(
535 from_map, Map::kTransitionsOrPrototypeInfoOffset);
536 TNode<HeapObject> maybe_transitions2 =
537 GetHeapObjectIfStrong(maybe_transitions, &runtime_map_lookup);
538 GotoIfNot(IsTransitionArrayMap(LoadMap(maybe_transitions2)),
539 &runtime_map_lookup);
540 TNode<WeakFixedArray> transitions = CAST(maybe_transitions2);
541 TNode<Object> side_step_transitions = CAST(LoadWeakFixedArrayElement(
542 transitions,
544 GotoIf(TaggedIsSmi(side_step_transitions), &runtime_map_lookup);
545 TNode<MaybeObject> maybe_target_map = LoadWeakFixedArrayElement(
546 CAST(side_step_transitions),
547 IntPtrConstant(SideStepTransition::index_of(
549 GotoIf(TaggedEqual(maybe_target_map,
551 &slow_path);
552 GotoIf(
553 TaggedEqual(maybe_target_map, SmiConstant(SideStepTransition::Empty)),
554 &runtime_map_lookup);
555 TNode<Map> target_map =
556 CAST(GetHeapObjectAssumeWeak(maybe_target_map, &runtime_map_lookup));
557 GotoIf(IsDeprecatedMap(target_map), &runtime_map_lookup);
558 TNode<MaybeObject> maybe_validity_cell = LoadWeakFixedArrayElement(
559 CAST(side_step_transitions),
560 IntPtrConstant(SideStepTransition::index_of(
562 TNode<Cell> validity_cell = CAST(
563 GetHeapObjectAssumeWeak(maybe_validity_cell, &runtime_map_lookup));
564 GotoIfNot(TaggedEqual(LoadCellValue(validity_cell),
565 SmiConstant(Map::kPrototypeChainValid)),
566 &runtime_map_lookup);
567 clone_map = target_map;
568 }
569 Goto(&continue_fast_path);
570
571 BIND(&runtime_map_lookup);
572 TNode<HeapObject> maybe_clone_map =
573 CAST(CallRuntime(Runtime::kObjectAssignTryFastcase, context, from, to));
574 GotoIf(TaggedEqual(maybe_clone_map, UndefinedConstant()), &slow_path);
575 GotoIf(TaggedEqual(maybe_clone_map, TrueConstant()), &done_fast_path);
576 CSA_DCHECK(this, IsMap(maybe_clone_map));
577 clone_map = CAST(maybe_clone_map);
578 Goto(&continue_fast_path);
579
580 BIND(&continue_fast_path);
581 CSA_DCHECK(this,
582 IntPtrEqual(LoadMapInstanceSizeInWords(to_map),
583 LoadMapInstanceSizeInWords(clone_map.value())));
585 this,
586 IntPtrEqual(LoadMapInobjectPropertiesStartInWords(to_map),
587 LoadMapInobjectPropertiesStartInWords(clone_map.value())));
588 FastCloneJSObject(
589 from, from_map, clone_map.value(),
591 TNode<FixedArray> elements) {
592 StoreMap(to, clone_map.value());
593 StoreJSReceiverPropertiesOrHash(to, properties);
594 StoreJSObjectElements(CAST(to), elements);
595 return to;
596 },
597 false /* target_is_new */);
598
599 Goto(&done_fast_path);
600 BIND(&done_fast_path);
601
602 // If the fast path above succeeded we must skip assigning the first source
603 // object in the generic implementation below.
604 slow_path_index = IntPtrConstant(2);
605 Branch(IntPtrGreaterThan(args_length, IntPtrConstant(2)), &slow_path,
606 &done);
607 }
608 BIND(&slow_path);
609
610 // 3. Let sources be the List of argument values starting with the
611 // second argument.
612 // 4. For each element nextSource of sources, in ascending index order,
613 {
614 args.ForEach(
615 [=, this](TNode<Object> next_source) {
616 CallBuiltin(Builtin::kSetDataProperties, context, to, next_source);
617 },
618 slow_path_index.value());
619 Goto(&done);
620 }
621
622 // 5. Return to.
623 BIND(&done);
624 args.PopAndReturn(to);
625}
626
627// ES #sec-object.keys
629 auto object = Parameter<Object>(Descriptor::kObject);
630 auto context = Parameter<Context>(Descriptor::kContext);
631
632 TVARIABLE(Smi, var_length);
633 TVARIABLE(FixedArrayBase, var_elements);
634 Label if_empty(this, Label::kDeferred), if_empty_elements(this),
635 if_fast(this), if_slow(this, Label::kDeferred), if_join(this);
636
637 // Check if the {object} has a usable enum cache.
638 GotoIf(TaggedIsSmi(object), &if_slow);
639
640 TNode<Map> object_map = LoadMap(CAST(object));
641 TNode<Uint32T> object_bit_field3 = LoadMapBitField3(object_map);
642 TNode<UintPtrT> object_enum_length =
643 DecodeWordFromWord32<Map::Bits3::EnumLengthBits>(object_bit_field3);
644 GotoIf(
645 WordEqual(object_enum_length, IntPtrConstant(kInvalidEnumCacheSentinel)),
646 &if_slow);
647
648 // Ensure that the {object} doesn't have any elements.
649 CSA_DCHECK(this, IsJSObjectMap(object_map));
650 TNode<FixedArrayBase> object_elements = LoadElements(CAST(object));
651 GotoIf(IsEmptyFixedArray(object_elements), &if_empty_elements);
652 Branch(IsEmptySlowElementDictionary(object_elements), &if_empty_elements,
653 &if_slow);
654
655 // Check whether there are enumerable properties.
656 BIND(&if_empty_elements);
657 Branch(WordEqual(object_enum_length, IntPtrConstant(0)), &if_empty, &if_fast);
658
659 // TODO(solanes): These if_xxx here and below seem to be quite similar for
660 // ObjectKeys and for ObjectGetOwnPropertyNames. In particular, if_fast seem
661 // to be the exact same.
662 BIND(&if_fast);
663 {
664 // The {object} has a usable enum cache, use that.
665 TNode<DescriptorArray> object_descriptors = LoadMapDescriptors(object_map);
666 TNode<EnumCache> object_enum_cache = LoadObjectField<EnumCache>(
667 object_descriptors, DescriptorArray::kEnumCacheOffset);
668 auto object_enum_keys = LoadObjectField<FixedArrayBase>(
669 object_enum_cache, EnumCache::kKeysOffset);
670
671 // Allocate a JSArray and copy the elements from the {object_enum_keys}.
672 TNode<JSArray> array;
673 TNode<FixedArrayBase> elements;
674 TNode<NativeContext> native_context = LoadNativeContext(context);
675 TNode<Map> array_map =
676 LoadJSArrayElementsMap(PACKED_ELEMENTS, native_context);
677 TNode<IntPtrT> object_enum_length_intptr = Signed(object_enum_length);
678 TNode<Smi> array_length = SmiTag(object_enum_length_intptr);
679 std::tie(array, elements) = AllocateUninitializedJSArrayWithElements(
680 PACKED_ELEMENTS, array_map, array_length, std::nullopt,
681 object_enum_length_intptr);
682 CopyFixedArrayElements(PACKED_ELEMENTS, object_enum_keys, elements,
683 object_enum_length_intptr, SKIP_WRITE_BARRIER);
684 Return(array);
685 }
686
687 BIND(&if_empty);
688 {
689 // The {object} doesn't have any enumerable keys.
690 var_length = SmiConstant(0);
691 var_elements = EmptyFixedArrayConstant();
692 Goto(&if_join);
693 }
694
695 BIND(&if_slow);
696 {
697 // Let the runtime compute the elements.
698 TNode<FixedArray> elements =
699 CAST(CallRuntime(Runtime::kObjectKeys, context, object));
700 var_length = LoadObjectField<Smi>(elements, offsetof(FixedArray, length_));
701 var_elements = elements;
702 Goto(&if_join);
703 }
704
705 BIND(&if_join);
706 {
707 // Wrap the elements into a proper JSArray and return that.
708 TNode<NativeContext> native_context = LoadNativeContext(context);
709 TNode<Map> array_map =
710 LoadJSArrayElementsMap(PACKED_ELEMENTS, native_context);
711 TNode<JSArray> array =
712 AllocateJSArray(array_map, var_elements.value(), var_length.value());
713 Return(array);
714 }
715}
716
717// https://github.com/tc39/proposal-accessible-object-hasownproperty
719 // Object.prototype.hasOwnProperty()
720 // 1. Let obj be ? ToObject(O).
721 // 2. Let key be ? ToPropertyKey(P).
722 // 3. Return ? HasOwnProperty(obj, key).
723 //
724 // ObjectPrototypeHasOwnProperty has similar semantics with steps 1 and 2
725 // swapped. We check if ToObject can fail and delegate the rest of the
726 // execution to ObjectPrototypeHasOwnProperty.
727
728 auto target = Parameter<Object>(Descriptor::kJSTarget);
729 auto new_target = Parameter<Object>(Descriptor::kJSNewTarget);
730 auto object = Parameter<Object>(Descriptor::kObject);
731 auto key = Parameter<Object>(Descriptor::kKey);
732 auto context = Parameter<Context>(Descriptor::kContext);
733
734 // ToObject can only fail when object is undefined or null.
735 Label undefined_or_null(this), not_undefined_nor_null(this);
736 Branch(IsNullOrUndefined(object), &undefined_or_null,
737 &not_undefined_nor_null);
738
739 BIND(&undefined_or_null);
740 ThrowTypeError(context, MessageTemplate::kUndefinedOrNullToObject);
741
742 BIND(&not_undefined_nor_null);
743 Return(CallJSBuiltin(Builtin::kObjectPrototypeHasOwnProperty, context, target,
744 new_target, object, key));
745}
746
747// ES #sec-object.getOwnPropertyNames
748TF_BUILTIN(ObjectGetOwnPropertyNames, ObjectBuiltinsAssembler) {
749 auto object = Parameter<Object>(Descriptor::kObject);
750 auto context = Parameter<Context>(Descriptor::kContext);
751
752 TVARIABLE(Smi, var_length);
753 TVARIABLE(FixedArrayBase, var_elements);
754 Label if_empty(this, Label::kDeferred), if_empty_elements(this),
755 if_fast(this), try_fast(this, Label::kDeferred),
756 if_slow(this, Label::kDeferred), if_join(this);
757
758 // Take the slow path if the {object} IsCustomElementsReceiverInstanceType or
759 // has any elements.
760 GotoIf(TaggedIsSmi(object), &if_slow);
761
762 TNode<Map> object_map = LoadMap(CAST(object));
763 TNode<Uint16T> instance_type = LoadMapInstanceType(object_map);
764 GotoIf(IsCustomElementsReceiverInstanceType(instance_type), &if_slow);
765 TNode<FixedArrayBase> object_elements = LoadElements(CAST(object));
766 GotoIf(IsEmptyFixedArray(object_elements), &if_empty_elements);
767 Branch(IsEmptySlowElementDictionary(object_elements), &if_empty_elements,
768 &if_slow);
769
770 // Check if the {object} has a usable enum cache.
771 BIND(&if_empty_elements);
772 TNode<Uint32T> object_bit_field3 = LoadMapBitField3(object_map);
773 TNode<UintPtrT> object_enum_length =
774 DecodeWordFromWord32<Map::Bits3::EnumLengthBits>(object_bit_field3);
775 GotoIf(
776 WordEqual(object_enum_length, IntPtrConstant(kInvalidEnumCacheSentinel)),
777 &try_fast);
778
779 // Check whether all own properties are enumerable.
780 TNode<UintPtrT> number_descriptors =
781 DecodeWordFromWord32<Map::Bits3::NumberOfOwnDescriptorsBits>(
782 object_bit_field3);
783 GotoIfNot(WordEqual(object_enum_length, number_descriptors), &if_slow);
784
785 // Check whether there are enumerable properties.
786 Branch(WordEqual(object_enum_length, IntPtrConstant(0)), &if_empty, &if_fast);
787
788 // TODO(solanes): These if_xxx here and below seem to be quite similar for
789 // ObjectKeys and for ObjectGetOwnPropertyNames. In particular, if_fast seem
790 // to be the exact same.
791 BIND(&if_fast);
792 {
793 // The {object} has a usable enum cache and all own properties are
794 // enumerable, use that.
795 TNode<DescriptorArray> object_descriptors = LoadMapDescriptors(object_map);
796 TNode<EnumCache> object_enum_cache = LoadObjectField<EnumCache>(
797 object_descriptors, DescriptorArray::kEnumCacheOffset);
798 auto object_enum_keys = LoadObjectField<FixedArrayBase>(
799 object_enum_cache, EnumCache::kKeysOffset);
800
801 // Allocate a JSArray and copy the elements from the {object_enum_keys}.
802 TNode<JSArray> array;
803 TNode<FixedArrayBase> elements;
804 TNode<NativeContext> native_context = LoadNativeContext(context);
805 TNode<Map> array_map =
806 LoadJSArrayElementsMap(PACKED_ELEMENTS, native_context);
807 TNode<IntPtrT> object_enum_length_intptr = Signed(object_enum_length);
808 TNode<Smi> array_length = SmiTag(object_enum_length_intptr);
809 std::tie(array, elements) = AllocateUninitializedJSArrayWithElements(
810 PACKED_ELEMENTS, array_map, array_length, std::nullopt,
811 object_enum_length_intptr);
812 CopyFixedArrayElements(PACKED_ELEMENTS, object_enum_keys, elements,
813 object_enum_length_intptr, SKIP_WRITE_BARRIER);
814 Return(array);
815 }
816
817 BIND(&try_fast);
818 {
819 // Let the runtime compute the elements and try initializing enum cache.
821 Runtime::kObjectGetOwnPropertyNamesTryFast, context, object));
822 var_length = LoadObjectField<Smi>(elements, offsetof(FixedArray, length_));
823 var_elements = elements;
824 Goto(&if_join);
825 }
826
827 BIND(&if_empty);
828 {
829 // The {object} doesn't have any enumerable keys.
830 var_length = SmiConstant(0);
831 var_elements = EmptyFixedArrayConstant();
832 Goto(&if_join);
833 }
834
835 BIND(&if_slow);
836 {
837 // Let the runtime compute the elements.
838 TNode<FixedArray> elements =
839 CAST(CallRuntime(Runtime::kObjectGetOwnPropertyNames, context, object));
840 var_length = LoadObjectField<Smi>(elements, offsetof(FixedArray, length_));
841 var_elements = elements;
842 Goto(&if_join);
843 }
844
845 BIND(&if_join);
846 {
847 // Wrap the elements into a proper JSArray and return that.
848 TNode<NativeContext> native_context = LoadNativeContext(context);
849 TNode<Map> array_map =
850 LoadJSArrayElementsMap(PACKED_ELEMENTS, native_context);
851 TNode<JSArray> array =
852 AllocateJSArray(array_map, var_elements.value(), var_length.value());
853 Return(array);
854 }
855}
856
858 auto object = UncheckedParameter<JSObject>(Descriptor::kObject);
859 auto context = UncheckedParameter<Context>(Descriptor::kContext);
860 GetOwnValuesOrEntries(context, object, CollectType::kValues);
861}
862
864 auto object = UncheckedParameter<JSObject>(Descriptor::kObject);
865 auto context = UncheckedParameter<Context>(Descriptor::kContext);
866 GetOwnValuesOrEntries(context, object, CollectType::kEntries);
867}
868
869// ES #sec-object.prototype.isprototypeof
870TF_BUILTIN(ObjectPrototypeIsPrototypeOf, ObjectBuiltinsAssembler) {
871 auto receiver = Parameter<Object>(Descriptor::kReceiver);
872 auto value = Parameter<Object>(Descriptor::kValue);
873 auto context = Parameter<Context>(Descriptor::kContext);
874 Label if_receiverisnullorundefined(this, Label::kDeferred),
875 if_valueisnotreceiver(this, Label::kDeferred);
876
877 // We only check whether {value} is a Smi here, so that the
878 // prototype chain walk below can safely access the {value}s
879 // map. We don't rule out Primitive {value}s, since all of
880 // them have null as their prototype, so the chain walk below
881 // immediately aborts and returns false anyways.
882 GotoIf(TaggedIsSmi(value), &if_valueisnotreceiver);
883
884 {
885 TNode<HeapObject> value_heap_object = CAST(value);
886
887 // Check if {receiver} is either null or undefined and in that case,
888 // invoke the ToObject builtin, which raises the appropriate error.
889 // Otherwise we don't need to invoke ToObject, since {receiver} is
890 // either already a JSReceiver, in which case ToObject is a no-op,
891 // or it's a Primitive and ToObject would allocate a fresh
892 // JSPrimitiveWrapper wrapper, which wouldn't be identical to any existing
893 // JSReceiver found in the prototype chain of {value}, hence it will return
894 // false no matter if we search for the Primitive {receiver} or
895 // a newly allocated JSPrimitiveWrapper wrapper for {receiver}.
896 GotoIf(IsNull(receiver), &if_receiverisnullorundefined);
897 GotoIf(IsUndefined(receiver), &if_receiverisnullorundefined);
898
899 // Loop through the prototype chain looking for the {receiver}.
900 Return(HasInPrototypeChain(context, value_heap_object, receiver));
901
902 BIND(&if_receiverisnullorundefined);
903 {
904 // If {value} is a primitive HeapObject, we need to return
905 // false instead of throwing an exception per order of the
906 // steps in the specification, so check that first here.
907 GotoIfNot(JSAnyIsNotPrimitive(value_heap_object), &if_valueisnotreceiver);
908
909 // Simulate the ToObject invocation on {receiver}.
910 ToObject(context, receiver);
911 Unreachable();
912 }
913 }
914
915 BIND(&if_valueisnotreceiver);
916 Return(FalseConstant());
917}
918
920 TVARIABLE(String, var_default);
921 TVARIABLE(JSAnyNotSmi, var_holder);
922 TVARIABLE(Map, var_holder_map);
923
924 Label checkstringtag(this), if_arguments(this), if_array(this),
925 if_boolean(this), if_date(this), if_error(this), if_function(this),
926 if_number(this, Label::kDeferred), if_object(this), if_primitive(this),
927 if_proxy(this, {&var_holder, &var_holder_map}, Label::kDeferred),
928 if_regexp(this), if_string(this), if_symbol(this, Label::kDeferred),
929 if_value(this), if_bigint(this, Label::kDeferred);
930
931 auto receiver = Parameter<JSAny>(Descriptor::kReceiver);
932 auto context = Parameter<Context>(Descriptor::kContext);
933
934 // This is arranged to check the likely cases first.
935 GotoIf(TaggedIsSmi(receiver), &if_number);
936
937 TNode<JSAnyNotSmi> receiver_heap_object = CAST(receiver);
938 TNode<Map> receiver_map = LoadMap(receiver_heap_object);
939 var_holder = receiver_heap_object;
940 var_holder_map = receiver_map;
941 TNode<Uint16T> receiver_instance_type = LoadMapInstanceType(receiver_map);
942 GotoIf(IsPrimitiveInstanceType(receiver_instance_type), &if_primitive);
943 GotoIf(IsFunctionInstanceType(receiver_instance_type), &if_function);
944 const struct {
946 Label* label;
947 } kJumpTable[] = {{JS_OBJECT_TYPE, &if_object},
948 {JS_ARRAY_TYPE, &if_array},
949 {JS_REG_EXP_TYPE, &if_regexp},
950 {JS_ARGUMENTS_OBJECT_TYPE, &if_arguments},
951 {JS_DATE_TYPE, &if_date},
952 {JS_API_OBJECT_TYPE, &if_object},
953 {JS_SPECIAL_API_OBJECT_TYPE, &if_object},
954 {JS_PROXY_TYPE, &if_proxy},
955 {JS_ERROR_TYPE, &if_error},
956 {JS_PRIMITIVE_WRAPPER_TYPE, &if_value}};
957 size_t const kNumCases = arraysize(kJumpTable);
958 Label* case_labels[kNumCases];
959 int32_t case_values[kNumCases];
960 for (size_t i = 0; i < kNumCases; ++i) {
961 case_labels[i] = kJumpTable[i].label;
962 case_values[i] = kJumpTable[i].value;
963 }
964 Switch(receiver_instance_type, &if_object, case_values, case_labels,
965 arraysize(case_values));
966
967 BIND(&if_arguments);
968 {
969 var_default = ArgumentsToStringConstant();
970 Goto(&checkstringtag);
971 }
972
973 BIND(&if_array);
974 {
975 var_default = ArrayToStringConstant();
976 Goto(&checkstringtag);
977 }
978
979 BIND(&if_boolean);
980 {
981 TNode<NativeContext> native_context = LoadNativeContext(context);
982 TNode<JSFunction> boolean_constructor = CAST(
983 LoadContextElement(native_context, Context::BOOLEAN_FUNCTION_INDEX));
984 TNode<Map> boolean_initial_map = LoadObjectField<Map>(
985 boolean_constructor, JSFunction::kPrototypeOrInitialMapOffset);
986 TNode<JSPrototype> boolean_prototype =
987 LoadMapPrototype(boolean_initial_map);
988 var_default = BooleanToStringConstant();
989 var_holder = boolean_prototype;
990 var_holder_map = LoadMap(boolean_prototype);
991 Goto(&checkstringtag);
992 }
993
994 BIND(&if_date);
995 {
996 var_default = DateToStringConstant();
997 Goto(&checkstringtag);
998 }
999
1000 BIND(&if_error);
1001 {
1002 var_default = ErrorToStringConstant();
1003 Goto(&checkstringtag);
1004 }
1005
1006 BIND(&if_function);
1007 {
1008 var_default = FunctionToStringConstant();
1009 Goto(&checkstringtag);
1010 }
1011
1012 BIND(&if_number);
1013 {
1014 TNode<NativeContext> native_context = LoadNativeContext(context);
1015 TNode<JSFunction> number_constructor = CAST(
1016 LoadContextElement(native_context, Context::NUMBER_FUNCTION_INDEX));
1017 TNode<Map> number_initial_map = LoadObjectField<Map>(
1018 number_constructor, JSFunction::kPrototypeOrInitialMapOffset);
1019 TNode<JSPrototype> number_prototype = LoadMapPrototype(number_initial_map);
1020 var_default = NumberToStringConstant();
1021 var_holder = number_prototype;
1022 var_holder_map = LoadMap(number_prototype);
1023 Goto(&checkstringtag);
1024 }
1025
1026 BIND(&if_object);
1027 {
1028 CSA_DCHECK(this, IsJSReceiver(CAST(receiver)));
1029 var_default = ObjectToStringConstant();
1030 Goto(&checkstringtag);
1031 }
1032
1033 BIND(&if_primitive);
1034 {
1035 Label return_undefined(this);
1036
1037 GotoIf(IsStringInstanceType(receiver_instance_type), &if_string);
1038 GotoIf(IsBigIntInstanceType(receiver_instance_type), &if_bigint);
1039 GotoIf(IsBooleanMap(receiver_map), &if_boolean);
1040 GotoIf(IsHeapNumberMap(receiver_map), &if_number);
1041 GotoIf(IsSymbolMap(receiver_map), &if_symbol);
1042 GotoIf(IsUndefined(receiver), &return_undefined);
1043 CSA_DCHECK(this, IsNull(receiver));
1044 Return(NullToStringConstant());
1045
1046 BIND(&return_undefined);
1047 Return(UndefinedToStringConstant());
1048 }
1049
1050 BIND(&if_regexp);
1051 {
1052 var_default = RegexpToStringConstant();
1053 Goto(&checkstringtag);
1054 }
1055
1056 BIND(&if_string);
1057 {
1058 TNode<NativeContext> native_context = LoadNativeContext(context);
1059 TNode<JSFunction> string_constructor = CAST(
1060 LoadContextElement(native_context, Context::STRING_FUNCTION_INDEX));
1061 TNode<Map> string_initial_map = LoadObjectField<Map>(
1062 string_constructor, JSFunction::kPrototypeOrInitialMapOffset);
1063 TNode<JSPrototype> string_prototype = LoadMapPrototype(string_initial_map);
1064 var_default = StringToStringConstant();
1065 var_holder = string_prototype;
1066 var_holder_map = LoadMap(string_prototype);
1067 Goto(&checkstringtag);
1068 }
1069
1070 BIND(&if_symbol);
1071 {
1072 TNode<NativeContext> native_context = LoadNativeContext(context);
1073 TNode<JSFunction> symbol_constructor = CAST(
1074 LoadContextElement(native_context, Context::SYMBOL_FUNCTION_INDEX));
1075 TNode<Map> symbol_initial_map = LoadObjectField<Map>(
1076 symbol_constructor, JSFunction::kPrototypeOrInitialMapOffset);
1077 TNode<JSPrototype> symbol_prototype = LoadMapPrototype(symbol_initial_map);
1078 var_default = ObjectToStringConstant();
1079 var_holder = symbol_prototype;
1080 var_holder_map = LoadMap(symbol_prototype);
1081 Goto(&checkstringtag);
1082 }
1083
1084 BIND(&if_bigint);
1085 {
1086 TNode<NativeContext> native_context = LoadNativeContext(context);
1087 TNode<JSFunction> bigint_constructor = CAST(
1088 LoadContextElement(native_context, Context::BIGINT_FUNCTION_INDEX));
1089 TNode<Map> bigint_initial_map = LoadObjectField<Map>(
1090 bigint_constructor, JSFunction::kPrototypeOrInitialMapOffset);
1091 TNode<JSPrototype> bigint_prototype = LoadMapPrototype(bigint_initial_map);
1092 var_default = ObjectToStringConstant();
1093 var_holder = bigint_prototype;
1094 var_holder_map = LoadMap(bigint_prototype);
1095 Goto(&checkstringtag);
1096 }
1097
1098 BIND(&if_value);
1099 {
1100 Label if_value_is_number(this, Label::kDeferred),
1101 if_value_is_boolean(this, Label::kDeferred),
1102 if_value_is_symbol(this, Label::kDeferred),
1103 if_value_is_bigint(this, Label::kDeferred),
1104 if_value_is_string(this, Label::kDeferred);
1105
1106 TNode<Object> receiver_value =
1107 LoadJSPrimitiveWrapperValue(CAST(receiver_heap_object));
1108 // We need to start with the object to see if the value was a subclass
1109 // which might have interesting properties.
1110 GotoIf(TaggedIsSmi(receiver_value), &if_value_is_number);
1111 TNode<Map> receiver_value_map = LoadMap(CAST(receiver_value));
1112 GotoIf(IsHeapNumberMap(receiver_value_map), &if_value_is_number);
1113 GotoIf(IsBooleanMap(receiver_value_map), &if_value_is_boolean);
1114 GotoIf(IsSymbolMap(receiver_value_map), &if_value_is_symbol);
1115 TNode<Uint16T> receiver_value_instance_type =
1116 LoadMapInstanceType(receiver_value_map);
1117 GotoIf(IsBigIntInstanceType(receiver_value_instance_type),
1118 &if_value_is_bigint);
1119 CSA_DCHECK(this, IsStringInstanceType(receiver_value_instance_type));
1120 Goto(&if_value_is_string);
1121
1122 BIND(&if_value_is_number);
1123 {
1124 var_default = NumberToStringConstant();
1125 Goto(&checkstringtag);
1126 }
1127
1128 BIND(&if_value_is_boolean);
1129 {
1130 var_default = BooleanToStringConstant();
1131 Goto(&checkstringtag);
1132 }
1133
1134 BIND(&if_value_is_string);
1135 {
1136 var_default = StringToStringConstant();
1137 Goto(&checkstringtag);
1138 }
1139
1140 BIND(&if_value_is_bigint);
1141 {
1142 var_default = ObjectToStringConstant();
1143 Goto(&checkstringtag);
1144 }
1145
1146 BIND(&if_value_is_symbol);
1147 {
1148 var_default = ObjectToStringConstant();
1149 Goto(&checkstringtag);
1150 }
1151 }
1152
1153 BIND(&checkstringtag);
1154 {
1155 Label return_default(this);
1156 TNode<Object> tag =
1157 GetInterestingProperty(context, receiver, &var_holder, &var_holder_map,
1158 ToStringTagSymbolConstant(), &return_default);
1159 GotoIf(TaggedIsSmi(tag), &return_default);
1160 GotoIfNot(IsString(CAST(tag)), &return_default);
1161 ReturnToStringFormat(context, CAST(tag));
1162
1163 BIND(&return_default);
1164 Return(var_default.value());
1165 }
1166
1167 BIND(&if_proxy);
1168 {
1169 receiver_heap_object = var_holder.value();
1170 receiver_map = var_holder_map.value();
1171 // Check if the proxy has been revoked.
1172 Label throw_proxy_handler_revoked(this, Label::kDeferred);
1173 TNode<HeapObject> handler =
1174 CAST(LoadObjectField(receiver_heap_object, JSProxy::kHandlerOffset));
1175 CSA_DCHECK(this, IsNullOrJSReceiver(handler));
1176 GotoIfNot(JSAnyIsNotPrimitive(handler), &throw_proxy_handler_revoked);
1177
1178 // If {receiver_heap_object} is a proxy for a JSArray, we default to
1179 // "[object Array]", otherwise we default to "[object Object]" or "[object
1180 // Function]" here, depending on whether the {receiver_heap_object} is
1181 // callable. The order matters here, i.e. we need to execute the
1182 // %ArrayIsArray check before the [[Get]] below, as the exception is
1183 // observable.
1184 TNode<Object> receiver_is_array =
1185 CallRuntime(Runtime::kArrayIsArray, context, receiver_heap_object);
1186 TNode<String> builtin_tag = Select<String>(
1187 IsTrue(receiver_is_array), [=, this] { return ArrayStringConstant(); },
1188 [=, this] {
1189 return Select<String>(
1190 IsCallableMap(receiver_map),
1191 [=, this] { return FunctionStringConstant(); },
1192 [=, this] { return ObjectStringConstant(); });
1193 });
1194
1195 // Lookup the @@toStringTag property on the {receiver_heap_object}.
1196 TVARIABLE(Object, var_tag,
1197 GetProperty(context, receiver_heap_object,
1198 isolate()->factory()->to_string_tag_symbol()));
1199 Label if_tagisnotstring(this), if_tagisstring(this);
1200 GotoIf(TaggedIsSmi(var_tag.value()), &if_tagisnotstring);
1201 Branch(IsString(CAST(var_tag.value())), &if_tagisstring,
1202 &if_tagisnotstring);
1203 BIND(&if_tagisnotstring);
1204 {
1205 var_tag = builtin_tag;
1206 Goto(&if_tagisstring);
1207 }
1208 BIND(&if_tagisstring);
1209 ReturnToStringFormat(context, CAST(var_tag.value()));
1210
1211 BIND(&throw_proxy_handler_revoked);
1212 {
1213 ThrowTypeError(context, MessageTemplate::kProxyRevoked,
1214 "Object.prototype.toString");
1215 }
1216 }
1217}
1218
1219// ES #sec-object.create
1221 int const kPrototypeArg = 0;
1222 int const kPropertiesArg = 1;
1223
1224 TNode<IntPtrT> argc = ChangeInt32ToIntPtr(
1225 UncheckedParameter<Int32T>(Descriptor::kJSActualArgumentsCount));
1226 CodeStubArguments args(this, argc);
1227
1228 TNode<Object> prototype = args.GetOptionalArgumentValue(kPrototypeArg);
1229 TNode<Object> properties = args.GetOptionalArgumentValue(kPropertiesArg);
1230 auto native_context = Parameter<NativeContext>(Descriptor::kContext);
1231
1232 Label call_runtime(this, Label::kDeferred), prototype_valid(this),
1233 no_properties(this);
1234
1235 {
1236 Comment("Argument 1 check: prototype");
1237 GotoIf(IsNull(prototype), &prototype_valid);
1238 BranchIfJSReceiver(prototype, &prototype_valid, &call_runtime);
1239 }
1240
1241 BIND(&prototype_valid);
1242 {
1243 Comment("Argument 2 check: properties");
1244 // Check that we have a simple object
1245 GotoIf(TaggedIsSmi(properties), &call_runtime);
1246 // Undefined implies no properties.
1247 GotoIf(IsUndefined(properties), &no_properties);
1248 TNode<Map> properties_map = LoadMap(CAST(properties));
1249 GotoIf(IsSpecialReceiverMap(properties_map), &call_runtime);
1250 // Stay on the fast path only if there are no elements.
1251 GotoIfNot(
1252 TaggedEqual(LoadElements(CAST(properties)), EmptyFixedArrayConstant()),
1253 &call_runtime);
1254 // Handle dictionary objects or fast objects with properties in runtime.
1255 TNode<Uint32T> bit_field3 = LoadMapBitField3(properties_map);
1256 GotoIf(IsSetWord32<Map::Bits3::IsDictionaryMapBit>(bit_field3),
1257 &call_runtime);
1258 Branch(IsSetWord32<Map::Bits3::NumberOfOwnDescriptorsBits>(bit_field3),
1259 &call_runtime, &no_properties);
1260 }
1261
1262 // Create a new object with the given prototype.
1263 BIND(&no_properties);
1264 {
1265 TVARIABLE(Map, map);
1266 TVARIABLE(HeapObject, new_properties);
1267 Label null_proto(this), non_null_proto(this), instantiate_map(this);
1268
1269 Branch(IsNull(prototype), &null_proto, &non_null_proto);
1270
1271 BIND(&null_proto);
1272 {
1273 map = LoadSlowObjectWithNullPrototypeMap(native_context);
1274 new_properties =
1275 AllocatePropertyDictionary(PropertyDictionary::kInitialCapacity);
1276 Goto(&instantiate_map);
1277 }
1278
1279 BIND(&non_null_proto);
1280 {
1281 new_properties = EmptyFixedArrayConstant();
1282 map = LoadObjectFunctionInitialMap(native_context);
1283 GotoIf(TaggedEqual(prototype, LoadMapPrototype(map.value())),
1284 &instantiate_map);
1285 // Try loading the prototype info.
1286 TNode<PrototypeInfo> prototype_info =
1287 LoadMapPrototypeInfo(LoadMap(CAST(prototype)), &call_runtime);
1288 Comment("Load ObjectCreateMap from PrototypeInfo");
1289 TNode<HeapObject> derived_maps = CAST(
1290 LoadObjectField(prototype_info, PrototypeInfo::kDerivedMapsOffset));
1291 // In case it exists, derived maps is a weak array list where the first
1292 // element is the object create map.
1293 GotoIf(TaggedEqual(derived_maps, UndefinedConstant()), &call_runtime);
1294 CSA_DCHECK(this, InstanceTypeEqual(LoadInstanceType(derived_maps),
1295 WEAK_ARRAY_LIST_TYPE));
1296 TNode<MaybeObject> maybe_map = UncheckedCast<MaybeObject>(LoadObjectField(
1297 derived_maps, IntPtrConstant(WeakArrayList::kHeaderSize)));
1298 map = CAST(GetHeapObjectAssumeWeak(maybe_map, &call_runtime));
1299 Goto(&instantiate_map);
1300 }
1301
1302 BIND(&instantiate_map);
1303 {
1304 TNode<JSObject> instance =
1305 AllocateJSObjectFromMap(map.value(), new_properties.value());
1306 args.PopAndReturn(instance);
1307 }
1308 }
1309
1310 BIND(&call_runtime);
1311 {
1313 Runtime::kObjectCreate, native_context, prototype, properties);
1314 args.PopAndReturn(result);
1315 }
1316}
1317
1318// ES #sec-object.is
1320 const auto left = Parameter<Object>(Descriptor::kLeft);
1321 const auto right = Parameter<Object>(Descriptor::kRight);
1322
1323 Label return_true(this), return_false(this);
1324 BranchIfSameValue(left, right, &return_true, &return_false);
1325
1326 BIND(&return_true);
1327 Return(TrueConstant());
1328
1329 BIND(&return_false);
1330 Return(FalseConstant());
1331}
1332
1333TF_BUILTIN(CreateIterResultObject, ObjectBuiltinsAssembler) {
1334 const auto value = Parameter<Object>(Descriptor::kValue);
1335 const auto done = Parameter<Boolean>(Descriptor::kDone);
1336 const auto context = Parameter<Context>(Descriptor::kContext);
1337
1338 const TNode<NativeContext> native_context = LoadNativeContext(context);
1339 const TNode<Map> map = CAST(
1340 LoadContextElement(native_context, Context::ITERATOR_RESULT_MAP_INDEX));
1341
1342 const TNode<JSObject> result = AllocateJSObjectFromMap(map);
1343
1344 StoreObjectFieldNoWriteBarrier(result, JSIteratorResult::kValueOffset, value);
1345 StoreObjectFieldNoWriteBarrier(result, JSIteratorResult::kDoneOffset, done);
1346
1347 Return(result);
1348}
1349
1351 auto key = Parameter<Object>(Descriptor::kKey);
1352 auto object = Parameter<JSAny>(Descriptor::kObject);
1353 auto context = Parameter<Context>(Descriptor::kContext);
1354
1355 Return(HasProperty(context, object, key, kHasProperty));
1356}
1357
1359 auto object = Parameter<Object>(Descriptor::kLeft);
1360 auto callable = Parameter<JSAny>(Descriptor::kRight);
1361 auto context = Parameter<Context>(Descriptor::kContext);
1362
1363 Return(InstanceOf(object, callable, context));
1364}
1365
1366TF_BUILTIN(InstanceOf_WithFeedback, ObjectBuiltinsAssembler) {
1367 auto object = Parameter<Object>(Descriptor::kLeft);
1368 auto callable = Parameter<JSAny>(Descriptor::kRight);
1369 auto context = Parameter<Context>(Descriptor::kContext);
1370 auto feedback_vector =
1371 Parameter<Union<FeedbackVector, Undefined>>(Descriptor::kFeedbackVector);
1372 auto slot = UncheckedParameter<UintPtrT>(Descriptor::kSlot);
1373
1374 CollectInstanceOfFeedback(callable, context, feedback_vector, slot);
1375 Return(InstanceOf(object, callable, context));
1376}
1377
1379 auto object = Parameter<Object>(Descriptor::kLeft);
1380 auto callable = Parameter<JSAny>(Descriptor::kRight);
1381 auto context = LoadContextFromBaseline();
1382 auto feedback_vector = LoadFeedbackVectorFromBaseline();
1383 auto slot = UncheckedParameter<UintPtrT>(Descriptor::kSlot);
1384
1385 CollectInstanceOfFeedback(callable, context, feedback_vector, slot);
1386 Return(InstanceOf(object, callable, context));
1387}
1388
1389// ES6 section 7.3.19 OrdinaryHasInstance ( C, O )
1391 auto constructor = Parameter<Object>(Descriptor::kLeft);
1392 auto object = Parameter<Object>(Descriptor::kRight);
1393 auto context = Parameter<Context>(Descriptor::kContext);
1394
1395 Return(OrdinaryHasInstance(context, constructor, object));
1396}
1397
1398TF_BUILTIN(CreateGeneratorObject, ObjectBuiltinsAssembler) {
1399 auto closure = Parameter<JSFunction>(Descriptor::kClosure);
1400 auto receiver = Parameter<Object>(Descriptor::kReceiver);
1401 auto context = Parameter<Context>(Descriptor::kContext);
1402
1403 // Get the initial map from the function, jumping to the runtime if we don't
1404 // have one.
1405 Label done(this), runtime(this);
1406 GotoIfForceSlowPath(&runtime);
1407 GotoIfNot(IsFunctionWithPrototypeSlotMap(LoadMap(closure)), &runtime);
1408 TNode<HeapObject> maybe_map = LoadObjectField<HeapObject>(
1409 closure, JSFunction::kPrototypeOrInitialMapOffset);
1410 GotoIf(DoesntHaveInstanceType(maybe_map, MAP_TYPE), &runtime);
1411 TNode<Map> map = CAST(maybe_map);
1412
1413 TNode<SharedFunctionInfo> shared = LoadObjectField<SharedFunctionInfo>(
1414 closure, JSFunction::kSharedFunctionInfoOffset);
1415 // TODO(40931165): load bytecode array from function's dispatch table entry
1416 // when available instead of shared function info.
1417 TNode<BytecodeArray> bytecode_array =
1418 LoadSharedFunctionInfoBytecodeArray(shared);
1419
1420 TNode<IntPtrT> parameter_count = Signed(ChangeUint32ToWord(
1421 LoadBytecodeArrayParameterCountWithoutReceiver(bytecode_array)));
1422
1423 TNode<IntPtrT> frame_size = ChangeInt32ToIntPtr(
1424 LoadObjectField<Int32T>(bytecode_array, BytecodeArray::kFrameSizeOffset));
1425 TNode<IntPtrT> length =
1426 IntPtrAdd(WordSar(frame_size, IntPtrConstant(kSystemPointerSizeLog2)),
1428 TNode<FixedArrayBase> parameters_and_registers =
1429 AllocateFixedArray(HOLEY_ELEMENTS, length);
1430 FillFixedArrayWithValue(HOLEY_ELEMENTS, parameters_and_registers,
1431 IntPtrConstant(0), length,
1432 RootIndex::kUndefinedValue);
1433 // TODO(cbruni): support start_offset to avoid double initialization.
1435 AllocateJSObjectFromMap(map, std::nullopt, std::nullopt,
1436 AllocationFlag::kNone, kWithSlackTracking);
1437 StoreObjectFieldNoWriteBarrier(result, JSGeneratorObject::kFunctionOffset,
1438 closure);
1439 StoreObjectFieldNoWriteBarrier(result, JSGeneratorObject::kContextOffset,
1440 context);
1441 StoreObjectFieldNoWriteBarrier(result, JSGeneratorObject::kReceiverOffset,
1442 receiver);
1443 StoreObjectFieldNoWriteBarrier(
1444 result, JSGeneratorObject::kParametersAndRegistersOffset,
1445 parameters_and_registers);
1446 TNode<Smi> resume_mode = SmiConstant(JSGeneratorObject::ResumeMode::kNext);
1447 StoreObjectFieldNoWriteBarrier(result, JSGeneratorObject::kResumeModeOffset,
1448 resume_mode);
1449 TNode<Smi> executing = SmiConstant(JSGeneratorObject::kGeneratorExecuting);
1450 StoreObjectFieldNoWriteBarrier(result, JSGeneratorObject::kContinuationOffset,
1451 executing);
1452 GotoIfNot(InstanceTypeEqual(LoadMapInstanceType(map),
1453 JS_ASYNC_GENERATOR_OBJECT_TYPE),
1454 &done);
1455 StoreObjectFieldNoWriteBarrier(
1456 result, JSAsyncGeneratorObject::kIsAwaitingOffset, SmiConstant(0));
1457 Goto(&done);
1458
1459 BIND(&done);
1460 { Return(result); }
1461
1462 BIND(&runtime);
1463 {
1464 Return(CallRuntime(Runtime::kCreateJSGeneratorObject, context, closure,
1465 receiver));
1466 }
1467}
1468
1469TF_BUILTIN(OrdinaryGetOwnPropertyDescriptor, ObjectBuiltinsAssembler) {
1470 auto context = Parameter<Context>(Descriptor::kContext);
1471 auto object = Parameter<JSReceiver>(Descriptor::kReceiver);
1472 auto name = Parameter<Name>(Descriptor::kKey);
1473 CSA_DCHECK(this, Word32BinaryNot(IsSpecialReceiverInstanceType(
1474 LoadMapInstanceType(LoadMap(object)))));
1475
1476 Label if_notunique_name(this), if_iskeyunique(this), done(this),
1477 if_keyisindex(this), call_runtime(this);
1478
1479 TVARIABLE(IntPtrT, var_index, IntPtrConstant(0));
1480 TVARIABLE(Name, var_name, name);
1481 TVARIABLE(HeapObject, result, UndefinedConstant());
1482
1483 TryToName(name, &if_keyisindex, &var_index, &if_iskeyunique, &var_name,
1484 &call_runtime, &if_notunique_name);
1485
1486 BIND(&if_notunique_name);
1487 {
1488 Label not_in_string_table(this);
1489 // If the string was not found in the string table, then no regular
1490 // object can have a property with that name, so return |undefined|.
1491 TryInternalizeString(CAST(name), &if_keyisindex, &var_index,
1492 &if_iskeyunique, &var_name, &done, &call_runtime);
1493 }
1494
1495 BIND(&if_iskeyunique);
1496 {
1497 Label if_found_value(this), if_not_found(this);
1498
1499 TVARIABLE(Object, var_value);
1500 TVARIABLE(Uint32T, var_details);
1501 TVARIABLE(Object, var_raw_value);
1502 TNode<Map> map = LoadMap(object);
1503 TNode<Int32T> instance_type = LoadMapInstanceType(map);
1504
1505 TryGetOwnProperty(context, object, object, map, instance_type,
1506 var_name.value(), &if_found_value, &var_value,
1507 &var_details, &var_raw_value, &done, &call_runtime,
1508 kReturnAccessorPair);
1509
1510 BIND(&if_found_value);
1511
1512 // 4. Return FromPropertyDetails(desc).
1513 result = AllocatePropertyDescriptorObject(context);
1514 InitializePropertyDescriptorObject(CAST(result.value()), var_value.value(),
1515 var_details.value(), &call_runtime);
1516 Goto(&done);
1517 }
1518
1519 BIND(&done);
1520 Return(result.value());
1521
1522 BIND(&if_keyisindex);
1523 Goto(&call_runtime);
1524
1525 BIND(&call_runtime);
1526 TailCallRuntime(Runtime::kGetOwnPropertyDescriptorObject, context, object,
1527 var_name.value());
1528}
1529
1530// ES6 section 19.1.2.7 Object.getOwnPropertyDescriptor ( O, P )
1531TF_BUILTIN(ObjectGetOwnPropertyDescriptor, ObjectBuiltinsAssembler) {
1532 auto argc = UncheckedParameter<Int32T>(Descriptor::kJSActualArgumentsCount);
1533 auto context = Parameter<Context>(Descriptor::kContext);
1534 CSA_DCHECK(this, IsUndefined(Parameter<Object>(Descriptor::kJSNewTarget)));
1535
1536 CodeStubArguments args(this, argc);
1537 TNode<Object> object_input = args.GetOptionalArgumentValue(0);
1538 TNode<Object> key = args.GetOptionalArgumentValue(1);
1539
1540 // 1. Let obj be ? ToObject(O).
1541 TNode<JSReceiver> object = ToObject_Inline(context, object_input);
1542
1543 // 2. Let key be ? ToPropertyKey(P).
1544 key = CallBuiltin(Builtin::kToName, context, key);
1545
1546 // 3. Let desc be ? obj.[[GetOwnProperty]](key).
1547 TNode<Object> desc =
1548 CallBuiltin(Builtin::kGetOwnPropertyDescriptor, context, object, key);
1549
1550 // 4. Return FromPropertyDescriptor(desc).
1552 FromPropertyDescriptor(context, desc);
1553
1554 args.PopAndReturn(result);
1555}
1556
1557// TODO(v8:11167) remove remove |context| and |object| parameters once
1558// OrderedNameDictionary supported.
1561 TNode<HeapObject> name_dictionary, Handle<Name> name, TNode<Object> value,
1562 Label* bailout) {
1563 Label done(this);
1564 GotoIfNot(condition, &done);
1565
1567 HeapConstantNoHole(name), value, bailout);
1568 Goto(&done);
1569
1570 BIND(&done);
1571}
1572
1575 TVARIABLE(JSObject, js_descriptor);
1576
1578 desc, PropertyDescriptorObject::kFlagsOffset);
1579
1580 TNode<Int32T> has_flags =
1582
1583 Label if_accessor_desc(this), if_data_desc(this), if_generic_desc(this),
1584 return_desc(this);
1585 GotoIf(
1586 Word32Equal(has_flags,
1589 &if_accessor_desc);
1591 has_flags,
1593 &if_data_desc);
1594 Goto(&if_generic_desc);
1595
1596 BIND(&if_accessor_desc);
1597 {
1598 js_descriptor = ConstructAccessorDescriptor(
1599 context, LoadObjectField(desc, PropertyDescriptorObject::kGetOffset),
1600 LoadObjectField(desc, PropertyDescriptorObject::kSetOffset),
1603 Goto(&return_desc);
1604 }
1605
1606 BIND(&if_data_desc);
1607 {
1608 js_descriptor = ConstructDataDescriptor(
1609 context, LoadObjectField(desc, PropertyDescriptorObject::kValueOffset),
1613 Goto(&return_desc);
1614 }
1615
1616 BIND(&if_generic_desc);
1617 {
1619 TNode<Map> map = CAST(LoadContextElement(
1620 native_context, Context::SLOW_OBJECT_WITH_OBJECT_PROTOTYPE_MAP));
1621 // We want to preallocate the slots for value, writable, get, set,
1622 // enumerable and configurable - a total of 6
1624 TNode<JSObject> js_desc = AllocateJSObjectFromMap(map, properties);
1625
1626 Label bailout(this, Label::kDeferred);
1627
1629 TNode<Object> value =
1630 LoadObjectField(desc, PropertyDescriptorObject::kValueOffset);
1631 AddToDictionaryIf(IsNotTheHole(value), context, js_desc, properties,
1632 factory->value_string(), value, &bailout);
1635 js_desc, properties, factory->writable_string(),
1638 &bailout);
1639
1640 TNode<Object> get =
1641 LoadObjectField(desc, PropertyDescriptorObject::kGetOffset);
1642 AddToDictionaryIf(IsNotTheHole(get), context, js_desc, properties,
1643 factory->get_string(), get, &bailout);
1644 TNode<Object> set =
1645 LoadObjectField(desc, PropertyDescriptorObject::kSetOffset);
1646 AddToDictionaryIf(IsNotTheHole(set), context, js_desc, properties,
1647 factory->set_string(), set, &bailout);
1648
1651 js_desc, properties, factory->enumerable_string(),
1654 &bailout);
1657 context, js_desc, properties, factory->configurable_string(),
1660 &bailout);
1661
1662 js_descriptor = js_desc;
1663 Goto(&return_desc);
1664
1665 BIND(&bailout);
1666 CSA_DCHECK(this, Int32Constant(0));
1667 Unreachable();
1668 }
1669
1670 BIND(&return_desc);
1671 return js_descriptor.value();
1672}
1673
1676 TNode<Object> desc) {
1677 CSA_DCHECK(this, TaggedIsNotSmi(desc));
1678
1679 if (IsUndefinedConstant(desc)) return UndefinedConstant();
1680
1681 Label done(this);
1682 TVARIABLE((Union<Undefined, JSObject>), result, UndefinedConstant());
1683 GotoIf(IsUndefined(desc), &done);
1684
1685 TNode<PropertyDescriptorObject> property_descriptor = CAST(desc);
1686 result = FromPropertyDescriptor(context, property_descriptor);
1687 Goto(&done);
1688
1689 BIND(&done);
1690 return result.value();
1691}
1692
1694 TNode<Context> context, TNode<Object> raw_value, TNode<Word32T> details,
1695 Label* if_bailout) {
1696 TVARIABLE(JSObject, js_descriptor);
1697
1698 Label if_accessor_desc(this), if_data_desc(this), return_desc(this);
1699 BranchIfAccessorPair(raw_value, &if_accessor_desc, &if_data_desc);
1700
1701 BIND(&if_accessor_desc);
1702 {
1703 TNode<AccessorPair> accessor_pair_value = CAST(raw_value);
1705 CAST(LoadAccessorPairGetter(accessor_pair_value));
1707 CAST(LoadAccessorPairSetter(accessor_pair_value));
1708 js_descriptor = ConstructAccessorDescriptor(
1709 context, GetAccessorOrUndefined(getter, if_bailout),
1710 GetAccessorOrUndefined(setter, if_bailout),
1713 Goto(&return_desc);
1714 }
1715
1716 BIND(&if_data_desc);
1717 {
1718 js_descriptor = ConstructDataDescriptor(
1719 context, raw_value,
1723 Goto(&return_desc);
1724 }
1725
1726 BIND(&return_desc);
1727 return js_descriptor.value();
1728}
1729
1731 TNode<HeapObject> accessor, Label* if_bailout) {
1732 Label bind_undefined(this, Label::kDeferred), return_result(this);
1734
1735 GotoIf(IsNull(accessor), &bind_undefined);
1736 result = accessor;
1737 TNode<Map> map = LoadMap(accessor);
1738 // TODO(ishell): probe template instantiations cache.
1739 GotoIf(IsFunctionTemplateInfoMap(map), if_bailout);
1740 Goto(&return_result);
1741
1742 BIND(&bind_undefined);
1743 result = UndefinedConstant();
1744 Goto(&return_result);
1745
1746 BIND(&return_result);
1747 return result.value();
1748}
1749
1751
1752} // namespace internal
1753} // namespace v8
#define BIND(label)
#define TVARIABLE(...)
#define CSA_DCHECK(csa,...)
#define TF_BUILTIN(Name, AssemblerBase)
int16_t parameter_count
Definition builtins.cc:67
Builtins::Kind kind
Definition builtins.cc:40
PropertyT * getter
static constexpr Builtin StringAdd(StringAddFlags flags=STRING_ADD_CHECK_NONE)
void GotoIfMapHasSlowProperties(TNode< Map > map, Label *if_slow)
TNode< JSArray > AllocateJSArray(ElementsKind kind, TNode< Map > array_map, TNode< IntPtrT > capacity, TNode< Smi > length, std::optional< TNode< AllocationSite > > allocation_site, AllocationFlags allocation_flags=AllocationFlag::kNone)
TNode< Name > LoadKeyByDescriptorEntry(TNode< DescriptorArray > descriptors, TNode< IntPtrT > descriptor)
TNode< FixedArrayBase > AllocateFixedArray(ElementsKind kind, TNode< TIndex > capacity, AllocationFlags flags=AllocationFlag::kNone, std::optional< TNode< Map > > fixed_array_map=std::nullopt)
TNode< BoolT > IsJSObjectMap(TNode< Map > map)
TNode< Int32T > TruncateIntPtrToInt32(TNode< IntPtrT > value)
void StoreFixedArrayElement(TNode< FixedArray > object, int index, TNode< Object > value, WriteBarrierMode barrier_mode=UPDATE_WRITE_BARRIER, CheckBounds check_bounds=CheckBounds::kAlways)
TNode< DescriptorArray > LoadMapDescriptors(TNode< Map > map)
TNode< JSReceiver > ToObject_Inline(TNode< Context > context, TNode< Object > input)
TNode< Smi > SmiTag(TNode< IntPtrT > value)
void Increment(TVariable< TIndex > *variable, int value=1)
TNode< BoolT > TaggedEqual(TNode< AnyTaggedT > a, TNode< AnyTaggedT > b)
TNode< FixedArrayBase > LoadElements(TNode< JSObject > object)
TNode< T > LoadObjectField(TNode< HeapObject > object, int offset)
TNode< BoolT > IsNotSetWord32(TNode< Word32T > word32)
TNode< Uint32T > LoadMapBitField3(TNode< Map > map)
TNode< BoolT > TaggedIsNotSmi(TNode< MaybeObject > a)
TNode< IntPtrT > ToKeyIndex(TNode< Uint32T > entry_index)
std::pair< TNode< JSArray >, TNode< FixedArrayBase > > AllocateUninitializedJSArrayWithElements(ElementsKind kind, TNode< Map > array_map, TNode< Smi > length, std::optional< TNode< AllocationSite > > allocation_site, TNode< IntPtrT > capacity, AllocationFlags allocation_flags=AllocationFlag::kNone, int array_header_size=JSArray::kHeaderSize)
TNode< Uint32T > LoadDetailsByDescriptorEntry(TNode< DescriptorArray > descriptors, TNode< IntPtrT > descriptor)
TNode< BoolT > IsSetWord32(TNode< Word32T > word32)
TNode< Map > LoadJSArrayElementsMap(ElementsKind kind, TNode< NativeContext > native_context)
TNode< Uint32T > DecodeWord32(TNode< Word32T > word32)
TNode< Object > LoadAccessorPairGetter(TNode< AccessorPair > accessor_pair)
TNode< Int32T > LoadAndUntagToWord32ObjectField(TNode< HeapObject > object, int offset)
void StoreObjectFieldNoWriteBarrier(TNode< HeapObject > object, TNode< IntPtrT > offset, TNode< T > value)
TNode< BoolT > IsJSArrayMap(TNode< Map > map)
TNode< NativeContext > LoadNativeContext(TNode< Context > context)
void BranchIfAccessorPair(TNode< Object > value, Label *if_accessor_pair, Label *if_not_accessor_pair)
TNode< Map > LoadMap(TNode< HeapObject > object)
TNode< JSObject > AllocateJSObjectFromMap(TNode< Map > map, std::optional< TNode< HeapObject > > properties=std::nullopt, std::optional< TNode< FixedArray > > elements=std::nullopt, AllocationFlags flags=AllocationFlag::kNone, SlackTrackingMode slack_tracking_mode=kNoSlackTracking)
TNode< PropertyDictionary > AllocatePropertyDictionary(int at_least_space_for)
TNode< Object > LoadAccessorPairSetter(TNode< AccessorPair > accessor_pair)
void FillFixedArrayWithValue(ElementsKind kind, TNode< FixedArrayBase > array, TNode< TIndex > from_index, TNode< TIndex > to_index, RootIndex value_root_index)
TNode< UintPtrT > DecodeWordFromWord32(TNode< Word32T > word32)
TNode< Boolean > SelectBooleanConstant(TNode< BoolT > condition)
void LoadPropertyFromFastObject(TNode< HeapObject > object, TNode< Map > map, TNode< DescriptorArray > descriptors, TNode< IntPtrT > name_index, TVariable< Uint32T > *var_details, TVariable< Object > *var_value)
void AddToDictionary(TNode< Dictionary > dictionary, TNode< Name > key, TNode< Object > value, Label *bailout, std::optional< TNode< IntPtrT > > insertion_index=std::nullopt)
v8::internal::Factory * factory()
Definition isolate.h:1527
static const int kGeneratorExecuting
static constexpr int kPrototypeChainValid
Definition map.h:517
static const int kInitialCapacity
Definition dictionary.h:250
TNode< HeapObject > GetAccessorOrUndefined(TNode< HeapObject > accessor, Label *if_bailout)
TNode< JSObject > ConstructDataDescriptor(TNode< Context > context, TNode< Object > value, TNode< BoolT > writable, TNode< BoolT > enumerable, TNode< BoolT > configurable)
TNode< JSObject > FromPropertyDetails(TNode< Context > context, TNode< Object > raw_value, TNode< Word32T > details, Label *if_bailout)
TNode< Union< Undefined, JSObject > > FromPropertyDescriptor(TNode< Context >, TNode< Object > desc)
TNode< JSObject > ConstructAccessorDescriptor(TNode< Context > context, TNode< Object > getter, TNode< Object > setter, TNode< BoolT > enumerable, TNode< BoolT > configurable)
void AddToDictionaryIf(TNode< BoolT > condition, TNode< Context > context, TNode< Object > object, TNode< HeapObject > name_dictionary, Handle< Name > name, TNode< Object > value, Label *bailout)
void ReturnToStringFormat(TNode< Context > context, TNode< String > string)
TNode< JSArray > FastGetOwnValuesOrEntries(TNode< Context > context, TNode< JSObject > object, Label *if_call_runtime_with_fast_path, Label *if_no_properties, CollectType collect_type)
TNode< JSArray > FinalizeValuesOrEntriesJSArray(TNode< Context > context, TNode< FixedArray > values_or_entries, TNode< IntPtrT > size, TNode< Map > array_map, Label *if_empty)
TNode< BoolT > IsPropertyKindAccessor(TNode< Uint32T > kind)
TNode< BoolT > IsPropertyEnumerable(TNode< Uint32T > details)
TNode< Uint32T > LoadPropertyKind(TNode< Uint32T > details)
ObjectEntriesValuesBuiltinsAssembler(compiler::CodeAssemblerState *state)
void GetOwnValuesOrEntries(TNode< Context > context, TNode< Object > maybe_object, CollectType collect_type)
TNode< BoolT > IsPropertyKindData(TNode< Uint32T > kind)
static const int kAttributesDontEnumMask
static const int kAttributesReadOnlyMask
static const int kAttributesDontDeleteMask
static const int kSideStepTransitionsIndex
TNode< Int32T > Signed(TNode< Word32T > x)
bool IsUndefinedConstant(TNode< Object > node)
TNode< IntPtrT > IntPtrConstant(intptr_t value)
TNode< BoolT > WordEqual(TNode< WordT > left, TNode< WordT > right)
void GotoIfNot(TNode< IntegralT > condition, Label *false_label, GotoHint goto_hint=GotoHint::kNone)
void Return(TNode< Object > value)
TNode< Uint32T > Unsigned(TNode< Word32T > x)
TNode< Int32T > Word32And(TNode< Int32T > left, TNode< Int32T > right)
TNode< String > StringConstant(const char *str)
TNode< Smi > SmiConstant(Tagged< Smi > value)
void GotoIf(TNode< IntegralT > condition, Label *true_label, GotoHint goto_hint=GotoHint::kNone)
TNode< BoolT > IntPtrEqual(TNode< WordT > left, TNode< WordT > right)
TNode< Int32T > Int32Constant(int32_t value)
TNode< BoolT > WordNotEqual(TNode< WordT > left, TNode< WordT > right)
TNode< Type > HeapConstantNoHole(Handle< Type > object)
TNode< BoolT > Word32Equal(TNode< Word32T > left, TNode< Word32T > right)
TNode< T > CallRuntime(Runtime::FunctionId function, TNode< Object > context, TArgs... args)
TNode< T > CallBuiltin(Builtin id, TNode< Object > context, TArgs... args)
void Branch(TNode< IntegralT > condition, Label *true_label, Label *false_label, BranchHint branch_hint=BranchHint::kNone)
#define CAST(x)
base::Vector< const DirectHandle< Object > > args
Definition execution.cc:74
DirectHandle< Object > new_target
Definition execution.cc:75
Label label
Isolate * isolate
TNode< Object > receiver
ZoneVector< RpoNumber > & result
const int length_
Definition mul-fft.cc:473
@ STRING_ADD_CHECK_NONE
Definition type-hints.h:74
@ SKIP_WRITE_BARRIER
Definition objects.h:52
bool IsNumber(Tagged< Object > obj)
bool IsSpecialReceiverInstanceType(InstanceType instance_type)
bool IsSpecialReceiverMap(Tagged< Map > map)
constexpr int kSystemPointerSizeLog2
Definition globals.h:494
@ FIRST_ANY_NONEXTENSIBLE_ELEMENTS_KIND
@ LAST_ANY_NONEXTENSIBLE_ELEMENTS_KIND
bool IsCustomElementsReceiverInstanceType(InstanceType instance_type)
bool IsNullOrUndefined(Tagged< Object > obj, Isolate *isolate)
Handle< To > UncheckedCast(Handle< From > value)
Definition handles-inl.h:55
static const int kInvalidEnumCacheSentinel
DONT_OVERRIDE DISABLE_ALLOCATION_SITES HOLEY_ELEMENTS
bool IsBooleanMap(Tagged< Map > map)
Definition map-inl.h:745
Map::Bits1::HasPrototypeSlotBit Map::Bits1::HasNamedInterceptorBit Map::Bits1::IsUndetectableBit Map::Bits1::IsConstructorBit Map::Bits2::IsImmutablePrototypeBit Map::Bits3::IsDeprecatedBit Map::Bits3::IsPrototypeMapBit bit_field3
Definition map-inl.h:137
return value
Definition map-inl.h:893
MaybeDirectHandle< FixedArray > GetOwnValuesOrEntries(Isolate *isolate, DirectHandle< JSReceiver > object, PropertyFilter filter, bool try_fast_path, bool get_entries)
kInstanceDescriptorsOffset kTransitionsOrPrototypeInfoOffset IsNull(value)||IsJSProxy(value)||IsWasmObject(value)||(IsJSObject(value) &&(HeapLayout
Definition map-inl.h:70
!IsContextMap !IsContextMap native_context
Definition map-inl.h:877
#define DCHECK(condition)
Definition logging.h:482
#define arraysize(array)
Definition macros.h:67
static constexpr int index_of(Kind kind)
Definition transitions.h:44
static constexpr Tagged< Smi > Empty
Definition transitions.h:40
static constexpr Tagged< Smi > Unreachable
Definition transitions.h:41