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 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 __ jmp(&index_int); | 516 __ jmp(&index_int); |
517 } | 517 } |
518 | 518 |
519 | 519 |
520 void KeyedLoadIC::GenerateString(MacroAssembler* masm) { | 520 void KeyedLoadIC::GenerateString(MacroAssembler* masm) { |
521 // ----------- S t a t e ------------- | 521 // ----------- S t a t e ------------- |
522 // -- rsp[0] : return address | 522 // -- rsp[0] : return address |
523 // -- rsp[8] : name | 523 // -- rsp[8] : name |
524 // -- rsp[16] : receiver | 524 // -- rsp[16] : receiver |
525 // ----------------------------------- | 525 // ----------------------------------- |
| 526 Label miss; |
| 527 Label index_not_smi; |
| 528 Label index_out_of_range; |
| 529 Label slow_char_code; |
| 530 Label got_char_code; |
526 | 531 |
527 Label miss, index_ok; | 532 Register receiver = rdx; |
| 533 Register index = rax; |
| 534 Register code = rbx; |
| 535 Register scratch = rcx; |
528 | 536 |
529 // Check that the receiver isn't a smi. | 537 __ movq(index, Operand(rsp, 1 * kPointerSize)); |
530 __ movq(rcx, Operand(rsp, 2 * kPointerSize)); | 538 __ movq(receiver, Operand(rsp, 2 * kPointerSize)); |
531 __ JumpIfSmi(rcx, &miss); | |
532 | 539 |
533 // Check that the receiver is a string. | 540 StringHelper::GenerateFastCharCodeAt(masm, |
534 Condition is_string = masm->IsObjectStringType(rcx, rax, rbx); | 541 receiver, |
535 __ j(NegateCondition(is_string), &miss); | 542 index, |
| 543 scratch, |
| 544 code, |
| 545 &miss, // When not a string. |
| 546 &index_not_smi, |
| 547 &index_out_of_range, |
| 548 &slow_char_code); |
| 549 // If we didn't bail out, code register contains smi tagged char |
| 550 // code. |
| 551 __ bind(&got_char_code); |
| 552 StringHelper::GenerateCharFromCode(masm, code, rax, scratch, JUMP_FUNCTION); |
| 553 #ifdef DEBUG |
| 554 __ Abort("Unexpected fall-through from char from code tail call"); |
| 555 #endif |
536 | 556 |
537 // Check if key is a smi or a heap number. | 557 // Check if key is a heap number. |
538 __ movq(rax, Operand(rsp, kPointerSize)); | 558 __ bind(&index_not_smi); |
539 __ JumpIfSmi(rax, &index_ok); | 559 __ CompareRoot(FieldOperand(index, HeapObject::kMapOffset), |
540 __ CheckMap(rax, Factory::heap_number_map(), &miss, false); | 560 Heap::kHeapNumberMapRootIndex); |
| 561 __ j(not_equal, &miss); |
541 | 562 |
542 __ bind(&index_ok); | 563 // Push receiver and key on the stack (now that we know they are a |
543 // Duplicate receiver and key since they are expected on the stack after | 564 // string and a number), and call runtime. |
544 // the KeyedLoadIC call. | 565 __ bind(&slow_char_code); |
545 __ pop(rbx); // return address | 566 __ EnterInternalFrame(); |
546 __ push(rcx); // receiver | 567 __ push(receiver); |
547 __ push(rax); // key | 568 __ push(index); |
548 __ push(rbx); // return address | 569 __ CallRuntime(Runtime::kStringCharCodeAt, 2); |
549 __ InvokeBuiltin(Builtins::STRING_CHAR_AT, JUMP_FUNCTION); | 570 ASSERT(!code.is(rax)); |
| 571 __ movq(code, rax); |
| 572 __ LeaveInternalFrame(); |
| 573 |
| 574 // Check if the runtime call returned NaN char code. If yes, return |
| 575 // undefined. Otherwise, we can continue. |
| 576 if (FLAG_debug_code) { |
| 577 ASSERT(kSmiTag == 0); |
| 578 __ JumpIfSmi(code, &got_char_code); |
| 579 __ CompareRoot(FieldOperand(code, HeapObject::kMapOffset), |
| 580 Heap::kHeapNumberMapRootIndex); |
| 581 __ Assert(equal, "StringCharCodeAt must return smi or heap number"); |
| 582 } |
| 583 __ CompareRoot(code, Heap::kNanValueRootIndex); |
| 584 __ j(not_equal, &got_char_code); |
| 585 |
| 586 __ bind(&index_out_of_range); |
| 587 __ LoadRoot(rax, Heap::kUndefinedValueRootIndex); |
| 588 __ ret(0); |
550 | 589 |
551 __ bind(&miss); | 590 __ bind(&miss); |
552 GenerateMiss(masm); | 591 GenerateMiss(masm); |
553 } | 592 } |
554 | 593 |
555 | 594 |
556 void KeyedLoadIC::GenerateExternalArray(MacroAssembler* masm, | 595 void KeyedLoadIC::GenerateExternalArray(MacroAssembler* masm, |
557 ExternalArrayType array_type) { | 596 ExternalArrayType array_type) { |
558 // ----------- S t a t e ------------- | 597 // ----------- S t a t e ------------- |
559 // -- rsp[0] : return address | 598 // -- rsp[0] : return address |
(...skipping 1013 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1573 __ bind(&miss); | 1612 __ bind(&miss); |
1574 | 1613 |
1575 GenerateMiss(masm); | 1614 GenerateMiss(masm); |
1576 } | 1615 } |
1577 | 1616 |
1578 | 1617 |
1579 #undef __ | 1618 #undef __ |
1580 | 1619 |
1581 | 1620 |
1582 } } // namespace v8::internal | 1621 } } // namespace v8::internal |
OLD | NEW |