| 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 // The intrinsic code below is executed before a method has built its frame. | 5 // The intrinsic code below is executed before a method has built its frame. |
| 6 // The return address is on the stack and the arguments below it. | 6 // The return address is on the stack and the arguments below it. |
| 7 // Registers EDX (arguments descriptor) and ECX (function) must be preserved. | 7 // Registers EDX (arguments descriptor) and ECX (function) must be preserved. |
| 8 // Each intrinsification method returns true if the corresponding | 8 // Each intrinsification method returns true if the corresponding |
| 9 // Dart method was intrinsified. | 9 // Dart method was intrinsified. |
| 10 | 10 |
| (...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 __ Bind(&fall_through); | 579 __ Bind(&fall_through); |
| 580 return false; | 580 return false; |
| 581 } | 581 } |
| 582 | 582 |
| 583 | 583 |
| 584 bool Intrinsifier::Integer_mul(Assembler* assembler) { | 584 bool Intrinsifier::Integer_mul(Assembler* assembler) { |
| 585 return Integer_mulFromInteger(assembler); | 585 return Integer_mulFromInteger(assembler); |
| 586 } | 586 } |
| 587 | 587 |
| 588 | 588 |
| 589 // Simple implementation: for positive dividend values greater than divisor, | |
| 590 // return dividend. | |
| 591 bool Intrinsifier::Integer_modulo(Assembler* assembler) { | 589 bool Intrinsifier::Integer_modulo(Assembler* assembler) { |
| 592 Label fall_through, return_zero; | 590 Label fall_through, return_zero, try_modulo; |
| 593 TestBothArgumentsSmis(assembler, &fall_through); | 591 TestBothArgumentsSmis(assembler, &fall_through); |
| 594 // EAX: right argument (divisor) | 592 // EAX: right argument (divisor) |
| 595 // Check if modulo by zero -> exception thrown in main function. | 593 // Check if modulo by zero -> exception thrown in main function. |
| 596 __ cmpl(EAX, Immediate(0)); | 594 __ cmpl(EAX, Immediate(0)); |
| 597 __ j(EQUAL, &fall_through, Assembler::kNearJump); | 595 __ j(EQUAL, &fall_through, Assembler::kNearJump); |
| 598 __ movl(EBX, Address(ESP, + 2 * kWordSize)); // Left argument (dividend). | 596 __ movl(EBX, Address(ESP, + 2 * kWordSize)); // Left argument (dividend). |
| 599 __ cmpl(EBX, Immediate(0)); | 597 __ cmpl(EBX, Immediate(0)); |
| 600 __ j(LESS, &fall_through, Assembler::kNearJump); | 598 __ j(LESS, &fall_through, Assembler::kNearJump); |
| 601 __ cmpl(EBX, EAX); | 599 __ cmpl(EBX, EAX); |
| 602 __ j(EQUAL, &return_zero, Assembler::kNearJump); | 600 __ j(EQUAL, &return_zero, Assembler::kNearJump); |
| 603 __ j(GREATER, &fall_through, Assembler::kNearJump); | 601 __ j(GREATER, &try_modulo, Assembler::kNearJump); |
| 604 __ movl(EAX, EBX); // Return dividend. | 602 __ movl(EAX, EBX); // Return dividend as it is smaller than divisor. |
| 605 __ ret(); | 603 __ ret(); |
| 606 __ Bind(&return_zero); | 604 __ Bind(&return_zero); |
| 607 __ xorl(EAX, EAX); // Return zero. | 605 __ xorl(EAX, EAX); // Return zero. |
| 608 __ ret(); | 606 __ ret(); |
| 607 __ Bind(&try_modulo); |
| 608 // EAX: right (non-null divisor). |
| 609 __ movl(EBX, EAX); |
| 610 __ SmiUntag(EBX); |
| 611 __ movl(EAX, Address(ESP, + 2 * kWordSize)); // Left argument (dividend). |
| 612 __ SmiUntag(EAX); |
| 613 __ cdq(); |
| 614 __ idivl(EBX); |
| 615 __ movl(EAX, EDX); |
| 616 __ SmiTag(EAX); |
| 617 __ ret(); |
| 609 __ Bind(&fall_through); | 618 __ Bind(&fall_through); |
| 610 return false; | 619 return false; |
| 611 } | 620 } |
| 612 | 621 |
| 613 | 622 |
| 614 bool Intrinsifier::Integer_truncDivide(Assembler* assembler) { | 623 bool Intrinsifier::Integer_truncDivide(Assembler* assembler) { |
| 615 Label fall_through; | 624 Label fall_through; |
| 616 TestBothArgumentsSmis(assembler, &fall_through); | 625 TestBothArgumentsSmis(assembler, &fall_through); |
| 617 // EAX: right argument (divisor) | 626 // EAX: right argument (divisor) |
| 618 __ cmpl(EAX, Immediate(0)); | 627 __ cmpl(EAX, Immediate(0)); |
| (...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1355 __ Bind(&is_true); | 1364 __ Bind(&is_true); |
| 1356 __ LoadObject(EAX, bool_true); | 1365 __ LoadObject(EAX, bool_true); |
| 1357 __ ret(); | 1366 __ ret(); |
| 1358 return true; | 1367 return true; |
| 1359 } | 1368 } |
| 1360 | 1369 |
| 1361 #undef __ | 1370 #undef __ |
| 1362 } // namespace dart | 1371 } // namespace dart |
| 1363 | 1372 |
| 1364 #endif // defined TARGET_ARCH_IA32 | 1373 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |