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

Side by Side Diff: test/cctest/test-assembler-arm.cc

Issue 102623003: [v8-dev] ARM: Optimize truncating division and fix sim (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years 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
« no previous file with comments | « src/arm/simulator-arm.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1421 matching lines...) Expand 10 before | Expand all | Expand 10 after
1432 __ nop(); 1432 __ nop();
1433 } 1433 }
1434 1434
1435 Label target; 1435 Label target;
1436 __ b(eq, &target); 1436 __ b(eq, &target);
1437 __ bind(&target); 1437 __ bind(&target);
1438 __ nop(); 1438 __ nop();
1439 } 1439 }
1440 1440
1441 1441
1442 #define TEST_SDIV(expected_, dividend_, divisor_) \
1443 t.dividend = dividend_; \
1444 t.divisor = divisor_; \
1445 t.result = 0; \
1446 dummy = CALL_GENERATED_CODE(f, &t, 0, 0, 0, 0); \
1447 CHECK_EQ(expected_, t.result);
1448
1449
1450 TEST(18) {
1451 // Test the sdiv.
1452 CcTest::InitializeVM();
1453 Isolate* isolate = CcTest::i_isolate();
1454 HandleScope scope(isolate);
1455
1456 typedef struct {
1457 uint32_t dividend;
1458 uint32_t divisor;
1459 uint32_t result;
1460 } T;
1461 T t;
1462
1463 Assembler assm(isolate, NULL, 0);
1464
1465 if (CpuFeatures::IsSupported(SUDIV)) {
1466 CpuFeatureScope scope(&assm, SUDIV);
1467
1468 __ mov(r3, Operand(r0));
1469
1470 __ ldr(r0, MemOperand(r3, OFFSET_OF(T, dividend)));
1471 __ ldr(r1, MemOperand(r3, OFFSET_OF(T, divisor)));
1472
1473 __ sdiv(r2, r0, r1);
1474 __ str(r2, MemOperand(r3, OFFSET_OF(T, result)));
1475
1476 __ bx(lr);
1477
1478 CodeDesc desc;
1479 assm.GetCode(&desc);
1480 Object* code = isolate->heap()->CreateCode(
1481 desc,
1482 Code::ComputeFlags(Code::STUB),
1483 Handle<Code>())->ToObjectChecked();
1484 CHECK(code->IsCode());
1485 #ifdef DEBUG
1486 Code::cast(code)->Print();
ulan 2013/12/11 13:57:10 Is this leftover from debug?
vincent.belliard.fr 2013/12/11 14:20:29 This is done in almost all the arm assembler tests
ulan 2013/12/11 14:40:07 OK, thanks.
1487 #endif
1488 F3 f = FUNCTION_CAST<F3>(Code::cast(code)->entry());
1489 Object* dummy;
1490 TEST_SDIV(1073741824, kMinInt, -2);
1491 TEST_SDIV(kMinInt, kMinInt, -1);
1492 TEST_SDIV(5, 10, 2);
1493 TEST_SDIV(3, 10, 3);
1494 TEST_SDIV(-5, 10, -2);
1495 TEST_SDIV(-3, 10, -3);
1496 TEST_SDIV(-5, -10, 2);
1497 TEST_SDIV(-3, -10, 3);
1498 TEST_SDIV(5, -10, -2);
1499 TEST_SDIV(3, -10, -3);
1500 USE(dummy);
1501 }
1502 }
1503
1504
1505 #undef TEST_SDIV
1506
1507
1442 TEST(code_relative_offset) { 1508 TEST(code_relative_offset) {
1443 // Test extracting the offset of a label from the beginning of the code 1509 // Test extracting the offset of a label from the beginning of the code
1444 // in a register. 1510 // in a register.
1445 CcTest::InitializeVM(); 1511 CcTest::InitializeVM();
1446 Isolate* isolate = CcTest::i_isolate(); 1512 Isolate* isolate = CcTest::i_isolate();
1447 HandleScope scope(isolate); 1513 HandleScope scope(isolate);
1448 // Initialize a code object that will contain the code. 1514 // Initialize a code object that will contain the code.
1449 Handle<Object> code_object(isolate->heap()->undefined_value(), isolate); 1515 Handle<Object> code_object(isolate->heap()->undefined_value(), isolate);
1450 1516
1451 Assembler assm(isolate, NULL, 0); 1517 Assembler assm(isolate, NULL, 0);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1504 Handle<Code> code = isolate->factory()->NewCode(desc, 1570 Handle<Code> code = isolate->factory()->NewCode(desc,
1505 Code::ComputeFlags(Code::STUB), code_object); 1571 Code::ComputeFlags(Code::STUB), code_object);
1506 CHECK(code->IsCode()); 1572 CHECK(code->IsCode());
1507 F1 f = FUNCTION_CAST<F1>(code->entry()); 1573 F1 f = FUNCTION_CAST<F1>(code->entry());
1508 int res = reinterpret_cast<int>(CALL_GENERATED_CODE(f, 21, 0, 0, 0, 0)); 1574 int res = reinterpret_cast<int>(CALL_GENERATED_CODE(f, 21, 0, 0, 0, 0));
1509 ::printf("f() = %d\n", res); 1575 ::printf("f() = %d\n", res);
1510 CHECK_EQ(42, res); 1576 CHECK_EQ(42, res);
1511 } 1577 }
1512 1578
1513 #undef __ 1579 #undef __
OLDNEW
« no previous file with comments | « src/arm/simulator-arm.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698