⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 260490 in webkit


Ignore:
Timestamp:
Apr 21, 2020, 7:54:28 PM (6 years ago)
Author:
ysuzuki@apple.com
Message:

[JSC] SpeculativeJIT::nonSpeculativeNonPeepholeStrictEq should expect AnyBigIntUse
https://bugs.webkit.org/show_bug.cgi?id=210832

Reviewed by Mark Lam.

JSTests:

  • stress/heap-and-32-bigint-eq.js: Added.

(shouldBe):

  • stress/heap-and-32-bigint-stricteq.js: Added.

(shouldBe):

Source/JavaScriptCore:

SpeculativeJIT::nonSpeculativeNonPeepholeStrictEq will get AnyBigIntUse now. We should use ManualOperandSpeculation
and speculate function to perform speculation check.

  • dfg/DFGSpeculativeJIT32_64.cpp:

(JSC::DFG::SpeculativeJIT::nonSpeculativePeepholeStrictEq):
(JSC::DFG::SpeculativeJIT::nonSpeculativeNonPeepholeStrictEq):

  • dfg/DFGSpeculativeJIT64.cpp:

(JSC::DFG::SpeculativeJIT::nonSpeculativeNonPeepholeStrictEq):

  • jsc.cpp:

(functionCreateHeapBigInt):
(functionCreateBigInt32):

  • runtime/BigIntConstructor.cpp:

(JSC::toBigInt):
(JSC::callBigIntConstructor):

  • runtime/BigIntConstructor.h:
  • runtime/JSBigInt.h:
Location:
trunk
Files:
2 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r260447 r260490  
     12020-04-21  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] SpeculativeJIT::nonSpeculativeNonPeepholeStrictEq should expect AnyBigIntUse
     4        https://bugs.webkit.org/show_bug.cgi?id=210832
     5
     6        Reviewed by Mark Lam.
     7
     8        * stress/heap-and-32-bigint-eq.js: Added.
     9        (shouldBe):
     10        * stress/heap-and-32-bigint-stricteq.js: Added.
     11        (shouldBe):
     12
    1132020-04-21  Alexey Shvayka  <shvaikalesh@gmail.com>
    214
  • trunk/Source/JavaScriptCore/ChangeLog

    r260489 r260490  
     12020-04-21  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] SpeculativeJIT::nonSpeculativeNonPeepholeStrictEq should expect AnyBigIntUse
     4        https://bugs.webkit.org/show_bug.cgi?id=210832
     5
     6        Reviewed by Mark Lam.
     7
     8        SpeculativeJIT::nonSpeculativeNonPeepholeStrictEq will get AnyBigIntUse now. We should use ManualOperandSpeculation
     9        and speculate function to perform speculation check.
     10
     11        * dfg/DFGSpeculativeJIT32_64.cpp:
     12        (JSC::DFG::SpeculativeJIT::nonSpeculativePeepholeStrictEq):
     13        (JSC::DFG::SpeculativeJIT::nonSpeculativeNonPeepholeStrictEq):
     14        * dfg/DFGSpeculativeJIT64.cpp:
     15        (JSC::DFG::SpeculativeJIT::nonSpeculativeNonPeepholeStrictEq):
     16        * jsc.cpp:
     17        (functionCreateHeapBigInt):
     18        (functionCreateBigInt32):
     19        * runtime/BigIntConstructor.cpp:
     20        (JSC::toBigInt):
     21        (JSC::callBigIntConstructor):
     22        * runtime/BigIntConstructor.h:
     23        * runtime/JSBigInt.h:
     24
    1252020-04-21  Yusuke Suzuki  <ysuzuki@apple.com>
    226
  • trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp

    r260331 r260490  
    11851185}
    11861186
    1187 bool SpeculativeJIT::nonSpeculativeStrictEq(Node* node, bool invert)
     1187bool SpeculativeJIT::genericJSValueStrictEq(Node* node, bool invert)
    11881188{
    11891189    unsigned branchIndexInBlock = detectPeepHoleBranch();
     
    12011201    }
    12021202   
    1203     nonSpeculativeNonPeepholeStrictEq(node, invert);
     1203    genericJSValueNonPeepholeStrictEq(node, invert);
    12041204   
    12051205    return false;
     
    65236523
    65246524    ASSERT(node->isBinaryUseKind(UntypedUse) || node->isBinaryUseKind(AnyBigIntUse));
    6525     return nonSpeculativeStrictEq(node);
     6525    return genericJSValueStrictEq(node);
    65266526}
    65276527
  • trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h

    r260331 r260490  
    747747   
    748748    void nonSpeculativePeepholeStrictEq(Node*, Node* branchNode, bool invert = false);
    749     void nonSpeculativeNonPeepholeStrictEq(Node*, bool invert = false);
    750     bool nonSpeculativeStrictEq(Node*, bool invert = false);
     749    void genericJSValueNonPeepholeStrictEq(Node*, bool invert = false);
     750    bool genericJSValueStrictEq(Node*, bool invert = false);
    751751   
    752752    void compileInstanceOfForCells(Node*, JSValueRegs valueGPR, JSValueRegs prototypeGPR, GPRReg resultGPT, GPRReg scratchGPR, GPRReg scratch2GPR, JITCompiler::Jump slowCase = JITCompiler::Jump());
  • trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp

    r260331 r260490  
    398398    }
    399399   
    400     JSValueOperand arg1(this, node->child1());
    401     JSValueOperand arg2(this, node->child2());
     400    JSValueOperand arg1(this, node->child1(), ManualOperandSpeculation);
     401    JSValueOperand arg2(this, node->child2(), ManualOperandSpeculation);
     402    speculate(node, node->child1());
     403    speculate(node, node->child2());
    402404    GPRReg arg1PayloadGPR = arg1.payloadGPR();
    403405    GPRReg arg2PayloadGPR = arg2.payloadGPR();
     
    436438}
    437439
    438 void SpeculativeJIT::nonSpeculativeNonPeepholeStrictEq(Node* node, bool invert)
     440void SpeculativeJIT::genericJSValueNonPeepholeStrictEq(Node* node, bool invert)
    439441{
    440     JSValueOperand arg1(this, node->child1());
    441     JSValueOperand arg2(this, node->child2());
     442    JSValueOperand arg1(this, node->child1(), ManualOperandSpeculation);
     443    JSValueOperand arg2(this, node->child2(), ManualOperandSpeculation);
     444    speculate(node, node->child1());
     445    speculate(node, node->child2());
    442446    GPRReg arg1PayloadGPR = arg1.payloadGPR();
    443447    GPRReg arg2PayloadGPR = arg2.payloadGPR();
  • trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp

    r260331 r260490  
    420420}
    421421
    422 void SpeculativeJIT::nonSpeculativeNonPeepholeStrictEq(Node* node, bool invert)
     422void SpeculativeJIT::genericJSValueNonPeepholeStrictEq(Node* node, bool invert)
    423423{
    424424    // FIXME: some of this code should be shareable with nonSpeculativePeepholeStrictEq
    425     JSValueOperand arg1(this, node->child1());
    426     JSValueOperand arg2(this, node->child2());
     425    JSValueOperand arg1(this, node->child1(), ManualOperandSpeculation);
     426    JSValueOperand arg2(this, node->child2(), ManualOperandSpeculation);
     427    speculate(node, node->child1());
     428    speculate(node, node->child2());
    427429    JSValueRegs arg1Regs = arg1.jsValueRegs();
    428430    JSValueRegs arg2Regs = arg2.jsValueRegs();
  • trunk/Source/JavaScriptCore/jsc.cpp

    r260415 r260490  
    2525#include "ArrayBuffer.h"
    2626#include "ArrayPrototype.h"
     27#include "BigIntConstructor.h"
    2728#include "BuiltinNames.h"
    2829#include "ButterflyInlines.h"
     
    271272
    272273static EncodedJSValue JSC_HOST_CALL functionCreateGlobalObject(JSGlobalObject*, CallFrame*);
     274static EncodedJSValue JSC_HOST_CALL functionCreateHeapBigInt(JSGlobalObject*, CallFrame*);
     275static EncodedJSValue JSC_HOST_CALL functionCreateBigInt32(JSGlobalObject*, CallFrame*);
    273276
    274277static EncodedJSValue JSC_HOST_CALL functionPrintStdOut(JSGlobalObject*, CallFrame*);
     
    542545
    543546        addFunction(vm, "createGlobalObject", functionCreateGlobalObject, 0);
     547        addFunction(vm, "createHeapBigInt", functionCreateHeapBigInt, 1);
     548#if USE(BIGINT32)
     549        addFunction(vm, "createBigInt32", functionCreateBigInt32, 1);
     550#endif
    544551
    545552        addFunction(vm, "dumpTypesForAllVariables", functionDumpTypesForAllVariables , 0);
     
    22452252}
    22462253
     2254EncodedJSValue JSC_HOST_CALL functionCreateHeapBigInt(JSGlobalObject* globalObject, CallFrame* callFrame)
     2255{
     2256    VM& vm = globalObject->vm();
     2257    auto scope = DECLARE_THROW_SCOPE(vm);
     2258    JSValue argument = callFrame->argument(0);
     2259    JSValue bigInt = toBigInt(globalObject, argument);
     2260    RETURN_IF_EXCEPTION(scope, encodedJSValue());
     2261#if USE(BIGINT32)
     2262    if (bigInt.isHeapBigInt())
     2263        return JSValue::encode(bigInt);
     2264    ASSERT(bigInt.isBigInt32());
     2265    int32_t value = bigInt.bigInt32AsInt32();
     2266    return JSValue::encode(JSBigInt::createFrom(vm, value));
     2267#else
     2268    return JSValue::encode(bigInt);
     2269#endif
     2270}
     2271
     2272#if USE(BIGINT32)
     2273EncodedJSValue JSC_HOST_CALL functionCreateBigInt32(JSGlobalObject* globalObject, CallFrame* callFrame)
     2274{
     2275    VM& vm = globalObject->vm();
     2276    auto scope = DECLARE_THROW_SCOPE(vm);
     2277    JSValue argument = callFrame->argument(0);
     2278    JSValue bigIntValue = toBigInt(globalObject, argument);
     2279    RETURN_IF_EXCEPTION(scope, encodedJSValue());
     2280    if (bigIntValue.isBigInt32())
     2281        return JSValue::encode(bigIntValue);
     2282    ASSERT(bigIntValue.isHeapBigInt());
     2283    JSBigInt* bigInt = jsCast<JSBigInt*>(bigIntValue);
     2284    if (!bigInt->length())
     2285        return JSValue::encode(JSValue(JSValue::JSBigInt32, 0));
     2286    if (bigInt->length() == 1) {
     2287        JSBigInt::Digit digit = bigInt->digit(0);
     2288        if (bigInt->sign()) {
     2289            if (digit <= static_cast<uint64_t>(-static_cast<int64_t>(INT32_MIN)))
     2290                return JSValue::encode(JSValue(JSValue::JSBigInt32, static_cast<int32_t>(-static_cast<int64_t>(digit))));
     2291        } else {
     2292            if (digit <= INT32_MAX)
     2293                return JSValue::encode(JSValue(JSValue::JSBigInt32, static_cast<int32_t>(digit)));
     2294        }
     2295    }
     2296    throwTypeError(globalObject, scope, "Out of range of BigInt32"_s);
     2297    return { };
     2298}
     2299#endif
     2300
    22472301EncodedJSValue JSC_HOST_CALL functionCheckModuleSyntax(JSGlobalObject* globalObject, CallFrame* callFrame)
    22482302{
  • trunk/Source/JavaScriptCore/runtime/BigIntConstructor.cpp

    r260384 r260490  
    7676// ------------------------------ Functions ---------------------------
    7777
    78 static EncodedJSValue toBigInt(JSGlobalObject* globalObject, JSValue argument)
     78JSValue toBigInt(JSGlobalObject* globalObject, JSValue argument)
    7979{
    8080    ASSERT(argument.isPrimitive());
    8181    VM& vm = globalObject->vm();
     82    auto scope = DECLARE_THROW_SCOPE(vm);
    8283   
    8384    if (argument.isBigInt())
    84         return JSValue::encode(argument);
     85        return argument;
    8586
    8687    if (argument.isBoolean()) {
    8788#if USE(BIGINT32)
    88         return JSValue::encode(JSValue(JSValue::JSBigInt32, argument.asBoolean()));
     89        return JSValue(JSValue::JSBigInt32, argument.asBoolean());
    8990#else
    90         return JSValue::encode(JSBigInt::createFrom(vm, argument.asBoolean()));
     91        return JSBigInt::createFrom(vm, argument.asBoolean());
    9192#endif
    9293    }
    9394
    9495    if (argument.isString()) {
     96        scope.release();
    9597        return toStringView(globalObject, argument, [&] (StringView view) {
    96             return JSValue::encode(JSBigInt::parseInt(globalObject, view));
     98            return JSBigInt::parseInt(globalObject, view);
    9799        });
    98100    }
    99101
    100102    ASSERT(argument.isUndefinedOrNull() || argument.isNumber() || argument.isSymbol());
    101     auto scope = DECLARE_THROW_SCOPE(vm);
    102     return throwVMTypeError(globalObject, scope, "Invalid argument type in ToBigInt operation"_s);
     103    throwTypeError(globalObject, scope, "Invalid argument type in ToBigInt operation"_s);
     104    return jsUndefined();
    103105}
    104106
     
    130132    }
    131133
    132     EncodedJSValue result = toBigInt(globalObject, primitive);
    133     RETURN_IF_EXCEPTION(scope, encodedJSValue());
    134     return result;
     134    RELEASE_AND_RETURN(scope, JSValue::encode(toBigInt(globalObject, primitive)));
    135135}
    136136
  • trunk/Source/JavaScriptCore/runtime/BigIntConstructor.h

    r260415 r260490  
    5959STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(BigIntConstructor, InternalFunction);
    6060
     61JS_EXPORT_PRIVATE JSValue toBigInt(JSGlobalObject*, JSValue);
     62
    6163} // namespace JSC
  • trunk/Source/JavaScriptCore/runtime/JSBigInt.h

    r260489 r260490  
    6464    static JSBigInt* createWithLengthUnchecked(VM&, unsigned length);
    6565
    66     static JSBigInt* createFrom(VM&, int32_t value);
     66    JS_EXPORT_PRIVATE static JSBigInt* createFrom(VM&, int32_t value);
    6767    static JSBigInt* createFrom(VM&, uint32_t value);
    6868    static JSBigInt* createFrom(VM&, int64_t value);
Note: See TracChangeset for help on using the changeset viewer.