OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 1992 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2003 // Source and destination are incremented by length. | 2003 // Source and destination are incremented by length. |
2004 // Many variants of movsb, loop unrolling, word moves, and indexed operands | 2004 // Many variants of movsb, loop unrolling, word moves, and indexed operands |
2005 // have been tried here already, and this is fastest. | 2005 // have been tried here already, and this is fastest. |
2006 // A simpler loop is faster on small copies, but 30% slower on large ones. | 2006 // A simpler loop is faster on small copies, but 30% slower on large ones. |
2007 // The cld() instruction must have been emitted, to set the direction flag(), | 2007 // The cld() instruction must have been emitted, to set the direction flag(), |
2008 // before calling this function. | 2008 // before calling this function. |
2009 void MacroAssembler::CopyBytes(Register source, | 2009 void MacroAssembler::CopyBytes(Register source, |
2010 Register destination, | 2010 Register destination, |
2011 Register length, | 2011 Register length, |
2012 Register scratch) { | 2012 Register scratch) { |
2013 Label loop, done, short_string, short_loop; | 2013 Label short_loop, len4, len8, len12, done, short_string; |
2014 // Experimentation shows that the short string loop is faster if length < 10. | |
2015 cmp(length, Immediate(10)); | |
2016 j(less_equal, &short_string); | |
2017 | |
2018 ASSERT(source.is(esi)); | 2014 ASSERT(source.is(esi)); |
2019 ASSERT(destination.is(edi)); | 2015 ASSERT(destination.is(edi)); |
2020 ASSERT(length.is(ecx)); | 2016 ASSERT(length.is(ecx)); |
| 2017 cmp(length, Immediate(4)); |
| 2018 j(below, &short_string, Label::kNear); |
2021 | 2019 |
2022 // Because source is 4-byte aligned in our uses of this function, | 2020 // Because source is 4-byte aligned in our uses of this function, |
2023 // we keep source aligned for the rep_movs call by copying the odd bytes | 2021 // we keep source aligned for the rep_movs call by copying the odd bytes |
2024 // at the end of the ranges. | 2022 // at the end of the ranges. |
2025 mov(scratch, Operand(source, length, times_1, -4)); | 2023 mov(scratch, Operand(source, length, times_1, -4)); |
2026 mov(Operand(destination, length, times_1, -4), scratch); | 2024 mov(Operand(destination, length, times_1, -4), scratch); |
| 2025 |
| 2026 cmp(length, Immediate(8)); |
| 2027 j(below_equal, &len4, Label::kNear); |
| 2028 cmp(length, Immediate(12)); |
| 2029 j(below_equal, &len8, Label::kNear); |
| 2030 cmp(length, Immediate(16)); |
| 2031 j(below_equal, &len12, Label::kNear); |
| 2032 |
2027 mov(scratch, ecx); | 2033 mov(scratch, ecx); |
2028 shr(ecx, 2); | 2034 shr(ecx, 2); |
2029 rep_movs(); | 2035 rep_movs(); |
2030 and_(scratch, Immediate(0x3)); | 2036 and_(scratch, Immediate(0x3)); |
2031 add(destination, scratch); | 2037 add(destination, scratch); |
2032 jmp(&done); | 2038 jmp(&done, Label::kNear); |
| 2039 |
| 2040 bind(&len12); |
| 2041 mov(scratch, Operand(source, 8)); |
| 2042 mov(Operand(destination, 8), scratch); |
| 2043 bind(&len8); |
| 2044 mov(scratch, Operand(source, 4)); |
| 2045 mov(Operand(destination, 4), scratch); |
| 2046 bind(&len4); |
| 2047 mov(scratch, Operand(source, 0)); |
| 2048 mov(Operand(destination, 0), scratch); |
| 2049 add(destination, length); |
| 2050 jmp(&done, Label::kNear); |
2033 | 2051 |
2034 bind(&short_string); | 2052 bind(&short_string); |
2035 test(length, length); | 2053 test(length, length); |
2036 j(zero, &done); | 2054 j(zero, &done, Label::kNear); |
2037 | 2055 |
2038 bind(&short_loop); | 2056 bind(&short_loop); |
2039 mov_b(scratch, Operand(source, 0)); | 2057 mov_b(scratch, Operand(source, 0)); |
2040 mov_b(Operand(destination, 0), scratch); | 2058 mov_b(Operand(destination, 0), scratch); |
2041 inc(source); | 2059 inc(source); |
2042 inc(destination); | 2060 inc(destination); |
2043 dec(length); | 2061 dec(length); |
2044 j(not_zero, &short_loop); | 2062 j(not_zero, &short_loop); |
2045 | 2063 |
2046 bind(&done); | 2064 bind(&done); |
(...skipping 1550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3597 cmp(scratch1, Immediate(DICTIONARY_ELEMENTS)); | 3615 cmp(scratch1, Immediate(DICTIONARY_ELEMENTS)); |
3598 j(equal, found); | 3616 j(equal, found); |
3599 mov(current, FieldOperand(current, Map::kPrototypeOffset)); | 3617 mov(current, FieldOperand(current, Map::kPrototypeOffset)); |
3600 cmp(current, Immediate(factory->null_value())); | 3618 cmp(current, Immediate(factory->null_value())); |
3601 j(not_equal, &loop_again); | 3619 j(not_equal, &loop_again); |
3602 } | 3620 } |
3603 | 3621 |
3604 } } // namespace v8::internal | 3622 } } // namespace v8::internal |
3605 | 3623 |
3606 #endif // V8_TARGET_ARCH_IA32 | 3624 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |