修訂 | aaf4bfb70c769edb676dcf036259fcaaac86ea5f (tree) |
---|---|
時間 | 2017-07-03 16:35:33 |
作者 | Nicolas Geoffray <ngeoffray@goog...> |
Commiter | android-build-team Robot |
ARM64: Restore FP registers in read barrier thunk.
bug: 62612946
Test: 658-fp-read-barrier
Test: run-libcore-tests.sh
(cherry picked from commit 7015e76436ff9eb738c9c6070c8fff8e98b3852e)
Change-Id: Id0bc55c21829429cd17a77e4c503971249c107f5
(cherry picked from commit a77f3c91ad7bd46fff8e98f582eef216892219b9)
@@ -2611,19 +2611,19 @@ READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg29, w29, x29 | ||
2611 | 2611 | RESTORE_TWO_REGS x14, x15, 112 |
2612 | 2612 | RESTORE_TWO_REGS x18, x19, 128 // Skip x16, x17, i.e. IP0, IP1. |
2613 | 2613 | RESTORE_REG xLR, 144 // Restore return address. |
2614 | - // Save all potentially live caller-save floating-point registers. | |
2615 | - stp d0, d1, [sp, #160] | |
2616 | - stp d2, d3, [sp, #176] | |
2617 | - stp d4, d5, [sp, #192] | |
2618 | - stp d6, d7, [sp, #208] | |
2619 | - stp d16, d17, [sp, #224] | |
2620 | - stp d18, d19, [sp, #240] | |
2621 | - stp d20, d21, [sp, #256] | |
2622 | - stp d22, d23, [sp, #272] | |
2623 | - stp d24, d25, [sp, #288] | |
2624 | - stp d26, d27, [sp, #304] | |
2625 | - stp d28, d29, [sp, #320] | |
2626 | - stp d30, d31, [sp, #336] | |
2614 | + // Restore caller-save floating-point registers. | |
2615 | + ldp d0, d1, [sp, #160] | |
2616 | + ldp d2, d3, [sp, #176] | |
2617 | + ldp d4, d5, [sp, #192] | |
2618 | + ldp d6, d7, [sp, #208] | |
2619 | + ldp d16, d17, [sp, #224] | |
2620 | + ldp d18, d19, [sp, #240] | |
2621 | + ldp d20, d21, [sp, #256] | |
2622 | + ldp d22, d23, [sp, #272] | |
2623 | + ldp d24, d25, [sp, #288] | |
2624 | + ldp d26, d27, [sp, #304] | |
2625 | + ldp d28, d29, [sp, #320] | |
2626 | + ldp d30, d31, [sp, #336] | |
2627 | 2627 | |
2628 | 2628 | ldr x0, [lr, #\ldr_offset] // Load the instruction. |
2629 | 2629 | adr xIP1, .Lmark_introspection_return_switch |
@@ -0,0 +1,2 @@ | ||
1 | +Regression test for the read barrier implementation in ARM64, | |
2 | +which used to not restore floating point registers. |
@@ -0,0 +1,136 @@ | ||
1 | +/* | |
2 | + * Copyright (C) 2017 The Android Open Source Project | |
3 | + * | |
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | + * you may not use this file except in compliance with the License. | |
6 | + * You may obtain a copy of the License at | |
7 | + * | |
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | + * | |
10 | + * Unless required by applicable law or agreed to in writing, software | |
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | + * See the License for the specific language governing permissions and | |
14 | + * limitations under the License. | |
15 | + */ | |
16 | + | |
17 | +public class Main { | |
18 | + static volatile boolean done = false; | |
19 | + | |
20 | + public static void main(String[] args) { | |
21 | + // Run a thread for 30 seconds, allocating memory and triggering garbage | |
22 | + // collection. | |
23 | + // Time is limited to 30 seconds to not make this test too long. The test used | |
24 | + // to trigger the failure around 1 every 10 runs. | |
25 | + Thread t = new Thread() { | |
26 | + public void run() { | |
27 | + long time = System.currentTimeMillis(); | |
28 | + while (System.currentTimeMillis() - time < 30000) { | |
29 | + for (int j = 0; j < 10000; j++) { | |
30 | + o = new Object[1000]; | |
31 | + } | |
32 | + Runtime.getRuntime().gc(); | |
33 | + Thread.yield(); | |
34 | + } | |
35 | + Main.done = true; | |
36 | + } | |
37 | + Object o; | |
38 | + }; | |
39 | + // Make the thread a daemon to quit early in case of an | |
40 | + // exception throw below. | |
41 | + t.setDaemon(true); | |
42 | + t.start(); | |
43 | + | |
44 | + // Run 'foo' as long as the test runs. | |
45 | + while (!done) { | |
46 | + double res = foo(staticMain); | |
47 | + if (res != 529.0) { | |
48 | + throw new Error("Unexpected result " + res); | |
49 | + } | |
50 | + } | |
51 | + } | |
52 | + | |
53 | + public static double foo(Main main) { | |
54 | + // Use up all D registers on arm64. | |
55 | + double d1 = main.field1; | |
56 | + double d2 = main.field2; | |
57 | + double d3 = main.field3; | |
58 | + double d4 = main.field4; | |
59 | + double d5 = main.field5; | |
60 | + double d6 = main.field6; | |
61 | + double d7 = main.field7; | |
62 | + double d8 = main.field8; | |
63 | + double d9 = main.field9; | |
64 | + double d10 = main.field10; | |
65 | + double d11 = main.field11; | |
66 | + double d12 = main.field12; | |
67 | + double d13 = main.field13; | |
68 | + double d14 = main.field14; | |
69 | + double d15 = main.field15; | |
70 | + double d16 = main.field16; | |
71 | + double d17 = main.field17; | |
72 | + double d18 = main.field18; | |
73 | + double d19 = main.field19; | |
74 | + double d20 = main.field20; | |
75 | + double d21 = main.field21; | |
76 | + double d22 = main.field22; | |
77 | + double d23 = main.field23; | |
78 | + double d24 = main.field24; | |
79 | + double d25 = main.field25; | |
80 | + double d26 = main.field26; | |
81 | + double d27 = main.field27; | |
82 | + double d28 = main.field28; | |
83 | + double d29 = main.field29; | |
84 | + double d30 = main.field30; | |
85 | + double d31 = main.field31; | |
86 | + double d32 = main.field32; | |
87 | + | |
88 | + // Trigger a read barrier. This used to make the test trip on ARM64 as | |
89 | + // the read barrier stub used to not restore the D registers. | |
90 | + double p = main.objectField.field1; | |
91 | + | |
92 | + return p + d1 + d2 + d3 + d4 + d5 + d6 + d7 + d8 + d9 + d10 + d11 + d12 + d13 + d14 + d15 + d16 + d17 + d18 + d19 + d20 + d21 + d22 + d23 + d24 + d25 + d26 + d27 + d28 + d29 + d30 + d31 + d32; | |
93 | + } | |
94 | + | |
95 | + // Initialize objects here and not in 'main' to avoid having | |
96 | + // these objects in roots. | |
97 | + public static Main staticMain = new Main(); | |
98 | + static { | |
99 | + staticMain.objectField = new Main(); | |
100 | + } | |
101 | + | |
102 | + public Main objectField; | |
103 | + | |
104 | + public double field1 = 1.0; | |
105 | + public double field2 = 2.0; | |
106 | + public double field3 = 3.0; | |
107 | + public double field4 = 4.0; | |
108 | + public double field5 = 5.0; | |
109 | + public double field6 = 6.0; | |
110 | + public double field7 = 7.0; | |
111 | + public double field8 = 8.0; | |
112 | + public double field9 = 9.0; | |
113 | + public double field10 = 10.0; | |
114 | + public double field11 = 11.0; | |
115 | + public double field12 = 12.0; | |
116 | + public double field13 = 13.0; | |
117 | + public double field14 = 14.0; | |
118 | + public double field15 = 15.0; | |
119 | + public double field16 = 16.0; | |
120 | + public double field17 = 17.0; | |
121 | + public double field18 = 18.0; | |
122 | + public double field19 = 19.0; | |
123 | + public double field20 = 20.0; | |
124 | + public double field21 = 21.0; | |
125 | + public double field22 = 22.0; | |
126 | + public double field23 = 23.0; | |
127 | + public double field24 = 24.0; | |
128 | + public double field25 = 25.0; | |
129 | + public double field26 = 26.0; | |
130 | + public double field27 = 27.0; | |
131 | + public double field28 = 28.0; | |
132 | + public double field29 = 29.0; | |
133 | + public double field30 = 30.0; | |
134 | + public double field31 = 31.0; | |
135 | + public double field32 = 32.0; | |
136 | +} |