diff --git a/src/accessors.cc b/src/accessors.cc index a368bbd81e..8508621c01 100644 --- a/src/accessors.cc +++ b/src/accessors.cc @@ -796,7 +796,8 @@ MaybeHandle ClearInternalStackTrace(Isolate* isolate, isolate, Object::SetProperty( isolate, error, isolate->factory()->stack_trace_symbol(), - isolate->factory()->undefined_value(), LanguageMode::kStrict), + isolate->factory()->undefined_value(), StoreOrigin::kMaybeKeyed, + Just(LanguageMode::kStrict)), JSReceiver); return error; } diff --git a/src/api.cc b/src/api.cc index c35dc7d85f..980bd35c2e 100644 --- a/src/api.cc +++ b/src/api.cc @@ -4005,8 +4005,8 @@ Maybe v8::Object::Set(v8::Local context, auto value_obj = Utils::OpenHandle(*value); has_pending_exception = i::Runtime::SetObjectProperty(isolate, self, key_obj, value_obj, - i::LanguageMode::kSloppy, - i::StoreOrigin::kMaybeKeyed) + i::StoreOrigin::kMaybeKeyed, + Just(i::LanguageMode::kSloppy)) .is_null(); RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); return Just(true); diff --git a/src/builtins/builtins-array.cc b/src/builtins/builtins-array.cc index 9774f24fe0..e895beb731 100644 --- a/src/builtins/builtins-array.cc +++ b/src/builtins/builtins-array.cc @@ -176,7 +176,8 @@ V8_WARN_UNUSED_RESULT MaybeHandle SetLengthProperty( return Object::SetProperty( 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, @@ -192,7 +193,7 @@ V8_WARN_UNUSED_RESULT Object GenericArrayFill(Isolate* isolate, // b. Perform ? Set(O, Pk, value, true). RETURN_FAILURE_ON_EXCEPTION( isolate, Object::SetPropertyOrElement(isolate, receiver, index, value, - LanguageMode::kStrict)); + Just(LanguageMode::kStrict))); // c. Increase k by 1. ++start; @@ -339,8 +340,8 @@ V8_WARN_UNUSED_RESULT Object GenericArrayPush(Isolate* isolate, isolate, receiver, isolate->factory()->NewNumber(length), &success); // Must succeed since we always pass a valid key. DCHECK(success); - MAYBE_RETURN(Object::SetProperty(&it, element, LanguageMode::kStrict, - StoreOrigin::kMaybeKeyed), + MAYBE_RETURN(Object::SetProperty(&it, element, StoreOrigin::kMaybeKeyed, + Just(LanguageMode::kStrict)), ReadOnlyRoots(isolate).exception()); } @@ -353,7 +354,8 @@ V8_WARN_UNUSED_RESULT Object GenericArrayPush(Isolate* isolate, RETURN_FAILURE_ON_EXCEPTION( isolate, Object::SetProperty(isolate, receiver, isolate->factory()->length_string(), - final_length, LanguageMode::kStrict)); + final_length, StoreOrigin::kMaybeKeyed, + Just(LanguageMode::kStrict))); // 8. Return len. return *final_length; @@ -408,7 +410,8 @@ V8_WARN_UNUSED_RESULT Object GenericArrayPop(Isolate* isolate, RETURN_FAILURE_ON_EXCEPTION( isolate, Object::SetProperty( isolate, receiver, isolate->factory()->length_string(), - Handle(Smi::zero(), isolate), LanguageMode::kStrict)); + Handle(Smi::zero(), isolate), + StoreOrigin::kMaybeKeyed, Just(LanguageMode::kStrict))); // b. Return undefined. return ReadOnlyRoots(isolate).undefined_value(); @@ -435,7 +438,8 @@ V8_WARN_UNUSED_RESULT Object GenericArrayPop(Isolate* isolate, RETURN_FAILURE_ON_EXCEPTION( isolate, Object::SetProperty(isolate, receiver, isolate->factory()->length_string(), - new_length, LanguageMode::kStrict)); + new_length, StoreOrigin::kMaybeKeyed, + Just(LanguageMode::kStrict))); // f. Return element. return *element; @@ -526,7 +530,7 @@ V8_WARN_UNUSED_RESULT Object GenericArrayShift(Isolate* isolate, // ii. Perform ? Set(O, to, fromVal, true). RETURN_FAILURE_ON_EXCEPTION( isolate, Object::SetPropertyOrElement(isolate, receiver, to, from_val, - LanguageMode::kStrict)); + Just(LanguageMode::kStrict))); } else { // e. Else fromPresent is false, // i. Perform ? DeletePropertyOrThrow(O, to). MAYBE_RETURN(JSReceiver::DeletePropertyOrElement(receiver, to, @@ -731,9 +735,9 @@ class ArrayConcatVisitor { isolate_->factory()->NewNumber(static_cast(index_offset_)); RETURN_ON_EXCEPTION( isolate_, - Object::SetProperty(isolate_, result, - isolate_->factory()->length_string(), length, - LanguageMode::kStrict), + Object::SetProperty( + isolate_, result, isolate_->factory()->length_string(), length, + StoreOrigin::kMaybeKeyed, Just(LanguageMode::kStrict)), JSReceiver); return result; } diff --git a/src/builtins/builtins-reflect.cc b/src/builtins/builtins-reflect.cc index cd3f2b4bed..642cdd984c 100644 --- a/src/builtins/builtins-reflect.cc +++ b/src/builtins/builtins-reflect.cc @@ -218,7 +218,7 @@ BUILTIN(ReflectSet) { LookupIterator it = LookupIterator::PropertyOrElement( isolate, receiver, name, Handle::cast(target)); Maybe result = Object::SetSuperProperty( - &it, value, LanguageMode::kSloppy, StoreOrigin::kMaybeKeyed); + &it, value, StoreOrigin::kMaybeKeyed, Just(LanguageMode::kSloppy)); MAYBE_RETURN(result, ReadOnlyRoots(isolate).exception()); return *isolate->factory()->ToBoolean(result.FromJust()); } diff --git a/src/debug/debug.cc b/src/debug/debug.cc index 2789513514..cc7e00de84 100644 --- a/src/debug/debug.cc +++ b/src/debug/debug.cc @@ -1723,7 +1723,8 @@ void Debug::OnException(Handle exception, Handle promise, Handle jspromise = Handle::cast(promise); // Mark the promise as already having triggered a message. Handle 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(); // Check whether the promise reject is considered an uncaught exception. uncaught = !isolate_->PromiseHasUserDefinedRejectHandler(jspromise); diff --git a/src/heap/factory.cc b/src/heap/factory.cc index 2ffbf7d4a4..3304932338 100644 --- a/src/heap/factory.cc +++ b/src/heap/factory.cc @@ -3875,11 +3875,11 @@ Handle Factory::NewArgumentsObject(Handle callee, Handle result = NewJSObjectFromMap(map); Handle value(Smi::FromInt(length), isolate()); Object::SetProperty(isolate(), result, length_string(), value, - LanguageMode::kStrict) + StoreOrigin::kMaybeKeyed, Just(LanguageMode::kStrict)) .Assert(); if (!strict_mode_callee) { Object::SetProperty(isolate(), result, callee_string(), callee, - LanguageMode::kStrict) + StoreOrigin::kMaybeKeyed, Just(LanguageMode::kStrict)) .Assert(); } return result; diff --git a/src/ic/ic.cc b/src/ic/ic.cc index c607679a2a..d9a7351195 100644 --- a/src/ic/ic.cc +++ b/src/ic/ic.cc @@ -1402,8 +1402,7 @@ MaybeHandle StoreIC::Store(Handle object, Handle name, if (MigrateDeprecated(object)) { Handle result; ASSIGN_RETURN_ON_EXCEPTION( - isolate(), result, - Object::SetProperty(isolate(), object, name, value, language_mode()), + isolate(), result, Object::SetProperty(isolate(), object, name, value), Object); return result; } @@ -1443,8 +1442,7 @@ MaybeHandle StoreIC::Store(Handle object, Handle name, } if (use_ic) UpdateCaches(&it, value, store_origin); - MAYBE_RETURN_NULL( - Object::SetProperty(&it, value, language_mode(), store_origin)); + MAYBE_RETURN_NULL(Object::SetProperty(&it, value, store_origin)); return value; } @@ -2008,7 +2006,7 @@ MaybeHandle KeyedStoreIC::Store(Handle object, ASSIGN_RETURN_ON_EXCEPTION( isolate(), result, Runtime::SetObjectProperty(isolate(), object, key, value, - language_mode(), StoreOrigin::kMaybeKeyed), + StoreOrigin::kMaybeKeyed), Object); return result; } @@ -2083,7 +2081,7 @@ MaybeHandle KeyedStoreIC::Store(Handle object, Handle::cast(object)->elements()->IsCowArray(); ASSIGN_RETURN_ON_EXCEPTION( isolate(), store_handle, - Runtime::SetObjectProperty(isolate(), object, key, value, language_mode(), + Runtime::SetObjectProperty(isolate(), object, key, value, StoreOrigin::kMaybeKeyed), Object); @@ -2176,20 +2174,6 @@ void StoreInArrayLiteralIC::Store(Handle array, Handle index, // Static IC stub generators. // // -namespace { - -// TODO(8580): Compute the language mode lazily to avoid the expensive -// computation of language mode here. -LanguageMode GetLanguageMode(Handle 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) { HandleScope scope(isolate); DCHECK_EQ(4, args.length()); @@ -2340,20 +2324,19 @@ RUNTIME_FUNCTION(Runtime_StoreIC_Miss) { FeedbackSlot vector_slot = FeedbackVector::ToSlot(slot->value()); FeedbackSlotKind kind = vector->GetKind(vector_slot); - LanguageMode language_mode = GetLanguageMode(vector, isolate->context()); 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); RETURN_RESULT_OR_FAILURE(isolate, ic.Store(receiver, key, value)); } else if (IsStoreGlobalICKind(kind)) { DCHECK_EQ(isolate->native_context()->global_proxy(), *receiver); receiver = isolate->global_object(); - StoreGlobalIC ic(isolate, vector, vector_slot, kind, language_mode); + StoreGlobalIC ic(isolate, vector, vector_slot, kind); ic.UpdateState(receiver, key); RETURN_RESULT_OR_FAILURE(isolate, ic.Store(key, value)); } else { DCHECK(IsKeyedStoreICKind(kind)); - KeyedStoreIC ic(isolate, vector, vector_slot, kind, language_mode); + KeyedStoreIC ic(isolate, vector, vector_slot, kind); ic.UpdateState(receiver, key); RETURN_RESULT_OR_FAILURE(isolate, ic.Store(receiver, key, value)); } @@ -2361,24 +2344,19 @@ RUNTIME_FUNCTION(Runtime_StoreIC_Miss) { RUNTIME_FUNCTION(Runtime_StoreICNoFeedback_Miss) { HandleScope scope(isolate); - DCHECK_EQ(5, args.length()); + DCHECK_EQ(4, args.length()); Handle value = args.at(0); Handle receiver = args.at(1); Handle key = args.at(2); - CONVERT_LANGUAGE_MODE_ARG_CHECKED(language_mode, 3); - CONVERT_INT32_ARG_CHECKED(is_own_property_value, 4); + CONVERT_INT32_ARG_CHECKED(is_own_property_value, 3); NamedPropertyType property_type = static_cast(is_own_property_value); - FeedbackSlotKind kind = (language_mode == LanguageMode::kStrict) - ? FeedbackSlotKind::kStoreNamedStrict - : FeedbackSlotKind::kStoreNamedSloppy; + FeedbackSlotKind kind = FeedbackSlotKind::kStoreNamedStrict; if (property_type == NamedPropertyType::kOwn) { - language_mode = LanguageMode::kStrict; kind = FeedbackSlotKind::kStoreOwnNamed; } - StoreIC ic(isolate, Handle(), FeedbackSlot(), kind, - language_mode); + StoreIC ic(isolate, Handle(), FeedbackSlot(), kind); 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()); FeedbackSlotKind kind = vector->GetKind(vector_slot); - LanguageMode language_mode = GetLanguageMode(vector, isolate->context()); - StoreGlobalIC ic(isolate, vector, vector_slot, kind, language_mode); + StoreGlobalIC ic(isolate, vector, vector_slot, kind); Handle global = isolate->global_object(); ic.UpdateState(global, key); RETURN_RESULT_OR_FAILURE(isolate, ic.Store(key, value)); @@ -2402,31 +2379,29 @@ RUNTIME_FUNCTION(Runtime_StoreGlobalIC_Miss) { RUNTIME_FUNCTION(Runtime_StoreGlobalICNoFeedback_Miss) { HandleScope scope(isolate); - DCHECK_EQ(3, args.length()); + DCHECK_EQ(2, args.length()); // Runtime functions don't follow the IC's calling convention. Handle value = args.at(0); Handle key = args.at(1); - CONVERT_LANGUAGE_MODE_ARG_CHECKED(language_mode, 2); - FeedbackSlotKind kind = (language_mode == LanguageMode::kStrict) - ? FeedbackSlotKind::kStoreGlobalStrict - : FeedbackSlotKind::kStoreGlobalSloppy; - StoreGlobalIC ic(isolate, Handle(), FeedbackSlot(), kind, - language_mode); + StoreGlobalIC ic(isolate, Handle(), FeedbackSlot(), + FeedbackSlotKind::kStoreGlobalStrict); 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) { HandleScope scope(isolate); DCHECK_EQ(5, args.length()); // Runtime functions don't follow the IC's calling convention. Handle value = args.at(0); - Handle vector = args.at(2); CONVERT_ARG_HANDLE_CHECKED(String, name, 4); #ifdef DEBUG { Handle slot = args.at(1); + Handle vector = args.at(2); FeedbackSlot vector_slot = FeedbackVector::ToSlot(slot->value()); FeedbackSlotKind slot_kind = vector->GetKind(vector_slot); DCHECK(IsStoreGlobalICKind(slot_kind)); @@ -2462,11 +2437,9 @@ RUNTIME_FUNCTION(Runtime_StoreGlobalIC_Slow) { return *value; } - LanguageMode language_mode = GetLanguageMode(vector, isolate->context()); RETURN_RESULT_OR_FAILURE( - isolate, - Runtime::SetObjectProperty(isolate, global, name, value, language_mode, - StoreOrigin::kMaybeKeyed)); + isolate, Runtime::SetObjectProperty(isolate, global, name, value, + StoreOrigin::kMaybeKeyed)); } RUNTIME_FUNCTION(Runtime_KeyedStoreIC_Miss) { @@ -2479,14 +2452,13 @@ RUNTIME_FUNCTION(Runtime_KeyedStoreIC_Miss) { Handle receiver = args.at(3); Handle key = args.at(4); - LanguageMode language_mode = GetLanguageMode(vector, isolate->context()); FeedbackSlot vector_slot = FeedbackVector::ToSlot(slot->value()); FeedbackSlotKind kind = vector->GetKind(vector_slot); // The elements store stubs miss into this function, but they are shared by // different ICs. if (IsKeyedStoreICKind(kind)) { - KeyedStoreIC ic(isolate, vector, vector_slot, kind, language_mode); + KeyedStoreIC ic(isolate, vector, vector_slot, kind); ic.UpdateState(receiver, key); RETURN_RESULT_OR_FAILURE(isolate, ic.Store(receiver, key, value)); } else { @@ -2502,18 +2474,16 @@ RUNTIME_FUNCTION(Runtime_KeyedStoreIC_Miss) { RUNTIME_FUNCTION(Runtime_KeyedStoreICNoFeedback_Miss) { HandleScope scope(isolate); - DCHECK_EQ(4, args.length()); + DCHECK_EQ(3, args.length()); // Runtime functions don't follow the IC's calling convention. Handle value = args.at(0); Handle receiver = args.at(1); Handle key = args.at(2); - CONVERT_LANGUAGE_MODE_ARG_CHECKED(language_mode, 3); - FeedbackSlotKind kind = (language_mode == LanguageMode::kStrict) - ? FeedbackSlotKind::kStoreKeyedStrict - : FeedbackSlotKind::kStoreKeyedSloppy; - KeyedStoreIC ic(isolate, Handle(), FeedbackSlot(), kind, - language_mode); + // TODO(mythria): Replace StoreKeyedStrict and StoreKeyedSloppy with + // StoreKeyed. + KeyedStoreIC ic(isolate, Handle(), FeedbackSlot(), + FeedbackSlotKind::kStoreKeyedStrict); RETURN_RESULT_OR_FAILURE(isolate, ic.Store(receiver, key, value)); } @@ -2539,19 +2509,17 @@ RUNTIME_FUNCTION(Runtime_StoreInArrayLiteralIC_Miss) { return *value; } +// TODO(mythria): We don't need feedback and slot here. Remove those arguments. RUNTIME_FUNCTION(Runtime_KeyedStoreIC_Slow) { HandleScope scope(isolate); DCHECK_EQ(5, args.length()); // Runtime functions don't follow the IC's calling convention. Handle value = args.at(0); - Handle vector = args.at(2); Handle object = args.at(3); Handle key = args.at(4); - LanguageMode language_mode = GetLanguageMode(vector, isolate->context()); RETURN_RESULT_OR_FAILURE( - isolate, - Runtime::SetObjectProperty(isolate, object, key, value, language_mode, - StoreOrigin::kMaybeKeyed)); + isolate, Runtime::SetObjectProperty(isolate, object, key, value, + StoreOrigin::kMaybeKeyed)); } RUNTIME_FUNCTION(Runtime_StoreInArrayLiteralIC_Slow) { @@ -2588,11 +2556,9 @@ RUNTIME_FUNCTION(Runtime_ElementsTransitionAndStoreIC_Miss) { return *value; } else { DCHECK(IsKeyedStoreICKind(kind) || IsStoreICKind(kind)); - LanguageMode language_mode = GetLanguageMode(vector, isolate->context()); RETURN_RESULT_OR_FAILURE( - isolate, - Runtime::SetObjectProperty(isolate, object, key, value, language_mode, - StoreOrigin::kMaybeKeyed)); + isolate, Runtime::SetObjectProperty(isolate, object, key, value, + StoreOrigin::kMaybeKeyed)); } } @@ -2734,20 +2700,17 @@ RUNTIME_FUNCTION(Runtime_StoreCallbackProperty) { Handle info = args.at(2); Handle name = args.at(3); Handle value = args.at(4); - CONVERT_LANGUAGE_MODE_ARG_CHECKED(language_mode, 5); HandleScope scope(isolate); if (V8_UNLIKELY(FLAG_runtime_stats)) { RETURN_RESULT_OR_FAILURE( - isolate, - Runtime::SetObjectProperty(isolate, receiver, name, value, - language_mode, StoreOrigin::kMaybeKeyed)); + isolate, Runtime::SetObjectProperty(isolate, receiver, name, value, + StoreOrigin::kMaybeKeyed)); } DCHECK(info->IsCompatibleReceiver(*receiver)); - ShouldThrow should_throw = - is_sloppy(language_mode) ? kDontThrow : kThrowOnError; + ShouldThrow should_throw = GetShouldThrow(isolate, Nothing()); PropertyCallbackArguments arguments(isolate, info->data(), *receiver, *holder, should_throw); arguments.CallAccessorSetter(info, name, value); @@ -2859,7 +2822,6 @@ RUNTIME_FUNCTION(Runtime_StorePropertyWithInterceptor) { Handle receiver = args.at(3); Handle name = args.at(4); 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 // for LoadHandler::kInterceptor case. @@ -2892,9 +2854,8 @@ RUNTIME_FUNCTION(Runtime_StorePropertyWithInterceptor) { DCHECK_EQ(LookupIterator::INTERCEPTOR, it.state()); it.Next(); - MAYBE_RETURN( - Object::SetProperty(&it, value, language_mode, StoreOrigin::kNamed), - ReadOnlyRoots(isolate).exception()); + MAYBE_RETURN(Object::SetProperty(&it, value, StoreOrigin::kNamed), + ReadOnlyRoots(isolate).exception()); return *value; } diff --git a/src/ic/ic.h b/src/ic/ic.h index 9ed469410f..68dc023b13 100644 --- a/src/ic/ic.h +++ b/src/ic/ic.h @@ -288,13 +288,11 @@ class KeyedLoadIC : public LoadIC { class StoreIC : public IC { public: StoreIC(Isolate* isolate, Handle vector, FeedbackSlot slot, - FeedbackSlotKind kind, LanguageMode language_mode) - : IC(isolate, vector, slot, kind), language_mode_(language_mode) { + FeedbackSlotKind kind) + : IC(isolate, vector, slot, kind) { DCHECK(IsAnyStore()); } - LanguageMode language_mode() const { return language_mode_; } - V8_WARN_UNUSED_RESULT MaybeHandle Store( Handle object, Handle name, Handle value, StoreOrigin store_origin = StoreOrigin::kNamed); @@ -314,11 +312,6 @@ class StoreIC : public IC { void UpdateCaches(LookupIterator* lookup, Handle value, 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: MaybeObjectHandle ComputeHandler(LookupIterator* lookup); @@ -328,9 +321,8 @@ class StoreIC : public IC { class StoreGlobalIC : public StoreIC { public: StoreGlobalIC(Isolate* isolate, Handle vector, - FeedbackSlot slot, FeedbackSlotKind kind, - LanguageMode language_mode) - : StoreIC(isolate, vector, slot, kind, language_mode) {} + FeedbackSlot slot, FeedbackSlotKind kind) + : StoreIC(isolate, vector, slot, kind) {} V8_WARN_UNUSED_RESULT MaybeHandle Store(Handle name, Handle value); @@ -354,9 +346,8 @@ class KeyedStoreIC : public StoreIC { } KeyedStoreIC(Isolate* isolate, Handle vector, - FeedbackSlot slot, FeedbackSlotKind kind, - LanguageMode language_mode) - : StoreIC(isolate, vector, slot, kind, language_mode) {} + FeedbackSlot slot, FeedbackSlotKind kind) + : StoreIC(isolate, vector, slot, kind) {} V8_WARN_UNUSED_RESULT MaybeHandle Store(Handle object, Handle name, @@ -390,8 +381,7 @@ class StoreInArrayLiteralIC : public KeyedStoreIC { StoreInArrayLiteralIC(Isolate* isolate, Handle vector, FeedbackSlot slot) : KeyedStoreIC(isolate, vector, slot, - FeedbackSlotKind::kStoreInArrayLiteral, - LanguageMode::kStrict) { + FeedbackSlotKind::kStoreInArrayLiteral) { DCHECK(IsStoreInArrayLiteralICKind(kind())); } diff --git a/src/interpreter/interpreter-generator.cc b/src/interpreter/interpreter-generator.cc index 0ac2146731..3636773d3e 100644 --- a/src/interpreter/interpreter-generator.cc +++ b/src/interpreter/interpreter-generator.cc @@ -237,10 +237,7 @@ IGNITION_HANDLER(StaGlobal, InterpreterAssembler) { Goto(&end); Bind(&no_feedback); - TNode closure = CAST(LoadRegister(Register::function_closure())); - Node* language_mode = GetLanguageMode(closure, context); - CallRuntime(Runtime::kStoreGlobalICNoFeedback_Miss, context, value, name, - language_mode); + CallRuntime(Runtime::kStoreGlobalICNoFeedback_Miss, context, value, name); Goto(&end); Bind(&end); @@ -616,11 +613,8 @@ class InterpreterStoreNamedPropertyAssembler : public InterpreterAssembler { Goto(&end); Bind(&no_feedback); - TNode closure = - CAST(LoadRegister(Register::function_closure())); - Node* language_mode = GetLanguageMode(closure, context); var_result.Bind(CallRuntime(Runtime::kStoreICNoFeedback_Miss, context, - value, object, name, language_mode, + value, object, name, SmiConstant(property_type))); Goto(&end); @@ -695,10 +689,8 @@ IGNITION_HANDLER(StaKeyedProperty, InterpreterAssembler) { Goto(&end); Bind(&no_feedback); - TNode closure = CAST(LoadRegister(Register::function_closure())); - Node* language_mode = GetLanguageMode(closure, context); var_result.Bind(CallRuntime(Runtime::kKeyedStoreICNoFeedback_Miss, context, - value, object, name, language_mode)); + value, object, name)); Goto(&end); Bind(&end); diff --git a/src/isolate.cc b/src/isolate.cc index 8549c08b0b..c7e362aa11 100644 --- a/src/isolate.cc +++ b/src/isolate.cc @@ -942,10 +942,12 @@ MaybeHandle Isolate::CaptureAndSetDetailedStackTrace( Handle stack_trace = CaptureCurrentStackTrace( stack_trace_for_uncaught_exceptions_frame_limit_, stack_trace_for_uncaught_exceptions_options_); - RETURN_ON_EXCEPTION(this, - Object::SetProperty(this, error_object, key, - stack_trace, LanguageMode::kStrict), - JSReceiver); + RETURN_ON_EXCEPTION( + this, + Object::SetProperty(this, error_object, key, stack_trace, + StoreOrigin::kMaybeKeyed, + Just(LanguageMode::kStrict)), + JSReceiver); } return error_object; } @@ -959,7 +961,8 @@ MaybeHandle Isolate::CaptureAndSetSimpleStackTrace( CaptureSimpleStackTrace(error_object, mode, caller); RETURN_ON_EXCEPTION(this, Object::SetProperty(this, error_object, key, stack_trace, - LanguageMode::kStrict), + StoreOrigin::kMaybeKeyed, + Just(LanguageMode::kStrict)), JSReceiver); return error_object; } diff --git a/src/objects-inl.h b/src/objects-inl.h index 0bad18efa8..e630025373 100644 --- a/src/objects-inl.h +++ b/src/objects-inl.h @@ -698,7 +698,7 @@ MaybeHandle Object::SetElement(Isolate* isolate, Handle object, LanguageMode language_mode) { LookupIterator it(isolate, object, index); MAYBE_RETURN_NULL( - SetProperty(&it, value, language_mode, StoreOrigin::kMaybeKeyed)); + SetProperty(&it, value, StoreOrigin::kMaybeKeyed, Just(language_mode))); return value; } @@ -1177,14 +1177,12 @@ MaybeHandle Object::GetPropertyOrElement(Isolate* isolate, return GetProperty(&it); } -MaybeHandle Object::SetPropertyOrElement(Isolate* isolate, - Handle object, - Handle name, - Handle value, - LanguageMode language_mode, - StoreOrigin store_origin) { +MaybeHandle Object::SetPropertyOrElement( + Isolate* isolate, Handle object, Handle name, + Handle value, Maybe language_mode, + StoreOrigin store_origin) { 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; } diff --git a/src/objects.cc b/src/objects.cc index 119c6aed72..c6be4caea8 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -123,6 +123,36 @@ namespace v8 { namespace internal { +namespace { +LanguageMode GetLanguageMode(Isolate* isolate, + Maybe 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(it.frame()); + std::vector 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 language_mode) { + return is_sloppy(GetLanguageMode(isolate, language_mode)) ? kDontThrow + : kThrowOnError; +} + bool ComparisonResultToBool(Operation op, ComparisonResult result) { switch (op) { case Operation::kLessThan: @@ -1805,7 +1835,6 @@ MaybeHandle Object::GetPropertyWithDefinedGetter( return Execution::Call(isolate, getter, receiver, 0, nullptr); } - Maybe Object::SetPropertyWithDefinedSetter(Handle receiver, Handle setter, Handle value, @@ -2272,7 +2301,7 @@ V8_WARN_UNUSED_RESULT Maybe FastAssign( if (use_set) { LookupIterator it(target, next_key, target); Maybe result = Object::SetProperty( - &it, prop_value, LanguageMode::kStrict, StoreOrigin::kNamed); + &it, prop_value, StoreOrigin::kNamed, Just(LanguageMode::kStrict)); if (result.IsNothing()) return result; if (stable) stable = from->map() == *map; } else { @@ -2335,8 +2364,8 @@ Maybe JSReceiver::SetOrCopyDataProperties( ASSIGN_RETURN_ON_EXCEPTION_VALUE( isolate, status, Runtime::SetObjectProperty(isolate, target, next_key, prop_value, - LanguageMode::kStrict, - StoreOrigin::kMaybeKeyed), + StoreOrigin::kMaybeKeyed, + Just(LanguageMode::kStrict)), Nothing()); } else { if (excluded_properties != nullptr && @@ -5180,21 +5209,20 @@ Maybe JSObject::SetPropertyWithInterceptor(LookupIterator* it, MaybeHandle Object::SetProperty(Isolate* isolate, Handle object, Handle name, Handle value, - LanguageMode language_mode, - StoreOrigin store_origin) { + StoreOrigin store_origin, + Maybe language_mode) { 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; } Maybe Object::SetPropertyInternal(LookupIterator* it, Handle value, - LanguageMode language_mode, + Maybe language_mode, StoreOrigin store_origin, bool* found) { it->UpdateProtector(); DCHECK(it->IsFound()); - ShouldThrow should_throw = - is_sloppy(language_mode) ? kDontThrow : kThrowOnError; + ShouldThrow should_throw = GetShouldThrow(it->isolate(), language_mode); // Make sure that the top context does not change when doing callbacks or // interceptor calls. @@ -5220,8 +5248,9 @@ Maybe Object::SetPropertyInternal(LookupIterator* it, receiver = handle(JSGlobalObject::cast(*receiver)->global_proxy(), it->isolate()); } - return JSProxy::SetProperty(it->GetHolder(), it->GetName(), - value, receiver, language_mode); + return JSProxy::SetProperty( + it->GetHolder(), it->GetName(), value, receiver, + GetLanguageMode(it->isolate(), language_mode)); } case LookupIterator::INTERCEPTOR: { @@ -5304,8 +5333,8 @@ Maybe Object::SetPropertyInternal(LookupIterator* it, } Maybe Object::SetProperty(LookupIterator* it, Handle value, - LanguageMode language_mode, - StoreOrigin store_origin) { + StoreOrigin store_origin, + Maybe language_mode) { if (it->IsFound()) { bool found = true; Maybe result = @@ -5316,20 +5345,21 @@ Maybe Object::SetProperty(LookupIterator* it, Handle value, // 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 // 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( MessageTemplate::kNotDefined, it->name())); return Nothing(); } - ShouldThrow should_throw = - is_sloppy(language_mode) ? kDontThrow : kThrowOnError; - return AddDataProperty(it, value, NONE, should_throw, store_origin); + return AddDataProperty(it, value, NONE, + GetShouldThrow(it->isolate(), language_mode), + store_origin); } Maybe Object::SetSuperProperty(LookupIterator* it, Handle value, - LanguageMode language_mode, - StoreOrigin store_origin) { + StoreOrigin store_origin, + Maybe language_mode) { Isolate* isolate = it->isolate(); if (it->IsFound()) { @@ -5344,8 +5374,7 @@ Maybe Object::SetSuperProperty(LookupIterator* it, Handle value, // The property either doesn't exist on the holder or exists there as a data // property. - ShouldThrow should_throw = - is_sloppy(language_mode) ? kDontThrow : kThrowOnError; + ShouldThrow should_throw = GetShouldThrow(it->isolate(), language_mode); if (!it->GetReceiver()->IsJSReceiver()) { return WriteToReadOnlyProperty(it, value, should_throw); @@ -6058,8 +6087,8 @@ Maybe JSProxy::SetProperty(Handle proxy, Handle name, if (trap->IsUndefined(isolate)) { LookupIterator it = LookupIterator::PropertyOrElement(isolate, receiver, name, target); - return Object::SetSuperProperty(&it, value, language_mode, - StoreOrigin::kMaybeKeyed); + return Object::SetSuperProperty(&it, value, StoreOrigin::kMaybeKeyed, + Just(language_mode)); } Handle trap_result; @@ -16614,7 +16643,7 @@ MaybeHandle JSPromise::Resolve(Handle promise, // Mark the dependency of the new {promise} on the {resolution}. Object::SetProperty(isolate, resolution, isolate->factory()->promise_handled_by_symbol(), - promise, LanguageMode::kStrict) + promise) .Check(); } isolate->native_context()->microtask_queue()->EnqueueMicrotask(*task); @@ -16937,8 +16966,7 @@ MaybeHandle JSRegExp::Initialize(Handle regexp, RETURN_ON_EXCEPTION( isolate, Object::SetProperty(isolate, regexp, factory->lastIndex_string(), - Handle(Smi::zero(), isolate), - LanguageMode::kStrict), + Handle(Smi::zero(), isolate)), JSRegExp); } diff --git a/src/objects.h b/src/objects.h index 72d3511c6f..2b2157a82e 100644 --- a/src/objects.h +++ b/src/objects.h @@ -531,6 +531,9 @@ class ZoneForwardList; // The element types selection for CreateListFromArrayLike. enum class ElementTypes { kAll, kStringAndSymbol }; +// TODO(mythria): Move this to a better place. +ShouldThrow GetShouldThrow(Isolate* isolate, Maybe language_mode); + // Object is the abstract superclass for all classes in the // object hierarchy. // 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 // covered by it (eg., concerning API callbacks). V8_WARN_UNUSED_RESULT static Maybe SetProperty( - LookupIterator* it, Handle value, LanguageMode language_mode, - StoreOrigin store_origin); + LookupIterator* it, Handle value, StoreOrigin store_origin, + Maybe language_mode = Nothing()); V8_WARN_UNUSED_RESULT static MaybeHandle SetProperty( Isolate* isolate, Handle object, Handle name, - Handle value, LanguageMode language_mode, - StoreOrigin store_origin = StoreOrigin::kMaybeKeyed); + Handle value, StoreOrigin store_origin = StoreOrigin::kMaybeKeyed, + Maybe language_mode = Nothing()); V8_WARN_UNUSED_RESULT static inline MaybeHandle SetPropertyOrElement( Isolate* isolate, Handle object, Handle name, - Handle value, LanguageMode language_mode, + Handle value, + Maybe language_mode = Nothing(), StoreOrigin store_origin = StoreOrigin::kMaybeKeyed); V8_WARN_UNUSED_RESULT static Maybe SetSuperProperty( - LookupIterator* it, Handle value, LanguageMode language_mode, - StoreOrigin store_origin); + LookupIterator* it, Handle value, StoreOrigin store_origin, + Maybe language_mode = Nothing()); V8_WARN_UNUSED_RESULT static Maybe CannotCreateProperty( Isolate* isolate, Handle receiver, Handle name, @@ -979,8 +983,8 @@ class Object { // Helper for SetProperty and SetSuperProperty. // Return value is only meaningful if [found] is set to true on return. V8_WARN_UNUSED_RESULT static Maybe SetPropertyInternal( - LookupIterator* it, Handle value, LanguageMode language_mode, - StoreOrigin store_origin, bool* found); + LookupIterator* it, Handle value, + Maybe language_mode, StoreOrigin store_origin, bool* found); V8_WARN_UNUSED_RESULT static MaybeHandle ConvertToName( Isolate* isolate, Handle input); diff --git a/src/pending-compilation-error-handler.cc b/src/pending-compilation-error-handler.cc index 5119e06cc8..c109a4e50c 100644 --- a/src/pending-compilation-error-handler.cc +++ b/src/pending-compilation-error-handler.cc @@ -120,18 +120,18 @@ void PendingCompilationErrorHandler::ThrowPendingError(Isolate* isolate, Handle key_start_pos = factory->error_start_pos_symbol(); Object::SetProperty(isolate, jserror, key_start_pos, handle(Smi::FromInt(location.start_pos()), isolate), - LanguageMode::kSloppy) + StoreOrigin::kMaybeKeyed, Just(LanguageMode::kStrict)) .Check(); Handle key_end_pos = factory->error_end_pos_symbol(); Object::SetProperty(isolate, jserror, key_end_pos, handle(Smi::FromInt(location.end_pos()), isolate), - LanguageMode::kSloppy) + StoreOrigin::kMaybeKeyed, Just(LanguageMode::kStrict)) .Check(); Handle key_script = factory->error_script_symbol(); Object::SetProperty(isolate, jserror, key_script, script, - LanguageMode::kSloppy) + StoreOrigin::kMaybeKeyed, Just(LanguageMode::kStrict)) .Check(); isolate->Throw(*error, &location); diff --git a/src/regexp/regexp-utils.cc b/src/regexp/regexp-utils.cc index 56b1e1b708..f22ea2c07e 100644 --- a/src/regexp/regexp-utils.cc +++ b/src/regexp/regexp-utils.cc @@ -51,9 +51,9 @@ MaybeHandle RegExpUtils::SetLastIndex(Isolate* isolate, JSRegExp::cast(*recv)->set_last_index(*value_as_object, SKIP_WRITE_BARRIER); return recv; } else { - return Object::SetProperty(isolate, recv, - isolate->factory()->lastIndex_string(), - value_as_object, LanguageMode::kStrict); + return Object::SetProperty( + isolate, recv, isolate->factory()->lastIndex_string(), value_as_object, + StoreOrigin::kMaybeKeyed, Just(LanguageMode::kStrict)); } } diff --git a/src/runtime/runtime-classes.cc b/src/runtime/runtime-classes.cc index 02db33733e..6e7c61dbdc 100644 --- a/src/runtime/runtime-classes.cc +++ b/src/runtime/runtime-classes.cc @@ -771,25 +771,22 @@ namespace { MaybeHandle StoreToSuper(Isolate* isolate, Handle home_object, Handle receiver, Handle name, - Handle value, - LanguageMode language_mode) { + Handle value) { Handle holder; ASSIGN_RETURN_ON_EXCEPTION(isolate, holder, GetSuperHolder(isolate, receiver, home_object, SuperMode::kStore, name, 0), Object); LookupIterator it(receiver, name, holder); - MAYBE_RETURN( - Object::SetSuperProperty(&it, value, language_mode, StoreOrigin::kNamed), - MaybeHandle()); + MAYBE_RETURN(Object::SetSuperProperty(&it, value, StoreOrigin::kNamed), + MaybeHandle()); return value; } MaybeHandle StoreElementToSuper(Isolate* isolate, Handle home_object, Handle receiver, uint32_t index, - Handle value, - LanguageMode language_mode) { + Handle value) { Handle holder; ASSIGN_RETURN_ON_EXCEPTION( isolate, holder, @@ -797,8 +794,7 @@ MaybeHandle StoreElementToSuper(Isolate* isolate, MaybeHandle(), index), Object); LookupIterator it(isolate, receiver, index, holder); - MAYBE_RETURN(Object::SetSuperProperty(&it, value, language_mode, - StoreOrigin::kMaybeKeyed), + MAYBE_RETURN(Object::SetSuperProperty(&it, value, StoreOrigin::kMaybeKeyed), MaybeHandle()); return value; } @@ -814,11 +810,11 @@ RUNTIME_FUNCTION(Runtime_StoreToSuper_Strict) { CONVERT_ARG_HANDLE_CHECKED(Object, value, 3); RETURN_RESULT_OR_FAILURE( - isolate, StoreToSuper(isolate, home_object, receiver, name, value, - LanguageMode::kStrict)); + isolate, StoreToSuper(isolate, home_object, receiver, name, value)); } - +// TODO(mythria): Now that we don't need language mode merge this and +// Runtime_StoreToSuper_Strict functions. RUNTIME_FUNCTION(Runtime_StoreToSuper_Sloppy) { HandleScope scope(isolate); DCHECK_EQ(4, args.length()); @@ -828,32 +824,29 @@ RUNTIME_FUNCTION(Runtime_StoreToSuper_Sloppy) { CONVERT_ARG_HANDLE_CHECKED(Object, value, 3); RETURN_RESULT_OR_FAILURE( - isolate, StoreToSuper(isolate, home_object, receiver, name, value, - LanguageMode::kSloppy)); + isolate, StoreToSuper(isolate, home_object, receiver, name, value)); } -static MaybeHandle StoreKeyedToSuper( - Isolate* isolate, Handle home_object, Handle receiver, - Handle key, Handle value, LanguageMode language_mode) { +static MaybeHandle StoreKeyedToSuper(Isolate* isolate, + Handle home_object, + Handle receiver, + Handle key, + Handle value) { uint32_t index = 0; if (key->ToArrayIndex(&index)) { - return StoreElementToSuper(isolate, home_object, receiver, index, value, - language_mode); + return StoreElementToSuper(isolate, home_object, receiver, index, value); } Handle name; ASSIGN_RETURN_ON_EXCEPTION(isolate, name, Object::ToName(isolate, key), Object); // TODO(verwaest): Unify using LookupIterator. if (name->AsArrayIndex(&index)) { - return StoreElementToSuper(isolate, home_object, receiver, index, value, - language_mode); + return StoreElementToSuper(isolate, home_object, receiver, index, value); } - return StoreToSuper(isolate, home_object, receiver, name, value, - language_mode); + return StoreToSuper(isolate, home_object, receiver, name, value); } - RUNTIME_FUNCTION(Runtime_StoreKeyedToSuper_Strict) { HandleScope scope(isolate); DCHECK_EQ(4, args.length()); @@ -863,11 +856,11 @@ RUNTIME_FUNCTION(Runtime_StoreKeyedToSuper_Strict) { CONVERT_ARG_HANDLE_CHECKED(Object, value, 3); RETURN_RESULT_OR_FAILURE( - isolate, StoreKeyedToSuper(isolate, home_object, receiver, key, value, - LanguageMode::kStrict)); + isolate, StoreKeyedToSuper(isolate, home_object, receiver, key, value)); } - +// TODO(mythria): Now that we don't need language mode merge this and +// Runtime_StoreKeyedToSuper_Strict functions. RUNTIME_FUNCTION(Runtime_StoreKeyedToSuper_Sloppy) { HandleScope scope(isolate); DCHECK_EQ(4, args.length()); @@ -877,8 +870,7 @@ RUNTIME_FUNCTION(Runtime_StoreKeyedToSuper_Sloppy) { CONVERT_ARG_HANDLE_CHECKED(Object, value, 3); RETURN_RESULT_OR_FAILURE( - isolate, StoreKeyedToSuper(isolate, home_object, receiver, key, value, - LanguageMode::kSloppy)); + isolate, StoreKeyedToSuper(isolate, home_object, receiver, key, value)); } } // namespace internal diff --git a/src/runtime/runtime-object.cc b/src/runtime/runtime-object.cc index fd3d2dd168..432f11a622 100644 --- a/src/runtime/runtime-object.cc +++ b/src/runtime/runtime-object.cc @@ -341,12 +341,10 @@ RUNTIME_FUNCTION(Runtime_ObjectCreate) { return *obj; } -MaybeHandle Runtime::SetObjectProperty(Isolate* isolate, - Handle object, - Handle key, - Handle value, - LanguageMode language_mode, - StoreOrigin store_origin) { +MaybeHandle Runtime::SetObjectProperty( + Isolate* isolate, Handle object, Handle key, + Handle value, StoreOrigin store_origin, + Maybe language_mode) { if (object->IsNullOrUndefined(isolate)) { THROW_NEW_ERROR( isolate, @@ -371,12 +369,11 @@ MaybeHandle Runtime::SetObjectProperty(Isolate* isolate, } MAYBE_RETURN_NULL( - Object::SetProperty(&it, value, language_mode, store_origin)); + Object::SetProperty(&it, value, store_origin, language_mode)); return value; } - RUNTIME_FUNCTION(Runtime_InternalSetPrototype) { HandleScope scope(isolate); DCHECK_EQ(2, args.length()); @@ -547,6 +544,7 @@ RUNTIME_FUNCTION(Runtime_GetProperty) { isolate, Runtime::GetObjectProperty(isolate, receiver_obj, key_obj)); } +// TODO(mythria): Remove language mode parameter to SetKeyedProperty RUNTIME_FUNCTION(Runtime_SetKeyedProperty) { HandleScope scope(isolate); 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, key, 1); CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); - CONVERT_LANGUAGE_MODE_ARG_CHECKED(language_mode, 3); RETURN_RESULT_OR_FAILURE( - isolate, - Runtime::SetObjectProperty(isolate, object, key, value, language_mode, - StoreOrigin::kMaybeKeyed)); + isolate, Runtime::SetObjectProperty(isolate, object, key, value, + StoreOrigin::kMaybeKeyed)); } +// TODO(mythria): Remove language mode parameter to SetNamedProperty RUNTIME_FUNCTION(Runtime_SetNamedProperty) { HandleScope scope(isolate); 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, key, 1); CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); - CONVERT_LANGUAGE_MODE_ARG_CHECKED(language_mode, 3); RETURN_RESULT_OR_FAILURE( isolate, Runtime::SetObjectProperty(isolate, object, key, value, - language_mode, StoreOrigin::kNamed)); + StoreOrigin::kNamed)); } // Similar to DefineDataPropertyInLiteral, but does not update feedback, and diff --git a/src/runtime/runtime-promise.cc b/src/runtime/runtime-promise.cc index cd76d5ee7d..48262db4b3 100644 --- a/src/runtime/runtime-promise.cc +++ b/src/runtime/runtime-promise.cc @@ -158,16 +158,17 @@ Handle AwaitPromisesInitCommon(Isolate* isolate, Object::SetProperty( isolate, reject_handler, isolate->factory()->promise_forwarding_handler_symbol(), - isolate->factory()->true_value(), LanguageMode::kStrict) + isolate->factory()->true_value(), StoreOrigin::kMaybeKeyed, + Just(LanguageMode::kStrict)) .Check(); Handle::cast(value)->set_handled_hint(is_predicted_as_caught); } // Mark the dependency to {outer_promise} in case the {throwaway} // Promise is found on the Promise stack - Object::SetProperty(isolate, throwaway, - isolate->factory()->promise_handled_by_symbol(), - outer_promise, LanguageMode::kStrict) + Object::SetProperty( + isolate, throwaway, isolate->factory()->promise_handled_by_symbol(), + outer_promise, StoreOrigin::kMaybeKeyed, Just(LanguageMode::kStrict)) .Check(); } diff --git a/src/runtime/runtime-proxy.cc b/src/runtime/runtime-proxy.cc index f4f84ebec9..66f71f56d9 100644 --- a/src/runtime/runtime-proxy.cc +++ b/src/runtime/runtime-proxy.cc @@ -61,6 +61,7 @@ RUNTIME_FUNCTION(Runtime_GetPropertyWithReceiver) { &it, static_cast(on_non_existent->value()))); } +// TODO(mythria): Remove language_mode parameter. RUNTIME_FUNCTION(Runtime_SetPropertyWithReceiver) { HandleScope scope(isolate); @@ -69,7 +70,6 @@ RUNTIME_FUNCTION(Runtime_SetPropertyWithReceiver) { CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 3); - CONVERT_LANGUAGE_MODE_ARG_CHECKED(language_mode, 4); bool success = false; LookupIterator it = LookupIterator::PropertyOrElement(isolate, receiver, key, @@ -78,8 +78,8 @@ RUNTIME_FUNCTION(Runtime_SetPropertyWithReceiver) { DCHECK(isolate->has_pending_exception()); return ReadOnlyRoots(isolate).exception(); } - Maybe result = Object::SetSuperProperty(&it, value, language_mode, - StoreOrigin::kMaybeKeyed); + Maybe result = + Object::SetSuperProperty(&it, value, StoreOrigin::kMaybeKeyed); MAYBE_RETURN(result, ReadOnlyRoots(isolate).exception()); return *isolate->factory()->ToBoolean(result.FromJust()); } diff --git a/src/runtime/runtime-scopes.cc b/src/runtime/runtime-scopes.cc index 8227242940..2828b38121 100644 --- a/src/runtime/runtime-scopes.cc +++ b/src/runtime/runtime-scopes.cc @@ -948,9 +948,9 @@ MaybeHandle StoreLookupSlot( object = handle(context->global_object(), isolate); } - ASSIGN_RETURN_ON_EXCEPTION( - isolate, value, - Object::SetProperty(isolate, object, name, value, language_mode), Object); + ASSIGN_RETURN_ON_EXCEPTION(isolate, value, + Object::SetProperty(isolate, object, name, value), + Object); return value; } diff --git a/src/runtime/runtime-wasm.cc b/src/runtime/runtime-wasm.cc index a94f122f6a..3cc8dd4087 100644 --- a/src/runtime/runtime-wasm.cc +++ b/src/runtime/runtime-wasm.cc @@ -123,8 +123,20 @@ RUNTIME_FUNCTION(Runtime_WasmThrowCreate) { CONVERT_ARG_CHECKED(WasmExceptionTag, tag_raw, 0); CONVERT_SMI_ARG_CHECKED(size, 1); // TODO(mstarzinger): Manually box because parameters are not visited yet. - Handle tag(tag_raw, isolate); - Handle exception = WasmExceptionPackage::New(isolate, tag, size); + Handle tag(tag_raw, isolate); + Handle 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 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; } diff --git a/src/runtime/runtime.h b/src/runtime/runtime.h index 43e4e99f5a..1163feb0ea 100644 --- a/src/runtime/runtime.h +++ b/src/runtime/runtime.h @@ -554,7 +554,7 @@ namespace internal { F(ElementsTransitionAndStoreIC_Miss, 6, 1) \ F(KeyedLoadIC_Miss, 4, 1) \ F(KeyedStoreIC_Miss, 5, 1) \ - F(KeyedStoreICNoFeedback_Miss, 4, 1) \ + F(KeyedStoreICNoFeedback_Miss, 3, 1) \ F(StoreInArrayLiteralIC_Miss, 5, 1) \ F(KeyedStoreIC_Slow, 5, 1) \ F(LoadAccessorProperty, 4, 1) \ @@ -564,12 +564,12 @@ namespace internal { F(LoadGlobalIC_Slow, 3, 1) \ F(LoadIC_Miss, 4, 1) \ F(LoadPropertyWithInterceptor, 5, 1) \ - F(StoreCallbackProperty, 6, 1) \ + F(StoreCallbackProperty, 5, 1) \ F(StoreGlobalIC_Miss, 4, 1) \ - F(StoreGlobalICNoFeedback_Miss, 3, 1) \ + F(StoreGlobalICNoFeedback_Miss, 2, 1) \ F(StoreGlobalIC_Slow, 5, 1) \ F(StoreIC_Miss, 5, 1) \ - F(StoreICNoFeedback_Miss, 5, 1) \ + F(StoreICNoFeedback_Miss, 4, 1) \ F(StoreInArrayLiteralIC_Slow, 5, 1) \ F(StorePropertyWithInterceptor, 5, 1) \ F(CloneObjectIC_Miss, 4, 1) @@ -700,8 +700,8 @@ class Runtime : public AllStatic { V8_WARN_UNUSED_RESULT static MaybeHandle SetObjectProperty( Isolate* isolate, Handle object, Handle key, - Handle value, LanguageMode language_mode, - StoreOrigin store_origin); + Handle value, StoreOrigin store_origin, + Maybe language_mode = Nothing()); V8_WARN_UNUSED_RESULT static MaybeHandle GetObjectProperty( Isolate* isolate, Handle object, Handle key, diff --git a/src/wasm/wasm-objects.cc b/src/wasm/wasm-objects.cc index c401d26967..0a9f08c3bd 100644 --- a/src/wasm/wasm-objects.cc +++ b/src/wasm/wasm-objects.cc @@ -1567,12 +1567,14 @@ Handle WasmExceptionPackage::New( MessageTemplate::kWasmExceptionError); CHECK(!Object::SetProperty(isolate, exception, isolate->factory()->wasm_exception_tag_symbol(), - exception_tag, LanguageMode::kStrict) + exception_tag, StoreOrigin::kMaybeKeyed, + Just(LanguageMode::kStrict)) .is_null()); Handle values = isolate->factory()->NewFixedArray(size); CHECK(!Object::SetProperty(isolate, exception, isolate->factory()->wasm_exception_values_symbol(), - values, LanguageMode::kStrict) + values, StoreOrigin::kMaybeKeyed, + Just(LanguageMode::kStrict)) .is_null()); return Handle::cast(exception); } diff --git a/test/cctest/heap/test-heap.cc b/test/cctest/heap/test-heap.cc index c7c1d93f87..7d1dc87ad0 100644 --- a/test/cctest/heap/test-heap.cc +++ b/test/cctest/heap/test-heap.cc @@ -368,16 +368,11 @@ TEST(GarbageCollection) { HandleScope inner_scope(isolate); // Allocate a function and keep it in global object's property. Handle function = factory->NewFunctionForTest(name); - Object::SetProperty(isolate, global, name, function, LanguageMode::kSloppy) - .Check(); + Object::SetProperty(isolate, global, name, function).Check(); // Allocate an object. Unrooted after leaving the scope. Handle obj = factory->NewJSObject(function); - Object::SetProperty(isolate, obj, prop_name, twenty_three, - LanguageMode::kSloppy) - .Check(); - Object::SetProperty(isolate, obj, prop_namex, twenty_four, - LanguageMode::kSloppy) - .Check(); + Object::SetProperty(isolate, obj, prop_name, twenty_three).Check(); + Object::SetProperty(isolate, obj, prop_namex, twenty_four).Check(); CHECK_EQ(Smi::FromInt(23), *Object::GetProperty(isolate, obj, prop_name).ToHandleChecked()); @@ -399,11 +394,8 @@ TEST(GarbageCollection) { HandleScope inner_scope(isolate); // Allocate another object, make it reachable from global. Handle obj = factory->NewJSObject(function); - Object::SetProperty(isolate, global, obj_name, obj, LanguageMode::kSloppy) - .Check(); - Object::SetProperty(isolate, obj, prop_name, twenty_three, - LanguageMode::kSloppy) - .Check(); + Object::SetProperty(isolate, global, obj_name, obj).Check(); + Object::SetProperty(isolate, obj, prop_name, twenty_three).Check(); } // After gc, it should survive. @@ -944,15 +936,11 @@ TEST(FunctionAllocation) { Handle prop_name = factory->InternalizeUtf8String("theSlot"); Handle obj = factory->NewJSObject(function); - Object::SetProperty(isolate, obj, prop_name, twenty_three, - LanguageMode::kSloppy) - .Check(); + Object::SetProperty(isolate, obj, prop_name, twenty_three).Check(); CHECK_EQ(Smi::FromInt(23), *Object::GetProperty(isolate, obj, prop_name).ToHandleChecked()); // Check that we can add properties to function objects. - Object::SetProperty(isolate, function, prop_name, twenty_four, - LanguageMode::kSloppy) - .Check(); + Object::SetProperty(isolate, function, prop_name, twenty_four).Check(); CHECK_EQ( Smi::FromInt(24), *Object::GetProperty(isolate, function, prop_name).ToHandleChecked()); @@ -983,7 +971,7 @@ TEST(ObjectProperties) { CHECK(Just(false) == JSReceiver::HasOwnProperty(obj, 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)); // delete first @@ -992,8 +980,8 @@ TEST(ObjectProperties) { CHECK(Just(false) == JSReceiver::HasOwnProperty(obj, first)); // add first and then second - Object::SetProperty(isolate, obj, first, one, LanguageMode::kSloppy).Check(); - Object::SetProperty(isolate, obj, second, two, LanguageMode::kSloppy).Check(); + Object::SetProperty(isolate, obj, first, one).Check(); + Object::SetProperty(isolate, obj, second, two).Check(); CHECK(Just(true) == JSReceiver::HasOwnProperty(obj, first)); CHECK(Just(true) == JSReceiver::HasOwnProperty(obj, second)); @@ -1007,8 +995,8 @@ TEST(ObjectProperties) { CHECK(Just(false) == JSReceiver::HasOwnProperty(obj, second)); // add first and then second - Object::SetProperty(isolate, obj, first, one, LanguageMode::kSloppy).Check(); - Object::SetProperty(isolate, obj, second, two, LanguageMode::kSloppy).Check(); + Object::SetProperty(isolate, obj, first, one).Check(); + Object::SetProperty(isolate, obj, second, two).Check(); CHECK(Just(true) == JSReceiver::HasOwnProperty(obj, first)); CHECK(Just(true) == JSReceiver::HasOwnProperty(obj, second)); @@ -1024,15 +1012,14 @@ TEST(ObjectProperties) { // check string and internalized string match const char* string1 = "fisk"; Handle s1 = factory->NewStringFromAsciiChecked(string1); - Object::SetProperty(isolate, obj, s1, one, LanguageMode::kSloppy).Check(); + Object::SetProperty(isolate, obj, s1, one).Check(); Handle s1_string = factory->InternalizeUtf8String(string1); CHECK(Just(true) == JSReceiver::HasOwnProperty(obj, s1_string)); // check internalized string and string match const char* string2 = "fugl"; Handle s2_string = factory->InternalizeUtf8String(string2); - Object::SetProperty(isolate, obj, s2_string, one, LanguageMode::kSloppy) - .Check(); + Object::SetProperty(isolate, obj, s2_string, one).Check(); Handle s2 = factory->NewStringFromAsciiChecked(string2); CHECK(Just(true) == JSReceiver::HasOwnProperty(obj, s2)); } @@ -1053,9 +1040,7 @@ TEST(JSObjectMaps) { // Set a propery Handle twenty_three(Smi::FromInt(23), isolate); - Object::SetProperty(isolate, obj, prop_name, twenty_three, - LanguageMode::kSloppy) - .Check(); + Object::SetProperty(isolate, obj, prop_name, twenty_three).Check(); CHECK_EQ(Smi::FromInt(23), *Object::GetProperty(isolate, obj, prop_name).ToHandleChecked()); @@ -1136,8 +1121,8 @@ TEST(JSObjectCopy) { Handle one(Smi::FromInt(1), isolate); Handle two(Smi::FromInt(2), isolate); - Object::SetProperty(isolate, obj, first, one, LanguageMode::kSloppy).Check(); - Object::SetProperty(isolate, obj, second, two, LanguageMode::kSloppy).Check(); + Object::SetProperty(isolate, obj, first, one).Check(); + Object::SetProperty(isolate, obj, second, two).Check(); Object::SetElement(isolate, obj, 0, first, LanguageMode::kSloppy).Check(); Object::SetElement(isolate, obj, 1, second, LanguageMode::kSloppy).Check(); @@ -1162,10 +1147,8 @@ TEST(JSObjectCopy) { CHECK_EQ(*value1, *value2); // Flip the values. - Object::SetProperty(isolate, clone, first, two, LanguageMode::kSloppy) - .Check(); - Object::SetProperty(isolate, clone, second, one, LanguageMode::kSloppy) - .Check(); + Object::SetProperty(isolate, clone, first, two).Check(); + Object::SetProperty(isolate, clone, second, one).Check(); Object::SetElement(isolate, clone, 0, second, LanguageMode::kSloppy).Check(); Object::SetElement(isolate, clone, 1, first, LanguageMode::kSloppy).Check(); @@ -2983,9 +2966,7 @@ static void AddPropertyTo( FLAG_gc_global = true; FLAG_retain_maps_for_n_gc = 0; CcTest::heap()->set_allocation_timeout(gc_count); - Object::SetProperty(isolate, object, prop_name, twenty_three, - LanguageMode::kSloppy) - .Check(); + Object::SetProperty(isolate, object, prop_name, twenty_three).Check(); } @@ -4855,8 +4836,7 @@ TEST(Regress442710) { Handle array = factory->NewJSArray(2); Handle name = factory->InternalizeUtf8String("testArray"); - Object::SetProperty(isolate, global, name, array, LanguageMode::kSloppy) - .Check(); + Object::SetProperty(isolate, global, name, array).Check(); CompileRun("testArray[0] = 1; testArray[1] = 2; testArray.shift();"); CcTest::CollectGarbage(OLD_SPACE); } diff --git a/test/cctest/heap/test-invalidated-slots.cc b/test/cctest/heap/test-invalidated-slots.cc index 897f4d0242..9eeda75cc5 100644 --- a/test/cctest/heap/test-invalidated-slots.cc +++ b/test/cctest/heap/test-invalidated-slots.cc @@ -330,25 +330,16 @@ HEAP_TEST(InvalidatedSlotsFastToSlow) { // Start incremental marking. heap::SimulateIncrementalMarking(heap); // Set properties to point to the evacuation candidate. - Object::SetProperty(isolate, obj, prop_name1, evacuated, - LanguageMode::kSloppy) - .Check(); - Object::SetProperty(isolate, obj, prop_name2, evacuated, - LanguageMode::kSloppy) - .Check(); - Object::SetProperty(isolate, obj, prop_name3, evacuated, - LanguageMode::kSloppy) - .Check(); + Object::SetProperty(isolate, obj, prop_name1, evacuated).Check(); + Object::SetProperty(isolate, obj, prop_name2, evacuated).Check(); + Object::SetProperty(isolate, obj, prop_name3, evacuated).Check(); { HandleScope scope(isolate); Handle dead = factory->NewFixedArray(1); - Object::SetProperty(isolate, obj, prop_name1, dead, LanguageMode::kSloppy) - .Check(); - Object::SetProperty(isolate, obj, prop_name2, dead, LanguageMode::kSloppy) - .Check(); - Object::SetProperty(isolate, obj, prop_name3, dead, LanguageMode::kSloppy) - .Check(); + Object::SetProperty(isolate, obj, prop_name1, dead).Check(); + Object::SetProperty(isolate, obj, prop_name2, dead).Check(); + Object::SetProperty(isolate, obj, prop_name3, dead).Check(); Handle map(obj->map(), isolate); Handle normalized_map = Map::Normalize(isolate, map, CLEAR_INOBJECT_PROPERTIES, "testing"); diff --git a/test/cctest/heap/test-mark-compact.cc b/test/cctest/heap/test-mark-compact.cc index 4f141af7a5..09ef3f3444 100644 --- a/test/cctest/heap/test-mark-compact.cc +++ b/test/cctest/heap/test-mark-compact.cc @@ -165,9 +165,7 @@ HEAP_TEST(MarkCompactCollector) { // allocate a garbage Handle func_name = factory->InternalizeUtf8String("theFunction"); Handle function = factory->NewFunctionForTest(func_name); - Object::SetProperty(isolate, global, func_name, function, - LanguageMode::kSloppy) - .Check(); + Object::SetProperty(isolate, global, func_name, function).Check(); factory->NewJSObject(function); } @@ -184,13 +182,10 @@ HEAP_TEST(MarkCompactCollector) { Handle obj = factory->NewJSObject(function); Handle obj_name = factory->InternalizeUtf8String("theObject"); - Object::SetProperty(isolate, global, obj_name, obj, LanguageMode::kSloppy) - .Check(); + Object::SetProperty(isolate, global, obj_name, obj).Check(); Handle prop_name = factory->InternalizeUtf8String("theSlot"); Handle twenty_three(Smi::FromInt(23), isolate); - Object::SetProperty(isolate, obj, prop_name, twenty_three, - LanguageMode::kSloppy) - .Check(); + Object::SetProperty(isolate, obj, prop_name, twenty_three).Check(); } CcTest::CollectGarbage(OLD_SPACE); diff --git a/test/cctest/test-compiler.cc b/test/cctest/test-compiler.cc index f05056a2de..3934194460 100644 --- a/test/cctest/test-compiler.cc +++ b/test/cctest/test-compiler.cc @@ -55,7 +55,8 @@ static void SetGlobalProperty(const char* name, Object value) { isolate->factory()->InternalizeUtf8String(name); Handle global(isolate->context()->global_object(), isolate); Runtime::SetObjectProperty(isolate, global, internalized_name, object, - LanguageMode::kSloppy, StoreOrigin::kMaybeKeyed) + StoreOrigin::kMaybeKeyed, + Just(LanguageMode::kSloppy)) .Check(); } diff --git a/test/cctest/test-intl.cc b/test/cctest/test-intl.cc index 0670340227..87cfec4659 100644 --- a/test/cctest/test-intl.cc +++ b/test/cctest/test-intl.cc @@ -132,7 +132,8 @@ TEST(GetStringOption) { Handle key = isolate->factory()->NewStringFromAsciiChecked("foo"); v8::internal::LookupIterator it(isolate, options, key); CHECK(Object::SetProperty(&it, Handle(Smi::FromInt(42), isolate), - LanguageMode::kStrict, StoreOrigin::kMaybeKeyed) + StoreOrigin::kMaybeKeyed, + Just(LanguageMode::kStrict)) .FromJust()); { @@ -191,7 +192,7 @@ TEST(GetBoolOption) { Handle false_value = handle(i::ReadOnlyRoots(isolate).false_value(), isolate); Object::SetProperty(isolate, options, key, false_value, - LanguageMode::kStrict) + StoreOrigin::kMaybeKeyed, Just(LanguageMode::kStrict)) .Assert(); bool result = false; Maybe found = @@ -205,7 +206,7 @@ TEST(GetBoolOption) { Handle true_value = handle(i::ReadOnlyRoots(isolate).true_value(), isolate); Object::SetProperty(isolate, options, key, true_value, - LanguageMode::kStrict) + StoreOrigin::kMaybeKeyed, Just(LanguageMode::kStrict)) .Assert(); bool result = false; Maybe found =