| OLD | NEW |
| 1 // Copyright 2010 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 |
| 11 // with the distribution. | 11 // with the distribution. |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 mov(Operand::StaticVariable(context_address), esi); | 332 mov(Operand::StaticVariable(context_address), esi); |
| 333 } | 333 } |
| 334 | 334 |
| 335 | 335 |
| 336 void MacroAssembler::EnterExitFrameEpilogue(int argc, bool save_doubles) { | 336 void MacroAssembler::EnterExitFrameEpilogue(int argc, bool save_doubles) { |
| 337 // Optionally save all XMM registers. | 337 // Optionally save all XMM registers. |
| 338 if (save_doubles) { | 338 if (save_doubles) { |
| 339 CpuFeatures::Scope scope(SSE2); | 339 CpuFeatures::Scope scope(SSE2); |
| 340 int space = XMMRegister::kNumRegisters * kDoubleSize + argc * kPointerSize; | 340 int space = XMMRegister::kNumRegisters * kDoubleSize + argc * kPointerSize; |
| 341 sub(Operand(esp), Immediate(space)); | 341 sub(Operand(esp), Immediate(space)); |
| 342 int offset = -2 * kPointerSize; | 342 const int offset = -2 * kPointerSize; |
| 343 for (int i = 0; i < XMMRegister::kNumRegisters; i++) { | 343 for (int i = 0; i < XMMRegister::kNumRegisters; i++) { |
| 344 XMMRegister reg = XMMRegister::from_code(i); | 344 XMMRegister reg = XMMRegister::from_code(i); |
| 345 movdbl(Operand(ebp, offset - ((i + 1) * kDoubleSize)), reg); | 345 movdbl(Operand(ebp, offset - ((i + 1) * kDoubleSize)), reg); |
| 346 } | 346 } |
| 347 } else { | 347 } else { |
| 348 sub(Operand(esp), Immediate(argc * kPointerSize)); | 348 sub(Operand(esp), Immediate(argc * kPointerSize)); |
| 349 } | 349 } |
| 350 | 350 |
| 351 // Get the required frame alignment for the OS. | 351 // Get the required frame alignment for the OS. |
| 352 const int kFrameAlignment = OS::ActivationFrameAlignment(); | 352 const int kFrameAlignment = OS::ActivationFrameAlignment(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 376 void MacroAssembler::EnterApiExitFrame(int argc) { | 376 void MacroAssembler::EnterApiExitFrame(int argc) { |
| 377 EnterExitFramePrologue(); | 377 EnterExitFramePrologue(); |
| 378 EnterExitFrameEpilogue(argc, false); | 378 EnterExitFrameEpilogue(argc, false); |
| 379 } | 379 } |
| 380 | 380 |
| 381 | 381 |
| 382 void MacroAssembler::LeaveExitFrame(bool save_doubles) { | 382 void MacroAssembler::LeaveExitFrame(bool save_doubles) { |
| 383 // Optionally restore all XMM registers. | 383 // Optionally restore all XMM registers. |
| 384 if (save_doubles) { | 384 if (save_doubles) { |
| 385 CpuFeatures::Scope scope(SSE2); | 385 CpuFeatures::Scope scope(SSE2); |
| 386 int offset = -2 * kPointerSize; | 386 const int offset = -2 * kPointerSize; |
| 387 for (int i = 0; i < XMMRegister::kNumRegisters; i++) { | 387 for (int i = 0; i < XMMRegister::kNumRegisters; i++) { |
| 388 XMMRegister reg = XMMRegister::from_code(i); | 388 XMMRegister reg = XMMRegister::from_code(i); |
| 389 movdbl(reg, Operand(ebp, offset - ((i + 1) * kDoubleSize))); | 389 movdbl(reg, Operand(ebp, offset - ((i + 1) * kDoubleSize))); |
| 390 } | 390 } |
| 391 } | 391 } |
| 392 | 392 |
| 393 // Get the return address from the stack and restore the frame pointer. | 393 // Get the return address from the stack and restore the frame pointer. |
| 394 mov(ecx, Operand(ebp, 1 * kPointerSize)); | 394 mov(ecx, Operand(ebp, 1 * kPointerSize)); |
| 395 mov(ebp, Operand(ebp, 0 * kPointerSize)); | 395 mov(ebp, Operand(ebp, 0 * kPointerSize)); |
| 396 | 396 |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 872 scratch1, | 872 scratch1, |
| 873 scratch2, | 873 scratch2, |
| 874 gc_required, | 874 gc_required, |
| 875 TAG_OBJECT); | 875 TAG_OBJECT); |
| 876 | 876 |
| 877 // Set the map. The other fields are left uninitialized. | 877 // Set the map. The other fields are left uninitialized. |
| 878 mov(FieldOperand(result, HeapObject::kMapOffset), | 878 mov(FieldOperand(result, HeapObject::kMapOffset), |
| 879 Immediate(FACTORY->cons_ascii_string_map())); | 879 Immediate(FACTORY->cons_ascii_string_map())); |
| 880 } | 880 } |
| 881 | 881 |
| 882 // All registers must be distinct. Only current_string needs valid contents | |
| 883 // on entry. All registers may be invalid on exit. result_operand is | |
| 884 // unchanged, padding_chars is updated correctly. | |
| 885 void MacroAssembler::AppendStringToTopOfNewSpace( | |
| 886 Register current_string, // Tagged pointer to string to copy. | |
| 887 Register current_string_length, | |
| 888 Register result_pos, | |
| 889 Register scratch, | |
| 890 Register new_padding_chars, | |
| 891 Operand operand_result, | |
| 892 Operand operand_padding_chars, | |
| 893 Label* bailout) { | |
| 894 mov(current_string_length, | |
| 895 FieldOperand(current_string, String::kLengthOffset)); | |
| 896 shr(current_string_length, 1); | |
| 897 sub(current_string_length, operand_padding_chars); | |
| 898 mov(new_padding_chars, current_string_length); | |
| 899 add(Operand(current_string_length), Immediate(kObjectAlignmentMask)); | |
| 900 and_(Operand(current_string_length), Immediate(~kObjectAlignmentMask)); | |
| 901 sub(new_padding_chars, Operand(current_string_length)); | |
| 902 neg(new_padding_chars); | |
| 903 // We need an allocation even if current_string_length is 0, to fetch | |
| 904 // result_pos. Consider using a faster fetch of result_pos in that case. | |
| 905 AllocateInNewSpace(current_string_length, result_pos, scratch, no_reg, | |
| 906 bailout, NO_ALLOCATION_FLAGS); | |
| 907 sub(result_pos, operand_padding_chars); | |
| 908 mov(operand_padding_chars, new_padding_chars); | |
| 909 | 882 |
| 910 Register scratch_2 = new_padding_chars; // Used to compute total length. | 883 // Copy memory, byte-by-byte, from source to destination. Not optimized for |
| 911 // Copy string to the end of result. | 884 // long or aligned copies. The contents of scratch and length are destroyed. |
| 912 mov(current_string_length, | 885 // Source and destination are incremented by length. |
| 913 FieldOperand(current_string, String::kLengthOffset)); | 886 // Many variants of movsb, loop unrolling, word moves, and indexed operands |
| 914 mov(scratch, operand_result); | 887 // have been tried here already, and this is fastest. |
| 915 mov(scratch_2, current_string_length); | 888 // A simpler loop is faster on small copies, but 30% slower on large ones. |
| 916 add(scratch_2, FieldOperand(scratch, String::kLengthOffset)); | 889 // The cld() instruction must have been emitted, to set the direction flag(), |
| 917 mov(FieldOperand(scratch, String::kLengthOffset), scratch_2); | 890 // before calling this function. |
| 918 shr(current_string_length, 1); | 891 void MacroAssembler::CopyBytes(Register source, |
| 919 lea(current_string, | 892 Register destination, |
| 920 FieldOperand(current_string, SeqAsciiString::kHeaderSize)); | 893 Register length, |
| 921 // Loop condition: while (--current_string_length >= 0). | 894 Register scratch) { |
| 922 Label copy_loop; | 895 Label loop, done, short_string, short_loop; |
| 923 Label copy_loop_entry; | 896 // Experimentation shows that the short string loop is faster if length < 10. |
| 924 jmp(©_loop_entry); | 897 cmp(Operand(length), Immediate(10)); |
| 925 bind(©_loop); | 898 j(less_equal, &short_string); |
| 926 mov_b(scratch, Operand(current_string, current_string_length, times_1, 0)); | 899 |
| 927 mov_b(Operand(result_pos, current_string_length, times_1, 0), scratch); | 900 ASSERT(source.is(esi)); |
| 928 bind(©_loop_entry); | 901 ASSERT(destination.is(edi)); |
| 929 sub(Operand(current_string_length), Immediate(1)); | 902 ASSERT(length.is(ecx)); |
| 930 j(greater_equal, ©_loop); | 903 |
| 904 // Because source is 4-byte aligned in our uses of this function, |
| 905 // we keep source aligned for the rep_movs call by copying the odd bytes |
| 906 // at the end of the ranges. |
| 907 mov(scratch, Operand(source, length, times_1, -4)); |
| 908 mov(Operand(destination, length, times_1, -4), scratch); |
| 909 mov(scratch, ecx); |
| 910 shr(ecx, 2); |
| 911 rep_movs(); |
| 912 and_(Operand(scratch), Immediate(0x3)); |
| 913 add(destination, Operand(scratch)); |
| 914 jmp(&done); |
| 915 |
| 916 bind(&short_string); |
| 917 test(length, Operand(length)); |
| 918 j(zero, &done); |
| 919 |
| 920 bind(&short_loop); |
| 921 mov_b(scratch, Operand(source, 0)); |
| 922 mov_b(Operand(destination, 0), scratch); |
| 923 inc(source); |
| 924 inc(destination); |
| 925 dec(length); |
| 926 j(not_zero, &short_loop); |
| 927 |
| 928 bind(&done); |
| 931 } | 929 } |
| 932 | 930 |
| 933 | 931 |
| 934 void MacroAssembler::NegativeZeroTest(CodeGenerator* cgen, | 932 void MacroAssembler::NegativeZeroTest(CodeGenerator* cgen, |
| 935 Register result, | 933 Register result, |
| 936 Register op, | 934 Register op, |
| 937 JumpTarget* then_target) { | 935 JumpTarget* then_target) { |
| 938 JumpTarget ok; | 936 JumpTarget ok; |
| 939 test(result, Operand(result)); | 937 test(result, Operand(result)); |
| 940 ok.Branch(not_zero, taken); | 938 ok.Branch(not_zero, taken); |
| (...skipping 963 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1904 | 1902 |
| 1905 // Check that the code was patched as expected. | 1903 // Check that the code was patched as expected. |
| 1906 ASSERT(masm_.pc_ == address_ + size_); | 1904 ASSERT(masm_.pc_ == address_ + size_); |
| 1907 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); | 1905 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); |
| 1908 } | 1906 } |
| 1909 | 1907 |
| 1910 | 1908 |
| 1911 } } // namespace v8::internal | 1909 } } // namespace v8::internal |
| 1912 | 1910 |
| 1913 #endif // V8_TARGET_ARCH_IA32 | 1911 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |