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

Unified Diff: test/cctest/test-assembler-x87.cc

Issue 2119793002: X87: [ia32] Fixes a bug in cmpw. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « src/x87/disasm-x87.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-assembler-x87.cc
diff --git a/test/cctest/test-assembler-x87.cc b/test/cctest/test-assembler-x87.cc
index a831a0b2f1a8658f14c995029354eeb649ed70c5..2655e3447ddad7e7623e86cef2dba2146b85836e 100644
--- a/test/cctest/test-assembler-x87.cc
+++ b/test/cctest/test-assembler-x87.cc
@@ -407,4 +407,45 @@ TEST(AssemblerIa32JumpTables2) {
}
}
+TEST(Regress621926) {
+ // Bug description:
+ // The opcodes for cmpw r/m16, r16 and cmpw r16, r/m16 were swapped.
+ // This was causing non-commutative comparisons to produce the wrong result.
+ CcTest::InitializeVM();
+ Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate());
+ HandleScope scope(isolate);
+ Assembler assm(isolate, nullptr, 0);
+
+ int16_t a = 42;
+
+ Label fail;
+ __ push(ebx);
+ __ mov(ebx, Immediate(reinterpret_cast<intptr_t>(&a)));
+ __ mov(eax, Immediate(41));
+ __ cmpw(eax, Operand(ebx));
+ __ j(above_equal, &fail);
+ __ cmpw(Operand(ebx), eax);
+ __ j(below_equal, &fail);
+ __ mov(eax, 1);
+ __ pop(ebx);
+ __ ret(0);
+ __ bind(&fail);
+ __ mov(eax, 0);
+ __ pop(ebx);
+ __ ret(0);
+
+ CodeDesc desc;
+ assm.GetCode(&desc);
+ Handle<Code> code = isolate->factory()->NewCode(
+ desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
+
+#ifdef OBJECT_PRINT
+ OFStream os(stdout);
+ code->Print(os);
+#endif
+
+ F0 f = FUNCTION_CAST<F0>(code->entry());
+ CHECK_EQ(f(), 1);
+}
+
#undef __
« no previous file with comments | « src/x87/disasm-x87.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698