OLD | NEW |
---|---|
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 1369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1380 Register dst_; | 1380 Register dst_; |
1381 Register src_; | 1381 Register src_; |
1382 Smi* value_; | 1382 Smi* value_; |
1383 OverwriteMode overwrite_mode_; | 1383 OverwriteMode overwrite_mode_; |
1384 }; | 1384 }; |
1385 | 1385 |
1386 | 1386 |
1387 void DeferredInlineSmiOperation::Generate() { | 1387 void DeferredInlineSmiOperation::Generate() { |
1388 __ push(src_); | 1388 __ push(src_); |
1389 __ push(Immediate(value_)); | 1389 __ push(Immediate(value_)); |
1390 GenericBinaryOpStub stub(op_, overwrite_mode_, SMI_CODE_INLINED); | 1390 GenericBinaryFlags flags = SMI_CODE_INLINED; |
1391 // For mod we don't generate all the Smi code inline. | |
1392 if (op_ == Token::MOD) flags = SMI_CODE_IN_STUB; | |
1393 GenericBinaryOpStub stub(op_, overwrite_mode_, flags); | |
Kevin Millikin (Chromium)
2009/06/18 07:23:49
You could write this:
GenericBinaryFlags flags =
| |
1391 __ CallStub(&stub); | 1394 __ CallStub(&stub); |
1392 if (!dst_.is(eax)) __ mov(dst_, eax); | 1395 if (!dst_.is(eax)) __ mov(dst_, eax); |
1393 } | 1396 } |
1394 | 1397 |
1395 | 1398 |
1396 // Call the appropriate binary operation stub to compute value op src | 1399 // Call the appropriate binary operation stub to compute value op src |
1397 // and leave the result in dst. | 1400 // and leave the result in dst. |
1398 class DeferredInlineSmiOperationReversed: public DeferredCode { | 1401 class DeferredInlineSmiOperationReversed: public DeferredCode { |
1399 public: | 1402 public: |
1400 DeferredInlineSmiOperationReversed(Token::Value op, | 1403 DeferredInlineSmiOperationReversed(Token::Value op, |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1765 ASSERT(op == Token::BIT_OR); | 1768 ASSERT(op == Token::BIT_OR); |
1766 if (int_value != 0) { | 1769 if (int_value != 0) { |
1767 __ or_(Operand(operand->reg()), Immediate(value)); | 1770 __ or_(Operand(operand->reg()), Immediate(value)); |
1768 } | 1771 } |
1769 } | 1772 } |
1770 deferred->BindExit(); | 1773 deferred->BindExit(); |
1771 frame_->Push(operand); | 1774 frame_->Push(operand); |
1772 break; | 1775 break; |
1773 } | 1776 } |
1774 | 1777 |
1778 // Generate inline code for mod of powers of 2 and negative powers of 2. | |
1779 case Token::MOD: | |
1780 if (!reversed && | |
1781 int_value != 0 && | |
1782 (IsPowerOf2(int_value) || IsPowerOf2(-int_value))) { | |
1783 operand->ToRegister(); | |
1784 frame_->Spill(operand->reg()); | |
1785 DeferredCode* deferred = new DeferredInlineSmiOperation(op, | |
1786 operand->reg(), | |
1787 operand->reg(), | |
1788 smi_value, | |
1789 overwrite_mode); | |
1790 // Check for negative or non-Smi left hand side. | |
1791 __ test(operand->reg(), Immediate(kSmiTagMask | 0x80000000)); | |
1792 deferred->Branch(not_zero); | |
1793 if (int_value < 0) int_value = -int_value; | |
1794 if (int_value == 1) { | |
1795 __ mov(operand->reg(), Immediate(Smi::FromInt(0))); | |
1796 } else { | |
1797 __ and_(operand->reg(), (int_value << kSmiTagSize) - 1); | |
1798 } | |
1799 deferred->BindExit(); | |
1800 frame_->Push(operand); | |
1801 break; | |
1802 } | |
1803 // Fall through if we did not find a power of 2 on the right hand side! | |
1804 | |
1775 default: { | 1805 default: { |
1776 Result constant_operand(value); | 1806 Result constant_operand(value); |
1777 if (reversed) { | 1807 if (reversed) { |
1778 LikelySmiBinaryOperation(op, &constant_operand, operand, | 1808 LikelySmiBinaryOperation(op, &constant_operand, operand, |
1779 overwrite_mode); | 1809 overwrite_mode); |
1780 } else { | 1810 } else { |
1781 LikelySmiBinaryOperation(op, operand, &constant_operand, | 1811 LikelySmiBinaryOperation(op, operand, &constant_operand, |
1782 overwrite_mode); | 1812 overwrite_mode); |
1783 } | 1813 } |
1784 break; | 1814 break; |
(...skipping 5728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7513 | 7543 |
7514 // Slow-case: Go through the JavaScript implementation. | 7544 // Slow-case: Go through the JavaScript implementation. |
7515 __ bind(&slow); | 7545 __ bind(&slow); |
7516 __ InvokeBuiltin(Builtins::INSTANCE_OF, JUMP_FUNCTION); | 7546 __ InvokeBuiltin(Builtins::INSTANCE_OF, JUMP_FUNCTION); |
7517 } | 7547 } |
7518 | 7548 |
7519 | 7549 |
7520 #undef __ | 7550 #undef __ |
7521 | 7551 |
7522 } } // namespace v8::internal | 7552 } } // namespace v8::internal |
OLD | NEW |