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 5705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5716 __ j(below, &string_add_flat_result); | 5716 __ j(below, &string_add_flat_result); |
5717 | 5717 |
5718 // If result is not supposed to be flat allocate a cons string object. If both | 5718 // If result is not supposed to be flat allocate a cons string object. If both |
5719 // strings are ASCII the result is an ASCII cons string. | 5719 // strings are ASCII the result is an ASCII cons string. |
5720 Label non_ascii, allocated, ascii_data; | 5720 Label non_ascii, allocated, ascii_data; |
5721 __ mov(edi, FieldOperand(eax, HeapObject::kMapOffset)); | 5721 __ mov(edi, FieldOperand(eax, HeapObject::kMapOffset)); |
5722 __ movzx_b(ecx, FieldOperand(edi, Map::kInstanceTypeOffset)); | 5722 __ movzx_b(ecx, FieldOperand(edi, Map::kInstanceTypeOffset)); |
5723 __ mov(edi, FieldOperand(edx, HeapObject::kMapOffset)); | 5723 __ mov(edi, FieldOperand(edx, HeapObject::kMapOffset)); |
5724 __ movzx_b(edi, FieldOperand(edi, Map::kInstanceTypeOffset)); | 5724 __ movzx_b(edi, FieldOperand(edi, Map::kInstanceTypeOffset)); |
5725 __ and_(ecx, edi); | 5725 __ and_(ecx, edi); |
5726 STATIC_ASSERT((kStringEncodingMask & kAsciiStringTag) != 0); | 5726 STATIC_ASSERT((kStringEncodingMask & kOneByteStringTag) != 0); |
5727 STATIC_ASSERT((kStringEncodingMask & kTwoByteStringTag) == 0); | 5727 STATIC_ASSERT((kStringEncodingMask & kTwoByteStringTag) == 0); |
5728 __ test(ecx, Immediate(kStringEncodingMask)); | 5728 __ test(ecx, Immediate(kStringEncodingMask)); |
5729 __ j(zero, &non_ascii); | 5729 __ j(zero, &non_ascii); |
5730 __ bind(&ascii_data); | 5730 __ bind(&ascii_data); |
5731 // Allocate an ASCII cons string. | 5731 // Allocate an ASCII cons string. |
5732 __ AllocateAsciiConsString(ecx, edi, no_reg, &call_runtime); | 5732 __ AllocateAsciiConsString(ecx, edi, no_reg, &call_runtime); |
5733 __ bind(&allocated); | 5733 __ bind(&allocated); |
5734 // Fill the fields of the cons string. | 5734 // Fill the fields of the cons string. |
5735 __ AssertSmi(ebx); | 5735 __ AssertSmi(ebx); |
5736 __ mov(FieldOperand(ecx, ConsString::kLengthOffset), ebx); | 5736 __ mov(FieldOperand(ecx, ConsString::kLengthOffset), ebx); |
5737 __ mov(FieldOperand(ecx, ConsString::kHashFieldOffset), | 5737 __ mov(FieldOperand(ecx, ConsString::kHashFieldOffset), |
5738 Immediate(String::kEmptyHashField)); | 5738 Immediate(String::kEmptyHashField)); |
5739 __ mov(FieldOperand(ecx, ConsString::kFirstOffset), eax); | 5739 __ mov(FieldOperand(ecx, ConsString::kFirstOffset), eax); |
5740 __ mov(FieldOperand(ecx, ConsString::kSecondOffset), edx); | 5740 __ mov(FieldOperand(ecx, ConsString::kSecondOffset), edx); |
5741 __ mov(eax, ecx); | 5741 __ mov(eax, ecx); |
5742 __ IncrementCounter(counters->string_add_native(), 1); | 5742 __ IncrementCounter(counters->string_add_native(), 1); |
5743 __ ret(2 * kPointerSize); | 5743 __ ret(2 * kPointerSize); |
5744 __ bind(&non_ascii); | 5744 __ bind(&non_ascii); |
5745 // At least one of the strings is two-byte. Check whether it happens | 5745 // At least one of the strings is two-byte. Check whether it happens |
5746 // to contain only ASCII characters. | 5746 // to contain only ASCII characters. |
5747 // ecx: first instance type AND second instance type. | 5747 // ecx: first instance type AND second instance type. |
5748 // edi: second instance type. | 5748 // edi: second instance type. |
5749 __ test(ecx, Immediate(kAsciiDataHintMask)); | 5749 __ test(ecx, Immediate(kAsciiDataHintMask)); |
5750 __ j(not_zero, &ascii_data); | 5750 __ j(not_zero, &ascii_data); |
5751 __ mov(ecx, FieldOperand(eax, HeapObject::kMapOffset)); | 5751 __ mov(ecx, FieldOperand(eax, HeapObject::kMapOffset)); |
5752 __ movzx_b(ecx, FieldOperand(ecx, Map::kInstanceTypeOffset)); | 5752 __ movzx_b(ecx, FieldOperand(ecx, Map::kInstanceTypeOffset)); |
5753 __ xor_(edi, ecx); | 5753 __ xor_(edi, ecx); |
5754 STATIC_ASSERT(kAsciiStringTag != 0 && kAsciiDataHintTag != 0); | 5754 STATIC_ASSERT(kOneByteStringTag != 0 && kAsciiDataHintTag != 0); |
5755 __ and_(edi, kAsciiStringTag | kAsciiDataHintTag); | 5755 __ and_(edi, kOneByteStringTag | kAsciiDataHintTag); |
5756 __ cmp(edi, kAsciiStringTag | kAsciiDataHintTag); | 5756 __ cmp(edi, kOneByteStringTag | kAsciiDataHintTag); |
5757 __ j(equal, &ascii_data); | 5757 __ j(equal, &ascii_data); |
5758 // Allocate a two byte cons string. | 5758 // Allocate a two byte cons string. |
5759 __ AllocateTwoByteConsString(ecx, edi, no_reg, &call_runtime); | 5759 __ AllocateTwoByteConsString(ecx, edi, no_reg, &call_runtime); |
5760 __ jmp(&allocated); | 5760 __ jmp(&allocated); |
5761 | 5761 |
5762 // We cannot encounter sliced strings or cons strings here since: | 5762 // We cannot encounter sliced strings or cons strings here since: |
5763 STATIC_ASSERT(SlicedString::kMinLength >= ConsString::kMinLength); | 5763 STATIC_ASSERT(SlicedString::kMinLength >= ConsString::kMinLength); |
5764 // Handle creating a flat result from either external or sequential strings. | 5764 // Handle creating a flat result from either external or sequential strings. |
5765 // Locate the first characters' locations. | 5765 // Locate the first characters' locations. |
5766 // eax: first string | 5766 // eax: first string |
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6317 // ecx: length (smi) | 6317 // ecx: length (smi) |
6318 __ cmp(ecx, Immediate(Smi::FromInt(SlicedString::kMinLength))); | 6318 __ cmp(ecx, Immediate(Smi::FromInt(SlicedString::kMinLength))); |
6319 // Short slice. Copy instead of slicing. | 6319 // Short slice. Copy instead of slicing. |
6320 __ j(less, ©_routine); | 6320 __ j(less, ©_routine); |
6321 // Allocate new sliced string. At this point we do not reload the instance | 6321 // Allocate new sliced string. At this point we do not reload the instance |
6322 // type including the string encoding because we simply rely on the info | 6322 // type including the string encoding because we simply rely on the info |
6323 // provided by the original string. It does not matter if the original | 6323 // provided by the original string. It does not matter if the original |
6324 // string's encoding is wrong because we always have to recheck encoding of | 6324 // string's encoding is wrong because we always have to recheck encoding of |
6325 // the newly created string's parent anyways due to externalized strings. | 6325 // the newly created string's parent anyways due to externalized strings. |
6326 Label two_byte_slice, set_slice_header; | 6326 Label two_byte_slice, set_slice_header; |
6327 STATIC_ASSERT((kStringEncodingMask & kAsciiStringTag) != 0); | 6327 STATIC_ASSERT((kStringEncodingMask & kOneByteStringTag) != 0); |
6328 STATIC_ASSERT((kStringEncodingMask & kTwoByteStringTag) == 0); | 6328 STATIC_ASSERT((kStringEncodingMask & kTwoByteStringTag) == 0); |
6329 __ test(ebx, Immediate(kStringEncodingMask)); | 6329 __ test(ebx, Immediate(kStringEncodingMask)); |
6330 __ j(zero, &two_byte_slice, Label::kNear); | 6330 __ j(zero, &two_byte_slice, Label::kNear); |
6331 __ AllocateAsciiSlicedString(eax, ebx, no_reg, &runtime); | 6331 __ AllocateAsciiSlicedString(eax, ebx, no_reg, &runtime); |
6332 __ jmp(&set_slice_header, Label::kNear); | 6332 __ jmp(&set_slice_header, Label::kNear); |
6333 __ bind(&two_byte_slice); | 6333 __ bind(&two_byte_slice); |
6334 __ AllocateTwoByteSlicedString(eax, ebx, no_reg, &runtime); | 6334 __ AllocateTwoByteSlicedString(eax, ebx, no_reg, &runtime); |
6335 __ bind(&set_slice_header); | 6335 __ bind(&set_slice_header); |
6336 __ mov(FieldOperand(eax, SlicedString::kLengthOffset), ecx); | 6336 __ mov(FieldOperand(eax, SlicedString::kLengthOffset), ecx); |
6337 __ mov(FieldOperand(eax, SlicedString::kHashFieldOffset), | 6337 __ mov(FieldOperand(eax, SlicedString::kHashFieldOffset), |
(...skipping 26 matching lines...) Expand all Loading... |
6364 __ mov(edi, FieldOperand(edi, ExternalString::kResourceDataOffset)); | 6364 __ mov(edi, FieldOperand(edi, ExternalString::kResourceDataOffset)); |
6365 // Move the pointer so that offset-wise, it looks like a sequential string. | 6365 // Move the pointer so that offset-wise, it looks like a sequential string. |
6366 STATIC_ASSERT(SeqTwoByteString::kHeaderSize == SeqAsciiString::kHeaderSize); | 6366 STATIC_ASSERT(SeqTwoByteString::kHeaderSize == SeqAsciiString::kHeaderSize); |
6367 __ sub(edi, Immediate(SeqTwoByteString::kHeaderSize - kHeapObjectTag)); | 6367 __ sub(edi, Immediate(SeqTwoByteString::kHeaderSize - kHeapObjectTag)); |
6368 | 6368 |
6369 __ bind(&sequential_string); | 6369 __ bind(&sequential_string); |
6370 // Stash away (adjusted) index and (underlying) string. | 6370 // Stash away (adjusted) index and (underlying) string. |
6371 __ push(edx); | 6371 __ push(edx); |
6372 __ push(edi); | 6372 __ push(edi); |
6373 __ SmiUntag(ecx); | 6373 __ SmiUntag(ecx); |
6374 STATIC_ASSERT((kAsciiStringTag & kStringEncodingMask) != 0); | 6374 STATIC_ASSERT((kOneByteStringTag & kStringEncodingMask) != 0); |
6375 __ test_b(ebx, kStringEncodingMask); | 6375 __ test_b(ebx, kStringEncodingMask); |
6376 __ j(zero, &two_byte_sequential); | 6376 __ j(zero, &two_byte_sequential); |
6377 | 6377 |
6378 // Sequential ASCII string. Allocate the result. | 6378 // Sequential ASCII string. Allocate the result. |
6379 __ AllocateAsciiString(eax, ecx, ebx, edx, edi, &runtime_drop_two); | 6379 __ AllocateAsciiString(eax, ecx, ebx, edx, edi, &runtime_drop_two); |
6380 | 6380 |
6381 // eax: result string | 6381 // eax: result string |
6382 // ecx: result string length | 6382 // ecx: result string length |
6383 __ mov(edx, esi); // esi used by following code. | 6383 __ mov(edx, esi); // esi used by following code. |
6384 // Locate first character of result. | 6384 // Locate first character of result. |
(...skipping 1142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7527 // Restore ecx. | 7527 // Restore ecx. |
7528 __ pop(ecx); | 7528 __ pop(ecx); |
7529 __ ret(0); | 7529 __ ret(0); |
7530 } | 7530 } |
7531 | 7531 |
7532 #undef __ | 7532 #undef __ |
7533 | 7533 |
7534 } } // namespace v8::internal | 7534 } } // namespace v8::internal |
7535 | 7535 |
7536 #endif // V8_TARGET_ARCH_IA32 | 7536 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |