OLD | NEW |
---|---|
1 // Copyright 2011 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 |
(...skipping 4321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4332 __ cmp(r0, ip); | 4332 __ cmp(r0, ip); |
4333 __ b(ne, &runtime); | 4333 __ b(ne, &runtime); |
4334 // Check that the last match info has space for the capture registers and the | 4334 // Check that the last match info has space for the capture registers and the |
4335 // additional information. | 4335 // additional information. |
4336 __ ldr(r0, | 4336 __ ldr(r0, |
4337 FieldMemOperand(last_match_info_elements, FixedArray::kLengthOffset)); | 4337 FieldMemOperand(last_match_info_elements, FixedArray::kLengthOffset)); |
4338 __ add(r2, r2, Operand(RegExpImpl::kLastMatchOverhead)); | 4338 __ add(r2, r2, Operand(RegExpImpl::kLastMatchOverhead)); |
4339 __ cmp(r2, Operand(r0, ASR, kSmiTagSize)); | 4339 __ cmp(r2, Operand(r0, ASR, kSmiTagSize)); |
4340 __ b(gt, &runtime); | 4340 __ b(gt, &runtime); |
4341 | 4341 |
4342 // Reset offset for possibly sliced string. | |
4343 __ mov(r9, Operand(0)); | |
antonm
2011/08/25 12:04:36
does it belong here? maybe move it int
Yang
2011/08/25 13:40:03
This is right before branching off depending on st
| |
4342 // subject: Subject string | 4344 // subject: Subject string |
4343 // regexp_data: RegExp data (FixedArray) | 4345 // regexp_data: RegExp data (FixedArray) |
4344 // Check the representation and encoding of the subject string. | 4346 // Check the representation and encoding of the subject string. |
4345 Label seq_string; | 4347 Label seq_string; |
4346 __ ldr(r0, FieldMemOperand(subject, HeapObject::kMapOffset)); | 4348 __ ldr(r0, FieldMemOperand(subject, HeapObject::kMapOffset)); |
4347 __ ldrb(r0, FieldMemOperand(r0, Map::kInstanceTypeOffset)); | 4349 __ ldrb(r0, FieldMemOperand(r0, Map::kInstanceTypeOffset)); |
4348 // First check for flat string. | 4350 // First check for flat string. |
4349 __ tst(r0, Operand(kIsNotStringMask | kStringRepresentationMask)); | 4351 __ and_(r1, r0, Operand(kIsNotStringMask | kStringRepresentationMask), SetCC); |
4350 STATIC_ASSERT((kStringTag | kSeqStringTag) == 0); | 4352 STATIC_ASSERT((kStringTag | kSeqStringTag) == 0); |
4351 __ b(eq, &seq_string); | 4353 __ b(eq, &seq_string); |
4352 | 4354 |
4353 // subject: Subject string | 4355 // subject: Subject string |
4354 // regexp_data: RegExp data (FixedArray) | 4356 // regexp_data: RegExp data (FixedArray) |
4355 // Check for flat cons string. | 4357 // Check for flat cons string or sliced string. |
4356 // A flat cons string is a cons string where the second part is the empty | 4358 // A flat cons string is a cons string where the second part is the empty |
4357 // string. In that case the subject string is just the first part of the cons | 4359 // string. In that case the subject string is just the first part of the cons |
4358 // string. Also in this case the first part of the cons string is known to be | 4360 // string. Also in this case the first part of the cons string is known to be |
4359 // a sequential string or an external string. | 4361 // a sequential string or an external string. |
4360 STATIC_ASSERT(kExternalStringTag !=0); | 4362 // In the case of a sliced string its offset has to be taken into account. |
4361 STATIC_ASSERT((kConsStringTag & kExternalStringTag) == 0); | 4363 Label cons_string, check_encoding; |
4362 __ tst(r0, Operand(kIsNotStringMask | kExternalStringTag)); | 4364 __ cmp(r1, Operand(kConsStringTag)); |
4365 __ b(eq, &cons_string); | |
4366 __ cmp(r1, Operand(kSlicedStringTag)); | |
4367 // If subject is not a sliced string, it can only be a non-string or an | |
4368 // external string. | |
4363 __ b(ne, &runtime); | 4369 __ b(ne, &runtime); |
4370 // String is sliced. | |
4371 __ ldr(r9, FieldMemOperand(subject, SlicedString::kOffsetOffset)); | |
4372 __ mov(r9, Operand(r9, ASR, kSmiTagSize)); | |
4373 __ ldr(subject, FieldMemOperand(subject, SlicedString::kParentOffset)); | |
4374 // r9: offset of sliced string, smi-tagged. | |
4375 __ jmp(&check_encoding); | |
4376 // String is a cons string, check whether it is flat. | |
4377 __ bind(&cons_string); | |
4364 __ ldr(r0, FieldMemOperand(subject, ConsString::kSecondOffset)); | 4378 __ ldr(r0, FieldMemOperand(subject, ConsString::kSecondOffset)); |
4365 __ LoadRoot(r1, Heap::kEmptyStringRootIndex); | 4379 __ LoadRoot(r1, Heap::kEmptyStringRootIndex); |
4366 __ cmp(r0, r1); | 4380 __ cmp(r0, r1); |
4367 __ b(ne, &runtime); | 4381 __ b(ne, &runtime); |
4368 __ ldr(subject, FieldMemOperand(subject, ConsString::kFirstOffset)); | 4382 __ ldr(subject, FieldMemOperand(subject, ConsString::kFirstOffset)); |
4383 // Is first part of cons or parent of slice a flat string? | |
4384 __ bind(&check_encoding); | |
4369 __ ldr(r0, FieldMemOperand(subject, HeapObject::kMapOffset)); | 4385 __ ldr(r0, FieldMemOperand(subject, HeapObject::kMapOffset)); |
4370 __ ldrb(r0, FieldMemOperand(r0, Map::kInstanceTypeOffset)); | 4386 __ ldrb(r0, FieldMemOperand(r0, Map::kInstanceTypeOffset)); |
4371 // Is first part a flat string? | |
4372 STATIC_ASSERT(kSeqStringTag == 0); | 4387 STATIC_ASSERT(kSeqStringTag == 0); |
4373 __ tst(r0, Operand(kStringRepresentationMask)); | 4388 __ tst(r0, Operand(kStringRepresentationMask)); |
4374 __ b(ne, &runtime); | 4389 __ b(ne, &runtime); |
4375 | |
4376 __ bind(&seq_string); | 4390 __ bind(&seq_string); |
4377 // subject: Subject string | 4391 // subject: Subject string |
4378 // regexp_data: RegExp data (FixedArray) | 4392 // regexp_data: RegExp data (FixedArray) |
4379 // r0: Instance type of subject string | 4393 // r0: Instance type of subject string |
4380 STATIC_ASSERT(4 == kAsciiStringTag); | 4394 STATIC_ASSERT(4 == kAsciiStringTag); |
4381 STATIC_ASSERT(kTwoByteStringTag == 0); | 4395 STATIC_ASSERT(kTwoByteStringTag == 0); |
4382 // Find the code object based on the assumptions above. | 4396 // Find the code object based on the assumptions above. |
4383 __ and_(r0, r0, Operand(kStringEncodingMask)); | 4397 __ and_(r0, r0, Operand(kStringEncodingMask)); |
4384 __ mov(r3, Operand(r0, ASR, 2), SetCC); | 4398 __ mov(r3, Operand(r0, ASR, 2), SetCC); |
4385 __ ldr(r7, FieldMemOperand(regexp_data, JSRegExp::kDataAsciiCodeOffset), ne); | 4399 __ ldr(r7, FieldMemOperand(regexp_data, JSRegExp::kDataAsciiCodeOffset), ne); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4431 __ add(r0, r0, Operand(r2)); | 4445 __ add(r0, r0, Operand(r2)); |
4432 __ str(r0, MemOperand(sp, 2 * kPointerSize)); | 4446 __ str(r0, MemOperand(sp, 2 * kPointerSize)); |
4433 | 4447 |
4434 // Argument 5 (sp[4]): static offsets vector buffer. | 4448 // Argument 5 (sp[4]): static offsets vector buffer. |
4435 __ mov(r0, | 4449 __ mov(r0, |
4436 Operand(ExternalReference::address_of_static_offsets_vector(isolate))); | 4450 Operand(ExternalReference::address_of_static_offsets_vector(isolate))); |
4437 __ str(r0, MemOperand(sp, 1 * kPointerSize)); | 4451 __ str(r0, MemOperand(sp, 1 * kPointerSize)); |
4438 | 4452 |
4439 // For arguments 4 and 3 get string length, calculate start of string data and | 4453 // For arguments 4 and 3 get string length, calculate start of string data and |
4440 // calculate the shift of the index (0 for ASCII and 1 for two byte). | 4454 // calculate the shift of the index (0 for ASCII and 1 for two byte). |
4441 __ ldr(r0, FieldMemOperand(subject, String::kLengthOffset)); | |
4442 __ mov(r0, Operand(r0, ASR, kSmiTagSize)); | |
4443 STATIC_ASSERT(SeqAsciiString::kHeaderSize == SeqTwoByteString::kHeaderSize); | 4455 STATIC_ASSERT(SeqAsciiString::kHeaderSize == SeqTwoByteString::kHeaderSize); |
4444 __ add(r9, subject, Operand(SeqAsciiString::kHeaderSize - kHeapObjectTag)); | 4456 __ add(r8, subject, Operand(SeqAsciiString::kHeaderSize - kHeapObjectTag)); |
antonm
2011/08/25 12:04:36
Apparently if you do:
__ add(r8, subject, Operand
| |
4445 __ eor(r3, r3, Operand(1)); | 4457 __ eor(r3, r3, Operand(1)); |
4446 // Argument 4 (r3): End of string data | 4458 // Load the length from the original subject string from the previous stack |
4447 // Argument 3 (r2): Start of string data | 4459 // frame. Therefore we have to use fp, which points exactly to two pointer |
4448 __ add(r2, r9, Operand(r1, LSL, r3)); | 4460 // sizes below the previous sp. (Because creating a new stack frame pushes |
4449 __ add(r3, r9, Operand(r0, LSL, r3)); | 4461 // the previous fp onto the stack and thereby moves up sp by 2*kPointerSize.) |
4462 __ ldr(r0, MemOperand(fp, kSubjectOffset + 2*kPointerSize)); | |
antonm
2011/08/25 12:04:36
nit: spaces around * (and in comment)
antonm
2011/08/25 12:04:36
this looks complicated to me. Cannot you thread o
Yang
2011/08/25 13:40:03
I tried, but r0 - r7 are used to pass arguments an
| |
4463 // If slice offset is not 0, load the length from the original sliced string. | |
antonm
2011/08/25 12:04:36
I don't see any conditional logic below.
Yang
2011/08/25 13:40:03
The condition is saved into r3. r3==1 if twobyte a
| |
4464 // Argument 4, r3: End of string data | |
4465 // Argument 3, r2: Start of string data | |
4466 // Prepare start and end index of the input. | |
4467 __ add(r2, r8, Operand(r9, LSL, r3)); | |
4468 __ add(r2, r2, Operand(r1, LSL, r3)); | |
4469 | |
4470 __ add(r8, r8, Operand(r9, LSL, r3)); | |
4471 __ ldr(r9, FieldMemOperand(r0, String::kLengthOffset)); | |
4472 __ mov(r9, Operand(r9, ASR, kSmiTagSize)); | |
4473 __ add(r3, r8, Operand(r9, LSL, r3)); | |
4450 | 4474 |
4451 // Argument 2 (r1): Previous index. | 4475 // Argument 2 (r1): Previous index. |
4452 // Already there | 4476 // Already there |
4453 | 4477 |
4454 // Argument 1 (r0): Subject string. | 4478 // Argument 1 (r0): Subject string. |
4455 __ mov(r0, subject); | 4479 // Already there |
4456 | 4480 |
4457 // Locate the code entry and call it. | 4481 // Locate the code entry and call it. |
4458 __ add(r7, r7, Operand(Code::kHeaderSize - kHeapObjectTag)); | 4482 __ add(r7, r7, Operand(Code::kHeaderSize - kHeapObjectTag)); |
4459 DirectCEntryStub stub; | 4483 DirectCEntryStub stub; |
4460 stub.GenerateCall(masm, r7); | 4484 stub.GenerateCall(masm, r7); |
4461 | 4485 |
4462 __ LeaveExitFrame(false, no_reg); | 4486 __ LeaveExitFrame(false, no_reg); |
4463 | 4487 |
4464 // r0: result | 4488 // r0: result |
4465 // subject: subject string (callee saved) | 4489 // subject: subject string (callee saved) |
4466 // regexp_data: RegExp data (callee saved) | 4490 // regexp_data: RegExp data (callee saved) |
4467 // last_match_info_elements: Last match info elements (callee saved) | 4491 // last_match_info_elements: Last match info elements (callee saved) |
4468 | 4492 |
4469 // Check the result. | 4493 // Check the result. |
4470 Label success; | 4494 Label success; |
4471 | 4495 |
4472 __ cmp(r0, Operand(NativeRegExpMacroAssembler::SUCCESS)); | 4496 __ cmp(subject, Operand(NativeRegExpMacroAssembler::SUCCESS)); |
4473 __ b(eq, &success); | 4497 __ b(eq, &success); |
4474 Label failure; | 4498 Label failure; |
4475 __ cmp(r0, Operand(NativeRegExpMacroAssembler::FAILURE)); | 4499 __ cmp(subject, Operand(NativeRegExpMacroAssembler::FAILURE)); |
4476 __ b(eq, &failure); | 4500 __ b(eq, &failure); |
4477 __ cmp(r0, Operand(NativeRegExpMacroAssembler::EXCEPTION)); | 4501 __ cmp(subject, Operand(NativeRegExpMacroAssembler::EXCEPTION)); |
4478 // If not exception it can only be retry. Handle that in the runtime system. | 4502 // If not exception it can only be retry. Handle that in the runtime system. |
4479 __ b(ne, &runtime); | 4503 __ b(ne, &runtime); |
4480 // Result must now be exception. If there is no pending exception already a | 4504 // Result must now be exception. If there is no pending exception already a |
4481 // stack overflow (on the backtrack stack) was detected in RegExp code but | 4505 // stack overflow (on the backtrack stack) was detected in RegExp code but |
4482 // haven't created the exception yet. Handle that in the runtime system. | 4506 // haven't created the exception yet. Handle that in the runtime system. |
4483 // TODO(592): Rerunning the RegExp to get the stack overflow exception. | 4507 // TODO(592): Rerunning the RegExp to get the stack overflow exception. |
4484 __ mov(r1, Operand(ExternalReference::the_hole_value_location(isolate))); | 4508 __ mov(r1, Operand(ExternalReference::the_hole_value_location(isolate))); |
4485 __ ldr(r1, MemOperand(r1, 0)); | 4509 __ ldr(r1, MemOperand(r1, 0)); |
4486 __ mov(r2, Operand(ExternalReference(Isolate::k_pending_exception_address, | 4510 __ mov(r2, Operand(ExternalReference(Isolate::k_pending_exception_address, |
4487 isolate))); | 4511 isolate))); |
4488 __ ldr(r0, MemOperand(r2, 0)); | 4512 __ ldr(r0, MemOperand(r2, 0)); |
4489 __ cmp(r0, r1); | 4513 __ cmp(subject, r1); |
4490 __ b(eq, &runtime); | 4514 __ b(eq, &runtime); |
4491 | 4515 |
4492 __ str(r1, MemOperand(r2, 0)); // Clear pending exception. | 4516 __ str(r1, MemOperand(r2, 0)); // Clear pending exception. |
4493 | 4517 |
4494 // Check if the exception is a termination. If so, throw as uncatchable. | 4518 // Check if the exception is a termination. If so, throw as uncatchable. |
4495 __ LoadRoot(ip, Heap::kTerminationExceptionRootIndex); | 4519 __ LoadRoot(ip, Heap::kTerminationExceptionRootIndex); |
4496 __ cmp(r0, ip); | 4520 __ cmp(subject, ip); |
4497 Label termination_exception; | 4521 Label termination_exception; |
4498 __ b(eq, &termination_exception); | 4522 __ b(eq, &termination_exception); |
4499 | 4523 |
4500 __ Throw(r0); // Expects thrown value in r0. | 4524 __ Throw(subject); // Expects thrown value in r0. |
4501 | 4525 |
4502 __ bind(&termination_exception); | 4526 __ bind(&termination_exception); |
4503 __ ThrowUncatchable(TERMINATION, r0); // Expects thrown value in r0. | 4527 __ ThrowUncatchable(TERMINATION, r0); // Expects thrown value in r0. |
4504 | 4528 |
4505 __ bind(&failure); | 4529 __ bind(&failure); |
4506 // For failure and exception return null. | 4530 // For failure and exception return null. |
4507 __ mov(r0, Operand(masm->isolate()->factory()->null_value())); | 4531 __ mov(r0, Operand(masm->isolate()->factory()->null_value())); |
4508 __ add(sp, sp, Operand(4 * kPointerSize)); | 4532 __ add(sp, sp, Operand(4 * kPointerSize)); |
4509 __ Ret(); | 4533 __ Ret(); |
4510 | 4534 |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4768 | IncludeNumberCompareField::encode(include_number_compare_) | 4792 | IncludeNumberCompareField::encode(include_number_compare_) |
4769 | IncludeSmiCompareField::encode(include_smi_compare_); | 4793 | IncludeSmiCompareField::encode(include_smi_compare_); |
4770 } | 4794 } |
4771 | 4795 |
4772 | 4796 |
4773 // StringCharCodeAtGenerator | 4797 // StringCharCodeAtGenerator |
4774 void StringCharCodeAtGenerator::GenerateFast(MacroAssembler* masm) { | 4798 void StringCharCodeAtGenerator::GenerateFast(MacroAssembler* masm) { |
4775 Label flat_string; | 4799 Label flat_string; |
4776 Label ascii_string; | 4800 Label ascii_string; |
4777 Label got_char_code; | 4801 Label got_char_code; |
4802 Label sliced_string; | |
4778 | 4803 |
4779 // If the receiver is a smi trigger the non-string case. | 4804 // If the receiver is a smi trigger the non-string case. |
4780 __ JumpIfSmi(object_, receiver_not_string_); | 4805 __ JumpIfSmi(object_, receiver_not_string_); |
4781 | 4806 |
4782 // Fetch the instance type of the receiver into result register. | 4807 // Fetch the instance type of the receiver into result register. |
4783 __ ldr(result_, FieldMemOperand(object_, HeapObject::kMapOffset)); | 4808 __ ldr(result_, FieldMemOperand(object_, HeapObject::kMapOffset)); |
4784 __ ldrb(result_, FieldMemOperand(result_, Map::kInstanceTypeOffset)); | 4809 __ ldrb(result_, FieldMemOperand(result_, Map::kInstanceTypeOffset)); |
4785 // If the receiver is not a string trigger the non-string case. | 4810 // If the receiver is not a string trigger the non-string case. |
4786 __ tst(result_, Operand(kIsNotStringMask)); | 4811 __ tst(result_, Operand(kIsNotStringMask)); |
4787 __ b(ne, receiver_not_string_); | 4812 __ b(ne, receiver_not_string_); |
4788 | 4813 |
4789 // If the index is non-smi trigger the non-smi case. | 4814 // If the index is non-smi trigger the non-smi case. |
4790 __ JumpIfNotSmi(index_, &index_not_smi_); | 4815 __ JumpIfNotSmi(index_, &index_not_smi_); |
4791 | 4816 |
4792 // Put smi-tagged index into scratch register. | 4817 // Put smi-tagged index into scratch register. |
4793 __ mov(scratch_, index_); | 4818 __ mov(scratch_, index_); |
4794 __ bind(&got_smi_index_); | 4819 __ bind(&got_smi_index_); |
4795 | 4820 |
4796 // Check for index out of range. | 4821 // Check for index out of range. |
4797 __ ldr(ip, FieldMemOperand(object_, String::kLengthOffset)); | 4822 __ ldr(ip, FieldMemOperand(object_, String::kLengthOffset)); |
4798 __ cmp(ip, Operand(scratch_)); | 4823 __ cmp(ip, Operand(scratch_)); |
4799 __ b(ls, index_out_of_range_); | 4824 __ b(ls, index_out_of_range_); |
4800 | 4825 |
4801 // We need special handling for non-flat strings. | 4826 // We need special handling for non-flat strings. |
4802 STATIC_ASSERT(kSeqStringTag == 0); | 4827 STATIC_ASSERT(kSeqStringTag == 0); |
4803 __ tst(result_, Operand(kStringRepresentationMask)); | 4828 __ tst(result_, Operand(kStringRepresentationMask)); |
4804 __ b(eq, &flat_string); | 4829 __ b(eq, &flat_string); |
4805 | 4830 |
4806 // Handle non-flat strings. | 4831 // Handle non-flat strings. |
4807 __ tst(result_, Operand(kIsConsStringMask)); | 4832 __ and_(result_, result_, Operand(kStringRepresentationMask)); |
4833 __ cmp(result_, Operand(kSlicedStringTag)); | |
4834 __ b(eq, &sliced_string); | |
4835 __ cmp(result_, Operand(kExternalStringTag)); | |
4808 __ b(eq, &call_runtime_); | 4836 __ b(eq, &call_runtime_); |
4809 | 4837 |
4810 // ConsString. | 4838 // ConsString. |
4811 // Check whether the right hand side is the empty string (i.e. if | 4839 // Check whether the right hand side is the empty string (i.e. if |
4812 // this is really a flat string in a cons string). If that is not | 4840 // this is really a flat string in a cons string). If that is not |
4813 // the case we would rather go to the runtime system now to flatten | 4841 // the case we would rather go to the runtime system now to flatten |
4814 // the string. | 4842 // the string. |
4815 __ ldr(result_, FieldMemOperand(object_, ConsString::kSecondOffset)); | 4843 __ ldr(result_, FieldMemOperand(object_, ConsString::kSecondOffset)); |
4816 __ LoadRoot(ip, Heap::kEmptyStringRootIndex); | 4844 __ LoadRoot(ip, Heap::kEmptyStringRootIndex); |
4817 __ cmp(result_, Operand(ip)); | 4845 __ cmp(result_, Operand(ip)); |
4818 __ b(ne, &call_runtime_); | 4846 __ b(ne, &call_runtime_); |
4819 // Get the first of the two strings and load its instance type. | 4847 // Get the first of the two strings and load its instance type. |
4820 __ ldr(object_, FieldMemOperand(object_, ConsString::kFirstOffset)); | 4848 __ ldr(object_, FieldMemOperand(object_, ConsString::kFirstOffset)); |
4821 __ ldr(result_, FieldMemOperand(object_, HeapObject::kMapOffset)); | 4849 __ ldr(result_, FieldMemOperand(object_, HeapObject::kMapOffset)); |
4822 __ ldrb(result_, FieldMemOperand(result_, Map::kInstanceTypeOffset)); | 4850 __ ldrb(result_, FieldMemOperand(result_, Map::kInstanceTypeOffset)); |
4823 // If the first cons component is also non-flat, then go to runtime. | 4851 // If the first cons component is also non-flat, then go to runtime. |
4824 STATIC_ASSERT(kSeqStringTag == 0); | 4852 STATIC_ASSERT(kSeqStringTag == 0); |
4825 __ tst(result_, Operand(kStringRepresentationMask)); | 4853 __ tst(result_, Operand(kStringRepresentationMask)); |
4826 __ b(ne, &call_runtime_); | 4854 __ b(ne, &call_runtime_); |
4855 __ jmp(&flat_string); | |
4856 | |
4857 // SlicedString, unpack and add offset. | |
4858 __ bind(&sliced_string); | |
4859 __ ldr(result_, FieldMemOperand(object_, SlicedString::kOffsetOffset)); | |
4860 __ add(scratch_, scratch_, result_); | |
4861 __ ldr(object_, FieldMemOperand(object_, SlicedString::kParentOffset)); | |
4862 __ ldr(result_, FieldMemOperand(object_, HeapObject::kMapOffset)); | |
4863 __ ldrb(result_, FieldMemOperand(result_, Map::kInstanceTypeOffset)); | |
antonm
2011/08/25 12:04:36
might be worth asserting that result_ is a flat st
| |
4827 | 4864 |
4828 // Check for 1-byte or 2-byte string. | 4865 // Check for 1-byte or 2-byte string. |
4829 __ bind(&flat_string); | 4866 __ bind(&flat_string); |
4830 STATIC_ASSERT(kAsciiStringTag != 0); | 4867 STATIC_ASSERT(kAsciiStringTag != 0); |
4831 __ tst(result_, Operand(kStringEncodingMask)); | 4868 __ tst(result_, Operand(kStringEncodingMask)); |
4832 __ b(ne, &ascii_string); | 4869 __ b(ne, &ascii_string); |
4833 | 4870 |
4834 // 2-byte string. | 4871 // 2-byte string. |
4835 // Load the 2-byte character code into the result register. We can | 4872 // Load the 2-byte character code into the result register. We can |
4836 // add without shifting since the smi tag size is the log2 of the | 4873 // add without shifting since the smi tag size is the log2 of the |
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5393 // 0 <= from <= to <= string.length. | 5430 // 0 <= from <= to <= string.length. |
5394 // If any of these assumptions fail, we call the runtime system. | 5431 // If any of these assumptions fail, we call the runtime system. |
5395 | 5432 |
5396 static const int kToOffset = 0 * kPointerSize; | 5433 static const int kToOffset = 0 * kPointerSize; |
5397 static const int kFromOffset = 1 * kPointerSize; | 5434 static const int kFromOffset = 1 * kPointerSize; |
5398 static const int kStringOffset = 2 * kPointerSize; | 5435 static const int kStringOffset = 2 * kPointerSize; |
5399 | 5436 |
5400 // Check bounds and smi-ness. | 5437 // Check bounds and smi-ness. |
5401 Register to = r6; | 5438 Register to = r6; |
5402 Register from = r7; | 5439 Register from = r7; |
5440 | |
5441 if (FLAG_string_slices) { | |
5442 __ nop(0); // Jumping as first instruction would crash the code generation. | |
5443 __ jmp(&runtime); | |
5444 } | |
5445 | |
5403 __ Ldrd(to, from, MemOperand(sp, kToOffset)); | 5446 __ Ldrd(to, from, MemOperand(sp, kToOffset)); |
5404 STATIC_ASSERT(kFromOffset == kToOffset + 4); | 5447 STATIC_ASSERT(kFromOffset == kToOffset + 4); |
5405 STATIC_ASSERT(kSmiTag == 0); | 5448 STATIC_ASSERT(kSmiTag == 0); |
5406 STATIC_ASSERT(kSmiTagSize + kSmiShiftSize == 1); | 5449 STATIC_ASSERT(kSmiTagSize + kSmiShiftSize == 1); |
5450 | |
5407 // I.e., arithmetic shift right by one un-smi-tags. | 5451 // I.e., arithmetic shift right by one un-smi-tags. |
5408 __ mov(r2, Operand(to, ASR, 1), SetCC); | 5452 __ mov(r2, Operand(to, ASR, 1), SetCC); |
5409 __ mov(r3, Operand(from, ASR, 1), SetCC, cc); | 5453 __ mov(r3, Operand(from, ASR, 1), SetCC, cc); |
5410 // If either to or from had the smi tag bit set, then carry is set now. | 5454 // If either to or from had the smi tag bit set, then carry is set now. |
5411 __ b(cs, &runtime); // Either "from" or "to" is not a smi. | 5455 __ b(cs, &runtime); // Either "from" or "to" is not a smi. |
5412 __ b(mi, &runtime); // From is negative. | 5456 __ b(mi, &runtime); // From is negative. |
5413 | 5457 |
5414 // Both to and from are smis. | 5458 // Both to and from are smis. |
5415 | |
5416 __ sub(r2, r2, Operand(r3), SetCC); | 5459 __ sub(r2, r2, Operand(r3), SetCC); |
5417 __ b(mi, &runtime); // Fail if from > to. | 5460 __ b(mi, &runtime); // Fail if from > to. |
5418 // Special handling of sub-strings of length 1 and 2. One character strings | 5461 // Special handling of sub-strings of length 1 and 2. One character strings |
5419 // are handled in the runtime system (looked up in the single character | 5462 // are handled in the runtime system (looked up in the single character |
5420 // cache). Two character strings are looked for in the symbol cache. | 5463 // cache). Two character strings are looked for in the symbol cache. |
5421 __ cmp(r2, Operand(2)); | 5464 __ cmp(r2, Operand(2)); |
5422 __ b(lt, &runtime); | 5465 __ b(lt, &runtime); |
5423 | 5466 |
5424 // r2: length | 5467 // r2: length |
5425 // r3: from index (untaged smi) | 5468 // r3: from index (untaged smi) |
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5911 __ ldr(r4, FieldMemOperand(r0, HeapObject::kMapOffset)); | 5954 __ ldr(r4, FieldMemOperand(r0, HeapObject::kMapOffset)); |
5912 __ ldr(r5, FieldMemOperand(r1, HeapObject::kMapOffset)); | 5955 __ ldr(r5, FieldMemOperand(r1, HeapObject::kMapOffset)); |
5913 __ ldrb(r4, FieldMemOperand(r4, Map::kInstanceTypeOffset)); | 5956 __ ldrb(r4, FieldMemOperand(r4, Map::kInstanceTypeOffset)); |
5914 __ ldrb(r5, FieldMemOperand(r5, Map::kInstanceTypeOffset)); | 5957 __ ldrb(r5, FieldMemOperand(r5, Map::kInstanceTypeOffset)); |
5915 } | 5958 } |
5916 // Check that both strings are sequential. | 5959 // Check that both strings are sequential. |
5917 STATIC_ASSERT(kSeqStringTag == 0); | 5960 STATIC_ASSERT(kSeqStringTag == 0); |
5918 __ tst(r4, Operand(kStringRepresentationMask)); | 5961 __ tst(r4, Operand(kStringRepresentationMask)); |
5919 __ tst(r5, Operand(kStringRepresentationMask), eq); | 5962 __ tst(r5, Operand(kStringRepresentationMask), eq); |
5920 __ b(ne, &string_add_runtime); | 5963 __ b(ne, &string_add_runtime); |
5964 // We cannot encounter sliced strings here since: | |
5965 STATIC_ASSERT(SlicedString::kMinLength >= String::kMinNonFlatLength); | |
antonm
2011/08/25 12:04:36
again, might be worth asserting.
Yang
2011/08/25 13:40:03
Removing this because the previous three lines alr
| |
5921 // Now check if both strings have the same encoding (ASCII/Two-byte). | 5966 // Now check if both strings have the same encoding (ASCII/Two-byte). |
5922 // r0: first string. | 5967 // r0: first string. |
5923 // r1: second string. | 5968 // r1: second string. |
5924 // r2: length of first string. | 5969 // r2: length of first string. |
5925 // r3: length of second string. | 5970 // r3: length of second string. |
5926 // r6: sum of lengths.. | 5971 // r6: sum of lengths.. |
5927 Label non_ascii_string_add_flat_result; | 5972 Label non_ascii_string_add_flat_result; |
5928 ASSERT(IsPowerOf2(kStringEncodingMask)); // Just one bit to test. | 5973 ASSERT(IsPowerOf2(kStringEncodingMask)); // Just one bit to test. |
5929 __ eor(r7, r4, Operand(r5)); | 5974 __ eor(r7, r4, Operand(r5)); |
5930 __ tst(r7, Operand(kStringEncodingMask)); | 5975 __ tst(r7, Operand(kStringEncodingMask)); |
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6535 __ mov(result, Operand(0)); | 6580 __ mov(result, Operand(0)); |
6536 __ Ret(); | 6581 __ Ret(); |
6537 } | 6582 } |
6538 | 6583 |
6539 | 6584 |
6540 #undef __ | 6585 #undef __ |
6541 | 6586 |
6542 } } // namespace v8::internal | 6587 } } // namespace v8::internal |
6543 | 6588 |
6544 #endif // V8_TARGET_ARCH_ARM | 6589 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |