Changeset 205267 in webkit


Ignore:
Timestamp:
Aug 31, 2016 2:03:34 PM (8 years ago)
Author:
Yusuke Suzuki
Message:

stress/random-53bit.js.ftl-no-cjit-no-inline-validate sometimes fails
https://bugs.webkit.org/show_bug.cgi?id=161436

Reviewed by Filip Pizlo.

JSTests:

The test checks Math.random() correctly produces 53bit random values.
The test can fail by design, but this should be fairly rare.

However, when introducing, we wrap the test() with 1e4 to ensure the FTL compilation, and this
increases the failure rate. By increasing the MAX in the test, we make the failures much more rare case.

And we also add getRandomSeed() and setRandomSeed(seed) JSC shell helpers to dump more useful information
and reproduce the situation easily.

  • stress/random-53bit.js:

(test):

Source/JavaScriptCore:

  • jsc.cpp:

(GlobalObject::finishCreation):
(functionGetRandomSeed):
(functionSetRandomSeed):

  • runtime/JSGlobalObject.h:

(JSC::JSGlobalObject::weakRandom):
(JSC::JSGlobalObject::weakRandomInteger): Deleted.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r205112 r205267  
     12016-08-31  Yusuke Suzuki  <utatane.tea@gmail.com>
     2
     3        stress/random-53bit.js.ftl-no-cjit-no-inline-validate sometimes fails
     4        https://bugs.webkit.org/show_bug.cgi?id=161436
     5
     6        Reviewed by Filip Pizlo.
     7
     8        The test checks Math.random() correctly produces 53bit random values.
     9        The test can fail by design, but this should be fairly rare.
     10
     11        However, when introducing, we wrap the `test()` with 1e4 to ensure the FTL compilation, and this
     12        increases the failure rate. By increasing the MAX in the test, we make the failures much more rare case.
     13
     14        And we also add getRandomSeed() and setRandomSeed(seed) JSC shell helpers to dump more useful information
     15        and reproduce the situation easily.
     16
     17        * stress/random-53bit.js:
     18        (test):
     19
    1202016-08-29  Benjamin Poulain  <bpoulain@apple.com>
    221
  • trunk/JSTests/stress/random-53bit.js

    r194087 r205267  
    11function test() {
    2     var MAX = 30;
     2    var MAX = 50;
    33    var found53Bit = false;
    44    var foundLessThan53Bit = false;
     5    var results = new Array(MAX);
    56
    67    for (var i = 0; i < MAX; ++i) {
    78        var str = Math.random().toString(2);
     9        results[i] = str;
    810        // 53 bit + '0.'.length
    911        if (str.length === (53 + 2))
     
    1517            return true;
    1618    }
     19    print(`Random seed ${getRandomSeed()}`);
     20    print(results.join('\n'));
    1721    return false;
    1822}
  • trunk/Source/JavaScriptCore/ChangeLog

    r205258 r205267  
     12016-08-31  Yusuke Suzuki  <utatane.tea@gmail.com>
     2
     3        stress/random-53bit.js.ftl-no-cjit-no-inline-validate sometimes fails
     4        https://bugs.webkit.org/show_bug.cgi?id=161436
     5
     6        Reviewed by Filip Pizlo.
     7
     8        * jsc.cpp:
     9        (GlobalObject::finishCreation):
     10        (functionGetRandomSeed):
     11        (functionSetRandomSeed):
     12        * runtime/JSGlobalObject.h:
     13        (JSC::JSGlobalObject::weakRandom):
     14        (JSC::JSGlobalObject::weakRandomInteger): Deleted.
     15
    1162016-08-31  Chris Dumez  <cdumez@apple.com>
    217
  • trunk/Source/JavaScriptCore/jsc.cpp

    r205198 r205267  
    648648static EncodedJSValue JSC_HOST_CALL functionShadowChickenFunctionsOnStack(ExecState*);
    649649static EncodedJSValue JSC_HOST_CALL functionSetGlobalConstRedeclarationShouldNotThrow(ExecState*);
     650static EncodedJSValue JSC_HOST_CALL functionGetRandomSeed(ExecState*);
     651static EncodedJSValue JSC_HOST_CALL functionSetRandomSeed(ExecState*);
    650652
    651653struct Script {
     
    857859
    858860        addFunction(vm, "drainMicrotasks", functionDrainMicrotasks, 0);
     861
     862        addFunction(vm, "getRandomSeed", functionGetRandomSeed, 0);
     863        addFunction(vm, "setRandomSeed", functionSetRandomSeed, 1);
    859864
    860865        addFunction(vm, "is32BitPlatform", functionIs32BitPlatform, 0);
     
    15981603}
    15991604
     1605EncodedJSValue JSC_HOST_CALL functionGetRandomSeed(ExecState* exec)
     1606{
     1607    return JSValue::encode(jsNumber(exec->lexicalGlobalObject()->weakRandom().seed()));
     1608}
     1609
     1610EncodedJSValue JSC_HOST_CALL functionSetRandomSeed(ExecState* exec)
     1611{
     1612    unsigned seed = exec->argument(0).toUInt32(exec);
     1613    if (exec->hadException())
     1614        return JSValue::encode(jsUndefined());
     1615    exec->lexicalGlobalObject()->weakRandom().setSeed(seed);
     1616    return JSValue::encode(jsUndefined());
     1617}
     1618
    16001619EncodedJSValue JSC_HOST_CALL functionReadline(ExecState* exec)
    16011620{
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h

    r204330 r205267  
    767767    double weakRandomNumber() { return m_weakRandom.get(); }
    768768    unsigned weakRandomInteger() { return m_weakRandom.getUint32(); }
     769    WeakRandom& weakRandom() { return m_weakRandom; }
    769770
    770771    UnlinkedProgramCodeBlock* createProgramCodeBlock(CallFrame*, ProgramExecutable*, JSObject** exception);
Note: See TracChangeset for help on using the changeset viewer.