Commit 5e993921 authored by Leszek Swirski's avatar Leszek Swirski Committed by Commit Bot

[ignition] Use jump for single deferred commands

For a single deferred commands, using a jump table is overkill, so
instead simply test the token against the single entry.

Bug: v8:4280
Bug: v8:6218
Change-Id: I0300f640080705fb10f46ad4ed5791703fa4dd77
Reviewed-on: https://chromium-review.googlesource.com/506153
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#45393}
parent bbb728bf
......@@ -198,19 +198,40 @@ class BytecodeGenerator::ControlScope::DeferredCommands final {
// Applies all recorded control-flow commands after the finally-block again.
// This generates a dynamic dispatch on the token from the entry point.
void ApplyDeferredCommands() {
BytecodeJumpTable* jump_table =
builder()->AllocateJumpTable(static_cast<int>(deferred_.size()), 0);
if (deferred_.size() == 0) return;
BytecodeLabel fall_through;
builder()
->LoadAccumulatorWithRegister(token_register_)
.SwitchOnSmiNoFeedback(jump_table)
.Jump(&fall_through);
for (const Entry& entry : deferred_) {
if (deferred_.size() == 1) {
// For a single entry, just jump to the fallthrough if we don't match the
// entry token.
const Entry& entry = deferred_[0];
builder()
->Bind(jump_table, entry.token)
.LoadAccumulatorWithRegister(result_register_);
->LoadLiteral(Smi::FromInt(entry.token))
.CompareOperation(Token::EQ_STRICT, token_register_)
.JumpIfFalse(ToBooleanMode::kAlreadyBoolean, &fall_through);
builder()->LoadAccumulatorWithRegister(result_register_);
execution_control()->PerformCommand(entry.command, entry.statement);
} else {
// For multiple entries, build a jump table and switch on the token,
// jumping to the fallthrough if none of them match.
BytecodeJumpTable* jump_table =
builder()->AllocateJumpTable(static_cast<int>(deferred_.size()), 0);
builder()
->LoadAccumulatorWithRegister(token_register_)
.SwitchOnSmiNoFeedback(jump_table)
.Jump(&fall_through);
for (const Entry& entry : deferred_) {
builder()
->Bind(jump_table, entry.token)
.LoadAccumulatorWithRegister(result_register_);
execution_control()->PerformCommand(entry.command, entry.statement);
}
}
builder()->Bind(&fall_through);
}
......
......@@ -11,7 +11,7 @@ snippet: "
"
frame size: 15
parameter count: 1
bytecode array length: 263
bytecode array length: 260
bytecodes: [
/* 30 E> */ B(StackCheck),
B(LdaZero),
......@@ -116,9 +116,9 @@ bytecodes: [
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(7), U8(1),
B(Ldar), R(11),
B(SetPendingMessage),
B(Ldar), R(9),
B(SwitchOnSmiNoFeedback), U8(10), U8(1), I8(0),
B(Jump), U8(5),
B(LdaZero),
B(TestEqualStrictNoFeedback), R(9),
B(JumpIfFalse), U8(5),
B(Ldar), R(10),
B(ReThrow),
B(LdaUndefined),
......@@ -135,7 +135,6 @@ constant pool: [
ONE_BYTE_INTERNALIZED_STRING_TYPE ["return"],
ONE_BYTE_INTERNALIZED_STRING_TYPE [""],
FIXED_ARRAY_TYPE,
Smi [6],
]
handlers: [
[7, 124, 130],
......@@ -296,7 +295,7 @@ snippet: "
"
frame size: 15
parameter count: 1
bytecode array length: 281
bytecode array length: 278
bytecodes: [
/* 30 E> */ B(StackCheck),
B(LdaZero),
......@@ -409,9 +408,9 @@ bytecodes: [
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(7), U8(1),
B(Ldar), R(11),
B(SetPendingMessage),
B(Ldar), R(9),
B(SwitchOnSmiNoFeedback), U8(10), U8(1), I8(0),
B(Jump), U8(5),
B(LdaZero),
B(TestEqualStrictNoFeedback), R(9),
B(JumpIfFalse), U8(5),
B(Ldar), R(10),
B(ReThrow),
B(LdaUndefined),
......@@ -428,7 +427,6 @@ constant pool: [
ONE_BYTE_INTERNALIZED_STRING_TYPE ["return"],
ONE_BYTE_INTERNALIZED_STRING_TYPE [""],
FIXED_ARRAY_TYPE,
Smi [6],
]
handlers: [
[7, 142, 148],
......
......@@ -15,7 +15,7 @@ snippet: "
"
frame size: 17
parameter count: 2
bytecode array length: 263
bytecode array length: 260
bytecodes: [
/* 10 E> */ B(StackCheck),
B(LdaZero),
......@@ -120,9 +120,9 @@ bytecodes: [
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(9), U8(1),
B(Ldar), R(13),
B(SetPendingMessage),
B(Ldar), R(11),
B(SwitchOnSmiNoFeedback), U8(9), U8(1), I8(0),
B(Jump), U8(5),
B(LdaZero),
B(TestEqualStrictNoFeedback), R(11),
B(JumpIfFalse), U8(5),
B(Ldar), R(12),
B(ReThrow),
B(LdaUndefined),
......@@ -138,7 +138,6 @@ constant pool: [
ONE_BYTE_INTERNALIZED_STRING_TYPE ["return"],
ONE_BYTE_INTERNALIZED_STRING_TYPE [""],
FIXED_ARRAY_TYPE,
Smi [6],
]
handlers: [
[7, 124, 130],
......@@ -155,7 +154,7 @@ snippet: "
"
frame size: 22
parameter count: 2
bytecode array length: 348
bytecode array length: 345
bytecodes: [
B(CreateFunctionContext), U8(4),
B(PushContext), R(7),
......@@ -298,9 +297,9 @@ bytecodes: [
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(6), U8(1),
B(Ldar), R(12),
B(SetPendingMessage),
B(Ldar), R(10),
B(SwitchOnSmiNoFeedback), U8(13), U8(1), I8(0),
B(Jump), U8(7),
B(LdaZero),
B(TestEqualStrictNoFeedback), R(10),
B(JumpIfFalse), U8(7),
B(PopContext), R(7),
B(Ldar), R(11),
B(ReThrow),
......@@ -322,7 +321,6 @@ constant pool: [
ONE_BYTE_INTERNALIZED_STRING_TYPE ["return"],
ONE_BYTE_INTERNALIZED_STRING_TYPE [""],
FIXED_ARRAY_TYPE,
Smi [6],
]
handlers: [
[35, 205, 211],
......@@ -339,7 +337,7 @@ snippet: "
"
frame size: 15
parameter count: 2
bytecode array length: 281
bytecode array length: 278
bytecodes: [
/* 10 E> */ B(StackCheck),
B(LdaZero),
......@@ -453,9 +451,9 @@ bytecodes: [
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(7), U8(1),
B(Ldar), R(11),
B(SetPendingMessage),
B(Ldar), R(9),
B(SwitchOnSmiNoFeedback), U8(11), U8(1), I8(0),
B(Jump), U8(5),
B(LdaZero),
B(TestEqualStrictNoFeedback), R(9),
B(JumpIfFalse), U8(5),
B(Ldar), R(10),
B(ReThrow),
B(LdaUndefined),
......@@ -473,7 +471,6 @@ constant pool: [
ONE_BYTE_INTERNALIZED_STRING_TYPE ["return"],
ONE_BYTE_INTERNALIZED_STRING_TYPE [""],
FIXED_ARRAY_TYPE,
Smi [6],
]
handlers: [
[7, 142, 148],
......@@ -490,7 +487,7 @@ snippet: "
"
frame size: 20
parameter count: 2
bytecode array length: 301
bytecode array length: 298
bytecodes: [
/* 10 E> */ B(StackCheck),
B(LdaZero),
......@@ -611,9 +608,9 @@ bytecodes: [
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(12), U8(1),
B(Ldar), R(16),
B(SetPendingMessage),
B(Ldar), R(14),
B(SwitchOnSmiNoFeedback), U8(11), U8(1), I8(0),
B(Jump), U8(5),
B(LdaZero),
B(TestEqualStrictNoFeedback), R(14),
B(JumpIfFalse), U8(5),
B(Ldar), R(15),
B(ReThrow),
B(LdaUndefined),
......@@ -631,7 +628,6 @@ constant pool: [
FIXED_ARRAY_TYPE,
ONE_BYTE_INTERNALIZED_STRING_TYPE ["return"],
FIXED_ARRAY_TYPE,
Smi [6],
]
handlers: [
[7, 162, 168],
......@@ -648,7 +644,7 @@ snippet: "
"
frame size: 15
parameter count: 2
bytecode array length: 596
bytecode array length: 593
bytecodes: [
B(Ldar), R(new_target),
B(JumpIfUndefined), U8(26),
......@@ -699,7 +695,7 @@ bytecodes: [
B(Star), R(7),
B(LdaZero),
B(Star), R(6),
B(JumpConstant), U8(14),
B(JumpConstant), U8(13),
B(Ldar), R(11),
/* 11 E> */ B(Throw),
B(Ldar), R(closure),
......@@ -851,9 +847,9 @@ bytecodes: [
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(12), U8(1),
B(Ldar), R(11),
B(SetPendingMessage),
B(Ldar), R(9),
B(SwitchOnSmiNoFeedback), U8(13), U8(1), I8(0),
B(Jump), U8(15),
B(LdaZero),
B(TestEqualStrictNoFeedback), R(9),
B(JumpIfFalse), U8(15),
B(PopContext), R(1),
B(PopContext), R(1),
B(LdaSmi), I8(1),
......@@ -885,7 +881,7 @@ bytecodes: [
B(Ldar), R(8),
B(SetPendingMessage),
B(Ldar), R(6),
B(SwitchOnSmiNoFeedback), U8(15), U8(2), I8(0),
B(SwitchOnSmiNoFeedback), U8(14), U8(2), I8(0),
B(Jump), U8(8),
B(Ldar), R(7),
/* 55 S> */ B(Return),
......@@ -908,13 +904,12 @@ constant pool: [
ONE_BYTE_INTERNALIZED_STRING_TYPE ["return"],
ONE_BYTE_INTERNALIZED_STRING_TYPE [""],
FIXED_ARRAY_TYPE,
Smi [6],
Smi [449],
Smi [446],
Smi [6],
Smi [9],
]
handlers: [
[56, 552, 558],
[56, 549, 555],
[137, 334, 340],
[140, 290, 292],
[426, 442, 444],
......@@ -1258,7 +1253,7 @@ snippet: "
"
frame size: 14
parameter count: 2
bytecode array length: 559
bytecode array length: 556
bytecodes: [
B(CreateFunctionContext), U8(10),
B(PushContext), R(0),
......@@ -1423,9 +1418,9 @@ bytecodes: [
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(11), U8(1),
B(Ldar), R(10),
B(SetPendingMessage),
B(Ldar), R(8),
B(SwitchOnSmiNoFeedback), U8(12), U8(1), I8(0),
B(Jump), U8(9),
B(LdaZero),
B(TestEqualStrictNoFeedback), R(8),
B(JumpIfFalse), U8(9),
B(PopContext), R(1),
B(PopContext), R(1),
B(Ldar), R(9),
......@@ -1446,7 +1441,7 @@ bytecodes: [
B(Jump), U8(53),
B(Star), R(8),
B(Ldar), R(closure),
B(CreateCatchContext), R(8), U8(7), U8(13),
B(CreateCatchContext), R(8), U8(7), U8(12),
B(Star), R(7),
B(LdaTheHole),
B(SetPendingMessage),
......@@ -1485,7 +1480,7 @@ bytecodes: [
B(Ldar), R(6),
B(SetPendingMessage),
B(Ldar), R(4),
B(SwitchOnSmiNoFeedback), U8(14), U8(2), I8(0),
B(SwitchOnSmiNoFeedback), U8(13), U8(2), I8(0),
B(Jump), U8(8),
B(Ldar), R(5),
/* 60 S> */ B(Return),
......@@ -1507,14 +1502,13 @@ constant pool: [
ONE_BYTE_INTERNALIZED_STRING_TYPE ["return"],
ONE_BYTE_INTERNALIZED_STRING_TYPE [""],
FIXED_ARRAY_TYPE,
Smi [6],
FIXED_ARRAY_TYPE,
Smi [6],
Smi [9],
]
handlers: [
[21, 513, 519],
[24, 460, 462],
[21, 510, 516],
[24, 457, 459],
[41, 242, 248],
[44, 194, 196],
[334, 350, 352],
......
......@@ -12,7 +12,7 @@ snippet: "
"
frame size: 4
parameter count: 1
bytecode array length: 47
bytecode array length: 44
bytecodes: [
/* 30 E> */ B(StackCheck),
/* 42 S> */ B(LdaSmi), I8(1),
......@@ -33,16 +33,15 @@ bytecodes: [
B(Star), R(0),
B(Ldar), R(3),
/* 72 E> */ B(SetPendingMessage),
B(Ldar), R(1),
B(SwitchOnSmiNoFeedback), U8(0), U8(1), I8(0),
B(Jump), U8(5),
B(LdaZero),
B(TestEqualStrictNoFeedback), R(1),
B(JumpIfFalse), U8(5),
B(Ldar), R(2),
B(ReThrow),
B(LdaUndefined),
/* 79 S> */ B(Return),
]
constant pool: [
Smi [6],
]
handlers: [
[8, 12, 18],
......@@ -55,7 +54,7 @@ snippet: "
"
frame size: 7
parameter count: 1
bytecode array length: 74
bytecode array length: 71
bytecodes: [
/* 30 E> */ B(StackCheck),
/* 42 S> */ B(LdaSmi), I8(1),
......@@ -89,9 +88,9 @@ bytecodes: [
B(Star), R(0),
B(Ldar), R(4),
/* 92 E> */ B(SetPendingMessage),
B(Ldar), R(2),
B(SwitchOnSmiNoFeedback), U8(2), U8(1), I8(0),
B(Jump), U8(5),
B(LdaZero),
B(TestEqualStrictNoFeedback), R(2),
B(JumpIfFalse), U8(5),
B(Ldar), R(3),
B(ReThrow),
B(LdaUndefined),
......@@ -100,7 +99,6 @@ bytecodes: [
constant pool: [
ONE_BYTE_INTERNALIZED_STRING_TYPE ["e"],
FIXED_ARRAY_TYPE,
Smi [6],
]
handlers: [
[8, 39, 45],
......@@ -115,7 +113,7 @@ snippet: "
"
frame size: 8
parameter count: 1
bytecode array length: 97
bytecode array length: 94
bytecodes: [
/* 30 E> */ B(StackCheck),
B(Mov), R(context), R(4),
......@@ -160,9 +158,9 @@ bytecodes: [
B(Star), R(0),
B(Ldar), R(4),
/* 116 E> */ B(SetPendingMessage),
B(Ldar), R(2),
B(SwitchOnSmiNoFeedback), U8(3), U8(1), I8(0),
B(Jump), U8(5),
B(LdaZero),
B(TestEqualStrictNoFeedback), R(2),
B(JumpIfFalse), U8(5),
B(Ldar), R(3),
B(ReThrow),
B(LdaUndefined),
......@@ -172,7 +170,6 @@ constant pool: [
ONE_BYTE_INTERNALIZED_STRING_TYPE ["e"],
FIXED_ARRAY_TYPE,
FIXED_ARRAY_TYPE,
Smi [6],
]
handlers: [
[4, 62, 68],
......
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