OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/globals.h" | 5 #include "vm/globals.h" |
6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
7 | 7 |
8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
9 #include "vm/os.h" | 9 #include "vm/os.h" |
10 #include "vm/unit_test.h" | 10 #include "vm/unit_test.h" |
(...skipping 3095 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3106 } | 3106 } |
3107 | 3107 |
3108 | 3108 |
3109 ASSEMBLER_TEST_RUN(TestObjectCompare, test) { | 3109 ASSEMBLER_TEST_RUN(TestObjectCompare, test) { |
3110 bool res = test->InvokeWithCodeAndThread<bool>(); | 3110 bool res = test->InvokeWithCodeAndThread<bool>(); |
3111 EXPECT_EQ(true, res); | 3111 EXPECT_EQ(true, res); |
3112 } | 3112 } |
3113 | 3113 |
3114 | 3114 |
3115 ASSEMBLER_TEST_GENERATE(TestNop, assembler) { | 3115 ASSEMBLER_TEST_GENERATE(TestNop, assembler) { |
| 3116 __ RawEntry(); |
| 3117 |
3116 __ nop(1); | 3118 __ nop(1); |
3117 __ nop(2); | 3119 __ nop(2); |
3118 __ nop(3); | 3120 __ nop(3); |
3119 __ nop(4); | 3121 __ nop(4); |
3120 __ nop(5); | 3122 __ nop(5); |
3121 __ nop(6); | 3123 __ nop(6); |
3122 __ nop(7); | 3124 __ nop(7); |
3123 __ nop(8); | 3125 __ nop(8); |
3124 __ movq(RAX, Immediate(assembler->CodeSize())); // Return code size. | 3126 __ movq(RAX, Immediate(assembler->CodeSize())); // Return code size. |
3125 __ ret(); | 3127 __ ret(); |
3126 } | 3128 } |
3127 | 3129 |
3128 | 3130 |
3129 ASSEMBLER_TEST_RUN(TestNop, test) { | 3131 ASSEMBLER_TEST_RUN(TestNop, test) { |
3130 typedef int (*TestNop)(); | 3132 typedef int (*TestNop)(); |
3131 int res = reinterpret_cast<TestNop>(test->entry())(); | 3133 int res = reinterpret_cast<TestNop>(test->payload_start())(); |
3132 EXPECT_EQ(36, res); // 36 nop bytes emitted. | 3134 EXPECT_EQ(36, res); // 36 nop bytes emitted. |
3133 } | 3135 } |
3134 | 3136 |
3135 | 3137 |
3136 ASSEMBLER_TEST_GENERATE(TestAlign0, assembler) { | 3138 ASSEMBLER_TEST_GENERATE(TestAlign0, assembler) { |
| 3139 __ RawEntry(); |
| 3140 |
3137 __ Align(4, 0); | 3141 __ Align(4, 0); |
3138 __ movq(RAX, Immediate(assembler->CodeSize())); // Return code size. | 3142 __ movq(RAX, Immediate(assembler->CodeSize())); // Return code size. |
3139 __ ret(); | 3143 __ ret(); |
3140 } | 3144 } |
3141 | 3145 |
3142 | 3146 |
3143 ASSEMBLER_TEST_RUN(TestAlign0, test) { | 3147 ASSEMBLER_TEST_RUN(TestAlign0, test) { |
3144 typedef int (*TestAlign0)(); | 3148 typedef int (*TestAlign0)(); |
3145 int res = reinterpret_cast<TestAlign0>(test->entry())(); | 3149 int res = reinterpret_cast<TestAlign0>(test->payload_start())(); |
3146 EXPECT_EQ(0, res); // 0 bytes emitted. | 3150 EXPECT_EQ(0, res); // 0 bytes emitted. |
3147 } | 3151 } |
3148 | 3152 |
3149 | 3153 |
3150 ASSEMBLER_TEST_GENERATE(TestAlign1, assembler) { | 3154 ASSEMBLER_TEST_GENERATE(TestAlign1, assembler) { |
| 3155 __ RawEntry(); |
| 3156 |
3151 __ nop(1); | 3157 __ nop(1); |
3152 __ Align(4, 0); | 3158 __ Align(4, 0); |
3153 __ movq(RAX, Immediate(assembler->CodeSize())); // Return code size. | 3159 __ movq(RAX, Immediate(assembler->CodeSize())); // Return code size. |
3154 __ ret(); | 3160 __ ret(); |
3155 } | 3161 } |
3156 | 3162 |
3157 | 3163 |
3158 ASSEMBLER_TEST_RUN(TestAlign1, test) { | 3164 ASSEMBLER_TEST_RUN(TestAlign1, test) { |
3159 typedef int (*TestAlign1)(); | 3165 typedef int (*TestAlign1)(); |
3160 int res = reinterpret_cast<TestAlign1>(test->entry())(); | 3166 int res = reinterpret_cast<TestAlign1>(test->payload_start())(); |
3161 EXPECT_EQ(4, res); // 4 bytes emitted. | 3167 EXPECT_EQ(4, res); // 4 bytes emitted. |
3162 } | 3168 } |
3163 | 3169 |
3164 | 3170 |
3165 ASSEMBLER_TEST_GENERATE(TestAlign1Offset1, assembler) { | 3171 ASSEMBLER_TEST_GENERATE(TestAlign1Offset1, assembler) { |
| 3172 __ RawEntry(); |
| 3173 |
3166 __ nop(1); | 3174 __ nop(1); |
3167 __ Align(4, 1); | 3175 __ Align(4, 1); |
3168 __ movq(RAX, Immediate(assembler->CodeSize())); // Return code size. | 3176 __ movq(RAX, Immediate(assembler->CodeSize())); // Return code size. |
3169 __ ret(); | 3177 __ ret(); |
3170 } | 3178 } |
3171 | 3179 |
3172 | 3180 |
3173 ASSEMBLER_TEST_RUN(TestAlign1Offset1, test) { | 3181 ASSEMBLER_TEST_RUN(TestAlign1Offset1, test) { |
3174 typedef int (*TestAlign1Offset1)(); | 3182 typedef int (*TestAlign1Offset1)(); |
3175 int res = reinterpret_cast<TestAlign1Offset1>(test->entry())(); | 3183 int res = reinterpret_cast<TestAlign1Offset1>(test->payload_start())(); |
3176 EXPECT_EQ(3, res); // 3 bytes emitted. | 3184 EXPECT_EQ(3, res); // 3 bytes emitted. |
3177 } | 3185 } |
3178 | 3186 |
3179 | 3187 |
3180 ASSEMBLER_TEST_GENERATE(TestAlignLarge, assembler) { | 3188 ASSEMBLER_TEST_GENERATE(TestAlignLarge, assembler) { |
| 3189 __ RawEntry(); |
| 3190 |
3181 __ nop(1); | 3191 __ nop(1); |
3182 __ Align(16, 0); | 3192 __ Align(16, 0); |
3183 __ movq(RAX, Immediate(assembler->CodeSize())); // Return code size. | 3193 __ movq(RAX, Immediate(assembler->CodeSize())); // Return code size. |
3184 __ ret(); | 3194 __ ret(); |
3185 } | 3195 } |
3186 | 3196 |
3187 | 3197 |
3188 ASSEMBLER_TEST_RUN(TestAlignLarge, test) { | 3198 ASSEMBLER_TEST_RUN(TestAlignLarge, test) { |
3189 typedef int (*TestAlignLarge)(); | 3199 typedef int (*TestAlignLarge)(); |
3190 int res = reinterpret_cast<TestAlignLarge>(test->entry())(); | 3200 int res = reinterpret_cast<TestAlignLarge>(test->payload_start())(); |
3191 EXPECT_EQ(16, res); // 16 bytes emitted. | 3201 EXPECT_EQ(16, res); // 16 bytes emitted. |
3192 } | 3202 } |
3193 | 3203 |
3194 | 3204 |
3195 ASSEMBLER_TEST_GENERATE(TestAdds, assembler) { | 3205 ASSEMBLER_TEST_GENERATE(TestAdds, assembler) { |
3196 __ movq(RAX, Immediate(4)); | 3206 __ movq(RAX, Immediate(4)); |
3197 __ pushq(RAX); | 3207 __ pushq(RAX); |
3198 __ addq(Address(RSP, 0), Immediate(5)); | 3208 __ addq(Address(RSP, 0), Immediate(5)); |
3199 // TOS: 9 | 3209 // TOS: 9 |
3200 __ addq(Address(RSP, 0), Immediate(-2)); | 3210 __ addq(Address(RSP, 0), Immediate(-2)); |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3585 int res = reinterpret_cast<ConditionalMovesNoOverflowCode>( | 3595 int res = reinterpret_cast<ConditionalMovesNoOverflowCode>( |
3586 test->entry())(0x7fffffffffffffff, 2); | 3596 test->entry())(0x7fffffffffffffff, 2); |
3587 EXPECT_EQ(1, res); | 3597 EXPECT_EQ(1, res); |
3588 res = reinterpret_cast<ConditionalMovesNoOverflowCode>(test->entry())(1, 1); | 3598 res = reinterpret_cast<ConditionalMovesNoOverflowCode>(test->entry())(1, 1); |
3589 EXPECT_EQ(0, res); | 3599 EXPECT_EQ(0, res); |
3590 } | 3600 } |
3591 | 3601 |
3592 } // namespace dart | 3602 } // namespace dart |
3593 | 3603 |
3594 #endif // defined TARGET_ARCH_X64 | 3604 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |