Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(878)

Side by Side Diff: src/v8.cc

Issue 80513004: Revert 17963, 17962 and 17955: Random number generator in JS changes (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Remove Yang's changes, too Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/v8.h ('k') | src/x64/full-codegen-x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 #endif 112 #endif
113 } 113 }
114 114
115 115
116 void V8::SetReturnAddressLocationResolver( 116 void V8::SetReturnAddressLocationResolver(
117 ReturnAddressLocationResolver resolver) { 117 ReturnAddressLocationResolver resolver) {
118 StackFrame::SetReturnAddressLocationResolver(resolver); 118 StackFrame::SetReturnAddressLocationResolver(resolver);
119 } 119 }
120 120
121 121
122 // Used by JavaScript APIs
123 uint32_t V8::Random(Context* context) {
124 ASSERT(context->IsNativeContext());
125 ByteArray* seed = context->random_seed();
126 uint32_t* state = reinterpret_cast<uint32_t*>(seed->GetDataStartAddress());
127
128 // When we get here, the RNG must have been initialized,
129 // see the Genesis constructor in file bootstrapper.cc.
130 ASSERT_NE(0, state[0]);
131 ASSERT_NE(0, state[1]);
132
133 // Mix the bits. Never replaces state[i] with 0 if it is nonzero.
134 state[0] = 18273 * (state[0] & 0xFFFF) + (state[0] >> 16);
135 state[1] = 36969 * (state[1] & 0xFFFF) + (state[1] >> 16);
136
137 return (state[0] << 14) + (state[1] & 0x3FFFF);
138 }
139
140
122 void V8::AddCallCompletedCallback(CallCompletedCallback callback) { 141 void V8::AddCallCompletedCallback(CallCompletedCallback callback) {
123 if (call_completed_callbacks_ == NULL) { // Lazy init. 142 if (call_completed_callbacks_ == NULL) { // Lazy init.
124 call_completed_callbacks_ = new List<CallCompletedCallback>(); 143 call_completed_callbacks_ = new List<CallCompletedCallback>();
125 } 144 }
126 for (int i = 0; i < call_completed_callbacks_->length(); i++) { 145 for (int i = 0; i < call_completed_callbacks_->length(); i++) {
127 if (callback == call_completed_callbacks_->at(i)) return; 146 if (callback == call_completed_callbacks_->at(i)) return;
128 } 147 }
129 call_completed_callbacks_->Add(callback); 148 call_completed_callbacks_->Add(callback);
130 } 149 }
131 150
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 platform_ = NULL; 220 platform_ = NULL;
202 } 221 }
203 222
204 223
205 v8::Platform* V8::GetCurrentPlatform() { 224 v8::Platform* V8::GetCurrentPlatform() {
206 ASSERT(platform_); 225 ASSERT(platform_);
207 return platform_; 226 return platform_;
208 } 227 }
209 228
210 } } // namespace v8::internal 229 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/v8.h ('k') | src/x64/full-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698