33 Factory* factory = isolate->factory();
39 raw->set_is_sloppy(
false);
40 raw->set_replace_on_access(
false);
45 if (
setter ==
nullptr)
setter = &ReconfigureToDataProperty;
67 if (map->is_dictionary_map()) {
72 switch (map->instance_type()) {
74 return CheckForName(isolate, name, isolate->factory()->length_string(),
78 return CheckForName(isolate, name, isolate->factory()->length_string(),
98 CHECK(it.HasAccess());
103 it.ReconfigureDataProperty(value, it.property_attributes());
114void
Accessors::ReconfigureToDataProperty(
118 RCS_SCOPE(isolate, RuntimeCallCounterId::kReconfigureToDataProperty);
126 isolate,
receiver, holder, name, value);
128 info.GetReturnValue().Set(
true);
136void Accessors::ArgumentsIteratorGetter(
140 HandleScope scope(isolate);
142 info.GetReturnValue().Set(
143 Utils::ToLocal(DirectHandle<Object>(
result, isolate)));
146DirectHandle<AccessorInfo> Accessors::MakeArgumentsIteratorInfo(
148 DirectHandle<Name> name = isolate->factory()->iterator_symbol();
149 return MakeAccessor(isolate, name, &ArgumentsIteratorGetter,
nullptr);
156void Accessors::ArrayLengthGetter(
159 RCS_SCOPE(isolate, RuntimeCallCounterId::kArrayLengthGetter);
161 HandleScope scope(isolate);
165 info.GetReturnValue().Set(
166 Utils::ToLocal(DirectHandle<Object>(
result, isolate)));
169void Accessors::ArrayLengthSetter(
173 RCS_SCOPE(isolate, RuntimeCallCounterId::kArrayLengthSetter);
174 HandleScope scope(isolate);
177 ReadOnlyRoots(isolate).length_string()));
196 info.GetReturnValue().Set(
true);
197 }
else if (info.ShouldThrowOnError()) {
198 Factory* factory = isolate->factory();
200 *factory->NewTypeError(MessageTemplate::kStrictReadOnlyProperty,
202 i::Object::TypeOf(isolate,
object),
object));
204 info.GetReturnValue().Set(
false);
212 FATAL(
"Fatal JavaScript invalid array length %u", length);
216 uint32_t actual_new_len = 0;
219 if (actual_new_len != length) {
220 if (info.ShouldThrowOnError()) {
221 Factory* factory = isolate->factory();
222 isolate->Throw(*factory->NewTypeError(
223 MessageTemplate::kStrictDeleteProperty,
224 factory->NewNumberFromUint(actual_new_len - 1), array));
226 info.GetReturnValue().Set(
false);
229 info.GetReturnValue().Set(
true);
233DirectHandle<AccessorInfo> Accessors::MakeArrayLengthInfo(Isolate* isolate) {
234 return MakeAccessor(isolate, isolate->factory()->length_string(),
235 &ArrayLengthGetter, &ArrayLengthSetter);
242void Accessors::ModuleNamespaceEntryGetter(
245 HandleScope scope(isolate);
248 DirectHandle<Object>
result;
251 info.GetReturnValue().Set(Utils::ToLocal(
result));
255void Accessors::ModuleNamespaceEntrySetter(
259 HandleScope scope(isolate);
260 Factory* factory = isolate->factory();
261 DirectHandle<JSModuleNamespace> holder =
264 if (info.ShouldThrowOnError()) {
266 *factory->NewTypeError(MessageTemplate::kStrictReadOnlyProperty,
268 i::Object::TypeOf(isolate, holder), holder));
270 info.GetReturnValue().Set(
false);
276 return MakeAccessor(isolate, name, &ModuleNamespaceEntryGetter,
277 &ModuleNamespaceEntrySetter);
284void Accessors::StringLengthGetter(
287 RCS_SCOPE(isolate, RuntimeCallCounterId::kStringLengthGetter);
298 if (!IsString(value)) {
305 info.GetReturnValue().Set(
306 Utils::ToLocal(DirectHandle<Object>(
result, isolate)));
309DirectHandle<AccessorInfo> Accessors::MakeStringLengthInfo(Isolate* isolate) {
310 return MakeAccessor(isolate, isolate->factory()->length_string(),
311 &StringLengthGetter,
nullptr);
320 if (!function->has_prototype()) {
328 isolate->factory()->NewFunctionPrototype(function);
334void Accessors::FunctionPrototypeGetter(
337 RCS_SCOPE(isolate, RuntimeCallCounterId::kFunctionPrototypeGetter);
339 DirectHandle<JSFunction> function =
341 DCHECK(function->has_prototype_property());
343 info.GetReturnValue().Set(Utils::ToLocal(
result));
346void Accessors::FunctionPrototypeSetter(
350 RCS_SCOPE(isolate, RuntimeCallCounterId::kFunctionPrototypeSetter);
351 HandleScope scope(isolate);
353 DirectHandle<JSFunction>
object =
355 DCHECK(object->has_prototype_property());
357 info.GetReturnValue().Set(
true);
360DirectHandle<AccessorInfo> Accessors::MakeFunctionPrototypeInfo(
362 return MakeAccessor(isolate, isolate->factory()->prototype_string(),
363 &FunctionPrototypeGetter, &FunctionPrototypeSetter);
370void Accessors::FunctionLengthGetter(
373 RCS_SCOPE(isolate, RuntimeCallCounterId::kFunctionLengthGetter);
374 HandleScope scope(isolate);
376 int length = function->length();
378 info.GetReturnValue().Set(Utils::ToLocal(
result));
381DirectHandle<AccessorInfo> Accessors::MakeFunctionLengthInfo(Isolate* isolate) {
382 return MakeAccessor(isolate, isolate->factory()->length_string(),
383 &FunctionLengthGetter, &ReconfigureToDataProperty);
390void Accessors::FunctionNameGetter(
393 HandleScope scope(isolate);
396 info.GetReturnValue().Set(Utils::ToLocal(
result));
399DirectHandle<AccessorInfo> Accessors::MakeFunctionNameInfo(Isolate* isolate) {
400 return MakeAccessor(isolate, isolate->factory()->name_string(),
401 &FunctionNameGetter, &ReconfigureToDataProperty);
411 int inlined_frame_index) {
412 Isolate* isolate = frame->isolate();
413 Factory* factory = isolate->factory();
415 TranslatedState translated_values(frame);
416 translated_values.Prepare(frame->fp());
418 int argument_count = 0;
419 TranslatedFrame* translated_frame =
420 translated_values.GetArgumentsInfoFromJSFrameIndex(inlined_frame_index,
422 TranslatedFrame::iterator iter = translated_frame->begin();
425 bool should_deoptimize = iter->IsMaterializedObject();
434 factory->NewArgumentsObject(function, argument_count);
435 DirectHandle<FixedArray> array = factory->NewFixedArray(argument_count);
436 for (
int i = 0;
i < argument_count; ++
i) {
439 should_deoptimize = should_deoptimize || iter->IsMaterializedObject();
440 DirectHandle<Object> value = iter->GetValue();
441 array->set(
i, *value);
444 arguments->set_elements(*array);
446 if (should_deoptimize) {
447 translated_values.StoreMaterializedValuesAndDeopt(frame);
454int FindFunctionInFrame(JavaScriptFrame* frame,
455 DirectHandle<JSFunction> function) {
456 FrameSummaries summaries = frame->Summarize();
457 for (
int i = summaries.
size();
i != 0;
i--) {
458 if (*summaries.frames[
i - 1].AsJavaScript().function() == *function) {
459 return static_cast<int>(
i) - 1;
466 JavaScriptStackFrameIterator* it,
467 int function_index) {
468 JavaScriptFrame* frame = it->frame();
470 if (function_index > 0) {
475 return ArgumentsFromDeoptInfo(frame, function_index);
480 const int length = frame->GetActualArgumentCount();
481 DirectHandle<JSFunction> function(frame->function(), isolate);
483 isolate->factory()->NewArgumentsObject(function, length);
484 DirectHandle<FixedArray> array = isolate->factory()->NewFixedArray(length);
487 DCHECK(array->length() == length);
490 if (IsTheHole(value, isolate)) {
494 value = ReadOnlyRoots(isolate).undefined_value();
496 array->set(
i, value);
498 arguments->set_elements(*array);
504 DirectHandle<JSObject> arguments_from_deopt_info =
505 ArgumentsFromDeoptInfo(frame, function_index);
506 DirectHandle<FixedArray> elements_from_deopt_info(
508 int common_length = std::min(length, elements_from_deopt_info->length());
509 for (
int i = 0;
i < common_length;
i++) {
510 array->set(
i, elements_from_deopt_info->
get(
i));
521 int inlined_jsframe_index) {
523 Address requested_frame_fp = frame->
fp();
527 if (it.frame()->fp() != requested_frame_fp)
continue;
528 return GetFrameArguments(isolate, &it, inlined_jsframe_index);
533void Accessors::FunctionArgumentsGetter(
540 if (!function->shared()->native()) {
544 int function_index = FindFunctionInFrame(frame, function);
545 if (function_index >= 0) {
546 result = GetFrameArguments(isolate, &it, function_index);
551 info.GetReturnValue().Set(Utils::ToLocal(
result));
554DirectHandle<AccessorInfo> Accessors::MakeFunctionArgumentsInfo(
556 return MakeAccessor(isolate, isolate->factory()->arguments_string(),
557 &FunctionArgumentsGetter,
nullptr);
566 return current_context->HasSameSecurityTokenAs(function->context());
581 }
while (!
function_.is_identical_to(function));
592 }
while (
function_->shared()->is_toplevel() ||
594 !
function_->shared()->IsUserJavaScript()));
615 bool should_deoptimize = iter->IsMaterializedObject();
617 if (should_deoptimize) {
642 return next_function;
663 if (function->shared()->native()) {
668 if (!it.Find(function)) {
674 if (!it.FindNextNonTopLevelNativeOrUserJavaScript()) {
687 if (
is_strict(caller->shared()->language_mode())) {
697void Accessors::FunctionCallerGetter(
702 DirectHandle<JSFunction> function =
704 DirectHandle<Object>
result;
705 MaybeDirectHandle<JSFunction> maybe_caller;
707 DirectHandle<JSFunction> caller;
709 if (!
v8_flags.correctness_fuzzer_suppressions &&
710 maybe_caller.ToHandle(&caller)) {
713 result = isolate->factory()->null_value();
715 info.GetReturnValue().Set(Utils::ToLocal(
result));
718DirectHandle<AccessorInfo> Accessors::MakeFunctionCallerInfo(Isolate* isolate) {
719 return MakeAccessor(isolate, isolate->factory()->caller_string(),
720 &FunctionCallerGetter,
nullptr);
727void Accessors::BoundFunctionLengthGetter(
730 RCS_SCOPE(isolate, RuntimeCallCounterId::kBoundFunctionLengthGetter);
731 HandleScope scope(isolate);
732 DirectHandle<JSBoundFunction> function =
740 info.GetReturnValue().Set(Utils::ToLocal(
result));
743DirectHandle<AccessorInfo> Accessors::MakeBoundFunctionLengthInfo(
745 return MakeAccessor(isolate, isolate->factory()->length_string(),
746 &BoundFunctionLengthGetter, &ReconfigureToDataProperty);
753void Accessors::BoundFunctionNameGetter(
756 RCS_SCOPE(isolate, RuntimeCallCounterId::kBoundFunctionNameGetter);
757 HandleScope scope(isolate);
758 DirectHandle<JSBoundFunction> function =
760 DirectHandle<Object>
result;
764 info.GetReturnValue().Set(Utils::ToLocal(
result));
767DirectHandle<AccessorInfo> Accessors::MakeBoundFunctionNameInfo(
769 return MakeAccessor(isolate, isolate->factory()->name_string(),
770 &BoundFunctionNameGetter, &ReconfigureToDataProperty);
777void Accessors::WrappedFunctionLengthGetter(
780 RCS_SCOPE(isolate, RuntimeCallCounterId::kBoundFunctionLengthGetter);
781 HandleScope scope(isolate);
790 info.GetReturnValue().Set(Utils::ToLocal(
result));
793DirectHandle<AccessorInfo> Accessors::MakeWrappedFunctionLengthInfo(
795 return MakeAccessor(isolate, isolate->factory()->length_string(),
796 &WrappedFunctionLengthGetter, &ReconfigureToDataProperty);
803void Accessors::ValueUnavailableGetter(
805 Isolate* isolate =
reinterpret_cast<Isolate*
>(info.GetIsolate());
806 HandleScope scope(isolate);
807 isolate->Throw(*isolate->factory()->NewReferenceError(
808 MessageTemplate::kAccessedUnavailableVariable,
812DirectHandle<AccessorInfo> Accessors::MakeValueUnavailableInfo(
814 return MakeAccessor(isolate, isolate->factory()->empty_string(),
815 &ValueUnavailableGetter, &ReconfigureToDataProperty);
822void Accessors::WrappedFunctionNameGetter(
825 RCS_SCOPE(isolate, RuntimeCallCounterId::kWrappedFunctionNameGetter);
826 HandleScope scope(isolate);
829 DirectHandle<Object>
result;
833 info.GetReturnValue().Set(Utils::ToLocal(
result));
836DirectHandle<AccessorInfo> Accessors::MakeWrappedFunctionNameInfo(
838 return MakeAccessor(isolate, isolate->factory()->name_string(),
839 &WrappedFunctionNameGetter, &ReconfigureToDataProperty);
850void Accessors::ErrorStackGetter(
851 const
v8::FunctionCallbackInfo<
v8::Value>& info) {
852 Isolate* isolate =
reinterpret_cast<Isolate*
>(info.GetIsolate());
853 HandleScope scope(isolate);
854 DirectHandle<Object> formatted_stack = isolate->factory()->undefined_value();
855 DirectHandle<JSReceiver> maybe_error_object =
857 if (IsJSObject(*maybe_error_object)) {
860 .ToHandle(&formatted_stack)) {
866 info.GetReturnValue().Set(
result);
869void Accessors::ErrorStackSetter(
871 Isolate* isolate =
reinterpret_cast<Isolate*
>(info.GetIsolate());
872 HandleScope scope(isolate);
873 DirectHandle<JSReceiver> maybe_error_object =
875 if (IsJSObject(*maybe_error_object)) {
@ kFunctionPrototypeCaller
@ kFunctionPrototypeArguments
static v8::internal::DirectHandle< To > OpenDirectHandle(v8::Local< From > handle)
static MaybeDirectHandle< Object > ReplaceAccessorWithDataProperty(Isolate *isolate, DirectHandle< JSAny > receiver, DirectHandle< JSObject > holder, DirectHandle< Name > name, DirectHandle< Object > value)
static DirectHandle< AccessorInfo > MakeModuleNamespaceEntryInfo(Isolate *isolate, DirectHandle< String > name)
static V8_EXPORT_PRIVATE DirectHandle< AccessorInfo > MakeAccessor(Isolate *isolate, DirectHandle< Name > name, AccessorNameGetterCallback getter, AccessorNameBooleanSetterCallback setter)
static bool IsJSObjectFieldAccessor(Isolate *isolate, DirectHandle< Map > map, DirectHandle< Name > name, FieldIndex *field_index)
static Handle< JSObject > FunctionGetArguments(JavaScriptFrame *frame, int inlined_jsframe_index)
void(*)(Local< v8::Name > property, Local< v8::Value > value, const PropertyCallbackInfo< v8::Boolean > &info) AccessorNameBooleanSetterCallback
FrameSummaries Summarize() const override
V8_INLINE bool is_identical_to(Handle< S > other) const
static MaybeDirectHandle< Object > GetFormattedStack(Isolate *isolate, DirectHandle< JSObject > maybe_error_object)
static void SetFormattedStack(Isolate *isolate, DirectHandle< JSObject > maybe_error_object, DirectHandle< Object > formatted_stack)
DirectHandle< AccessorInfo > NewAccessorInfo()
Handle< Name > InternalizeName(Handle< T > name)
static FieldIndex ForInObjectOffset(int offset, Encoding encoding)
DirectHandle< JSFunction > MaterializeFunction()
bool FindNextNonTopLevelNativeOrUserJavaScript()
bool Find(DirectHandle< JSFunction > function)
MaybeDirectHandle< JSFunction > next()
DirectHandle< JSFunction > function_
FrameSummaries summaries_
JavaScriptStackFrameIterator frame_iterator_
FrameFunctionIterator(Isolate *isolate)
void CountUsage(v8::Isolate::UseCounterFeature feature)
Tagged< Context > context() const
static bool AnythingToArrayLength(Isolate *isolate, DirectHandle< Object > length_object, uint32_t *output)
static V8_EXPORT_PRIVATE Maybe< bool > SetLength(DirectHandle< JSArray > array, uint32_t length)
static bool HasReadOnlyLength(DirectHandle< JSArray > array)
static MaybeHandle< String > GetName(Isolate *isolate, DirectHandle< JSBoundFunction > function)
static Maybe< int > GetLength(Isolate *isolate, DirectHandle< JSBoundFunction > function)
static void SetPrototype(DirectHandle< JSFunction > function, DirectHandle< Object > value)
static Handle< String > GetName(Isolate *isolate, DirectHandle< JSFunction > function)
static Maybe< int > GetLength(Isolate *isolate, DirectHandle< JSWrappedFunction > function)
static MaybeHandle< String > GetName(Isolate *isolate, DirectHandle< JSWrappedFunction > function)
JavaScriptFrame * frame() const
V8_EXPORT_PRIVATE void Advance()
bool Equals(Tagged< Name > other)
static bool ToArrayLength(Tagged< Object > obj, uint32_t *index)
static double NumberValue(Tagged< Number > obj)
static V8_EXPORT_PRIVATE bool SameValue(Tagged< Object > obj, Tagged< Object > other)
static constexpr Tagged< Smi > FromInt(int value)
Isolate * isolate() const
void StoreMaterializedValuesAndDeopt(JavaScriptFrame *frame)
TranslatedFrame * GetFrameFromJSFrameIndex(int jsframe_index)
void Prepare(Address stack_frame_pointer)
Handle< SharedFunctionInfo > info
ZoneVector< RpoNumber > & result
PerThreadAssertScopeDebugOnly< false, SAFEPOINTS_ASSERT, HEAP_ALLOCATION_ASSERT > DisallowGarbageCollection
Tagged(T object) -> Tagged< T >
static bool AllowAccessToFunction(Tagged< Context > current_context, Tagged< JSFunction > function)
bool IsResumableFunction(FunctionKind kind)
static V8_INLINE bool CheckForName(Isolate *isolate, DirectHandle< Name > name, DirectHandle< String > property_name, int offset, FieldIndex::Encoding encoding, FieldIndex *index)
bool is_strict(LanguageMode language_mode)
V8_EXPORT_PRIVATE FlagValues v8_flags
static DirectHandle< Object > GetFunctionPrototype(Isolate *isolate, DirectHandle< JSFunction > function)
MaybeDirectHandle< JSFunction > FindCaller(Isolate *isolate, DirectHandle< JSFunction > function)
constexpr bool CodeKindCanDeoptimize(CodeKind kind)
Tagged< To > Cast(Tagged< From > value, const v8::SourceLocation &loc=INIT_SOURCE_LOCATION_IN_DEBUG)
void(*)(Local< Name > property, const PropertyCallbackInfo< Value > &info) AccessorNameGetterCallback
#define CHECK_EQ(lhs, rhs)
#define DCHECK(condition)
#define DCHECK_LT(v1, v2)
#define DCHECK_EQ(v1, v2)
std::vector< FrameSummary > frames
#define END_ALLOW_USE_DEPRECATED()
#define V8_WARN_UNUSED_RESULT
#define V8_UNLIKELY(condition)
#define START_ALLOW_USE_DEPRECATED()