| 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 7113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7124 __ JumpIfSmi(rax, &runtime); | 7124 __ JumpIfSmi(rax, &runtime); |
| 7125 Condition is_string = masm->IsObjectStringType(rax, rbx, rbx); | 7125 Condition is_string = masm->IsObjectStringType(rax, rbx, rbx); |
| 7126 __ j(NegateCondition(is_string), &runtime); | 7126 __ j(NegateCondition(is_string), &runtime); |
| 7127 // Get the length of the string to rbx. | 7127 // Get the length of the string to rbx. |
| 7128 __ movl(rbx, FieldOperand(rax, String::kLengthOffset)); | 7128 __ movl(rbx, FieldOperand(rax, String::kLengthOffset)); |
| 7129 | 7129 |
| 7130 // rbx: Length of subject string | 7130 // rbx: Length of subject string |
| 7131 // rcx: RegExp data (FixedArray) | 7131 // rcx: RegExp data (FixedArray) |
| 7132 // rdx: Number of capture registers | 7132 // rdx: Number of capture registers |
| 7133 // Check that the third argument is a positive smi less than the string | 7133 // Check that the third argument is a positive smi less than the string |
| 7134 // length. A negative value will be greater (usigned comparison). | 7134 // length. A negative value will be greater (unsigned comparison). |
| 7135 __ movq(rax, Operand(rsp, kPreviousIndexOffset)); | 7135 __ movq(rax, Operand(rsp, kPreviousIndexOffset)); |
| 7136 __ SmiToInteger32(rax, rax); | 7136 __ SmiToInteger32(rax, rax); |
| 7137 __ cmpl(rax, rbx); | 7137 __ cmpl(rax, rbx); |
| 7138 __ j(above, &runtime); | 7138 __ j(above, &runtime); |
| 7139 | 7139 |
| 7140 // rcx: RegExp data (FixedArray) | 7140 // rcx: RegExp data (FixedArray) |
| 7141 // rdx: Number of capture registers | 7141 // rdx: Number of capture registers |
| 7142 // Check that the fourth object is a JSArray object. | 7142 // Check that the fourth object is a JSArray object. |
| 7143 __ movq(rax, Operand(rsp, kLastMatchInfoOffset)); | 7143 __ movq(rax, Operand(rsp, kLastMatchInfoOffset)); |
| 7144 __ JumpIfSmi(rax, &runtime); | 7144 __ JumpIfSmi(rax, &runtime); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 7170 ASSERT_EQ(0, kStringTag); | 7170 ASSERT_EQ(0, kStringTag); |
| 7171 ASSERT_EQ(0, kSeqStringTag); | 7171 ASSERT_EQ(0, kSeqStringTag); |
| 7172 __ testb(rbx, Immediate(kIsNotStringMask | kStringRepresentationMask)); | 7172 __ testb(rbx, Immediate(kIsNotStringMask | kStringRepresentationMask)); |
| 7173 __ j(zero, &seq_string); | 7173 __ j(zero, &seq_string); |
| 7174 | 7174 |
| 7175 // Check for flat cons string. | 7175 // Check for flat cons string. |
| 7176 // A flat cons string is a cons string where the second part is the empty | 7176 // A flat cons string is a cons string where the second part is the empty |
| 7177 // string. In that case the subject string is just the first part of the cons | 7177 // string. In that case the subject string is just the first part of the cons |
| 7178 // string. Also in this case the first part of the cons string is known to be | 7178 // string. Also in this case the first part of the cons string is known to be |
| 7179 // a sequential string or an external string. | 7179 // a sequential string or an external string. |
| 7180 __ movl(rdx, rbx); | 7180 __ andb(rbx, Immediate(kStringRepresentationMask)); |
| 7181 __ andb(rdx, Immediate(kStringRepresentationMask)); | 7181 __ cmpb(rbx, Immediate(kConsStringTag)); |
| 7182 __ cmpb(rdx, Immediate(kConsStringTag)); | |
| 7183 __ j(not_equal, &runtime); | 7182 __ j(not_equal, &runtime); |
| 7184 __ movq(rdx, FieldOperand(rax, ConsString::kSecondOffset)); | 7183 __ movq(rdx, FieldOperand(rax, ConsString::kSecondOffset)); |
| 7185 __ Cmp(rdx, Factory::empty_string()); | 7184 __ Cmp(rdx, Factory::empty_string()); |
| 7186 __ j(not_equal, &runtime); | 7185 __ j(not_equal, &runtime); |
| 7187 __ movq(rax, FieldOperand(rax, ConsString::kFirstOffset)); | 7186 __ movq(rax, FieldOperand(rax, ConsString::kFirstOffset)); |
| 7188 __ movq(rbx, FieldOperand(rax, HeapObject::kMapOffset)); | 7187 __ movq(rbx, FieldOperand(rax, HeapObject::kMapOffset)); |
| 7189 __ movzxbl(rbx, FieldOperand(rbx, Map::kInstanceTypeOffset)); | 7188 __ movzxbl(rbx, FieldOperand(rbx, Map::kInstanceTypeOffset)); |
| 7190 ASSERT_EQ(0, kSeqStringTag); | 7189 ASSERT_EQ(0, kSeqStringTag); |
| 7191 __ testb(rbx, Immediate(kStringRepresentationMask)); | 7190 __ testb(rbx, Immediate(kStringRepresentationMask)); |
| 7192 __ j(not_zero, &runtime); | 7191 __ j(not_zero, &runtime); |
| 7193 __ andb(rbx, Immediate(kStringRepresentationEncodingMask)); | 7192 __ andb(rbx, Immediate(kStringRepresentationEncodingMask)); |
| 7194 | 7193 |
| 7195 __ bind(&seq_string); | 7194 __ bind(&seq_string); |
| 7196 // rax: subject string (sequential either ascii to two byte) | 7195 // rax: subject string (sequential either ascii to two byte) |
| 7197 // rbx: suject string type & kStringRepresentationEncodingMask | 7196 // rbx: suject string type & kStringRepresentationEncodingMask |
| 7198 // rcx: RegExp data (FixedArray) | 7197 // rcx: RegExp data (FixedArray) |
| 7199 // Check that the irregexp code has been generated for an ascii string. If | 7198 // Check that the irregexp code has been generated for an ascii string. If |
| 7200 // it has, the field contains a code object otherwise it contains the hole. | 7199 // it has, the field contains a code object otherwise it contains the hole. |
| 7201 __ cmpb(rbx, Immediate(kStringTag | kSeqStringTag | kTwoByteStringTag)); | 7200 const int kSeqTwoByteString = kStringTag | kSeqStringTag | kTwoByteStringTag; |
| 7201 __ cmpb(rbx, Immediate(kSeqTwoByteString)); |
| 7202 __ j(equal, &seq_two_byte_string); | 7202 __ j(equal, &seq_two_byte_string); |
| 7203 if (FLAG_debug_code) { | 7203 if (FLAG_debug_code) { |
| 7204 __ cmpb(rbx, Immediate(kStringTag | kSeqStringTag | kAsciiStringTag)); | 7204 __ cmpb(rbx, Immediate(kStringTag | kSeqStringTag | kAsciiStringTag)); |
| 7205 __ Check(equal, "Expected sequential ascii string"); | 7205 __ Check(equal, "Expected sequential ascii string"); |
| 7206 } | 7206 } |
| 7207 __ movq(r12, FieldOperand(rcx, JSRegExp::kDataAsciiCodeOffset)); | 7207 __ movq(r12, FieldOperand(rcx, JSRegExp::kDataAsciiCodeOffset)); |
| 7208 __ Set(rdi, 1); // Type is ascii. | 7208 __ Set(rdi, 1); // Type is ascii. |
| 7209 __ jmp(&check_code); | 7209 __ jmp(&check_code); |
| 7210 | 7210 |
| 7211 __ bind(&seq_two_byte_string); | 7211 __ bind(&seq_two_byte_string); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7317 __ j(equal, &success); | 7317 __ j(equal, &success); |
| 7318 Label failure; | 7318 Label failure; |
| 7319 __ cmpq(rax, Immediate(NativeRegExpMacroAssembler::FAILURE)); | 7319 __ cmpq(rax, Immediate(NativeRegExpMacroAssembler::FAILURE)); |
| 7320 __ j(equal, &failure); | 7320 __ j(equal, &failure); |
| 7321 __ cmpq(rax, Immediate(NativeRegExpMacroAssembler::EXCEPTION)); | 7321 __ cmpq(rax, Immediate(NativeRegExpMacroAssembler::EXCEPTION)); |
| 7322 // If not exception it can only be retry. Handle that in the runtime system. | 7322 // If not exception it can only be retry. Handle that in the runtime system. |
| 7323 __ j(not_equal, &runtime); | 7323 __ j(not_equal, &runtime); |
| 7324 // Result must now be exception. If there is no pending exception already a | 7324 // Result must now be exception. If there is no pending exception already a |
| 7325 // stack overflow (on the backtrack stack) was detected in RegExp code but | 7325 // stack overflow (on the backtrack stack) was detected in RegExp code but |
| 7326 // haven't created the exception yet. Handle that in the runtime system. | 7326 // haven't created the exception yet. Handle that in the runtime system. |
| 7327 // TODO(592) Rerunning the RegExp to get the stack overflow exception. | 7327 // TODO(592): Rerunning the RegExp to get the stack overflow exception. |
| 7328 ExternalReference pending_exception_address(Top::k_pending_exception_address); | 7328 ExternalReference pending_exception_address(Top::k_pending_exception_address); |
| 7329 __ movq(kScratchRegister, pending_exception_address); | 7329 __ movq(kScratchRegister, pending_exception_address); |
| 7330 __ Cmp(kScratchRegister, Factory::the_hole_value()); | 7330 __ Cmp(kScratchRegister, Factory::the_hole_value()); |
| 7331 __ j(equal, &runtime); | 7331 __ j(equal, &runtime); |
| 7332 __ bind(&failure); | 7332 __ bind(&failure); |
| 7333 // For failure and exception return null. | 7333 // For failure and exception return null. |
| 7334 __ Move(rax, Factory::null_value()); | 7334 __ Move(rax, Factory::null_value()); |
| 7335 __ ret(4 * kPointerSize); | 7335 __ ret(4 * kPointerSize); |
| 7336 | 7336 |
| 7337 // Load RegExp data. | 7337 // Load RegExp data. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 7364 __ movq(rcx, rbx); | 7364 __ movq(rcx, rbx); |
| 7365 __ RecordWrite(rcx, RegExpImpl::kLastInputOffset, rax, rdi); | 7365 __ RecordWrite(rcx, RegExpImpl::kLastInputOffset, rax, rdi); |
| 7366 | 7366 |
| 7367 // Get the static offsets vector filled by the native regexp code. | 7367 // Get the static offsets vector filled by the native regexp code. |
| 7368 __ movq(rcx, ExternalReference::address_of_static_offsets_vector()); | 7368 __ movq(rcx, ExternalReference::address_of_static_offsets_vector()); |
| 7369 | 7369 |
| 7370 // rbx: last_match_info backing store (FixedArray) | 7370 // rbx: last_match_info backing store (FixedArray) |
| 7371 // rcx: offsets vector | 7371 // rcx: offsets vector |
| 7372 // rdx: number of capture registers | 7372 // rdx: number of capture registers |
| 7373 Label next_capture, done; | 7373 Label next_capture, done; |
| 7374 __ movq(rax, Operand(rsp, kPreviousIndexOffset)); | |
| 7375 // Capture register counter starts from number of capture registers and | 7374 // Capture register counter starts from number of capture registers and |
| 7376 // counts down until wraping after zero. | 7375 // counts down until wraping after zero. |
| 7377 __ bind(&next_capture); | 7376 __ bind(&next_capture); |
| 7378 __ subq(rdx, Immediate(1)); | 7377 __ subq(rdx, Immediate(1)); |
| 7379 __ j(negative, &done); | 7378 __ j(negative, &done); |
| 7380 // Read the value from the static offsets vector buffer and make it a smi. | 7379 // Read the value from the static offsets vector buffer and make it a smi. |
| 7381 __ movl(rdi, Operand(rcx, rdx, times_int_size, 0)); | 7380 __ movl(rdi, Operand(rcx, rdx, times_int_size, 0)); |
| 7382 __ Integer32ToSmi(rdi, rdi, &runtime); | 7381 __ Integer32ToSmi(rdi, rdi, &runtime); |
| 7383 // Store the smi value in the last match info. | 7382 // Store the smi value in the last match info. |
| 7384 __ movq(FieldOperand(rbx, | 7383 __ movq(FieldOperand(rbx, |
| (...skipping 2781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10166 // Call the function from C++. | 10165 // Call the function from C++. |
| 10167 return FUNCTION_CAST<ModuloFunction>(buffer); | 10166 return FUNCTION_CAST<ModuloFunction>(buffer); |
| 10168 } | 10167 } |
| 10169 | 10168 |
| 10170 #endif | 10169 #endif |
| 10171 | 10170 |
| 10172 | 10171 |
| 10173 #undef __ | 10172 #undef __ |
| 10174 | 10173 |
| 10175 } } // namespace v8::internal | 10174 } } // namespace v8::internal |
| OLD | NEW |