Commit 80780765 authored by Santiago Aboy Solanes's avatar Santiago Aboy Solanes Committed by Commit Bot

[csa][cleanup] Remove unneeded Unhcecked casts from T to the same T

For example, there is no need to do UncheckedCast<Object>(obj), if obj
is already of type Object.

Bug: v8:6949
Change-Id: I44278a023cb8741ead7b554569c66f412f01ffee
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2737294Reviewed-by: 's avatarMythri Alle <mythria@chromium.org>
Commit-Queue: Santiago Aboy Solanes <solanes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#73210}
parent 0be03022
......@@ -910,7 +910,7 @@ TNode<IntPtrT> CollectionsBuiltinsAssembler::GetHash(
BIND(&if_receiver);
{
var_hash = LoadJSReceiverIdentityHash(key);
var_hash = LoadJSReceiverIdentityHash(CAST(key));
Goto(&done);
}
......@@ -2722,7 +2722,7 @@ TF_BUILTIN(WeakMapLookupHashIndex, WeakCollectionsBuiltinsAssembler) {
GotoIfNotJSReceiver(key, &if_not_found);
TNode<IntPtrT> hash = LoadJSReceiverIdentityHash(key, &if_not_found);
TNode<IntPtrT> hash = LoadJSReceiverIdentityHash(CAST(key), &if_not_found);
TNode<IntPtrT> capacity = LoadTableCapacity(table);
TNode<IntPtrT> key_index =
FindKeyIndexForKey(table, key, hash, EntryMask(capacity), &if_not_found);
......@@ -2787,7 +2787,7 @@ TF_BUILTIN(WeakCollectionDelete, WeakCollectionsBuiltinsAssembler) {
GotoIfNotJSReceiver(key, &if_not_found);
TNode<IntPtrT> hash = LoadJSReceiverIdentityHash(key, &if_not_found);
TNode<IntPtrT> hash = LoadJSReceiverIdentityHash(CAST(key), &if_not_found);
TNode<EphemeronHashTable> table = LoadTable(collection);
TNode<IntPtrT> capacity = LoadTableCapacity(table);
TNode<IntPtrT> key_index =
......
......@@ -54,8 +54,7 @@ IteratorRecord IteratorBuiltinsAssembler::GetIterator(TNode<Context> context,
BIND(&get_next);
TNode<Object> next =
GetProperty(context, iterator, factory()->next_string());
return IteratorRecord{TNode<JSReceiver>::UncheckedCast(iterator),
TNode<Object>::UncheckedCast(next)};
return IteratorRecord{TNode<JSReceiver>::UncheckedCast(iterator), next};
}
}
......
......@@ -320,7 +320,7 @@ TNode<JSArray> ObjectEntriesValuesBuiltinsAssembler::FastGetOwnValuesOrEntries(
IntPtrConstant(2));
StoreFixedArrayElement(CAST(elements), 0, next_key, SKIP_WRITE_BARRIER);
StoreFixedArrayElement(CAST(elements), 1, value, SKIP_WRITE_BARRIER);
value = TNode<JSArray>::UncheckedCast(array);
value = array;
}
StoreFixedArrayElement(values_or_entries, var_result_index.value(),
......@@ -350,7 +350,7 @@ ObjectEntriesValuesBuiltinsAssembler::FinalizeValuesOrEntriesJSArray(
GotoIf(IntPtrEqual(size, IntPtrConstant(0)), if_empty);
TNode<JSArray> array = AllocateJSArray(array_map, result, SmiTag(size));
return TNode<JSArray>::UncheckedCast(array);
return array;
}
TF_BUILTIN(ObjectPrototypeHasOwnProperty, ObjectBuiltinsAssembler) {
......
......@@ -128,10 +128,6 @@ macro Convert<To: type, From: type>(i: From): To labels Overflow {
Convert<Boolean, bool>(b: bool): Boolean {
return b ? True : False;
}
extern macro ConvertElementsKindToInt(ElementsKind): int32;
Convert<int32, ElementsKind>(elementsKind: ElementsKind): int32 {
return ConvertElementsKindToInt(elementsKind);
}
Convert<Number, int32>(i: int32): Number {
return ChangeInt32ToTagged(i);
}
......
......@@ -60,7 +60,7 @@ struct PromiseAllSettledWrapResultAsRejectedFunctor {
}
}
extern macro LoadJSReceiverIdentityHash(Object): intptr labels IfNoHash;
extern macro LoadJSReceiverIdentityHash(JSReceiver): intptr labels IfNoHash;
type PromiseAllResolveElementContext extends FunctionContext;
extern enum PromiseAllResolveElementContextSlots extends intptr
......
......@@ -350,7 +350,7 @@ TNode<Float64T> CodeStubAssembler::Float64Round(TNode<Float64T> x) {
Goto(&return_x);
BIND(&return_x);
return TNode<Float64T>::UncheckedCast(var_x.value());
return var_x.value();
}
TNode<Float64T> CodeStubAssembler::Float64Ceil(TNode<Float64T> x) {
......@@ -402,7 +402,7 @@ TNode<Float64T> CodeStubAssembler::Float64Ceil(TNode<Float64T> x) {
Goto(&return_x);
BIND(&return_x);
return TNode<Float64T>::UncheckedCast(var_x.value());
return var_x.value();
}
TNode<Float64T> CodeStubAssembler::Float64Floor(TNode<Float64T> x) {
......@@ -454,7 +454,7 @@ TNode<Float64T> CodeStubAssembler::Float64Floor(TNode<Float64T> x) {
Goto(&return_x);
BIND(&return_x);
return TNode<Float64T>::UncheckedCast(var_x.value());
return var_x.value();
}
TNode<Float64T> CodeStubAssembler::Float64RoundToEven(TNode<Float64T> x) {
......@@ -485,7 +485,7 @@ TNode<Float64T> CodeStubAssembler::Float64RoundToEven(TNode<Float64T> x) {
Goto(&done);
BIND(&done);
return TNode<Float64T>::UncheckedCast(var_result.value());
return var_result.value();
}
TNode<Float64T> CodeStubAssembler::Float64Trunc(TNode<Float64T> x) {
......@@ -546,7 +546,7 @@ TNode<Float64T> CodeStubAssembler::Float64Trunc(TNode<Float64T> x) {
Goto(&return_x);
BIND(&return_x);
return TNode<Float64T>::UncheckedCast(var_x.value());
return var_x.value();
}
template <>
......@@ -1776,19 +1776,17 @@ TNode<Uint32T> CodeStubAssembler::EnsureOnlyHasSimpleProperties(
}
TNode<IntPtrT> CodeStubAssembler::LoadJSReceiverIdentityHash(
TNode<Object> receiver, Label* if_no_hash) {
TNode<JSReceiver> receiver, Label* if_no_hash) {
TVARIABLE(IntPtrT, var_hash);
Label done(this), if_smi(this), if_property_array(this),
if_ordered_property_dictionary(this), if_property_dictionary(this),
if_fixed_array(this);
TNode<Object> properties_or_hash =
LoadObjectField(TNode<HeapObject>::UncheckedCast(receiver),
JSReceiver::kPropertiesOrHashOffset);
LoadObjectField(receiver, JSReceiver::kPropertiesOrHashOffset);
GotoIf(TaggedIsSmi(properties_or_hash), &if_smi);
TNode<HeapObject> properties =
TNode<HeapObject>::UncheckedCast(properties_or_hash);
TNode<HeapObject> properties = CAST(properties_or_hash);
TNode<Uint16T> properties_instance_type = LoadInstanceType(properties);
GotoIf(InstanceTypeEqual(properties_instance_type, PROPERTY_ARRAY_TYPE),
......@@ -1809,7 +1807,7 @@ TNode<IntPtrT> CodeStubAssembler::LoadJSReceiverIdentityHash(
BIND(&if_smi);
{
var_hash = SmiUntag(TNode<Smi>::UncheckedCast(properties_or_hash));
var_hash = SmiUntag(CAST(properties_or_hash));
Goto(&done);
}
......@@ -1817,8 +1815,7 @@ TNode<IntPtrT> CodeStubAssembler::LoadJSReceiverIdentityHash(
{
TNode<IntPtrT> length_and_hash = LoadAndUntagObjectField(
properties, PropertyArray::kLengthAndHashOffset);
var_hash = TNode<IntPtrT>::UncheckedCast(
DecodeWord<PropertyArray::HashField>(length_and_hash));
var_hash = Signed(DecodeWord<PropertyArray::HashField>(length_and_hash));
Goto(&done);
}
if (V8_DICT_MODE_PROTOTYPES_BOOL) {
......@@ -2695,9 +2692,8 @@ TNode<BoolT> CodeStubAssembler::IsGeneratorFunction(
TNode<BoolT> CodeStubAssembler::IsJSFunctionWithPrototypeSlot(
TNode<HeapObject> object) {
// Only JSFunction maps may have HasPrototypeSlotBit set.
return TNode<BoolT>::UncheckedCast(
IsSetWord32<Map::Bits1::HasPrototypeSlotBit>(
LoadMapBitField(LoadMap(object))));
return IsSetWord32<Map::Bits1::HasPrototypeSlotBit>(
LoadMapBitField(LoadMap(object)));
}
void CodeStubAssembler::BranchIfHasPrototypeProperty(
......@@ -2868,7 +2864,7 @@ void CodeStubAssembler::StoreFixedArrayOrPropertyArrayElement(
[=] {
TNode<IntPtrT> length_and_hash = LoadAndUntagObjectField(
object, PropertyArray::kLengthAndHashOffset);
return TNode<IntPtrT>::UncheckedCast(
return Signed(
DecodeWord<PropertyArray::LengthField>(length_and_hash));
},
[=] {
......
......@@ -777,20 +777,20 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
template <class... TArgs>
TNode<Object> Call(TNode<Context> context, TNode<Object> callable,
TNode<JSReceiver> receiver, TArgs... args) {
return UncheckedCast<Object>(CallJS(
return CallJS(
CodeFactory::Call(isolate(), ConvertReceiverMode::kNotNullOrUndefined),
context, callable, receiver, args...));
context, callable, receiver, args...);
}
template <class... TArgs>
TNode<Object> Call(TNode<Context> context, TNode<Object> callable,
TNode<Object> receiver, TArgs... args) {
if (IsUndefinedConstant(receiver) || IsNullConstant(receiver)) {
return UncheckedCast<Object>(CallJS(
return CallJS(
CodeFactory::Call(isolate(), ConvertReceiverMode::kNullOrUndefined),
context, callable, receiver, args...));
context, callable, receiver, args...);
}
return UncheckedCast<Object>(CallJS(CodeFactory::Call(isolate()), context,
callable, receiver, args...));
return CallJS(CodeFactory::Call(isolate()), context, callable, receiver,
args...);
}
TNode<Object> CallApiCallback(TNode<Object> context, TNode<RawPtrT> callback,
......@@ -1271,7 +1271,7 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
TNode<Int32T> instance_type,
Label* bailout);
// Load the identity hash of a JSRececiver.
TNode<IntPtrT> LoadJSReceiverIdentityHash(TNode<Object> receiver,
TNode<IntPtrT> LoadJSReceiverIdentityHash(TNode<JSReceiver> receiver,
Label* if_no_hash = nullptr);
// This is only used on a newly allocated PropertyArray which
......@@ -2022,10 +2022,6 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
return UncheckedCast<FixedDoubleArray>(base);
}
TNode<Int32T> ConvertElementsKindToInt(TNode<Int32T> elements_kind) {
return UncheckedCast<Int32T>(elements_kind);
}
template <typename T>
bool ClassHasMapConstant() {
return false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment