| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 2638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2649 void LCodeGen::DoStringCharCodeAt(LStringCharCodeAt* instr) { | 2649 void LCodeGen::DoStringCharCodeAt(LStringCharCodeAt* instr) { |
| 2650 class DeferredStringCharCodeAt: public LDeferredCode { | 2650 class DeferredStringCharCodeAt: public LDeferredCode { |
| 2651 public: | 2651 public: |
| 2652 DeferredStringCharCodeAt(LCodeGen* codegen, LStringCharCodeAt* instr) | 2652 DeferredStringCharCodeAt(LCodeGen* codegen, LStringCharCodeAt* instr) |
| 2653 : LDeferredCode(codegen), instr_(instr) { } | 2653 : LDeferredCode(codegen), instr_(instr) { } |
| 2654 virtual void Generate() { codegen()->DoDeferredStringCharCodeAt(instr_); } | 2654 virtual void Generate() { codegen()->DoDeferredStringCharCodeAt(instr_); } |
| 2655 private: | 2655 private: |
| 2656 LStringCharCodeAt* instr_; | 2656 LStringCharCodeAt* instr_; |
| 2657 }; | 2657 }; |
| 2658 | 2658 |
| 2659 DeferredStringCharCodeAt* deferred = new DeferredStringCharCodeAt(this, | 2659 DeferredStringCharCodeAt* deferred |
| 2660 instr); | 2660 = new DeferredStringCharCodeAt(this, instr); |
| 2661 | 2661 |
| 2662 Register string = ToRegister(instr->string()); | 2662 Register string = ToRegister(instr->string()); |
| 2663 Register index = no_reg; | 2663 Register index = no_reg; |
| 2664 int const_index = -1; | 2664 int const_index = -1; |
| 2665 if (instr->index()->IsConstantOperand()) { | 2665 if (instr->index()->IsConstantOperand()) { |
| 2666 const_index = ToInteger32(LConstantOperand::cast(instr->index())); | 2666 const_index = ToInteger32(LConstantOperand::cast(instr->index())); |
| 2667 } else { | 2667 } else { |
| 2668 index = ToRegister(instr->index()); | 2668 index = ToRegister(instr->index()); |
| 2669 } | 2669 } |
| 2670 Register result = ToRegister(instr->result()); | 2670 Register result = ToRegister(instr->result()); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2703 | 2703 |
| 2704 // Check for 1-byte or 2-byte string. | 2704 // Check for 1-byte or 2-byte string. |
| 2705 __ bind(&flat_string); | 2705 __ bind(&flat_string); |
| 2706 STATIC_ASSERT(kAsciiStringTag != 0); | 2706 STATIC_ASSERT(kAsciiStringTag != 0); |
| 2707 __ test(result, Immediate(kStringEncodingMask)); | 2707 __ test(result, Immediate(kStringEncodingMask)); |
| 2708 __ j(not_zero, &ascii_string); | 2708 __ j(not_zero, &ascii_string); |
| 2709 | 2709 |
| 2710 // 2-byte string. | 2710 // 2-byte string. |
| 2711 // Load the 2-byte character code into the result register. | 2711 // Load the 2-byte character code into the result register. |
| 2712 STATIC_ASSERT(kSmiTag == 0 && kSmiTagSize == 1); | 2712 STATIC_ASSERT(kSmiTag == 0 && kSmiTagSize == 1); |
| 2713 if (index.is_valid()) { | 2713 if (instr->index()->IsConstantOperand()) { |
| 2714 __ movzx_w(result, |
| 2715 FieldOperand(string, |
| 2716 SeqTwoByteString::kHeaderSize + 2 * const_index)); |
| 2717 } else { |
| 2714 __ movzx_w(result, FieldOperand(string, | 2718 __ movzx_w(result, FieldOperand(string, |
| 2715 index, times_2, | 2719 index, |
| 2720 times_2, |
| 2716 SeqTwoByteString::kHeaderSize)); | 2721 SeqTwoByteString::kHeaderSize)); |
| 2717 } else { | |
| 2718 __ movzx_w(result, FieldOperand( | |
| 2719 string, SeqTwoByteString::kHeaderSize + 2 * const_index)); | |
| 2720 } | 2722 } |
| 2721 __ jmp(&done); | 2723 __ jmp(&done); |
| 2722 | 2724 |
| 2723 // ASCII string. | 2725 // ASCII string. |
| 2724 // Load the byte into the result register. | 2726 // Load the byte into the result register. |
| 2725 __ bind(&ascii_string); | 2727 __ bind(&ascii_string); |
| 2726 if (index.is_valid()) { | 2728 if (instr->index()->IsConstantOperand()) { |
| 2727 __ movzx_b(result, FieldOperand(string, | 2729 __ movzx_b(result, FieldOperand(string, |
| 2728 index, times_1, | 2730 SeqAsciiString::kHeaderSize + const_index)); |
| 2729 SeqAsciiString::kHeaderSize)); | |
| 2730 } else { | 2731 } else { |
| 2731 __ movzx_b(result, FieldOperand(string, | 2732 __ movzx_b(result, FieldOperand(string, |
| 2732 SeqAsciiString::kHeaderSize + const_index)); | 2733 index, |
| 2734 times_1, |
| 2735 SeqAsciiString::kHeaderSize)); |
| 2733 } | 2736 } |
| 2734 __ bind(&done); | 2737 __ bind(&done); |
| 2735 __ bind(deferred->exit()); | 2738 __ bind(deferred->exit()); |
| 2736 } | 2739 } |
| 2737 | 2740 |
| 2738 | 2741 |
| 2739 void LCodeGen::DoDeferredStringCharCodeAt(LStringCharCodeAt* instr) { | 2742 void LCodeGen::DoDeferredStringCharCodeAt(LStringCharCodeAt* instr) { |
| 2740 Register string = ToRegister(instr->string()); | 2743 Register string = ToRegister(instr->string()); |
| 2741 Register result = ToRegister(instr->result()); | 2744 Register result = ToRegister(instr->result()); |
| 2742 | 2745 |
| (...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3580 ASSERT(osr_pc_offset_ == -1); | 3583 ASSERT(osr_pc_offset_ == -1); |
| 3581 osr_pc_offset_ = masm()->pc_offset(); | 3584 osr_pc_offset_ = masm()->pc_offset(); |
| 3582 } | 3585 } |
| 3583 | 3586 |
| 3584 | 3587 |
| 3585 #undef __ | 3588 #undef __ |
| 3586 | 3589 |
| 3587 } } // namespace v8::internal | 3590 } } // namespace v8::internal |
| 3588 | 3591 |
| 3589 #endif // V8_TARGET_ARCH_IA32 | 3592 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |