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

Side by Side Diff: src/ia32/lithium-codegen-ia32.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/hydrogen-instructions.cc ('k') | src/objects.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 3811 matching lines...) Expand 10 before | Expand all | Expand 10 after
3822 void LCodeGen::DoCheckNonSmi(LCheckNonSmi* instr) { 3822 void LCodeGen::DoCheckNonSmi(LCheckNonSmi* instr) {
3823 LOperand* input = instr->InputAt(0); 3823 LOperand* input = instr->InputAt(0);
3824 __ test(ToRegister(input), Immediate(kSmiTagMask)); 3824 __ test(ToRegister(input), Immediate(kSmiTagMask));
3825 DeoptimizeIf(zero, instr->environment()); 3825 DeoptimizeIf(zero, instr->environment());
3826 } 3826 }
3827 3827
3828 3828
3829 void LCodeGen::DoCheckInstanceType(LCheckInstanceType* instr) { 3829 void LCodeGen::DoCheckInstanceType(LCheckInstanceType* instr) {
3830 Register input = ToRegister(instr->InputAt(0)); 3830 Register input = ToRegister(instr->InputAt(0));
3831 Register temp = ToRegister(instr->TempAt(0)); 3831 Register temp = ToRegister(instr->TempAt(0));
3832 InstanceType first = instr->hydrogen()->first();
3833 InstanceType last = instr->hydrogen()->last();
3834 3832
3835 __ mov(temp, FieldOperand(input, HeapObject::kMapOffset)); 3833 __ mov(temp, FieldOperand(input, HeapObject::kMapOffset));
3836 3834
3837 // If there is only one type in the interval check for equality. 3835 if (instr->hydrogen()->is_interval_check()) {
3838 if (first == last) { 3836 InstanceType first;
3837 InstanceType last;
3838 instr->hydrogen()->GetCheckInterval(&first, &last);
3839
3839 __ cmpb(FieldOperand(temp, Map::kInstanceTypeOffset), 3840 __ cmpb(FieldOperand(temp, Map::kInstanceTypeOffset),
3840 static_cast<int8_t>(first)); 3841 static_cast<int8_t>(first));
3841 DeoptimizeIf(not_equal, instr->environment()); 3842
3842 } else if (first == FIRST_STRING_TYPE && last == LAST_STRING_TYPE) { 3843 // If there is only one type in the interval check for equality.
3843 // String has a dedicated bit in instance type. 3844 if (first == last) {
3844 __ test_b(FieldOperand(temp, Map::kInstanceTypeOffset), kIsNotStringMask); 3845 DeoptimizeIf(not_equal, instr->environment());
3845 DeoptimizeIf(not_zero, instr->environment()); 3846 } else {
3846 } else { 3847 DeoptimizeIf(below, instr->environment());
3847 __ cmpb(FieldOperand(temp, Map::kInstanceTypeOffset), 3848 // Omit check for the last type.
3848 static_cast<int8_t>(first)); 3849 if (last != LAST_TYPE) {
3849 DeoptimizeIf(below, instr->environment()); 3850 __ cmpb(FieldOperand(temp, Map::kInstanceTypeOffset),
3850 // Omit check for the last type. 3851 static_cast<int8_t>(last));
3851 if (last != LAST_TYPE) { 3852 DeoptimizeIf(above, instr->environment());
3852 __ cmpb(FieldOperand(temp, Map::kInstanceTypeOffset), 3853 }
3853 static_cast<int8_t>(last)); 3854 }
3854 DeoptimizeIf(above, instr->environment()); 3855 } else {
3856 uint8_t mask;
3857 uint8_t tag;
3858 instr->hydrogen()->GetCheckMaskAndTag(&mask, &tag);
3859
3860 if (IsPowerOf2(mask)) {
3861 ASSERT(tag == 0 || IsPowerOf2(tag));
3862 __ test_b(FieldOperand(temp, Map::kInstanceTypeOffset), mask);
3863 DeoptimizeIf(tag == 0 ? not_zero : zero, instr->environment());
3864 } else {
3865 __ movzx_b(temp, FieldOperand(temp, Map::kInstanceTypeOffset));
3866 __ and_(temp, mask);
3867 __ cmpb(Operand(temp), tag);
3868 DeoptimizeIf(not_equal, instr->environment());
3855 } 3869 }
3856 } 3870 }
3857 } 3871 }
3858 3872
3859 3873
3860 void LCodeGen::DoCheckFunction(LCheckFunction* instr) { 3874 void LCodeGen::DoCheckFunction(LCheckFunction* instr) {
3861 ASSERT(instr->InputAt(0)->IsRegister()); 3875 ASSERT(instr->InputAt(0)->IsRegister());
3862 Register reg = ToRegister(instr->InputAt(0)); 3876 Register reg = ToRegister(instr->InputAt(0));
3863 __ cmp(reg, instr->hydrogen()->target()); 3877 __ cmp(reg, instr->hydrogen()->target());
3864 DeoptimizeIf(not_equal, instr->environment()); 3878 DeoptimizeIf(not_equal, instr->environment());
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
4306 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); 4320 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
4307 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator); 4321 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator);
4308 } 4322 }
4309 4323
4310 4324
4311 #undef __ 4325 #undef __
4312 4326
4313 } } // namespace v8::internal 4327 } } // namespace v8::internal
4314 4328
4315 #endif // V8_TARGET_ARCH_IA32 4329 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/hydrogen-instructions.cc ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698