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

Side by Side Diff: src/codegen-ia32.cc

Issue 18710: Optimizes check for Smi range in the code generator.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 11 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 | « no previous file | 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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 1109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1120 int shift_value = int_value & 0x1f; // only least significant 5 bits 1120 int shift_value = int_value & 0x1f; // only least significant 5 bits
1121 DeferredCode* deferred = 1121 DeferredCode* deferred =
1122 new DeferredInlinedSmiOperation(this, Token::SHL, shift_value, 1122 new DeferredInlinedSmiOperation(this, Token::SHL, shift_value,
1123 overwrite_mode); 1123 overwrite_mode);
1124 frame_->Pop(eax); 1124 frame_->Pop(eax);
1125 __ test(eax, Immediate(kSmiTagMask)); 1125 __ test(eax, Immediate(kSmiTagMask));
1126 __ mov(ebx, Operand(eax)); 1126 __ mov(ebx, Operand(eax));
1127 __ j(not_zero, deferred->enter(), not_taken); 1127 __ j(not_zero, deferred->enter(), not_taken);
1128 __ sar(ebx, kSmiTagSize); 1128 __ sar(ebx, kSmiTagSize);
1129 __ shl(ebx, shift_value); 1129 __ shl(ebx, shift_value);
1130 __ lea(ecx, Operand(ebx, 0x40000000)); 1130 // This is the Smi check for the shifted result.
1131 __ test(ecx, Immediate(0x80000000)); 1131 // After signed subtraction of 0xc0000000, the valid
1132 __ j(not_zero, deferred->enter(), not_taken); 1132 // Smis are positive.
1133 __ cmp(ebx, 0xc0000000);
1134 __ j(sign, deferred->enter(), not_taken);
1133 // tag result and store it in TOS (eax) 1135 // tag result and store it in TOS (eax)
1134 ASSERT(kSmiTagSize == times_2); // adjust code if not the case 1136 ASSERT(kSmiTagSize == times_2); // adjust code if not the case
1135 __ lea(eax, Operand(ebx, ebx, times_1, kSmiTag)); 1137 __ lea(eax, Operand(ebx, ebx, times_1, kSmiTag));
1136 __ bind(deferred->exit()); 1138 __ bind(deferred->exit());
1137 frame_->Push(eax); 1139 frame_->Push(eax);
1138 } 1140 }
1139 break; 1141 break;
1140 } 1142 }
1141 1143
1142 case Token::BIT_OR: 1144 case Token::BIT_OR:
(...skipping 3124 matching lines...) Expand 10 before | Expand all | Expand 10 after
4267 // - 0x80000000: high bit would be lost when smi tagging. 4269 // - 0x80000000: high bit would be lost when smi tagging.
4268 // - 0x40000000: this number would convert to negative when 4270 // - 0x40000000: this number would convert to negative when
4269 // Smi tagging these two cases can only happen with shifts 4271 // Smi tagging these two cases can only happen with shifts
4270 // by 0 or 1 when handed a valid smi. 4272 // by 0 or 1 when handed a valid smi.
4271 __ test(eax, Immediate(0xc0000000)); 4273 __ test(eax, Immediate(0xc0000000));
4272 __ j(not_zero, slow, not_taken); 4274 __ j(not_zero, slow, not_taken);
4273 break; 4275 break;
4274 case Token::SHL: 4276 case Token::SHL:
4275 __ shl(eax); 4277 __ shl(eax);
4276 // Check that the *signed* result fits in a smi. 4278 // Check that the *signed* result fits in a smi.
4277 __ lea(ecx, Operand(eax, 0x40000000)); 4279 __ cmp(eax, 0xc0000000);
4278 __ test(ecx, Immediate(0x80000000)); 4280 __ j(sign, slow, not_taken);
4279 __ j(not_zero, slow, not_taken);
4280 break; 4281 break;
4281 default: 4282 default:
4282 UNREACHABLE(); 4283 UNREACHABLE();
4283 } 4284 }
4284 // Tag the result and store it in register eax. 4285 // Tag the result and store it in register eax.
4285 ASSERT(kSmiTagSize == times_2); // adjust code if not the case 4286 ASSERT(kSmiTagSize == times_2); // adjust code if not the case
4286 __ lea(eax, Operand(eax, eax, times_1, kSmiTag)); 4287 __ lea(eax, Operand(eax, eax, times_1, kSmiTag));
4287 break; 4288 break;
4288 4289
4289 default: 4290 default:
(...skipping 1019 matching lines...) Expand 10 before | Expand all | Expand 10 after
5309 5310
5310 // Slow-case: Go through the JavaScript implementation. 5311 // Slow-case: Go through the JavaScript implementation.
5311 __ bind(&slow); 5312 __ bind(&slow);
5312 __ InvokeBuiltin(Builtins::INSTANCE_OF, JUMP_FUNCTION); 5313 __ InvokeBuiltin(Builtins::INSTANCE_OF, JUMP_FUNCTION);
5313 } 5314 }
5314 5315
5315 5316
5316 #undef __ 5317 #undef __
5317 5318
5318 } } // namespace v8::internal 5319 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698