Commit e0c851fc authored by Ross McIlroy's avatar Ross McIlroy Committed by Commit Bot

[Turboprop] Avoid passing unnecessary args to DyanmicMapChecks builtin

The feedback vector can be retrieved from the callee's frame, and the
actual_map can be read from the actual_value, so avoid passing these
explicitly to the DynamicMapChecks builtin. This reduces the size of
each DynamicMapCheck codegen by around 20 bytes on x64.

BUG=v8:9684

Change-Id: I31cf9b8cf085284ac051ebafc86f3e26105f3046
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2485813
Auto-Submit: Ross McIlroy <rmcilroy@chromium.org>
Commit-Queue: Sathya Gunasekaran  <gsathya@chromium.org>
Reviewed-by: 's avatarSathya Gunasekaran  <gsathya@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70629}
parent 4068b3d2
...@@ -11,6 +11,7 @@ const kBailout: constexpr int32 ...@@ -11,6 +11,7 @@ const kBailout: constexpr int32
const kDeopt: constexpr int32 const kDeopt: constexpr int32
generates 'static_cast<int>(DynamicMapChecksStatus::kDeopt)'; generates 'static_cast<int>(DynamicMapChecksStatus::kDeopt)';
extern runtime TryMigrateInstance(implicit context: Context)(Object): Object; extern runtime TryMigrateInstance(implicit context: Context)(Object): Object;
extern macro LoadFeedbackVectorForStub(): FeedbackVector;
macro PerformMapAndHandlerCheck( macro PerformMapAndHandlerCheck(
entry: constexpr int32, polymorphicArray: WeakFixedArray, entry: constexpr int32, polymorphicArray: WeakFixedArray,
...@@ -123,8 +124,10 @@ macro PerformMonomorphicCheck( ...@@ -123,8 +124,10 @@ macro PerformMonomorphicCheck(
// //
// For other cases, we bailout to the runtime. // For other cases, we bailout to the runtime.
builtin DynamicMapChecks(implicit context: Context)( builtin DynamicMapChecks(implicit context: Context)(
feedbackVector: FeedbackVector, slotIndex: intptr, actualValue: HeapObject, slotIndex: intptr, actualValue: HeapObject,
actualMap: Map, actualHandler: Smi|DataHandler): int32 { actualHandler: Smi|DataHandler): int32 {
const feedbackVector = LoadFeedbackVectorForStub();
let actualMap = actualValue.map;
const feedback = feedbackVector[slotIndex]; const feedback = feedbackVector[slotIndex];
try { try {
const maybePolymorphicArray = const maybePolymorphicArray =
...@@ -132,7 +135,6 @@ builtin DynamicMapChecks(implicit context: Context)( ...@@ -132,7 +135,6 @@ builtin DynamicMapChecks(implicit context: Context)(
return PerformPolymorphicCheck( return PerformPolymorphicCheck(
maybePolymorphicArray, actualMap, actualHandler); maybePolymorphicArray, actualMap, actualHandler);
} label MigrateAndDoMonomorphicCheck { } label MigrateAndDoMonomorphicCheck {
let newActualMap = actualMap;
if (IsDeprecatedMap(actualMap)) { if (IsDeprecatedMap(actualMap)) {
// TODO(gsathya): Should this migration happen before the // TODO(gsathya): Should this migration happen before the
// polymorphic check? // polymorphic check?
...@@ -140,10 +142,10 @@ builtin DynamicMapChecks(implicit context: Context)( ...@@ -140,10 +142,10 @@ builtin DynamicMapChecks(implicit context: Context)(
if (TaggedIsSmi(result)) { if (TaggedIsSmi(result)) {
return kDeopt; return kDeopt;
} }
newActualMap = actualValue.map; actualMap = actualValue.map;
} }
return PerformMonomorphicCheck( return PerformMonomorphicCheck(
feedbackVector, slotIndex, feedback, newActualMap, actualHandler); feedbackVector, slotIndex, feedback, actualMap, actualHandler);
} }
} }
......
...@@ -1991,7 +1991,6 @@ void EffectControlLinearizer::LowerDynamicCheckMaps(Node* node, ...@@ -1991,7 +1991,6 @@ void EffectControlLinearizer::LowerDynamicCheckMaps(Node* node,
Node* actual_value = node->InputAt(0); Node* actual_value = node->InputAt(0);
FeedbackSource const& feedback = p.feedback(); FeedbackSource const& feedback = p.feedback();
Node* feedback_vector = __ HeapConstant(feedback.vector);
Node* actual_value_map = __ LoadField(AccessBuilder::ForMap(), actual_value); Node* actual_value_map = __ LoadField(AccessBuilder::ForMap(), actual_value);
Node* actual_handler = Node* actual_handler =
p.handler()->IsSmi() p.handler()->IsSmi()
...@@ -2014,9 +2013,8 @@ void EffectControlLinearizer::LowerDynamicCheckMaps(Node* node, ...@@ -2014,9 +2013,8 @@ void EffectControlLinearizer::LowerDynamicCheckMaps(Node* node,
Node* slot_index = __ IntPtrConstant(feedback.index()); Node* slot_index = __ IntPtrConstant(feedback.index());
Operator::Properties properties = Operator::kNoDeopt | Operator::kNoThrow; Operator::Properties properties = Operator::kNoDeopt | Operator::kNoThrow;
auto builtin = Builtins::kDynamicMapChecks; auto builtin = Builtins::kDynamicMapChecks;
Node* result = Node* result = CallBuiltin(builtin, properties, slot_index, actual_value,
CallBuiltin(builtin, properties, feedback_vector, slot_index, actual_handler);
actual_value, actual_value_map, actual_handler);
__ GotoIf(__ WordEqual(result, __ IntPtrConstant(static_cast<int>( __ GotoIf(__ WordEqual(result, __ IntPtrConstant(static_cast<int>(
DynamicMapChecksStatus::kSuccess))), DynamicMapChecksStatus::kSuccess))),
&done); &done);
...@@ -2035,6 +2033,7 @@ void EffectControlLinearizer::LowerDynamicCheckMaps(Node* node, ...@@ -2035,6 +2033,7 @@ void EffectControlLinearizer::LowerDynamicCheckMaps(Node* node,
} }
} else { } else {
DCHECK_EQ(p.state(), DynamicCheckMapsParameters::kPolymorphic); DCHECK_EQ(p.state(), DynamicCheckMapsParameters::kPolymorphic);
Node* feedback_vector = __ HeapConstant(feedback.vector);
Node* feedback_slot = Node* feedback_slot =
__ LoadField(AccessBuilder::ForFeedbackVectorSlot(feedback.index()), __ LoadField(AccessBuilder::ForFeedbackVectorSlot(feedback.index()),
feedback_vector); feedback_vector);
......
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