Commit a27a7a70 authored by oliver@apple.com's avatar oliver@apple.com
Browse files

2010-08-24 Oliver Hunt <oliver@apple.com>

        Reviewed by Geoff Garen.

        Don't seed the JS random number generator from time()
        https://bugs.webkit.org/show_bug.cgi?id=41868
        <rdar://problem/8171025>

        Switch to using the secure random number generator to
        seed the fast random generator, and make the generator
        be per global object.

        * runtime/JSGlobalData.cpp:
        (JSC::JSGlobalData::JSGlobalData):
        * runtime/JSGlobalData.h:
        * runtime/JSGlobalObject.h:
        (JSC::JSGlobalObject::JSGlobalObjectData::JSGlobalObjectData):
        (JSC::JSGlobalObject::weakRandomNumber):
        * runtime/MathObject.cpp:
        (JSC::mathProtoFuncRandom):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@65947 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 60409623
2010-08-24 Oliver Hunt <oliver@apple.com>
Reviewed by Geoff Garen.
Don't seed the JS random number generator from time()
https://bugs.webkit.org/show_bug.cgi?id=41868
<rdar://problem/8171025>
Switch to using the secure random number generator to
seed the fast random generator, and make the generator
be per global object.
* runtime/JSGlobalData.cpp:
(JSC::JSGlobalData::JSGlobalData):
* runtime/JSGlobalData.h:
* runtime/JSGlobalObject.h:
(JSC::JSGlobalObject::JSGlobalObjectData::JSGlobalObjectData):
(JSC::JSGlobalObject::weakRandomNumber):
* runtime/MathObject.cpp:
(JSC::mathProtoFuncRandom):
2010-08-24 Oliver Hunt <oliver@apple.com>
Reviewed by Beth Dakin.
......
......@@ -143,7 +143,6 @@ JSGlobalData::JSGlobalData(GlobalDataType globalDataType, ThreadStackType thread
, firstStringifierToMark(0)
, markStack(jsArrayVPtr)
, cachedUTCOffset(NaN)
, weakRandom(static_cast<int>(currentTime()))
, maxReentryDepth(threadStackType == ThreadStackTypeSmall ? MaxSmallThreadReentryDepth : MaxLargeThreadReentryDepth)
, m_regExpCache(new RegExpCache(this))
#ifndef NDEBUG
......
......@@ -213,8 +213,6 @@ namespace JSC {
UString cachedDateString;
double cachedDateStringValue;
WeakRandom weakRandom;
int maxReentryDepth;
......
......@@ -31,6 +31,7 @@
#include "StringPrototype.h"
#include <wtf/HashSet.h>
#include <wtf/OwnPtr.h>
#include <wtf/RandomNumber.h>
namespace JSC {
......@@ -92,6 +93,7 @@ namespace JSC {
, datePrototype(0)
, regExpPrototype(0)
, methodCallDummy(0)
, weakRandom(static_cast<unsigned>(randomNumber() * (std::numeric_limits<unsigned>::max() + 1.0)))
{
}
......@@ -156,6 +158,7 @@ namespace JSC {
HashSet<GlobalCodeBlock*> codeBlocks;
WeakMapSet weakMaps;
WeakRandom weakRandom;
};
public:
......@@ -295,6 +298,7 @@ namespace JSC {
d()->weakMaps.remove(map);
}
double weakRandomNumber() { return d()->weakRandom.get(); }
protected:
static const unsigned AnonymousSlotCount = JSVariableObject::AnonymousSlotCount + 1;
......
......@@ -211,7 +211,7 @@ EncodedJSValue JSC_HOST_CALL mathProtoFuncPow(ExecState* exec)
EncodedJSValue JSC_HOST_CALL mathProtoFuncRandom(ExecState* exec)
{
return JSValue::encode(jsDoubleNumber(exec, exec->globalData().weakRandom.get()));
return JSValue::encode(jsDoubleNumber(exec, exec->lexicalGlobalObject()->weakRandomNumber()));
}
EncodedJSValue JSC_HOST_CALL mathProtoFuncRound(ExecState* exec)
......
2010-08-24 Oliver Hunt <oliver@apple.com>
Reviewed by Geoff Garen.
Don't seed the JS random number generator from time()
https://bugs.webkit.org/show_bug.cgi?id=41868
<rdar://problem/8171025>
Add forwarding header for RandomNumber in JavaScriptGlue
* ForwardingHeaders/wtf/RandomNumber.h: Added.
2010-08-11 Gavin Barraclough <barraclough@apple.com>
Rubber stamps by Darin Adler & Sam Weinig.
......
#include <JavaScriptCore/RandomNumber.h>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment