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

Side by Side Diff: src/x64/lithium-codegen-x64.cc

Issue 6964011: Refactor HCheckInstanceType to allow mask/tag tests. (Closed)
Patch Set: Rebased 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/objects-printer.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 3632 matching lines...) Expand 10 before | Expand all | Expand 10 after
3643 3643
3644 void LCodeGen::DoCheckNonSmi(LCheckNonSmi* instr) { 3644 void LCodeGen::DoCheckNonSmi(LCheckNonSmi* instr) {
3645 LOperand* input = instr->InputAt(0); 3645 LOperand* input = instr->InputAt(0);
3646 Condition cc = masm()->CheckSmi(ToRegister(input)); 3646 Condition cc = masm()->CheckSmi(ToRegister(input));
3647 DeoptimizeIf(cc, instr->environment()); 3647 DeoptimizeIf(cc, instr->environment());
3648 } 3648 }
3649 3649
3650 3650
3651 void LCodeGen::DoCheckInstanceType(LCheckInstanceType* instr) { 3651 void LCodeGen::DoCheckInstanceType(LCheckInstanceType* instr) {
3652 Register input = ToRegister(instr->InputAt(0)); 3652 Register input = ToRegister(instr->InputAt(0));
3653 InstanceType first = instr->hydrogen()->first();
3654 InstanceType last = instr->hydrogen()->last();
3655 3653
3656 __ movq(kScratchRegister, FieldOperand(input, HeapObject::kMapOffset)); 3654 __ movq(kScratchRegister, FieldOperand(input, HeapObject::kMapOffset));
3657 3655
3658 // If there is only one type in the interval check for equality. 3656 if (instr->hydrogen()->is_interval_check()) {
3659 if (first == last) { 3657 InstanceType first;
3658 InstanceType last;
3659 instr->hydrogen()->GetCheckInterval(&first, &last);
3660
3660 __ cmpb(FieldOperand(kScratchRegister, Map::kInstanceTypeOffset), 3661 __ cmpb(FieldOperand(kScratchRegister, Map::kInstanceTypeOffset),
3661 Immediate(static_cast<int8_t>(first))); 3662 Immediate(static_cast<int8_t>(first)));
3662 DeoptimizeIf(not_equal, instr->environment()); 3663
3663 } else if (first == FIRST_STRING_TYPE && last == LAST_STRING_TYPE) { 3664 // If there is only one type in the interval check for equality.
3664 // String has a dedicated bit in instance type. 3665 if (first == last) {
3665 __ testb(FieldOperand(kScratchRegister, Map::kInstanceTypeOffset), 3666 DeoptimizeIf(not_equal, instr->environment());
3666 Immediate(kIsNotStringMask)); 3667 } else {
3667 DeoptimizeIf(not_zero, instr->environment()); 3668 DeoptimizeIf(below, instr->environment());
3669 // Omit check for the last type.
3670 if (last != LAST_TYPE) {
3671 __ cmpb(FieldOperand(kScratchRegister, Map::kInstanceTypeOffset),
3672 Immediate(static_cast<int8_t>(last)));
3673 DeoptimizeIf(above, instr->environment());
3674 }
3675 }
3668 } else { 3676 } else {
3669 __ cmpb(FieldOperand(kScratchRegister, Map::kInstanceTypeOffset), 3677 uint8_t mask;
3670 Immediate(static_cast<int8_t>(first))); 3678 uint8_t tag;
3671 DeoptimizeIf(below, instr->environment()); 3679 instr->hydrogen()->GetCheckMaskAndTag(&mask, &tag);
3672 // Omit check for the last type. 3680
3673 if (last != LAST_TYPE) { 3681 if (IsPowerOf2(mask)) {
3674 __ cmpb(FieldOperand(kScratchRegister, Map::kInstanceTypeOffset), 3682 ASSERT(tag == 0 || IsPowerOf2(tag));
3675 Immediate(static_cast<int8_t>(last))); 3683 __ testb(FieldOperand(kScratchRegister, Map::kInstanceTypeOffset),
3676 DeoptimizeIf(above, instr->environment()); 3684 Immediate(mask));
3685 DeoptimizeIf(tag == 0 ? not_zero : zero, instr->environment());
3686 } else {
3687 __ movzxbl(kScratchRegister,
3688 FieldOperand(kScratchRegister, Map::kInstanceTypeOffset));
3689 __ andb(kScratchRegister, Immediate(mask));
3690 __ cmpb(kScratchRegister, Immediate(tag));
3691 DeoptimizeIf(not_equal, instr->environment());
3677 } 3692 }
3678 } 3693 }
3679 } 3694 }
3680 3695
3681 3696
3682 void LCodeGen::DoCheckFunction(LCheckFunction* instr) { 3697 void LCodeGen::DoCheckFunction(LCheckFunction* instr) {
3683 ASSERT(instr->InputAt(0)->IsRegister()); 3698 ASSERT(instr->InputAt(0)->IsRegister());
3684 Register reg = ToRegister(instr->InputAt(0)); 3699 Register reg = ToRegister(instr->InputAt(0));
3685 __ Cmp(reg, instr->hydrogen()->target()); 3700 __ Cmp(reg, instr->hydrogen()->target());
3686 DeoptimizeIf(not_equal, instr->environment()); 3701 DeoptimizeIf(not_equal, instr->environment());
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
4107 RegisterEnvironmentForDeoptimization(environment); 4122 RegisterEnvironmentForDeoptimization(environment);
4108 ASSERT(osr_pc_offset_ == -1); 4123 ASSERT(osr_pc_offset_ == -1);
4109 osr_pc_offset_ = masm()->pc_offset(); 4124 osr_pc_offset_ = masm()->pc_offset();
4110 } 4125 }
4111 4126
4112 #undef __ 4127 #undef __
4113 4128
4114 } } // namespace v8::internal 4129 } } // namespace v8::internal
4115 4130
4116 #endif // V8_TARGET_ARCH_X64 4131 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/objects-printer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698