v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
runtime-object.cc
Go to the documentation of this file.
1// Copyright 2014 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#include "src/base/macros.h"
14#include "src/heap/heap-inl.h" // For ToBoolean. TODO(jkummerow): Drop.
20#include "src/runtime/runtime.h"
21
22namespace v8 {
23namespace internal {
24
26 Isolate* isolate, DirectHandle<JSAny> lookup_start_object,
28 if (receiver.is_null()) {
29 receiver = lookup_start_object;
30 }
31 if (IsNullOrUndefined(*lookup_start_object, isolate)) {
32 ErrorUtils::ThrowLoadFromNullOrUndefined(isolate, lookup_start_object, key);
34 }
35
36 bool success = false;
37 PropertyKey lookup_key(isolate, key, &success);
38 if (!success) return MaybeDirectHandle<Object>();
40 LookupIterator(isolate, receiver, lookup_key, lookup_start_object);
41
43 if (result.is_null()) {
44 return result;
45 }
46 if (is_found) {
47 *is_found = it.state() != LookupIterator::TYPED_ARRAY_INDEX_NOT_FOUND &&
48 it.state() != LookupIterator::NOT_FOUND;
49 }
50
51 return result;
52}
53
57 // Check that {object} is actually a receiver.
58 if (!IsJSReceiver(*object)) {
60 isolate,
61 NewTypeError(MessageTemplate::kInvalidInOperatorUse, key, object));
62 }
64
65 // Convert the {key} to a name.
67 ASSIGN_RETURN_ON_EXCEPTION(isolate, name, Object::ToName(isolate, key));
68
69 // Lookup the {name} on {receiver}.
70 Maybe<bool> maybe = JSReceiver::HasProperty(isolate, receiver, name);
71 if (maybe.IsNothing()) return MaybeDirectHandle<Object>();
72 return isolate->factory()->ToBoolean(maybe.FromJust());
73}
74
78 LanguageMode language_mode) {
79 bool success = false;
80 PropertyKey lookup_key(isolate, key, &success);
81 if (!success) return Nothing<bool>();
82 LookupIterator it(isolate, receiver, lookup_key, LookupIterator::OWN);
83
84 return JSReceiver::DeleteProperty(&it, language_mode);
85}
86
87// ES #sec-object.keys
88RUNTIME_FUNCTION(Runtime_ObjectKeys) {
89 HandleScope scope(isolate);
90 DirectHandle<Object> object = args.at(0);
91
92 // Convert the {object} to a proper {receiver}.
95 Object::ToObject(isolate, object));
96
97 // Collect the own keys for the {receiver}.
100 isolate, keys,
104 return *keys;
105}
106
107// ES #sec-object.getOwnPropertyNames
108RUNTIME_FUNCTION(Runtime_ObjectGetOwnPropertyNames) {
109 HandleScope scope(isolate);
110 DirectHandle<Object> object = args.at(0);
111
112 // Convert the {object} to a proper {receiver}.
115 Object::ToObject(isolate, object));
116
117 // Collect the own keys for the {receiver}.
118 // TODO(v8:9401): We should extend the fast path of KeyAccumulator::GetKeys to
119 // also use fast path even when filter = SKIP_SYMBOLS.
122 isolate, keys,
126 return *keys;
127}
128
129RUNTIME_FUNCTION(Runtime_ObjectGetOwnPropertyNamesTryFast) {
130 HandleScope scope(isolate);
131 DirectHandle<Object> object = args.at(0);
132
133 // Convert the {object} to a proper {receiver}.
136 Object::ToObject(isolate, object));
137
138 DirectHandle<Map> map(receiver->map(), isolate);
139
140 int nod = map->NumberOfOwnDescriptors();
142 if (nod != 0 && map->NumberOfEnumerableProperties() == nod) {
144 isolate, keys,
148 } else {
150 isolate, keys,
154 }
155
156 return *keys;
157}
158
159// ES6 19.1.3.2
160RUNTIME_FUNCTION(Runtime_ObjectHasOwnProperty) {
161 HandleScope scope(isolate);
162 DirectHandle<Object> property = args.at(1);
163
164 // TODO(ishell): To improve performance, consider performing the to-string
165 // conversion of {property} before calling into the runtime.
166 bool success;
167 PropertyKey key(isolate, property, &success);
168 if (!success) return ReadOnlyRoots(isolate).exception();
169
170 DirectHandle<JSAny> object = args.at<JSAny>(0);
171
172 if (IsJSModuleNamespace(*object)) {
173 LookupIterator it(isolate, object, key, LookupIterator::OWN);
176 if (!result.IsJust()) return ReadOnlyRoots(isolate).exception();
177 return isolate->heap()->ToBoolean(result.FromJust());
178
179 } else if (IsJSObject(*object)) {
180 DirectHandle<JSObject> js_obj = Cast<JSObject>(object);
181 // Fast case: either the key is a real named property or it is not
182 // an array index and there are no interceptors or hidden
183 // prototypes.
184 // TODO(jkummerow): Make JSReceiver::HasOwnProperty fast enough to
185 // handle all cases directly (without this custom fast path).
186 {
188 LookupIterator it(isolate, js_obj, key, js_obj, c);
190 if (maybe.IsNothing()) return ReadOnlyRoots(isolate).exception();
191 DCHECK(!isolate->has_exception());
192 if (maybe.FromJust()) return ReadOnlyRoots(isolate).true_value();
193 }
194
195 Tagged<Map> map = js_obj->map();
196 if (!IsJSGlobalProxyMap(map) &&
197 (key.is_element() && key.index() <= JSObject::kMaxElementIndex
198 ? !map->has_indexed_interceptor()
199 : !map->has_named_interceptor())) {
200 return ReadOnlyRoots(isolate).false_value();
201 }
202
203 // Slow case.
204 LookupIterator it(isolate, js_obj, key, js_obj, LookupIterator::OWN);
206 if (maybe.IsNothing()) return ReadOnlyRoots(isolate).exception();
207 DCHECK(!isolate->has_exception());
208 return isolate->heap()->ToBoolean(maybe.FromJust());
209
210 } else if (IsJSProxy(*object)) {
211 LookupIterator it(isolate, object, key, Cast<JSProxy>(object),
213 Maybe<PropertyAttributes> attributes =
215 if (attributes.IsNothing()) return ReadOnlyRoots(isolate).exception();
216 return isolate->heap()->ToBoolean(attributes.FromJust() != ABSENT);
217
218 } else if (IsString(*object)) {
219 return isolate->heap()->ToBoolean(
220 key.is_element()
221 ? key.index() < static_cast<size_t>(Cast<String>(*object)->length())
222 : key.name()->Equals(ReadOnlyRoots(isolate).length_string()));
223 } else if (IsNullOrUndefined(*object, isolate)) {
225 isolate, NewTypeError(MessageTemplate::kUndefinedOrNullToObject));
226 }
227
228 return ReadOnlyRoots(isolate).false_value();
229}
230
231RUNTIME_FUNCTION(Runtime_HasOwnConstDataProperty) {
232 HandleScope scope(isolate);
233 DCHECK_EQ(2, args.length());
234 DirectHandle<Object> object = args.at(0);
235 DirectHandle<Object> property = args.at(1);
236
237 bool success;
238 PropertyKey key(isolate, property, &success);
239 if (!success) return ReadOnlyRoots(isolate).undefined_value();
240
241 if (IsJSObject(*object)) {
242 DirectHandle<JSObject> js_obj = Cast<JSObject>(object);
243 LookupIterator it(isolate, js_obj, key, js_obj, LookupIterator::OWN);
244
245 switch (it.state()) {
247 return isolate->heap()->ToBoolean(false);
249 return isolate->heap()->ToBoolean(it.constness() ==
251 default:
252 return ReadOnlyRoots(isolate).undefined_value();
253 }
254 }
255
256 return ReadOnlyRoots(isolate).undefined_value();
257}
258
259RUNTIME_FUNCTION(Runtime_IsDictPropertyConstTrackingEnabled) {
260 return isolate->heap()->ToBoolean(V8_DICT_PROPERTY_CONST_TRACKING_BOOL);
261}
262
263RUNTIME_FUNCTION(Runtime_AddDictionaryProperty) {
264 HandleScope scope(isolate);
266 DirectHandle<Name> name = args.at<Name>(1);
267 DirectHandle<Object> value = args.at(2);
268
269 DCHECK(IsUniqueName(*name));
270
271 PropertyDetails property_details(
276 receiver->property_dictionary_swiss(), isolate);
277 dictionary = SwissNameDictionary::Add(isolate, dictionary, name, value,
278 property_details);
279 // TODO(pthier): Add flags to swiss dictionaries and track interesting
280 // symbols.
281 receiver->SetProperties(*dictionary);
282 } else {
283 DirectHandle<NameDictionary> dictionary(receiver->property_dictionary(),
284 isolate);
285 dictionary =
286 NameDictionary::Add(isolate, dictionary, name, value, property_details);
287 if (name->IsInteresting(isolate)) {
288 dictionary->set_may_have_interesting_properties(true);
289 }
290 receiver->SetProperties(*dictionary);
291 }
292
293 return *value;
294}
295
296RUNTIME_FUNCTION(Runtime_AddPrivateBrand) {
297 HandleScope scope(isolate);
298 DCHECK_EQ(args.length(), 4);
300 DirectHandle<Symbol> brand = args.at<Symbol>(1);
301 DirectHandle<Context> context = args.at<Context>(2);
302 int depth = args.smi_value_at(3);
303 DCHECK(brand->is_private_name());
304
305 LookupIterator it(isolate, receiver, brand, LookupIterator::OWN);
306
307 if (it.IsFound()) {
309 isolate,
310 NewTypeError(MessageTemplate::kInvalidPrivateBrandReinitialization,
311 brand));
312 }
313
314 PropertyAttributes attributes =
316
317 // Look for the context in |depth| in the context chain to store it
318 // in the instance with the brand variable as key, which is needed by
319 // the debugger for retrieving names of private methods.
320 DCHECK_GE(depth, 0);
321 for (; depth > 0; depth--) {
322 context = direct_handle(
323 Cast<Context>(context->get(Context::PREVIOUS_INDEX)), isolate);
324 }
325 DCHECK_EQ(context->scope_info()->scope_type(), ScopeType::CLASS_SCOPE);
327 &it, context, attributes, Just(kThrowOnError), StoreOrigin::kMaybeKeyed);
328 // Objects in shared space are fixed shape, so private symbols cannot be
329 // added.
330 if (V8_UNLIKELY(IsAlwaysSharedSpaceJSObject(*receiver))) {
331 CHECK(added_brand.IsNothing());
332 return ReadOnlyRoots(isolate).exception();
333 }
334 CHECK(added_brand.IsJust());
335 return *receiver;
336}
337
338// ES6 section 19.1.2.2 Object.create ( O [ , Properties ] )
339// TODO(verwaest): Support the common cases with precached map directly in
340// an Object.create stub.
341RUNTIME_FUNCTION(Runtime_ObjectCreate) {
342 HandleScope scope(isolate);
343 DirectHandle<Object> maybe_prototype = args.at(0);
344 DirectHandle<Object> properties = args.at(1);
346 // 1. If Type(O) is neither Object nor Null, throw a TypeError exception.
348 if (!TryCast(maybe_prototype, &prototype)) {
350 isolate,
351 NewTypeError(MessageTemplate::kProtoObjectOrNull, maybe_prototype));
352 }
353
354 // 2. Let obj be ObjectCreate(O).
356 isolate, obj, JSObject::ObjectCreate(isolate, prototype));
357
358 // 3. If Properties is not undefined, then
359 if (!IsUndefined(*properties, isolate)) {
360 // a. Return ? ObjectDefineProperties(obj, Properties).
361 // Define the properties if properties was specified and is not undefined.
363 isolate, JSReceiver::DefineProperties(isolate, obj, properties));
364 }
365 // 4. Return obj.
366 return *obj;
367}
368
370 Isolate* isolate, DirectHandle<JSAny> lookup_start_obj,
372 MaybeDirectHandle<JSAny> maybe_receiver, StoreOrigin store_origin,
373 Maybe<ShouldThrow> should_throw) {
375 if (!maybe_receiver.ToHandle(&receiver)) {
376 receiver = lookup_start_obj;
377 }
378 if (IsNullOrUndefined(*lookup_start_obj, isolate)) {
379 MaybeDirectHandle<String> maybe_property =
381 DirectHandle<String> property_name;
382 if (maybe_property.ToHandle(&property_name)) {
384 isolate,
385 NewTypeError(MessageTemplate::kNonObjectPropertyStoreWithProperty,
386 lookup_start_obj, property_name));
387 } else {
388 THROW_NEW_ERROR(isolate,
389 NewTypeError(MessageTemplate::kNonObjectPropertyStore,
390 lookup_start_obj));
391 }
392 }
393
394 // Check if the given key is an array index.
395 bool success = false;
396 PropertyKey lookup_key(isolate, key, &success);
397 if (!success) return MaybeDirectHandle<Object>();
398 LookupIterator it(isolate, receiver, lookup_key, lookup_start_obj);
399 if (IsSymbol(*key) && Cast<Symbol>(*key)->is_private_name()) {
400 Maybe<bool> can_store = JSReceiver::CheckPrivateNameStore(&it, false);
401 MAYBE_RETURN_NULL(can_store);
402 if (!can_store.FromJust()) {
403 return isolate->factory()->undefined_value();
404 }
405 }
406
408 Object::SetProperty(&it, value, store_origin, should_throw));
409
410 return value;
411}
412
415 DirectHandle<Object> value, StoreOrigin store_origin,
416 Maybe<ShouldThrow> should_throw) {
417 return SetObjectProperty(isolate, object, key, value, object, store_origin,
418 should_throw);
419}
420
423 DirectHandle<Object> value, StoreOrigin store_origin) {
424 if (IsNullOrUndefined(*object, isolate)) {
425 MaybeDirectHandle<String> maybe_property =
427 DirectHandle<String> property_name;
428 if (maybe_property.ToHandle(&property_name)) {
430 isolate,
431 NewTypeError(MessageTemplate::kNonObjectPropertyStoreWithProperty,
432 object, property_name));
433 } else {
435 isolate,
436 NewTypeError(MessageTemplate::kNonObjectPropertyStore, object));
437 }
438 }
439 // Check if the given key is an array index.
440 bool success = false;
441 PropertyKey lookup_key(isolate, key, &success);
442 if (!success) return MaybeDirectHandle<Object>();
443
444 if (IsSymbol(*key) && Cast<Symbol>(*key)->is_private_name()) {
445 LookupIterator it(isolate, object, lookup_key, LookupIterator::OWN);
446 Maybe<bool> can_store = JSReceiver::CheckPrivateNameStore(&it, true);
447 MAYBE_RETURN_NULL(can_store);
448 // If the state is ACCESS_CHECK, the faliled access check callback
449 // is configured but it did't throw.
450 DCHECK_IMPLIES(it.IsFound(), it.state() == LookupIterator::ACCESS_CHECK &&
451 !can_store.FromJust());
452 if (!can_store.FromJust()) {
453 return isolate->factory()->undefined_value();
454 }
457 } else {
459 isolate, object, lookup_key, value, Nothing<ShouldThrow>()));
460 }
461
462 return value;
463}
464
465RUNTIME_FUNCTION(Runtime_InternalSetPrototype) {
466 HandleScope scope(isolate);
467 DCHECK_EQ(2, args.length());
469 DirectHandle<Object> prototype = args.at(1);
471 JSReceiver::SetPrototype(isolate, obj, prototype, false, kThrowOnError),
472 ReadOnlyRoots(isolate).exception());
473 return *obj;
474}
475
476RUNTIME_FUNCTION(Runtime_OptimizeObjectForAddingMultipleProperties) {
477 HandleScope scope(isolate);
478 DCHECK_EQ(2, args.length());
479 DirectHandle<JSObject> object = args.at<JSObject>(0);
480 int properties = args.smi_value_at(1);
481 // Conservative upper limit to prevent fuzz tests from going OOM.
482 if (properties > 100000) return isolate->ThrowIllegalOperation();
483 if (object->HasFastProperties() && !IsJSGlobalProxy(*object)) {
485 properties, "OptimizeForAdding");
486 }
487 return *object;
488}
489
490RUNTIME_FUNCTION(Runtime_ObjectValues) {
491 HandleScope scope(isolate);
492 DCHECK_EQ(1, args.length());
493
495
498 isolate, values,
501 return *isolate->factory()->NewJSArrayWithElements(values);
502}
503
504RUNTIME_FUNCTION(Runtime_ObjectValuesSkipFastPath) {
505 HandleScope scope(isolate);
506 DCHECK_EQ(1, args.length());
507
509
512 isolate, value,
515 return *isolate->factory()->NewJSArrayWithElements(value);
516}
517
518RUNTIME_FUNCTION(Runtime_ObjectEntries) {
519 HandleScope scope(isolate);
520 DCHECK_EQ(1, args.length());
521
523
526 isolate, entries,
529 return *isolate->factory()->NewJSArrayWithElements(entries);
530}
531
532RUNTIME_FUNCTION(Runtime_ObjectEntriesSkipFastPath) {
533 HandleScope scope(isolate);
534 DCHECK_EQ(1, args.length());
535
537
540 isolate, entries,
543 return *isolate->factory()->NewJSArrayWithElements(entries);
544}
545
546RUNTIME_FUNCTION(Runtime_ObjectIsExtensible) {
547 HandleScope scope(isolate);
548 DCHECK_EQ(1, args.length());
549 DirectHandle<Object> object = args.at(0);
550
552 IsJSReceiver(*object)
554 : Just(false);
555 MAYBE_RETURN(result, ReadOnlyRoots(isolate).exception());
556 return isolate->heap()->ToBoolean(result.FromJust());
557}
558
559RUNTIME_FUNCTION(Runtime_JSReceiverPreventExtensionsThrow) {
560 HandleScope scope(isolate);
561 DCHECK_EQ(1, args.length());
563
566 ReadOnlyRoots(isolate).exception());
567 return *object;
568}
569
570RUNTIME_FUNCTION(Runtime_JSReceiverPreventExtensionsDontThrow) {
571 HandleScope scope(isolate);
572 DCHECK_EQ(1, args.length());
574
576 isolate, Cast<JSReceiver>(object), kDontThrow);
577 MAYBE_RETURN(result, ReadOnlyRoots(isolate).exception());
578 return *isolate->factory()->ToBoolean(result.FromJust());
579}
580
581RUNTIME_FUNCTION(Runtime_JSReceiverGetPrototypeOf) {
582 HandleScope scope(isolate);
583 DCHECK_EQ(1, args.length());
585
588}
589
590RUNTIME_FUNCTION(Runtime_JSReceiverSetPrototypeOfThrow) {
591 HandleScope scope(isolate);
592
593 DCHECK_EQ(2, args.length());
595 DirectHandle<Object> proto = args.at(1);
596
598 JSReceiver::SetPrototype(isolate, object, proto, true, kThrowOnError),
599 ReadOnlyRoots(isolate).exception());
600
601 return *object;
602}
603
604RUNTIME_FUNCTION(Runtime_JSReceiverSetPrototypeOfDontThrow) {
605 HandleScope scope(isolate);
606
607 DCHECK_EQ(2, args.length());
609 DirectHandle<Object> proto = args.at(1);
610
612 JSReceiver::SetPrototype(isolate, object, proto, true, kDontThrow);
613 MAYBE_RETURN(result, ReadOnlyRoots(isolate).exception());
614 return *isolate->factory()->ToBoolean(result.FromJust());
615}
616
617RUNTIME_FUNCTION(Runtime_GetProperty) {
618 HandleScope scope(isolate);
619 DCHECK(args.length() == 3 || args.length() == 2);
620 DirectHandle<JSAny> lookup_start_obj = args.at<JSAny>(0);
621 DirectHandle<Object> key_obj = args.at(1);
622 DirectHandle<JSAny> receiver_obj = lookup_start_obj;
623 if (args.length() == 3) {
624 receiver_obj = args.at<JSAny>(2);
625 }
626
627 // Fast cases for getting named properties of the lookup_start_obj JSObject
628 // itself.
629 //
630 // The global proxy objects has to be excluded since LookupOwn on
631 // the global proxy object can return a valid result even though the
632 // global proxy object never has properties. This is the case
633 // because the global proxy object forwards everything to its hidden
634 // prototype including own lookups.
635 //
636 // Additionally, we need to make sure that we do not cache results
637 // for objects that require access checks.
638
639 // Convert string-index keys to their number variant to avoid internalization
640 // below; and speed up subsequent conversion to index.
641 uint32_t index;
642 if (IsString(*key_obj) && Cast<String>(*key_obj)->AsArrayIndex(&index)) {
643 key_obj = isolate->factory()->NewNumberFromUint(index);
644 }
645 if (IsJSObject(*lookup_start_obj)) {
646 DirectHandle<JSObject> lookup_start_object =
647 Cast<JSObject>(lookup_start_obj);
648 if (!IsJSGlobalProxy(*lookup_start_object) &&
649 !IsAccessCheckNeeded(*lookup_start_object) && IsName(*key_obj)) {
651 key_obj = key = isolate->factory()->InternalizeName(key);
652
654 if (IsJSGlobalObject(*lookup_start_object)) {
655 // Attempt dictionary lookup.
656 Tagged<GlobalDictionary> dictionary =
657 Cast<JSGlobalObject>(*lookup_start_object)
658 ->global_dictionary(kAcquireLoad);
659 InternalIndex entry = dictionary->FindEntry(isolate, key);
660 if (entry.is_found()) {
661 Tagged<PropertyCell> cell = dictionary->CellAt(entry);
662 if (cell->property_details().kind() == PropertyKind::kData) {
663 Tagged<Object> value = cell->value();
664 if (!IsPropertyCellHole(value, isolate)) return value;
665 // If value is the hole (meaning, absent) do the general lookup.
666 }
667 }
668 } else if (!lookup_start_object->HasFastProperties()) {
669 // Attempt dictionary lookup.
671 Tagged<SwissNameDictionary> dictionary =
672 lookup_start_object->property_dictionary_swiss();
673 InternalIndex entry = dictionary->FindEntry(isolate, *key);
674 if (entry.is_found() &&
675 (dictionary->DetailsAt(entry).kind() == PropertyKind::kData)) {
676 return dictionary->ValueAt(entry);
677 }
678 } else {
679 Tagged<NameDictionary> dictionary =
680 lookup_start_object->property_dictionary();
681 InternalIndex entry = dictionary->FindEntry(isolate, key);
682 if ((entry.is_found()) &&
683 (dictionary->DetailsAt(entry).kind() == PropertyKind::kData)) {
684 return dictionary->ValueAt(entry);
685 }
686 }
687 }
688 } else if (IsSmi(*key_obj)) {
689 // JSObject without a name key. If the key is a Smi, check for a
690 // definite out-of-bounds access to elements, which is a strong indicator
691 // that subsequent accesses will also call the runtime. Proactively
692 // transition elements to FAST_*_ELEMENTS to avoid excessive boxing of
693 // doubles for those future calls in the case that the elements would
694 // become PACKED_DOUBLE_ELEMENTS.
695 ElementsKind elements_kind = lookup_start_object->GetElementsKind();
696 if (IsDoubleElementsKind(elements_kind)) {
697 if (Smi::ToInt(*key_obj) >= lookup_start_object->elements()->length()) {
698 elements_kind = IsHoleyElementsKind(elements_kind) ? HOLEY_ELEMENTS
700 JSObject::TransitionElementsKind(lookup_start_object, elements_kind);
701 }
702 } else {
703 DCHECK(IsSmiOrObjectElementsKind(elements_kind) ||
704 !IsFastElementsKind(elements_kind));
705 }
706 }
707 } else if (IsString(*lookup_start_obj) && IsSmi(*key_obj)) {
708 // Fast case for string indexing using [] with a smi index.
709 DirectHandle<String> str = Cast<String>(lookup_start_obj);
710 uint32_t smi_index = Cast<Smi>(*key_obj).value();
711 if (smi_index < str->length()) {
712 Factory* factory = isolate->factory();
714 String::Flatten(isolate, str)->Get(smi_index));
715 }
716 }
717
718 // Fall back to GetObjectProperty.
720 isolate, Runtime::GetObjectProperty(isolate, lookup_start_obj, key_obj,
721 receiver_obj));
722}
723
724RUNTIME_FUNCTION(Runtime_SetKeyedProperty) {
725 HandleScope scope(isolate);
726 DCHECK_EQ(3, args.length());
727
728 DirectHandle<JSAny> object = args.at<JSAny>(0);
730 DirectHandle<Object> value = args.at(2);
731
733 isolate, Runtime::SetObjectProperty(isolate, object, key, value,
735}
736
737RUNTIME_FUNCTION(Runtime_DefineObjectOwnProperty) {
738 HandleScope scope(isolate);
739 DCHECK_EQ(3, args.length());
740
741 DirectHandle<JSAny> object = args.at<JSAny>(0);
743 DirectHandle<Object> value = args.at(2);
744
746 isolate, Runtime::DefineObjectOwnProperty(isolate, object, key, value,
748}
749
750RUNTIME_FUNCTION(Runtime_SetNamedProperty) {
751 HandleScope scope(isolate);
752 DCHECK_EQ(3, args.length());
753
754 DirectHandle<JSAny> object = args.at<JSAny>(0);
756 DirectHandle<Object> value = args.at(2);
757
759 isolate, Runtime::SetObjectProperty(isolate, object, key, value,
761}
762
763namespace {
764
765// ES6 section 12.5.4.
766Tagged<Object> DeleteProperty(Isolate* isolate, DirectHandle<Object> object,
767 DirectHandle<Object> key,
768 LanguageMode language_mode) {
769 DirectHandle<JSReceiver> receiver;
771 Object::ToObject(isolate, object));
773 Runtime::DeleteObjectProperty(isolate, receiver, key, language_mode);
774 MAYBE_RETURN(result, ReadOnlyRoots(isolate).exception());
775 return isolate->heap()->ToBoolean(result.FromJust());
776}
777
778} // namespace
779
780RUNTIME_FUNCTION(Runtime_DeleteProperty) {
781 HandleScope scope(isolate);
782 DCHECK_EQ(3, args.length());
783 DirectHandle<Object> object = args.at(0);
785 int language_mode = args.smi_value_at(2);
786 return DeleteProperty(isolate, object, key,
787 static_cast<LanguageMode>(language_mode));
788}
789
790RUNTIME_FUNCTION(Runtime_ShrinkNameDictionary) {
791 HandleScope scope(isolate);
792 DCHECK_EQ(1, args.length());
794
795 return *NameDictionary::Shrink(isolate, dictionary);
796}
797
798RUNTIME_FUNCTION(Runtime_ShrinkSwissNameDictionary) {
799 HandleScope scope(isolate);
800 DCHECK_EQ(1, args.length());
803
804 return *SwissNameDictionary::Shrink(isolate, dictionary);
805}
806
807// ES6 section 12.9.3, operator in.
808RUNTIME_FUNCTION(Runtime_HasProperty) {
809 HandleScope scope(isolate);
810 DCHECK_EQ(2, args.length());
811 DirectHandle<Object> object = args.at(0);
813
814 // Check that {object} is actually a receiver.
815 if (!IsJSReceiver(*object)) {
817 isolate,
818 NewTypeError(MessageTemplate::kInvalidInOperatorUse, key, object));
819 }
821
822 // Convert the {key} to a name.
825 Object::ToName(isolate, key));
826
827 // Lookup the {name} on {receiver}.
828 Maybe<bool> maybe = JSReceiver::HasProperty(isolate, receiver, name);
829 if (maybe.IsNothing()) return ReadOnlyRoots(isolate).exception();
830 return isolate->heap()->ToBoolean(maybe.FromJust());
831}
832
833RUNTIME_FUNCTION(Runtime_GetOwnPropertyKeys) {
834 HandleScope scope(isolate);
835 DCHECK_EQ(2, args.length());
837 int filter_value = args.smi_value_at(1);
838 PropertyFilter filter = static_cast<PropertyFilter>(filter_value);
839
842 isolate, keys,
845
846 return *isolate->factory()->NewJSArrayWithElements(keys);
847}
848
849RUNTIME_FUNCTION(Runtime_ToFastProperties) {
850 HandleScope scope(isolate);
851 DCHECK_EQ(1, args.length());
852 DirectHandle<Object> object = args.at(0);
853 if (IsJSObject(*object) && !IsJSGlobalObject(*object)) {
855 "RuntimeToFastProperties");
856 }
857 return *object;
858}
859
860RUNTIME_FUNCTION(Runtime_AllocateHeapNumber) {
861 HandleScope scope(isolate);
862 DCHECK_EQ(0, args.length());
863 return *isolate->factory()->NewHeapNumber(0);
864}
865
866RUNTIME_FUNCTION(Runtime_NewObject) {
867 HandleScope scope(isolate);
868 DCHECK_EQ(2, args.length());
872 isolate,
874}
875
876RUNTIME_FUNCTION(Runtime_GetDerivedMap) {
877 HandleScope scope(isolate);
878 DCHECK_EQ(3, args.length());
881 DirectHandle<Object> rab_gsab = args.at(2);
882 if (IsTrue(*rab_gsab)) {
884 isolate, JSFunction::GetDerivedRabGsabTypedArrayMap(isolate, target,
885 new_target));
886 } else {
888 isolate, JSFunction::GetDerivedMap(isolate, target, new_target));
889 }
890}
891
892RUNTIME_FUNCTION(Runtime_CompleteInobjectSlackTrackingForMap) {
894 HandleScope scope(isolate);
895 DCHECK_EQ(1, args.length());
896
897 DirectHandle<Map> initial_map = args.at<Map>(0);
898 MapUpdater::CompleteInobjectSlackTracking(isolate, *initial_map);
899
900 return ReadOnlyRoots(isolate).undefined_value();
901}
902
903RUNTIME_FUNCTION(Runtime_TryMigrateInstance) {
904 HandleScope scope(isolate);
905 DCHECK_EQ(1, args.length());
906 DirectHandle<JSObject> js_object = args.at<JSObject>(0);
907 // It could have been a DCHECK but we call this function directly from tests.
908 if (!js_object->map()->is_deprecated()) return Smi::zero();
909 // This call must not cause lazy deopts, because it's called from deferred
910 // code where we can't handle lazy deopts for lack of a suitable bailout
911 // ID. So we just try migration and signal failure if necessary,
912 // which will also trigger a deopt.
913 if (!JSObject::TryMigrateInstance(isolate, js_object)) return Smi::zero();
914 return *js_object;
915}
916
917RUNTIME_FUNCTION(Runtime_TryMigrateInstanceAndMarkMapAsMigrationTarget) {
918 HandleScope scope(isolate);
919 DCHECK_EQ(1, args.length());
920 DirectHandle<JSObject> js_object = args.at<JSObject>(0);
921 DCHECK(js_object->map()->is_deprecated());
922
923#ifdef DEBUG
924 DirectHandle<Map> old_map(js_object->map(), isolate);
925#endif // DEBUG
926
927 if (!JSObject::TryMigrateInstance(isolate, js_object)) {
928 return ReadOnlyRoots(isolate).undefined_value();
929 }
930
931 // Otherwise, the migration was successful.
932#ifdef DEBUG
933 DCHECK_NE(*old_map, js_object->map());
934#endif // DEBUG
935
936 js_object->map()->set_is_migration_target(true);
937 return ReadOnlyRoots(isolate).undefined_value();
938}
939
940static bool IsValidAccessor(Isolate* isolate, DirectHandle<Object> obj) {
941 return IsNullOrUndefined(*obj, isolate) || IsCallable(*obj);
942}
943
944// Implements part of 8.12.9 DefineOwnProperty.
945// There are 3 cases that lead here:
946// Step 4b - define a new accessor property.
947// Steps 9c & 12 - replace an existing data property with an accessor property.
948// Step 12 - update an existing accessor property with an accessor or generic
949// descriptor.
950RUNTIME_FUNCTION(Runtime_DefineAccessorPropertyUnchecked) {
951 HandleScope scope(isolate);
952 DCHECK_EQ(5, args.length());
954 CHECK(!IsNull(*obj, isolate));
955 DirectHandle<Name> name = args.at<Name>(1);
957 CHECK(IsValidAccessor(isolate, getter));
959 CHECK(IsValidAccessor(isolate, setter));
960 auto attrs = PropertyAttributesFromInt(args.smi_value_at(4));
961
964 setter, attrs));
965 return ReadOnlyRoots(isolate).undefined_value();
966}
967
968RUNTIME_FUNCTION(Runtime_SetFunctionName) {
969 HandleScope scope(isolate);
970 DCHECK_EQ(2, args.length());
971 DirectHandle<Object> value = args.at(0);
972 DirectHandle<Name> name = args.at<Name>(1);
973 DCHECK(IsJSFunction(*value));
974 auto function = Cast<JSFunction>(value);
975 DCHECK(!function->shared()->HasSharedName());
976 DirectHandle<Map> function_map(function->map(), isolate);
977 if (!JSFunction::SetName(function, name,
978 isolate->factory()->empty_string())) {
979 return ReadOnlyRoots(isolate).exception();
980 }
981 // Class constructors do not reserve in-object space for name field.
982 DCHECK_IMPLIES(!IsClassConstructor(function->shared()->kind()),
983 *function_map == function->map());
984 return *value;
985}
986
987RUNTIME_FUNCTION(Runtime_DefineKeyedOwnPropertyInLiteral) {
988 HandleScope scope(isolate);
989 DCHECK_EQ(6, args.length());
991 Handle<Object> name = args.at(1);
992 DirectHandle<Object> value = args.at(2);
993 int flag = args.smi_value_at(3);
994 Handle<HeapObject> maybe_vector = args.at<HeapObject>(4);
995
996 if (!IsUndefined(*maybe_vector)) {
997 int index = args.tagged_index_value_at(5);
998 DCHECK(IsName(*name));
999 DCHECK(IsFeedbackVector(*maybe_vector));
1000 Handle<FeedbackVector> vector = Cast<FeedbackVector>(maybe_vector);
1001 FeedbackNexus nexus(isolate, vector, FeedbackVector::ToSlot(index));
1003 if (IsUniqueName(*name)) {
1004 nexus.ConfigureMonomorphic(Cast<Name>(name),
1005 direct_handle(object->map(), isolate),
1007 } else {
1009 }
1010 } else if (nexus.ic_state() == InlineCacheState::MONOMORPHIC) {
1011 if (nexus.GetFirstMap() != object->map() || nexus.GetName() != *name) {
1013 }
1014 }
1015 }
1016
1018
1020 DCHECK(IsName(*name));
1021 DCHECK(IsJSFunction(*value));
1022 auto function = Cast<JSFunction>(value);
1023 DCHECK(!function->shared()->HasSharedName());
1024 DirectHandle<Map> function_map(function->map(), isolate);
1025 if (!JSFunction::SetName(function, Cast<Name>(name),
1026 isolate->factory()->empty_string())) {
1027 return ReadOnlyRoots(isolate).exception();
1028 }
1029 // Class constructors do not reserve in-object space for name field.
1030 DCHECK_IMPLIES(!IsClassConstructor(function->shared()->kind()),
1031 *function_map == function->map());
1032 }
1033
1034 PropertyKey key(isolate, name);
1035 LookupIterator it(isolate, object, key, object, LookupIterator::OWN);
1036
1039 // Cannot fail since this should only be called when
1040 // creating an object literal.
1042 DCHECK(result.IsJust());
1043 USE(result);
1044
1045 // Return the value so that
1046 // BaselineCompiler::VisitDefineKeyedOwnPropertyInLiteral doesn't have to
1047 // save the accumulator.
1048 return *value;
1049}
1050
1051RUNTIME_FUNCTION(Runtime_HasFastPackedElements) {
1052 SealHandleScope shs(isolate);
1053 DCHECK_EQ(1, args.length());
1054 auto obj = Cast<HeapObject>(args[0]);
1055 return isolate->heap()->ToBoolean(
1056 IsFastPackedElementsKind(obj->map()->elements_kind()));
1057}
1058
1059RUNTIME_FUNCTION(Runtime_IsJSReceiver) {
1060 SealHandleScope shs(isolate);
1061 DCHECK_EQ(1, args.length());
1062 Tagged<Object> obj = args[0];
1063 return isolate->heap()->ToBoolean(IsJSReceiver(obj));
1064}
1065
1066RUNTIME_FUNCTION(Runtime_GetFunctionName) {
1067 HandleScope scope(isolate);
1068 DCHECK_EQ(1, args.length());
1069 DirectHandle<JSFunction> function = args.at<JSFunction>(0);
1070 return *JSFunction::GetName(isolate, function);
1071}
1072
1073RUNTIME_FUNCTION(Runtime_DefineGetterPropertyUnchecked) {
1074 HandleScope scope(isolate);
1075 DCHECK_EQ(4, args.length());
1076 DirectHandle<JSObject> object = args.at<JSObject>(0);
1077 DirectHandle<Name> name = args.at<Name>(1);
1079 auto attrs = PropertyAttributesFromInt(args.smi_value_at(3));
1080
1081 if (Cast<String>(getter->shared()->Name())->length() == 0) {
1082 DirectHandle<Map> getter_map(getter->map(), isolate);
1083 if (!JSFunction::SetName(getter, name, isolate->factory()->get_string())) {
1084 return ReadOnlyRoots(isolate).exception();
1085 }
1086 CHECK_EQ(*getter_map, getter->map());
1087 }
1088
1090 isolate,
1092 object, name, getter, isolate->factory()->null_value(), attrs));
1093 return ReadOnlyRoots(isolate).undefined_value();
1094}
1095
1096RUNTIME_FUNCTION(Runtime_SetDataProperties) {
1097 HandleScope scope(isolate);
1098 DCHECK_EQ(2, args.length());
1100 DirectHandle<Object> source = args.at(1);
1101
1102 // 2. If source is undefined or null, let keys be an empty List.
1103 if (IsUndefined(*source, isolate) || IsNull(*source, isolate)) {
1104 return ReadOnlyRoots(isolate).undefined_value();
1105 }
1106
1108 isolate, target, source,
1110 ReadOnlyRoots(isolate).exception());
1111 return ReadOnlyRoots(isolate).undefined_value();
1112}
1113
1114RUNTIME_FUNCTION(Runtime_CopyDataProperties) {
1115 HandleScope scope(isolate);
1116 DCHECK_EQ(2, args.length());
1117 DirectHandle<JSObject> target = args.at<JSObject>(0);
1118 DirectHandle<Object> source = args.at(1);
1119
1120 // 2. If source is undefined or null, let keys be an empty List.
1121 if (IsUndefined(*source, isolate) || IsNull(*source, isolate)) {
1122 return ReadOnlyRoots(isolate).undefined_value();
1123 }
1124
1127 isolate, target, source,
1129 ReadOnlyRoots(isolate).exception());
1130 return ReadOnlyRoots(isolate).undefined_value();
1131}
1132
1133namespace {
1134
1135// Check that the excluded properties are within the stack range of the top of
1136// the stack, and the start of the JS frame.
1137void CheckExcludedPropertiesAreOnCallerStack(Isolate* isolate, Address base,
1138 int count) {
1139#ifdef DEBUG
1140 StackFrameIterator it(isolate);
1141
1142 // Don't need to check when there's no excluded properties.
1143 if (count == 0) return;
1144
1145 DCHECK(!it.done());
1146
1147 // Properties are pass in order on the stack, which means that their addresses
1148 // are in reverse order in memory (because stacks grow backwards). So, we
1149 // need to check if the _last_ property address is before the stack end...
1150 Address last_property = base - (count - 1) * kSystemPointerSize;
1151 DCHECK_GE(last_property, it.frame()->sp());
1152
1153 // ... and for the first JS frame, make sure the _first_ property address is
1154 // after that stack frame's start.
1155 for (; !it.done(); it.Advance()) {
1156 if (it.frame()->is_javascript()) {
1157 DCHECK_LT(base, it.frame()->fp());
1158 return;
1159 }
1160 }
1161
1162 // We should always find a JS frame.
1163 UNREACHABLE();
1164#endif
1165}
1166
1167} // namespace
1168
1169RUNTIME_FUNCTION(Runtime_CopyDataPropertiesWithExcludedPropertiesOnStack) {
1170 HandleScope scope(isolate);
1171 DCHECK_EQ(3, args.length());
1172 DirectHandle<Object> source = args.at(0);
1173 int excluded_property_count = args.smi_value_at(1);
1174 // The excluded_property_base is passed as a raw stack pointer. This is safe
1175 // because the stack pointer is aligned, so it looks like a Smi to the GC.
1176 Address* excluded_property_base = reinterpret_cast<Address*>(args[2].ptr());
1177 DCHECK(HAS_SMI_TAG(reinterpret_cast<intptr_t>(excluded_property_base)));
1178 // Also make sure that the given base pointer points to to on-stack values.
1179 CheckExcludedPropertiesAreOnCallerStack(
1180 isolate, reinterpret_cast<Address>(excluded_property_base),
1181 excluded_property_count);
1182
1183 // If source is undefined or null, throw a non-coercible error.
1184 if (IsNullOrUndefined(*source, isolate)) {
1186 isolate, source, MaybeDirectHandle<Object>());
1187 }
1188
1189 DirectHandleVector<Object> excluded_properties(isolate,
1190 excluded_property_count);
1191 for (int i = 0; i < excluded_property_count; i++) {
1192 // Because the excluded properties on stack is from high address
1193 // to low address, so we need to use sub
1194 IndirectHandle<Object> property(excluded_property_base - i);
1195 uint32_t property_num;
1196 // We convert string to number if possible, in cases of computed
1197 // properties resolving to numbers, which would've been strings
1198 // instead because of our call to %ToName() in the desugaring for
1199 // computed properties.
1200 if (IsString(*property) &&
1201 Cast<String>(*property)->AsArrayIndex(&property_num)) {
1202 property = isolate->factory()->NewNumberFromUint(property_num);
1203 }
1204
1205 excluded_properties[i] = property;
1206 }
1207
1208 DirectHandle<JSObject> target =
1209 isolate->factory()->NewJSObject(isolate->object_function());
1212 isolate, target, source,
1214 {excluded_properties.data(), excluded_properties.size()}, false),
1215 ReadOnlyRoots(isolate).exception());
1216 return *target;
1217}
1218
1219RUNTIME_FUNCTION(Runtime_DefineSetterPropertyUnchecked) {
1220 HandleScope scope(isolate);
1221 DCHECK_EQ(4, args.length());
1222 DirectHandle<JSObject> object = args.at<JSObject>(0);
1223 DirectHandle<Name> name = args.at<Name>(1);
1225 auto attrs = PropertyAttributesFromInt(args.smi_value_at(3));
1226
1227 if (Cast<String>(setter->shared()->Name())->length() == 0) {
1228 DirectHandle<Map> setter_map(setter->map(), isolate);
1229 if (!JSFunction::SetName(setter, name, isolate->factory()->set_string())) {
1230 return ReadOnlyRoots(isolate).exception();
1231 }
1232 CHECK_EQ(*setter_map, setter->map());
1233 }
1234
1236 isolate,
1238 object, name, isolate->factory()->null_value(), setter, attrs));
1239 return ReadOnlyRoots(isolate).undefined_value();
1240}
1241
1242RUNTIME_FUNCTION(Runtime_ToObject) {
1243 // Runtime call is implemented in InterpreterIntrinsics and lowered in
1244 // JSIntrinsicLowering.
1245 UNREACHABLE();
1246}
1247
1248RUNTIME_FUNCTION(Runtime_ToNumber) {
1249 HandleScope scope(isolate);
1250 DCHECK_EQ(1, args.length());
1251 DirectHandle<Object> input = args.at(0);
1252 RETURN_RESULT_OR_FAILURE(isolate, Object::ToNumber(isolate, input));
1253}
1254
1255RUNTIME_FUNCTION(Runtime_ToNumeric) {
1256 HandleScope scope(isolate);
1257 DCHECK_EQ(1, args.length());
1258 Handle<Object> input = args.at(0);
1259 RETURN_RESULT_OR_FAILURE(isolate, Object::ToNumeric(isolate, input));
1260}
1261
1262RUNTIME_FUNCTION(Runtime_ToLength) {
1263 HandleScope scope(isolate);
1264 DCHECK_EQ(1, args.length());
1265 DirectHandle<Object> input = args.at(0);
1266 RETURN_RESULT_OR_FAILURE(isolate, Object::ToLength(isolate, input));
1267}
1268
1269RUNTIME_FUNCTION(Runtime_ToString) {
1270 HandleScope scope(isolate);
1271 DCHECK_EQ(1, args.length());
1272 DirectHandle<Object> input = args.at(0);
1273 RETURN_RESULT_OR_FAILURE(isolate, Object::ToString(isolate, input));
1274}
1275
1276RUNTIME_FUNCTION(Runtime_ToName) {
1277 HandleScope scope(isolate);
1278 DCHECK_EQ(1, args.length());
1279 DirectHandle<Object> input = args.at(0);
1280 RETURN_RESULT_OR_FAILURE(isolate, Object::ToName(isolate, input));
1281}
1282
1283RUNTIME_FUNCTION(Runtime_HasInPrototypeChain) {
1284 HandleScope scope(isolate);
1285 DCHECK_EQ(2, args.length());
1286 DirectHandle<Object> object = args.at(0);
1287 DirectHandle<Object> prototype = args.at(1);
1288 if (!IsJSReceiver(*object)) return ReadOnlyRoots(isolate).false_value();
1290 isolate, Cast<JSReceiver>(object), prototype);
1291 MAYBE_RETURN(result, ReadOnlyRoots(isolate).exception());
1292 return isolate->heap()->ToBoolean(result.FromJust());
1293}
1294
1295// ES6 section 7.4.7 CreateIterResultObject ( value, done )
1296RUNTIME_FUNCTION(Runtime_CreateIterResultObject) {
1297 HandleScope scope(isolate);
1298 DCHECK_EQ(2, args.length());
1299 DirectHandle<Object> value = args.at(0);
1300 DirectHandle<Object> done = args.at(1);
1301 return *isolate->factory()->NewJSIteratorResult(
1302 value, Object::BooleanValue(*done, isolate));
1303}
1304
1305RUNTIME_FUNCTION(Runtime_CreateDataProperty) {
1306 HandleScope scope(isolate);
1307 DCHECK_EQ(3, args.length());
1310 DirectHandle<Object> value = args.at(2);
1311 bool success;
1312 PropertyKey lookup_key(isolate, key, &success);
1313 if (!success) return ReadOnlyRoots(isolate).exception();
1314 MAYBE_RETURN(JSReceiver::CreateDataProperty(isolate, o, lookup_key, value,
1316 ReadOnlyRoots(isolate).exception());
1317 return *value;
1318}
1319
1320RUNTIME_FUNCTION(Runtime_SetOwnPropertyIgnoreAttributes) {
1321 HandleScope scope(isolate);
1322 DCHECK_EQ(4, args.length());
1325 DirectHandle<Object> value = args.at(2);
1326 int attributes = args.smi_value_at(3);
1327
1330 o, key, value, PropertyAttributes(attributes)));
1331}
1332
1333// Returns a PropertyDescriptorObject (property-descriptor-object.h)
1334RUNTIME_FUNCTION(Runtime_GetOwnPropertyDescriptorObject) {
1335 HandleScope scope(isolate);
1336
1337 DCHECK_EQ(2, args.length());
1339 DirectHandle<Name> name = args.at<Name>(1);
1340
1341 PropertyDescriptor desc;
1342 Maybe<bool> found =
1343 JSReceiver::GetOwnPropertyDescriptor(isolate, object, name, &desc);
1344 MAYBE_RETURN(found, ReadOnlyRoots(isolate).exception());
1345
1346 if (!found.FromJust()) return ReadOnlyRoots(isolate).undefined_value();
1347 return *desc.ToPropertyDescriptorObject(isolate);
1348}
1349
1355
1358 // It's the class constructor for static methods/accessors,
1359 // the brand symbol for instance methods/accessors,
1360 // and the private name symbol for fields.
1363};
1364
1365namespace {
1366void CollectPrivateMethodsAndAccessorsFromContext(
1367 Isolate* isolate, DirectHandle<Context> context, DirectHandle<String> desc,
1368 Handle<Object> brand, IsStaticFlag is_static_flag,
1369 std::vector<PrivateMember>* results) {
1370 DirectHandle<ScopeInfo> scope_info(context->scope_info(), isolate);
1371 VariableLookupResult lookup_result;
1372 int context_index = scope_info->ContextSlotIndex(desc, &lookup_result);
1373 if (context_index == -1 ||
1375 lookup_result.is_static_flag != is_static_flag) {
1376 return;
1377 }
1378
1379 Handle<Object> slot_value(context->get(context_index), isolate);
1381 IsJSFunction(*slot_value));
1383 IsAccessorPair(*slot_value));
1384 results->push_back({
1385 lookup_result.mode == VariableMode::kPrivateMethod
1388 brand,
1389 slot_value,
1390 });
1391}
1392
1393Maybe<bool> CollectPrivateMembersFromReceiver(
1394 Isolate* isolate, DirectHandle<JSReceiver> receiver,
1395 DirectHandle<String> desc, std::vector<PrivateMember>* results) {
1396 PropertyFilter key_filter =
1398 DirectHandle<FixedArray> keys;
1400 isolate, keys,
1403 Nothing<bool>());
1404
1405 if (IsJSFunction(*receiver)) {
1407 DirectHandle<SharedFunctionInfo> shared(func->shared(), isolate);
1408 if (shared->is_class_constructor() &&
1409 shared->has_static_private_methods_or_accessors()) {
1410 DirectHandle<Context> receiver_context(
1411 Cast<JSFunction>(*receiver)->context(), isolate);
1412 CollectPrivateMethodsAndAccessorsFromContext(
1413 isolate, receiver_context, desc, func, IsStaticFlag::kStatic,
1414 results);
1415 }
1416 }
1417
1418 for (int i = 0; i < keys->length(); ++i) {
1419 DirectHandle<Object> obj_key(keys->get(i), isolate);
1420 Handle<Symbol> symbol(Cast<Symbol>(*obj_key), isolate);
1421 CHECK(symbol->is_private_name());
1422 Handle<Object> value;
1424 isolate, value, Object::GetProperty(isolate, receiver, symbol),
1425 Nothing<bool>());
1426
1427 if (symbol->is_private_brand()) {
1428 DirectHandle<Context> value_context(Cast<Context>(*value), isolate);
1429 CollectPrivateMethodsAndAccessorsFromContext(
1430 isolate, value_context, desc, symbol, IsStaticFlag::kNotStatic,
1431 results);
1432 } else {
1433 DirectHandle<String> symbol_desc(Cast<String>(symbol->description()),
1434 isolate);
1435 if (symbol_desc->Equals(*desc)) {
1436 results->push_back({
1438 symbol,
1439 value,
1440 });
1441 }
1442 }
1443 }
1444
1445 return Just(true);
1446}
1447
1448Maybe<bool> FindPrivateMembersFromReceiver(Isolate* isolate,
1449 DirectHandle<JSReceiver> receiver,
1450 DirectHandle<String> desc,
1451 MessageTemplate not_found_message,
1452 PrivateMember* result) {
1453 std::vector<PrivateMember> results;
1455 CollectPrivateMembersFromReceiver(isolate, receiver, desc, &results),
1456 Nothing<bool>());
1457
1458 if (results.empty()) {
1459 THROW_NEW_ERROR_RETURN_VALUE(isolate, NewError(not_found_message, desc),
1460 Nothing<bool>());
1461 } else if (results.size() > 1) {
1463 isolate, NewError(MessageTemplate::kConflictingPrivateName, desc),
1464 Nothing<bool>());
1465 }
1466
1467 *result = results[0];
1468 return Just(true);
1469}
1470} // namespace
1471
1474 DirectHandle<String> desc) {
1476 MAYBE_RETURN_NULL(FindPrivateMembersFromReceiver(
1477 isolate, receiver, desc, MessageTemplate::kInvalidPrivateMemberRead,
1478 &result));
1479
1480 switch (result.type) {
1483 return result.value;
1484 }
1486 // The accessors are collected from the contexts, so there is no need to
1487 // perform brand checks.
1488 auto pair = Cast<AccessorPair>(result.value);
1489 if (IsNull(pair->getter())) {
1491 isolate,
1492 NewError(MessageTemplate::kInvalidPrivateGetterAccess, desc));
1493 }
1494 DCHECK(IsJSFunction(pair->getter()));
1496 isolate);
1497 return Execution::Call(isolate, getter, receiver, {});
1498 }
1499 }
1500}
1501
1506 MAYBE_RETURN_NULL(FindPrivateMembersFromReceiver(
1507 isolate, receiver, desc, MessageTemplate::kInvalidPrivateMemberRead,
1508 &result));
1509
1510 switch (result.type) {
1512 auto symbol = Cast<Symbol>(result.brand_or_field_symbol);
1513 return Object::SetProperty(isolate, receiver, symbol, value,
1515 }
1518 isolate, NewError(MessageTemplate::kInvalidPrivateMethodWrite, desc));
1519 }
1521 // The accessors are collected from the contexts, so there is no need to
1522 // perform brand checks.
1523 auto pair = Cast<AccessorPair>(result.value);
1524 if (IsNull(pair->setter())) {
1526 isolate,
1527 NewError(MessageTemplate::kInvalidPrivateSetterAccess, desc));
1528 }
1529 DCHECK(IsJSFunction(pair->setter()));
1530 DirectHandle<Object> args[] = {value};
1532 isolate);
1534 }
1535 }
1536}
1537
1538RUNTIME_FUNCTION(Runtime_GetPrivateMember) {
1539 HandleScope scope(isolate);
1540 // TODO(chromium:1381806) support specifying scopes, or selecting the right
1541 // one from the conflicting names.
1542 DCHECK_EQ(args.length(), 2);
1544 Handle<String> desc = args.at<String>(1);
1545 if (IsJSReceiver(*receiver)) {
1547 isolate,
1549 }
1551 isolate, NewTypeError(MessageTemplate::kNonObjectPrivateNameAccess, desc,
1552 receiver));
1553}
1554
1555RUNTIME_FUNCTION(Runtime_SetPrivateMember) {
1556 HandleScope scope(isolate);
1557 // TODO(chromium:1381806) support specifying scopes, or selecting the right
1558 // one from the conflicting names.
1559 DCHECK_EQ(args.length(), 3);
1561 Handle<String> desc = args.at<String>(1);
1562 if (IsJSReceiver(*receiver)) {
1563 DirectHandle<Object> value = args.at<Object>(2);
1566 desc, value));
1567 }
1569 isolate, NewTypeError(MessageTemplate::kNonObjectPrivateNameAccess, desc,
1570 receiver));
1571}
1572
1573RUNTIME_FUNCTION(Runtime_LoadPrivateSetter) {
1574 HandleScope scope(isolate);
1575 DCHECK_EQ(args.length(), 1);
1577 DCHECK(IsJSFunction(pair->setter()));
1578 return pair->setter();
1579}
1580
1581RUNTIME_FUNCTION(Runtime_LoadPrivateGetter) {
1582 HandleScope scope(isolate);
1583 DCHECK_EQ(args.length(), 1);
1585 DCHECK(IsJSFunction(pair->getter()));
1586 return pair->getter();
1587}
1588
1589RUNTIME_FUNCTION(Runtime_CreatePrivateAccessors) {
1590 HandleScope scope(isolate);
1591 DCHECK_EQ(args.length(), 2);
1592 DCHECK(IsNull(args[0]) || IsJSFunction(args[0]));
1593 DCHECK(IsNull(args[1]) || IsJSFunction(args[1]));
1594 DirectHandle<AccessorPair> pair = isolate->factory()->NewAccessorPair();
1595 pair->SetComponents(args[0], args[1]);
1596 return *pair;
1597}
1598
1599// TODO(v8:11330) This is only here while the CSA/Torque implementation of
1600// SwissNameDictionary is work in progress.
1601RUNTIME_FUNCTION(Runtime_SwissTableAllocate) {
1602 HandleScope scope(isolate);
1603 int at_least_space_for = args.smi_value_at(0);
1604
1605 return *isolate->factory()->NewSwissNameDictionary(at_least_space_for,
1607}
1608
1609// TODO(v8:11330) This is only here while the CSA/Torque implementation of
1610// SwissNameDictionary is work in progress.
1611RUNTIME_FUNCTION(Runtime_SwissTableAdd) {
1612 HandleScope scope(isolate);
1615 DirectHandle<Object> value = args.at(2);
1616 PropertyDetails details(Cast<Smi>(args[3]));
1617
1619
1620 return *SwissNameDictionary::Add(isolate, table, key, value, details);
1621}
1622
1623// TODO(v8:11330) This is only here while the CSA/Torque implementation of
1624// SwissNameDictionary is work in progress.
1625RUNTIME_FUNCTION(Runtime_SwissTableFindEntry) {
1626 HandleScope scope(isolate);
1628 auto table = Cast<SwissNameDictionary>(args[0]);
1630 InternalIndex index = table->FindEntry(isolate, key);
1631 return Smi::FromInt(index.is_found()
1632 ? index.as_int()
1634}
1635
1636// TODO(v8:11330) This is only here while the CSA/Torque implementation of
1637// SwissNameDictionary is work in progress.
1638RUNTIME_FUNCTION(Runtime_SwissTableUpdate) {
1639 HandleScope scope(isolate);
1641 auto table = Cast<SwissNameDictionary>(args[0]);
1642 InternalIndex index(args.smi_value_at(1));
1643 Tagged<Object> value = args[2];
1644 table->ValueAtPut(index, value);
1645
1646 PropertyDetails details(Cast<Smi>(args[3]));
1647 table->DetailsAtPut(index, details);
1648
1649 return ReadOnlyRoots(isolate).undefined_value();
1650}
1651
1652// TODO(v8:11330) This is only here while the CSA/Torque implementation of
1653// SwissNameDictionary is work in progress.
1654RUNTIME_FUNCTION(Runtime_SwissTableDelete) {
1655 HandleScope scope(isolate);
1657 InternalIndex index(args.smi_value_at(1));
1658
1659 return *SwissNameDictionary::DeleteEntry(isolate, table, index);
1660}
1661
1662// TODO(v8:11330) This is only here while the CSA/Torque implementation of
1663// SwissNameDictionary is work in progress.
1664RUNTIME_FUNCTION(Runtime_SwissTableEquals) {
1665 HandleScope scope(isolate);
1667 auto table = Cast<SwissNameDictionary>(args[0]);
1668 auto other = Cast<SwissNameDictionary>(args[0]);
1669 return Smi::FromInt(table->EqualsForTesting(other));
1670}
1671
1672// TODO(v8:11330) This is only here while the CSA/Torque implementation of
1673// SwissNameDictionary is work in progress.
1674RUNTIME_FUNCTION(Runtime_SwissTableElementsCount) {
1675 HandleScope scope(isolate);
1677 auto table = Cast<SwissNameDictionary>(args[0]);
1678 return Smi::FromInt(table->NumberOfElements());
1679}
1680
1681// TODO(v8:11330) This is only here while the CSA/Torque implementation of
1682// SwissNameDictionary is work in progress.
1683RUNTIME_FUNCTION(Runtime_SwissTableKeyAt) {
1684 HandleScope scope(isolate);
1686 auto table = Cast<SwissNameDictionary>(args[0]);
1687 InternalIndex index(args.smi_value_at(1));
1688 return table->KeyAt(index);
1689}
1690
1691// TODO(v8:11330) This is only here while the CSA/Torque implementation of
1692// SwissNameDictionary is work in progress.
1693RUNTIME_FUNCTION(Runtime_SwissTableValueAt) {
1694 HandleScope scope(isolate);
1696 auto table = Cast<SwissNameDictionary>(args[0]);
1697 InternalIndex index(args.smi_value_at(1));
1698 return table->ValueAt(index);
1699}
1700
1701// TODO(v8:11330) This is only here while the CSA/Torque implementation of
1702// SwissNameDictionary is work in progress.
1703RUNTIME_FUNCTION(Runtime_SwissTableDetailsAt) {
1704 HandleScope scope(isolate);
1706 auto table = Cast<SwissNameDictionary>(args[0]);
1707 InternalIndex index(args.smi_value_at(1));
1708 PropertyDetails d = table->DetailsAt(index);
1709 return d.AsSmi();
1710}
1711
1712} // namespace internal
1713} // namespace v8
PropertyT * getter
V8_INLINE bool IsJust() const
Definition v8-maybe.h:36
V8_INLINE T FromJust() const &
Definition v8-maybe.h:64
V8_INLINE bool IsNothing() const
Definition v8-maybe.h:35
DirectHandle< T > * data() noexcept
Definition handles.h:916
size_t size() const noexcept
Definition handles.h:900
static Tagged< Object > ThrowLoadFromNullOrUndefined(Isolate *isolate, DirectHandle< Object > object, MaybeDirectHandle< Object > key)
Definition messages.cc:1006
V8_EXPORT_PRIVATE static V8_WARN_UNUSED_RESULT MaybeHandle< Object > Call(Isolate *isolate, DirectHandle< Object > callable, DirectHandle< Object > receiver, base::Vector< const DirectHandle< Object > > args)
Definition execution.cc:523
Handle< String > LookupSingleCharacterStringFromCode(uint16_t code)
Tagged< Name > GetName() const
void ConfigureMonomorphic(DirectHandle< Name > name, DirectHandle< Map > receiver_map, const MaybeObjectDirectHandle &handler)
InlineCacheState ic_state() const
Tagged< Map > GetFirstMap() const
static FeedbackSlot ToSlot(intptr_t index)
static V8_WARN_UNUSED_RESULT bool SetName(DirectHandle< JSFunction > function, DirectHandle< Name > name, DirectHandle< String > prefix)
static Handle< String > GetName(Isolate *isolate, DirectHandle< JSFunction > function)
static V8_WARN_UNUSED_RESULT MaybeDirectHandle< Map > GetDerivedRabGsabTypedArrayMap(Isolate *isolate, DirectHandle< JSFunction > constructor, DirectHandle< JSReceiver > new_target)
static V8_EXPORT_PRIVATE V8_WARN_UNUSED_RESULT MaybeHandle< Map > GetDerivedMap(Isolate *isolate, DirectHandle< JSFunction > constructor, DirectHandle< JSReceiver > new_target)
static V8_WARN_UNUSED_RESULT HandleType< Object >::MaybeType DefineOwnPropertyIgnoreAttributes(LookupIterator *it, HandleType< T > value, PropertyAttributes attributes, AccessorInfoHandling handling=DONT_FORCE_FIELD, EnforceDefineSemantics semantics=EnforceDefineSemantics::kSet)
static V8_EXPORT_PRIVATE void MigrateSlowToFast(DirectHandle< JSObject > object, int unused_property_fields, const char *reason)
static V8_EXPORT_PRIVATE V8_WARN_UNUSED_RESULT MaybeHandle< JSObject > New(DirectHandle< JSFunction > constructor, DirectHandle< JSReceiver > new_target, DirectHandle< AllocationSite > site, NewJSObjectType=NewJSObjectType::kNoAPIWrapper)
static constexpr uint32_t kMaxElementIndex
Definition js-objects.h:924
static V8_WARN_UNUSED_RESULT MaybeDirectHandle< Object > V8_EXPORT_PRIVATE SetOwnPropertyIgnoreAttributes(DirectHandle< JSObject > object, DirectHandle< Name > name, DirectHandle< Object > value, PropertyAttributes attributes)
static V8_EXPORT_PRIVATE void NormalizeProperties(Isolate *isolate, DirectHandle< JSObject > object, PropertyNormalizationMode mode, int expected_additional_properties, bool use_cache, const char *reason)
static V8_EXPORT_PRIVATE void TransitionElementsKind(DirectHandle< JSObject > object, ElementsKind to_kind)
static V8_EXPORT_PRIVATE MaybeDirectHandle< Object > DefineOwnAccessorIgnoreAttributes(DirectHandle< JSObject > object, DirectHandle< Name > name, DirectHandle< Object > getter, DirectHandle< Object > setter, PropertyAttributes attributes)
static bool TryMigrateInstance(Isolate *isolate, DirectHandle< JSObject > instance)
static V8_WARN_UNUSED_RESULT MaybeDirectHandle< JSObject > ObjectCreate(Isolate *isolate, DirectHandle< JSPrototype > prototype)
V8_EXPORT_PRIVATE static V8_WARN_UNUSED_RESULT Maybe< bool > GetOwnPropertyDescriptor(Isolate *isolate, DirectHandle< JSReceiver > object, DirectHandle< Object > key, PropertyDescriptor *desc)
V8_EXPORT_PRIVATE static V8_WARN_UNUSED_RESULT Maybe< bool > SetPrototype(Isolate *isolate, DirectHandle< JSReceiver > object, DirectHandle< Object > value, bool from_javascript, ShouldThrow should_throw)
V8_EXPORT_PRIVATE static V8_WARN_UNUSED_RESULT Maybe< bool > DeleteProperty(Isolate *isolate, DirectHandle< JSReceiver > object, DirectHandle< Name > name, LanguageMode language_mode=LanguageMode::kSloppy)
static V8_WARN_UNUSED_RESULT Maybe< bool > PreventExtensions(Isolate *isolate, DirectHandle< JSReceiver > object, ShouldThrow should_throw)
static V8_WARN_UNUSED_RESULT Maybe< bool > HasInPrototypeChain(Isolate *isolate, DirectHandle< JSReceiver > object, DirectHandle< Object > proto)
static V8_WARN_UNUSED_RESULT MaybeDirectHandle< FixedArray > GetOwnValues(Isolate *isolate, DirectHandle< JSReceiver > object, PropertyFilter filter, bool try_fast_path=true)
static MaybeDirectHandle< JSPrototype > GetPrototype(Isolate *isolate, DirectHandle< JSReceiver > receiver)
static V8_WARN_UNUSED_RESULT Maybe< bool > CreateDataProperty(Isolate *isolate, DirectHandle< JSReceiver > object, DirectHandle< Name > key, DirectHandle< Object > value, Maybe< ShouldThrow > should_throw)
static V8_WARN_UNUSED_RESULT Maybe< bool > IsExtensible(Isolate *isolate, DirectHandle< JSReceiver > object)
static V8_WARN_UNUSED_RESULT Maybe< PropertyAttributes > GetPropertyAttributes(Isolate *isolate, DirectHandle< JSReceiver > object, DirectHandle< Name > name)
static V8_WARN_UNUSED_RESULT MaybeDirectHandle< FixedArray > GetOwnEntries(Isolate *isolate, DirectHandle< JSReceiver > object, PropertyFilter filter, bool try_fast_path=true)
static V8_WARN_UNUSED_RESULT Maybe< bool > CheckPrivateNameStore(LookupIterator *it, bool is_define)
static V8_WARN_UNUSED_RESULT Maybe< bool > SetOrCopyDataProperties(Isolate *isolate, DirectHandle< JSReceiver > target, DirectHandle< Object > source, PropertiesEnumerationMode mode, base::Vector< DirectHandle< Object > > excluded_properties={}, bool use_set=true)
V8_EXPORT_PRIVATE static V8_WARN_UNUSED_RESULT Maybe< bool > HasProperty(LookupIterator *it)
Definition js-objects.cc:98
static V8_WARN_UNUSED_RESULT Maybe< bool > AddPrivateField(LookupIterator *it, DirectHandle< Object > value, Maybe< ShouldThrow > should_throw)
static V8_WARN_UNUSED_RESULT MaybeDirectHandle< Object > DefineProperties(Isolate *isolate, DirectHandle< Object > object, DirectHandle< Object > properties)
static MaybeHandle< FixedArray > GetKeys(Isolate *isolate, DirectHandle< JSReceiver > object, KeyCollectionMode mode, PropertyFilter filter, GetKeysConversion keys_conversion=GetKeysConversion::kKeepNumbers, bool is_for_in=false, bool skip_indices=false)
Definition keys.cc:97
static void CompleteInobjectSlackTracking(Isolate *isolate, Tagged< Map > initial_map)
V8_WARN_UNUSED_RESULT V8_INLINE bool ToHandle(DirectHandle< S > *out) const
static V8_WARN_UNUSED_RESULT MaybeHandle< Object > ToLength(Isolate *isolate, DirectHandle< Object > input)
static V8_WARN_UNUSED_RESULT HandleType< String >::MaybeType ToString(Isolate *isolate, HandleType< T > input)
V8_EXPORT_PRIVATE static V8_WARN_UNUSED_RESULT Maybe< bool > AddDataProperty(LookupIterator *it, DirectHandle< Object > value, PropertyAttributes attributes, Maybe< ShouldThrow > should_throw, StoreOrigin store_origin, EnforceDefineSemantics semantics=EnforceDefineSemantics::kSet)
Definition objects.cc:2667
V8_EXPORT_PRIVATE static V8_WARN_UNUSED_RESULT Maybe< bool > SetProperty(LookupIterator *it, DirectHandle< Object > value, StoreOrigin store_origin, Maybe< ShouldThrow > should_throw=Nothing< ShouldThrow >())
Definition objects.cc:2439
static V8_WARN_UNUSED_RESULT HandleType< Number >::MaybeType ToNumber(Isolate *isolate, HandleType< T > input)
static V8_EXPORT_PRIVATE bool BooleanValue(Tagged< Object > obj, IsolateT *isolate)
static V8_WARN_UNUSED_RESULT HandleType< JSReceiver >::MaybeType ToObject(Isolate *isolate, HandleType< T > object, const char *method_name=nullptr)
static V8_EXPORT_PRIVATE MaybeDirectHandle< String > NoSideEffectsToMaybeString(Isolate *isolate, DirectHandle< Object > input)
Definition objects.cc:584
static V8_WARN_UNUSED_RESULT HandleType< Name >::MaybeType ToName(Isolate *isolate, HandleType< Object > input)
V8_EXPORT_PRIVATE static V8_WARN_UNUSED_RESULT MaybeHandle< Object > GetProperty(LookupIterator *it, bool is_global_reference=false)
Definition objects.cc:1248
static V8_WARN_UNUSED_RESULT HandleType< Object >::MaybeType ToNumeric(Isolate *isolate, HandleType< T > input)
static constexpr PropertyConstness kConstIfDictConstnessTracking
Tagged< Smi > AsSmi() const
Definition objects-inl.h:79
V8_EXPORT_PRIVATE static V8_WARN_UNUSED_RESULT MaybeDirectHandle< Object > SetPrivateMember(Isolate *isolate, DirectHandle< JSReceiver > receiver, DirectHandle< String > desc, DirectHandle< Object > value)
static V8_WARN_UNUSED_RESULT MaybeDirectHandle< Object > HasProperty(Isolate *isolate, DirectHandle< Object > object, DirectHandle< Object > key)
V8_EXPORT_PRIVATE static V8_WARN_UNUSED_RESULT MaybeDirectHandle< Object > SetObjectProperty(Isolate *isolate, DirectHandle< JSAny > object, DirectHandle< Object > key, DirectHandle< Object > value, MaybeDirectHandle< JSAny > receiver, StoreOrigin store_origin, Maybe< ShouldThrow > should_throw=Nothing< ShouldThrow >())
V8_EXPORT_PRIVATE static V8_WARN_UNUSED_RESULT Maybe< bool > DeleteObjectProperty(Isolate *isolate, DirectHandle< JSReceiver > receiver, DirectHandle< Object > key, LanguageMode language_mode)
V8_EXPORT_PRIVATE static V8_WARN_UNUSED_RESULT MaybeDirectHandle< Object > GetObjectProperty(Isolate *isolate, DirectHandle< JSAny > lookup_start_object, DirectHandle< Object > key, DirectHandle< JSAny > receiver={}, bool *is_found=nullptr)
V8_EXPORT_PRIVATE static V8_WARN_UNUSED_RESULT MaybeDirectHandle< Object > DefineObjectOwnProperty(Isolate *isolate, DirectHandle< JSAny > object, DirectHandle< Object > key, DirectHandle< Object > value, StoreOrigin store_origin)
V8_EXPORT_PRIVATE static V8_WARN_UNUSED_RESULT MaybeDirectHandle< Object > GetPrivateMember(Isolate *isolate, DirectHandle< JSReceiver > receiver, DirectHandle< String > desc)
static constexpr int ToInt(const Tagged< Object > object)
Definition smi.h:33
static constexpr Tagged< Smi > FromInt(int value)
Definition smi.h:38
static constexpr Tagged< Smi > zero()
Definition smi.h:99
static V8_INLINE HandleType< String > Flatten(Isolate *isolate, HandleType< T > string, AllocationType allocation=AllocationType::kYoung)
static HandleType< SwissNameDictionary > Shrink(Isolate *isolate, HandleType< SwissNameDictionary > table)
static HandleType< SwissNameDictionary > Add(IsolateT *isolate, HandleType< SwissNameDictionary > table, DirectHandle< Name > key, DirectHandle< Object > value, PropertyDetails details, InternalIndex *entry_out=nullptr)
static HandleType< SwissNameDictionary > DeleteEntry(Isolate *isolate, HandleType< SwissNameDictionary > table, InternalIndex entry)
#define V8_ENABLE_SWISS_NAME_DICTIONARY_BOOL
Definition globals.h:242
#define HAS_SMI_TAG(value)
Definition globals.h:1771
#define V8_DICT_PROPERTY_CONST_TRACKING_BOOL
Definition globals.h:249
#define RUNTIME_FUNCTION(Name)
Definition arguments.h:162
#define RETURN_FAILURE_IF_EXCEPTION(isolate)
Definition isolate.h:205
#define THROW_NEW_ERROR_RETURN_VALUE(isolate, call, value)
Definition isolate.h:300
#define ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, dst, call)
Definition isolate.h:284
#define ASSIGN_RETURN_ON_EXCEPTION(isolate, dst, call)
Definition isolate.h:291
#define THROW_NEW_ERROR(isolate, call)
Definition isolate.h:307
#define ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, dst, call, value)
Definition isolate.h:276
#define THROW_NEW_ERROR_RETURN_FAILURE(isolate, call)
Definition isolate.h:294
#define RETURN_FAILURE_ON_EXCEPTION(isolate, call)
Definition isolate.h:368
#define MAYBE_RETURN_NULL(call)
Definition isolate.h:413
#define MAYBE_RETURN(call, value)
Definition isolate.h:408
#define RETURN_RESULT_OR_FAILURE(isolate, call)
Definition isolate.h:264
base::Vector< const DirectHandle< Object > > args
Definition execution.cc:74
DirectHandle< Object > new_target
Definition execution.cc:75
TNode< Object > target
TNode< Object > receiver
SharedFunctionInfoRef shared
std::map< const std::string, const std::string > map
const std::string property
ZoneVector< RpoNumber > & result
ZoneVector< Entry > entries
constexpr Vector< T > VectorOf(T *start, size_t size)
Definition vector.h:360
V8_INLINE const Operation & Get(const Graph &graph, OpIndex index)
Definition graph.h:1231
@ kEnumerationOrder
Definition globals.h:2859
@ kPropertyAdditionOrder
Definition globals.h:2861
bool TryCast(Tagged< From > value, Tagged< To > *out)
Definition casting.h:77
constexpr bool IsHoleyElementsKind(ElementsKind kind)
bool IsClassConstructor(FunctionKind kind)
V8_INLINE constexpr bool IsSmi(TaggedImpl< kRefType, StorageType > obj)
Definition objects.h:665
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
Definition flags.cc:2086
Flag flags[]
Definition flags.cc:3797
bool IsNullOrUndefined(Tagged< Object > obj, Isolate *isolate)
bool IsSmiOrObjectElementsKind(ElementsKind kind)
constexpr int kSystemPointerSize
Definition globals.h:410
bool IsFastPackedElementsKind(ElementsKind kind)
DONT_OVERRIDE DISABLE_ALLOCATION_SITES HOLEY_ELEMENTS
bool IsFastElementsKind(ElementsKind kind)
static bool IsValidAccessor(Isolate *isolate, DirectHandle< Object > obj)
bool IsUniqueName(Tagged< Name > obj)
V8_INLINE PropertyAttributes PropertyAttributesFromInt(int value)
bool IsPrivateMethodOrAccessorVariableMode(VariableMode mode)
Definition globals.h:2135
return value
Definition map-inl.h:893
constexpr bool IsDoubleElementsKind(ElementsKind kind)
kInstanceDescriptorsOffset kTransitionsOrPrototypeInfoOffset IsNull(value)||IsJSProxy(value)||IsWasmObject(value)||(IsJSObject(value) &&(HeapLayout
Definition map-inl.h:70
kInstanceDescriptorsOffset kTransitionsOrPrototypeInfoOffset prototype
Definition map-inl.h:69
@ KEEP_INOBJECT_PROPERTIES
Definition objects.h:62
Tagged< To > Cast(Tagged< From > value, const v8::SourceLocation &loc=INIT_SOURCE_LOCATION_IN_DEBUG)
Definition casting.h:150
Local< T > Handle
Maybe< T > Nothing()
Definition v8-maybe.h:112
static constexpr AcquireLoadTag kAcquireLoad
Definition globals.h:2908
Maybe< T > Just(const T &t)
Definition v8-maybe.h:117
PropertyFilter
Definition v8-object.h:179
#define CHECK(condition)
Definition logging.h:124
#define DCHECK_IMPLIES(v1, v2)
Definition logging.h:493
#define DCHECK_NE(v1, v2)
Definition logging.h:486
#define DCHECK_GE(v1, v2)
Definition logging.h:488
#define CHECK_EQ(lhs, rhs)
#define DCHECK(condition)
Definition logging.h:482
#define DCHECK_LT(v1, v2)
Definition logging.h:489
#define DCHECK_EQ(v1, v2)
Definition logging.h:485
#define USE(...)
Definition macros.h:293
Handle< Object > brand_or_field_symbol
#define V8_UNLIKELY(condition)
Definition v8config.h:660