[FeedbackVector] Case statements can share a single vector slot

In the fast case, the feedback should be the same across all slots
(like a switch over enum values).

BUG=v8:7045

Change-Id: I2c32f81cda55874ea6fc8d6a18c85d9929cff1bb
Reviewed-on: https://chromium-review.googlesource.com/756701
Reviewed-by: Mythri Alle <mythria@chromium.org>
Commit-Queue: Michael Stanton <mvstanton@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49177}
This commit is contained in:
Mike Stanton 2017-11-07 10:19:54 +01:00 committed by Commit Bot
parent f2062511ca
commit bdcab5f756
2 changed files with 14 additions and 12 deletions

View File

@ -1382,6 +1382,9 @@ void BytecodeGenerator::VisitSwitchStatement(SwitchStatement* stmt) {
// Keep the switch value in a register until a case matches.
Register tag = VisitForRegisterValue(stmt->tag());
FeedbackSlot slot = clauses->length() > 0
? feedback_spec()->AddCompareICSlot()
: FeedbackSlot::Invalid();
// Iterate over all cases and create nodes for label comparison.
for (int i = 0; i < clauses->length(); i++) {
@ -1395,9 +1398,8 @@ void BytecodeGenerator::VisitSwitchStatement(SwitchStatement* stmt) {
// Perform label comparison as if via '===' with tag.
VisitForAccumulatorValue(clause->label());
builder()->CompareOperation(
Token::Value::EQ_STRICT, tag,
feedback_index(feedback_spec()->AddCompareICSlot()));
builder()->CompareOperation(Token::Value::EQ_STRICT, tag,
feedback_index(slot));
switch_builder.Case(ToBooleanMode::kAlreadyBoolean, i);
}

View File

@ -25,7 +25,7 @@ bytecodes: [
B(Mov), R(0), R(1),
B(JumpIfTrue), U8(11),
B(LdaSmi), I8(2),
B(TestEqualStrict), R(1), U8(1),
B(TestEqualStrict), R(1), U8(0),
B(JumpIfTrue), U8(7),
B(Jump), U8(8),
/* 66 S> */ B(LdaSmi), I8(2),
@ -60,7 +60,7 @@ bytecodes: [
B(Mov), R(0), R(1),
B(JumpIfTrue), U8(11),
B(LdaSmi), I8(2),
B(TestEqualStrict), R(1), U8(1),
B(TestEqualStrict), R(1), U8(0),
B(JumpIfTrue), U8(10),
B(Jump), U8(14),
/* 66 S> */ B(LdaSmi), I8(2),
@ -97,7 +97,7 @@ bytecodes: [
B(Mov), R(0), R(1),
B(JumpIfTrue), U8(11),
B(LdaSmi), I8(2),
B(TestEqualStrict), R(1), U8(1),
B(TestEqualStrict), R(1), U8(0),
B(JumpIfTrue), U8(8),
B(Jump), U8(12),
/* 66 S> */ B(LdaSmi), I8(2),
@ -134,7 +134,7 @@ bytecodes: [
B(Mov), R(0), R(1),
B(JumpIfTrue), U8(11),
B(LdaSmi), I8(3),
B(TestEqualStrict), R(1), U8(1),
B(TestEqualStrict), R(1), U8(0),
B(JumpIfTrue), U8(6),
B(Jump), U8(6),
/* 66 S> */ B(Jump), U8(10),
@ -172,7 +172,7 @@ bytecodes: [
B(TestEqualStrict), R(1), U8(0),
B(JumpIfTrue), U8(11),
B(LdaSmi), I8(3),
B(TestEqualStrict), R(1), U8(1),
B(TestEqualStrict), R(1), U8(0),
B(JumpIfTrue), U8(10),
B(Jump), U8(14),
/* 74 S> */ B(LdaSmi), I8(1),
@ -313,7 +313,7 @@ bytecodes: [
B(Mov), R(0), R(1),
B(JumpIfTrue), U8(11),
B(LdaSmi), I8(2),
B(TestEqualStrict), R(1), U8(1),
B(TestEqualStrict), R(1), U8(0),
B(JumpIfTrueConstant), U8(0),
B(JumpConstant), U8(1),
/* 68 S> */ B(LdaSmi), I8(2),
@ -482,14 +482,14 @@ bytecodes: [
B(Mov), R(0), R(1),
B(JumpIfTrue), U8(11),
B(LdaSmi), I8(2),
B(TestEqualStrict), R(1), U8(1),
B(TestEqualStrict), R(1), U8(0),
B(JumpIfTrue), U8(32),
B(Jump), U8(34),
/* 70 S> */ B(Ldar), R(0),
/* 79 E> */ B(AddSmi), I8(1), U8(2),
/* 79 E> */ B(AddSmi), I8(1), U8(1),
B(Star), R(2),
B(LdaSmi), I8(2),
B(TestEqualStrict), R(2), U8(3),
B(TestEqualStrict), R(2), U8(2),
B(JumpIfTrue), U8(4),
B(Jump), U8(8),
/* 101 S> */ B(LdaSmi), I8(1),