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 2640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2651 // Allocate a heap number. | 2651 // Allocate a heap number. |
2652 __ CallRuntime(Runtime::kNumberAlloc, 0); | 2652 __ CallRuntime(Runtime::kNumberAlloc, 0); |
2653 __ movq(rbx, rax); | 2653 __ movq(rbx, rax); |
2654 | 2654 |
2655 __ bind(&heapnumber_allocated); | 2655 __ bind(&heapnumber_allocated); |
2656 | 2656 |
2657 // Return a random uint32 number in rax. | 2657 // Return a random uint32 number in rax. |
2658 // The fresh HeapNumber is in rbx, which is callee-save on both x64 ABIs. | 2658 // The fresh HeapNumber is in rbx, which is callee-save on both x64 ABIs. |
2659 __ PrepareCallCFunction(1); | 2659 __ PrepareCallCFunction(1); |
2660 #ifdef _WIN64 | 2660 #ifdef _WIN64 |
2661 __ LoadAddress(rcx, ExternalReference::isolate_address()); | 2661 __ movq(rcx, ContextOperand(context_register(), Context::GLOBAL_INDEX)); |
| 2662 __ movq(rcx, FieldOperand(rcx, GlobalObject::kGlobalContextOffset)); |
| 2663 |
2662 #else | 2664 #else |
2663 __ LoadAddress(rdi, ExternalReference::isolate_address()); | 2665 __ movq(rdi, ContextOperand(context_register(), Context::GLOBAL_INDEX)); |
| 2666 __ movq(rdi, FieldOperand(rdi, GlobalObject::kGlobalContextOffset)); |
2664 #endif | 2667 #endif |
2665 __ CallCFunction(ExternalReference::random_uint32_function(isolate()), 1); | 2668 __ CallCFunction(ExternalReference::random_uint32_function(isolate()), 1); |
2666 | 2669 |
2667 // Convert 32 random bits in rax to 0.(32 random bits) in a double | 2670 // Convert 32 random bits in rax to 0.(32 random bits) in a double |
2668 // by computing: | 2671 // by computing: |
2669 // ( 1.(20 0s)(32 random bits) x 2^20 ) - (1.0 x 2^20)). | 2672 // ( 1.(20 0s)(32 random bits) x 2^20 ) - (1.0 x 2^20)). |
2670 __ movl(rcx, Immediate(0x49800000)); // 1.0 x 2^20 as single. | 2673 __ movl(rcx, Immediate(0x49800000)); // 1.0 x 2^20 as single. |
2671 __ movd(xmm1, rcx); | 2674 __ movd(xmm1, rcx); |
2672 __ movd(xmm0, rax); | 2675 __ movd(xmm0, rax); |
2673 __ cvtss2sd(xmm1, xmm1); | 2676 __ cvtss2sd(xmm1, xmm1); |
(...skipping 1522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4196 *context_length = 0; | 4199 *context_length = 0; |
4197 return previous_; | 4200 return previous_; |
4198 } | 4201 } |
4199 | 4202 |
4200 | 4203 |
4201 #undef __ | 4204 #undef __ |
4202 | 4205 |
4203 } } // namespace v8::internal | 4206 } } // namespace v8::internal |
4204 | 4207 |
4205 #endif // V8_TARGET_ARCH_X64 | 4208 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |