OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 1797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1808 | 1808 |
1809 | 1809 |
1810 static void ICCompareStub_CheckInputType(MacroAssembler* masm, | 1810 static void ICCompareStub_CheckInputType(MacroAssembler* masm, |
1811 Register input, | 1811 Register input, |
1812 Register scratch, | 1812 Register scratch, |
1813 CompareIC::State expected, | 1813 CompareIC::State expected, |
1814 Label* fail) { | 1814 Label* fail) { |
1815 Label ok; | 1815 Label ok; |
1816 if (expected == CompareIC::SMI) { | 1816 if (expected == CompareIC::SMI) { |
1817 __ JumpIfNotSmi(input, fail); | 1817 __ JumpIfNotSmi(input, fail); |
1818 } else if (expected == CompareIC::HEAP_NUMBER) { | 1818 } else if (expected == CompareIC::NUMBER) { |
1819 __ JumpIfSmi(input, &ok); | 1819 __ JumpIfSmi(input, &ok); |
1820 __ CheckMap(input, scratch, Heap::kHeapNumberMapRootIndex, fail, | 1820 __ CheckMap(input, scratch, Heap::kHeapNumberMapRootIndex, fail, |
1821 DONT_DO_SMI_CHECK); | 1821 DONT_DO_SMI_CHECK); |
1822 } | 1822 } |
1823 // We could be strict about symbol/string here, but as long as | 1823 // We could be strict about symbol/string here, but as long as |
1824 // hydrogen doesn't care, the stub doesn't have to care either. | 1824 // hydrogen doesn't care, the stub doesn't have to care either. |
1825 __ bind(&ok); | 1825 __ bind(&ok); |
1826 } | 1826 } |
1827 | 1827 |
1828 | 1828 |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2167 | 2167 |
2168 // TODO(svenpanne): Use virtual functions instead of switch. | 2168 // TODO(svenpanne): Use virtual functions instead of switch. |
2169 void UnaryOpStub::Generate(MacroAssembler* masm) { | 2169 void UnaryOpStub::Generate(MacroAssembler* masm) { |
2170 switch (operand_type_) { | 2170 switch (operand_type_) { |
2171 case UnaryOpIC::UNINITIALIZED: | 2171 case UnaryOpIC::UNINITIALIZED: |
2172 GenerateTypeTransition(masm); | 2172 GenerateTypeTransition(masm); |
2173 break; | 2173 break; |
2174 case UnaryOpIC::SMI: | 2174 case UnaryOpIC::SMI: |
2175 GenerateSmiStub(masm); | 2175 GenerateSmiStub(masm); |
2176 break; | 2176 break; |
2177 case UnaryOpIC::HEAP_NUMBER: | 2177 case UnaryOpIC::NUMBER: |
2178 GenerateHeapNumberStub(masm); | 2178 GenerateNumberStub(masm); |
2179 break; | 2179 break; |
2180 case UnaryOpIC::GENERIC: | 2180 case UnaryOpIC::GENERIC: |
2181 GenerateGenericStub(masm); | 2181 GenerateGenericStub(masm); |
2182 break; | 2182 break; |
2183 } | 2183 } |
2184 } | 2184 } |
2185 | 2185 |
2186 | 2186 |
2187 void UnaryOpStub::GenerateTypeTransition(MacroAssembler* masm) { | 2187 void UnaryOpStub::GenerateTypeTransition(MacroAssembler* masm) { |
2188 // Argument is in a0 and v0 at this point, so we can overwrite a0. | 2188 // Argument is in a0 and v0 at this point, so we can overwrite a0. |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2248 __ JumpIfNotSmi(a0, non_smi); | 2248 __ JumpIfNotSmi(a0, non_smi); |
2249 | 2249 |
2250 // Flip bits and revert inverted smi-tag. | 2250 // Flip bits and revert inverted smi-tag. |
2251 __ Neg(v0, a0); | 2251 __ Neg(v0, a0); |
2252 __ And(v0, v0, ~kSmiTagMask); | 2252 __ And(v0, v0, ~kSmiTagMask); |
2253 __ Ret(); | 2253 __ Ret(); |
2254 } | 2254 } |
2255 | 2255 |
2256 | 2256 |
2257 // TODO(svenpanne): Use virtual functions instead of switch. | 2257 // TODO(svenpanne): Use virtual functions instead of switch. |
2258 void UnaryOpStub::GenerateHeapNumberStub(MacroAssembler* masm) { | 2258 void UnaryOpStub::GenerateNumberStub(MacroAssembler* masm) { |
2259 switch (op_) { | 2259 switch (op_) { |
2260 case Token::SUB: | 2260 case Token::SUB: |
2261 GenerateHeapNumberStubSub(masm); | 2261 GenerateNumberStubSub(masm); |
2262 break; | 2262 break; |
2263 case Token::BIT_NOT: | 2263 case Token::BIT_NOT: |
2264 GenerateHeapNumberStubBitNot(masm); | 2264 GenerateNumberStubBitNot(masm); |
2265 break; | 2265 break; |
2266 default: | 2266 default: |
2267 UNREACHABLE(); | 2267 UNREACHABLE(); |
2268 } | 2268 } |
2269 } | 2269 } |
2270 | 2270 |
2271 | 2271 |
2272 void UnaryOpStub::GenerateHeapNumberStubSub(MacroAssembler* masm) { | 2272 void UnaryOpStub::GenerateNumberStubSub(MacroAssembler* masm) { |
2273 Label non_smi, slow, call_builtin; | 2273 Label non_smi, slow, call_builtin; |
2274 GenerateSmiCodeSub(masm, &non_smi, &call_builtin); | 2274 GenerateSmiCodeSub(masm, &non_smi, &call_builtin); |
2275 __ bind(&non_smi); | 2275 __ bind(&non_smi); |
2276 GenerateHeapNumberCodeSub(masm, &slow); | 2276 GenerateHeapNumberCodeSub(masm, &slow); |
2277 __ bind(&slow); | 2277 __ bind(&slow); |
2278 GenerateTypeTransition(masm); | 2278 GenerateTypeTransition(masm); |
2279 __ bind(&call_builtin); | 2279 __ bind(&call_builtin); |
2280 GenerateGenericCodeFallback(masm); | 2280 GenerateGenericCodeFallback(masm); |
2281 } | 2281 } |
2282 | 2282 |
2283 | 2283 |
2284 void UnaryOpStub::GenerateHeapNumberStubBitNot(MacroAssembler* masm) { | 2284 void UnaryOpStub::GenerateNumberStubBitNot(MacroAssembler* masm) { |
2285 Label non_smi, slow; | 2285 Label non_smi, slow; |
2286 GenerateSmiCodeBitNot(masm, &non_smi); | 2286 GenerateSmiCodeBitNot(masm, &non_smi); |
2287 __ bind(&non_smi); | 2287 __ bind(&non_smi); |
2288 GenerateHeapNumberCodeBitNot(masm, &slow); | 2288 GenerateHeapNumberCodeBitNot(masm, &slow); |
2289 __ bind(&slow); | 2289 __ bind(&slow); |
2290 GenerateTypeTransition(masm); | 2290 GenerateTypeTransition(masm); |
2291 } | 2291 } |
2292 | 2292 |
2293 | 2293 |
2294 void UnaryOpStub::GenerateHeapNumberCodeSub(MacroAssembler* masm, | 2294 void UnaryOpStub::GenerateHeapNumberCodeSub(MacroAssembler* masm, |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2689 // Load the operands. | 2689 // Load the operands. |
2690 if (smi_operands) { | 2690 if (smi_operands) { |
2691 FloatingPointHelper::LoadSmis(masm, destination, scratch1, scratch2); | 2691 FloatingPointHelper::LoadSmis(masm, destination, scratch1, scratch2); |
2692 } else { | 2692 } else { |
2693 // Load right operand to f14 or a2/a3. | 2693 // Load right operand to f14 or a2/a3. |
2694 if (right_type == BinaryOpIC::INT32) { | 2694 if (right_type == BinaryOpIC::INT32) { |
2695 FloatingPointHelper::LoadNumberAsInt32Double( | 2695 FloatingPointHelper::LoadNumberAsInt32Double( |
2696 masm, right, destination, f14, f16, a2, a3, heap_number_map, | 2696 masm, right, destination, f14, f16, a2, a3, heap_number_map, |
2697 scratch1, scratch2, f2, miss); | 2697 scratch1, scratch2, f2, miss); |
2698 } else { | 2698 } else { |
2699 Label* fail = (right_type == BinaryOpIC::HEAP_NUMBER) ? miss | 2699 Label* fail = (right_type == BinaryOpIC::NUMBER) ? miss |
2700 : not_numbers; | 2700 : not_numbers; |
rossberg
2013/03/04 14:03:11
Nit: this looks like it could fit on the previous
palfia
2013/03/04 14:39:50
Done.
| |
2701 FloatingPointHelper::LoadNumber( | 2701 FloatingPointHelper::LoadNumber( |
2702 masm, destination, right, f14, a2, a3, heap_number_map, | 2702 masm, destination, right, f14, a2, a3, heap_number_map, |
2703 scratch1, scratch2, fail); | 2703 scratch1, scratch2, fail); |
2704 } | 2704 } |
2705 // Load left operand to f12 or a0/a1. This keeps a0/a1 intact if it | 2705 // Load left operand to f12 or a0/a1. This keeps a0/a1 intact if it |
2706 // jumps to |miss|. | 2706 // jumps to |miss|. |
2707 if (left_type == BinaryOpIC::INT32) { | 2707 if (left_type == BinaryOpIC::INT32) { |
2708 FloatingPointHelper::LoadNumberAsInt32Double( | 2708 FloatingPointHelper::LoadNumberAsInt32Double( |
2709 masm, left, destination, f12, f16, a0, a1, heap_number_map, | 2709 masm, left, destination, f12, f16, a0, a1, heap_number_map, |
2710 scratch1, scratch2, f2, miss); | 2710 scratch1, scratch2, f2, miss); |
2711 } else { | 2711 } else { |
2712 Label* fail = (left_type == BinaryOpIC::HEAP_NUMBER) ? miss | 2712 Label* fail = (left_type == BinaryOpIC::NUMBER) ? miss |
2713 : not_numbers; | 2713 : not_numbers; |
rossberg
2013/03/04 14:03:11
Same here.
palfia
2013/03/04 14:39:50
Done.
| |
2714 FloatingPointHelper::LoadNumber( | 2714 FloatingPointHelper::LoadNumber( |
2715 masm, destination, left, f12, a0, a1, heap_number_map, | 2715 masm, destination, left, f12, a0, a1, heap_number_map, |
2716 scratch1, scratch2, fail); | 2716 scratch1, scratch2, fail); |
2717 } | 2717 } |
2718 } | 2718 } |
2719 | 2719 |
2720 // Calculate the result. | 2720 // Calculate the result. |
2721 if (destination == FloatingPointHelper::kFPURegisters) { | 2721 if (destination == FloatingPointHelper::kFPURegisters) { |
2722 // Using FPU registers: | 2722 // Using FPU registers: |
2723 // f12: Left value. | 2723 // f12: Left value. |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3102 // Tag the result and return. | 3102 // Tag the result and return. |
3103 __ SmiTag(v0, scratch1); | 3103 __ SmiTag(v0, scratch1); |
3104 __ Ret(); | 3104 __ Ret(); |
3105 } else { | 3105 } else { |
3106 // DIV just falls through to allocating a heap number. | 3106 // DIV just falls through to allocating a heap number. |
3107 } | 3107 } |
3108 | 3108 |
3109 __ bind(&return_heap_number); | 3109 __ bind(&return_heap_number); |
3110 // Return a heap number, or fall through to type transition or runtime | 3110 // Return a heap number, or fall through to type transition or runtime |
3111 // call if we can't. | 3111 // call if we can't. |
3112 if (result_type_ >= ((op_ == Token::DIV) ? BinaryOpIC::HEAP_NUMBER | 3112 if (result_type_ >= ((op_ == Token::DIV) ? BinaryOpIC::NUMBER |
3113 : BinaryOpIC::INT32)) { | 3113 : BinaryOpIC::INT32)) { |
3114 // We are using FPU registers so s0 is available. | 3114 // We are using FPU registers so s0 is available. |
3115 heap_number_result = s0; | 3115 heap_number_result = s0; |
3116 BinaryOpStub_GenerateHeapResultAllocation(masm, | 3116 BinaryOpStub_GenerateHeapResultAllocation(masm, |
3117 heap_number_result, | 3117 heap_number_result, |
3118 heap_number_map, | 3118 heap_number_map, |
3119 scratch1, | 3119 scratch1, |
3120 scratch2, | 3120 scratch2, |
3121 &call_runtime, | 3121 &call_runtime, |
3122 mode_); | 3122 mode_); |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3331 __ bind(&check); | 3331 __ bind(&check); |
3332 __ LoadRoot(t0, Heap::kUndefinedValueRootIndex); | 3332 __ LoadRoot(t0, Heap::kUndefinedValueRootIndex); |
3333 __ Branch(&done, ne, a0, Operand(t0)); | 3333 __ Branch(&done, ne, a0, Operand(t0)); |
3334 if (Token::IsBitOp(op_)) { | 3334 if (Token::IsBitOp(op_)) { |
3335 __ li(a0, Operand(Smi::FromInt(0))); | 3335 __ li(a0, Operand(Smi::FromInt(0))); |
3336 } else { | 3336 } else { |
3337 __ LoadRoot(a0, Heap::kNanValueRootIndex); | 3337 __ LoadRoot(a0, Heap::kNanValueRootIndex); |
3338 } | 3338 } |
3339 __ bind(&done); | 3339 __ bind(&done); |
3340 | 3340 |
3341 GenerateHeapNumberStub(masm); | 3341 GenerateNumberStub(masm); |
3342 } | 3342 } |
3343 | 3343 |
3344 | 3344 |
3345 void BinaryOpStub::GenerateHeapNumberStub(MacroAssembler* masm) { | 3345 void BinaryOpStub::GenerateNumberStub(MacroAssembler* masm) { |
3346 Label call_runtime, transition; | 3346 Label call_runtime, transition; |
3347 BinaryOpStub_GenerateFPOperation( | 3347 BinaryOpStub_GenerateFPOperation( |
3348 masm, left_type_, right_type_, false, | 3348 masm, left_type_, right_type_, false, |
3349 &transition, &call_runtime, &transition, op_, mode_); | 3349 &transition, &call_runtime, &transition, op_, mode_); |
3350 | 3350 |
3351 __ bind(&transition); | 3351 __ bind(&transition); |
3352 GenerateTypeTransition(masm); | 3352 GenerateTypeTransition(masm); |
3353 | 3353 |
3354 __ bind(&call_runtime); | 3354 __ bind(&call_runtime); |
3355 GenerateRegisterArgsPush(masm); | 3355 GenerateRegisterArgsPush(masm); |
(...skipping 3679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7035 __ SmiUntag(a0); | 7035 __ SmiUntag(a0); |
7036 __ Subu(v0, a1, a0); | 7036 __ Subu(v0, a1, a0); |
7037 } | 7037 } |
7038 __ Ret(); | 7038 __ Ret(); |
7039 | 7039 |
7040 __ bind(&miss); | 7040 __ bind(&miss); |
7041 GenerateMiss(masm); | 7041 GenerateMiss(masm); |
7042 } | 7042 } |
7043 | 7043 |
7044 | 7044 |
7045 void ICCompareStub::GenerateHeapNumbers(MacroAssembler* masm) { | 7045 void ICCompareStub::GenerateNumbers(MacroAssembler* masm) { |
7046 ASSERT(state_ == CompareIC::HEAP_NUMBER); | 7046 ASSERT(state_ == CompareIC::NUMBER); |
7047 | 7047 |
7048 Label generic_stub; | 7048 Label generic_stub; |
7049 Label unordered, maybe_undefined1, maybe_undefined2; | 7049 Label unordered, maybe_undefined1, maybe_undefined2; |
7050 Label miss; | 7050 Label miss; |
7051 | 7051 |
7052 if (left_ == CompareIC::SMI) { | 7052 if (left_ == CompareIC::SMI) { |
7053 __ JumpIfNotSmi(a1, &miss); | 7053 __ JumpIfNotSmi(a1, &miss); |
7054 } | 7054 } |
7055 if (right_ == CompareIC::SMI) { | 7055 if (right_ == CompareIC::SMI) { |
7056 __ JumpIfNotSmi(a0, &miss); | 7056 __ JumpIfNotSmi(a0, &miss); |
(...skipping 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8061 __ Pop(ra, t1, a1); | 8061 __ Pop(ra, t1, a1); |
8062 __ Ret(); | 8062 __ Ret(); |
8063 } | 8063 } |
8064 | 8064 |
8065 | 8065 |
8066 #undef __ | 8066 #undef __ |
8067 | 8067 |
8068 } } // namespace v8::internal | 8068 } } // namespace v8::internal |
8069 | 8069 |
8070 #endif // V8_TARGET_ARCH_MIPS | 8070 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |