Commit e4a72d8b authored by Igor Sheludko's avatar Igor Sheludko Committed by Commit Bot

[csa] Minor refactoring to prepare for the Object.assign CL.

1) Add exit point parameter to EmitGenericPropertyStore(),
2) carve TryLookupPropertyInSimpleObject() out of TryLookupProperty().

Bug: v8:5988
Change-Id: I6cef48731c27e5bb72dce5eaa0169fbf59787ed7
Reviewed-on: https://chromium-review.googlesource.com/997747Reviewed-by: 's avatarMarja Hölttä <marja@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52448}
parent fb0bc36b
......@@ -6997,20 +6997,21 @@ void CodeStubAssembler::Lookup(TNode<Name> unique_name, TNode<Array> array,
}
}
void CodeStubAssembler::TryLookupProperty(
Node* object, Node* map, Node* instance_type, Node* unique_name,
Label* if_found_fast, Label* if_found_dict, Label* if_found_global,
void CodeStubAssembler::TryLookupPropertyInSimpleObject(
TNode<JSObject> object, TNode<Map> map, TNode<Name> unique_name,
Label* if_found_fast, Label* if_found_dict,
TVariable<HeapObject>* var_meta_storage, TVariable<IntPtrT>* var_name_index,
Label* if_not_found, Label* if_bailout) {
Label if_objectisspecial(this);
GotoIf(IsSpecialReceiverInstanceType(instance_type), &if_objectisspecial);
Label* if_not_found) {
CSA_ASSERT(
this,
Word32BinaryNot(IsSpecialReceiverInstanceType(LoadMapInstanceType(map))));
uint32_t mask =
Map::HasNamedInterceptorBit::kMask | Map::IsAccessCheckNeededBit::kMask;
CSA_ASSERT(this, Word32BinaryNot(IsSetWord32(LoadMapBitField(map), mask)));
USE(mask);
Node* bit_field3 = LoadMapBitField3(map);
TNode<Uint32T> bit_field3 = LoadMapBitField3(map);
Label if_isfastmap(this), if_isslowmap(this);
Branch(IsSetWord32<Map::IsDictionaryMapBit>(bit_field3), &if_isslowmap,
&if_isfastmap);
......@@ -7030,6 +7031,21 @@ void CodeStubAssembler::TryLookupProperty(
NameDictionaryLookup<NameDictionary>(dictionary, unique_name, if_found_dict,
var_name_index, if_not_found);
}
}
void CodeStubAssembler::TryLookupProperty(
SloppyTNode<JSObject> object, SloppyTNode<Map> map,
SloppyTNode<Int32T> instance_type, SloppyTNode<Name> unique_name,
Label* if_found_fast, Label* if_found_dict, Label* if_found_global,
TVariable<HeapObject>* var_meta_storage, TVariable<IntPtrT>* var_name_index,
Label* if_not_found, Label* if_bailout) {
Label if_objectisspecial(this);
GotoIf(IsSpecialReceiverInstanceType(instance_type), &if_objectisspecial);
TryLookupPropertyInSimpleObject(object, map, unique_name, if_found_fast,
if_found_dict, var_meta_storage,
var_name_index, if_not_found);
BIND(&if_objectisspecial);
{
// Handle global object here and bailout for other special objects.
......@@ -7037,7 +7053,7 @@ void CodeStubAssembler::TryLookupProperty(
if_bailout);
// Handle interceptors and access checks in runtime.
Node* bit_field = LoadMapBitField(map);
TNode<Int32T> bit_field = LoadMapBitField(map);
int mask =
Map::HasNamedInterceptorBit::kMask | Map::IsAccessCheckNeededBit::kMask;
GotoIf(IsSetWord32(bit_field, mask), if_bailout);
......@@ -7238,10 +7254,9 @@ void CodeStubAssembler::LoadPropertyFromGlobalDictionary(Node* dictionary,
// |value| is the property backing store's contents, which is either a value
// or an accessor pair, as specified by |details|.
// Returns either the original value, or the result of the getter call.
Node* CodeStubAssembler::CallGetterIfAccessor(Node* value, Node* details,
Node* context, Node* receiver,
Label* if_bailout,
GetOwnPropertyMode mode) {
TNode<Object> CodeStubAssembler::CallGetterIfAccessor(
Node* value, Node* details, Node* context, Node* receiver,
Label* if_bailout, GetOwnPropertyMode mode) {
VARIABLE(var_value, MachineRepresentation::kTagged, value);
Label done(this), if_accessor_info(this, Label::kDeferred);
......@@ -7339,7 +7354,7 @@ Node* CodeStubAssembler::CallGetterIfAccessor(Node* value, Node* details,
}
BIND(&done);
return var_value.value();
return UncheckedCast<Object>(var_value.value());
}
void CodeStubAssembler::TryGetOwnProperty(
......
......@@ -1710,13 +1710,24 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
//
// Note: this code does not check if the global dictionary points to deleted
// entry! This has to be done by the caller.
void TryLookupProperty(Node* object, Node* map, Node* instance_type,
Node* unique_name, Label* if_found_fast,
void TryLookupProperty(SloppyTNode<JSObject> object, SloppyTNode<Map> map,
SloppyTNode<Int32T> instance_type,
SloppyTNode<Name> unique_name, Label* if_found_fast,
Label* if_found_dict, Label* if_found_global,
TVariable<HeapObject>* var_meta_storage,
TVariable<IntPtrT>* var_name_index,
Label* if_not_found, Label* if_bailout);
// This is a building block for TryLookupProperty() above. Supports only
// non-special fast and dictionary objects.
void TryLookupPropertyInSimpleObject(TNode<JSObject> object, TNode<Map> map,
TNode<Name> unique_name,
Label* if_found_fast,
Label* if_found_dict,
TVariable<HeapObject>* var_meta_storage,
TVariable<IntPtrT>* var_name_index,
Label* if_not_found);
// This method jumps to if_found if the element is known to exist. To
// if_absent if it's known to not exist. To if_not_found if the prototype
// chain needs to be checked. And if_bailout if the lookup is unsupported.
......@@ -2069,9 +2080,9 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
TNode<Uint32T> DescriptorArrayGetDetails(TNode<DescriptorArray> descriptors,
TNode<Uint32T> descriptor_number);
Node* CallGetterIfAccessor(Node* value, Node* details, Node* context,
Node* receiver, Label* if_bailout,
GetOwnPropertyMode mode = kCallJSGetter);
TNode<Object> CallGetterIfAccessor(Node* value, Node* details, Node* context,
Node* receiver, Label* if_bailout,
GetOwnPropertyMode mode = kCallJSGetter);
TNode<IntPtrT> TryToIntptr(Node* key, Label* miss);
......
......@@ -894,6 +894,7 @@ void AccessorAssembler::HandleStoreICHandlerCase(
}
BIND(&store_transition);
HandleStoreICTransitionMapHandlerCase(p, map_or_property_cell, miss, false);
Return(p->value);
}
}
......@@ -949,7 +950,6 @@ void AccessorAssembler::HandleStoreICTransitionMapHandlerCase(
OverwriteExistingFastDataProperty(p->receiver, transition_map, descriptors,
last_key_index, details, p->value, miss,
true);
Return(p->value);
}
void AccessorAssembler::CheckFieldType(Node* descriptors, Node* name_index,
......
......@@ -41,7 +41,15 @@ class KeyedStoreGenericAssembler : public AccessorAssembler {
Node* value, Node* context, Label* slow);
void EmitGenericPropertyStore(Node* receiver, Node* receiver_map,
const StoreICParameters* p, Label* slow);
const StoreICParameters* p,
ExitPoint* exit_point, Label* slow,
bool assume_strict_language_mode = false);
void EmitGenericPropertyStore(Node* receiver, Node* receiver_map,
const StoreICParameters* p, Label* slow) {
ExitPoint direct_exit(this);
EmitGenericPropertyStore(receiver, receiver_map, p, &direct_exit, slow);
}
void BranchIfPrototypesHaveNonFastElements(Node* receiver_map,
Label* non_fast_elements,
......@@ -611,7 +619,7 @@ void KeyedStoreGenericAssembler::LookupPropertyOnPrototypeChain(
void KeyedStoreGenericAssembler::EmitGenericPropertyStore(
Node* receiver, Node* receiver_map, const StoreICParameters* p,
Label* slow) {
ExitPoint* exit_point, Label* slow, bool assume_strict_language_mode) {
VARIABLE(var_accessor_pair, MachineRepresentation::kTagged);
VARIABLE(var_accessor_holder, MachineRepresentation::kTagged);
Label stub_cache(this), fast_properties(this), dictionary_properties(this),
......@@ -651,7 +659,7 @@ void KeyedStoreGenericAssembler::EmitGenericPropertyStore(
OverwriteExistingFastDataProperty(receiver, receiver_map, descriptors,
name_index, details, p->value, slow,
false);
Return(p->value);
exit_point->Return(p->value);
}
}
BIND(&lookup_transition);
......@@ -721,6 +729,7 @@ void KeyedStoreGenericAssembler::EmitGenericPropertyStore(
// Validate the transition handler candidate and apply the transition.
HandleStoreICTransitionMapHandlerCase(p, var_transition_map.value(),
slow, true);
exit_point->Return(p->value);
}
}
}
......@@ -754,7 +763,7 @@ void KeyedStoreGenericAssembler::EmitGenericPropertyStore(
CheckForAssociatedProtector(p->name, slow);
StoreValueByKeyIndex<NameDictionary>(properties, var_name_index.value(),
p->value);
Return(p->value);
exit_point->Return(p->value);
}
}
......@@ -774,11 +783,11 @@ void KeyedStoreGenericAssembler::EmitGenericPropertyStore(
InvalidateValidityCellIfPrototype(receiver_map, bitfield2);
Add<NameDictionary>(properties, p->name, p->value,
&add_dictionary_property_slow);
Return(p->value);
exit_point->Return(p->value);
BIND(&add_dictionary_property_slow);
TailCallRuntime(Runtime::kAddDictionaryProperty, p->context, p->receiver,
p->name, p->value);
exit_point->ReturnCallRuntime(Runtime::kAddDictionaryProperty, p->context,
p->receiver, p->name, p->value);
}
}
......@@ -796,13 +805,17 @@ void KeyedStoreGenericAssembler::EmitGenericPropertyStore(
Callable callable = CodeFactory::Call(isolate());
CallJS(callable, p->context, setter, receiver, p->value);
Return(p->value);
exit_point->Return(p->value);
BIND(&not_callable);
{
Label strict(this);
BranchIfStrictMode(p->vector, p->slot, &strict);
Return(p->value);
if (assume_strict_language_mode) {
Goto(&strict);
} else {
BranchIfStrictMode(p->vector, p->slot, &strict);
exit_point->Return(p->value);
}
BIND(&strict);
{
......@@ -815,9 +828,12 @@ void KeyedStoreGenericAssembler::EmitGenericPropertyStore(
BIND(&readonly);
{
Label strict(this);
BranchIfStrictMode(p->vector, p->slot, &strict);
Return(p->value);
if (assume_strict_language_mode) {
Goto(&strict);
} else {
BranchIfStrictMode(p->vector, p->slot, &strict);
exit_point->Return(p->value);
}
BIND(&strict);
{
Node* type = Typeof(p->receiver);
......
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