Index: src/interpreter/bytecode-array-builder.cc |
diff --git a/src/interpreter/bytecode-array-builder.cc b/src/interpreter/bytecode-array-builder.cc |
index 615580baadb7ad481604417087c7dbfd11ee953b..2834c3340cfb56a7941b2e1e3fe42b36b4eab54e 100644 |
--- a/src/interpreter/bytecode-array-builder.cc |
+++ b/src/interpreter/bytecode-array-builder.cc |
@@ -328,8 +328,13 @@ BytecodeArrayBuilder& BytecodeArrayBuilder::CountOperation(Token::Value op, |
return *this; |
} |
-BytecodeArrayBuilder& BytecodeArrayBuilder::LogicalNot() { |
- OutputToBooleanLogicalNot(); |
+BytecodeArrayBuilder& BytecodeArrayBuilder::LogicalNot(ToBooleanMode mode) { |
+ if (mode == ToBooleanMode::kAlreadyBoolean) { |
+ OutputLogicalNot(); |
+ } else { |
+ DCHECK_EQ(mode, ToBooleanMode::kConvertToBoolean); |
+ OutputToBooleanLogicalNot(); |
+ } |
return *this; |
} |
@@ -895,17 +900,27 @@ BytecodeArrayBuilder& BytecodeArrayBuilder::Jump(BytecodeLabel* label) { |
return *this; |
} |
-BytecodeArrayBuilder& BytecodeArrayBuilder::JumpIfTrue(BytecodeLabel* label) { |
- // The peephole optimizer attempts to simplify JumpIfToBooleanTrue |
- // to JumpIfTrue. |
+BytecodeArrayBuilder& BytecodeArrayBuilder::JumpIfTrue(ToBooleanMode mode, |
+ BytecodeLabel* label) { |
DCHECK(!label->is_bound()); |
- OutputJumpIfToBooleanTrue(label, 0); |
+ if (mode == ToBooleanMode::kAlreadyBoolean) { |
+ OutputJumpIfTrue(label, 0); |
+ } else { |
+ DCHECK_EQ(mode, ToBooleanMode::kConvertToBoolean); |
+ OutputJumpIfToBooleanTrue(label, 0); |
+ } |
return *this; |
} |
-BytecodeArrayBuilder& BytecodeArrayBuilder::JumpIfFalse(BytecodeLabel* label) { |
+BytecodeArrayBuilder& BytecodeArrayBuilder::JumpIfFalse(ToBooleanMode mode, |
+ BytecodeLabel* label) { |
DCHECK(!label->is_bound()); |
- OutputJumpIfToBooleanFalse(label, 0); |
+ if (mode == ToBooleanMode::kAlreadyBoolean) { |
+ OutputJumpIfFalse(label, 0); |
+ } else { |
+ DCHECK_EQ(mode, ToBooleanMode::kConvertToBoolean); |
+ OutputJumpIfToBooleanFalse(label, 0); |
+ } |
return *this; |
} |
@@ -941,7 +956,8 @@ BytecodeArrayBuilder& BytecodeArrayBuilder::JumpIfNil(BytecodeLabel* label, |
NilValue nil) { |
if (op == Token::EQ) { |
// TODO(rmcilroy): Implement JumpIfUndetectable. |
- return CompareUndetectable().JumpIfTrue(label); |
+ return CompareUndetectable().JumpIfTrue(ToBooleanMode::kAlreadyBoolean, |
+ label); |
} else { |
DCHECK_EQ(Token::EQ_STRICT, op); |
if (nil == kUndefinedValue) { |
@@ -958,7 +974,8 @@ BytecodeArrayBuilder& BytecodeArrayBuilder::JumpIfNotNil(BytecodeLabel* label, |
NilValue nil) { |
if (op == Token::EQ) { |
// TODO(rmcilroy): Implement JumpIfUndetectable. |
- return CompareUndetectable().JumpIfFalse(label); |
+ return CompareUndetectable().JumpIfFalse(ToBooleanMode::kAlreadyBoolean, |
+ label); |
} else { |
DCHECK_EQ(Token::EQ_STRICT, op); |
if (nil == kUndefinedValue) { |
@@ -1328,6 +1345,16 @@ uint32_t BytecodeArrayBuilder::GetOutputRegisterListOperand( |
return static_cast<uint32_t>(reg_list.first_register().ToOperand()); |
} |
+std::ostream& operator<<(std::ostream& os, |
+ const BytecodeArrayBuilder::ToBooleanMode& mode) { |
+ switch (mode) { |
+ case BytecodeArrayBuilder::ToBooleanMode::kAlreadyBoolean: |
+ return os << "AlreadyBoolean"; |
+ case BytecodeArrayBuilder::ToBooleanMode::kConvertToBoolean: |
+ return os << "ConvertToBoolean"; |
+ } |
+} |
+ |
} // namespace interpreter |
} // namespace internal |
} // namespace v8 |