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

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

Issue 6937001: Compare IC: add STRINGS state. (Closed)
Patch Set: Ports Created 9 years, 7 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
« no previous file with comments | « no previous file | src/code-stubs.h » ('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 5885 matching lines...) Expand 10 before | Expand all | Expand 10 after
5896 5896
5897 CompareStub stub(GetCondition(), strict(), NO_COMPARE_FLAGS, r1, r0); 5897 CompareStub stub(GetCondition(), strict(), NO_COMPARE_FLAGS, r1, r0);
5898 __ bind(&generic_stub); 5898 __ bind(&generic_stub);
5899 __ Jump(stub.GetCode(), RelocInfo::CODE_TARGET); 5899 __ Jump(stub.GetCode(), RelocInfo::CODE_TARGET);
5900 5900
5901 __ bind(&miss); 5901 __ bind(&miss);
5902 GenerateMiss(masm); 5902 GenerateMiss(masm);
5903 } 5903 }
5904 5904
5905 5905
5906 void ICCompareStub::GenerateStrings(MacroAssembler* masm) {
5907 ASSERT(state_ == CompareIC::STRINGS);
5908 Label miss;
5909
5910 // Registers containing left and right operands respectively.
5911 Register left = r1;
5912 Register right = r0;
5913 Register tmp1 = r2;
5914 Register tmp2 = r3;
5915 Register tmp3 = r4;
5916 Register tmp4 = r5;
5917
5918 // Check that both operands are heap objects.
5919 __ JumpIfEitherSmi(left, right, &miss);
5920
5921 // Check that both operands are strings. This leaves the instance
5922 // types loaded in tmp1 and tmp2.
5923 __ ldr(tmp1, FieldMemOperand(left, HeapObject::kMapOffset));
5924 __ ldr(tmp2, FieldMemOperand(right, HeapObject::kMapOffset));
5925 __ ldrb(tmp1, FieldMemOperand(tmp1, Map::kInstanceTypeOffset));
5926 __ ldrb(tmp2, FieldMemOperand(tmp2, Map::kInstanceTypeOffset));
5927 STATIC_ASSERT(kNotStringTag != 0);
5928 __ orr(tmp3, tmp1, tmp2);
5929 __ tst(tmp3, Operand(kIsNotStringMask));
5930 __ b(ne, &miss);
5931
5932 // Fast check for identical strings.
5933 __ cmp(left, right);
5934 STATIC_ASSERT(EQUAL == 0);
5935 STATIC_ASSERT(kSmiTag == 0);
5936 __ mov(r0, Operand(Smi::FromInt(EQUAL)), LeaveCC, eq);
5937 __ Ret(eq);
5938
5939 // Handle not identical strings.
5940
5941 // Check that both strings are symbols. If they are, we're done
5942 // because we already know they are not identical.
5943 ASSERT(GetCondition() == eq);
5944 STATIC_ASSERT(kSymbolTag != 0);
5945 __ and_(tmp3, tmp1, Operand(tmp2));
5946 __ tst(tmp3, Operand(kIsSymbolMask));
5947 // Make sure r0 is non-zero. At this point input operands are
5948 // guaranteed to be non-zero.
5949 ASSERT(right.is(r0));
5950 __ Ret(ne);
5951
5952 // Check that both strings are sequential ASCII.
5953 Label runtime;
5954 __ JumpIfBothInstanceTypesAreNotSequentialAscii(tmp1, tmp2, tmp3, tmp4,
5955 &runtime);
5956
5957 // Compare flat ASCII strings. Returns when done.
5958 StringCompareStub::GenerateCompareFlatAsciiStrings(
5959 masm, left, right, tmp1, tmp2, tmp3, tmp4);
5960
5961 // Handle more complex cases in runtime.
5962 __ bind(&runtime);
5963 __ Push(left, right);
5964 __ TailCallRuntime(Runtime::kStringCompare, 2, 1);
5965
5966 __ bind(&miss);
5967 GenerateMiss(masm);
5968 }
5969
5970
5906 void ICCompareStub::GenerateObjects(MacroAssembler* masm) { 5971 void ICCompareStub::GenerateObjects(MacroAssembler* masm) {
5907 ASSERT(state_ == CompareIC::OBJECTS); 5972 ASSERT(state_ == CompareIC::OBJECTS);
5908 Label miss; 5973 Label miss;
5909 __ and_(r2, r1, Operand(r0)); 5974 __ and_(r2, r1, Operand(r0));
5910 __ tst(r2, Operand(kSmiTagMask)); 5975 __ tst(r2, Operand(kSmiTagMask));
5911 __ b(eq, &miss); 5976 __ b(eq, &miss);
5912 5977
5913 __ CompareObjectType(r0, r2, r2, JS_OBJECT_TYPE); 5978 __ CompareObjectType(r0, r2, r2, JS_OBJECT_TYPE);
5914 __ b(ne, &miss); 5979 __ b(ne, &miss);
5915 __ CompareObjectType(r1, r2, r2, JS_OBJECT_TYPE); 5980 __ CompareObjectType(r1, r2, r2, JS_OBJECT_TYPE);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
5971 __ str(pc, MemOperand(sp, 0)); 6036 __ str(pc, MemOperand(sp, 0));
5972 __ Jump(target); // Call the C++ function. 6037 __ Jump(target); // Call the C++ function.
5973 } 6038 }
5974 6039
5975 6040
5976 #undef __ 6041 #undef __
5977 6042
5978 } } // namespace v8::internal 6043 } } // namespace v8::internal
5979 6044
5980 #endif // V8_TARGET_ARCH_ARM 6045 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/code-stubs.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698