Commit e06d57b0 authored by mythria's avatar mythria Committed by Commit bot

[Interpreter] Removes TestNotEqualsStrict bytecode from interpreter.

TestNotEqualsStrict is converted to a TestEqualsStrict and logical not
by the parser. Also, CompareIC does not have an implementation for
TestNotEqualsStrict. Hence, removing this bytecode.

BUG=v8:4280
LOG=N

Review URL: https://codereview.chromium.org/1768593002

Cr-Commit-Position: refs/heads/master@{#34527}
parent f53418b8
......@@ -1282,10 +1282,6 @@ void BytecodeGraphBuilder::VisitTestEqualStrict() {
BuildCompareOp(javascript()->StrictEqual());
}
void BytecodeGraphBuilder::VisitTestNotEqualStrict() {
BuildCompareOp(javascript()->StrictNotEqual());
}
void BytecodeGraphBuilder::VisitTestLessThan() {
BuildCompareOp(javascript()->LessThan());
}
......
......@@ -654,7 +654,6 @@ bool BytecodeArrayBuilder::NeedToBooleanCast() {
case Bytecode::kTestEqual:
case Bytecode::kTestNotEqual:
case Bytecode::kTestEqualStrict:
case Bytecode::kTestNotEqualStrict:
case Bytecode::kTestLessThan:
case Bytecode::kTestLessThanOrEqual:
case Bytecode::kTestGreaterThan:
......@@ -1420,8 +1419,6 @@ Bytecode BytecodeArrayBuilder::BytecodeForCompareOperation(Token::Value op) {
return Bytecode::kTestNotEqual;
case Token::Value::EQ_STRICT:
return Bytecode::kTestEqualStrict;
case Token::Value::NE_STRICT:
return Bytecode::kTestNotEqualStrict;
case Token::Value::LT:
return Bytecode::kTestLessThan;
case Token::Value::GT:
......
......@@ -199,7 +199,6 @@ namespace interpreter {
V(TestEqual, OperandType::kReg8) \
V(TestNotEqual, OperandType::kReg8) \
V(TestEqualStrict, OperandType::kReg8) \
V(TestNotEqualStrict, OperandType::kReg8) \
V(TestLessThan, OperandType::kReg8) \
V(TestGreaterThan, OperandType::kReg8) \
V(TestLessThanOrEqual, OperandType::kReg8) \
......
......@@ -1192,15 +1192,6 @@ void Interpreter::DoTestEqualStrict(InterpreterAssembler* assembler) {
}
// TestNotEqualStrict <src>
//
// Test if the value in the <src> register is not strictly equal to the
// accumulator.
void Interpreter::DoTestNotEqualStrict(InterpreterAssembler* assembler) {
DoBinaryOp(CodeFactory::StrictNotEqual(isolate_), assembler);
}
// TestLessThan <src>
//
// Test if the value in the <src> register is less than the accumulator.
......
......@@ -1179,12 +1179,10 @@ TEST(InterpreterConditionalJumps2) {
CHECK_EQ(Smi::cast(*return_value)->value(), 7);
}
static const Token::Value kComparisonTypes[] = {
Token::Value::EQ, Token::Value::NE, Token::Value::EQ_STRICT,
Token::Value::NE_STRICT, Token::Value::LT, Token::Value::LTE,
Token::Value::GT, Token::Value::GTE};
Token::Value::EQ, Token::Value::NE, Token::Value::EQ_STRICT,
Token::Value::LT, Token::Value::LTE, Token::Value::GT,
Token::Value::GTE};
template <typename T>
bool CompareC(Token::Value op, T lhs, T rhs, bool types_differed = false) {
......@@ -1379,6 +1377,76 @@ TEST(InterpreterMixedComparisons) {
}
}
TEST(InterpreterStrictNotEqual) {
HandleAndZoneScope handles;
i::Factory* factory = handles.main_isolate()->factory();
const char* code_snippet =
"function f(lhs, rhs) {\n"
" return lhs !== rhs;\n"
"}\n"
"f(0, 0);\n";
InterpreterTester tester(handles.main_isolate(), code_snippet);
auto callable = tester.GetCallable<Handle<Object>, Handle<Object>>();
// Test passing different types.
const char* inputs[] = {"-1.77", "-40.333", "0.01", "55.77e5", "2.01"};
i::UnicodeCache unicode_cache;
for (size_t i = 0; i < arraysize(inputs); i++) {
for (size_t j = 0; j < arraysize(inputs); j++) {
double lhs = StringToDouble(&unicode_cache, inputs[i],
i::ConversionFlags::NO_FLAGS);
double rhs = StringToDouble(&unicode_cache, inputs[j],
i::ConversionFlags::NO_FLAGS);
Handle<Object> lhs_obj = factory->NewNumber(lhs);
Handle<Object> rhs_obj = factory->NewStringFromAsciiChecked(inputs[j]);
Handle<Object> return_value =
callable(lhs_obj, rhs_obj).ToHandleChecked();
CHECK(return_value->IsBoolean());
CHECK_EQ(return_value->BooleanValue(),
CompareC(Token::Value::NE_STRICT, lhs, rhs, true));
}
}
// Test passing string types.
const char* inputs_str[] = {"A", "abc", "z", "", "Foo!", "Foo"};
for (size_t i = 0; i < arraysize(inputs_str); i++) {
for (size_t j = 0; j < arraysize(inputs_str); j++) {
Handle<Object> lhs_obj =
factory->NewStringFromAsciiChecked(inputs_str[i]);
Handle<Object> rhs_obj =
factory->NewStringFromAsciiChecked(inputs_str[j]);
Handle<Object> return_value =
callable(lhs_obj, rhs_obj).ToHandleChecked();
CHECK(return_value->IsBoolean());
CHECK_EQ(return_value->BooleanValue(),
CompareC(Token::Value::NE_STRICT, inputs_str[i], inputs_str[j]));
}
}
// Test passing doubles.
double inputs_number[] = {std::numeric_limits<double>::min(),
std::numeric_limits<double>::max(),
-0.001,
0.01,
0.1000001,
1e99,
-1e-99};
for (size_t i = 0; i < arraysize(inputs_number); i++) {
for (size_t j = 0; j < arraysize(inputs_number); j++) {
Handle<Object> lhs_obj = factory->NewNumber(inputs_number[i]);
Handle<Object> rhs_obj = factory->NewNumber(inputs_number[j]);
Handle<Object> return_value =
callable(lhs_obj, rhs_obj).ToHandleChecked();
CHECK(return_value->IsBoolean());
CHECK_EQ(return_value->BooleanValue(),
CompareC(Token::Value::NE_STRICT, inputs_number[i],
inputs_number[j]));
}
}
}
TEST(InterpreterInstanceOf) {
HandleAndZoneScope handles;
......
......@@ -139,7 +139,6 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) {
builder.CompareOperation(Token::Value::EQ, reg)
.CompareOperation(Token::Value::NE, reg)
.CompareOperation(Token::Value::EQ_STRICT, reg)
.CompareOperation(Token::Value::NE_STRICT, reg)
.CompareOperation(Token::Value::LT, reg)
.CompareOperation(Token::Value::GT, reg)
.CompareOperation(Token::Value::LTE, reg)
......
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