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

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

Issue 9169088: Use cmp instead of tst to check for zero. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 10 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/builtins-arm.cc ('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 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 2320 matching lines...) Expand 10 before | Expand all | Expand 10 after
2331 // Do multiplication 2331 // Do multiplication
2332 // scratch1 = lower 32 bits of ip * left. 2332 // scratch1 = lower 32 bits of ip * left.
2333 // scratch2 = higher 32 bits of ip * left. 2333 // scratch2 = higher 32 bits of ip * left.
2334 __ smull(scratch1, scratch2, left, ip); 2334 __ smull(scratch1, scratch2, left, ip);
2335 // Check for overflowing the smi range - no overflow if higher 33 bits of 2335 // Check for overflowing the smi range - no overflow if higher 33 bits of
2336 // the result are identical. 2336 // the result are identical.
2337 __ mov(ip, Operand(scratch1, ASR, 31)); 2337 __ mov(ip, Operand(scratch1, ASR, 31));
2338 __ cmp(ip, Operand(scratch2)); 2338 __ cmp(ip, Operand(scratch2));
2339 __ b(ne, &not_smi_result); 2339 __ b(ne, &not_smi_result);
2340 // Go slow on zero result to handle -0. 2340 // Go slow on zero result to handle -0.
2341 __ tst(scratch1, Operand(scratch1)); 2341 __ cmp(scratch1, Operand(0));
2342 __ mov(right, Operand(scratch1), LeaveCC, ne); 2342 __ mov(right, Operand(scratch1), LeaveCC, ne);
2343 __ Ret(ne); 2343 __ Ret(ne);
2344 // We need -0 if we were multiplying a negative number with 0 to get 0. 2344 // We need -0 if we were multiplying a negative number with 0 to get 0.
2345 // We know one of them was zero. 2345 // We know one of them was zero.
2346 __ add(scratch2, right, Operand(left), SetCC); 2346 __ add(scratch2, right, Operand(left), SetCC);
2347 __ mov(right, Operand(Smi::FromInt(0)), LeaveCC, pl); 2347 __ mov(right, Operand(Smi::FromInt(0)), LeaveCC, pl);
2348 __ Ret(pl); // Return smi 0 if the non-zero one was positive. 2348 __ Ret(pl); // Return smi 0 if the non-zero one was positive.
2349 // We fall through here if we multiplied a negative number with 0, because 2349 // We fall through here if we multiplied a negative number with 0, because
2350 // that would mean we should produce -0. 2350 // that would mean we should produce -0.
2351 break; 2351 break;
(...skipping 2297 matching lines...) Expand 10 before | Expand all | Expand 10 after
4649 Register last_match_info_elements = r6; 4649 Register last_match_info_elements = r6;
4650 4650
4651 // Ensure that a RegExp stack is allocated. 4651 // Ensure that a RegExp stack is allocated.
4652 Isolate* isolate = masm->isolate(); 4652 Isolate* isolate = masm->isolate();
4653 ExternalReference address_of_regexp_stack_memory_address = 4653 ExternalReference address_of_regexp_stack_memory_address =
4654 ExternalReference::address_of_regexp_stack_memory_address(isolate); 4654 ExternalReference::address_of_regexp_stack_memory_address(isolate);
4655 ExternalReference address_of_regexp_stack_memory_size = 4655 ExternalReference address_of_regexp_stack_memory_size =
4656 ExternalReference::address_of_regexp_stack_memory_size(isolate); 4656 ExternalReference::address_of_regexp_stack_memory_size(isolate);
4657 __ mov(r0, Operand(address_of_regexp_stack_memory_size)); 4657 __ mov(r0, Operand(address_of_regexp_stack_memory_size));
4658 __ ldr(r0, MemOperand(r0, 0)); 4658 __ ldr(r0, MemOperand(r0, 0));
4659 __ tst(r0, Operand(r0)); 4659 __ cmp(r0, Operand(0));
4660 __ b(eq, &runtime); 4660 __ b(eq, &runtime);
4661 4661
4662 // Check that the first argument is a JSRegExp object. 4662 // Check that the first argument is a JSRegExp object.
4663 __ ldr(r0, MemOperand(sp, kJSRegExpOffset)); 4663 __ ldr(r0, MemOperand(sp, kJSRegExpOffset));
4664 STATIC_ASSERT(kSmiTag == 0); 4664 STATIC_ASSERT(kSmiTag == 0);
4665 __ JumpIfSmi(r0, &runtime); 4665 __ JumpIfSmi(r0, &runtime);
4666 __ CompareObjectType(r0, r1, r1, JS_REGEXP_TYPE); 4666 __ CompareObjectType(r0, r1, r1, JS_REGEXP_TYPE);
4667 __ b(ne, &runtime); 4667 __ b(ne, &runtime);
4668 4668
4669 // Check that the RegExp has been compiled (data contains a fixed array). 4669 // Check that the RegExp has been compiled (data contains a fixed array).
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
5101 __ str(r6, FieldMemOperand(r3, FixedArray::kLengthOffset)); 5101 __ str(r6, FieldMemOperand(r3, FixedArray::kLengthOffset));
5102 // Fill contents of fixed-array with the-hole. 5102 // Fill contents of fixed-array with the-hole.
5103 __ mov(r2, Operand(factory->the_hole_value())); 5103 __ mov(r2, Operand(factory->the_hole_value()));
5104 __ add(r3, r3, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); 5104 __ add(r3, r3, Operand(FixedArray::kHeaderSize - kHeapObjectTag));
5105 // Fill fixed array elements with hole. 5105 // Fill fixed array elements with hole.
5106 // r0: JSArray, tagged. 5106 // r0: JSArray, tagged.
5107 // r2: the hole. 5107 // r2: the hole.
5108 // r3: Start of elements in FixedArray. 5108 // r3: Start of elements in FixedArray.
5109 // r5: Number of elements to fill. 5109 // r5: Number of elements to fill.
5110 Label loop; 5110 Label loop;
5111 __ tst(r5, Operand(r5)); 5111 __ cmp(r5, Operand(0));
5112 __ bind(&loop); 5112 __ bind(&loop);
5113 __ b(le, &done); // Jump if r1 is negative or zero. 5113 __ b(le, &done); // Jump if r5 is negative or zero.
5114 __ sub(r5, r5, Operand(1), SetCC); 5114 __ sub(r5, r5, Operand(1), SetCC);
5115 __ str(r2, MemOperand(r3, r5, LSL, kPointerSizeLog2)); 5115 __ str(r2, MemOperand(r3, r5, LSL, kPointerSizeLog2));
5116 __ jmp(&loop); 5116 __ jmp(&loop);
5117 5117
5118 __ bind(&done); 5118 __ bind(&done);
5119 __ add(sp, sp, Operand(3 * kPointerSize)); 5119 __ add(sp, sp, Operand(3 * kPointerSize));
5120 __ Ret(); 5120 __ Ret();
5121 5121
5122 __ bind(&slowcase); 5122 __ bind(&slowcase);
5123 __ TailCallRuntime(Runtime::kRegExpConstructResult, 3, 1); 5123 __ TailCallRuntime(Runtime::kRegExpConstructResult, 3, 1);
(...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after
6013 __ cmp(length, scratch2); 6013 __ cmp(length, scratch2);
6014 __ b(eq, &check_zero_length); 6014 __ b(eq, &check_zero_length);
6015 __ bind(&strings_not_equal); 6015 __ bind(&strings_not_equal);
6016 __ mov(r0, Operand(Smi::FromInt(NOT_EQUAL))); 6016 __ mov(r0, Operand(Smi::FromInt(NOT_EQUAL)));
6017 __ Ret(); 6017 __ Ret();
6018 6018
6019 // Check if the length is zero. 6019 // Check if the length is zero.
6020 Label compare_chars; 6020 Label compare_chars;
6021 __ bind(&check_zero_length); 6021 __ bind(&check_zero_length);
6022 STATIC_ASSERT(kSmiTag == 0); 6022 STATIC_ASSERT(kSmiTag == 0);
6023 __ tst(length, Operand(length)); 6023 __ cmp(length, Operand(0));
6024 __ b(ne, &compare_chars); 6024 __ b(ne, &compare_chars);
6025 __ mov(r0, Operand(Smi::FromInt(EQUAL))); 6025 __ mov(r0, Operand(Smi::FromInt(EQUAL)));
6026 __ Ret(); 6026 __ Ret();
6027 6027
6028 // Compare characters. 6028 // Compare characters.
6029 __ bind(&compare_chars); 6029 __ bind(&compare_chars);
6030 GenerateAsciiCharsCompareLoop(masm, 6030 GenerateAsciiCharsCompareLoop(masm,
6031 left, right, length, scratch2, scratch3, 6031 left, right, length, scratch2, scratch3,
6032 &strings_not_equal); 6032 &strings_not_equal);
6033 6033
(...skipping 12 matching lines...) Expand all
6046 Register scratch4) { 6046 Register scratch4) {
6047 Label result_not_equal, compare_lengths; 6047 Label result_not_equal, compare_lengths;
6048 // Find minimum length and length difference. 6048 // Find minimum length and length difference.
6049 __ ldr(scratch1, FieldMemOperand(left, String::kLengthOffset)); 6049 __ ldr(scratch1, FieldMemOperand(left, String::kLengthOffset));
6050 __ ldr(scratch2, FieldMemOperand(right, String::kLengthOffset)); 6050 __ ldr(scratch2, FieldMemOperand(right, String::kLengthOffset));
6051 __ sub(scratch3, scratch1, Operand(scratch2), SetCC); 6051 __ sub(scratch3, scratch1, Operand(scratch2), SetCC);
6052 Register length_delta = scratch3; 6052 Register length_delta = scratch3;
6053 __ mov(scratch1, scratch2, LeaveCC, gt); 6053 __ mov(scratch1, scratch2, LeaveCC, gt);
6054 Register min_length = scratch1; 6054 Register min_length = scratch1;
6055 STATIC_ASSERT(kSmiTag == 0); 6055 STATIC_ASSERT(kSmiTag == 0);
6056 __ tst(min_length, Operand(min_length)); 6056 __ cmp(min_length, Operand(0));
6057 __ b(eq, &compare_lengths); 6057 __ b(eq, &compare_lengths);
6058 6058
6059 // Compare loop. 6059 // Compare loop.
6060 GenerateAsciiCharsCompareLoop(masm, 6060 GenerateAsciiCharsCompareLoop(masm,
6061 left, right, min_length, scratch2, scratch4, 6061 left, right, min_length, scratch2, scratch4,
6062 &result_not_equal); 6062 &result_not_equal);
6063 6063
6064 // Compare lengths - strings up to min-length are equal. 6064 // Compare lengths - strings up to min-length are equal.
6065 __ bind(&compare_lengths); 6065 __ bind(&compare_lengths);
6066 ASSERT(Smi::FromInt(EQUAL) == static_cast<Smi*>(0)); 6066 ASSERT(Smi::FromInt(EQUAL) == static_cast<Smi*>(0));
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after
6804 6804
6805 const int spill_mask = 6805 const int spill_mask =
6806 (lr.bit() | r6.bit() | r5.bit() | r4.bit() | r3.bit() | 6806 (lr.bit() | r6.bit() | r5.bit() | r4.bit() | r3.bit() |
6807 r2.bit() | r1.bit() | r0.bit()); 6807 r2.bit() | r1.bit() | r0.bit());
6808 6808
6809 __ stm(db_w, sp, spill_mask); 6809 __ stm(db_w, sp, spill_mask);
6810 __ ldr(r0, FieldMemOperand(receiver, JSObject::kPropertiesOffset)); 6810 __ ldr(r0, FieldMemOperand(receiver, JSObject::kPropertiesOffset));
6811 __ mov(r1, Operand(Handle<String>(name))); 6811 __ mov(r1, Operand(Handle<String>(name)));
6812 StringDictionaryLookupStub stub(NEGATIVE_LOOKUP); 6812 StringDictionaryLookupStub stub(NEGATIVE_LOOKUP);
6813 __ CallStub(&stub); 6813 __ CallStub(&stub);
6814 __ tst(r0, Operand(r0)); 6814 __ cmp(r0, Operand(0));
6815 __ ldm(ia_w, sp, spill_mask); 6815 __ ldm(ia_w, sp, spill_mask);
6816 6816
6817 __ b(eq, done); 6817 __ b(eq, done);
6818 __ b(ne, miss); 6818 __ b(ne, miss);
6819 } 6819 }
6820 6820
6821 6821
6822 // Probe the string dictionary in the |elements| register. Jump to the 6822 // Probe the string dictionary in the |elements| register. Jump to the
6823 // |done| label if a property with the given name is found. Jump to 6823 // |done| label if a property with the given name is found. Jump to
6824 // the |miss| label otherwise. 6824 // the |miss| label otherwise.
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
6881 if (name.is(r0)) { 6881 if (name.is(r0)) {
6882 ASSERT(!elements.is(r1)); 6882 ASSERT(!elements.is(r1));
6883 __ Move(r1, name); 6883 __ Move(r1, name);
6884 __ Move(r0, elements); 6884 __ Move(r0, elements);
6885 } else { 6885 } else {
6886 __ Move(r0, elements); 6886 __ Move(r0, elements);
6887 __ Move(r1, name); 6887 __ Move(r1, name);
6888 } 6888 }
6889 StringDictionaryLookupStub stub(POSITIVE_LOOKUP); 6889 StringDictionaryLookupStub stub(POSITIVE_LOOKUP);
6890 __ CallStub(&stub); 6890 __ CallStub(&stub);
6891 __ tst(r0, Operand(r0)); 6891 __ cmp(r0, Operand(0));
6892 __ mov(scratch2, Operand(r2)); 6892 __ mov(scratch2, Operand(r2));
6893 __ ldm(ia_w, sp, spill_mask); 6893 __ ldm(ia_w, sp, spill_mask);
6894 6894
6895 __ b(ne, done); 6895 __ b(ne, done);
6896 __ b(eq, miss); 6896 __ b(eq, miss);
6897 } 6897 }
6898 6898
6899 6899
6900 void StringDictionaryLookupStub::Generate(MacroAssembler* masm) { 6900 void StringDictionaryLookupStub::Generate(MacroAssembler* masm) {
6901 // This stub overrides SometimesSetsUpAFrame() to return false. That means 6901 // This stub overrides SometimesSetsUpAFrame() to return false. That means
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
7314 __ StoreNumberToDoubleElements(r0, r3, r1, r5, r6, r7, r9, r10, 7314 __ StoreNumberToDoubleElements(r0, r3, r1, r5, r6, r7, r9, r10,
7315 &slow_elements); 7315 &slow_elements);
7316 __ Ret(); 7316 __ Ret();
7317 } 7317 }
7318 7318
7319 #undef __ 7319 #undef __
7320 7320
7321 } } // namespace v8::internal 7321 } } // namespace v8::internal
7322 7322
7323 #endif // V8_TARGET_ARCH_ARM 7323 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « src/arm/builtins-arm.cc ('k') | src/arm/full-codegen-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698