OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 11287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11298 // Check that the last match info has space for the capture registers and the | 11298 // Check that the last match info has space for the capture registers and the |
11299 // additional information. | 11299 // additional information. |
11300 __ mov(eax, FieldOperand(ebx, FixedArray::kLengthOffset)); | 11300 __ mov(eax, FieldOperand(ebx, FixedArray::kLengthOffset)); |
11301 __ SmiUntag(eax); | 11301 __ SmiUntag(eax); |
11302 __ add(Operand(edx), Immediate(RegExpImpl::kLastMatchOverhead)); | 11302 __ add(Operand(edx), Immediate(RegExpImpl::kLastMatchOverhead)); |
11303 __ cmp(edx, Operand(eax)); | 11303 __ cmp(edx, Operand(eax)); |
11304 __ j(greater, &runtime); | 11304 __ j(greater, &runtime); |
11305 | 11305 |
11306 // ecx: RegExp data (FixedArray) | 11306 // ecx: RegExp data (FixedArray) |
11307 // Check the representation and encoding of the subject string. | 11307 // Check the representation and encoding of the subject string. |
11308 Label seq_string, seq_two_byte_string, check_code; | 11308 Label seq_ascii_string, seq_two_byte_string, check_code; |
11309 const int kStringRepresentationEncodingMask = | |
11310 kIsNotStringMask | kStringRepresentationMask | kStringEncodingMask; | |
11311 __ mov(eax, Operand(esp, kSubjectOffset)); | 11309 __ mov(eax, Operand(esp, kSubjectOffset)); |
11312 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); | 11310 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); |
11313 __ movzx_b(ebx, FieldOperand(ebx, Map::kInstanceTypeOffset)); | 11311 __ movzx_b(ebx, FieldOperand(ebx, Map::kInstanceTypeOffset)); |
11314 __ and_(ebx, kStringRepresentationEncodingMask); | 11312 // First check for flat two byte string. |
11315 // First check for sequential string. | 11313 __ and_(ebx, |
11316 ASSERT_EQ(0, kStringTag); | 11314 kIsNotStringMask | kStringRepresentationMask | kStringEncodingMask); |
11317 ASSERT_EQ(0, kSeqStringTag); | 11315 ASSERT_EQ(0, kStringTag | kSeqStringTag | kTwoByteStringTag); |
| 11316 __ j(zero, &seq_two_byte_string); |
| 11317 // Any other flat string must be a flat ascii string. |
11318 __ test(Operand(ebx), | 11318 __ test(Operand(ebx), |
11319 Immediate(kIsNotStringMask | kStringRepresentationMask)); | 11319 Immediate(kIsNotStringMask | kStringRepresentationMask)); |
11320 __ j(zero, &seq_string); | 11320 __ j(zero, &seq_ascii_string); |
11321 | 11321 |
11322 // Check for flat cons string. | 11322 // Check for flat cons string. |
11323 // A flat cons string is a cons string where the second part is the empty | 11323 // A flat cons string is a cons string where the second part is the empty |
11324 // string. In that case the subject string is just the first part of the cons | 11324 // string. In that case the subject string is just the first part of the cons |
11325 // string. Also in this case the first part of the cons string is known to be | 11325 // string. Also in this case the first part of the cons string is known to be |
11326 // a sequential string or an external string. | 11326 // a sequential string or an external string. |
11327 __ and_(ebx, kStringRepresentationMask); | 11327 ASSERT(kExternalStringTag !=0); |
11328 __ cmp(ebx, kConsStringTag); | 11328 ASSERT_EQ(0, kConsStringTag & kExternalStringTag); |
11329 __ j(not_equal, &runtime); | 11329 __ test(Operand(ebx), |
| 11330 Immediate(kIsNotStringMask | kExternalStringTag)); |
| 11331 __ j(not_zero, &runtime); |
| 11332 // String is a cons string. |
11330 __ mov(edx, FieldOperand(eax, ConsString::kSecondOffset)); | 11333 __ mov(edx, FieldOperand(eax, ConsString::kSecondOffset)); |
11331 __ cmp(Operand(edx), Factory::empty_string()); | 11334 __ cmp(Operand(edx), Factory::empty_string()); |
11332 __ j(not_equal, &runtime); | 11335 __ j(not_equal, &runtime); |
11333 __ mov(eax, FieldOperand(eax, ConsString::kFirstOffset)); | 11336 __ mov(eax, FieldOperand(eax, ConsString::kFirstOffset)); |
11334 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); | 11337 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); |
11335 __ movzx_b(ebx, FieldOperand(ebx, Map::kInstanceTypeOffset)); | 11338 // String is a cons string with empty second part. |
11336 ASSERT_EQ(0, kSeqStringTag); | 11339 // eax: first part of cons string. |
11337 __ test(ebx, Immediate(kStringRepresentationMask)); | 11340 // ebx: map of first part of cons string. |
| 11341 // Is first part a flat two byte string? |
| 11342 __ test_b(FieldOperand(ebx, Map::kInstanceTypeOffset), |
| 11343 kStringRepresentationMask | kStringEncodingMask); |
| 11344 ASSERT_EQ(0, kSeqStringTag | kTwoByteStringTag); |
| 11345 __ j(zero, &seq_two_byte_string); |
| 11346 // Any other flat string must be ascii. |
| 11347 __ test_b(FieldOperand(ebx, Map::kInstanceTypeOffset), |
| 11348 kStringRepresentationMask); |
11338 __ j(not_zero, &runtime); | 11349 __ j(not_zero, &runtime); |
11339 __ and_(ebx, kStringRepresentationEncodingMask); | |
11340 | 11350 |
11341 __ bind(&seq_string); | 11351 __ bind(&seq_ascii_string); |
11342 // eax: subject string (sequential either ascii to two byte) | 11352 // eax: subject string (flat ascii) |
11343 // ebx: suject string type & kStringRepresentationEncodingMask | |
11344 // ecx: RegExp data (FixedArray) | 11353 // ecx: RegExp data (FixedArray) |
11345 // Check that the irregexp code has been generated for an ascii string. If | |
11346 // it has, the field contains a code object otherwise it contains the hole. | |
11347 const int kSeqTwoByteString = kStringTag | kSeqStringTag | kTwoByteStringTag; | |
11348 __ cmp(ebx, kSeqTwoByteString); | |
11349 __ j(equal, &seq_two_byte_string); | |
11350 if (FLAG_debug_code) { | |
11351 __ cmp(ebx, kStringTag | kSeqStringTag | kAsciiStringTag); | |
11352 __ Check(equal, "Expected sequential ascii string"); | |
11353 } | |
11354 __ mov(edx, FieldOperand(ecx, JSRegExp::kDataAsciiCodeOffset)); | 11354 __ mov(edx, FieldOperand(ecx, JSRegExp::kDataAsciiCodeOffset)); |
11355 __ Set(edi, Immediate(1)); // Type is ascii. | 11355 __ Set(edi, Immediate(1)); // Type is ascii. |
11356 __ jmp(&check_code); | 11356 __ jmp(&check_code); |
11357 | 11357 |
11358 __ bind(&seq_two_byte_string); | 11358 __ bind(&seq_two_byte_string); |
11359 // eax: subject string | 11359 // eax: subject string (flat two byte) |
11360 // ecx: RegExp data (FixedArray) | 11360 // ecx: RegExp data (FixedArray) |
11361 __ mov(edx, FieldOperand(ecx, JSRegExp::kDataUC16CodeOffset)); | 11361 __ mov(edx, FieldOperand(ecx, JSRegExp::kDataUC16CodeOffset)); |
11362 __ Set(edi, Immediate(0)); // Type is two byte. | 11362 __ Set(edi, Immediate(0)); // Type is two byte. |
11363 | 11363 |
11364 __ bind(&check_code); | 11364 __ bind(&check_code); |
11365 // Check that the irregexp code has been generated for the actual string | 11365 // Check that the irregexp code has been generated for the actual string |
11366 // encoding. If it has, the field contains a code object otherwise it contains | 11366 // encoding. If it has, the field contains a code object otherwise it contains |
11367 // the hole. | 11367 // the hole. |
11368 __ CmpObjectType(edx, CODE_TYPE, ebx); | 11368 __ CmpObjectType(edx, CODE_TYPE, ebx); |
11369 __ j(not_equal, &runtime); | 11369 __ j(not_equal, &runtime); |
(...skipping 1520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12890 Label non_ascii_string_add_flat_result; | 12890 Label non_ascii_string_add_flat_result; |
12891 ASSERT(kStringEncodingMask == kAsciiStringTag); | 12891 ASSERT(kStringEncodingMask == kAsciiStringTag); |
12892 __ mov(ecx, FieldOperand(eax, HeapObject::kMapOffset)); | 12892 __ mov(ecx, FieldOperand(eax, HeapObject::kMapOffset)); |
12893 __ test_b(FieldOperand(ecx, Map::kInstanceTypeOffset), kAsciiStringTag); | 12893 __ test_b(FieldOperand(ecx, Map::kInstanceTypeOffset), kAsciiStringTag); |
12894 __ j(zero, &non_ascii_string_add_flat_result); | 12894 __ j(zero, &non_ascii_string_add_flat_result); |
12895 __ mov(ecx, FieldOperand(edx, HeapObject::kMapOffset)); | 12895 __ mov(ecx, FieldOperand(edx, HeapObject::kMapOffset)); |
12896 __ test_b(FieldOperand(ecx, Map::kInstanceTypeOffset), kAsciiStringTag); | 12896 __ test_b(FieldOperand(ecx, Map::kInstanceTypeOffset), kAsciiStringTag); |
12897 __ j(zero, &string_add_runtime); | 12897 __ j(zero, &string_add_runtime); |
12898 | 12898 |
12899 __ bind(&make_flat_ascii_string); | 12899 __ bind(&make_flat_ascii_string); |
12900 // Both strings are ascii strings. As they are short they are both flat. | 12900 // Both strings are ascii strings. As they are short they are both flat. |
12901 // ebx: length of resulting flat string as a smi | 12901 // ebx: length of resulting flat string as a smi |
12902 __ SmiUntag(ebx); | 12902 __ SmiUntag(ebx); |
12903 __ AllocateAsciiString(eax, ebx, ecx, edx, edi, &string_add_runtime); | 12903 __ AllocateAsciiString(eax, ebx, ecx, edx, edi, &string_add_runtime); |
12904 // eax: result string | 12904 // eax: result string |
12905 __ mov(ecx, eax); | 12905 __ mov(ecx, eax); |
12906 // Locate first character of result. | 12906 // Locate first character of result. |
12907 __ add(Operand(ecx), Immediate(SeqAsciiString::kHeaderSize - kHeapObjectTag)); | 12907 __ add(Operand(ecx), Immediate(SeqAsciiString::kHeaderSize - kHeapObjectTag)); |
12908 // Load first argument and locate first character. | 12908 // Load first argument and locate first character. |
12909 __ mov(edx, Operand(esp, 2 * kPointerSize)); | 12909 __ mov(edx, Operand(esp, 2 * kPointerSize)); |
12910 __ mov(edi, FieldOperand(edx, String::kLengthOffset)); | 12910 __ mov(edi, FieldOperand(edx, String::kLengthOffset)); |
(...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13701 masm.GetCode(&desc); | 13701 masm.GetCode(&desc); |
13702 // Call the function from C++. | 13702 // Call the function from C++. |
13703 return FUNCTION_CAST<MemCopyFunction>(buffer); | 13703 return FUNCTION_CAST<MemCopyFunction>(buffer); |
13704 } | 13704 } |
13705 | 13705 |
13706 #undef __ | 13706 #undef __ |
13707 | 13707 |
13708 } } // namespace v8::internal | 13708 } } // namespace v8::internal |
13709 | 13709 |
13710 #endif // V8_TARGET_ARCH_IA32 | 13710 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |