[cleanup] Add UpdateFeedbackMode to CollectConstructFeedback to avoid test

Change-Id: Icdd2d4a178415d240a82378ffa575e6e6b79dca1
Bug: v8:11429
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2697353
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: Nico Hartmann <nicohartmann@chromium.org>
Reviewed-by: Toon Verwaest <verwaest@chromium.org>
Commit-Queue: Victor Gomes <victorgomes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#72805}
This commit is contained in:
Victor Gomes 2021-02-17 11:25:58 +01:00 committed by Commit Bot
parent af3c5307f0
commit d85c81b45a
7 changed files with 39 additions and 14 deletions

View File

@ -228,6 +228,10 @@ type Callable = JSFunction|JSBoundFunction|CallableJSProxy|CallableApiObject;
type WriteBarrierMode
generates 'TNode<Int32T>' constexpr 'WriteBarrierMode';
extern enum UpdateFeedbackMode { kOptionalFeedback, kGuaranteedFeedback }
extern operator '==' macro UpdateFeedbackModeEqual(
constexpr UpdateFeedbackMode, constexpr UpdateFeedbackMode): constexpr bool;
extern enum UnicodeEncoding { UTF16, UTF32 }
// Promise constants

View File

@ -47,13 +47,12 @@ TF_BUILTIN(Construct_Baseline, CallOrConstructBuiltinsAssembler) {
// TODO(verwaest): Only emit context loads where necessary
auto context = LoadContextFromBaseline();
// TODO(verwaest): Make sure CollectConstructFeedback knows we have a
// feedback vector.
auto feedback_vector = LoadFeedbackVectorFromBaseline();
TVARIABLE(AllocationSite, allocation_site);
Label if_construct_generic(this), if_construct_array(this);
CollectConstructFeedback(context, target, new_target, feedback_vector, slot,
UpdateFeedbackMode::kGuaranteedFeedback,
&if_construct_generic, &if_construct_array,
&allocation_site);
@ -76,6 +75,7 @@ TF_BUILTIN(Construct_WithFeedback, CallOrConstructBuiltinsAssembler) {
TVARIABLE(AllocationSite, allocation_site);
Label if_construct_generic(this), if_construct_array(this);
CollectConstructFeedback(context, target, new_target, feedback_vector, slot,
UpdateFeedbackMode::kOptionalFeedback,
&if_construct_generic, &if_construct_array,
&allocation_site);
@ -107,6 +107,7 @@ TF_BUILTIN(ConstructWithArrayLike_WithFeedback,
TVARIABLE(AllocationSite, allocation_site);
Label if_construct_generic(this), if_construct_array(this);
CollectConstructFeedback(context, target, new_target, feedback_vector, slot,
UpdateFeedbackMode::kOptionalFeedback,
&if_construct_generic, &if_construct_array,
&allocation_site);
@ -137,13 +138,12 @@ TF_BUILTIN(ConstructWithSpread_Baseline, CallOrConstructBuiltinsAssembler) {
// TODO(verwaest): Only emit context loads where necessary
auto context = LoadContextFromBaseline();
// TODO(verwaest): Make sure CollectConstructFeedback knows we have a
// feedback vector.
auto feedback_vector = LoadFeedbackVectorFromBaseline();
TVARIABLE(AllocationSite, allocation_site);
Label if_construct_generic(this), if_construct_array(this);
CollectConstructFeedback(context, target, new_target, feedback_vector, slot,
UpdateFeedbackMode::kGuaranteedFeedback,
&if_construct_generic, &if_construct_array,
&allocation_site);
@ -167,6 +167,7 @@ TF_BUILTIN(ConstructWithSpread_WithFeedback, CallOrConstructBuiltinsAssembler) {
TVARIABLE(AllocationSite, allocation_site);
Label if_construct_generic(this), if_construct_array(this);
CollectConstructFeedback(context, target, new_target, feedback_vector, slot,
UpdateFeedbackMode::kOptionalFeedback,
&if_construct_generic, &if_construct_array,
&allocation_site);

View File

@ -141,10 +141,25 @@ macro BothTaggedEqualArrayFunction(implicit context: Context)(
extern macro CreateAllocationSiteInFeedbackVector(
FeedbackVector, uintptr): AllocationSite;
macro CastFeedbackVector(
maybeFeedbackVector: Undefined|FeedbackVector,
updateFeedbackMode: constexpr UpdateFeedbackMode):
FeedbackVector labels Fallback {
if constexpr (updateFeedbackMode == UpdateFeedbackMode::kGuaranteedFeedback) {
return UnsafeCast<FeedbackVector>(maybeFeedbackVector);
} else if constexpr (
updateFeedbackMode == UpdateFeedbackMode::kOptionalFeedback) {
return Cast<FeedbackVector>(maybeFeedbackVector) otherwise goto Fallback;
} else {
unreachable;
}
}
macro CollectConstructFeedback(implicit context: Context)(
target: JSAny, newTarget: JSAny,
maybeFeedbackVector: Undefined|FeedbackVector,
slotId: uintptr): never labels ConstructGeneric,
maybeFeedbackVector: Undefined|FeedbackVector, slotId: uintptr,
updateFeedbackMode: constexpr UpdateFeedbackMode):
never labels ConstructGeneric,
ConstructArray(AllocationSite) {
// TODO(v8:9891): Remove this assert once all callers are ported to Torque.
// This assert ensures correctness of maybeFeedbackVector's type which can
@ -152,8 +167,10 @@ macro CollectConstructFeedback(implicit context: Context)(
assert(
IsUndefined(maybeFeedbackVector) ||
Is<FeedbackVector>(maybeFeedbackVector));
const feedbackVector = Cast<FeedbackVector>(maybeFeedbackVector)
otherwise goto ConstructGeneric;
const feedbackVector = CastFeedbackVector(
maybeFeedbackVector, updateFeedbackMode) otherwise goto ConstructGeneric;
IncrementCallCount(feedbackVector, slotId);
try {

View File

@ -25,11 +25,12 @@ macro CollectInstanceOfFeedback(
@export
macro CollectConstructFeedback(implicit context: Context)(
target: JSAny, newTarget: JSAny,
maybeFeedbackVector: Undefined|FeedbackVector,
slotId: uintptr): never labels ConstructGeneric,
maybeFeedbackVector: Undefined|FeedbackVector, slotId: uintptr,
updateFeedbackMode: constexpr UpdateFeedbackMode):
never labels ConstructGeneric,
ConstructArray(AllocationSite) {
callable::CollectConstructFeedback(
target, newTarget, maybeFeedbackVector, slotId)
target, newTarget, maybeFeedbackVector, slotId, updateFeedbackMode)
otherwise ConstructGeneric, ConstructArray;
}

View File

@ -50,7 +50,6 @@ builtin BytecodeBudgetInterruptFromCode(implicit context: Context)(
extern transitioning builtin ForInFilter(implicit context: Context)(
JSAny, HeapObject): JSAny;
extern enum ForInFeedback extends uint31 { kAny, ...}
extern enum UpdateFeedbackMode { kOptionalFeedback, kGuaranteedFeedback }
extern macro UpdateFeedback(
SmiTagged<ForInFeedback>, Undefined | FeedbackVector, uintptr,
constexpr UpdateFeedbackMode);

View File

@ -3172,6 +3172,9 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
TNode<JSFunction> closure);
// Update the type feedback vector.
bool UpdateFeedbackModeEqual(UpdateFeedbackMode a, UpdateFeedbackMode b) {
return a == b;
}
void UpdateFeedback(TNode<Smi> feedback,
TNode<HeapObject> maybe_feedback_vector,
TNode<UintPtrT> slot_id, UpdateFeedbackMode mode);

View File

@ -802,8 +802,8 @@ TNode<Object> InterpreterAssembler::Construct(
construct_array(this, &var_site);
CollectConstructFeedback(context, target, new_target, maybe_feedback_vector,
slot_id, &construct_generic, &construct_array,
&var_site);
slot_id, UpdateFeedbackMode::kOptionalFeedback,
&construct_generic, &construct_array, &var_site);
BIND(&construct_generic);
{