| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 __ and_(rbx, Immediate(String::kArrayIndexValueMask)); | 517 __ and_(rbx, Immediate(String::kArrayIndexValueMask)); |
| 518 __ shr(rbx, Immediate(String::kHashShift)); | 518 __ shr(rbx, Immediate(String::kHashShift)); |
| 519 __ Integer32ToSmi(rax, rbx); | 519 __ Integer32ToSmi(rax, rbx); |
| 520 __ jmp(&index_smi); | 520 __ jmp(&index_smi); |
| 521 } | 521 } |
| 522 | 522 |
| 523 | 523 |
| 524 void KeyedLoadIC::GenerateString(MacroAssembler* masm) { | 524 void KeyedLoadIC::GenerateString(MacroAssembler* masm) { |
| 525 // ----------- S t a t e ------------- | 525 // ----------- S t a t e ------------- |
| 526 // -- rsp[0] : return address | 526 // -- rsp[0] : return address |
| 527 // -- rsp[8] : name | 527 // -- rsp[8] : name (index) |
| 528 // -- rsp[16] : receiver | 528 // -- rsp[16] : receiver |
| 529 // ----------------------------------- | 529 // ----------------------------------- |
| 530 Label miss; | 530 Label miss; |
| 531 Label index_not_smi; | |
| 532 Label index_out_of_range; | 531 Label index_out_of_range; |
| 533 Label slow_char_code; | |
| 534 Label got_char_code; | |
| 535 | 532 |
| 536 Register receiver = rdx; | 533 Register receiver = rdx; |
| 537 Register index = rax; | 534 Register index = rax; |
| 538 Register code = rbx; | 535 Register scratch1 = rbx; |
| 539 Register scratch = rcx; | 536 Register scratch2 = rcx; |
| 537 Register result = rax; |
| 540 | 538 |
| 541 __ movq(index, Operand(rsp, 1 * kPointerSize)); | 539 __ movq(index, Operand(rsp, 1 * kPointerSize)); |
| 542 __ movq(receiver, Operand(rsp, 2 * kPointerSize)); | 540 __ movq(receiver, Operand(rsp, 2 * kPointerSize)); |
| 543 | 541 |
| 544 StringHelper::GenerateFastCharCodeAt(masm, | 542 StringCharAtGenerator char_at_generator(receiver, |
| 545 receiver, | 543 index, |
| 546 index, | 544 scratch1, |
| 547 scratch, | 545 scratch2, |
| 548 code, | 546 result, |
| 549 &miss, // When not a string. | 547 &miss, // When not a string. |
| 550 &index_not_smi, | 548 &miss, // When not a number. |
| 551 &index_out_of_range, | 549 &index_out_of_range, |
| 552 &slow_char_code); | 550 STRING_REQUIRE_ARRAY_INDEX); |
| 553 // If we didn't bail out, code register contains smi tagged char | 551 char_at_generator.GenerateFast(masm); |
| 554 // code. | 552 __ ret(0); |
| 555 __ bind(&got_char_code); | |
| 556 StringHelper::GenerateCharFromCode(masm, code, rax, scratch, JUMP_FUNCTION); | |
| 557 #ifdef DEBUG | |
| 558 __ Abort("Unexpected fall-through from char from code tail call"); | |
| 559 #endif | |
| 560 | 553 |
| 561 // Check if key is a heap number. | 554 ICRuntimeCallHelper call_helper; |
| 562 __ bind(&index_not_smi); | 555 char_at_generator.GenerateSlow(masm, call_helper); |
| 563 __ CompareRoot(FieldOperand(index, HeapObject::kMapOffset), | |
| 564 Heap::kHeapNumberMapRootIndex); | |
| 565 __ j(not_equal, &miss); | |
| 566 | |
| 567 // Push receiver and key on the stack (now that we know they are a | |
| 568 // string and a number), and call runtime. | |
| 569 __ bind(&slow_char_code); | |
| 570 __ EnterInternalFrame(); | |
| 571 __ push(receiver); | |
| 572 __ push(index); | |
| 573 __ CallRuntime(Runtime::kStringCharCodeAt, 2); | |
| 574 ASSERT(!code.is(rax)); | |
| 575 __ movq(code, rax); | |
| 576 __ LeaveInternalFrame(); | |
| 577 | |
| 578 // Check if the runtime call returned NaN char code. If yes, return | |
| 579 // undefined. Otherwise, we can continue. | |
| 580 if (FLAG_debug_code) { | |
| 581 ASSERT(kSmiTag == 0); | |
| 582 __ JumpIfSmi(code, &got_char_code); | |
| 583 __ CompareRoot(FieldOperand(code, HeapObject::kMapOffset), | |
| 584 Heap::kHeapNumberMapRootIndex); | |
| 585 __ Assert(equal, "StringCharCodeAt must return smi or heap number"); | |
| 586 } | |
| 587 __ CompareRoot(code, Heap::kNanValueRootIndex); | |
| 588 __ j(not_equal, &got_char_code); | |
| 589 | 556 |
| 590 __ bind(&index_out_of_range); | 557 __ bind(&index_out_of_range); |
| 591 __ LoadRoot(rax, Heap::kUndefinedValueRootIndex); | 558 __ LoadRoot(rax, Heap::kUndefinedValueRootIndex); |
| 592 __ ret(0); | 559 __ ret(0); |
| 593 | 560 |
| 594 __ bind(&miss); | 561 __ bind(&miss); |
| 595 GenerateMiss(masm); | 562 GenerateMiss(masm); |
| 596 } | 563 } |
| 597 | 564 |
| 598 | 565 |
| (...skipping 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1613 GenerateMiss(masm); | 1580 GenerateMiss(masm); |
| 1614 } | 1581 } |
| 1615 | 1582 |
| 1616 | 1583 |
| 1617 #undef __ | 1584 #undef __ |
| 1618 | 1585 |
| 1619 | 1586 |
| 1620 } } // namespace v8::internal | 1587 } } // namespace v8::internal |
| 1621 | 1588 |
| 1622 #endif // V8_TARGET_ARCH_X64 | 1589 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |