Chromium Code Reviews| 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 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 513 EBX, | 513 EBX, |
| 514 TIMES_1, | 514 TIMES_1, |
| 515 Int8Array::data_offset())); | 515 Int8Array::data_offset())); |
| 516 __ SmiTag(EAX); | 516 __ SmiTag(EAX); |
| 517 __ ret(); | 517 __ ret(); |
| 518 __ Bind(&fall_through); | 518 __ Bind(&fall_through); |
| 519 return false; | 519 return false; |
| 520 } | 520 } |
| 521 | 521 |
| 522 | 522 |
| 523 bool Intrinsifier::Int8Array_setIndexed(Assembler* assembler) { | |
| 524 Label fall_through; | |
| 525 // Verify that the array index is valid. | |
| 526 TestByteArraySetIndex(assembler, &fall_through); | |
| 527 // After TestByteArraySetIndex: | |
| 528 // * EAX has the base address of the byte array. | |
| 529 // * EBX has the index into the array. | |
| 530 // EBX contains the SMI index which is shifted by 1. | |
| 531 __ SmiUntag(EBX); | |
| 532 // Move EBX into EDI. | |
| 533 __ movl(EDI, EBX); | |
| 534 // Load the value into EBX. | |
| 535 __ movl(EBX, Address(ESP, + 1 * kWordSize)); // Value. | |
| 536 // If EBX is not an Smi, jump to fall through. | |
| 537 __ testl(EBX, Immediate(kSmiTagMask)); | |
| 538 __ j(NOT_ZERO, &fall_through, Assembler::kNearJump); | |
| 539 __ SmiUntag(EBX); | |
| 540 // Add 128 to EBX to bring it into 0..FF. | |
| 541 __ addl(EBX, Immediate(128)); | |
|
cshapiro
2012/10/12 23:05:21
It would be great if we could put these magic numb
| |
| 542 __ cmpl(EBX, Immediate(0xFF)); | |
| 543 // If EBX is too large an Int8, jump to fall through. | |
| 544 __ j(ABOVE, &fall_through, Assembler::kNearJump); | |
| 545 // Remove addition. | |
| 546 __ subl(EBX, Immediate(128)); | |
| 547 // Store BL into array EAX[EDI] = BL. | |
| 548 __ movb(FieldAddress(EAX, EDI, TIMES_1, Int8Array::data_offset()), BL); | |
| 549 __ ret(); | |
| 550 __ Bind(&fall_through); | |
| 551 return false; | |
| 552 } | |
| 553 | |
| 554 | |
| 523 bool Intrinsifier::Uint8Array_getIndexed(Assembler* assembler) { | 555 bool Intrinsifier::Uint8Array_getIndexed(Assembler* assembler) { |
| 524 Label fall_through; | 556 Label fall_through; |
| 525 TestByteArrayIndex(assembler, &fall_through); | 557 TestByteArrayIndex(assembler, &fall_through); |
| 526 __ SmiUntag(EBX); | 558 __ SmiUntag(EBX); |
| 527 __ movzxb(EAX, FieldAddress(EAX, | 559 __ movzxb(EAX, FieldAddress(EAX, |
| 528 EBX, | 560 EBX, |
| 529 TIMES_1, | 561 TIMES_1, |
| 530 Uint8Array::data_offset())); | 562 Uint8Array::data_offset())); |
| 531 __ SmiTag(EAX); | 563 __ SmiTag(EAX); |
| 532 __ ret(); | 564 __ ret(); |
| 533 __ Bind(&fall_through); | 565 __ Bind(&fall_through); |
| 534 return false; | 566 return false; |
| 535 } | 567 } |
| 536 | 568 |
| 537 | 569 |
| 570 bool Intrinsifier::Uint8Array_setIndexed(Assembler* assembler) { | |
| 571 Label fall_through; | |
| 572 // Verify that the array index is valid. | |
| 573 TestByteArraySetIndex(assembler, &fall_through); | |
| 574 // After TestByteArraySetIndex: | |
| 575 // * EAX has the base address of the byte array. | |
| 576 // * EBX has the index into the array. | |
| 577 // EBX contains the SMI index which is shifted by 1. | |
| 578 __ SmiUntag(EBX); | |
| 579 // Move EBX into EDI. | |
| 580 __ movl(EDI, EBX); | |
| 581 // Load the value into EBX. | |
| 582 __ movl(EBX, Address(ESP, + 1 * kWordSize)); // Value. | |
| 583 // If EBX is not an Smi, jump to fall through. | |
| 584 __ testl(EBX, Immediate(kSmiTagMask)); | |
| 585 __ j(NOT_ZERO, &fall_through, Assembler::kNearJump); | |
| 586 __ SmiUntag(EBX); | |
| 587 // If EBX is too large an Uint8, jump to fall through. | |
| 588 __ cmpl(EBX, Immediate(0xFF)); | |
| 589 __ j(ABOVE, &fall_through, Assembler::kNearJump); | |
| 590 // Store BL into array EAX[EDI] = BL. | |
| 591 __ movb(FieldAddress(EAX, EDI, TIMES_1, Uint8Array::data_offset()), BL); | |
| 592 __ ret(); | |
| 593 __ Bind(&fall_through); | |
| 594 return false; | |
| 595 } | |
| 596 | |
| 597 | |
| 538 bool Intrinsifier::Int16Array_getIndexed(Assembler* assembler) { | 598 bool Intrinsifier::Int16Array_getIndexed(Assembler* assembler) { |
| 539 Label fall_through; | 599 Label fall_through; |
| 540 TestByteArrayIndex(assembler, &fall_through); | 600 TestByteArrayIndex(assembler, &fall_through); |
| 541 __ movsxw(EAX, FieldAddress(EAX, | 601 __ movsxw(EAX, FieldAddress(EAX, |
| 542 EBX, | 602 EBX, |
| 543 TIMES_1, | 603 TIMES_1, |
| 544 Int16Array::data_offset())); | 604 Int16Array::data_offset())); |
| 545 __ SmiTag(EAX); | 605 __ SmiTag(EAX); |
| 546 __ ret(); | 606 __ ret(); |
| 547 __ Bind(&fall_through); | 607 __ Bind(&fall_through); |
| (...skipping 950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1498 __ Bind(&is_true); | 1558 __ Bind(&is_true); |
| 1499 __ LoadObject(EAX, bool_true); | 1559 __ LoadObject(EAX, bool_true); |
| 1500 __ ret(); | 1560 __ ret(); |
| 1501 return true; | 1561 return true; |
| 1502 } | 1562 } |
| 1503 | 1563 |
| 1504 #undef __ | 1564 #undef __ |
| 1505 } // namespace dart | 1565 } // namespace dart |
| 1506 | 1566 |
| 1507 #endif // defined TARGET_ARCH_IA32 | 1567 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |