OLD | NEW |
---|---|
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 7000 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7011 answer = allocator_->Allocate(); | 7011 answer = allocator_->Allocate(); |
7012 ASSERT(answer.is_valid()); | 7012 ASSERT(answer.is_valid()); |
7013 // Check that both operands are smis using the answer register as a | 7013 // Check that both operands are smis using the answer register as a |
7014 // temporary. | 7014 // temporary. |
7015 DeferredInlineBinaryOperation* deferred = | 7015 DeferredInlineBinaryOperation* deferred = |
7016 new DeferredInlineBinaryOperation(op, | 7016 new DeferredInlineBinaryOperation(op, |
7017 answer.reg(), | 7017 answer.reg(), |
7018 left->reg(), | 7018 left->reg(), |
7019 rcx, | 7019 rcx, |
7020 overwrite_mode); | 7020 overwrite_mode); |
7021 __ JumpIfNotBothSmi(left->reg(), rcx, deferred->entry_label()); | 7021 |
7022 Label do_op; | |
7023 if (right_type_info.IsSmi()) { | |
7024 if (FLAG_debug_code) { | |
7025 __ AbortIfNotSmi(right->reg()); | |
7026 } | |
7027 __ movq(answer.reg(), left->reg()); | |
7028 // If left is not known to be a smi, check if it is. | |
7029 // If left is not known to be a number, and it isn't a smi, check if | |
7030 // it is a HeapNumber. | |
7031 if (!left_type_info.IsSmi()) { | |
7032 __ JumpIfSmi(answer.reg(), &do_op); | |
7033 if (!left_type_info.IsNumber()) { | |
7034 // Branch if not a heapnumber. | |
7035 __ Cmp(FieldOperand(answer.reg(), HeapObject::kMapOffset), | |
7036 Factory::heap_number_map()); | |
7037 deferred->Branch(not_equal); | |
7038 } | |
7039 // Load integer value into answer register using truncation. | |
William Hesse
2010/05/21 09:05:27
This is the case we also hope to avoid by using th
| |
7040 __ cvttsd2si(answer.reg(), | |
7041 FieldOperand(answer.reg(), HeapNumber::kValueOffset)); | |
7042 // Branch if we might have overflowed. | |
7043 // (False negative for Smi::kMinValue) | |
7044 __ cmpq(answer.reg(), Immediate(0x80000000)); | |
7045 deferred->Branch(equal); | |
7046 // TODO(lrn): Inline shifts on int32 here instead of first smi-tagging. | |
7047 __ Integer32ToSmi(answer.reg(), answer.reg()); | |
7048 } else { | |
7049 // Fast case - both are actually smis. | |
7050 if (FLAG_debug_code) { | |
7051 __ AbortIfNotSmi(left->reg()); | |
7052 } | |
7053 } | |
7054 } else { | |
7055 __ JumpIfNotBothSmi(left->reg(), rcx, deferred->entry_label()); | |
7056 } | |
7057 __ bind(&do_op); | |
7022 | 7058 |
7023 // Perform the operation. | 7059 // Perform the operation. |
7024 switch (op) { | 7060 switch (op) { |
7025 case Token::SAR: | 7061 case Token::SAR: |
7026 __ SmiShiftArithmeticRight(answer.reg(), left->reg(), rcx); | 7062 __ SmiShiftArithmeticRight(answer.reg(), left->reg(), rcx); |
7027 break; | 7063 break; |
7028 case Token::SHR: { | 7064 case Token::SHR: { |
7029 __ SmiShiftLogicalRight(answer.reg(), | 7065 __ SmiShiftLogicalRight(answer.reg(), |
7030 left->reg(), | 7066 left->reg(), |
7031 rcx, | 7067 rcx, |
(...skipping 4560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
11592 } | 11628 } |
11593 | 11629 |
11594 #endif | 11630 #endif |
11595 | 11631 |
11596 | 11632 |
11597 #undef __ | 11633 #undef __ |
11598 | 11634 |
11599 } } // namespace v8::internal | 11635 } } // namespace v8::internal |
11600 | 11636 |
11601 #endif // V8_TARGET_ARCH_X64 | 11637 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |