Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(825)

Side by Side Diff: src/arm/code-stubs-arm.cc

Issue 19492006: Cleanup StringAddFlags. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add extra ASSERTs. Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/arm/code-stubs-arm.h ('k') | src/arm/full-codegen-arm.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1879 matching lines...) Expand 10 before | Expand all | Expand 10 after
1890 // Test if left operand is a string. 1890 // Test if left operand is a string.
1891 __ JumpIfSmi(left, &call_runtime); 1891 __ JumpIfSmi(left, &call_runtime);
1892 __ CompareObjectType(left, r2, r2, FIRST_NONSTRING_TYPE); 1892 __ CompareObjectType(left, r2, r2, FIRST_NONSTRING_TYPE);
1893 __ b(ge, &call_runtime); 1893 __ b(ge, &call_runtime);
1894 1894
1895 // Test if right operand is a string. 1895 // Test if right operand is a string.
1896 __ JumpIfSmi(right, &call_runtime); 1896 __ JumpIfSmi(right, &call_runtime);
1897 __ CompareObjectType(right, r2, r2, FIRST_NONSTRING_TYPE); 1897 __ CompareObjectType(right, r2, r2, FIRST_NONSTRING_TYPE);
1898 __ b(ge, &call_runtime); 1898 __ b(ge, &call_runtime);
1899 1899
1900 StringAddStub string_add_stub((StringAddFlags) 1900 StringAddStub string_add_stub(
1901 (ERECT_FRAME | NO_STRING_CHECK_IN_STUB)); 1901 (StringAddFlags)(STRING_ADD_CHECK_NONE | STRING_ADD_ERECT_FRAME));
1902 GenerateRegisterArgsPush(masm); 1902 GenerateRegisterArgsPush(masm);
1903 __ TailCallStub(&string_add_stub); 1903 __ TailCallStub(&string_add_stub);
1904 1904
1905 __ bind(&call_runtime); 1905 __ bind(&call_runtime);
1906 GenerateTypeTransition(masm); 1906 GenerateTypeTransition(masm);
1907 } 1907 }
1908 1908
1909 1909
1910 void BinaryOpStub::GenerateInt32Stub(MacroAssembler* masm) { 1910 void BinaryOpStub::GenerateInt32Stub(MacroAssembler* masm) {
1911 ASSERT(Max(left_type_, right_type_) == BinaryOpIC::INT32); 1911 ASSERT(Max(left_type_, right_type_) == BinaryOpIC::INT32);
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
2249 Label left_not_string, call_runtime; 2249 Label left_not_string, call_runtime;
2250 2250
2251 Register left = r1; 2251 Register left = r1;
2252 Register right = r0; 2252 Register right = r0;
2253 2253
2254 // Check if left argument is a string. 2254 // Check if left argument is a string.
2255 __ JumpIfSmi(left, &left_not_string); 2255 __ JumpIfSmi(left, &left_not_string);
2256 __ CompareObjectType(left, r2, r2, FIRST_NONSTRING_TYPE); 2256 __ CompareObjectType(left, r2, r2, FIRST_NONSTRING_TYPE);
2257 __ b(ge, &left_not_string); 2257 __ b(ge, &left_not_string);
2258 2258
2259 StringAddStub string_add_left_stub((StringAddFlags) 2259 StringAddStub string_add_left_stub(
2260 (ERECT_FRAME | NO_STRING_CHECK_LEFT_IN_STUB)); 2260 (StringAddFlags)(STRING_ADD_CHECK_RIGHT | STRING_ADD_ERECT_FRAME));
2261 GenerateRegisterArgsPush(masm); 2261 GenerateRegisterArgsPush(masm);
2262 __ TailCallStub(&string_add_left_stub); 2262 __ TailCallStub(&string_add_left_stub);
2263 2263
2264 // Left operand is not a string, test right. 2264 // Left operand is not a string, test right.
2265 __ bind(&left_not_string); 2265 __ bind(&left_not_string);
2266 __ JumpIfSmi(right, &call_runtime); 2266 __ JumpIfSmi(right, &call_runtime);
2267 __ CompareObjectType(right, r2, r2, FIRST_NONSTRING_TYPE); 2267 __ CompareObjectType(right, r2, r2, FIRST_NONSTRING_TYPE);
2268 __ b(ge, &call_runtime); 2268 __ b(ge, &call_runtime);
2269 2269
2270 StringAddStub string_add_right_stub((StringAddFlags) 2270 StringAddStub string_add_right_stub(
2271 (ERECT_FRAME | NO_STRING_CHECK_RIGHT_IN_STUB)); 2271 (StringAddFlags)(STRING_ADD_CHECK_LEFT | STRING_ADD_ERECT_FRAME));
2272 GenerateRegisterArgsPush(masm); 2272 GenerateRegisterArgsPush(masm);
2273 __ TailCallStub(&string_add_right_stub); 2273 __ TailCallStub(&string_add_right_stub);
2274 2274
2275 // At least one argument is not a string. 2275 // At least one argument is not a string.
2276 __ bind(&call_runtime); 2276 __ bind(&call_runtime);
2277 } 2277 }
2278 2278
2279 2279
2280 void BinaryOpStub_GenerateHeapResultAllocation(MacroAssembler* masm, 2280 void BinaryOpStub_GenerateHeapResultAllocation(MacroAssembler* masm,
2281 Register result, 2281 Register result,
(...skipping 3205 matching lines...) Expand 10 before | Expand all | Expand 10 after
5487 5487
5488 // Stack on entry: 5488 // Stack on entry:
5489 // sp[0]: second argument (right). 5489 // sp[0]: second argument (right).
5490 // sp[4]: first argument (left). 5490 // sp[4]: first argument (left).
5491 5491
5492 // Load the two arguments. 5492 // Load the two arguments.
5493 __ ldr(r0, MemOperand(sp, 1 * kPointerSize)); // First argument. 5493 __ ldr(r0, MemOperand(sp, 1 * kPointerSize)); // First argument.
5494 __ ldr(r1, MemOperand(sp, 0 * kPointerSize)); // Second argument. 5494 __ ldr(r1, MemOperand(sp, 0 * kPointerSize)); // Second argument.
5495 5495
5496 // Make sure that both arguments are strings if not known in advance. 5496 // Make sure that both arguments are strings if not known in advance.
5497 if ((flags_ & NO_STRING_ADD_FLAGS) != 0) { 5497 // Otherwise, at least one of the arguments is definitely a string,
5498 // and we convert the one that is not known to be a string.
5499 if ((flags_ & STRING_ADD_CHECK_BOTH) == STRING_ADD_CHECK_BOTH) {
5500 ASSERT((flags_ & STRING_ADD_CHECK_LEFT) == STRING_ADD_CHECK_LEFT);
5501 ASSERT((flags_ & STRING_ADD_CHECK_RIGHT) == STRING_ADD_CHECK_RIGHT);
5498 __ JumpIfEitherSmi(r0, r1, &call_runtime); 5502 __ JumpIfEitherSmi(r0, r1, &call_runtime);
5499 // Load instance types. 5503 // Load instance types.
5500 __ ldr(r4, FieldMemOperand(r0, HeapObject::kMapOffset)); 5504 __ ldr(r4, FieldMemOperand(r0, HeapObject::kMapOffset));
5501 __ ldr(r5, FieldMemOperand(r1, HeapObject::kMapOffset)); 5505 __ ldr(r5, FieldMemOperand(r1, HeapObject::kMapOffset));
5502 __ ldrb(r4, FieldMemOperand(r4, Map::kInstanceTypeOffset)); 5506 __ ldrb(r4, FieldMemOperand(r4, Map::kInstanceTypeOffset));
5503 __ ldrb(r5, FieldMemOperand(r5, Map::kInstanceTypeOffset)); 5507 __ ldrb(r5, FieldMemOperand(r5, Map::kInstanceTypeOffset));
5504 STATIC_ASSERT(kStringTag == 0); 5508 STATIC_ASSERT(kStringTag == 0);
5505 // If either is not a string, go to runtime. 5509 // If either is not a string, go to runtime.
5506 __ tst(r4, Operand(kIsNotStringMask)); 5510 __ tst(r4, Operand(kIsNotStringMask));
5507 __ tst(r5, Operand(kIsNotStringMask), eq); 5511 __ tst(r5, Operand(kIsNotStringMask), eq);
5508 __ b(ne, &call_runtime); 5512 __ b(ne, &call_runtime);
5509 } else { 5513 } else if ((flags_ & STRING_ADD_CHECK_LEFT) == STRING_ADD_CHECK_LEFT) {
5510 // Here at least one of the arguments is definitely a string. 5514 ASSERT((flags_ & STRING_ADD_CHECK_RIGHT) == 0);
5511 // We convert the one that is not known to be a string. 5515 GenerateConvertArgument(
5512 if ((flags_ & NO_STRING_CHECK_LEFT_IN_STUB) == 0) { 5516 masm, 1 * kPointerSize, r0, r2, r3, r4, r5, &call_builtin);
5513 ASSERT((flags_ & NO_STRING_CHECK_RIGHT_IN_STUB) != 0); 5517 builtin_id = Builtins::STRING_ADD_RIGHT;
5514 GenerateConvertArgument( 5518 } else if ((flags_ & STRING_ADD_CHECK_RIGHT) == STRING_ADD_CHECK_RIGHT) {
5515 masm, 1 * kPointerSize, r0, r2, r3, r4, r5, &call_builtin); 5519 ASSERT((flags_ & STRING_ADD_CHECK_LEFT) == 0);
5516 builtin_id = Builtins::STRING_ADD_RIGHT; 5520 GenerateConvertArgument(
5517 } else if ((flags_ & NO_STRING_CHECK_RIGHT_IN_STUB) == 0) { 5521 masm, 0 * kPointerSize, r1, r2, r3, r4, r5, &call_builtin);
5518 ASSERT((flags_ & NO_STRING_CHECK_LEFT_IN_STUB) != 0); 5522 builtin_id = Builtins::STRING_ADD_LEFT;
5519 GenerateConvertArgument(
5520 masm, 0 * kPointerSize, r1, r2, r3, r4, r5, &call_builtin);
5521 builtin_id = Builtins::STRING_ADD_LEFT;
5522 }
5523 } 5523 }
5524 5524
5525 // Both arguments are strings. 5525 // Both arguments are strings.
5526 // r0: first string 5526 // r0: first string
5527 // r1: second string 5527 // r1: second string
5528 // r4: first string instance type (if flags_ == NO_STRING_ADD_FLAGS) 5528 // r4: first string instance type (if flags_ == NO_STRING_ADD_FLAGS)
5529 // r5: second string instance type (if flags_ == NO_STRING_ADD_FLAGS) 5529 // r5: second string instance type (if flags_ == NO_STRING_ADD_FLAGS)
5530 { 5530 {
5531 Label strings_not_empty; 5531 Label strings_not_empty;
5532 // Check if either of the strings are empty. In that case return the other. 5532 // Check if either of the strings are empty. In that case return the other.
(...skipping 27 matching lines...) Expand all
5560 Label string_add_flat_result, longer_than_two; 5560 Label string_add_flat_result, longer_than_two;
5561 // Adding two lengths can't overflow. 5561 // Adding two lengths can't overflow.
5562 STATIC_ASSERT(String::kMaxLength < String::kMaxLength * 2); 5562 STATIC_ASSERT(String::kMaxLength < String::kMaxLength * 2);
5563 __ add(r6, r2, Operand(r3)); 5563 __ add(r6, r2, Operand(r3));
5564 // Use the string table when adding two one character strings, as it 5564 // Use the string table when adding two one character strings, as it
5565 // helps later optimizations to return a string here. 5565 // helps later optimizations to return a string here.
5566 __ cmp(r6, Operand(2)); 5566 __ cmp(r6, Operand(2));
5567 __ b(ne, &longer_than_two); 5567 __ b(ne, &longer_than_two);
5568 5568
5569 // Check that both strings are non-external ASCII strings. 5569 // Check that both strings are non-external ASCII strings.
5570 if (flags_ != NO_STRING_ADD_FLAGS) { 5570 if ((flags_ & STRING_ADD_CHECK_BOTH) != STRING_ADD_CHECK_BOTH) {
5571 __ ldr(r4, FieldMemOperand(r0, HeapObject::kMapOffset)); 5571 __ ldr(r4, FieldMemOperand(r0, HeapObject::kMapOffset));
5572 __ ldr(r5, FieldMemOperand(r1, HeapObject::kMapOffset)); 5572 __ ldr(r5, FieldMemOperand(r1, HeapObject::kMapOffset));
5573 __ ldrb(r4, FieldMemOperand(r4, Map::kInstanceTypeOffset)); 5573 __ ldrb(r4, FieldMemOperand(r4, Map::kInstanceTypeOffset));
5574 __ ldrb(r5, FieldMemOperand(r5, Map::kInstanceTypeOffset)); 5574 __ ldrb(r5, FieldMemOperand(r5, Map::kInstanceTypeOffset));
5575 } 5575 }
5576 __ JumpIfBothInstanceTypesAreNotSequentialAscii(r4, r5, r6, r7, 5576 __ JumpIfBothInstanceTypesAreNotSequentialAscii(r4, r5, r6, r7,
5577 &call_runtime); 5577 &call_runtime);
5578 5578
5579 // Get the two characters forming the sub string. 5579 // Get the two characters forming the sub string.
5580 __ ldrb(r2, FieldMemOperand(r0, SeqOneByteString::kHeaderSize)); 5580 __ ldrb(r2, FieldMemOperand(r0, SeqOneByteString::kHeaderSize));
(...skipping 27 matching lines...) Expand all
5608 __ b(lt, &string_add_flat_result); 5608 __ b(lt, &string_add_flat_result);
5609 // Handle exceptionally long strings in the runtime system. 5609 // Handle exceptionally long strings in the runtime system.
5610 STATIC_ASSERT((String::kMaxLength & 0x80000000) == 0); 5610 STATIC_ASSERT((String::kMaxLength & 0x80000000) == 0);
5611 ASSERT(IsPowerOf2(String::kMaxLength + 1)); 5611 ASSERT(IsPowerOf2(String::kMaxLength + 1));
5612 // kMaxLength + 1 is representable as shifted literal, kMaxLength is not. 5612 // kMaxLength + 1 is representable as shifted literal, kMaxLength is not.
5613 __ cmp(r6, Operand(String::kMaxLength + 1)); 5613 __ cmp(r6, Operand(String::kMaxLength + 1));
5614 __ b(hs, &call_runtime); 5614 __ b(hs, &call_runtime);
5615 5615
5616 // If result is not supposed to be flat, allocate a cons string object. 5616 // If result is not supposed to be flat, allocate a cons string object.
5617 // If both strings are ASCII the result is an ASCII cons string. 5617 // If both strings are ASCII the result is an ASCII cons string.
5618 if (flags_ != NO_STRING_ADD_FLAGS) { 5618 if ((flags_ & STRING_ADD_CHECK_BOTH) != STRING_ADD_CHECK_BOTH) {
5619 __ ldr(r4, FieldMemOperand(r0, HeapObject::kMapOffset)); 5619 __ ldr(r4, FieldMemOperand(r0, HeapObject::kMapOffset));
5620 __ ldr(r5, FieldMemOperand(r1, HeapObject::kMapOffset)); 5620 __ ldr(r5, FieldMemOperand(r1, HeapObject::kMapOffset));
5621 __ ldrb(r4, FieldMemOperand(r4, Map::kInstanceTypeOffset)); 5621 __ ldrb(r4, FieldMemOperand(r4, Map::kInstanceTypeOffset));
5622 __ ldrb(r5, FieldMemOperand(r5, Map::kInstanceTypeOffset)); 5622 __ ldrb(r5, FieldMemOperand(r5, Map::kInstanceTypeOffset));
5623 } 5623 }
5624 Label non_ascii, allocated, ascii_data; 5624 Label non_ascii, allocated, ascii_data;
5625 STATIC_ASSERT(kTwoByteStringTag == 0); 5625 STATIC_ASSERT(kTwoByteStringTag == 0);
5626 __ tst(r4, Operand(kStringEncodingMask)); 5626 __ tst(r4, Operand(kStringEncodingMask));
5627 __ tst(r5, Operand(kStringEncodingMask), ne); 5627 __ tst(r5, Operand(kStringEncodingMask), ne);
5628 __ b(eq, &non_ascii); 5628 __ b(eq, &non_ascii);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
5691 // Locate the first characters' locations. 5691 // Locate the first characters' locations.
5692 // r0: first string 5692 // r0: first string
5693 // r1: second string 5693 // r1: second string
5694 // r2: length of first string 5694 // r2: length of first string
5695 // r3: length of second string 5695 // r3: length of second string
5696 // r4: first string instance type (if flags_ == NO_STRING_ADD_FLAGS) 5696 // r4: first string instance type (if flags_ == NO_STRING_ADD_FLAGS)
5697 // r5: second string instance type (if flags_ == NO_STRING_ADD_FLAGS) 5697 // r5: second string instance type (if flags_ == NO_STRING_ADD_FLAGS)
5698 // r6: sum of lengths. 5698 // r6: sum of lengths.
5699 Label first_prepared, second_prepared; 5699 Label first_prepared, second_prepared;
5700 __ bind(&string_add_flat_result); 5700 __ bind(&string_add_flat_result);
5701 if (flags_ != NO_STRING_ADD_FLAGS) { 5701 if ((flags_ & STRING_ADD_CHECK_BOTH) != STRING_ADD_CHECK_BOTH) {
5702 __ ldr(r4, FieldMemOperand(r0, HeapObject::kMapOffset)); 5702 __ ldr(r4, FieldMemOperand(r0, HeapObject::kMapOffset));
5703 __ ldr(r5, FieldMemOperand(r1, HeapObject::kMapOffset)); 5703 __ ldr(r5, FieldMemOperand(r1, HeapObject::kMapOffset));
5704 __ ldrb(r4, FieldMemOperand(r4, Map::kInstanceTypeOffset)); 5704 __ ldrb(r4, FieldMemOperand(r4, Map::kInstanceTypeOffset));
5705 __ ldrb(r5, FieldMemOperand(r5, Map::kInstanceTypeOffset)); 5705 __ ldrb(r5, FieldMemOperand(r5, Map::kInstanceTypeOffset));
5706 } 5706 }
5707 5707
5708 // Check whether both strings have same encoding 5708 // Check whether both strings have same encoding
5709 __ eor(r7, r4, Operand(r5)); 5709 __ eor(r7, r4, Operand(r5));
5710 __ tst(r7, Operand(kStringEncodingMask)); 5710 __ tst(r7, Operand(kStringEncodingMask));
5711 __ b(ne, &call_runtime); 5711 __ b(ne, &call_runtime);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
5779 // r6: first character of result. 5779 // r6: first character of result.
5780 StringHelper::GenerateCopyCharacters(masm, r6, r7, r2, r4, false); 5780 StringHelper::GenerateCopyCharacters(masm, r6, r7, r2, r4, false);
5781 // r6: next character of result. 5781 // r6: next character of result.
5782 StringHelper::GenerateCopyCharacters(masm, r6, r1, r3, r4, false); 5782 StringHelper::GenerateCopyCharacters(masm, r6, r1, r3, r4, false);
5783 __ IncrementCounter(counters->string_add_native(), 1, r2, r3); 5783 __ IncrementCounter(counters->string_add_native(), 1, r2, r3);
5784 __ add(sp, sp, Operand(2 * kPointerSize)); 5784 __ add(sp, sp, Operand(2 * kPointerSize));
5785 __ Ret(); 5785 __ Ret();
5786 5786
5787 // Just jump to runtime to add the two strings. 5787 // Just jump to runtime to add the two strings.
5788 __ bind(&call_runtime); 5788 __ bind(&call_runtime);
5789 if ((flags_ & ERECT_FRAME) != 0) { 5789 if ((flags_ & STRING_ADD_ERECT_FRAME) != 0) {
5790 GenerateRegisterArgsPop(masm); 5790 GenerateRegisterArgsPop(masm);
5791 // Build a frame 5791 // Build a frame
5792 { 5792 {
5793 FrameScope scope(masm, StackFrame::INTERNAL); 5793 FrameScope scope(masm, StackFrame::INTERNAL);
5794 GenerateRegisterArgsPush(masm); 5794 GenerateRegisterArgsPush(masm);
5795 __ CallRuntime(Runtime::kStringAdd, 2); 5795 __ CallRuntime(Runtime::kStringAdd, 2);
5796 } 5796 }
5797 __ Ret(); 5797 __ Ret();
5798 } else { 5798 } else {
5799 __ TailCallRuntime(Runtime::kStringAdd, 2, 1); 5799 __ TailCallRuntime(Runtime::kStringAdd, 2, 1);
5800 } 5800 }
5801 5801
5802 if (call_builtin.is_linked()) { 5802 if (call_builtin.is_linked()) {
5803 __ bind(&call_builtin); 5803 __ bind(&call_builtin);
5804 if ((flags_ & ERECT_FRAME) != 0) { 5804 if ((flags_ & STRING_ADD_ERECT_FRAME) != 0) {
5805 GenerateRegisterArgsPop(masm); 5805 GenerateRegisterArgsPop(masm);
5806 // Build a frame 5806 // Build a frame
5807 { 5807 {
5808 FrameScope scope(masm, StackFrame::INTERNAL); 5808 FrameScope scope(masm, StackFrame::INTERNAL);
5809 GenerateRegisterArgsPush(masm); 5809 GenerateRegisterArgsPush(masm);
5810 __ InvokeBuiltin(builtin_id, CALL_FUNCTION); 5810 __ InvokeBuiltin(builtin_id, CALL_FUNCTION);
5811 } 5811 }
5812 __ Ret(); 5812 __ Ret();
5813 } else { 5813 } else {
5814 __ InvokeBuiltin(builtin_id, JUMP_FUNCTION); 5814 __ InvokeBuiltin(builtin_id, JUMP_FUNCTION);
(...skipping 1377 matching lines...) Expand 10 before | Expand all | Expand 10 after
7192 __ bind(&fast_elements_case); 7192 __ bind(&fast_elements_case);
7193 GenerateCase(masm, FAST_ELEMENTS); 7193 GenerateCase(masm, FAST_ELEMENTS);
7194 } 7194 }
7195 7195
7196 7196
7197 #undef __ 7197 #undef __
7198 7198
7199 } } // namespace v8::internal 7199 } } // namespace v8::internal
7200 7200
7201 #endif // V8_TARGET_ARCH_ARM 7201 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « src/arm/code-stubs-arm.h ('k') | src/arm/full-codegen-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698