Reland "Change SetProperty/SetSuperProperty to infer language mode when possible"

This is a reland of 0896599f6f with a fix for
failing layout test.

Original change's description:
> Change SetProperty/SetSuperProperty to infer language mode when possible
>
> In most cases, the language mode can be inferred from the closure and
> the context. Computing the language mode instead of passing it around
> simplifies the ICs and will make it possible to go towards lazily
> allocating feedback vectors. Currently ICs obtain the language mode from
> the feedback vectors and with lazy feedback allocation we may not always
> have feedback vectors. Since computing language mode is a bit expensive
> we want to defer it as far as possible.
>
> In Array builtins and other builtins like Reflect.Set we need to force a
> language mode when setting the properties. To support these cases the
> SetProperty methods allow the language mode to be overridden when needed.
>
> This is a first cl in a series of cls, that will defer the language mode
> computation further and remove language mode where it is not needed.
>
> BUG: v8:8580
> Change-Id: I9c2396e3bcfe77c3c9d6760c46d86954d54744b9
> Reviewed-on: https://chromium-review.googlesource.com/c/1409426
> Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
> Reviewed-by: Jakob Gruber <jgruber@chromium.org>
> Reviewed-by: Toon Verwaest <verwaest@chromium.org>
> Commit-Queue: Mythri Alle <mythria@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#58893}

TBR: ahaas@chromium.org
Change-Id: Id5d81eae91b55638dbc72168f0e5203e684869fb
Reviewed-on: https://chromium-review.googlesource.com/c/1421077
Commit-Queue: Mythri Alle <mythria@chromium.org>
Reviewed-by: Ross McIlroy <rmcilroy@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: Toon Verwaest <verwaest@chromium.org>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59075}
This commit is contained in:
Mythri 2019-01-23 16:34:14 +00:00 committed by Commit Bot
parent d4f3da010e
commit e2846ea6e4
28 changed files with 260 additions and 307 deletions

View File

@ -796,7 +796,8 @@ MaybeHandle<JSReceiver> ClearInternalStackTrace(Isolate* isolate,
isolate, isolate,
Object::SetProperty( Object::SetProperty(
isolate, error, isolate->factory()->stack_trace_symbol(), isolate, error, isolate->factory()->stack_trace_symbol(),
isolate->factory()->undefined_value(), LanguageMode::kStrict), isolate->factory()->undefined_value(), StoreOrigin::kMaybeKeyed,
Just(LanguageMode::kStrict)),
JSReceiver); JSReceiver);
return error; return error;
} }

View File

@ -4005,8 +4005,8 @@ Maybe<bool> v8::Object::Set(v8::Local<v8::Context> context,
auto value_obj = Utils::OpenHandle(*value); auto value_obj = Utils::OpenHandle(*value);
has_pending_exception = has_pending_exception =
i::Runtime::SetObjectProperty(isolate, self, key_obj, value_obj, i::Runtime::SetObjectProperty(isolate, self, key_obj, value_obj,
i::LanguageMode::kSloppy, i::StoreOrigin::kMaybeKeyed,
i::StoreOrigin::kMaybeKeyed) Just(i::LanguageMode::kSloppy))
.is_null(); .is_null();
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
return Just(true); return Just(true);

View File

@ -176,7 +176,8 @@ V8_WARN_UNUSED_RESULT MaybeHandle<Object> SetLengthProperty(
return Object::SetProperty( return Object::SetProperty(
isolate, receiver, isolate->factory()->length_string(), isolate, receiver, isolate->factory()->length_string(),
isolate->factory()->NewNumber(length), LanguageMode::kStrict); isolate->factory()->NewNumber(length), StoreOrigin::kMaybeKeyed,
Just(LanguageMode::kStrict));
} }
V8_WARN_UNUSED_RESULT Object GenericArrayFill(Isolate* isolate, V8_WARN_UNUSED_RESULT Object GenericArrayFill(Isolate* isolate,
@ -192,7 +193,7 @@ V8_WARN_UNUSED_RESULT Object GenericArrayFill(Isolate* isolate,
// b. Perform ? Set(O, Pk, value, true). // b. Perform ? Set(O, Pk, value, true).
RETURN_FAILURE_ON_EXCEPTION( RETURN_FAILURE_ON_EXCEPTION(
isolate, Object::SetPropertyOrElement(isolate, receiver, index, value, isolate, Object::SetPropertyOrElement(isolate, receiver, index, value,
LanguageMode::kStrict)); Just(LanguageMode::kStrict)));
// c. Increase k by 1. // c. Increase k by 1.
++start; ++start;
@ -339,8 +340,8 @@ V8_WARN_UNUSED_RESULT Object GenericArrayPush(Isolate* isolate,
isolate, receiver, isolate->factory()->NewNumber(length), &success); isolate, receiver, isolate->factory()->NewNumber(length), &success);
// Must succeed since we always pass a valid key. // Must succeed since we always pass a valid key.
DCHECK(success); DCHECK(success);
MAYBE_RETURN(Object::SetProperty(&it, element, LanguageMode::kStrict, MAYBE_RETURN(Object::SetProperty(&it, element, StoreOrigin::kMaybeKeyed,
StoreOrigin::kMaybeKeyed), Just(LanguageMode::kStrict)),
ReadOnlyRoots(isolate).exception()); ReadOnlyRoots(isolate).exception());
} }
@ -353,7 +354,8 @@ V8_WARN_UNUSED_RESULT Object GenericArrayPush(Isolate* isolate,
RETURN_FAILURE_ON_EXCEPTION( RETURN_FAILURE_ON_EXCEPTION(
isolate, Object::SetProperty(isolate, receiver, isolate, Object::SetProperty(isolate, receiver,
isolate->factory()->length_string(), isolate->factory()->length_string(),
final_length, LanguageMode::kStrict)); final_length, StoreOrigin::kMaybeKeyed,
Just(LanguageMode::kStrict)));
// 8. Return len. // 8. Return len.
return *final_length; return *final_length;
@ -408,7 +410,8 @@ V8_WARN_UNUSED_RESULT Object GenericArrayPop(Isolate* isolate,
RETURN_FAILURE_ON_EXCEPTION( RETURN_FAILURE_ON_EXCEPTION(
isolate, Object::SetProperty( isolate, Object::SetProperty(
isolate, receiver, isolate->factory()->length_string(), isolate, receiver, isolate->factory()->length_string(),
Handle<Smi>(Smi::zero(), isolate), LanguageMode::kStrict)); Handle<Smi>(Smi::zero(), isolate),
StoreOrigin::kMaybeKeyed, Just(LanguageMode::kStrict)));
// b. Return undefined. // b. Return undefined.
return ReadOnlyRoots(isolate).undefined_value(); return ReadOnlyRoots(isolate).undefined_value();
@ -435,7 +438,8 @@ V8_WARN_UNUSED_RESULT Object GenericArrayPop(Isolate* isolate,
RETURN_FAILURE_ON_EXCEPTION( RETURN_FAILURE_ON_EXCEPTION(
isolate, Object::SetProperty(isolate, receiver, isolate, Object::SetProperty(isolate, receiver,
isolate->factory()->length_string(), isolate->factory()->length_string(),
new_length, LanguageMode::kStrict)); new_length, StoreOrigin::kMaybeKeyed,
Just(LanguageMode::kStrict)));
// f. Return element. // f. Return element.
return *element; return *element;
@ -526,7 +530,7 @@ V8_WARN_UNUSED_RESULT Object GenericArrayShift(Isolate* isolate,
// ii. Perform ? Set(O, to, fromVal, true). // ii. Perform ? Set(O, to, fromVal, true).
RETURN_FAILURE_ON_EXCEPTION( RETURN_FAILURE_ON_EXCEPTION(
isolate, Object::SetPropertyOrElement(isolate, receiver, to, from_val, isolate, Object::SetPropertyOrElement(isolate, receiver, to, from_val,
LanguageMode::kStrict)); Just(LanguageMode::kStrict)));
} else { // e. Else fromPresent is false, } else { // e. Else fromPresent is false,
// i. Perform ? DeletePropertyOrThrow(O, to). // i. Perform ? DeletePropertyOrThrow(O, to).
MAYBE_RETURN(JSReceiver::DeletePropertyOrElement(receiver, to, MAYBE_RETURN(JSReceiver::DeletePropertyOrElement(receiver, to,
@ -731,9 +735,9 @@ class ArrayConcatVisitor {
isolate_->factory()->NewNumber(static_cast<double>(index_offset_)); isolate_->factory()->NewNumber(static_cast<double>(index_offset_));
RETURN_ON_EXCEPTION( RETURN_ON_EXCEPTION(
isolate_, isolate_,
Object::SetProperty(isolate_, result, Object::SetProperty(
isolate_->factory()->length_string(), length, isolate_, result, isolate_->factory()->length_string(), length,
LanguageMode::kStrict), StoreOrigin::kMaybeKeyed, Just(LanguageMode::kStrict)),
JSReceiver); JSReceiver);
return result; return result;
} }

View File

@ -218,7 +218,7 @@ BUILTIN(ReflectSet) {
LookupIterator it = LookupIterator::PropertyOrElement( LookupIterator it = LookupIterator::PropertyOrElement(
isolate, receiver, name, Handle<JSReceiver>::cast(target)); isolate, receiver, name, Handle<JSReceiver>::cast(target));
Maybe<bool> result = Object::SetSuperProperty( Maybe<bool> result = Object::SetSuperProperty(
&it, value, LanguageMode::kSloppy, StoreOrigin::kMaybeKeyed); &it, value, StoreOrigin::kMaybeKeyed, Just(LanguageMode::kSloppy));
MAYBE_RETURN(result, ReadOnlyRoots(isolate).exception()); MAYBE_RETURN(result, ReadOnlyRoots(isolate).exception());
return *isolate->factory()->ToBoolean(result.FromJust()); return *isolate->factory()->ToBoolean(result.FromJust());
} }

View File

@ -1723,7 +1723,8 @@ void Debug::OnException(Handle<Object> exception, Handle<Object> promise,
Handle<JSObject> jspromise = Handle<JSObject>::cast(promise); Handle<JSObject> jspromise = Handle<JSObject>::cast(promise);
// Mark the promise as already having triggered a message. // Mark the promise as already having triggered a message.
Handle<Symbol> key = isolate_->factory()->promise_debug_marker_symbol(); Handle<Symbol> key = isolate_->factory()->promise_debug_marker_symbol();
Object::SetProperty(isolate_, jspromise, key, key, LanguageMode::kStrict) Object::SetProperty(isolate_, jspromise, key, key, StoreOrigin::kMaybeKeyed,
Just(LanguageMode::kStrict))
.Assert(); .Assert();
// Check whether the promise reject is considered an uncaught exception. // Check whether the promise reject is considered an uncaught exception.
uncaught = !isolate_->PromiseHasUserDefinedRejectHandler(jspromise); uncaught = !isolate_->PromiseHasUserDefinedRejectHandler(jspromise);

View File

@ -3875,11 +3875,11 @@ Handle<JSObject> Factory::NewArgumentsObject(Handle<JSFunction> callee,
Handle<JSObject> result = NewJSObjectFromMap(map); Handle<JSObject> result = NewJSObjectFromMap(map);
Handle<Smi> value(Smi::FromInt(length), isolate()); Handle<Smi> value(Smi::FromInt(length), isolate());
Object::SetProperty(isolate(), result, length_string(), value, Object::SetProperty(isolate(), result, length_string(), value,
LanguageMode::kStrict) StoreOrigin::kMaybeKeyed, Just(LanguageMode::kStrict))
.Assert(); .Assert();
if (!strict_mode_callee) { if (!strict_mode_callee) {
Object::SetProperty(isolate(), result, callee_string(), callee, Object::SetProperty(isolate(), result, callee_string(), callee,
LanguageMode::kStrict) StoreOrigin::kMaybeKeyed, Just(LanguageMode::kStrict))
.Assert(); .Assert();
} }
return result; return result;

View File

@ -1402,8 +1402,7 @@ MaybeHandle<Object> StoreIC::Store(Handle<Object> object, Handle<Name> name,
if (MigrateDeprecated(object)) { if (MigrateDeprecated(object)) {
Handle<Object> result; Handle<Object> result;
ASSIGN_RETURN_ON_EXCEPTION( ASSIGN_RETURN_ON_EXCEPTION(
isolate(), result, isolate(), result, Object::SetProperty(isolate(), object, name, value),
Object::SetProperty(isolate(), object, name, value, language_mode()),
Object); Object);
return result; return result;
} }
@ -1443,8 +1442,7 @@ MaybeHandle<Object> StoreIC::Store(Handle<Object> object, Handle<Name> name,
} }
if (use_ic) UpdateCaches(&it, value, store_origin); if (use_ic) UpdateCaches(&it, value, store_origin);
MAYBE_RETURN_NULL( MAYBE_RETURN_NULL(Object::SetProperty(&it, value, store_origin));
Object::SetProperty(&it, value, language_mode(), store_origin));
return value; return value;
} }
@ -2008,7 +2006,7 @@ MaybeHandle<Object> KeyedStoreIC::Store(Handle<Object> object,
ASSIGN_RETURN_ON_EXCEPTION( ASSIGN_RETURN_ON_EXCEPTION(
isolate(), result, isolate(), result,
Runtime::SetObjectProperty(isolate(), object, key, value, Runtime::SetObjectProperty(isolate(), object, key, value,
language_mode(), StoreOrigin::kMaybeKeyed), StoreOrigin::kMaybeKeyed),
Object); Object);
return result; return result;
} }
@ -2083,7 +2081,7 @@ MaybeHandle<Object> KeyedStoreIC::Store(Handle<Object> object,
Handle<JSArray>::cast(object)->elements()->IsCowArray(); Handle<JSArray>::cast(object)->elements()->IsCowArray();
ASSIGN_RETURN_ON_EXCEPTION( ASSIGN_RETURN_ON_EXCEPTION(
isolate(), store_handle, isolate(), store_handle,
Runtime::SetObjectProperty(isolate(), object, key, value, language_mode(), Runtime::SetObjectProperty(isolate(), object, key, value,
StoreOrigin::kMaybeKeyed), StoreOrigin::kMaybeKeyed),
Object); Object);
@ -2176,20 +2174,6 @@ void StoreInArrayLiteralIC::Store(Handle<JSArray> array, Handle<Object> index,
// Static IC stub generators. // Static IC stub generators.
// //
// //
namespace {
// TODO(8580): Compute the language mode lazily to avoid the expensive
// computation of language mode here.
LanguageMode GetLanguageMode(Handle<FeedbackVector> vector, Context context) {
LanguageMode language_mode = vector->shared_function_info()->language_mode();
if (context->scope_info()->language_mode() > language_mode) {
return context->scope_info()->language_mode();
}
return language_mode;
}
} // namespace
RUNTIME_FUNCTION(Runtime_LoadIC_Miss) { RUNTIME_FUNCTION(Runtime_LoadIC_Miss) {
HandleScope scope(isolate); HandleScope scope(isolate);
DCHECK_EQ(4, args.length()); DCHECK_EQ(4, args.length());
@ -2340,20 +2324,19 @@ RUNTIME_FUNCTION(Runtime_StoreIC_Miss) {
FeedbackSlot vector_slot = FeedbackVector::ToSlot(slot->value()); FeedbackSlot vector_slot = FeedbackVector::ToSlot(slot->value());
FeedbackSlotKind kind = vector->GetKind(vector_slot); FeedbackSlotKind kind = vector->GetKind(vector_slot);
LanguageMode language_mode = GetLanguageMode(vector, isolate->context());
if (IsStoreICKind(kind) || IsStoreOwnICKind(kind)) { if (IsStoreICKind(kind) || IsStoreOwnICKind(kind)) {
StoreIC ic(isolate, vector, vector_slot, kind, language_mode); StoreIC ic(isolate, vector, vector_slot, kind);
ic.UpdateState(receiver, key); ic.UpdateState(receiver, key);
RETURN_RESULT_OR_FAILURE(isolate, ic.Store(receiver, key, value)); RETURN_RESULT_OR_FAILURE(isolate, ic.Store(receiver, key, value));
} else if (IsStoreGlobalICKind(kind)) { } else if (IsStoreGlobalICKind(kind)) {
DCHECK_EQ(isolate->native_context()->global_proxy(), *receiver); DCHECK_EQ(isolate->native_context()->global_proxy(), *receiver);
receiver = isolate->global_object(); receiver = isolate->global_object();
StoreGlobalIC ic(isolate, vector, vector_slot, kind, language_mode); StoreGlobalIC ic(isolate, vector, vector_slot, kind);
ic.UpdateState(receiver, key); ic.UpdateState(receiver, key);
RETURN_RESULT_OR_FAILURE(isolate, ic.Store(key, value)); RETURN_RESULT_OR_FAILURE(isolate, ic.Store(key, value));
} else { } else {
DCHECK(IsKeyedStoreICKind(kind)); DCHECK(IsKeyedStoreICKind(kind));
KeyedStoreIC ic(isolate, vector, vector_slot, kind, language_mode); KeyedStoreIC ic(isolate, vector, vector_slot, kind);
ic.UpdateState(receiver, key); ic.UpdateState(receiver, key);
RETURN_RESULT_OR_FAILURE(isolate, ic.Store(receiver, key, value)); RETURN_RESULT_OR_FAILURE(isolate, ic.Store(receiver, key, value));
} }
@ -2361,24 +2344,19 @@ RUNTIME_FUNCTION(Runtime_StoreIC_Miss) {
RUNTIME_FUNCTION(Runtime_StoreICNoFeedback_Miss) { RUNTIME_FUNCTION(Runtime_StoreICNoFeedback_Miss) {
HandleScope scope(isolate); HandleScope scope(isolate);
DCHECK_EQ(5, args.length()); DCHECK_EQ(4, args.length());
Handle<Object> value = args.at(0); Handle<Object> value = args.at(0);
Handle<Object> receiver = args.at(1); Handle<Object> receiver = args.at(1);
Handle<Name> key = args.at<Name>(2); Handle<Name> key = args.at<Name>(2);
CONVERT_LANGUAGE_MODE_ARG_CHECKED(language_mode, 3); CONVERT_INT32_ARG_CHECKED(is_own_property_value, 3);
CONVERT_INT32_ARG_CHECKED(is_own_property_value, 4);
NamedPropertyType property_type = NamedPropertyType property_type =
static_cast<NamedPropertyType>(is_own_property_value); static_cast<NamedPropertyType>(is_own_property_value);
FeedbackSlotKind kind = (language_mode == LanguageMode::kStrict) FeedbackSlotKind kind = FeedbackSlotKind::kStoreNamedStrict;
? FeedbackSlotKind::kStoreNamedStrict
: FeedbackSlotKind::kStoreNamedSloppy;
if (property_type == NamedPropertyType::kOwn) { if (property_type == NamedPropertyType::kOwn) {
language_mode = LanguageMode::kStrict;
kind = FeedbackSlotKind::kStoreOwnNamed; kind = FeedbackSlotKind::kStoreOwnNamed;
} }
StoreIC ic(isolate, Handle<FeedbackVector>(), FeedbackSlot(), kind, StoreIC ic(isolate, Handle<FeedbackVector>(), FeedbackSlot(), kind);
language_mode);
RETURN_RESULT_OR_FAILURE(isolate, ic.Store(receiver, key, value)); RETURN_RESULT_OR_FAILURE(isolate, ic.Store(receiver, key, value));
} }
@ -2393,8 +2371,7 @@ RUNTIME_FUNCTION(Runtime_StoreGlobalIC_Miss) {
FeedbackSlot vector_slot = FeedbackVector::ToSlot(slot->value()); FeedbackSlot vector_slot = FeedbackVector::ToSlot(slot->value());
FeedbackSlotKind kind = vector->GetKind(vector_slot); FeedbackSlotKind kind = vector->GetKind(vector_slot);
LanguageMode language_mode = GetLanguageMode(vector, isolate->context()); StoreGlobalIC ic(isolate, vector, vector_slot, kind);
StoreGlobalIC ic(isolate, vector, vector_slot, kind, language_mode);
Handle<JSGlobalObject> global = isolate->global_object(); Handle<JSGlobalObject> global = isolate->global_object();
ic.UpdateState(global, key); ic.UpdateState(global, key);
RETURN_RESULT_OR_FAILURE(isolate, ic.Store(key, value)); RETURN_RESULT_OR_FAILURE(isolate, ic.Store(key, value));
@ -2402,31 +2379,29 @@ RUNTIME_FUNCTION(Runtime_StoreGlobalIC_Miss) {
RUNTIME_FUNCTION(Runtime_StoreGlobalICNoFeedback_Miss) { RUNTIME_FUNCTION(Runtime_StoreGlobalICNoFeedback_Miss) {
HandleScope scope(isolate); HandleScope scope(isolate);
DCHECK_EQ(3, args.length()); DCHECK_EQ(2, args.length());
// Runtime functions don't follow the IC's calling convention. // Runtime functions don't follow the IC's calling convention.
Handle<Object> value = args.at(0); Handle<Object> value = args.at(0);
Handle<Name> key = args.at<Name>(1); Handle<Name> key = args.at<Name>(1);
CONVERT_LANGUAGE_MODE_ARG_CHECKED(language_mode, 2);
FeedbackSlotKind kind = (language_mode == LanguageMode::kStrict) StoreGlobalIC ic(isolate, Handle<FeedbackVector>(), FeedbackSlot(),
? FeedbackSlotKind::kStoreGlobalStrict FeedbackSlotKind::kStoreGlobalStrict);
: FeedbackSlotKind::kStoreGlobalSloppy;
StoreGlobalIC ic(isolate, Handle<FeedbackVector>(), FeedbackSlot(), kind,
language_mode);
RETURN_RESULT_OR_FAILURE(isolate, ic.Store(key, value)); RETURN_RESULT_OR_FAILURE(isolate, ic.Store(key, value));
} }
// TODO(mythria): Remove Feedback vector and slot. Since they are not used apart
// from the DCHECK.
RUNTIME_FUNCTION(Runtime_StoreGlobalIC_Slow) { RUNTIME_FUNCTION(Runtime_StoreGlobalIC_Slow) {
HandleScope scope(isolate); HandleScope scope(isolate);
DCHECK_EQ(5, args.length()); DCHECK_EQ(5, args.length());
// Runtime functions don't follow the IC's calling convention. // Runtime functions don't follow the IC's calling convention.
Handle<Object> value = args.at(0); Handle<Object> value = args.at(0);
Handle<FeedbackVector> vector = args.at<FeedbackVector>(2);
CONVERT_ARG_HANDLE_CHECKED(String, name, 4); CONVERT_ARG_HANDLE_CHECKED(String, name, 4);
#ifdef DEBUG #ifdef DEBUG
{ {
Handle<Smi> slot = args.at<Smi>(1); Handle<Smi> slot = args.at<Smi>(1);
Handle<FeedbackVector> vector = args.at<FeedbackVector>(2);
FeedbackSlot vector_slot = FeedbackVector::ToSlot(slot->value()); FeedbackSlot vector_slot = FeedbackVector::ToSlot(slot->value());
FeedbackSlotKind slot_kind = vector->GetKind(vector_slot); FeedbackSlotKind slot_kind = vector->GetKind(vector_slot);
DCHECK(IsStoreGlobalICKind(slot_kind)); DCHECK(IsStoreGlobalICKind(slot_kind));
@ -2462,11 +2437,9 @@ RUNTIME_FUNCTION(Runtime_StoreGlobalIC_Slow) {
return *value; return *value;
} }
LanguageMode language_mode = GetLanguageMode(vector, isolate->context());
RETURN_RESULT_OR_FAILURE( RETURN_RESULT_OR_FAILURE(
isolate, isolate, Runtime::SetObjectProperty(isolate, global, name, value,
Runtime::SetObjectProperty(isolate, global, name, value, language_mode, StoreOrigin::kMaybeKeyed));
StoreOrigin::kMaybeKeyed));
} }
RUNTIME_FUNCTION(Runtime_KeyedStoreIC_Miss) { RUNTIME_FUNCTION(Runtime_KeyedStoreIC_Miss) {
@ -2479,14 +2452,13 @@ RUNTIME_FUNCTION(Runtime_KeyedStoreIC_Miss) {
Handle<Object> receiver = args.at(3); Handle<Object> receiver = args.at(3);
Handle<Object> key = args.at(4); Handle<Object> key = args.at(4);
LanguageMode language_mode = GetLanguageMode(vector, isolate->context());
FeedbackSlot vector_slot = FeedbackVector::ToSlot(slot->value()); FeedbackSlot vector_slot = FeedbackVector::ToSlot(slot->value());
FeedbackSlotKind kind = vector->GetKind(vector_slot); FeedbackSlotKind kind = vector->GetKind(vector_slot);
// The elements store stubs miss into this function, but they are shared by // The elements store stubs miss into this function, but they are shared by
// different ICs. // different ICs.
if (IsKeyedStoreICKind(kind)) { if (IsKeyedStoreICKind(kind)) {
KeyedStoreIC ic(isolate, vector, vector_slot, kind, language_mode); KeyedStoreIC ic(isolate, vector, vector_slot, kind);
ic.UpdateState(receiver, key); ic.UpdateState(receiver, key);
RETURN_RESULT_OR_FAILURE(isolate, ic.Store(receiver, key, value)); RETURN_RESULT_OR_FAILURE(isolate, ic.Store(receiver, key, value));
} else { } else {
@ -2502,18 +2474,16 @@ RUNTIME_FUNCTION(Runtime_KeyedStoreIC_Miss) {
RUNTIME_FUNCTION(Runtime_KeyedStoreICNoFeedback_Miss) { RUNTIME_FUNCTION(Runtime_KeyedStoreICNoFeedback_Miss) {
HandleScope scope(isolate); HandleScope scope(isolate);
DCHECK_EQ(4, args.length()); DCHECK_EQ(3, args.length());
// Runtime functions don't follow the IC's calling convention. // Runtime functions don't follow the IC's calling convention.
Handle<Object> value = args.at(0); Handle<Object> value = args.at(0);
Handle<Object> receiver = args.at(1); Handle<Object> receiver = args.at(1);
Handle<Object> key = args.at(2); Handle<Object> key = args.at(2);
CONVERT_LANGUAGE_MODE_ARG_CHECKED(language_mode, 3);
FeedbackSlotKind kind = (language_mode == LanguageMode::kStrict) // TODO(mythria): Replace StoreKeyedStrict and StoreKeyedSloppy with
? FeedbackSlotKind::kStoreKeyedStrict // StoreKeyed.
: FeedbackSlotKind::kStoreKeyedSloppy; KeyedStoreIC ic(isolate, Handle<FeedbackVector>(), FeedbackSlot(),
KeyedStoreIC ic(isolate, Handle<FeedbackVector>(), FeedbackSlot(), kind, FeedbackSlotKind::kStoreKeyedStrict);
language_mode);
RETURN_RESULT_OR_FAILURE(isolate, ic.Store(receiver, key, value)); RETURN_RESULT_OR_FAILURE(isolate, ic.Store(receiver, key, value));
} }
@ -2539,19 +2509,17 @@ RUNTIME_FUNCTION(Runtime_StoreInArrayLiteralIC_Miss) {
return *value; return *value;
} }
// TODO(mythria): We don't need feedback and slot here. Remove those arguments.
RUNTIME_FUNCTION(Runtime_KeyedStoreIC_Slow) { RUNTIME_FUNCTION(Runtime_KeyedStoreIC_Slow) {
HandleScope scope(isolate); HandleScope scope(isolate);
DCHECK_EQ(5, args.length()); DCHECK_EQ(5, args.length());
// Runtime functions don't follow the IC's calling convention. // Runtime functions don't follow the IC's calling convention.
Handle<Object> value = args.at(0); Handle<Object> value = args.at(0);
Handle<FeedbackVector> vector = args.at<FeedbackVector>(2);
Handle<Object> object = args.at(3); Handle<Object> object = args.at(3);
Handle<Object> key = args.at(4); Handle<Object> key = args.at(4);
LanguageMode language_mode = GetLanguageMode(vector, isolate->context());
RETURN_RESULT_OR_FAILURE( RETURN_RESULT_OR_FAILURE(
isolate, isolate, Runtime::SetObjectProperty(isolate, object, key, value,
Runtime::SetObjectProperty(isolate, object, key, value, language_mode, StoreOrigin::kMaybeKeyed));
StoreOrigin::kMaybeKeyed));
} }
RUNTIME_FUNCTION(Runtime_StoreInArrayLiteralIC_Slow) { RUNTIME_FUNCTION(Runtime_StoreInArrayLiteralIC_Slow) {
@ -2588,11 +2556,9 @@ RUNTIME_FUNCTION(Runtime_ElementsTransitionAndStoreIC_Miss) {
return *value; return *value;
} else { } else {
DCHECK(IsKeyedStoreICKind(kind) || IsStoreICKind(kind)); DCHECK(IsKeyedStoreICKind(kind) || IsStoreICKind(kind));
LanguageMode language_mode = GetLanguageMode(vector, isolate->context());
RETURN_RESULT_OR_FAILURE( RETURN_RESULT_OR_FAILURE(
isolate, isolate, Runtime::SetObjectProperty(isolate, object, key, value,
Runtime::SetObjectProperty(isolate, object, key, value, language_mode, StoreOrigin::kMaybeKeyed));
StoreOrigin::kMaybeKeyed));
} }
} }
@ -2734,20 +2700,17 @@ RUNTIME_FUNCTION(Runtime_StoreCallbackProperty) {
Handle<AccessorInfo> info = args.at<AccessorInfo>(2); Handle<AccessorInfo> info = args.at<AccessorInfo>(2);
Handle<Name> name = args.at<Name>(3); Handle<Name> name = args.at<Name>(3);
Handle<Object> value = args.at(4); Handle<Object> value = args.at(4);
CONVERT_LANGUAGE_MODE_ARG_CHECKED(language_mode, 5);
HandleScope scope(isolate); HandleScope scope(isolate);
if (V8_UNLIKELY(FLAG_runtime_stats)) { if (V8_UNLIKELY(FLAG_runtime_stats)) {
RETURN_RESULT_OR_FAILURE( RETURN_RESULT_OR_FAILURE(
isolate, isolate, Runtime::SetObjectProperty(isolate, receiver, name, value,
Runtime::SetObjectProperty(isolate, receiver, name, value, StoreOrigin::kMaybeKeyed));
language_mode, StoreOrigin::kMaybeKeyed));
} }
DCHECK(info->IsCompatibleReceiver(*receiver)); DCHECK(info->IsCompatibleReceiver(*receiver));
ShouldThrow should_throw = ShouldThrow should_throw = GetShouldThrow(isolate, Nothing<LanguageMode>());
is_sloppy(language_mode) ? kDontThrow : kThrowOnError;
PropertyCallbackArguments arguments(isolate, info->data(), *receiver, *holder, PropertyCallbackArguments arguments(isolate, info->data(), *receiver, *holder,
should_throw); should_throw);
arguments.CallAccessorSetter(info, name, value); arguments.CallAccessorSetter(info, name, value);
@ -2859,7 +2822,6 @@ RUNTIME_FUNCTION(Runtime_StorePropertyWithInterceptor) {
Handle<JSObject> receiver = args.at<JSObject>(3); Handle<JSObject> receiver = args.at<JSObject>(3);
Handle<Name> name = args.at<Name>(4); Handle<Name> name = args.at<Name>(4);
FeedbackSlot vector_slot = FeedbackVector::ToSlot(slot->value()); FeedbackSlot vector_slot = FeedbackVector::ToSlot(slot->value());
LanguageMode language_mode = GetLanguageMode(vector, isolate->context());
// TODO(ishell): Cache interceptor_holder in the store handler like we do // TODO(ishell): Cache interceptor_holder in the store handler like we do
// for LoadHandler::kInterceptor case. // for LoadHandler::kInterceptor case.
@ -2892,9 +2854,8 @@ RUNTIME_FUNCTION(Runtime_StorePropertyWithInterceptor) {
DCHECK_EQ(LookupIterator::INTERCEPTOR, it.state()); DCHECK_EQ(LookupIterator::INTERCEPTOR, it.state());
it.Next(); it.Next();
MAYBE_RETURN( MAYBE_RETURN(Object::SetProperty(&it, value, StoreOrigin::kNamed),
Object::SetProperty(&it, value, language_mode, StoreOrigin::kNamed), ReadOnlyRoots(isolate).exception());
ReadOnlyRoots(isolate).exception());
return *value; return *value;
} }

View File

@ -288,13 +288,11 @@ class KeyedLoadIC : public LoadIC {
class StoreIC : public IC { class StoreIC : public IC {
public: public:
StoreIC(Isolate* isolate, Handle<FeedbackVector> vector, FeedbackSlot slot, StoreIC(Isolate* isolate, Handle<FeedbackVector> vector, FeedbackSlot slot,
FeedbackSlotKind kind, LanguageMode language_mode) FeedbackSlotKind kind)
: IC(isolate, vector, slot, kind), language_mode_(language_mode) { : IC(isolate, vector, slot, kind) {
DCHECK(IsAnyStore()); DCHECK(IsAnyStore());
} }
LanguageMode language_mode() const { return language_mode_; }
V8_WARN_UNUSED_RESULT MaybeHandle<Object> Store( V8_WARN_UNUSED_RESULT MaybeHandle<Object> Store(
Handle<Object> object, Handle<Name> name, Handle<Object> value, Handle<Object> object, Handle<Name> name, Handle<Object> value,
StoreOrigin store_origin = StoreOrigin::kNamed); StoreOrigin store_origin = StoreOrigin::kNamed);
@ -314,11 +312,6 @@ class StoreIC : public IC {
void UpdateCaches(LookupIterator* lookup, Handle<Object> value, void UpdateCaches(LookupIterator* lookup, Handle<Object> value,
StoreOrigin store_origin); StoreOrigin store_origin);
// TODO(v8:8580): Instead of storing the language mode, compute it lazily
// from the closure and context when needed. We only need it when throwing
// exceptions, so it is OK to be slow.
LanguageMode language_mode_;
private: private:
MaybeObjectHandle ComputeHandler(LookupIterator* lookup); MaybeObjectHandle ComputeHandler(LookupIterator* lookup);
@ -328,9 +321,8 @@ class StoreIC : public IC {
class StoreGlobalIC : public StoreIC { class StoreGlobalIC : public StoreIC {
public: public:
StoreGlobalIC(Isolate* isolate, Handle<FeedbackVector> vector, StoreGlobalIC(Isolate* isolate, Handle<FeedbackVector> vector,
FeedbackSlot slot, FeedbackSlotKind kind, FeedbackSlot slot, FeedbackSlotKind kind)
LanguageMode language_mode) : StoreIC(isolate, vector, slot, kind) {}
: StoreIC(isolate, vector, slot, kind, language_mode) {}
V8_WARN_UNUSED_RESULT MaybeHandle<Object> Store(Handle<Name> name, V8_WARN_UNUSED_RESULT MaybeHandle<Object> Store(Handle<Name> name,
Handle<Object> value); Handle<Object> value);
@ -354,9 +346,8 @@ class KeyedStoreIC : public StoreIC {
} }
KeyedStoreIC(Isolate* isolate, Handle<FeedbackVector> vector, KeyedStoreIC(Isolate* isolate, Handle<FeedbackVector> vector,
FeedbackSlot slot, FeedbackSlotKind kind, FeedbackSlot slot, FeedbackSlotKind kind)
LanguageMode language_mode) : StoreIC(isolate, vector, slot, kind) {}
: StoreIC(isolate, vector, slot, kind, language_mode) {}
V8_WARN_UNUSED_RESULT MaybeHandle<Object> Store(Handle<Object> object, V8_WARN_UNUSED_RESULT MaybeHandle<Object> Store(Handle<Object> object,
Handle<Object> name, Handle<Object> name,
@ -390,8 +381,7 @@ class StoreInArrayLiteralIC : public KeyedStoreIC {
StoreInArrayLiteralIC(Isolate* isolate, Handle<FeedbackVector> vector, StoreInArrayLiteralIC(Isolate* isolate, Handle<FeedbackVector> vector,
FeedbackSlot slot) FeedbackSlot slot)
: KeyedStoreIC(isolate, vector, slot, : KeyedStoreIC(isolate, vector, slot,
FeedbackSlotKind::kStoreInArrayLiteral, FeedbackSlotKind::kStoreInArrayLiteral) {
LanguageMode::kStrict) {
DCHECK(IsStoreInArrayLiteralICKind(kind())); DCHECK(IsStoreInArrayLiteralICKind(kind()));
} }

View File

@ -237,10 +237,7 @@ IGNITION_HANDLER(StaGlobal, InterpreterAssembler) {
Goto(&end); Goto(&end);
Bind(&no_feedback); Bind(&no_feedback);
TNode<JSFunction> closure = CAST(LoadRegister(Register::function_closure())); CallRuntime(Runtime::kStoreGlobalICNoFeedback_Miss, context, value, name);
Node* language_mode = GetLanguageMode(closure, context);
CallRuntime(Runtime::kStoreGlobalICNoFeedback_Miss, context, value, name,
language_mode);
Goto(&end); Goto(&end);
Bind(&end); Bind(&end);
@ -616,11 +613,8 @@ class InterpreterStoreNamedPropertyAssembler : public InterpreterAssembler {
Goto(&end); Goto(&end);
Bind(&no_feedback); Bind(&no_feedback);
TNode<JSFunction> closure =
CAST(LoadRegister(Register::function_closure()));
Node* language_mode = GetLanguageMode(closure, context);
var_result.Bind(CallRuntime(Runtime::kStoreICNoFeedback_Miss, context, var_result.Bind(CallRuntime(Runtime::kStoreICNoFeedback_Miss, context,
value, object, name, language_mode, value, object, name,
SmiConstant(property_type))); SmiConstant(property_type)));
Goto(&end); Goto(&end);
@ -695,10 +689,8 @@ IGNITION_HANDLER(StaKeyedProperty, InterpreterAssembler) {
Goto(&end); Goto(&end);
Bind(&no_feedback); Bind(&no_feedback);
TNode<JSFunction> closure = CAST(LoadRegister(Register::function_closure()));
Node* language_mode = GetLanguageMode(closure, context);
var_result.Bind(CallRuntime(Runtime::kKeyedStoreICNoFeedback_Miss, context, var_result.Bind(CallRuntime(Runtime::kKeyedStoreICNoFeedback_Miss, context,
value, object, name, language_mode)); value, object, name));
Goto(&end); Goto(&end);
Bind(&end); Bind(&end);

View File

@ -942,10 +942,12 @@ MaybeHandle<JSReceiver> Isolate::CaptureAndSetDetailedStackTrace(
Handle<FixedArray> stack_trace = CaptureCurrentStackTrace( Handle<FixedArray> stack_trace = CaptureCurrentStackTrace(
stack_trace_for_uncaught_exceptions_frame_limit_, stack_trace_for_uncaught_exceptions_frame_limit_,
stack_trace_for_uncaught_exceptions_options_); stack_trace_for_uncaught_exceptions_options_);
RETURN_ON_EXCEPTION(this, RETURN_ON_EXCEPTION(
Object::SetProperty(this, error_object, key, this,
stack_trace, LanguageMode::kStrict), Object::SetProperty(this, error_object, key, stack_trace,
JSReceiver); StoreOrigin::kMaybeKeyed,
Just(LanguageMode::kStrict)),
JSReceiver);
} }
return error_object; return error_object;
} }
@ -959,7 +961,8 @@ MaybeHandle<JSReceiver> Isolate::CaptureAndSetSimpleStackTrace(
CaptureSimpleStackTrace(error_object, mode, caller); CaptureSimpleStackTrace(error_object, mode, caller);
RETURN_ON_EXCEPTION(this, RETURN_ON_EXCEPTION(this,
Object::SetProperty(this, error_object, key, stack_trace, Object::SetProperty(this, error_object, key, stack_trace,
LanguageMode::kStrict), StoreOrigin::kMaybeKeyed,
Just(LanguageMode::kStrict)),
JSReceiver); JSReceiver);
return error_object; return error_object;
} }

View File

@ -698,7 +698,7 @@ MaybeHandle<Object> Object::SetElement(Isolate* isolate, Handle<Object> object,
LanguageMode language_mode) { LanguageMode language_mode) {
LookupIterator it(isolate, object, index); LookupIterator it(isolate, object, index);
MAYBE_RETURN_NULL( MAYBE_RETURN_NULL(
SetProperty(&it, value, language_mode, StoreOrigin::kMaybeKeyed)); SetProperty(&it, value, StoreOrigin::kMaybeKeyed, Just(language_mode)));
return value; return value;
} }
@ -1177,14 +1177,12 @@ MaybeHandle<Object> Object::GetPropertyOrElement(Isolate* isolate,
return GetProperty(&it); return GetProperty(&it);
} }
MaybeHandle<Object> Object::SetPropertyOrElement(Isolate* isolate, MaybeHandle<Object> Object::SetPropertyOrElement(
Handle<Object> object, Isolate* isolate, Handle<Object> object, Handle<Name> name,
Handle<Name> name, Handle<Object> value, Maybe<LanguageMode> language_mode,
Handle<Object> value, StoreOrigin store_origin) {
LanguageMode language_mode,
StoreOrigin store_origin) {
LookupIterator it = LookupIterator::PropertyOrElement(isolate, object, name); LookupIterator it = LookupIterator::PropertyOrElement(isolate, object, name);
MAYBE_RETURN_NULL(SetProperty(&it, value, language_mode, store_origin)); MAYBE_RETURN_NULL(SetProperty(&it, value, store_origin, language_mode));
return value; return value;
} }

View File

@ -123,6 +123,36 @@
namespace v8 { namespace v8 {
namespace internal { namespace internal {
namespace {
LanguageMode GetLanguageMode(Isolate* isolate,
Maybe<LanguageMode> language_mode) {
if (language_mode.IsJust()) return language_mode.FromJust();
LanguageMode mode = isolate->context()->scope_info()->language_mode();
for (StackFrameIterator it(isolate); !it.done(); it.Advance()) {
if (!(it.frame()->is_optimized() || it.frame()->is_interpreted())) {
continue;
}
// Get the language mode from closure.
JavaScriptFrame* js_frame = static_cast<JavaScriptFrame*>(it.frame());
std::vector<SharedFunctionInfo> functions;
js_frame->GetFunctions(&functions);
LanguageMode closure_language_mode = functions.back()->language_mode();
if (closure_language_mode > mode) {
mode = closure_language_mode;
}
break;
}
return mode;
}
} // namespace
ShouldThrow GetShouldThrow(Isolate* isolate,
Maybe<LanguageMode> language_mode) {
return is_sloppy(GetLanguageMode(isolate, language_mode)) ? kDontThrow
: kThrowOnError;
}
bool ComparisonResultToBool(Operation op, ComparisonResult result) { bool ComparisonResultToBool(Operation op, ComparisonResult result) {
switch (op) { switch (op) {
case Operation::kLessThan: case Operation::kLessThan:
@ -1805,7 +1835,6 @@ MaybeHandle<Object> Object::GetPropertyWithDefinedGetter(
return Execution::Call(isolate, getter, receiver, 0, nullptr); return Execution::Call(isolate, getter, receiver, 0, nullptr);
} }
Maybe<bool> Object::SetPropertyWithDefinedSetter(Handle<Object> receiver, Maybe<bool> Object::SetPropertyWithDefinedSetter(Handle<Object> receiver,
Handle<JSReceiver> setter, Handle<JSReceiver> setter,
Handle<Object> value, Handle<Object> value,
@ -2272,7 +2301,7 @@ V8_WARN_UNUSED_RESULT Maybe<bool> FastAssign(
if (use_set) { if (use_set) {
LookupIterator it(target, next_key, target); LookupIterator it(target, next_key, target);
Maybe<bool> result = Object::SetProperty( Maybe<bool> result = Object::SetProperty(
&it, prop_value, LanguageMode::kStrict, StoreOrigin::kNamed); &it, prop_value, StoreOrigin::kNamed, Just(LanguageMode::kStrict));
if (result.IsNothing()) return result; if (result.IsNothing()) return result;
if (stable) stable = from->map() == *map; if (stable) stable = from->map() == *map;
} else { } else {
@ -2335,8 +2364,8 @@ Maybe<bool> JSReceiver::SetOrCopyDataProperties(
ASSIGN_RETURN_ON_EXCEPTION_VALUE( ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, status, isolate, status,
Runtime::SetObjectProperty(isolate, target, next_key, prop_value, Runtime::SetObjectProperty(isolate, target, next_key, prop_value,
LanguageMode::kStrict, StoreOrigin::kMaybeKeyed,
StoreOrigin::kMaybeKeyed), Just(LanguageMode::kStrict)),
Nothing<bool>()); Nothing<bool>());
} else { } else {
if (excluded_properties != nullptr && if (excluded_properties != nullptr &&
@ -5180,21 +5209,20 @@ Maybe<bool> JSObject::SetPropertyWithInterceptor(LookupIterator* it,
MaybeHandle<Object> Object::SetProperty(Isolate* isolate, Handle<Object> object, MaybeHandle<Object> Object::SetProperty(Isolate* isolate, Handle<Object> object,
Handle<Name> name, Handle<Object> value, Handle<Name> name, Handle<Object> value,
LanguageMode language_mode, StoreOrigin store_origin,
StoreOrigin store_origin) { Maybe<LanguageMode> language_mode) {
LookupIterator it(isolate, object, name); LookupIterator it(isolate, object, name);
MAYBE_RETURN_NULL(SetProperty(&it, value, language_mode, store_origin)); MAYBE_RETURN_NULL(SetProperty(&it, value, store_origin, language_mode));
return value; return value;
} }
Maybe<bool> Object::SetPropertyInternal(LookupIterator* it, Maybe<bool> Object::SetPropertyInternal(LookupIterator* it,
Handle<Object> value, Handle<Object> value,
LanguageMode language_mode, Maybe<LanguageMode> language_mode,
StoreOrigin store_origin, bool* found) { StoreOrigin store_origin, bool* found) {
it->UpdateProtector(); it->UpdateProtector();
DCHECK(it->IsFound()); DCHECK(it->IsFound());
ShouldThrow should_throw = ShouldThrow should_throw = GetShouldThrow(it->isolate(), language_mode);
is_sloppy(language_mode) ? kDontThrow : kThrowOnError;
// Make sure that the top context does not change when doing callbacks or // Make sure that the top context does not change when doing callbacks or
// interceptor calls. // interceptor calls.
@ -5220,8 +5248,9 @@ Maybe<bool> Object::SetPropertyInternal(LookupIterator* it,
receiver = handle(JSGlobalObject::cast(*receiver)->global_proxy(), receiver = handle(JSGlobalObject::cast(*receiver)->global_proxy(),
it->isolate()); it->isolate());
} }
return JSProxy::SetProperty(it->GetHolder<JSProxy>(), it->GetName(), return JSProxy::SetProperty(
value, receiver, language_mode); it->GetHolder<JSProxy>(), it->GetName(), value, receiver,
GetLanguageMode(it->isolate(), language_mode));
} }
case LookupIterator::INTERCEPTOR: { case LookupIterator::INTERCEPTOR: {
@ -5304,8 +5333,8 @@ Maybe<bool> Object::SetPropertyInternal(LookupIterator* it,
} }
Maybe<bool> Object::SetProperty(LookupIterator* it, Handle<Object> value, Maybe<bool> Object::SetProperty(LookupIterator* it, Handle<Object> value,
LanguageMode language_mode, StoreOrigin store_origin,
StoreOrigin store_origin) { Maybe<LanguageMode> language_mode) {
if (it->IsFound()) { if (it->IsFound()) {
bool found = true; bool found = true;
Maybe<bool> result = Maybe<bool> result =
@ -5316,20 +5345,21 @@ Maybe<bool> Object::SetProperty(LookupIterator* it, Handle<Object> value,
// If the receiver is the JSGlobalObject, the store was contextual. In case // If the receiver is the JSGlobalObject, the store was contextual. In case
// the property did not exist yet on the global object itself, we have to // the property did not exist yet on the global object itself, we have to
// throw a reference error in strict mode. In sloppy mode, we continue. // throw a reference error in strict mode. In sloppy mode, we continue.
if (is_strict(language_mode) && it->GetReceiver()->IsJSGlobalObject()) { if (is_strict(GetLanguageMode(it->isolate(), language_mode)) &&
it->GetReceiver()->IsJSGlobalObject()) {
it->isolate()->Throw(*it->isolate()->factory()->NewReferenceError( it->isolate()->Throw(*it->isolate()->factory()->NewReferenceError(
MessageTemplate::kNotDefined, it->name())); MessageTemplate::kNotDefined, it->name()));
return Nothing<bool>(); return Nothing<bool>();
} }
ShouldThrow should_throw = return AddDataProperty(it, value, NONE,
is_sloppy(language_mode) ? kDontThrow : kThrowOnError; GetShouldThrow(it->isolate(), language_mode),
return AddDataProperty(it, value, NONE, should_throw, store_origin); store_origin);
} }
Maybe<bool> Object::SetSuperProperty(LookupIterator* it, Handle<Object> value, Maybe<bool> Object::SetSuperProperty(LookupIterator* it, Handle<Object> value,
LanguageMode language_mode, StoreOrigin store_origin,
StoreOrigin store_origin) { Maybe<LanguageMode> language_mode) {
Isolate* isolate = it->isolate(); Isolate* isolate = it->isolate();
if (it->IsFound()) { if (it->IsFound()) {
@ -5344,8 +5374,7 @@ Maybe<bool> Object::SetSuperProperty(LookupIterator* it, Handle<Object> value,
// The property either doesn't exist on the holder or exists there as a data // The property either doesn't exist on the holder or exists there as a data
// property. // property.
ShouldThrow should_throw = ShouldThrow should_throw = GetShouldThrow(it->isolate(), language_mode);
is_sloppy(language_mode) ? kDontThrow : kThrowOnError;
if (!it->GetReceiver()->IsJSReceiver()) { if (!it->GetReceiver()->IsJSReceiver()) {
return WriteToReadOnlyProperty(it, value, should_throw); return WriteToReadOnlyProperty(it, value, should_throw);
@ -6058,8 +6087,8 @@ Maybe<bool> JSProxy::SetProperty(Handle<JSProxy> proxy, Handle<Name> name,
if (trap->IsUndefined(isolate)) { if (trap->IsUndefined(isolate)) {
LookupIterator it = LookupIterator it =
LookupIterator::PropertyOrElement(isolate, receiver, name, target); LookupIterator::PropertyOrElement(isolate, receiver, name, target);
return Object::SetSuperProperty(&it, value, language_mode, return Object::SetSuperProperty(&it, value, StoreOrigin::kMaybeKeyed,
StoreOrigin::kMaybeKeyed); Just(language_mode));
} }
Handle<Object> trap_result; Handle<Object> trap_result;
@ -16614,7 +16643,7 @@ MaybeHandle<Object> JSPromise::Resolve(Handle<JSPromise> promise,
// Mark the dependency of the new {promise} on the {resolution}. // Mark the dependency of the new {promise} on the {resolution}.
Object::SetProperty(isolate, resolution, Object::SetProperty(isolate, resolution,
isolate->factory()->promise_handled_by_symbol(), isolate->factory()->promise_handled_by_symbol(),
promise, LanguageMode::kStrict) promise)
.Check(); .Check();
} }
isolate->native_context()->microtask_queue()->EnqueueMicrotask(*task); isolate->native_context()->microtask_queue()->EnqueueMicrotask(*task);
@ -16937,8 +16966,7 @@ MaybeHandle<JSRegExp> JSRegExp::Initialize(Handle<JSRegExp> regexp,
RETURN_ON_EXCEPTION( RETURN_ON_EXCEPTION(
isolate, isolate,
Object::SetProperty(isolate, regexp, factory->lastIndex_string(), Object::SetProperty(isolate, regexp, factory->lastIndex_string(),
Handle<Smi>(Smi::zero(), isolate), Handle<Smi>(Smi::zero(), isolate)),
LanguageMode::kStrict),
JSRegExp); JSRegExp);
} }

View File

@ -531,6 +531,9 @@ class ZoneForwardList;
// The element types selection for CreateListFromArrayLike. // The element types selection for CreateListFromArrayLike.
enum class ElementTypes { kAll, kStringAndSymbol }; enum class ElementTypes { kAll, kStringAndSymbol };
// TODO(mythria): Move this to a better place.
ShouldThrow GetShouldThrow(Isolate* isolate, Maybe<LanguageMode> language_mode);
// Object is the abstract superclass for all classes in the // Object is the abstract superclass for all classes in the
// object hierarchy. // object hierarchy.
// Object does not use any virtual functions to avoid the // Object does not use any virtual functions to avoid the
@ -784,20 +787,21 @@ class Object {
// argument. These cases are either in accordance with the spec or not // argument. These cases are either in accordance with the spec or not
// covered by it (eg., concerning API callbacks). // covered by it (eg., concerning API callbacks).
V8_WARN_UNUSED_RESULT static Maybe<bool> SetProperty( V8_WARN_UNUSED_RESULT static Maybe<bool> SetProperty(
LookupIterator* it, Handle<Object> value, LanguageMode language_mode, LookupIterator* it, Handle<Object> value, StoreOrigin store_origin,
StoreOrigin store_origin); Maybe<LanguageMode> language_mode = Nothing<LanguageMode>());
V8_WARN_UNUSED_RESULT static MaybeHandle<Object> SetProperty( V8_WARN_UNUSED_RESULT static MaybeHandle<Object> SetProperty(
Isolate* isolate, Handle<Object> object, Handle<Name> name, Isolate* isolate, Handle<Object> object, Handle<Name> name,
Handle<Object> value, LanguageMode language_mode, Handle<Object> value, StoreOrigin store_origin = StoreOrigin::kMaybeKeyed,
StoreOrigin store_origin = StoreOrigin::kMaybeKeyed); Maybe<LanguageMode> language_mode = Nothing<LanguageMode>());
V8_WARN_UNUSED_RESULT static inline MaybeHandle<Object> SetPropertyOrElement( V8_WARN_UNUSED_RESULT static inline MaybeHandle<Object> SetPropertyOrElement(
Isolate* isolate, Handle<Object> object, Handle<Name> name, Isolate* isolate, Handle<Object> object, Handle<Name> name,
Handle<Object> value, LanguageMode language_mode, Handle<Object> value,
Maybe<LanguageMode> language_mode = Nothing<LanguageMode>(),
StoreOrigin store_origin = StoreOrigin::kMaybeKeyed); StoreOrigin store_origin = StoreOrigin::kMaybeKeyed);
V8_WARN_UNUSED_RESULT static Maybe<bool> SetSuperProperty( V8_WARN_UNUSED_RESULT static Maybe<bool> SetSuperProperty(
LookupIterator* it, Handle<Object> value, LanguageMode language_mode, LookupIterator* it, Handle<Object> value, StoreOrigin store_origin,
StoreOrigin store_origin); Maybe<LanguageMode> language_mode = Nothing<LanguageMode>());
V8_WARN_UNUSED_RESULT static Maybe<bool> CannotCreateProperty( V8_WARN_UNUSED_RESULT static Maybe<bool> CannotCreateProperty(
Isolate* isolate, Handle<Object> receiver, Handle<Object> name, Isolate* isolate, Handle<Object> receiver, Handle<Object> name,
@ -979,8 +983,8 @@ class Object {
// Helper for SetProperty and SetSuperProperty. // Helper for SetProperty and SetSuperProperty.
// Return value is only meaningful if [found] is set to true on return. // Return value is only meaningful if [found] is set to true on return.
V8_WARN_UNUSED_RESULT static Maybe<bool> SetPropertyInternal( V8_WARN_UNUSED_RESULT static Maybe<bool> SetPropertyInternal(
LookupIterator* it, Handle<Object> value, LanguageMode language_mode, LookupIterator* it, Handle<Object> value,
StoreOrigin store_origin, bool* found); Maybe<LanguageMode> language_mode, StoreOrigin store_origin, bool* found);
V8_WARN_UNUSED_RESULT static MaybeHandle<Name> ConvertToName( V8_WARN_UNUSED_RESULT static MaybeHandle<Name> ConvertToName(
Isolate* isolate, Handle<Object> input); Isolate* isolate, Handle<Object> input);

View File

@ -120,18 +120,18 @@ void PendingCompilationErrorHandler::ThrowPendingError(Isolate* isolate,
Handle<Name> key_start_pos = factory->error_start_pos_symbol(); Handle<Name> key_start_pos = factory->error_start_pos_symbol();
Object::SetProperty(isolate, jserror, key_start_pos, Object::SetProperty(isolate, jserror, key_start_pos,
handle(Smi::FromInt(location.start_pos()), isolate), handle(Smi::FromInt(location.start_pos()), isolate),
LanguageMode::kSloppy) StoreOrigin::kMaybeKeyed, Just(LanguageMode::kStrict))
.Check(); .Check();
Handle<Name> key_end_pos = factory->error_end_pos_symbol(); Handle<Name> key_end_pos = factory->error_end_pos_symbol();
Object::SetProperty(isolate, jserror, key_end_pos, Object::SetProperty(isolate, jserror, key_end_pos,
handle(Smi::FromInt(location.end_pos()), isolate), handle(Smi::FromInt(location.end_pos()), isolate),
LanguageMode::kSloppy) StoreOrigin::kMaybeKeyed, Just(LanguageMode::kStrict))
.Check(); .Check();
Handle<Name> key_script = factory->error_script_symbol(); Handle<Name> key_script = factory->error_script_symbol();
Object::SetProperty(isolate, jserror, key_script, script, Object::SetProperty(isolate, jserror, key_script, script,
LanguageMode::kSloppy) StoreOrigin::kMaybeKeyed, Just(LanguageMode::kStrict))
.Check(); .Check();
isolate->Throw(*error, &location); isolate->Throw(*error, &location);

View File

@ -51,9 +51,9 @@ MaybeHandle<Object> RegExpUtils::SetLastIndex(Isolate* isolate,
JSRegExp::cast(*recv)->set_last_index(*value_as_object, SKIP_WRITE_BARRIER); JSRegExp::cast(*recv)->set_last_index(*value_as_object, SKIP_WRITE_BARRIER);
return recv; return recv;
} else { } else {
return Object::SetProperty(isolate, recv, return Object::SetProperty(
isolate->factory()->lastIndex_string(), isolate, recv, isolate->factory()->lastIndex_string(), value_as_object,
value_as_object, LanguageMode::kStrict); StoreOrigin::kMaybeKeyed, Just(LanguageMode::kStrict));
} }
} }

View File

@ -771,25 +771,22 @@ namespace {
MaybeHandle<Object> StoreToSuper(Isolate* isolate, Handle<JSObject> home_object, MaybeHandle<Object> StoreToSuper(Isolate* isolate, Handle<JSObject> home_object,
Handle<Object> receiver, Handle<Name> name, Handle<Object> receiver, Handle<Name> name,
Handle<Object> value, Handle<Object> value) {
LanguageMode language_mode) {
Handle<JSReceiver> holder; Handle<JSReceiver> holder;
ASSIGN_RETURN_ON_EXCEPTION(isolate, holder, ASSIGN_RETURN_ON_EXCEPTION(isolate, holder,
GetSuperHolder(isolate, receiver, home_object, GetSuperHolder(isolate, receiver, home_object,
SuperMode::kStore, name, 0), SuperMode::kStore, name, 0),
Object); Object);
LookupIterator it(receiver, name, holder); LookupIterator it(receiver, name, holder);
MAYBE_RETURN( MAYBE_RETURN(Object::SetSuperProperty(&it, value, StoreOrigin::kNamed),
Object::SetSuperProperty(&it, value, language_mode, StoreOrigin::kNamed), MaybeHandle<Object>());
MaybeHandle<Object>());
return value; return value;
} }
MaybeHandle<Object> StoreElementToSuper(Isolate* isolate, MaybeHandle<Object> StoreElementToSuper(Isolate* isolate,
Handle<JSObject> home_object, Handle<JSObject> home_object,
Handle<Object> receiver, uint32_t index, Handle<Object> receiver, uint32_t index,
Handle<Object> value, Handle<Object> value) {
LanguageMode language_mode) {
Handle<JSReceiver> holder; Handle<JSReceiver> holder;
ASSIGN_RETURN_ON_EXCEPTION( ASSIGN_RETURN_ON_EXCEPTION(
isolate, holder, isolate, holder,
@ -797,8 +794,7 @@ MaybeHandle<Object> StoreElementToSuper(Isolate* isolate,
MaybeHandle<Name>(), index), MaybeHandle<Name>(), index),
Object); Object);
LookupIterator it(isolate, receiver, index, holder); LookupIterator it(isolate, receiver, index, holder);
MAYBE_RETURN(Object::SetSuperProperty(&it, value, language_mode, MAYBE_RETURN(Object::SetSuperProperty(&it, value, StoreOrigin::kMaybeKeyed),
StoreOrigin::kMaybeKeyed),
MaybeHandle<Object>()); MaybeHandle<Object>());
return value; return value;
} }
@ -814,11 +810,11 @@ RUNTIME_FUNCTION(Runtime_StoreToSuper_Strict) {
CONVERT_ARG_HANDLE_CHECKED(Object, value, 3); CONVERT_ARG_HANDLE_CHECKED(Object, value, 3);
RETURN_RESULT_OR_FAILURE( RETURN_RESULT_OR_FAILURE(
isolate, StoreToSuper(isolate, home_object, receiver, name, value, isolate, StoreToSuper(isolate, home_object, receiver, name, value));
LanguageMode::kStrict));
} }
// TODO(mythria): Now that we don't need language mode merge this and
// Runtime_StoreToSuper_Strict functions.
RUNTIME_FUNCTION(Runtime_StoreToSuper_Sloppy) { RUNTIME_FUNCTION(Runtime_StoreToSuper_Sloppy) {
HandleScope scope(isolate); HandleScope scope(isolate);
DCHECK_EQ(4, args.length()); DCHECK_EQ(4, args.length());
@ -828,32 +824,29 @@ RUNTIME_FUNCTION(Runtime_StoreToSuper_Sloppy) {
CONVERT_ARG_HANDLE_CHECKED(Object, value, 3); CONVERT_ARG_HANDLE_CHECKED(Object, value, 3);
RETURN_RESULT_OR_FAILURE( RETURN_RESULT_OR_FAILURE(
isolate, StoreToSuper(isolate, home_object, receiver, name, value, isolate, StoreToSuper(isolate, home_object, receiver, name, value));
LanguageMode::kSloppy));
} }
static MaybeHandle<Object> StoreKeyedToSuper( static MaybeHandle<Object> StoreKeyedToSuper(Isolate* isolate,
Isolate* isolate, Handle<JSObject> home_object, Handle<Object> receiver, Handle<JSObject> home_object,
Handle<Object> key, Handle<Object> value, LanguageMode language_mode) { Handle<Object> receiver,
Handle<Object> key,
Handle<Object> value) {
uint32_t index = 0; uint32_t index = 0;
if (key->ToArrayIndex(&index)) { if (key->ToArrayIndex(&index)) {
return StoreElementToSuper(isolate, home_object, receiver, index, value, return StoreElementToSuper(isolate, home_object, receiver, index, value);
language_mode);
} }
Handle<Name> name; Handle<Name> name;
ASSIGN_RETURN_ON_EXCEPTION(isolate, name, Object::ToName(isolate, key), ASSIGN_RETURN_ON_EXCEPTION(isolate, name, Object::ToName(isolate, key),
Object); Object);
// TODO(verwaest): Unify using LookupIterator. // TODO(verwaest): Unify using LookupIterator.
if (name->AsArrayIndex(&index)) { if (name->AsArrayIndex(&index)) {
return StoreElementToSuper(isolate, home_object, receiver, index, value, return StoreElementToSuper(isolate, home_object, receiver, index, value);
language_mode);
} }
return StoreToSuper(isolate, home_object, receiver, name, value, return StoreToSuper(isolate, home_object, receiver, name, value);
language_mode);
} }
RUNTIME_FUNCTION(Runtime_StoreKeyedToSuper_Strict) { RUNTIME_FUNCTION(Runtime_StoreKeyedToSuper_Strict) {
HandleScope scope(isolate); HandleScope scope(isolate);
DCHECK_EQ(4, args.length()); DCHECK_EQ(4, args.length());
@ -863,11 +856,11 @@ RUNTIME_FUNCTION(Runtime_StoreKeyedToSuper_Strict) {
CONVERT_ARG_HANDLE_CHECKED(Object, value, 3); CONVERT_ARG_HANDLE_CHECKED(Object, value, 3);
RETURN_RESULT_OR_FAILURE( RETURN_RESULT_OR_FAILURE(
isolate, StoreKeyedToSuper(isolate, home_object, receiver, key, value, isolate, StoreKeyedToSuper(isolate, home_object, receiver, key, value));
LanguageMode::kStrict));
} }
// TODO(mythria): Now that we don't need language mode merge this and
// Runtime_StoreKeyedToSuper_Strict functions.
RUNTIME_FUNCTION(Runtime_StoreKeyedToSuper_Sloppy) { RUNTIME_FUNCTION(Runtime_StoreKeyedToSuper_Sloppy) {
HandleScope scope(isolate); HandleScope scope(isolate);
DCHECK_EQ(4, args.length()); DCHECK_EQ(4, args.length());
@ -877,8 +870,7 @@ RUNTIME_FUNCTION(Runtime_StoreKeyedToSuper_Sloppy) {
CONVERT_ARG_HANDLE_CHECKED(Object, value, 3); CONVERT_ARG_HANDLE_CHECKED(Object, value, 3);
RETURN_RESULT_OR_FAILURE( RETURN_RESULT_OR_FAILURE(
isolate, StoreKeyedToSuper(isolate, home_object, receiver, key, value, isolate, StoreKeyedToSuper(isolate, home_object, receiver, key, value));
LanguageMode::kSloppy));
} }
} // namespace internal } // namespace internal

View File

@ -341,12 +341,10 @@ RUNTIME_FUNCTION(Runtime_ObjectCreate) {
return *obj; return *obj;
} }
MaybeHandle<Object> Runtime::SetObjectProperty(Isolate* isolate, MaybeHandle<Object> Runtime::SetObjectProperty(
Handle<Object> object, Isolate* isolate, Handle<Object> object, Handle<Object> key,
Handle<Object> key, Handle<Object> value, StoreOrigin store_origin,
Handle<Object> value, Maybe<LanguageMode> language_mode) {
LanguageMode language_mode,
StoreOrigin store_origin) {
if (object->IsNullOrUndefined(isolate)) { if (object->IsNullOrUndefined(isolate)) {
THROW_NEW_ERROR( THROW_NEW_ERROR(
isolate, isolate,
@ -371,12 +369,11 @@ MaybeHandle<Object> Runtime::SetObjectProperty(Isolate* isolate,
} }
MAYBE_RETURN_NULL( MAYBE_RETURN_NULL(
Object::SetProperty(&it, value, language_mode, store_origin)); Object::SetProperty(&it, value, store_origin, language_mode));
return value; return value;
} }
RUNTIME_FUNCTION(Runtime_InternalSetPrototype) { RUNTIME_FUNCTION(Runtime_InternalSetPrototype) {
HandleScope scope(isolate); HandleScope scope(isolate);
DCHECK_EQ(2, args.length()); DCHECK_EQ(2, args.length());
@ -547,6 +544,7 @@ RUNTIME_FUNCTION(Runtime_GetProperty) {
isolate, Runtime::GetObjectProperty(isolate, receiver_obj, key_obj)); isolate, Runtime::GetObjectProperty(isolate, receiver_obj, key_obj));
} }
// TODO(mythria): Remove language mode parameter to SetKeyedProperty
RUNTIME_FUNCTION(Runtime_SetKeyedProperty) { RUNTIME_FUNCTION(Runtime_SetKeyedProperty) {
HandleScope scope(isolate); HandleScope scope(isolate);
DCHECK_EQ(4, args.length()); DCHECK_EQ(4, args.length());
@ -554,14 +552,13 @@ RUNTIME_FUNCTION(Runtime_SetKeyedProperty) {
CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); CONVERT_ARG_HANDLE_CHECKED(Object, object, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
CONVERT_LANGUAGE_MODE_ARG_CHECKED(language_mode, 3);
RETURN_RESULT_OR_FAILURE( RETURN_RESULT_OR_FAILURE(
isolate, isolate, Runtime::SetObjectProperty(isolate, object, key, value,
Runtime::SetObjectProperty(isolate, object, key, value, language_mode, StoreOrigin::kMaybeKeyed));
StoreOrigin::kMaybeKeyed));
} }
// TODO(mythria): Remove language mode parameter to SetNamedProperty
RUNTIME_FUNCTION(Runtime_SetNamedProperty) { RUNTIME_FUNCTION(Runtime_SetNamedProperty) {
HandleScope scope(isolate); HandleScope scope(isolate);
DCHECK_EQ(4, args.length()); DCHECK_EQ(4, args.length());
@ -569,11 +566,10 @@ RUNTIME_FUNCTION(Runtime_SetNamedProperty) {
CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); CONVERT_ARG_HANDLE_CHECKED(Object, object, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
CONVERT_LANGUAGE_MODE_ARG_CHECKED(language_mode, 3);
RETURN_RESULT_OR_FAILURE( RETURN_RESULT_OR_FAILURE(
isolate, Runtime::SetObjectProperty(isolate, object, key, value, isolate, Runtime::SetObjectProperty(isolate, object, key, value,
language_mode, StoreOrigin::kNamed)); StoreOrigin::kNamed));
} }
// Similar to DefineDataPropertyInLiteral, but does not update feedback, and // Similar to DefineDataPropertyInLiteral, but does not update feedback, and

View File

@ -158,16 +158,17 @@ Handle<JSPromise> AwaitPromisesInitCommon(Isolate* isolate,
Object::SetProperty( Object::SetProperty(
isolate, reject_handler, isolate, reject_handler,
isolate->factory()->promise_forwarding_handler_symbol(), isolate->factory()->promise_forwarding_handler_symbol(),
isolate->factory()->true_value(), LanguageMode::kStrict) isolate->factory()->true_value(), StoreOrigin::kMaybeKeyed,
Just(LanguageMode::kStrict))
.Check(); .Check();
Handle<JSPromise>::cast(value)->set_handled_hint(is_predicted_as_caught); Handle<JSPromise>::cast(value)->set_handled_hint(is_predicted_as_caught);
} }
// Mark the dependency to {outer_promise} in case the {throwaway} // Mark the dependency to {outer_promise} in case the {throwaway}
// Promise is found on the Promise stack // Promise is found on the Promise stack
Object::SetProperty(isolate, throwaway, Object::SetProperty(
isolate->factory()->promise_handled_by_symbol(), isolate, throwaway, isolate->factory()->promise_handled_by_symbol(),
outer_promise, LanguageMode::kStrict) outer_promise, StoreOrigin::kMaybeKeyed, Just(LanguageMode::kStrict))
.Check(); .Check();
} }

View File

@ -61,6 +61,7 @@ RUNTIME_FUNCTION(Runtime_GetPropertyWithReceiver) {
&it, static_cast<OnNonExistent>(on_non_existent->value()))); &it, static_cast<OnNonExistent>(on_non_existent->value())));
} }
// TODO(mythria): Remove language_mode parameter.
RUNTIME_FUNCTION(Runtime_SetPropertyWithReceiver) { RUNTIME_FUNCTION(Runtime_SetPropertyWithReceiver) {
HandleScope scope(isolate); HandleScope scope(isolate);
@ -69,7 +70,6 @@ RUNTIME_FUNCTION(Runtime_SetPropertyWithReceiver) {
CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 3); CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 3);
CONVERT_LANGUAGE_MODE_ARG_CHECKED(language_mode, 4);
bool success = false; bool success = false;
LookupIterator it = LookupIterator::PropertyOrElement(isolate, receiver, key, LookupIterator it = LookupIterator::PropertyOrElement(isolate, receiver, key,
@ -78,8 +78,8 @@ RUNTIME_FUNCTION(Runtime_SetPropertyWithReceiver) {
DCHECK(isolate->has_pending_exception()); DCHECK(isolate->has_pending_exception());
return ReadOnlyRoots(isolate).exception(); return ReadOnlyRoots(isolate).exception();
} }
Maybe<bool> result = Object::SetSuperProperty(&it, value, language_mode, Maybe<bool> result =
StoreOrigin::kMaybeKeyed); Object::SetSuperProperty(&it, value, StoreOrigin::kMaybeKeyed);
MAYBE_RETURN(result, ReadOnlyRoots(isolate).exception()); MAYBE_RETURN(result, ReadOnlyRoots(isolate).exception());
return *isolate->factory()->ToBoolean(result.FromJust()); return *isolate->factory()->ToBoolean(result.FromJust());
} }

View File

@ -948,9 +948,9 @@ MaybeHandle<Object> StoreLookupSlot(
object = handle(context->global_object(), isolate); object = handle(context->global_object(), isolate);
} }
ASSIGN_RETURN_ON_EXCEPTION( ASSIGN_RETURN_ON_EXCEPTION(isolate, value,
isolate, value, Object::SetProperty(isolate, object, name, value),
Object::SetProperty(isolate, object, name, value, language_mode), Object); Object);
return value; return value;
} }

View File

@ -123,8 +123,20 @@ RUNTIME_FUNCTION(Runtime_WasmThrowCreate) {
CONVERT_ARG_CHECKED(WasmExceptionTag, tag_raw, 0); CONVERT_ARG_CHECKED(WasmExceptionTag, tag_raw, 0);
CONVERT_SMI_ARG_CHECKED(size, 1); CONVERT_SMI_ARG_CHECKED(size, 1);
// TODO(mstarzinger): Manually box because parameters are not visited yet. // TODO(mstarzinger): Manually box because parameters are not visited yet.
Handle<WasmExceptionTag> tag(tag_raw, isolate); Handle<Object> tag(tag_raw, isolate);
Handle<JSReceiver> exception = WasmExceptionPackage::New(isolate, tag, size); Handle<Object> exception = isolate->factory()->NewWasmRuntimeError(
MessageTemplate::kWasmExceptionError);
CHECK(!Object::SetProperty(isolate, exception,
isolate->factory()->wasm_exception_tag_symbol(),
tag, StoreOrigin::kMaybeKeyed,
Just(LanguageMode::kStrict))
.is_null());
Handle<FixedArray> values = isolate->factory()->NewFixedArray(size);
CHECK(!Object::SetProperty(isolate, exception,
isolate->factory()->wasm_exception_values_symbol(),
values, StoreOrigin::kMaybeKeyed,
Just(LanguageMode::kStrict))
.is_null());
return *exception; return *exception;
} }

View File

@ -554,7 +554,7 @@ namespace internal {
F(ElementsTransitionAndStoreIC_Miss, 6, 1) \ F(ElementsTransitionAndStoreIC_Miss, 6, 1) \
F(KeyedLoadIC_Miss, 4, 1) \ F(KeyedLoadIC_Miss, 4, 1) \
F(KeyedStoreIC_Miss, 5, 1) \ F(KeyedStoreIC_Miss, 5, 1) \
F(KeyedStoreICNoFeedback_Miss, 4, 1) \ F(KeyedStoreICNoFeedback_Miss, 3, 1) \
F(StoreInArrayLiteralIC_Miss, 5, 1) \ F(StoreInArrayLiteralIC_Miss, 5, 1) \
F(KeyedStoreIC_Slow, 5, 1) \ F(KeyedStoreIC_Slow, 5, 1) \
F(LoadAccessorProperty, 4, 1) \ F(LoadAccessorProperty, 4, 1) \
@ -564,12 +564,12 @@ namespace internal {
F(LoadGlobalIC_Slow, 3, 1) \ F(LoadGlobalIC_Slow, 3, 1) \
F(LoadIC_Miss, 4, 1) \ F(LoadIC_Miss, 4, 1) \
F(LoadPropertyWithInterceptor, 5, 1) \ F(LoadPropertyWithInterceptor, 5, 1) \
F(StoreCallbackProperty, 6, 1) \ F(StoreCallbackProperty, 5, 1) \
F(StoreGlobalIC_Miss, 4, 1) \ F(StoreGlobalIC_Miss, 4, 1) \
F(StoreGlobalICNoFeedback_Miss, 3, 1) \ F(StoreGlobalICNoFeedback_Miss, 2, 1) \
F(StoreGlobalIC_Slow, 5, 1) \ F(StoreGlobalIC_Slow, 5, 1) \
F(StoreIC_Miss, 5, 1) \ F(StoreIC_Miss, 5, 1) \
F(StoreICNoFeedback_Miss, 5, 1) \ F(StoreICNoFeedback_Miss, 4, 1) \
F(StoreInArrayLiteralIC_Slow, 5, 1) \ F(StoreInArrayLiteralIC_Slow, 5, 1) \
F(StorePropertyWithInterceptor, 5, 1) \ F(StorePropertyWithInterceptor, 5, 1) \
F(CloneObjectIC_Miss, 4, 1) F(CloneObjectIC_Miss, 4, 1)
@ -700,8 +700,8 @@ class Runtime : public AllStatic {
V8_WARN_UNUSED_RESULT static MaybeHandle<Object> SetObjectProperty( V8_WARN_UNUSED_RESULT static MaybeHandle<Object> SetObjectProperty(
Isolate* isolate, Handle<Object> object, Handle<Object> key, Isolate* isolate, Handle<Object> object, Handle<Object> key,
Handle<Object> value, LanguageMode language_mode, Handle<Object> value, StoreOrigin store_origin,
StoreOrigin store_origin); Maybe<LanguageMode> language_mode = Nothing<LanguageMode>());
V8_WARN_UNUSED_RESULT static MaybeHandle<Object> GetObjectProperty( V8_WARN_UNUSED_RESULT static MaybeHandle<Object> GetObjectProperty(
Isolate* isolate, Handle<Object> object, Handle<Object> key, Isolate* isolate, Handle<Object> object, Handle<Object> key,

View File

@ -1567,12 +1567,14 @@ Handle<JSReceiver> WasmExceptionPackage::New(
MessageTemplate::kWasmExceptionError); MessageTemplate::kWasmExceptionError);
CHECK(!Object::SetProperty(isolate, exception, CHECK(!Object::SetProperty(isolate, exception,
isolate->factory()->wasm_exception_tag_symbol(), isolate->factory()->wasm_exception_tag_symbol(),
exception_tag, LanguageMode::kStrict) exception_tag, StoreOrigin::kMaybeKeyed,
Just(LanguageMode::kStrict))
.is_null()); .is_null());
Handle<FixedArray> values = isolate->factory()->NewFixedArray(size); Handle<FixedArray> values = isolate->factory()->NewFixedArray(size);
CHECK(!Object::SetProperty(isolate, exception, CHECK(!Object::SetProperty(isolate, exception,
isolate->factory()->wasm_exception_values_symbol(), isolate->factory()->wasm_exception_values_symbol(),
values, LanguageMode::kStrict) values, StoreOrigin::kMaybeKeyed,
Just(LanguageMode::kStrict))
.is_null()); .is_null());
return Handle<JSReceiver>::cast(exception); return Handle<JSReceiver>::cast(exception);
} }

View File

@ -368,16 +368,11 @@ TEST(GarbageCollection) {
HandleScope inner_scope(isolate); HandleScope inner_scope(isolate);
// Allocate a function and keep it in global object's property. // Allocate a function and keep it in global object's property.
Handle<JSFunction> function = factory->NewFunctionForTest(name); Handle<JSFunction> function = factory->NewFunctionForTest(name);
Object::SetProperty(isolate, global, name, function, LanguageMode::kSloppy) Object::SetProperty(isolate, global, name, function).Check();
.Check();
// Allocate an object. Unrooted after leaving the scope. // Allocate an object. Unrooted after leaving the scope.
Handle<JSObject> obj = factory->NewJSObject(function); Handle<JSObject> obj = factory->NewJSObject(function);
Object::SetProperty(isolate, obj, prop_name, twenty_three, Object::SetProperty(isolate, obj, prop_name, twenty_three).Check();
LanguageMode::kSloppy) Object::SetProperty(isolate, obj, prop_namex, twenty_four).Check();
.Check();
Object::SetProperty(isolate, obj, prop_namex, twenty_four,
LanguageMode::kSloppy)
.Check();
CHECK_EQ(Smi::FromInt(23), CHECK_EQ(Smi::FromInt(23),
*Object::GetProperty(isolate, obj, prop_name).ToHandleChecked()); *Object::GetProperty(isolate, obj, prop_name).ToHandleChecked());
@ -399,11 +394,8 @@ TEST(GarbageCollection) {
HandleScope inner_scope(isolate); HandleScope inner_scope(isolate);
// Allocate another object, make it reachable from global. // Allocate another object, make it reachable from global.
Handle<JSObject> obj = factory->NewJSObject(function); Handle<JSObject> obj = factory->NewJSObject(function);
Object::SetProperty(isolate, global, obj_name, obj, LanguageMode::kSloppy) Object::SetProperty(isolate, global, obj_name, obj).Check();
.Check(); Object::SetProperty(isolate, obj, prop_name, twenty_three).Check();
Object::SetProperty(isolate, obj, prop_name, twenty_three,
LanguageMode::kSloppy)
.Check();
} }
// After gc, it should survive. // After gc, it should survive.
@ -944,15 +936,11 @@ TEST(FunctionAllocation) {
Handle<String> prop_name = factory->InternalizeUtf8String("theSlot"); Handle<String> prop_name = factory->InternalizeUtf8String("theSlot");
Handle<JSObject> obj = factory->NewJSObject(function); Handle<JSObject> obj = factory->NewJSObject(function);
Object::SetProperty(isolate, obj, prop_name, twenty_three, Object::SetProperty(isolate, obj, prop_name, twenty_three).Check();
LanguageMode::kSloppy)
.Check();
CHECK_EQ(Smi::FromInt(23), CHECK_EQ(Smi::FromInt(23),
*Object::GetProperty(isolate, obj, prop_name).ToHandleChecked()); *Object::GetProperty(isolate, obj, prop_name).ToHandleChecked());
// Check that we can add properties to function objects. // Check that we can add properties to function objects.
Object::SetProperty(isolate, function, prop_name, twenty_four, Object::SetProperty(isolate, function, prop_name, twenty_four).Check();
LanguageMode::kSloppy)
.Check();
CHECK_EQ( CHECK_EQ(
Smi::FromInt(24), Smi::FromInt(24),
*Object::GetProperty(isolate, function, prop_name).ToHandleChecked()); *Object::GetProperty(isolate, function, prop_name).ToHandleChecked());
@ -983,7 +971,7 @@ TEST(ObjectProperties) {
CHECK(Just(false) == JSReceiver::HasOwnProperty(obj, first)); CHECK(Just(false) == JSReceiver::HasOwnProperty(obj, first));
// add first // add first
Object::SetProperty(isolate, obj, first, one, LanguageMode::kSloppy).Check(); Object::SetProperty(isolate, obj, first, one).Check();
CHECK(Just(true) == JSReceiver::HasOwnProperty(obj, first)); CHECK(Just(true) == JSReceiver::HasOwnProperty(obj, first));
// delete first // delete first
@ -992,8 +980,8 @@ TEST(ObjectProperties) {
CHECK(Just(false) == JSReceiver::HasOwnProperty(obj, first)); CHECK(Just(false) == JSReceiver::HasOwnProperty(obj, first));
// add first and then second // add first and then second
Object::SetProperty(isolate, obj, first, one, LanguageMode::kSloppy).Check(); Object::SetProperty(isolate, obj, first, one).Check();
Object::SetProperty(isolate, obj, second, two, LanguageMode::kSloppy).Check(); Object::SetProperty(isolate, obj, second, two).Check();
CHECK(Just(true) == JSReceiver::HasOwnProperty(obj, first)); CHECK(Just(true) == JSReceiver::HasOwnProperty(obj, first));
CHECK(Just(true) == JSReceiver::HasOwnProperty(obj, second)); CHECK(Just(true) == JSReceiver::HasOwnProperty(obj, second));
@ -1007,8 +995,8 @@ TEST(ObjectProperties) {
CHECK(Just(false) == JSReceiver::HasOwnProperty(obj, second)); CHECK(Just(false) == JSReceiver::HasOwnProperty(obj, second));
// add first and then second // add first and then second
Object::SetProperty(isolate, obj, first, one, LanguageMode::kSloppy).Check(); Object::SetProperty(isolate, obj, first, one).Check();
Object::SetProperty(isolate, obj, second, two, LanguageMode::kSloppy).Check(); Object::SetProperty(isolate, obj, second, two).Check();
CHECK(Just(true) == JSReceiver::HasOwnProperty(obj, first)); CHECK(Just(true) == JSReceiver::HasOwnProperty(obj, first));
CHECK(Just(true) == JSReceiver::HasOwnProperty(obj, second)); CHECK(Just(true) == JSReceiver::HasOwnProperty(obj, second));
@ -1024,15 +1012,14 @@ TEST(ObjectProperties) {
// check string and internalized string match // check string and internalized string match
const char* string1 = "fisk"; const char* string1 = "fisk";
Handle<String> s1 = factory->NewStringFromAsciiChecked(string1); Handle<String> s1 = factory->NewStringFromAsciiChecked(string1);
Object::SetProperty(isolate, obj, s1, one, LanguageMode::kSloppy).Check(); Object::SetProperty(isolate, obj, s1, one).Check();
Handle<String> s1_string = factory->InternalizeUtf8String(string1); Handle<String> s1_string = factory->InternalizeUtf8String(string1);
CHECK(Just(true) == JSReceiver::HasOwnProperty(obj, s1_string)); CHECK(Just(true) == JSReceiver::HasOwnProperty(obj, s1_string));
// check internalized string and string match // check internalized string and string match
const char* string2 = "fugl"; const char* string2 = "fugl";
Handle<String> s2_string = factory->InternalizeUtf8String(string2); Handle<String> s2_string = factory->InternalizeUtf8String(string2);
Object::SetProperty(isolate, obj, s2_string, one, LanguageMode::kSloppy) Object::SetProperty(isolate, obj, s2_string, one).Check();
.Check();
Handle<String> s2 = factory->NewStringFromAsciiChecked(string2); Handle<String> s2 = factory->NewStringFromAsciiChecked(string2);
CHECK(Just(true) == JSReceiver::HasOwnProperty(obj, s2)); CHECK(Just(true) == JSReceiver::HasOwnProperty(obj, s2));
} }
@ -1053,9 +1040,7 @@ TEST(JSObjectMaps) {
// Set a propery // Set a propery
Handle<Smi> twenty_three(Smi::FromInt(23), isolate); Handle<Smi> twenty_three(Smi::FromInt(23), isolate);
Object::SetProperty(isolate, obj, prop_name, twenty_three, Object::SetProperty(isolate, obj, prop_name, twenty_three).Check();
LanguageMode::kSloppy)
.Check();
CHECK_EQ(Smi::FromInt(23), CHECK_EQ(Smi::FromInt(23),
*Object::GetProperty(isolate, obj, prop_name).ToHandleChecked()); *Object::GetProperty(isolate, obj, prop_name).ToHandleChecked());
@ -1136,8 +1121,8 @@ TEST(JSObjectCopy) {
Handle<Smi> one(Smi::FromInt(1), isolate); Handle<Smi> one(Smi::FromInt(1), isolate);
Handle<Smi> two(Smi::FromInt(2), isolate); Handle<Smi> two(Smi::FromInt(2), isolate);
Object::SetProperty(isolate, obj, first, one, LanguageMode::kSloppy).Check(); Object::SetProperty(isolate, obj, first, one).Check();
Object::SetProperty(isolate, obj, second, two, LanguageMode::kSloppy).Check(); Object::SetProperty(isolate, obj, second, two).Check();
Object::SetElement(isolate, obj, 0, first, LanguageMode::kSloppy).Check(); Object::SetElement(isolate, obj, 0, first, LanguageMode::kSloppy).Check();
Object::SetElement(isolate, obj, 1, second, LanguageMode::kSloppy).Check(); Object::SetElement(isolate, obj, 1, second, LanguageMode::kSloppy).Check();
@ -1162,10 +1147,8 @@ TEST(JSObjectCopy) {
CHECK_EQ(*value1, *value2); CHECK_EQ(*value1, *value2);
// Flip the values. // Flip the values.
Object::SetProperty(isolate, clone, first, two, LanguageMode::kSloppy) Object::SetProperty(isolate, clone, first, two).Check();
.Check(); Object::SetProperty(isolate, clone, second, one).Check();
Object::SetProperty(isolate, clone, second, one, LanguageMode::kSloppy)
.Check();
Object::SetElement(isolate, clone, 0, second, LanguageMode::kSloppy).Check(); Object::SetElement(isolate, clone, 0, second, LanguageMode::kSloppy).Check();
Object::SetElement(isolate, clone, 1, first, LanguageMode::kSloppy).Check(); Object::SetElement(isolate, clone, 1, first, LanguageMode::kSloppy).Check();
@ -2983,9 +2966,7 @@ static void AddPropertyTo(
FLAG_gc_global = true; FLAG_gc_global = true;
FLAG_retain_maps_for_n_gc = 0; FLAG_retain_maps_for_n_gc = 0;
CcTest::heap()->set_allocation_timeout(gc_count); CcTest::heap()->set_allocation_timeout(gc_count);
Object::SetProperty(isolate, object, prop_name, twenty_three, Object::SetProperty(isolate, object, prop_name, twenty_three).Check();
LanguageMode::kSloppy)
.Check();
} }
@ -4855,8 +4836,7 @@ TEST(Regress442710) {
Handle<JSArray> array = factory->NewJSArray(2); Handle<JSArray> array = factory->NewJSArray(2);
Handle<String> name = factory->InternalizeUtf8String("testArray"); Handle<String> name = factory->InternalizeUtf8String("testArray");
Object::SetProperty(isolate, global, name, array, LanguageMode::kSloppy) Object::SetProperty(isolate, global, name, array).Check();
.Check();
CompileRun("testArray[0] = 1; testArray[1] = 2; testArray.shift();"); CompileRun("testArray[0] = 1; testArray[1] = 2; testArray.shift();");
CcTest::CollectGarbage(OLD_SPACE); CcTest::CollectGarbage(OLD_SPACE);
} }

View File

@ -330,25 +330,16 @@ HEAP_TEST(InvalidatedSlotsFastToSlow) {
// Start incremental marking. // Start incremental marking.
heap::SimulateIncrementalMarking(heap); heap::SimulateIncrementalMarking(heap);
// Set properties to point to the evacuation candidate. // Set properties to point to the evacuation candidate.
Object::SetProperty(isolate, obj, prop_name1, evacuated, Object::SetProperty(isolate, obj, prop_name1, evacuated).Check();
LanguageMode::kSloppy) Object::SetProperty(isolate, obj, prop_name2, evacuated).Check();
.Check(); Object::SetProperty(isolate, obj, prop_name3, evacuated).Check();
Object::SetProperty(isolate, obj, prop_name2, evacuated,
LanguageMode::kSloppy)
.Check();
Object::SetProperty(isolate, obj, prop_name3, evacuated,
LanguageMode::kSloppy)
.Check();
{ {
HandleScope scope(isolate); HandleScope scope(isolate);
Handle<HeapObject> dead = factory->NewFixedArray(1); Handle<HeapObject> dead = factory->NewFixedArray(1);
Object::SetProperty(isolate, obj, prop_name1, dead, LanguageMode::kSloppy) Object::SetProperty(isolate, obj, prop_name1, dead).Check();
.Check(); Object::SetProperty(isolate, obj, prop_name2, dead).Check();
Object::SetProperty(isolate, obj, prop_name2, dead, LanguageMode::kSloppy) Object::SetProperty(isolate, obj, prop_name3, dead).Check();
.Check();
Object::SetProperty(isolate, obj, prop_name3, dead, LanguageMode::kSloppy)
.Check();
Handle<Map> map(obj->map(), isolate); Handle<Map> map(obj->map(), isolate);
Handle<Map> normalized_map = Handle<Map> normalized_map =
Map::Normalize(isolate, map, CLEAR_INOBJECT_PROPERTIES, "testing"); Map::Normalize(isolate, map, CLEAR_INOBJECT_PROPERTIES, "testing");

View File

@ -165,9 +165,7 @@ HEAP_TEST(MarkCompactCollector) {
// allocate a garbage // allocate a garbage
Handle<String> func_name = factory->InternalizeUtf8String("theFunction"); Handle<String> func_name = factory->InternalizeUtf8String("theFunction");
Handle<JSFunction> function = factory->NewFunctionForTest(func_name); Handle<JSFunction> function = factory->NewFunctionForTest(func_name);
Object::SetProperty(isolate, global, func_name, function, Object::SetProperty(isolate, global, func_name, function).Check();
LanguageMode::kSloppy)
.Check();
factory->NewJSObject(function); factory->NewJSObject(function);
} }
@ -184,13 +182,10 @@ HEAP_TEST(MarkCompactCollector) {
Handle<JSObject> obj = factory->NewJSObject(function); Handle<JSObject> obj = factory->NewJSObject(function);
Handle<String> obj_name = factory->InternalizeUtf8String("theObject"); Handle<String> obj_name = factory->InternalizeUtf8String("theObject");
Object::SetProperty(isolate, global, obj_name, obj, LanguageMode::kSloppy) Object::SetProperty(isolate, global, obj_name, obj).Check();
.Check();
Handle<String> prop_name = factory->InternalizeUtf8String("theSlot"); Handle<String> prop_name = factory->InternalizeUtf8String("theSlot");
Handle<Smi> twenty_three(Smi::FromInt(23), isolate); Handle<Smi> twenty_three(Smi::FromInt(23), isolate);
Object::SetProperty(isolate, obj, prop_name, twenty_three, Object::SetProperty(isolate, obj, prop_name, twenty_three).Check();
LanguageMode::kSloppy)
.Check();
} }
CcTest::CollectGarbage(OLD_SPACE); CcTest::CollectGarbage(OLD_SPACE);

View File

@ -55,7 +55,8 @@ static void SetGlobalProperty(const char* name, Object value) {
isolate->factory()->InternalizeUtf8String(name); isolate->factory()->InternalizeUtf8String(name);
Handle<JSObject> global(isolate->context()->global_object(), isolate); Handle<JSObject> global(isolate->context()->global_object(), isolate);
Runtime::SetObjectProperty(isolate, global, internalized_name, object, Runtime::SetObjectProperty(isolate, global, internalized_name, object,
LanguageMode::kSloppy, StoreOrigin::kMaybeKeyed) StoreOrigin::kMaybeKeyed,
Just(LanguageMode::kSloppy))
.Check(); .Check();
} }

View File

@ -132,7 +132,8 @@ TEST(GetStringOption) {
Handle<String> key = isolate->factory()->NewStringFromAsciiChecked("foo"); Handle<String> key = isolate->factory()->NewStringFromAsciiChecked("foo");
v8::internal::LookupIterator it(isolate, options, key); v8::internal::LookupIterator it(isolate, options, key);
CHECK(Object::SetProperty(&it, Handle<Smi>(Smi::FromInt(42), isolate), CHECK(Object::SetProperty(&it, Handle<Smi>(Smi::FromInt(42), isolate),
LanguageMode::kStrict, StoreOrigin::kMaybeKeyed) StoreOrigin::kMaybeKeyed,
Just(LanguageMode::kStrict))
.FromJust()); .FromJust());
{ {
@ -191,7 +192,7 @@ TEST(GetBoolOption) {
Handle<Object> false_value = Handle<Object> false_value =
handle(i::ReadOnlyRoots(isolate).false_value(), isolate); handle(i::ReadOnlyRoots(isolate).false_value(), isolate);
Object::SetProperty(isolate, options, key, false_value, Object::SetProperty(isolate, options, key, false_value,
LanguageMode::kStrict) StoreOrigin::kMaybeKeyed, Just(LanguageMode::kStrict))
.Assert(); .Assert();
bool result = false; bool result = false;
Maybe<bool> found = Maybe<bool> found =
@ -205,7 +206,7 @@ TEST(GetBoolOption) {
Handle<Object> true_value = Handle<Object> true_value =
handle(i::ReadOnlyRoots(isolate).true_value(), isolate); handle(i::ReadOnlyRoots(isolate).true_value(), isolate);
Object::SetProperty(isolate, options, key, true_value, Object::SetProperty(isolate, options, key, true_value,
LanguageMode::kStrict) StoreOrigin::kMaybeKeyed, Just(LanguageMode::kStrict))
.Assert(); .Assert();
bool result = false; bool result = false;
Maybe<bool> found = Maybe<bool> found =