| 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 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 (index) | 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; | 498 Label miss; |
| 499 Label not_positive_smi; | 499 Label index_not_smi; |
| 500 Label index_out_of_range; |
| 500 Label slow_char_code; | 501 Label slow_char_code; |
| 501 Label got_char_code; | 502 Label got_char_code; |
| 502 | 503 |
| 503 Register receiver = edx; | 504 Register receiver = edx; |
| 504 Register index = eax; | 505 Register index = eax; |
| 505 Register code = ebx; | 506 Register code = ebx; |
| 506 Register scratch = ecx; | 507 Register scratch = ecx; |
| 507 | 508 |
| 508 StringHelper::GenerateFastCharCodeAt(masm, | 509 StringHelper::GenerateFastCharCodeAt(masm, |
| 509 receiver, | 510 receiver, |
| 510 index, | 511 index, |
| 511 scratch, | 512 scratch, |
| 512 code, | 513 code, |
| 513 &miss, // When not a string. | 514 &miss, // When not a string. |
| 514 ¬_positive_smi, | 515 &index_not_smi, |
| 516 &index_out_of_range, |
| 515 &slow_char_code); | 517 &slow_char_code); |
| 516 // If we didn't bail out, code register contains smi tagged char | 518 // If we didn't bail out, code register contains smi tagged char |
| 517 // code. | 519 // code. |
| 518 __ bind(&got_char_code); | 520 __ bind(&got_char_code); |
| 519 StringHelper::GenerateCharFromCode(masm, code, eax, JUMP_FUNCTION); | 521 StringHelper::GenerateCharFromCode(masm, code, eax, JUMP_FUNCTION); |
| 520 #ifdef DEBUG | 522 #ifdef DEBUG |
| 521 __ Abort("Unexpected fall-through from char from code tail call"); | 523 __ Abort("Unexpected fall-through from char from code tail call"); |
| 522 #endif | 524 #endif |
| 523 | 525 |
| 524 // Check if key is a smi or a heap number. | 526 // Check if key is a heap number. |
| 525 __ bind(¬_positive_smi); | 527 __ bind(&index_not_smi); |
| 526 ASSERT(kSmiTag == 0); | 528 __ CheckMap(index, Factory::heap_number_map(), &miss, true); |
| 527 __ test(index, Immediate(kSmiTagMask)); | |
| 528 __ j(zero, &slow_char_code); | |
| 529 __ mov(ecx, FieldOperand(eax, HeapObject::kMapOffset)); | |
| 530 __ cmp(ecx, Factory::heap_number_map()); | |
| 531 __ j(not_equal, &miss); | |
| 532 | 529 |
| 533 // Push receiver and key on the stack (now that we know they are a | 530 // Push receiver and key on the stack (now that we know they are a |
| 534 // string and a number), and call runtime. | 531 // string and a number), and call runtime. |
| 535 __ bind(&slow_char_code); | 532 __ bind(&slow_char_code); |
| 536 __ EnterInternalFrame(); | 533 __ EnterInternalFrame(); |
| 537 __ push(receiver); | 534 __ push(receiver); |
| 538 __ push(index); | 535 __ push(index); |
| 539 __ CallRuntime(Runtime::kStringCharCodeAt, 2); | 536 __ CallRuntime(Runtime::kStringCharCodeAt, 2); |
| 540 ASSERT(!code.is(eax)); | 537 ASSERT(!code.is(eax)); |
| 541 __ mov(code, eax); | 538 __ mov(code, eax); |
| 542 __ LeaveInternalFrame(); | 539 __ LeaveInternalFrame(); |
| 543 | 540 |
| 544 // Check if the runtime call returned NaN char code. If yes, return | 541 // Check if the runtime call returned NaN char code. If yes, return |
| 545 // undefined. Otherwise, we can continue. | 542 // undefined. Otherwise, we can continue. |
| 546 if (FLAG_debug_code) { | 543 if (FLAG_debug_code) { |
| 547 ASSERT(kSmiTag == 0); | 544 ASSERT(kSmiTag == 0); |
| 548 __ test(code, Immediate(kSmiTagMask)); | 545 __ test(code, Immediate(kSmiTagMask)); |
| 549 __ j(zero, &got_char_code); | 546 __ j(zero, &got_char_code); |
| 550 __ mov(scratch, FieldOperand(code, HeapObject::kMapOffset)); | 547 __ mov(scratch, FieldOperand(code, HeapObject::kMapOffset)); |
| 551 __ cmp(scratch, Factory::heap_number_map()); | 548 __ cmp(scratch, Factory::heap_number_map()); |
| 552 __ Assert(equal, "StringCharCodeAt must return smi or heap number"); | 549 __ Assert(equal, "StringCharCodeAt must return smi or heap number"); |
| 553 } | 550 } |
| 554 __ cmp(code, Factory::nan_value()); | 551 __ cmp(code, Factory::nan_value()); |
| 555 __ j(not_equal, &got_char_code); | 552 __ j(not_equal, &got_char_code); |
| 553 __ bind(&index_out_of_range); |
| 556 __ Set(eax, Immediate(Factory::undefined_value())); | 554 __ Set(eax, Immediate(Factory::undefined_value())); |
| 557 __ ret(0); | 555 __ ret(0); |
| 558 | 556 |
| 559 __ bind(&miss); | 557 __ bind(&miss); |
| 560 GenerateMiss(masm); | 558 GenerateMiss(masm); |
| 561 } | 559 } |
| 562 | 560 |
| 563 | 561 |
| 564 void KeyedLoadIC::GenerateExternalArray(MacroAssembler* masm, | 562 void KeyedLoadIC::GenerateExternalArray(MacroAssembler* masm, |
| 565 ExternalArrayType array_type) { | 563 ExternalArrayType array_type) { |
| (...skipping 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1638 | 1636 |
| 1639 // Do tail-call to runtime routine. | 1637 // Do tail-call to runtime routine. |
| 1640 ExternalReference ref = ExternalReference(IC_Utility(kKeyedStoreIC_Miss)); | 1638 ExternalReference ref = ExternalReference(IC_Utility(kKeyedStoreIC_Miss)); |
| 1641 __ TailCallExternalReference(ref, 3, 1); | 1639 __ TailCallExternalReference(ref, 3, 1); |
| 1642 } | 1640 } |
| 1643 | 1641 |
| 1644 #undef __ | 1642 #undef __ |
| 1645 | 1643 |
| 1646 | 1644 |
| 1647 } } // namespace v8::internal | 1645 } } // namespace v8::internal |
| OLD | NEW |