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

Side by Side Diff: runtime/vm/assembler_x64_test.cc

Issue 25118002: Eliminates more large immediates from x64 code. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 2 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 1274 matching lines...) Expand 10 before | Expand all | Expand 10 after
1285 static int LeafReturnArgument(int x) { 1285 static int LeafReturnArgument(int x) {
1286 return x + 87; 1286 return x + 87;
1287 } 1287 }
1288 1288
1289 1289
1290 ASSEMBLER_TEST_GENERATE(CallSimpleLeaf, assembler) { 1290 ASSEMBLER_TEST_GENERATE(CallSimpleLeaf, assembler) {
1291 ExternalLabel call1("LeafReturn42", reinterpret_cast<uword>(LeafReturn42)); 1291 ExternalLabel call1("LeafReturn42", reinterpret_cast<uword>(LeafReturn42));
1292 ExternalLabel call2("LeafReturnArgument", 1292 ExternalLabel call2("LeafReturnArgument",
1293 reinterpret_cast<uword>(LeafReturnArgument)); 1293 reinterpret_cast<uword>(LeafReturnArgument));
1294 int space = ComputeStackSpaceReservation(0, 8); 1294 int space = ComputeStackSpaceReservation(0, 8);
1295 __ AddImmediate(RSP, Immediate(-space)); 1295 __ subq(RSP, Immediate(space));
1296 __ call(&call1); 1296 __ call(&call1);
1297 __ AddImmediate(RSP, Immediate(space)); 1297 __ addq(RSP, Immediate(space));
1298 space = ComputeStackSpaceReservation(0, 8); 1298 space = ComputeStackSpaceReservation(0, 8);
1299 __ AddImmediate(RSP, Immediate(-space)); 1299 __ subq(RSP, Immediate(space));
1300 __ movl(RDI, RAX); 1300 __ movl(RDI, RAX);
1301 __ call(&call2); 1301 __ call(&call2);
1302 __ AddImmediate(RSP, Immediate(space)); 1302 __ addq(RSP, Immediate(space));
1303 __ ret(); 1303 __ ret();
1304 } 1304 }
1305 1305
1306 1306
1307 ASSEMBLER_TEST_RUN(CallSimpleLeaf, test) { 1307 ASSEMBLER_TEST_RUN(CallSimpleLeaf, test) {
1308 typedef int (*CallSimpleLeafCode)(); 1308 typedef int (*CallSimpleLeafCode)();
1309 EXPECT_EQ(42 + 87, reinterpret_cast<CallSimpleLeafCode>(test->entry())()); 1309 EXPECT_EQ(42 + 87, reinterpret_cast<CallSimpleLeafCode>(test->entry())());
1310 } 1310 }
1311 1311
1312 1312
1313 ASSEMBLER_TEST_GENERATE(JumpSimpleLeaf, assembler) { 1313 ASSEMBLER_TEST_GENERATE(JumpSimpleLeaf, assembler) {
1314 ExternalLabel call1("LeafReturn42", reinterpret_cast<uword>(LeafReturn42)); 1314 ExternalLabel call1("LeafReturn42", reinterpret_cast<uword>(LeafReturn42));
1315 Label L; 1315 Label L;
1316 int space = ComputeStackSpaceReservation(0, 8); 1316 int space = ComputeStackSpaceReservation(0, 8);
1317 __ AddImmediate(RSP, Immediate(-space)); 1317 __ subq(RSP, Immediate(space));
1318 __ call(&L); 1318 __ call(&L);
1319 __ AddImmediate(RSP, Immediate(space)); 1319 __ addq(RSP, Immediate(space));
1320 __ ret(); 1320 __ ret();
1321 __ Bind(&L); 1321 __ Bind(&L);
1322 __ jmp(&call1); 1322 __ jmp(&call1);
1323 } 1323 }
1324 1324
1325 1325
1326 ASSEMBLER_TEST_RUN(JumpSimpleLeaf, test) { 1326 ASSEMBLER_TEST_RUN(JumpSimpleLeaf, test) {
1327 typedef int (*JumpSimpleLeafCode)(); 1327 typedef int (*JumpSimpleLeafCode)();
1328 EXPECT_EQ(42, reinterpret_cast<JumpSimpleLeafCode>(test->entry())()); 1328 EXPECT_EQ(42, reinterpret_cast<JumpSimpleLeafCode>(test->entry())());
1329 } 1329 }
(...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after
2176 EXPECT_EQ(0, res); 2176 EXPECT_EQ(0, res);
2177 } 2177 }
2178 2178
2179 2179
2180 ASSEMBLER_TEST_GENERATE(TestObjectCompare, assembler) { 2180 ASSEMBLER_TEST_GENERATE(TestObjectCompare, assembler) {
2181 ObjectStore* object_store = Isolate::Current()->object_store(); 2181 ObjectStore* object_store = Isolate::Current()->object_store();
2182 const Object& obj = Object::ZoneHandle(object_store->smi_class()); 2182 const Object& obj = Object::ZoneHandle(object_store->smi_class());
2183 Label fail; 2183 Label fail;
2184 __ EnterDartFrame(0); 2184 __ EnterDartFrame(0);
2185 __ LoadObject(RAX, obj, PP); 2185 __ LoadObject(RAX, obj, PP);
2186 __ CompareObject(RAX, obj); 2186 __ CompareObject(RAX, obj, PP);
2187 __ j(NOT_EQUAL, &fail); 2187 __ j(NOT_EQUAL, &fail);
2188 __ LoadObject(RCX, obj, PP); 2188 __ LoadObject(RCX, obj, PP);
2189 __ CompareObject(RCX, obj); 2189 __ CompareObject(RCX, obj, PP);
2190 __ j(NOT_EQUAL, &fail); 2190 __ j(NOT_EQUAL, &fail);
2191 const Smi& smi = Smi::ZoneHandle(Smi::New(15)); 2191 const Smi& smi = Smi::ZoneHandle(Smi::New(15));
2192 __ LoadObject(RCX, smi, PP); 2192 __ LoadObject(RCX, smi, PP);
2193 __ CompareObject(RCX, smi); 2193 __ CompareObject(RCX, smi, PP);
2194 __ j(NOT_EQUAL, &fail); 2194 __ j(NOT_EQUAL, &fail);
2195 __ pushq(RAX); 2195 __ pushq(RAX);
2196 __ StoreObject(Address(RSP, 0), obj); 2196 __ StoreObject(Address(RSP, 0), obj, PP);
2197 __ popq(RCX); 2197 __ popq(RCX);
2198 __ CompareObject(RCX, obj); 2198 __ CompareObject(RCX, obj, PP);
2199 __ j(NOT_EQUAL, &fail); 2199 __ j(NOT_EQUAL, &fail);
2200 __ pushq(RAX); 2200 __ pushq(RAX);
2201 __ StoreObject(Address(RSP, 0), smi); 2201 __ StoreObject(Address(RSP, 0), smi, PP);
2202 __ popq(RCX); 2202 __ popq(RCX);
2203 __ CompareObject(RCX, smi); 2203 __ CompareObject(RCX, smi, PP);
2204 __ j(NOT_EQUAL, &fail); 2204 __ j(NOT_EQUAL, &fail);
2205 __ movl(RAX, Immediate(1)); // OK 2205 __ movl(RAX, Immediate(1)); // OK
2206 __ LeaveFrameWithPP(); 2206 __ LeaveFrameWithPP();
2207 __ ret(); 2207 __ ret();
2208 __ Bind(&fail); 2208 __ Bind(&fail);
2209 __ movl(RAX, Immediate(0)); // Fail. 2209 __ movl(RAX, Immediate(0)); // Fail.
2210 __ LeaveFrameWithPP(); 2210 __ LeaveFrameWithPP();
2211 __ ret(); 2211 __ ret();
2212 } 2212 }
2213 2213
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
2636 EXPECT_EQ(1, res); // Greater equal. 2636 EXPECT_EQ(1, res); // Greater equal.
2637 res = reinterpret_cast<ConditionalMovesCompareCode>(test->entry())(5, 5); 2637 res = reinterpret_cast<ConditionalMovesCompareCode>(test->entry())(5, 5);
2638 EXPECT_EQ(1, res); // Greater equal. 2638 EXPECT_EQ(1, res); // Greater equal.
2639 res = reinterpret_cast<ConditionalMovesCompareCode>(test->entry())(2, 5); 2639 res = reinterpret_cast<ConditionalMovesCompareCode>(test->entry())(2, 5);
2640 EXPECT_EQ(-1, res); // Less. 2640 EXPECT_EQ(-1, res); // Less.
2641 } 2641 }
2642 2642
2643 } // namespace dart 2643 } // namespace dart
2644 2644
2645 #endif // defined TARGET_ARCH_X64 2645 #endif // defined TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698