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

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

Issue 2481873005: clang-format runtime/vm (Closed)
Patch Set: Merge Created 4 years, 1 month 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
« no previous file with comments | « runtime/vm/assembler_mips.cc ('k') | runtime/vm/assembler_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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_MIPS) 6 #if defined(TARGET_ARCH_MIPS)
7 7
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/cpu.h" 9 #include "vm/cpu.h"
10 #include "vm/os.h" 10 #include "vm/os.h"
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 ASSEMBLER_TEST_GENERATE(LoadHalfWordUnaligned, assembler) { 323 ASSEMBLER_TEST_GENERATE(LoadHalfWordUnaligned, assembler) {
324 __ LoadHalfWordUnaligned(V0, A0, TMP); 324 __ LoadHalfWordUnaligned(V0, A0, TMP);
325 __ jr(RA); 325 __ jr(RA);
326 } 326 }
327 327
328 328
329 ASSEMBLER_TEST_RUN(LoadHalfWordUnaligned, test) { 329 ASSEMBLER_TEST_RUN(LoadHalfWordUnaligned, test) {
330 EXPECT(test != NULL); 330 EXPECT(test != NULL);
331 typedef intptr_t (*LoadHalfWordUnaligned)(intptr_t) DART_UNUSED; 331 typedef intptr_t (*LoadHalfWordUnaligned)(intptr_t) DART_UNUSED;
332 uint8_t buffer[4] = { 332 uint8_t buffer[4] = {
333 0x89, 0xAB, 0xCD, 0xEF, 333 0x89, 0xAB, 0xCD, 0xEF,
334 }; 334 };
335 335
336 EXPECT_EQ(static_cast<int16_t>(static_cast<uint16_t>(0xAB89)), 336 EXPECT_EQ(
337 EXECUTE_TEST_CODE_INTPTR_INTPTR( 337 static_cast<int16_t>(static_cast<uint16_t>(0xAB89)),
338 LoadHalfWordUnaligned, 338 EXECUTE_TEST_CODE_INTPTR_INTPTR(LoadHalfWordUnaligned, test->entry(),
339 test->entry(), 339 reinterpret_cast<intptr_t>(&buffer[0])));
340 reinterpret_cast<intptr_t>(&buffer[0]))); 340 EXPECT_EQ(
341 EXPECT_EQ(static_cast<int16_t>(static_cast<uint16_t>(0xCDAB)), 341 static_cast<int16_t>(static_cast<uint16_t>(0xCDAB)),
342 EXECUTE_TEST_CODE_INTPTR_INTPTR( 342 EXECUTE_TEST_CODE_INTPTR_INTPTR(LoadHalfWordUnaligned, test->entry(),
343 LoadHalfWordUnaligned, 343 reinterpret_cast<intptr_t>(&buffer[1])));
344 test->entry(),
345 reinterpret_cast<intptr_t>(&buffer[1])));
346 } 344 }
347 345
348 346
349 ASSEMBLER_TEST_GENERATE(LoadHalfWordUnsignedUnaligned, assembler) { 347 ASSEMBLER_TEST_GENERATE(LoadHalfWordUnsignedUnaligned, assembler) {
350 __ LoadHalfWordUnsignedUnaligned(V0, A0, TMP); 348 __ LoadHalfWordUnsignedUnaligned(V0, A0, TMP);
351 __ jr(RA); 349 __ jr(RA);
352 } 350 }
353 351
354 352
355 ASSEMBLER_TEST_RUN(LoadHalfWordUnsignedUnaligned, test) { 353 ASSEMBLER_TEST_RUN(LoadHalfWordUnsignedUnaligned, test) {
356 EXPECT(test != NULL); 354 EXPECT(test != NULL);
357 typedef intptr_t (*LoadHalfWordUnsignedUnaligned)(intptr_t) DART_UNUSED; 355 typedef intptr_t (*LoadHalfWordUnsignedUnaligned)(intptr_t) DART_UNUSED;
358 uint8_t buffer[4] = { 356 uint8_t buffer[4] = {
359 0x89, 0xAB, 0xCD, 0xEF, 357 0x89, 0xAB, 0xCD, 0xEF,
360 }; 358 };
361 359
362 EXPECT_EQ(0xAB89, 360 EXPECT_EQ(0xAB89, EXECUTE_TEST_CODE_INTPTR_INTPTR(
363 EXECUTE_TEST_CODE_INTPTR_INTPTR( 361 LoadHalfWordUnsignedUnaligned, test->entry(),
364 LoadHalfWordUnsignedUnaligned, 362 reinterpret_cast<intptr_t>(&buffer[0])));
365 test->entry(), 363 EXPECT_EQ(0xCDAB, EXECUTE_TEST_CODE_INTPTR_INTPTR(
366 reinterpret_cast<intptr_t>(&buffer[0]))); 364 LoadHalfWordUnsignedUnaligned, test->entry(),
367 EXPECT_EQ(0xCDAB, 365 reinterpret_cast<intptr_t>(&buffer[1])));
368 EXECUTE_TEST_CODE_INTPTR_INTPTR(
369 LoadHalfWordUnsignedUnaligned,
370 test->entry(),
371 reinterpret_cast<intptr_t>(&buffer[1])));
372 } 366 }
373 367
374 368
375 ASSEMBLER_TEST_GENERATE(StoreHalfWordUnaligned, assembler) { 369 ASSEMBLER_TEST_GENERATE(StoreHalfWordUnaligned, assembler) {
376 __ LoadImmediate(A1, 0xABCD); 370 __ LoadImmediate(A1, 0xABCD);
377 __ StoreWordUnaligned(A1, A0, TMP); 371 __ StoreWordUnaligned(A1, A0, TMP);
378 __ mov(V0, A1); 372 __ mov(V0, A1);
379 __ jr(RA); 373 __ jr(RA);
380 } 374 }
381 375
382 376
383 ASSEMBLER_TEST_RUN(StoreHalfWordUnaligned, test) { 377 ASSEMBLER_TEST_RUN(StoreHalfWordUnaligned, test) {
384 EXPECT(test != NULL); 378 EXPECT(test != NULL);
385 typedef intptr_t (*StoreHalfWordUnaligned)(intptr_t) DART_UNUSED; 379 typedef intptr_t (*StoreHalfWordUnaligned)(intptr_t) DART_UNUSED;
386 uint8_t buffer[4] = { 380 uint8_t buffer[4] = {
387 0, 0, 0, 0, 381 0, 0, 0, 0,
388 }; 382 };
389 383
390 EXPECT_EQ(0xABCD, 384 EXPECT_EQ(0xABCD, EXECUTE_TEST_CODE_INTPTR_INTPTR(
391 EXECUTE_TEST_CODE_INTPTR_INTPTR( 385 StoreHalfWordUnaligned, test->entry(),
392 StoreHalfWordUnaligned, 386 reinterpret_cast<intptr_t>(&buffer[0])));
393 test->entry(),
394 reinterpret_cast<intptr_t>(&buffer[0])));
395 EXPECT_EQ(0xCD, buffer[0]); 387 EXPECT_EQ(0xCD, buffer[0]);
396 EXPECT_EQ(0xAB, buffer[1]); 388 EXPECT_EQ(0xAB, buffer[1]);
397 EXPECT_EQ(0, buffer[2]); 389 EXPECT_EQ(0, buffer[2]);
398 390
399 EXPECT_EQ(0xABCD, 391 EXPECT_EQ(0xABCD, EXECUTE_TEST_CODE_INTPTR_INTPTR(
400 EXECUTE_TEST_CODE_INTPTR_INTPTR( 392 StoreHalfWordUnaligned, test->entry(),
401 StoreHalfWordUnaligned, 393 reinterpret_cast<intptr_t>(&buffer[1])));
402 test->entry(),
403 reinterpret_cast<intptr_t>(&buffer[1])));
404 EXPECT_EQ(0xCD, buffer[1]); 394 EXPECT_EQ(0xCD, buffer[1]);
405 EXPECT_EQ(0xAB, buffer[2]); 395 EXPECT_EQ(0xAB, buffer[2]);
406 EXPECT_EQ(0, buffer[3]); 396 EXPECT_EQ(0, buffer[3]);
407 } 397 }
408 398
409 399
410 ASSEMBLER_TEST_GENERATE(LoadWordUnaligned, assembler) { 400 ASSEMBLER_TEST_GENERATE(LoadWordUnaligned, assembler) {
411 __ LoadWordUnaligned(V0, A0, TMP); 401 __ LoadWordUnaligned(V0, A0, TMP);
412 __ jr(RA); 402 __ jr(RA);
413 } 403 }
414 404
415 405
416 ASSEMBLER_TEST_RUN(LoadWordUnaligned, test) { 406 ASSEMBLER_TEST_RUN(LoadWordUnaligned, test) {
417 EXPECT(test != NULL); 407 EXPECT(test != NULL);
418 typedef intptr_t (*LoadWordUnaligned)(intptr_t) DART_UNUSED; 408 typedef intptr_t (*LoadWordUnaligned)(intptr_t) DART_UNUSED;
419 uint8_t buffer[8] = { 409 uint8_t buffer[8] = {0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0};
420 0x12, 0x34, 0x56, 0x78,
421 0x9A, 0xBC, 0xDE, 0xF0
422 };
423 410
424 EXPECT_EQ(0x78563412, 411 EXPECT_EQ(0x78563412, EXECUTE_TEST_CODE_INTPTR_INTPTR(
425 EXECUTE_TEST_CODE_INTPTR_INTPTR( 412 LoadWordUnaligned, test->entry(),
426 LoadWordUnaligned, 413 reinterpret_cast<intptr_t>(&buffer[0])));
427 test->entry(), 414 EXPECT_EQ(0x9A785634, EXECUTE_TEST_CODE_INTPTR_INTPTR(
428 reinterpret_cast<intptr_t>(&buffer[0]))); 415 LoadWordUnaligned, test->entry(),
429 EXPECT_EQ(0x9A785634, 416 reinterpret_cast<intptr_t>(&buffer[1])));
430 EXECUTE_TEST_CODE_INTPTR_INTPTR( 417 EXPECT_EQ(0xBC9A7856, EXECUTE_TEST_CODE_INTPTR_INTPTR(
431 LoadWordUnaligned, 418 LoadWordUnaligned, test->entry(),
432 test->entry(), 419 reinterpret_cast<intptr_t>(&buffer[2])));
433 reinterpret_cast<intptr_t>(&buffer[1]))); 420 EXPECT_EQ(0xDEBC9A78, EXECUTE_TEST_CODE_INTPTR_INTPTR(
434 EXPECT_EQ(0xBC9A7856, 421 LoadWordUnaligned, test->entry(),
435 EXECUTE_TEST_CODE_INTPTR_INTPTR( 422 reinterpret_cast<intptr_t>(&buffer[3])));
436 LoadWordUnaligned,
437 test->entry(),
438 reinterpret_cast<intptr_t>(&buffer[2])));
439 EXPECT_EQ(0xDEBC9A78,
440 EXECUTE_TEST_CODE_INTPTR_INTPTR(
441 LoadWordUnaligned,
442 test->entry(),
443 reinterpret_cast<intptr_t>(&buffer[3])));
444 } 423 }
445 424
446 425
447 ASSEMBLER_TEST_GENERATE(StoreWordUnaligned, assembler) { 426 ASSEMBLER_TEST_GENERATE(StoreWordUnaligned, assembler) {
448 __ LoadImmediate(A1, 0x12345678); 427 __ LoadImmediate(A1, 0x12345678);
449 __ StoreWordUnaligned(A1, A0, TMP); 428 __ StoreWordUnaligned(A1, A0, TMP);
450 __ mov(V0, A1); 429 __ mov(V0, A1);
451 __ jr(RA); 430 __ jr(RA);
452 } 431 }
453 432
454 433
455 ASSEMBLER_TEST_RUN(StoreWordUnaligned, test) { 434 ASSEMBLER_TEST_RUN(StoreWordUnaligned, test) {
456 EXPECT(test != NULL); 435 EXPECT(test != NULL);
457 typedef intptr_t (*StoreWordUnaligned)(intptr_t) DART_UNUSED; 436 typedef intptr_t (*StoreWordUnaligned)(intptr_t) DART_UNUSED;
458 uint8_t buffer[8] = { 437 uint8_t buffer[8] = {0, 0, 0, 0, 0, 0, 0, 0};
459 0, 0, 0, 0,
460 0, 0, 0, 0
461 };
462 438
463 EXPECT_EQ(0x12345678, 439 EXPECT_EQ(0x12345678, EXECUTE_TEST_CODE_INTPTR_INTPTR(
464 EXECUTE_TEST_CODE_INTPTR_INTPTR( 440 StoreWordUnaligned, test->entry(),
465 StoreWordUnaligned, 441 reinterpret_cast<intptr_t>(&buffer[0])));
466 test->entry(),
467 reinterpret_cast<intptr_t>(&buffer[0])));
468 EXPECT_EQ(0x78, buffer[0]); 442 EXPECT_EQ(0x78, buffer[0]);
469 EXPECT_EQ(0x56, buffer[1]); 443 EXPECT_EQ(0x56, buffer[1]);
470 EXPECT_EQ(0x34, buffer[2]); 444 EXPECT_EQ(0x34, buffer[2]);
471 EXPECT_EQ(0x12, buffer[3]); 445 EXPECT_EQ(0x12, buffer[3]);
472 446
473 EXPECT_EQ(0x12345678, 447 EXPECT_EQ(0x12345678, EXECUTE_TEST_CODE_INTPTR_INTPTR(
474 EXECUTE_TEST_CODE_INTPTR_INTPTR( 448 StoreWordUnaligned, test->entry(),
475 StoreWordUnaligned, 449 reinterpret_cast<intptr_t>(&buffer[1])));
476 test->entry(),
477 reinterpret_cast<intptr_t>(&buffer[1])));
478 EXPECT_EQ(0x78, buffer[1]); 450 EXPECT_EQ(0x78, buffer[1]);
479 EXPECT_EQ(0x56, buffer[2]); 451 EXPECT_EQ(0x56, buffer[2]);
480 EXPECT_EQ(0x34, buffer[3]); 452 EXPECT_EQ(0x34, buffer[3]);
481 EXPECT_EQ(0x12, buffer[4]); 453 EXPECT_EQ(0x12, buffer[4]);
482 454
483 EXPECT_EQ(0x12345678, 455 EXPECT_EQ(0x12345678, EXECUTE_TEST_CODE_INTPTR_INTPTR(
484 EXECUTE_TEST_CODE_INTPTR_INTPTR( 456 StoreWordUnaligned, test->entry(),
485 StoreWordUnaligned, 457 reinterpret_cast<intptr_t>(&buffer[2])));
486 test->entry(),
487 reinterpret_cast<intptr_t>(&buffer[2])));
488 EXPECT_EQ(0x78, buffer[2]); 458 EXPECT_EQ(0x78, buffer[2]);
489 EXPECT_EQ(0x56, buffer[3]); 459 EXPECT_EQ(0x56, buffer[3]);
490 EXPECT_EQ(0x34, buffer[4]); 460 EXPECT_EQ(0x34, buffer[4]);
491 EXPECT_EQ(0x12, buffer[5]); 461 EXPECT_EQ(0x12, buffer[5]);
492 462
493 EXPECT_EQ(0x12345678, 463 EXPECT_EQ(0x12345678, EXECUTE_TEST_CODE_INTPTR_INTPTR(
494 EXECUTE_TEST_CODE_INTPTR_INTPTR( 464 StoreWordUnaligned, test->entry(),
495 StoreWordUnaligned, 465 reinterpret_cast<intptr_t>(&buffer[3])));
496 test->entry(),
497 reinterpret_cast<intptr_t>(&buffer[3])));
498 EXPECT_EQ(0x78, buffer[3]); 466 EXPECT_EQ(0x78, buffer[3]);
499 EXPECT_EQ(0x56, buffer[4]); 467 EXPECT_EQ(0x56, buffer[4]);
500 EXPECT_EQ(0x34, buffer[5]); 468 EXPECT_EQ(0x34, buffer[5]);
501 EXPECT_EQ(0x12, buffer[6]); 469 EXPECT_EQ(0x12, buffer[6]);
502 } 470 }
503 471
504 472
505 ASSEMBLER_TEST_GENERATE(Lui, assembler) { 473 ASSEMBLER_TEST_GENERATE(Lui, assembler) {
506 __ lui(V0, Immediate(42)); 474 __ lui(V0, Immediate(42));
507 __ jr(RA); 475 __ jr(RA);
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 779
812 ASSEMBLER_TEST_RUN(Sltu, test) { 780 ASSEMBLER_TEST_RUN(Sltu, test) {
813 typedef int (*SimpleCode)() DART_UNUSED; 781 typedef int (*SimpleCode)() DART_UNUSED;
814 EXPECT_EQ(0, EXECUTE_TEST_CODE_INT32(SimpleCode, test->entry())); 782 EXPECT_EQ(0, EXECUTE_TEST_CODE_INT32(SimpleCode, test->entry()));
815 } 783 }
816 784
817 785
818 ASSEMBLER_TEST_GENERATE(Slti, assembler) { 786 ASSEMBLER_TEST_GENERATE(Slti, assembler) {
819 __ LoadImmediate(T1, -2); 787 __ LoadImmediate(T1, -2);
820 __ slti(A0, T1, Immediate(-1)); // -2 < -1 -> 1. 788 __ slti(A0, T1, Immediate(-1)); // -2 < -1 -> 1.
821 __ slti(A1, T1, Immediate(0)); // -2 < 0 -> 1. 789 __ slti(A1, T1, Immediate(0)); // -2 < 0 -> 1.
822 __ and_(V0, A0, A1); 790 __ and_(V0, A0, A1);
823 __ jr(RA); 791 __ jr(RA);
824 } 792 }
825 793
826 794
827 ASSEMBLER_TEST_RUN(Slti, test) { 795 ASSEMBLER_TEST_RUN(Slti, test) {
828 typedef int (*SimpleCode)() DART_UNUSED; 796 typedef int (*SimpleCode)() DART_UNUSED;
829 EXPECT_EQ(1, EXECUTE_TEST_CODE_INT32(SimpleCode, test->entry())); 797 EXPECT_EQ(1, EXECUTE_TEST_CODE_INT32(SimpleCode, test->entry()));
830 } 798 }
831 799
832 800
833 ASSEMBLER_TEST_GENERATE(Sltiu, assembler) { 801 ASSEMBLER_TEST_GENERATE(Sltiu, assembler) {
834 __ LoadImmediate(T1, -1); 802 __ LoadImmediate(T1, -1);
835 __ LoadImmediate(T2, 0x10000); 803 __ LoadImmediate(T2, 0x10000);
836 __ sltiu(A0, T1, Immediate(-2)); // 0xffffffffUL < 0xfffffffeUL -> 0. 804 __ sltiu(A0, T1, Immediate(-2)); // 0xffffffffUL < 0xfffffffeUL -> 0.
837 __ sltiu(A1, T1, Immediate(0)); // 0xffffffffUL < 0 -> 0. 805 __ sltiu(A1, T1, Immediate(0)); // 0xffffffffUL < 0 -> 0.
838 __ sltiu(A2, T2, Immediate(-2)); // 0x10000UL < 0xfffffffeUL -> 1. 806 __ sltiu(A2, T2, Immediate(-2)); // 0x10000UL < 0xfffffffeUL -> 1.
839 __ addiu(A2, A2, Immediate(-1)); 807 __ addiu(A2, A2, Immediate(-1));
840 __ or_(V0, A0, A1); 808 __ or_(V0, A0, A1);
841 __ or_(V0, V0, A2); 809 __ or_(V0, V0, A2);
842 __ jr(RA); 810 __ jr(RA);
843 } 811 }
844 812
845 813
846 ASSEMBLER_TEST_RUN(Sltiu, test) { 814 ASSEMBLER_TEST_RUN(Sltiu, test) {
847 typedef int (*SimpleCode)() DART_UNUSED; 815 typedef int (*SimpleCode)() DART_UNUSED;
(...skipping 1369 matching lines...) Expand 10 before | Expand all | Expand 10 after
2217 2185
2218 2186
2219 ASSEMBLER_TEST_RUN(Cop1TruncWD_Inf, test) { 2187 ASSEMBLER_TEST_RUN(Cop1TruncWD_Inf, test) {
2220 typedef int (*SimpleCode)() DART_UNUSED; 2188 typedef int (*SimpleCode)() DART_UNUSED;
2221 EXPECT(test != NULL); 2189 EXPECT(test != NULL);
2222 EXPECT_EQ(kMaxInt32, EXECUTE_TEST_CODE_INT32(SimpleCode, test->entry())); 2190 EXPECT_EQ(kMaxInt32, EXECUTE_TEST_CODE_INT32(SimpleCode, test->entry()));
2223 } 2191 }
2224 2192
2225 2193
2226 ASSEMBLER_TEST_GENERATE(Cop1TruncWD_Overflow, assembler) { 2194 ASSEMBLER_TEST_GENERATE(Cop1TruncWD_Overflow, assembler) {
2227 __ LoadImmediate(D1, 2.0*kMaxInt32); 2195 __ LoadImmediate(D1, 2.0 * kMaxInt32);
2228 __ truncwd(F0, D1); 2196 __ truncwd(F0, D1);
2229 __ mfc1(V0, F0); 2197 __ mfc1(V0, F0);
2230 __ Ret(); 2198 __ Ret();
2231 } 2199 }
2232 2200
2233 2201
2234 ASSEMBLER_TEST_RUN(Cop1TruncWD_Overflow, test) { 2202 ASSEMBLER_TEST_RUN(Cop1TruncWD_Overflow, test) {
2235 typedef int (*SimpleCode)() DART_UNUSED; 2203 typedef int (*SimpleCode)() DART_UNUSED;
2236 EXPECT(test != NULL); 2204 EXPECT(test != NULL);
2237 EXPECT_EQ(kMaxInt32, EXECUTE_TEST_CODE_INT32(SimpleCode, test->entry())); 2205 EXPECT_EQ(kMaxInt32, EXECUTE_TEST_CODE_INT32(SimpleCode, test->entry()));
2238 } 2206 }
2239 2207
2240 2208
2241 ASSEMBLER_TEST_GENERATE(Cop1TruncWD_Underflow, assembler) { 2209 ASSEMBLER_TEST_GENERATE(Cop1TruncWD_Underflow, assembler) {
2242 __ LoadImmediate(D1, 2.0*kMinInt32); 2210 __ LoadImmediate(D1, 2.0 * kMinInt32);
2243 __ truncwd(F0, D1); 2211 __ truncwd(F0, D1);
2244 __ mfc1(V0, F0); 2212 __ mfc1(V0, F0);
2245 __ Ret(); 2213 __ Ret();
2246 } 2214 }
2247 2215
2248 2216
2249 ASSEMBLER_TEST_RUN(Cop1TruncWD_Underflow, test) { 2217 ASSEMBLER_TEST_RUN(Cop1TruncWD_Underflow, test) {
2250 typedef int (*SimpleCode)() DART_UNUSED; 2218 typedef int (*SimpleCode)() DART_UNUSED;
2251 EXPECT(test != NULL); 2219 EXPECT(test != NULL);
2252 EXPECT_EQ(kMaxInt32, EXECUTE_TEST_CODE_INT32(SimpleCode, test->entry())); 2220 EXPECT_EQ(kMaxInt32, EXECUTE_TEST_CODE_INT32(SimpleCode, test->entry()));
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
2305 // RA: return address. 2273 // RA: return address.
2306 // A0: value. 2274 // A0: value.
2307 // A1: growable array. 2275 // A1: growable array.
2308 // A2: current thread. 2276 // A2: current thread.
2309 ASSEMBLER_TEST_GENERATE(StoreIntoObject, assembler) { 2277 ASSEMBLER_TEST_GENERATE(StoreIntoObject, assembler) {
2310 __ addiu(SP, SP, Immediate(-3 * kWordSize)); 2278 __ addiu(SP, SP, Immediate(-3 * kWordSize));
2311 __ sw(CODE_REG, Address(SP, 2 * kWordSize)); 2279 __ sw(CODE_REG, Address(SP, 2 * kWordSize));
2312 __ sw(THR, Address(SP, 1 * kWordSize)); 2280 __ sw(THR, Address(SP, 1 * kWordSize));
2313 __ sw(RA, Address(SP, 0 * kWordSize)); 2281 __ sw(RA, Address(SP, 0 * kWordSize));
2314 __ mov(THR, A2); 2282 __ mov(THR, A2);
2315 __ StoreIntoObject(A1, 2283 __ StoreIntoObject(A1, FieldAddress(A1, GrowableObjectArray::data_offset()),
2316 FieldAddress(A1, GrowableObjectArray::data_offset()),
2317 A0); 2284 A0);
2318 __ lw(RA, Address(SP, 0 * kWordSize)); 2285 __ lw(RA, Address(SP, 0 * kWordSize));
2319 __ lw(THR, Address(SP, 1 * kWordSize)); 2286 __ lw(THR, Address(SP, 1 * kWordSize));
2320 __ lw(CODE_REG, Address(SP, 2 * kWordSize)); 2287 __ lw(CODE_REG, Address(SP, 2 * kWordSize));
2321 __ addiu(SP, SP, Immediate(3 * kWordSize)); 2288 __ addiu(SP, SP, Immediate(3 * kWordSize));
2322 __ Ret(); 2289 __ Ret();
2323 } 2290 }
2324 2291
2325 2292
2326 ASSEMBLER_TEST_GENERATE(Semaphore, assembler) { 2293 ASSEMBLER_TEST_GENERATE(Semaphore, assembler) {
2327 __ EnterFrame(); 2294 __ EnterFrame();
2328 __ LoadImmediate(T0, 40); 2295 __ LoadImmediate(T0, 40);
2329 __ LoadImmediate(T1, 42); 2296 __ LoadImmediate(T1, 42);
2330 __ Push(T0); 2297 __ Push(T0);
2331 Label retry; 2298 Label retry;
2332 __ Bind(&retry); 2299 __ Bind(&retry);
2333 __ ll(T0, Address(SP)); 2300 __ ll(T0, Address(SP));
2334 __ mov(T2, T1); 2301 __ mov(T2, T1);
2335 __ sc(T2, Address(SP)); // T1 == 1, success 2302 __ sc(T2, Address(SP)); // T1 == 1, success
2336 __ LoadImmediate(T3, 1); 2303 __ LoadImmediate(T3, 1);
2337 __ bne(T2, T3, &retry); // NE if context switch occurred between ll and sc 2304 __ bne(T2, T3, &retry); // NE if context switch occurred between ll and sc
2338 __ Pop(V0); // 42 2305 __ Pop(V0); // 42
2339 __ LeaveFrameAndReturn(); 2306 __ LeaveFrameAndReturn();
2340 } 2307 }
2341 2308
2342 2309
2343 ASSEMBLER_TEST_RUN(Semaphore, test) { 2310 ASSEMBLER_TEST_RUN(Semaphore, test) {
2344 EXPECT(test != NULL); 2311 EXPECT(test != NULL);
2345 typedef int (*Semaphore)() DART_UNUSED; 2312 typedef int (*Semaphore)() DART_UNUSED;
2346 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT32(Semaphore, test->entry())); 2313 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT32(Semaphore, test->entry()));
2347 } 2314 }
2348 2315
2349 2316
2350 } // namespace dart 2317 } // namespace dart
2351 2318
2352 #endif // defined TARGET_ARCH_MIPS 2319 #endif // defined TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « runtime/vm/assembler_mips.cc ('k') | runtime/vm/assembler_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698