Skip to content

Commit

Permalink
Merged: [ic] Fix store handler selection for arguments objects
Browse files Browse the repository at this point in the history
Drive-by: fix printing of handlers in --trace-feedback-updates mode.

Bug: chromium:1450481
(cherry picked from commit e144f3b)

Change-Id: Ic8d20764a8eeac3d1f77c37cfb270d387482e7bb
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4584888
Reviewed-by: Toon Verwaest <[email protected]>
Commit-Queue: Igor Sheludko <[email protected]>
Cr-Commit-Position: refs/branch-heads/11.5@{v8#6}
Cr-Branched-From: 0c4044b-refs/heads/11.5.150@{#1}
Cr-Branched-From: b71d303-refs/heads/main@{#87781}
  • Loading branch information
isheludko authored and V8 LUCI CQ committed Jun 2, 2023
1 parent 565f01c commit dd4ae1d
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 10 deletions.
16 changes: 11 additions & 5 deletions src/diagnostics/objects-printer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1338,12 +1338,18 @@ void FeedbackNexus::Print(std::ostream& os) {
case FeedbackSlotKind::kSetKeyedStrict: {
os << InlineCacheState2String(ic_state());
if (ic_state() == InlineCacheState::MONOMORPHIC) {
os << "\n " << Brief(GetFeedback()) << ": ";
Object handler = GetFeedbackExtra().GetHeapObjectOrSmi();
if (handler.IsWeakFixedArray()) {
handler = WeakFixedArray::cast(handler).Get(0).GetHeapObjectOrSmi();
HeapObject feedback = GetFeedback().GetHeapObject();
HeapObject feedback_extra = GetFeedbackExtra().GetHeapObject();
if (feedback.IsName()) {
os << " with name " << Brief(feedback);
WeakFixedArray array = WeakFixedArray::cast(feedback_extra);
os << "\n " << Brief(array.Get(0)) << ": ";
Object handler = array.Get(1).GetHeapObjectOrSmi();
StoreHandler::PrintHandler(handler, os);
} else {
os << "\n " << Brief(feedback) << ": ";
StoreHandler::PrintHandler(feedback_extra, os);
}
StoreHandler::PrintHandler(handler, os);
} else if (ic_state() == InlineCacheState::POLYMORPHIC) {
HeapObject feedback = GetFeedback().GetHeapObject();
WeakFixedArray array;
Expand Down
5 changes: 4 additions & 1 deletion src/ic/handler-configuration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -596,8 +596,11 @@ void StoreHandler::PrintHandler(Object handler, std::ostream& os) {
os << ", validity cell = ";
store_handler.validity_cell().ShortPrint(os);
os << ")" << std::endl;
} else if (handler.IsMap()) {
os << "StoreHandler(field transition to " << Brief(handler) << ")"
<< std::endl;
} else {
os << "StoreHandler(<unexpected>)(" << Brief(handler) << ")";
os << "StoreHandler(<unexpected>)(" << Brief(handler) << ")" << std::endl;
}
}

Expand Down
16 changes: 12 additions & 4 deletions src/ic/ic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2303,10 +2303,18 @@ Handle<Object> KeyedStoreIC::StoreElementHandler(
receiver_map->has_sealed_elements() ||
receiver_map->has_nonextensible_elements() ||
receiver_map->has_typed_array_or_rab_gsab_typed_array_elements()) {
// TODO(jgruber): Update counter name.
TRACE_HANDLER_STATS(isolate(), KeyedStoreIC_StoreFastElementStub);
code = StoreHandler::StoreFastElementBuiltin(isolate(), store_mode);
if (receiver_map->has_typed_array_or_rab_gsab_typed_array_elements()) {
return code;
if (receiver_map->IsJSArgumentsObjectMap() &&
receiver_map->has_fast_packed_elements()) {
// Allow fast behaviour for in-bounds stores while making it miss and
// properly handle the out of bounds store case.
code = StoreHandler::StoreFastElementBuiltin(isolate(), STANDARD_STORE);
} else {
code = StoreHandler::StoreFastElementBuiltin(isolate(), store_mode);
if (receiver_map->has_typed_array_or_rab_gsab_typed_array_elements()) {
return code;
}
}
} else if (IsStoreInArrayLiteralIC()) {
// TODO(jgruber): Update counter name.
Expand All @@ -2317,7 +2325,7 @@ Handle<Object> KeyedStoreIC::StoreElementHandler(
TRACE_HANDLER_STATS(isolate(), KeyedStoreIC_StoreElementStub);
DCHECK(DICTIONARY_ELEMENTS == receiver_map->elements_kind() ||
receiver_map->has_frozen_elements());
code = StoreHandler::StoreSlow(isolate(), store_mode);
return StoreHandler::StoreSlow(isolate(), store_mode);
}

if (IsAnyDefineOwn() || IsStoreInArrayLiteralIC()) return code;
Expand Down
4 changes: 4 additions & 0 deletions src/objects/map-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,10 @@ bool Map::has_fast_elements() const {
return IsFastElementsKind(elements_kind());
}

bool Map::has_fast_packed_elements() const {
return IsFastPackedElementsKind(elements_kind());
}

bool Map::has_sloppy_arguments_elements() const {
return IsSloppyArgumentsElementsKind(elements_kind());
}
Expand Down
1 change: 1 addition & 0 deletions src/objects/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ class Map : public TorqueGeneratedMap<Map, HeapObject> {
inline bool has_fast_smi_or_object_elements() const;
inline bool has_fast_double_elements() const;
inline bool has_fast_elements() const;
inline bool has_fast_packed_elements() const;
inline bool has_sloppy_arguments_elements() const;
inline bool has_fast_sloppy_arguments_elements() const;
inline bool has_fast_string_wrapper_elements() const;
Expand Down

0 comments on commit dd4ae1d

Please sign in to comment.