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

Unified Diff: runtime/vm/assembler_arm64_test.cc

Issue 2965723002: VM: Reland Inline instance object hash code into object header on 64bit. (Closed)
Patch Set: Fix snapshot incompatibility that sank Flutter Gallery Created 3 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
Index: runtime/vm/assembler_arm64_test.cc
diff --git a/runtime/vm/assembler_arm64_test.cc b/runtime/vm/assembler_arm64_test.cc
index 566a9a323ae669fb12df34e2814cc79462fd1359..624a950e717bddb4bfab28bd343bdac7f041024c 100644
--- a/runtime/vm/assembler_arm64_test.cc
+++ b/runtime/vm/assembler_arm64_test.cc
@@ -580,7 +580,7 @@ ASSEMBLER_TEST_GENERATE(Semaphore, assembler) {
ASSEMBLER_TEST_RUN(Semaphore, test) {
EXPECT(test != NULL);
- typedef int (*Semaphore)() DART_UNUSED;
+ typedef intptr_t (*Semaphore)() DART_UNUSED;
EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(Semaphore, test->entry()));
}
@@ -602,11 +602,73 @@ ASSEMBLER_TEST_GENERATE(FailedSemaphore, assembler) {
ASSEMBLER_TEST_RUN(FailedSemaphore, test) {
EXPECT(test != NULL);
- typedef int (*FailedSemaphore)() DART_UNUSED;
+ typedef intptr_t (*FailedSemaphore)() DART_UNUSED;
EXPECT_EQ(41, EXECUTE_TEST_CODE_INT64(FailedSemaphore, test->entry()));
}
+ASSEMBLER_TEST_GENERATE(Semaphore32, assembler) {
+ __ SetupDartSP();
+ __ movz(R0, Immediate(40), 0);
+ __ add(R0, R0, Operand(R0, LSL, 32));
+ __ Push(R0);
+
+ __ movz(R0, Immediate(40), 0);
+ __ movz(R1, Immediate(42), 0);
+
+ Label retry;
+ __ Bind(&retry);
+ __ ldxr(R0, SP, kWord);
+ // 32 bit operation should ignore the high word of R0 that was pushed on the
+ // stack.
+ __ stxr(TMP, R1, SP, kWord); // IP == 0, success
+ __ cmp(TMP, Operand(0));
+ __ b(&retry, NE); // NE if context switch occurred between ldrex and strex.
+ __ Pop(R0); // 42 + 42 * 2**32
+ __ RestoreCSP();
+ __ ret();
+}
+
+
+ASSEMBLER_TEST_RUN(Semaphore32, test) {
+ EXPECT(test != NULL);
+ typedef intptr_t (*Semaphore32)() DART_UNUSED;
+ // Lower word has been atomically switched from 40 to 42k, whereas upper word
+ // is unchanged at 40.
+ EXPECT_EQ(42 + (40l << 32),
+ EXECUTE_TEST_CODE_INT64(Semaphore32, test->entry()));
+}
+
+
+ASSEMBLER_TEST_GENERATE(FailedSemaphore32, assembler) {
+ __ SetupDartSP();
+ __ movz(R0, Immediate(40), 0);
+ __ add(R0, R0, Operand(R0, LSL, 32));
+ __ Push(R0);
+
+ __ movz(R0, Immediate(40), 0);
+ __ movz(R1, Immediate(42), 0);
+
+ __ ldxr(R0, SP, kWord);
+ __ clrex(); // Simulate a context switch.
+ __ stxr(TMP, R1, SP, kWord); // IP == 1, failure
+ __ Pop(R0); // 40
+ __ add(R0, R0, Operand(TMP));
+ __ RestoreCSP();
+ __ ret();
+}
+
+
+ASSEMBLER_TEST_RUN(FailedSemaphore32, test) {
+ EXPECT(test != NULL);
+ typedef intptr_t (*FailedSemaphore32)() DART_UNUSED;
+ // Lower word has had the failure code (1) added to it. Upper word is
+ // unchanged at 40.
+ EXPECT_EQ(41 + (40l << 32),
+ EXECUTE_TEST_CODE_INT64(FailedSemaphore32, test->entry()));
+}
+
+
// Logical register operations.
ASSEMBLER_TEST_GENERATE(AndRegs, assembler) {
__ movz(R1, Immediate(43), 0);

Powered by Google App Engine
This is Rietveld 408576698