| 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 3063 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3074 static const int kRandomSeedOffset = | 3074 static const int kRandomSeedOffset = |
| 3075 FixedArray::kHeaderSize + Context::RANDOM_SEED_INDEX * kPointerSize; | 3075 FixedArray::kHeaderSize + Context::RANDOM_SEED_INDEX * kPointerSize; |
| 3076 __ mov(ebx, FieldOperand(eax, kRandomSeedOffset)); | 3076 __ mov(ebx, FieldOperand(eax, kRandomSeedOffset)); |
| 3077 // ebx: FixedArray of the global context's random seeds | 3077 // ebx: FixedArray of the global context's random seeds |
| 3078 | 3078 |
| 3079 // Load state[0]. | 3079 // Load state[0]. |
| 3080 __ mov(ecx, FieldOperand(ebx, ByteArray::kHeaderSize)); | 3080 __ mov(ecx, FieldOperand(ebx, ByteArray::kHeaderSize)); |
| 3081 // If state[0] == 0, call runtime to initialize seeds. | 3081 // If state[0] == 0, call runtime to initialize seeds. |
| 3082 __ test(ecx, ecx); | 3082 __ test(ecx, ecx); |
| 3083 __ j(zero, deferred->entry()); | 3083 __ j(zero, deferred->entry()); |
| 3084 // Load state[1]. |
| 3085 __ mov(eax, FieldOperand(ebx, ByteArray::kHeaderSize + kSeedSize)); |
| 3086 // ecx: state[0] |
| 3087 // eax: state[1] |
| 3084 | 3088 |
| 3085 // state[0] = 18273 * (state[0] & 0xFFFF) + (state[0] >> 16) | 3089 // state[0] = 18273 * (state[0] & 0xFFFF) + (state[0] >> 16) |
| 3086 __ movzx_w(edx, ecx); | 3090 __ movzx_w(edx, ecx); |
| 3087 __ imul(edx, edx, 18273); | 3091 __ imul(edx, edx, 18273); |
| 3088 __ shr(ecx, 16); | 3092 __ shr(ecx, 16); |
| 3089 __ add(ecx, edx); | 3093 __ add(ecx, edx); |
| 3094 // Save state[0]. |
| 3090 __ mov(FieldOperand(ebx, ByteArray::kHeaderSize), ecx); | 3095 __ mov(FieldOperand(ebx, ByteArray::kHeaderSize), ecx); |
| 3091 | 3096 |
| 3092 // Load state[1]. | 3097 // state[1] = 36969 * (state[1] & 0xFFFF) + (state[1] >> 16) |
| 3093 // state[1] = 36969 * (state[1] & 0xFFFF) + (state[1] >> 16); | |
| 3094 __ mov(eax, FieldOperand(ebx, ByteArray::kHeaderSize + kSeedSize)); | |
| 3095 __ movzx_w(edx, eax); | 3098 __ movzx_w(edx, eax); |
| 3096 __ imul(edx, edx, 36969); | 3099 __ imul(edx, edx, 36969); |
| 3097 __ shr(eax, 16); | 3100 __ shr(eax, 16); |
| 3098 __ add(eax, edx); | 3101 __ add(eax, edx); |
| 3102 // Save state[1]. |
| 3099 __ mov(FieldOperand(ebx, ByteArray::kHeaderSize + kSeedSize), eax); | 3103 __ mov(FieldOperand(ebx, ByteArray::kHeaderSize + kSeedSize), eax); |
| 3100 | 3104 |
| 3101 // ecx: state[0] | |
| 3102 // eax: state[1] | |
| 3103 // Random bit pattern = (state[0] << 14) + (state[1] & 0x3FFFF) | 3105 // Random bit pattern = (state[0] << 14) + (state[1] & 0x3FFFF) |
| 3104 __ shl(ecx, 14); | 3106 __ shl(ecx, 14); |
| 3105 __ and_(eax, Immediate(0x3FFFF)); | 3107 __ and_(eax, Immediate(0x3FFFF)); |
| 3106 __ add(eax, ecx); | 3108 __ add(eax, ecx); |
| 3107 | 3109 |
| 3108 __ bind(deferred->exit()); | 3110 __ bind(deferred->exit()); |
| 3109 // Convert 32 random bits in eax to 0.(32 random bits) in a double | 3111 // Convert 32 random bits in eax to 0.(32 random bits) in a double |
| 3110 // by computing: | 3112 // by computing: |
| 3111 // ( 1.(20 0s)(32 random bits) x 2^20 ) - (1.0 x 2^20)). | 3113 // ( 1.(20 0s)(32 random bits) x 2^20 ) - (1.0 x 2^20)). |
| 3112 __ mov(ebx, Immediate(0x49800000)); // 1.0 x 2^20 as single. | 3114 __ mov(ebx, Immediate(0x49800000)); // 1.0 x 2^20 as single. |
| (...skipping 1842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4955 FixedArray::kHeaderSize - kPointerSize)); | 4957 FixedArray::kHeaderSize - kPointerSize)); |
| 4956 __ bind(&done); | 4958 __ bind(&done); |
| 4957 } | 4959 } |
| 4958 | 4960 |
| 4959 | 4961 |
| 4960 #undef __ | 4962 #undef __ |
| 4961 | 4963 |
| 4962 } } // namespace v8::internal | 4964 } } // namespace v8::internal |
| 4963 | 4965 |
| 4964 #endif // V8_TARGET_ARCH_IA32 | 4966 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |