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

Side by Side Diff: src/x64/code-stubs-x64.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 | « src/ic.cc ('k') | no next file » | 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 4667 matching lines...) Expand 10 before | Expand all | Expand 10 after
4678 4678
4679 CompareStub stub(GetCondition(), strict(), NO_COMPARE_FLAGS); 4679 CompareStub stub(GetCondition(), strict(), NO_COMPARE_FLAGS);
4680 __ bind(&generic_stub); 4680 __ bind(&generic_stub);
4681 __ jmp(stub.GetCode(), RelocInfo::CODE_TARGET); 4681 __ jmp(stub.GetCode(), RelocInfo::CODE_TARGET);
4682 4682
4683 __ bind(&miss); 4683 __ bind(&miss);
4684 GenerateMiss(masm); 4684 GenerateMiss(masm);
4685 } 4685 }
4686 4686
4687 4687
4688 void ICCompareStub::GenerateStrings(MacroAssembler* masm) {
4689 ASSERT(state_ == CompareIC::STRINGS);
4690 Label miss;
4691
4692 // Registers containing left and right operands respectively.
4693 Register left = rdx;
4694 Register right = rax;
4695 Register tmp1 = rcx;
4696 Register tmp2 = rbx;
4697 Register tmp3 = rdi;
4698 Register tmp4 = r8;
4699
4700 // Check that both operands are heap objects.
4701 Condition cond = masm->CheckEitherSmi(left, right, tmp1);
4702 __ j(cond, &miss);
4703
4704 // Check that both operands are strings. This leaves the instance
4705 // types loaded in tmp1 and tmp2.
4706 __ movq(tmp1, FieldOperand(left, HeapObject::kMapOffset));
4707 __ movq(tmp2, FieldOperand(right, HeapObject::kMapOffset));
4708 __ movzxbq(tmp1, FieldOperand(tmp1, Map::kInstanceTypeOffset));
4709 __ movzxbq(tmp2, FieldOperand(tmp2, Map::kInstanceTypeOffset));
4710 __ movq(tmp3, tmp1);
4711 STATIC_ASSERT(kNotStringTag != 0);
4712 __ or_(tmp3, tmp2);
4713 __ testl(tmp3, Immediate(kIsNotStringMask));
4714 __ j(not_zero, &miss);
4715
4716 // Fast check for identical strings.
4717 NearLabel not_same;
4718 __ cmpq(left, right);
4719 __ j(not_equal, &not_same);
4720 STATIC_ASSERT(EQUAL == 0);
4721 STATIC_ASSERT(kSmiTag == 0);
4722 __ Move(rax, Smi::FromInt(EQUAL));
4723 __ ret(0);
4724
4725 // Handle not identical strings.
4726 __ bind(&not_same);
4727
4728 // Check that both strings are symbols. If they are, we're done
4729 // because we already know they are not identical.
4730 NearLabel do_compare;
4731 ASSERT(GetCondition() == equal);
4732 STATIC_ASSERT(kSymbolTag != 0);
4733 __ and_(tmp1, tmp2);
4734 __ testl(tmp1, Immediate(kIsSymbolMask));
4735 __ j(zero, &do_compare);
4736 // Make sure rax is non-zero. At this point input operands are
4737 // guaranteed to be non-zero.
4738 ASSERT(right.is(rax));
4739 __ ret(0);
4740
4741 // Check that both strings are sequential ASCII.
4742 Label runtime;
4743 __ bind(&do_compare);
4744 __ JumpIfNotBothSequentialAsciiStrings(left, right, tmp1, tmp2, &runtime);
4745
4746 // Compare flat ASCII strings. Returns when done.
4747 StringCompareStub::GenerateCompareFlatAsciiStrings(
4748 masm, left, right, tmp1, tmp2, tmp3, tmp4);
4749
4750 // Handle more complex cases in runtime.
4751 __ bind(&runtime);
4752 __ pop(tmp1); // Return address.
4753 __ push(left);
4754 __ push(right);
4755 __ push(tmp1);
4756 __ TailCallRuntime(Runtime::kStringCompare, 2, 1);
4757
4758 __ bind(&miss);
4759 GenerateMiss(masm);
4760 }
4761
4762
4688 void ICCompareStub::GenerateObjects(MacroAssembler* masm) { 4763 void ICCompareStub::GenerateObjects(MacroAssembler* masm) {
4689 ASSERT(state_ == CompareIC::OBJECTS); 4764 ASSERT(state_ == CompareIC::OBJECTS);
4690 NearLabel miss; 4765 NearLabel miss;
4691 Condition either_smi = masm->CheckEitherSmi(rdx, rax); 4766 Condition either_smi = masm->CheckEitherSmi(rdx, rax);
4692 __ j(either_smi, &miss); 4767 __ j(either_smi, &miss);
4693 4768
4694 __ CmpObjectType(rax, JS_OBJECT_TYPE, rcx); 4769 __ CmpObjectType(rax, JS_OBJECT_TYPE, rcx);
4695 __ j(not_equal, &miss, not_taken); 4770 __ j(not_equal, &miss, not_taken);
4696 __ CmpObjectType(rdx, JS_OBJECT_TYPE, rcx); 4771 __ CmpObjectType(rdx, JS_OBJECT_TYPE, rcx);
4697 __ j(not_equal, &miss, not_taken); 4772 __ j(not_equal, &miss, not_taken);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
4734 // Do a tail call to the rewritten stub. 4809 // Do a tail call to the rewritten stub.
4735 __ jmp(rdi); 4810 __ jmp(rdi);
4736 } 4811 }
4737 4812
4738 4813
4739 #undef __ 4814 #undef __
4740 4815
4741 } } // namespace v8::internal 4816 } } // namespace v8::internal
4742 4817
4743 #endif // V8_TARGET_ARCH_X64 4818 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/ic.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698