| 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 Sampler::TearDown(); | 102 Sampler::TearDown(); |
| 103 } | 103 } |
| 104 | 104 |
| 105 | 105 |
| 106 void V8::SetReturnAddressLocationResolver( | 106 void V8::SetReturnAddressLocationResolver( |
| 107 ReturnAddressLocationResolver resolver) { | 107 ReturnAddressLocationResolver resolver) { |
| 108 StackFrame::SetReturnAddressLocationResolver(resolver); | 108 StackFrame::SetReturnAddressLocationResolver(resolver); |
| 109 } | 109 } |
| 110 | 110 |
| 111 | 111 |
| 112 // Used by JavaScript APIs | |
| 113 uint32_t V8::Random(Context* context) { | |
| 114 ASSERT(context->IsNativeContext()); | |
| 115 ByteArray* seed = context->random_seed(); | |
| 116 uint32_t* state = reinterpret_cast<uint32_t*>(seed->GetDataStartAddress()); | |
| 117 | |
| 118 // When we get here, the RNG must have been initialized, | |
| 119 // see the Genesis constructor in file bootstrapper.cc. | |
| 120 ASSERT_NE(0, state[0]); | |
| 121 ASSERT_NE(0, state[1]); | |
| 122 | |
| 123 // Mix the bits. Never replaces state[i] with 0 if it is nonzero. | |
| 124 state[0] = 18273 * (state[0] & 0xFFFF) + (state[0] >> 16); | |
| 125 state[1] = 36969 * (state[1] & 0xFFFF) + (state[1] >> 16); | |
| 126 | |
| 127 return (state[0] << 14) + (state[1] & 0x3FFFF); | |
| 128 } | |
| 129 | |
| 130 | |
| 131 void V8::AddCallCompletedCallback(CallCompletedCallback callback) { | 112 void V8::AddCallCompletedCallback(CallCompletedCallback callback) { |
| 132 if (call_completed_callbacks_ == NULL) { // Lazy init. | 113 if (call_completed_callbacks_ == NULL) { // Lazy init. |
| 133 call_completed_callbacks_ = new List<CallCompletedCallback>(); | 114 call_completed_callbacks_ = new List<CallCompletedCallback>(); |
| 134 } | 115 } |
| 135 for (int i = 0; i < call_completed_callbacks_->length(); i++) { | 116 for (int i = 0; i < call_completed_callbacks_->length(); i++) { |
| 136 if (callback == call_completed_callbacks_->at(i)) return; | 117 if (callback == call_completed_callbacks_->at(i)) return; |
| 137 } | 118 } |
| 138 call_completed_callbacks_->Add(callback); | 119 call_completed_callbacks_->Add(callback); |
| 139 } | 120 } |
| 140 | 121 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 ExternalReference::SetUp(); | 201 ExternalReference::SetUp(); |
| 221 Bootstrapper::InitializeOncePerProcess(); | 202 Bootstrapper::InitializeOncePerProcess(); |
| 222 } | 203 } |
| 223 | 204 |
| 224 | 205 |
| 225 void V8::InitializeOncePerProcess() { | 206 void V8::InitializeOncePerProcess() { |
| 226 CallOnce(&init_once, &InitializeOncePerProcessImpl); | 207 CallOnce(&init_once, &InitializeOncePerProcessImpl); |
| 227 } | 208 } |
| 228 | 209 |
| 229 } } // namespace v8::internal | 210 } } // namespace v8::internal |
| OLD | NEW |