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 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 (1 << String::kArrayIndexValueBits)); | 484 (1 << String::kArrayIndexValueBits)); |
485 __ bind(&index_string); | 485 __ bind(&index_string); |
486 __ and_(ebx, String::kArrayIndexHashMask); | 486 __ and_(ebx, String::kArrayIndexHashMask); |
487 __ shr(ebx, String::kHashShift); | 487 __ shr(ebx, String::kHashShift); |
488 __ jmp(&index_int); | 488 __ jmp(&index_int); |
489 } | 489 } |
490 | 490 |
491 | 491 |
492 void KeyedLoadIC::GenerateString(MacroAssembler* masm) { | 492 void KeyedLoadIC::GenerateString(MacroAssembler* masm) { |
493 // ----------- S t a t e ------------- | 493 // ----------- S t a t e ------------- |
494 // -- eax : key | 494 // -- eax : key (index) |
495 // -- edx : receiver | 495 // -- edx : receiver |
496 // -- esp[0] : return address | 496 // -- esp[0] : return address |
497 // ----------------------------------- | 497 // ----------------------------------- |
498 Label miss, index_ok; | 498 Label miss; |
| 499 Label not_positive_smi; |
| 500 Label slow_char_code; |
| 501 Label got_char_code; |
499 | 502 |
500 // Pop return address. | 503 Register receiver = edx; |
501 // Performing the load early is better in the common case. | 504 Register index = eax; |
502 __ pop(ebx); | 505 Register code = ebx; |
| 506 Register scratch = ecx; |
503 | 507 |
504 __ test(edx, Immediate(kSmiTagMask)); | 508 StringHelper::GenerateFastCharCodeAt(masm, |
505 __ j(zero, &miss); | 509 receiver, |
506 __ mov(ecx, FieldOperand(edx, HeapObject::kMapOffset)); | 510 index, |
507 __ movzx_b(ecx, FieldOperand(ecx, Map::kInstanceTypeOffset)); | 511 scratch, |
508 __ test(ecx, Immediate(kIsNotStringMask)); | 512 code, |
509 __ j(not_zero, &miss); | 513 &miss, // When not a string. |
| 514 ¬_positive_smi, |
| 515 &slow_char_code); |
| 516 // If we didn't bail out, code register contains smi tagged char |
| 517 // code. |
| 518 __ bind(&got_char_code); |
| 519 StringHelper::GenerateCharFromCode(masm, code, eax, JUMP_FUNCTION); |
| 520 #ifdef DEBUG |
| 521 __ Abort("Unexpected fall-through from char from code tail call"); |
| 522 #endif |
510 | 523 |
511 // Check if key is a smi or a heap number. | 524 // Check if key is a smi or a heap number. |
512 __ test(eax, Immediate(kSmiTagMask)); | 525 __ bind(¬_positive_smi); |
513 __ j(zero, &index_ok); | 526 ASSERT(kSmiTag == 0); |
| 527 __ test(index, Immediate(kSmiTagMask)); |
| 528 __ j(zero, &slow_char_code); |
514 __ mov(ecx, FieldOperand(eax, HeapObject::kMapOffset)); | 529 __ mov(ecx, FieldOperand(eax, HeapObject::kMapOffset)); |
515 __ cmp(ecx, Factory::heap_number_map()); | 530 __ cmp(ecx, Factory::heap_number_map()); |
516 __ j(not_equal, &miss); | 531 __ j(not_equal, &miss); |
517 | 532 |
518 __ bind(&index_ok); | 533 // Push receiver and key on the stack (now that we know they are a |
519 // Push receiver and key on the stack, and make a tail call. | 534 // string and a number), and call runtime. |
520 __ push(edx); // receiver | 535 __ bind(&slow_char_code); |
521 __ push(eax); // key | 536 __ EnterInternalFrame(); |
522 __ push(ebx); // return address | 537 __ push(receiver); |
523 __ InvokeBuiltin(Builtins::STRING_CHAR_AT, JUMP_FUNCTION); | 538 __ push(index); |
| 539 __ CallRuntime(Runtime::kStringCharCodeAt, 1); |
| 540 ASSERT(!code.is(eax)); |
| 541 __ mov(code, eax); |
| 542 __ LeaveInternalFrame(); |
| 543 __ jmp(&got_char_code); |
524 | 544 |
525 __ bind(&miss); | 545 __ bind(&miss); |
526 __ push(ebx); | |
527 GenerateMiss(masm); | 546 GenerateMiss(masm); |
528 } | 547 } |
529 | 548 |
530 | 549 |
531 void KeyedLoadIC::GenerateExternalArray(MacroAssembler* masm, | 550 void KeyedLoadIC::GenerateExternalArray(MacroAssembler* masm, |
532 ExternalArrayType array_type) { | 551 ExternalArrayType array_type) { |
533 // ----------- S t a t e ------------- | 552 // ----------- S t a t e ------------- |
534 // -- eax : key | 553 // -- eax : key |
535 // -- edx : receiver | 554 // -- edx : receiver |
536 // -- esp[0] : return address | 555 // -- esp[0] : return address |
(...skipping 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1605 | 1624 |
1606 // Do tail-call to runtime routine. | 1625 // Do tail-call to runtime routine. |
1607 ExternalReference ref = ExternalReference(IC_Utility(kKeyedStoreIC_Miss)); | 1626 ExternalReference ref = ExternalReference(IC_Utility(kKeyedStoreIC_Miss)); |
1608 __ TailCallExternalReference(ref, 3, 1); | 1627 __ TailCallExternalReference(ref, 3, 1); |
1609 } | 1628 } |
1610 | 1629 |
1611 #undef __ | 1630 #undef __ |
1612 | 1631 |
1613 | 1632 |
1614 } } // namespace v8::internal | 1633 } } // namespace v8::internal |
OLD | NEW |