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

[cleanup][CSA] TNodify LoadPropertyFromFastObject and related functions

Related ones are TryGetOwnProperty and CallGetterIfAccessor.

Bug: v8:10021
Change-Id: I1b65c4260ab48b4431fa2b84a8be5789f24fa800
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1993960
Commit-Queue: Santiago Aboy Solanes <solanes@chromium.org>
Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65704}
parent d987e45d
......@@ -1002,7 +1002,7 @@ TF_BUILTIN(GetProperty, CodeStubAssembler) {
TNode<Name> unique_name, Label* next_holder, Label* if_bailout) {
TVARIABLE(Object, var_value);
Label if_found(this);
TryGetOwnProperty(context, receiver, holder, holder_map,
TryGetOwnProperty(context, receiver, CAST(holder), holder_map,
holder_instance_type, unique_name, &if_found,
&var_value, next_holder, if_bailout);
BIND(&if_found);
......@@ -1057,7 +1057,7 @@ TF_BUILTIN(GetPropertyWithReceiver, CodeStubAssembler) {
TNode<Name> unique_name, Label* next_holder, Label* if_bailout) {
TVARIABLE(Object, var_value);
Label if_found(this);
TryGetOwnProperty(context, receiver, holder, holder_map,
TryGetOwnProperty(context, receiver, CAST(holder), holder_map,
holder_instance_type, unique_name, &if_found,
&var_value, next_holder, if_bailout);
BIND(&if_found);
......
......@@ -1336,7 +1336,7 @@ TF_BUILTIN(ObjectGetOwnPropertyDescriptor, ObjectBuiltinsAssembler) {
Label if_found_value(this), return_empty(this), if_not_found(this);
TVARIABLE(Object, var_value);
TVARIABLE(Word32T, var_details);
TVARIABLE(Uint32T, var_details);
TVARIABLE(Object, var_raw_value);
TryGetOwnProperty(context, object, object, map, instance_type,
......
......@@ -8528,22 +8528,20 @@ TNode<Object> CodeStubAssembler::GetIteratorMethod(
}
void CodeStubAssembler::LoadPropertyFromFastObject(
Node* object, Node* map, TNode<DescriptorArray> descriptors,
Node* name_index, Variable* var_details, Variable* var_value) {
DCHECK_EQ(MachineRepresentation::kWord32, var_details->rep());
DCHECK_EQ(MachineRepresentation::kTagged, var_value->rep());
TNode<Uint32T> details =
LoadDetailsByKeyIndex(descriptors, UncheckedCast<IntPtrT>(name_index));
var_details->Bind(details);
TNode<HeapObject> object, TNode<Map> map,
TNode<DescriptorArray> descriptors, TNode<IntPtrT> name_index,
TVariable<Uint32T>* var_details, TVariable<Object>* var_value) {
TNode<Uint32T> details = LoadDetailsByKeyIndex(descriptors, name_index);
*var_details = details;
LoadPropertyFromFastObject(object, map, descriptors, name_index, details,
var_value);
}
void CodeStubAssembler::LoadPropertyFromFastObject(
Node* object, Node* map, TNode<DescriptorArray> descriptors,
Node* name_index, Node* details, Variable* var_value) {
TNode<HeapObject> object, TNode<Map> map,
TNode<DescriptorArray> descriptors, TNode<IntPtrT> name_index,
TNode<Uint32T> details, TVariable<Object>* var_value) {
Comment("[ LoadPropertyFromFastObject");
TNode<Uint32T> location =
......@@ -8579,14 +8577,13 @@ void CodeStubAssembler::LoadPropertyFromFastObject(
&if_tagged, &if_double);
BIND(&if_tagged);
{
var_value->Bind(LoadObjectField(object, field_offset));
*var_value = LoadObjectField(object, field_offset);
Goto(&done);
}
BIND(&if_double);
{
if (FLAG_unbox_double_fields) {
var_double_value =
LoadObjectField<Float64T>(CAST(object), field_offset);
var_double_value = LoadObjectField<Float64T>(object, field_offset);
} else {
TNode<HeapNumber> heap_number =
CAST(LoadObjectField(object, field_offset));
......@@ -8598,7 +8595,7 @@ void CodeStubAssembler::LoadPropertyFromFastObject(
BIND(&if_backing_store);
{
Comment("if_backing_store");
TNode<HeapObject> properties = LoadFastProperties(object);
TNode<HeapObject> properties = LoadFastProperties(CAST(object));
field_index = Signed(IntPtrSub(field_index, instance_size_in_words));
TNode<Object> value =
LoadPropertyArrayElement(CAST(properties), field_index);
......@@ -8609,7 +8606,7 @@ void CodeStubAssembler::LoadPropertyFromFastObject(
&if_tagged, &if_double);
BIND(&if_tagged);
{
var_value->Bind(value);
*var_value = value;
Goto(&done);
}
BIND(&if_double);
......@@ -8623,14 +8620,13 @@ void CodeStubAssembler::LoadPropertyFromFastObject(
Comment("rebox_double");
TNode<HeapNumber> heap_number =
AllocateHeapNumberWithValue(var_double_value.value());
var_value->Bind(heap_number);
*var_value = heap_number;
Goto(&done);
}
}
BIND(&if_in_descriptor);
{
var_value->Bind(
LoadValueByKeyIndex(descriptors, UncheckedCast<IntPtrT>(name_index)));
*var_value = LoadValueByKeyIndex(descriptors, name_index);
Goto(&done);
}
BIND(&done);
......@@ -8680,16 +8676,16 @@ void CodeStubAssembler::LoadPropertyFromGlobalDictionary(Node* dictionary,
// or an accessor pair, as specified by |details|.
// Returns either the original value, or the result of the getter call.
TNode<Object> CodeStubAssembler::CallGetterIfAccessor(
Node* value, Node* details, Node* context, Node* receiver,
Label* if_bailout, GetOwnPropertyMode mode) {
VARIABLE(var_value, MachineRepresentation::kTagged, value);
TNode<Object> value, TNode<Uint32T> details, TNode<Context> context,
TNode<Object> receiver, Label* if_bailout, GetOwnPropertyMode mode) {
TVARIABLE(Object, var_value, value);
Label done(this), if_accessor_info(this, Label::kDeferred);
TNode<Uint32T> kind = DecodeWord32<PropertyDetails::KindField>(details);
GotoIf(Word32Equal(kind, Int32Constant(kData)), &done);
// Accessor case.
GotoIfNot(IsAccessorPair(value), &if_accessor_info);
GotoIfNot(IsAccessorPair(CAST(value)), &if_accessor_info);
// AccessorPair case.
{
......@@ -8704,15 +8700,14 @@ TNode<Object> CodeStubAssembler::CallGetterIfAccessor(
GotoIf(IsFunctionTemplateInfoMap(getter_map), &if_function_template_info);
// Return undefined if the {getter} is not callable.
var_value.Bind(UndefinedConstant());
var_value = UndefinedConstant();
Goto(&done);
BIND(&if_callable);
{
// Call the accessor.
Callable callable = CodeFactory::Call(isolate());
Node* result = CallJS(callable, context, getter, receiver);
var_value.Bind(result);
var_value = CallJS(callable, context, getter, receiver);
Goto(&done);
}
......@@ -8724,9 +8719,9 @@ TNode<Object> CodeStubAssembler::CallGetterIfAccessor(
TNode<NativeContext> creation_context =
GetCreationContext(CAST(receiver), if_bailout);
var_value.Bind(CallBuiltin(
var_value = CallBuiltin(
Builtins::kCallFunctionTemplate_CheckAccessAndCompatibleReceiver,
creation_context, getter, IntPtrConstant(0), receiver));
creation_context, getter, IntPtrConstant(0), receiver);
Goto(&done);
}
} else {
......@@ -8737,13 +8732,12 @@ TNode<Object> CodeStubAssembler::CallGetterIfAccessor(
// AccessorInfo case.
BIND(&if_accessor_info);
{
Node* accessor_info = value;
CSA_ASSERT(this, IsAccessorInfo(value));
CSA_ASSERT(this, TaggedIsNotSmi(receiver));
TNode<AccessorInfo> accessor_info = CAST(value);
Label if_array(this), if_function(this), if_wrapper(this);
// Dispatch based on {receiver} instance type.
TNode<Map> receiver_map = LoadMap(receiver);
TNode<Map> receiver_map = LoadMap(CAST(receiver));
TNode<Uint16T> receiver_instance_type = LoadMapInstanceType(receiver_map);
GotoIf(IsJSArrayInstanceType(receiver_instance_type), &if_array);
GotoIf(IsJSFunctionInstanceType(receiver_instance_type), &if_function);
......@@ -8758,7 +8752,7 @@ TNode<Object> CodeStubAssembler::CallGetterIfAccessor(
LoadObjectField(accessor_info, AccessorInfo::kNameOffset)),
if_bailout);
TNode<JSArray> array = CAST(receiver);
var_value.Bind(LoadJSArrayLength(array));
var_value = LoadJSArrayLength(array);
Goto(&done);
}
......@@ -8772,7 +8766,7 @@ TNode<Object> CodeStubAssembler::CallGetterIfAccessor(
GotoIfPrototypeRequiresRuntimeLookup(CAST(receiver), receiver_map,
if_bailout);
var_value.Bind(LoadJSFunctionPrototype(CAST(receiver), if_bailout));
var_value = LoadJSFunctionPrototype(CAST(receiver), if_bailout);
Goto(&done);
}
......@@ -8788,39 +8782,41 @@ TNode<Object> CodeStubAssembler::CallGetterIfAccessor(
LoadJSPrimitiveWrapperValue(CAST(receiver));
GotoIfNot(TaggedIsNotSmi(receiver_value), if_bailout);
GotoIfNot(IsString(CAST(receiver_value)), if_bailout);
var_value.Bind(LoadStringLengthAsSmi(CAST(receiver_value)));
var_value = LoadStringLengthAsSmi(CAST(receiver_value));
Goto(&done);
}
}
BIND(&done);
return UncheckedCast<Object>(var_value.value());
return var_value.value();
}
void CodeStubAssembler::TryGetOwnProperty(
Node* context, Node* receiver, Node* object, Node* map, Node* instance_type,
Node* unique_name, Label* if_found_value, Variable* var_value,
Label* if_not_found, Label* if_bailout) {
TNode<Context> context, TNode<HeapObject> receiver,
TNode<JSReceiver> object, TNode<Map> map, TNode<Int32T> instance_type,
TNode<Name> unique_name, Label* if_found_value,
TVariable<Object>* var_value, Label* if_not_found, Label* if_bailout) {
TryGetOwnProperty(context, receiver, object, map, instance_type, unique_name,
if_found_value, var_value, nullptr, nullptr, if_not_found,
if_bailout, kCallJSGetter);
}
void CodeStubAssembler::TryGetOwnProperty(
Node* context, Node* receiver, Node* object, Node* map, Node* instance_type,
Node* unique_name, Label* if_found_value, Variable* var_value,
Variable* var_details, Variable* var_raw_value, Label* if_not_found,
Label* if_bailout, GetOwnPropertyMode mode) {
TNode<Context> context, TNode<HeapObject> receiver,
TNode<JSReceiver> object, TNode<Map> map, TNode<Int32T> instance_type,
TNode<Name> unique_name, Label* if_found_value,
TVariable<Object>* var_value, TVariable<Uint32T>* var_details,
TVariable<Object>* var_raw_value, Label* if_not_found, Label* if_bailout,
GetOwnPropertyMode mode) {
DCHECK_EQ(MachineRepresentation::kTagged, var_value->rep());
Comment("TryGetOwnProperty");
CSA_ASSERT(this, IsUniqueNameNoIndex(CAST(unique_name)));
CSA_ASSERT(this, IsUniqueNameNoIndex(unique_name));
TVARIABLE(HeapObject, var_meta_storage);
TVARIABLE(IntPtrT, var_entry);
Label if_found_fast(this), if_found_dict(this), if_found_global(this);
VARIABLE(local_var_details, MachineRepresentation::kWord32);
TVARIABLE(Uint32T, local_var_details);
if (!var_details) {
var_details = &local_var_details;
}
......@@ -8859,12 +8855,12 @@ void CodeStubAssembler::TryGetOwnProperty(
{
// TODO(ishell): Execute C++ accessor in case of accessor info
if (var_raw_value) {
var_raw_value->Bind(var_value->value());
*var_raw_value = *var_value;
}
TNode<Object> value =
CallGetterIfAccessor(var_value->value(), var_details->value(), context,
receiver, if_bailout, mode);
var_value->Bind(value);
*var_value = value;
Goto(if_found_value);
}
}
......
......@@ -3087,16 +3087,18 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
// is an accessor then it also calls a getter. If the property is a double
// field it re-wraps value in an immutable heap number. {unique_name} must be
// a unique name (Symbol or InternalizedString) that is not an array index.
void TryGetOwnProperty(Node* context, Node* receiver, Node* object, Node* map,
Node* instance_type, Node* unique_name,
Label* if_found, Variable* var_value,
void TryGetOwnProperty(TNode<Context> context, TNode<HeapObject> receiver,
TNode<JSReceiver> object, TNode<Map> map,
TNode<Int32T> instance_type, TNode<Name> unique_name,
Label* if_found_value, TVariable<Object>* var_value,
Label* if_not_found, Label* if_bailout);
void TryGetOwnProperty(Node* context, Node* receiver, Node* object, Node* map,
Node* instance_type, Node* unique_name,
Label* if_found, Variable* var_value,
Variable* var_details, Variable* var_raw_value,
Label* if_not_found, Label* if_bailout,
GetOwnPropertyMode mode);
void TryGetOwnProperty(TNode<Context> context, TNode<HeapObject> receiver,
TNode<JSReceiver> object, TNode<Map> map,
TNode<Int32T> instance_type, TNode<Name> unique_name,
Label* if_found_value, TVariable<Object>* var_value,
TVariable<Uint32T>* var_details,
TVariable<Object>* var_raw_value, Label* if_not_found,
Label* if_bailout, GetOwnPropertyMode mode);
TNode<Object> GetProperty(SloppyTNode<Context> context,
SloppyTNode<Object> receiver, Handle<Name> name) {
......@@ -3142,20 +3144,20 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
return TailCallStub(Builtins::CallableFor(isolate(), id), context, args...);
}
void LoadPropertyFromFastObject(Node* object, Node* map,
void LoadPropertyFromFastObject(TNode<HeapObject> object, TNode<Map> map,
TNode<DescriptorArray> descriptors,
Node* name_index, Variable* var_details,
Variable* var_value);
TNode<IntPtrT> name_index,
TVariable<Uint32T>* var_details,
TVariable<Object>* var_value);
void LoadPropertyFromFastObject(Node* object, Node* map,
void LoadPropertyFromFastObject(TNode<HeapObject> object, TNode<Map> map,
TNode<DescriptorArray> descriptors,
Node* name_index, Node* details,
Variable* var_value);
TNode<IntPtrT> name_index, TNode<Uint32T>,
TVariable<Object>* var_value);
void LoadPropertyFromNameDictionary(Node* dictionary, Node* entry,
Variable* var_details,
Variable* var_value);
void LoadPropertyFromGlobalDictionary(Node* dictionary, Node* entry,
Variable* var_details,
Variable* var_value, Label* if_deleted);
......@@ -3759,8 +3761,10 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
const ForEachKeyValueFunction& body,
Label* bailout);
TNode<Object> CallGetterIfAccessor(Node* value, Node* details, Node* context,
Node* receiver, Label* if_bailout,
TNode<Object> CallGetterIfAccessor(TNode<Object> value,
TNode<Uint32T> details,
TNode<Context> context,
TNode<Object> receiver, Label* if_bailout,
GetOwnPropertyMode mode = kCallJSGetter);
TNode<IntPtrT> TryToIntptr(SloppyTNode<Object> key, Label* if_not_intptr,
......
......@@ -627,8 +627,8 @@ void AccessorAssembler::HandleLoadICSmiHandlerLoadNamedCase(
// Ensure the property cell doesn't contain the hole.
TNode<Object> value =
LoadObjectField(CAST(holder), PropertyCell::kValueOffset);
TNode<Int32T> details = LoadAndUntagToWord32ObjectField(
CAST(holder), PropertyCell::kPropertyDetailsRawOffset);
TNode<Uint32T> details = Unsigned(LoadAndUntagToWord32ObjectField(
CAST(holder), PropertyCell::kPropertyDetailsRawOffset));
GotoIf(IsTheHole(value), miss);
exit_point->Return(CallGetterIfAccessor(value, details, p->context(),
......@@ -2490,7 +2490,7 @@ void AccessorAssembler::GenericPropertyLoad(TNode<HeapObject> receiver,
var_holder_map = proto_map;
var_holder_instance_type = proto_instance_type;
Label next_proto(this), return_value(this, &var_value), goto_slow(this);
TryGetOwnProperty(p->context(), receiver, proto, proto_map,
TryGetOwnProperty(p->context(), receiver, CAST(proto), proto_map,
proto_instance_type, name, &return_value, &var_value,
&next_proto, &goto_slow);
......
......@@ -1397,11 +1397,11 @@ TEST(TryGetOwnProperty) {
Handle<Symbol> not_found_symbol = factory->NewSymbol();
Handle<Symbol> bailout_symbol = factory->NewSymbol();
{
Node* object = m.Parameter(0);
Node* unique_name = m.Parameter(1);
Node* context = m.Parameter(kNumParams + 2);
TNode<JSReceiver> object = m.CAST(m.Parameter(0));
TNode<Name> unique_name = m.CAST(m.Parameter(1));
TNode<Context> context = m.CAST(m.Parameter(kNumParams + 2));
Variable var_value(&m, MachineRepresentation::kTagged);
TVariable<Object> var_value(&m);
Label if_found(&m), if_not_found(&m), if_bailout(&m);
TNode<Map> map = m.LoadMap(object);
......
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