| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 | 116 |
| 117 virtual void Generate(); | 117 virtual void Generate(); |
| 118 | 118 |
| 119 private: | 119 private: |
| 120 Register dst_; | 120 Register dst_; |
| 121 Smi* value_; | 121 Smi* value_; |
| 122 OverwriteMode overwrite_mode_; | 122 OverwriteMode overwrite_mode_; |
| 123 }; | 123 }; |
| 124 | 124 |
| 125 | 125 |
| 126 // The result of value + src is in dst. It either overflowed or was not |
| 127 // smi tagged. Undo the speculative addition and call the appropriate |
| 128 // specialized stub for add. The result is left in dst. |
| 129 class DeferredInlineSmiAddReversed: public DeferredCode { |
| 130 public: |
| 131 DeferredInlineSmiAddReversed(Register dst, |
| 132 Smi* value, |
| 133 OverwriteMode overwrite_mode) |
| 134 : dst_(dst), value_(value), overwrite_mode_(overwrite_mode) { |
| 135 set_comment("[ DeferredInlineSmiAddReversed"); |
| 136 } |
| 137 |
| 138 virtual void Generate(); |
| 139 |
| 140 private: |
| 141 Register dst_; |
| 142 Smi* value_; |
| 143 OverwriteMode overwrite_mode_; |
| 144 }; |
| 145 |
| 146 |
| 126 class DeferredInlineSmiSub: public DeferredCode { | 147 class DeferredInlineSmiSub: public DeferredCode { |
| 127 public: | 148 public: |
| 128 DeferredInlineSmiSub(Register dst, | 149 DeferredInlineSmiSub(Register dst, |
| 129 Smi* value, | 150 Smi* value, |
| 130 OverwriteMode overwrite_mode) | 151 OverwriteMode overwrite_mode) |
| 131 : dst_(dst), value_(value), overwrite_mode_(overwrite_mode) { | 152 : dst_(dst), value_(value), overwrite_mode_(overwrite_mode) { |
| 132 set_comment("[ DeferredInlineSmiSub"); | 153 set_comment("[ DeferredInlineSmiSub"); |
| 133 } | 154 } |
| 134 | 155 |
| 135 virtual void Generate(); | 156 virtual void Generate(); |
| (...skipping 4914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5050 | 5071 |
| 5051 void DeferredInlineSmiAdd::Generate() { | 5072 void DeferredInlineSmiAdd::Generate() { |
| 5052 __ push(dst_); | 5073 __ push(dst_); |
| 5053 __ push(Immediate(value_)); | 5074 __ push(Immediate(value_)); |
| 5054 GenericBinaryOpStub igostub(Token::ADD, overwrite_mode_, SMI_CODE_INLINED); | 5075 GenericBinaryOpStub igostub(Token::ADD, overwrite_mode_, SMI_CODE_INLINED); |
| 5055 __ CallStub(&igostub); | 5076 __ CallStub(&igostub); |
| 5056 if (!dst_.is(rax)) __ movq(dst_, rax); | 5077 if (!dst_.is(rax)) __ movq(dst_, rax); |
| 5057 } | 5078 } |
| 5058 | 5079 |
| 5059 | 5080 |
| 5060 // The result of value + src is in dst. It either overflowed or was not | |
| 5061 // smi tagged. Undo the speculative addition and call the appropriate | |
| 5062 // specialized stub for add. The result is left in dst. | |
| 5063 class DeferredInlineSmiAddReversed: public DeferredCode { | |
| 5064 public: | |
| 5065 DeferredInlineSmiAddReversed(Register dst, | |
| 5066 Smi* value, | |
| 5067 OverwriteMode overwrite_mode) | |
| 5068 : dst_(dst), value_(value), overwrite_mode_(overwrite_mode) { | |
| 5069 set_comment("[ DeferredInlineSmiAddReversed"); | |
| 5070 } | |
| 5071 | |
| 5072 virtual void Generate(); | |
| 5073 | |
| 5074 private: | |
| 5075 Register dst_; | |
| 5076 Smi* value_; | |
| 5077 OverwriteMode overwrite_mode_; | |
| 5078 }; | |
| 5079 | |
| 5080 | |
| 5081 void DeferredInlineSmiAddReversed::Generate() { | 5081 void DeferredInlineSmiAddReversed::Generate() { |
| 5082 __ push(Immediate(value_)); // Note: sign extended. | 5082 __ push(Immediate(value_)); // Note: sign extended. |
| 5083 __ push(dst_); | 5083 __ push(dst_); |
| 5084 GenericBinaryOpStub igostub(Token::ADD, overwrite_mode_, SMI_CODE_INLINED); | 5084 GenericBinaryOpStub igostub(Token::ADD, overwrite_mode_, SMI_CODE_INLINED); |
| 5085 __ CallStub(&igostub); | 5085 __ CallStub(&igostub); |
| 5086 if (!dst_.is(rax)) __ movq(dst_, rax); | 5086 if (!dst_.is(rax)) __ movq(dst_, rax); |
| 5087 } | 5087 } |
| 5088 | 5088 |
| 5089 | 5089 |
| 5090 void DeferredInlineSmiSub::Generate() { | 5090 void DeferredInlineSmiSub::Generate() { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5159 __ addl(operand->reg(), Immediate(smi_value)); | 5159 __ addl(operand->reg(), Immediate(smi_value)); |
| 5160 Label add_success; | 5160 Label add_success; |
| 5161 __ j(no_overflow, &add_success); | 5161 __ j(no_overflow, &add_success); |
| 5162 __ subl(operand->reg(), Immediate(smi_value)); | 5162 __ subl(operand->reg(), Immediate(smi_value)); |
| 5163 deferred->Jump(); | 5163 deferred->Jump(); |
| 5164 __ bind(&add_success); | 5164 __ bind(&add_success); |
| 5165 deferred->BindExit(); | 5165 deferred->BindExit(); |
| 5166 frame_->Push(operand); | 5166 frame_->Push(operand); |
| 5167 break; | 5167 break; |
| 5168 } | 5168 } |
| 5169 |
| 5170 case Token::SUB: { |
| 5171 if (reversed) { |
| 5172 Result constant_operand(value); |
| 5173 LikelySmiBinaryOperation(op, &constant_operand, operand, |
| 5174 overwrite_mode); |
| 5175 } else { |
| 5176 operand->ToRegister(); |
| 5177 frame_->Spill(operand->reg()); |
| 5178 DeferredCode* deferred = new DeferredInlineSmiSub(operand->reg(), |
| 5179 smi_value, |
| 5180 overwrite_mode); |
| 5181 __ testl(operand->reg(), Immediate(kSmiTagMask)); |
| 5182 deferred->Branch(not_zero); |
| 5183 // A smi currently fits in a 32-bit Immediate. |
| 5184 __ subl(operand->reg(), Immediate(smi_value)); |
| 5185 Label add_success; |
| 5186 __ j(no_overflow, &add_success); |
| 5187 __ addl(operand->reg(), Immediate(smi_value)); |
| 5188 deferred->Jump(); |
| 5189 __ bind(&add_success); |
| 5190 deferred->BindExit(); |
| 5191 frame_->Push(operand); |
| 5192 } |
| 5193 break; |
| 5194 } |
| 5169 // TODO(X64): Move other implementations from ia32 to here. | 5195 // TODO(X64): Move other implementations from ia32 to here. |
| 5170 | 5196 |
| 5171 // Generate inline code for mod of powers of 2 and negative powers of 2. | 5197 // Generate inline code for mod of powers of 2 and negative powers of 2. |
| 5172 case Token::MOD: | 5198 case Token::MOD: |
| 5173 if (!reversed && | 5199 if (!reversed && |
| 5174 int_value != 0 && | 5200 int_value != 0 && |
| 5175 (IsPowerOf2(int_value) || IsPowerOf2(-int_value))) { | 5201 (IsPowerOf2(int_value) || IsPowerOf2(-int_value))) { |
| 5176 operand->ToRegister(); | 5202 operand->ToRegister(); |
| 5177 frame_->Spill(operand->reg()); | 5203 frame_->Spill(operand->reg()); |
| 5178 DeferredCode* deferred = new DeferredInlineSmiOperation(op, | 5204 DeferredCode* deferred = new DeferredInlineSmiOperation(op, |
| (...skipping 2336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7515 int CompareStub::MinorKey() { | 7541 int CompareStub::MinorKey() { |
| 7516 // Encode the two parameters in a unique 16 bit value. | 7542 // Encode the two parameters in a unique 16 bit value. |
| 7517 ASSERT(static_cast<unsigned>(cc_) < (1 << 15)); | 7543 ASSERT(static_cast<unsigned>(cc_) < (1 << 15)); |
| 7518 return (static_cast<unsigned>(cc_) << 1) | (strict_ ? 1 : 0); | 7544 return (static_cast<unsigned>(cc_) << 1) | (strict_ ? 1 : 0); |
| 7519 } | 7545 } |
| 7520 | 7546 |
| 7521 | 7547 |
| 7522 #undef __ | 7548 #undef __ |
| 7523 | 7549 |
| 7524 } } // namespace v8::internal | 7550 } } // namespace v8::internal |
| OLD | NEW |