Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Unified Diff: test/unittests/interpreter/bytecode-array-builder-unittest.cc

Issue 2795183002: [Interpreter] Move ToBoolean elision in BytecodeGenerator. (Closed)
Patch Set: tests Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: test/unittests/interpreter/bytecode-array-builder-unittest.cc
diff --git a/test/unittests/interpreter/bytecode-array-builder-unittest.cc b/test/unittests/interpreter/bytecode-array-builder-unittest.cc
index f70c86d7372d5e4593dc849a99cbf85ea4887329..f4e097342a2355281127a1cd91d9f62d87359064 100644
--- a/test/unittests/interpreter/bytecode-array-builder-unittest.cc
+++ b/test/unittests/interpreter/bytecode-array-builder-unittest.cc
@@ -22,6 +22,8 @@ class BytecodeArrayBuilderTest : public TestWithIsolateAndZone {
~BytecodeArrayBuilderTest() override {}
};
+using ToBooleanMode = BytecodeArrayBuilder::ToBooleanMode;
+
TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) {
CanonicalHandleScope canonical(isolate());
BytecodeArrayBuilder builder(isolate(), zone(), 0, 1, 131);
@@ -195,8 +197,8 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) {
// Emit unary operator invocations.
builder
- .LogicalNot() // ToBooleanLogicalNot
- .LogicalNot() // non-ToBoolean LogicalNot
+ .LogicalNot(ToBooleanMode::kConvertToBoolean)
+ .LogicalNot(ToBooleanMode::kAlreadyBoolean)
.TypeOf();
// Emit delete
@@ -241,7 +243,8 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) {
// Short jumps with Imm8 operands
{
BytecodeLabel start, after_jump1, after_jump2, after_jump3, after_jump4,
- after_jump5, after_jump6, after_jump7;
+ after_jump5, after_jump6, after_jump7, after_jump8, after_jump9,
+ after_jump10, after_jump11;
builder.Bind(&start)
.Jump(&after_jump1)
.Bind(&after_jump1)
@@ -257,6 +260,14 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) {
.Bind(&after_jump6)
.JumpIfJSReceiver(&after_jump7)
.Bind(&after_jump7)
+ .JumpIfTrue(ToBoolean::kConvertToBoolean, &after_jump8)
+ .Bind(&after_jump8)
+ .JumpIfTrue(ToBoolean::kAlreadyBoolean, &after_jump9)
+ .Bind(&after_jump9)
+ .JumpIfFalse(ToBoolean::kConvertToBoolean, &after_jump10)
+ .Bind(&after_jump10)
+ .JumpIfFalse(ToBoolean::kAlreadyBoolean, &after_jump11)
+ .Bind(&after_jump11)
.JumpLoop(&start, 0);
}
@@ -266,14 +277,10 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) {
BytecodeLabel after_jump;
builder.Jump(&end[0])
.Bind(&after_jump)
- .LoadTrue()
- .JumpIfTrue(&end[1])
- .LoadTrue()
- .JumpIfFalse(&end[2])
- .LoadLiteral(Smi::kZero)
- .JumpIfTrue(&end[3])
- .LoadLiteral(Smi::kZero)
- .JumpIfFalse(&end[4])
+ .JumpIfTrue(ToBoolean::kConvertToBoolean, &end[1])
+ .JumpIfTrue(ToBoolean::kAlreadyBoolean, &end[2])
+ .JumpIfFalse(ToBoolean::kConvertToBoolean, &end[3])
+ .JumpIfFalse(ToBoolean::kAlreadyBoolean, &end[4])
.JumpIfNull(&end[5])
.JumpIfNotNull(&end[6])
.JumpIfUndefined(&end[7])
@@ -283,30 +290,6 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) {
.JumpIfJSReceiver(&end[10]);
}
- // Perform an operation that returns boolean value to
- // generate JumpIfTrue/False
- {
- BytecodeLabel after_jump1, after_jump2;
- builder.CompareOperation(Token::Value::EQ, reg, 1)
- .JumpIfTrue(&after_jump1)
- .Bind(&after_jump1)
- .CompareOperation(Token::Value::EQ, reg, 2)
- .JumpIfFalse(&after_jump2)
- .Bind(&after_jump2);
- }
-
- // Perform an operation that returns a non-boolean operation to
- // generate JumpIfToBooleanTrue/False.
- {
- BytecodeLabel after_jump1, after_jump2;
- builder.BinaryOperation(Token::Value::ADD, reg, 1)
- .JumpIfTrue(&after_jump1)
- .Bind(&after_jump1)
- .BinaryOperation(Token::Value::ADD, reg, 2)
- .JumpIfFalse(&after_jump2)
- .Bind(&after_jump2);
- }
-
// Emit set pending message bytecode.
builder.SetPendingMessage();
@@ -439,12 +422,6 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) {
if (!FLAG_ignition_peephole) {
// Insert entries for bytecodes only emitted by peephole optimizer.
- scorecard[Bytecodes::ToByte(Bytecode::kLogicalNot)] = 1;
- scorecard[Bytecodes::ToByte(Bytecode::kJump)] = 1;
- scorecard[Bytecodes::ToByte(Bytecode::kJumpIfTrue)] = 1;
- scorecard[Bytecodes::ToByte(Bytecode::kJumpIfFalse)] = 1;
- scorecard[Bytecodes::ToByte(Bytecode::kJumpIfTrueConstant)] = 1;
- scorecard[Bytecodes::ToByte(Bytecode::kJumpIfFalseConstant)] = 1;
scorecard[Bytecodes::ToByte(Bytecode::kAddSmi)] = 1;
scorecard[Bytecodes::ToByte(Bytecode::kSubSmi)] = 1;
scorecard[Bytecodes::ToByte(Bytecode::kBitwiseAndSmi)] = 1;

Powered by Google App Engine
This is Rietveld 408576698