Changeset 252231 in webkit


Ignore:
Timestamp:
Nov 7, 2019 7:55:47 PM (4 years ago)
Author:
Tadeu Zagallo
Message:

Use fewer virtual registers in Wasm LLInt
https://bugs.webkit.org/show_bug.cgi?id=203861

Reviewed by Saam Barati.

Reduce the number of virtual registers in two ways:

  • Re-use arguments for result values (e.g. the result of add lhs, rhs should go in lhs, not a new virtual register)
  • Re-use the argument register space for return values that should be placed in registers
  • bytecode/BytecodeList.rb:
  • generator/Wasm.rb:
  • llint/WebAssembly.asm:
  • wasm/WasmLLIntGenerator.cpp:

(JSC::Wasm::LLIntGenerator::callInformationFor):
(JSC::Wasm::LLIntGenerator::addReturn):
(JSC::Wasm::LLIntGenerator::addRefIsNull):
(JSC::Wasm::LLIntGenerator::addTableGet):
(JSC::Wasm::LLIntGenerator::addTableGrow):
(JSC::Wasm::LLIntGenerator::addGrowMemory):
(JSC::Wasm::LLIntGenerator::addSelect):
(JSC::Wasm::LLIntGenerator::load):

Location:
trunk/Source/JavaScriptCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r252229 r252231  
     12019-11-07  Tadeu Zagallo  <tzagallo@apple.com>
     2
     3        Use fewer virtual registers in Wasm LLInt
     4        https://bugs.webkit.org/show_bug.cgi?id=203861
     5
     6        Reviewed by Saam Barati.
     7
     8        Reduce the number of virtual registers in two ways:
     9        - Re-use arguments for result values (e.g. the result of add lhs, rhs should go in lhs, not a new virtual register)
     10        - Re-use the argument register space for return values that should be placed in registers
     11
     12        * bytecode/BytecodeList.rb:
     13        * generator/Wasm.rb:
     14        * llint/WebAssembly.asm:
     15        * wasm/WasmLLIntGenerator.cpp:
     16        (JSC::Wasm::LLIntGenerator::callInformationFor):
     17        (JSC::Wasm::LLIntGenerator::addReturn):
     18        (JSC::Wasm::LLIntGenerator::addRefIsNull):
     19        (JSC::Wasm::LLIntGenerator::addTableGet):
     20        (JSC::Wasm::LLIntGenerator::addTableGrow):
     21        (JSC::Wasm::LLIntGenerator::addGrowMemory):
     22        (JSC::Wasm::LLIntGenerator::addSelect):
     23        (JSC::Wasm::LLIntGenerator::load):
     24
    1252019-11-07  Robin Morisset  <rmorisset@apple.com>
    226
  • trunk/Source/JavaScriptCore/bytecode/BytecodeList.rb

    r252229 r252231  
    12881288    }
    12891289
    1290 op :ret,
    1291     args: {
    1292         stackOffset: unsigned,
    1293     }
     1290op :ret
    12941291
    12951292op :switch,
  • trunk/Source/JavaScriptCore/generator/Wasm.rb

    r251886 r252231  
    5959auto LLIntGenerator::addOp<#{op_type(op)}>(ExpressionType lhs, ExpressionType rhs, ExpressionType& result) -> PartialResult
    6060{
    61     result = newTemporary();
     61    result = lhs;
    6262    #{op.capitalized_name}::emit(this, result, lhs, rhs);
    6363    return { };
     
    7171auto LLIntGenerator::addOp<#{op_type(op)}>(ExpressionType operand, ExpressionType& result) -> PartialResult
    7272{
    73     result = newTemporary();
     73    result = operand;
    7474    #{op.capitalized_name}::emit(this, result, operand);
    7575    return { };
  • trunk/Source/JavaScriptCore/llint/WebAssembly.asm

    r251886 r252231  
    605605unprefixedWasmOp(wasm_ret, WasmRet, macro(ctx)
    606606    checkSwitchToJITForEpilogue()
    607     wgetu(ctx, m_stackOffset, ws1)
    608     lshifti 3, ws1
    609     negi ws1
    610     sxi2q ws1, ws1
    611     addp cfr, ws1
    612607    forEachArgumentGPR(macro (offset, gpr)
    613         loadq offset[ws1], gpr
     608        loadq -offset - 8 - CalleeSaveSpaceAsVirtualRegisters * 8[cfr], gpr
    614609    end)
    615610    forEachArgumentFPR(macro (offset, fpr)
    616         loadd offset[ws1], fpr
     611        loadd -offset - 8 - CalleeSaveSpaceAsVirtualRegisters * 8[cfr], fpr
    617612    end)
    618613    doReturn()
  • trunk/Source/JavaScriptCore/wasm/WasmLLIntGenerator.cpp

    r251978 r252231  
    353353
    354354
    355     for (uint32_t i = 0; i < gprCount; i++)
    356         registers.append(newTemporary());
    357     for (uint32_t i = 0; i < fprCount; i++)
    358         registers.append(newTemporary());
    359 
    360     if (role == CallRole::Caller) {
     355    if (role == CallRole::Callee) {
     356        // Reuse the slots we allocated to spill the registers in addArguments
     357        for (uint32_t i = gprCount + fprCount; i--;)
     358            registers.append(new RegisterID(::JSC::virtualRegisterForLocal(numberOfLLIntCalleeSaveRegisters + i)));
     359    } else {
     360        for (uint32_t i = 0; i < gprCount; i++)
     361            registers.append(newTemporary());
     362        for (uint32_t i = 0; i < fprCount; i++)
     363            registers.append(newTemporary());
     364
    361365        for (uint32_t i = 0; i < signature.argumentCount(); i++)
    362366            allocateStackRegister(signature.argument(i));
     
    630634    LLIntCallInformation info = callInformationFor(*data.m_signature, CallRole::Callee);
    631635    unifyValuesWithBlock(info.results, returnValues);
    632     WasmRet::emit(this, info.stackOffset);
     636    WasmRet::emit(this);
    633637
    634638    return { };
     
    748752auto LLIntGenerator::addRefIsNull(ExpressionType value, ExpressionType& result) -> PartialResult
    749753{
    750     result = newTemporary();
     754    result = value;
    751755    WasmRefIsNull::emit(this, result, value);
    752756
     
    764768auto LLIntGenerator::addTableGet(unsigned tableIndex, ExpressionType index, ExpressionType& result) -> PartialResult
    765769{
    766     result = newTemporary();
     770    result = index;
    767771    WasmTableGet::emit(this, result, index, tableIndex);
    768772
     
    787791auto LLIntGenerator::addTableGrow(unsigned tableIndex, ExpressionType fill, ExpressionType delta, ExpressionType& result) -> PartialResult
    788792{
    789     result = newTemporary();
     793    result = fill;
    790794    WasmTableGrow::emit(this, result, fill, delta, tableIndex);
    791795
     
    817821auto LLIntGenerator::addGrowMemory(ExpressionType delta, ExpressionType& result) -> PartialResult
    818822{
    819     result = newTemporary();
     823    result = delta;
    820824    WasmGrowMemory::emit(this, result, delta);
    821825
     
    825829auto LLIntGenerator::addSelect(ExpressionType condition, ExpressionType nonZero, ExpressionType zero, ExpressionType& result) -> PartialResult
    826830{
    827     result = newTemporary();
     831    result = condition;
    828832    WasmSelect::emit(this, result, condition, nonZero, zero);
    829833
     
    833837auto LLIntGenerator::load(LoadOpType op, ExpressionType pointer, ExpressionType& result, uint32_t offset) -> PartialResult
    834838{
    835     result = newTemporary();
     839    result = pointer;
    836840    switch (op) {
    837841    case LoadOpType::I32Load8S:
Note: See TracChangeset for help on using the changeset viewer.