| 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 2112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2123 if (allow_heapnumber_results == BinaryOpStub::ALLOW_HEAPNUMBER_RESULTS) { | 2123 if (allow_heapnumber_results == BinaryOpStub::ALLOW_HEAPNUMBER_RESULTS) { |
| 2124 BinaryOpStub_GenerateFPOperation( | 2124 BinaryOpStub_GenerateFPOperation( |
| 2125 masm, BinaryOpIC::UNINITIALIZED, BinaryOpIC::UNINITIALIZED, true, | 2125 masm, BinaryOpIC::UNINITIALIZED, BinaryOpIC::UNINITIALIZED, true, |
| 2126 use_runtime, gc_required, ¬_smis, op, mode); | 2126 use_runtime, gc_required, ¬_smis, op, mode); |
| 2127 } | 2127 } |
| 2128 __ bind(¬_smis); | 2128 __ bind(¬_smis); |
| 2129 } | 2129 } |
| 2130 | 2130 |
| 2131 | 2131 |
| 2132 void BinaryOpStub::GenerateSmiStub(MacroAssembler* masm) { | 2132 void BinaryOpStub::GenerateSmiStub(MacroAssembler* masm) { |
| 2133 Label not_smis, call_runtime; | 2133 Label right_arg_changed, call_runtime; |
| 2134 |
| 2135 if (op_ == Token::MOD && has_fixed_right_arg_) { |
| 2136 // It is guaranteed that the value will fit into a Smi, because if it |
| 2137 // didn't, we wouldn't be here, see BinaryOp_Patch. |
| 2138 __ cmp(r0, Operand(Smi::FromInt(fixed_right_arg_value()))); |
| 2139 __ b(ne, &right_arg_changed); |
| 2140 } |
| 2134 | 2141 |
| 2135 if (result_type_ == BinaryOpIC::UNINITIALIZED || | 2142 if (result_type_ == BinaryOpIC::UNINITIALIZED || |
| 2136 result_type_ == BinaryOpIC::SMI) { | 2143 result_type_ == BinaryOpIC::SMI) { |
| 2137 // Only allow smi results. | 2144 // Only allow smi results. |
| 2138 BinaryOpStub_GenerateSmiCode( | 2145 BinaryOpStub_GenerateSmiCode( |
| 2139 masm, &call_runtime, NULL, op_, NO_HEAPNUMBER_RESULTS, mode_); | 2146 masm, &call_runtime, NULL, op_, NO_HEAPNUMBER_RESULTS, mode_); |
| 2140 } else { | 2147 } else { |
| 2141 // Allow heap number result and don't make a transition if a heap number | 2148 // Allow heap number result and don't make a transition if a heap number |
| 2142 // cannot be allocated. | 2149 // cannot be allocated. |
| 2143 BinaryOpStub_GenerateSmiCode( | 2150 BinaryOpStub_GenerateSmiCode( |
| 2144 masm, &call_runtime, &call_runtime, op_, ALLOW_HEAPNUMBER_RESULTS, | 2151 masm, &call_runtime, &call_runtime, op_, ALLOW_HEAPNUMBER_RESULTS, |
| 2145 mode_); | 2152 mode_); |
| 2146 } | 2153 } |
| 2147 | 2154 |
| 2148 // Code falls through if the result is not returned as either a smi or heap | 2155 // Code falls through if the result is not returned as either a smi or heap |
| 2149 // number. | 2156 // number. |
| 2157 __ bind(&right_arg_changed); |
| 2150 GenerateTypeTransition(masm); | 2158 GenerateTypeTransition(masm); |
| 2151 | 2159 |
| 2152 __ bind(&call_runtime); | 2160 __ bind(&call_runtime); |
| 2153 { | 2161 { |
| 2154 FrameScope scope(masm, StackFrame::INTERNAL); | 2162 FrameScope scope(masm, StackFrame::INTERNAL); |
| 2155 GenerateRegisterArgsPush(masm); | 2163 GenerateRegisterArgsPush(masm); |
| 2156 GenerateCallRuntime(masm); | 2164 GenerateCallRuntime(masm); |
| 2157 } | 2165 } |
| 2158 __ Ret(); | 2166 __ Ret(); |
| 2159 } | 2167 } |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2311 mode_); | 2319 mode_); |
| 2312 __ sub(r0, heap_number_result, Operand(kHeapObjectTag)); | 2320 __ sub(r0, heap_number_result, Operand(kHeapObjectTag)); |
| 2313 __ vstr(d5, r0, HeapNumber::kValueOffset); | 2321 __ vstr(d5, r0, HeapNumber::kValueOffset); |
| 2314 __ mov(r0, heap_number_result); | 2322 __ mov(r0, heap_number_result); |
| 2315 __ Ret(); | 2323 __ Ret(); |
| 2316 | 2324 |
| 2317 // A DIV operation expecting an integer result falls through | 2325 // A DIV operation expecting an integer result falls through |
| 2318 // to type transition. | 2326 // to type transition. |
| 2319 | 2327 |
| 2320 } else { | 2328 } else { |
| 2329 // TODO(svenpanne) We should check the right argument here, see the |
| 2330 // beginning of GenerateSmiStub, but I can't figure out how... :-/ |
| 2331 |
| 2321 // We preserved r0 and r1 to be able to call runtime. | 2332 // We preserved r0 and r1 to be able to call runtime. |
| 2322 // Save the left value on the stack. | 2333 // Save the left value on the stack. |
| 2323 __ Push(r5, r4); | 2334 __ Push(r5, r4); |
| 2324 | 2335 |
| 2325 Label pop_and_call_runtime; | 2336 Label pop_and_call_runtime; |
| 2326 | 2337 |
| 2327 // Allocate a heap number to store the result. | 2338 // Allocate a heap number to store the result. |
| 2328 heap_number_result = r5; | 2339 heap_number_result = r5; |
| 2329 BinaryOpStub_GenerateHeapResultAllocation(masm, | 2340 BinaryOpStub_GenerateHeapResultAllocation(masm, |
| 2330 heap_number_result, | 2341 heap_number_result, |
| (...skipping 5103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7434 __ Jump(generic_construct_stub, RelocInfo::CODE_TARGET); | 7445 __ Jump(generic_construct_stub, RelocInfo::CODE_TARGET); |
| 7435 } | 7446 } |
| 7436 } | 7447 } |
| 7437 | 7448 |
| 7438 | 7449 |
| 7439 #undef __ | 7450 #undef __ |
| 7440 | 7451 |
| 7441 } } // namespace v8::internal | 7452 } } // namespace v8::internal |
| 7442 | 7453 |
| 7443 #endif // V8_TARGET_ARCH_ARM | 7454 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |