OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 2683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2694 __ bind(&slow_allocate_heapnumber); | 2694 __ bind(&slow_allocate_heapnumber); |
2695 // Allocate a heap number. | 2695 // Allocate a heap number. |
2696 __ CallRuntime(Runtime::kNumberAlloc, 0); | 2696 __ CallRuntime(Runtime::kNumberAlloc, 0); |
2697 __ movq(rbx, rax); | 2697 __ movq(rbx, rax); |
2698 | 2698 |
2699 __ bind(&heapnumber_allocated); | 2699 __ bind(&heapnumber_allocated); |
2700 | 2700 |
2701 // Return a random uint32 number in rax. | 2701 // Return a random uint32 number in rax. |
2702 // The fresh HeapNumber is in rbx, which is callee-save on both x64 ABIs. | 2702 // The fresh HeapNumber is in rbx, which is callee-save on both x64 ABIs. |
2703 __ PrepareCallCFunction(0); | 2703 __ PrepareCallCFunction(0); |
2704 __ CallCFunction(ExternalReference::random_uint32_function(), 0); | 2704 __ CallCFunction(ExternalReference::random_uint32_function(isolate()), 0); |
2705 | 2705 |
2706 // Convert 32 random bits in rax to 0.(32 random bits) in a double | 2706 // Convert 32 random bits in rax to 0.(32 random bits) in a double |
2707 // by computing: | 2707 // by computing: |
2708 // ( 1.(20 0s)(32 random bits) x 2^20 ) - (1.0 x 2^20)). | 2708 // ( 1.(20 0s)(32 random bits) x 2^20 ) - (1.0 x 2^20)). |
2709 __ movl(rcx, Immediate(0x49800000)); // 1.0 x 2^20 as single. | 2709 __ movl(rcx, Immediate(0x49800000)); // 1.0 x 2^20 as single. |
2710 __ movd(xmm1, rcx); | 2710 __ movd(xmm1, rcx); |
2711 __ movd(xmm0, rax); | 2711 __ movd(xmm0, rax); |
2712 __ cvtss2sd(xmm1, xmm1); | 2712 __ cvtss2sd(xmm1, xmm1); |
2713 __ xorpd(xmm0, xmm1); | 2713 __ xorpd(xmm0, xmm1); |
2714 __ subsd(xmm0, xmm1); | 2714 __ subsd(xmm0, xmm1); |
(...skipping 1281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3996 __ ret(0); | 3996 __ ret(0); |
3997 } | 3997 } |
3998 | 3998 |
3999 | 3999 |
4000 #undef __ | 4000 #undef __ |
4001 | 4001 |
4002 | 4002 |
4003 } } // namespace v8::internal | 4003 } } // namespace v8::internal |
4004 | 4004 |
4005 #endif // V8_TARGET_ARCH_X64 | 4005 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |