OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 } | 495 } |
496 | 496 |
497 | 497 |
498 void KeyedLoadIC::GenerateString(MacroAssembler* masm) { | 498 void KeyedLoadIC::GenerateString(MacroAssembler* masm) { |
499 // ----------- S t a t e ------------- | 499 // ----------- S t a t e ------------- |
500 // -- eax : key (index) | 500 // -- eax : key (index) |
501 // -- edx : receiver | 501 // -- edx : receiver |
502 // -- esp[0] : return address | 502 // -- esp[0] : return address |
503 // ----------------------------------- | 503 // ----------------------------------- |
504 Label miss; | 504 Label miss; |
505 Label index_not_smi; | |
506 Label index_out_of_range; | 505 Label index_out_of_range; |
507 Label slow_char_code; | |
508 Label got_char_code; | |
509 | 506 |
510 Register receiver = edx; | 507 Register receiver = edx; |
511 Register index = eax; | 508 Register index = eax; |
512 Register code = ebx; | 509 Register scratch1 = ebx; |
513 Register scratch = ecx; | 510 Register scratch2 = ecx; |
| 511 Register result = eax; |
514 | 512 |
515 StringHelper::GenerateFastCharCodeAt(masm, | 513 StringCharAtGenerator char_at_generator(receiver, |
516 receiver, | 514 index, |
517 index, | 515 scratch1, |
518 scratch, | 516 scratch2, |
519 code, | 517 result, |
520 &miss, // When not a string. | 518 &miss, // When not a string. |
521 &index_not_smi, | 519 &miss, // When not a number. |
522 &index_out_of_range, | 520 &index_out_of_range, |
523 &slow_char_code); | 521 STRING_REQUIRE_ARRAY_INDEX); |
524 // If we didn't bail out, code register contains smi tagged char | 522 char_at_generator.GenerateFast(masm); |
525 // code. | 523 __ ret(0); |
526 __ bind(&got_char_code); | |
527 StringHelper::GenerateCharFromCode(masm, code, eax, JUMP_FUNCTION); | |
528 #ifdef DEBUG | |
529 __ Abort("Unexpected fall-through from char from code tail call"); | |
530 #endif | |
531 | 524 |
532 // Check if key is a heap number. | 525 ICRuntimeCallHelper call_helper; |
533 __ bind(&index_not_smi); | 526 char_at_generator.GenerateSlow(masm, call_helper); |
534 __ CheckMap(index, Factory::heap_number_map(), &miss, true); | |
535 | 527 |
536 // Push receiver and key on the stack (now that we know they are a | |
537 // string and a number), and call runtime. | |
538 __ bind(&slow_char_code); | |
539 __ EnterInternalFrame(); | |
540 __ push(receiver); | |
541 __ push(index); | |
542 __ CallRuntime(Runtime::kStringCharCodeAt, 2); | |
543 ASSERT(!code.is(eax)); | |
544 __ mov(code, eax); | |
545 __ LeaveInternalFrame(); | |
546 | |
547 // Check if the runtime call returned NaN char code. If yes, return | |
548 // undefined. Otherwise, we can continue. | |
549 if (FLAG_debug_code) { | |
550 ASSERT(kSmiTag == 0); | |
551 __ test(code, Immediate(kSmiTagMask)); | |
552 __ j(zero, &got_char_code); | |
553 __ mov(scratch, FieldOperand(code, HeapObject::kMapOffset)); | |
554 __ cmp(scratch, Factory::heap_number_map()); | |
555 __ Assert(equal, "StringCharCodeAt must return smi or heap number"); | |
556 } | |
557 __ cmp(code, Factory::nan_value()); | |
558 __ j(not_equal, &got_char_code); | |
559 __ bind(&index_out_of_range); | 528 __ bind(&index_out_of_range); |
560 __ Set(eax, Immediate(Factory::undefined_value())); | 529 __ Set(eax, Immediate(Factory::undefined_value())); |
561 __ ret(0); | 530 __ ret(0); |
562 | 531 |
563 __ bind(&miss); | 532 __ bind(&miss); |
564 GenerateMiss(masm); | 533 GenerateMiss(masm); |
565 } | 534 } |
566 | 535 |
567 | 536 |
568 void KeyedLoadIC::GenerateExternalArray(MacroAssembler* masm, | 537 void KeyedLoadIC::GenerateExternalArray(MacroAssembler* masm, |
(...skipping 1071 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1640 ExternalReference ref = ExternalReference(IC_Utility(kKeyedStoreIC_Miss)); | 1609 ExternalReference ref = ExternalReference(IC_Utility(kKeyedStoreIC_Miss)); |
1641 __ TailCallExternalReference(ref, 3, 1); | 1610 __ TailCallExternalReference(ref, 3, 1); |
1642 } | 1611 } |
1643 | 1612 |
1644 #undef __ | 1613 #undef __ |
1645 | 1614 |
1646 | 1615 |
1647 } } // namespace v8::internal | 1616 } } // namespace v8::internal |
1648 | 1617 |
1649 #endif // V8_TARGET_ARCH_IA32 | 1618 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |