Title: [252231] trunk/Source/_javascript_Core
Revision
252231
Author
tzaga...@apple.com
Date
2019-11-07 19:55:47 -0800 (Thu, 07 Nov 2019)

Log 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):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (252230 => 252231)


--- trunk/Source/_javascript_Core/ChangeLog	2019-11-08 02:52:40 UTC (rev 252230)
+++ trunk/Source/_javascript_Core/ChangeLog	2019-11-08 03:55:47 UTC (rev 252231)
@@ -1,3 +1,27 @@
+2019-11-07  Tadeu Zagallo  <tzaga...@apple.com>
+
+        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):
+
 2019-11-07  Robin Morisset  <rmoris...@apple.com>
 
         Split ArithProfile into a Unary and a Binary version

Modified: trunk/Source/_javascript_Core/bytecode/BytecodeList.rb (252230 => 252231)


--- trunk/Source/_javascript_Core/bytecode/BytecodeList.rb	2019-11-08 02:52:40 UTC (rev 252230)
+++ trunk/Source/_javascript_Core/bytecode/BytecodeList.rb	2019-11-08 03:55:47 UTC (rev 252231)
@@ -1287,10 +1287,7 @@
         targetLabel: WasmBoundLabel,
     }
 
-op :ret,
-    args: {
-        stackOffset: unsigned,
-    }
+op :ret
 
 op :switch,
     args: {

Modified: trunk/Source/_javascript_Core/generator/Wasm.rb (252230 => 252231)


--- trunk/Source/_javascript_Core/generator/Wasm.rb	2019-11-08 02:52:40 UTC (rev 252230)
+++ trunk/Source/_javascript_Core/generator/Wasm.rb	2019-11-08 03:55:47 UTC (rev 252231)
@@ -58,7 +58,7 @@
 template<>
 auto LLIntGenerator::addOp<#{op_type(op)}>(ExpressionType lhs, ExpressionType rhs, ExpressionType& result) -> PartialResult
 {
-    result = newTemporary();
+    result = lhs;
     #{op.capitalized_name}::emit(this, result, lhs, rhs);
     return { };
 }
@@ -70,7 +70,7 @@
 template<>
 auto LLIntGenerator::addOp<#{op_type(op)}>(ExpressionType operand, ExpressionType& result) -> PartialResult
 {
-    result = newTemporary();
+    result = operand;
     #{op.capitalized_name}::emit(this, result, operand);
     return { };
 }

Modified: trunk/Source/_javascript_Core/llint/WebAssembly.asm (252230 => 252231)


--- trunk/Source/_javascript_Core/llint/WebAssembly.asm	2019-11-08 02:52:40 UTC (rev 252230)
+++ trunk/Source/_javascript_Core/llint/WebAssembly.asm	2019-11-08 03:55:47 UTC (rev 252231)
@@ -604,16 +604,11 @@
 
 unprefixedWasmOp(wasm_ret, WasmRet, macro(ctx)
     checkSwitchToJITForEpilogue()
-    wgetu(ctx, m_stackOffset, ws1)
-    lshifti 3, ws1
-    negi ws1
-    sxi2q ws1, ws1
-    addp cfr, ws1
     forEachArgumentGPR(macro (offset, gpr)
-        loadq offset[ws1], gpr
+        loadq -offset - 8 - CalleeSaveSpaceAsVirtualRegisters * 8[cfr], gpr
     end)
     forEachArgumentFPR(macro (offset, fpr)
-        loadd offset[ws1], fpr
+        loadd -offset - 8 - CalleeSaveSpaceAsVirtualRegisters * 8[cfr], fpr
     end)
     doReturn()
 end)

Modified: trunk/Source/_javascript_Core/wasm/WasmLLIntGenerator.cpp (252230 => 252231)


--- trunk/Source/_javascript_Core/wasm/WasmLLIntGenerator.cpp	2019-11-08 02:52:40 UTC (rev 252230)
+++ trunk/Source/_javascript_Core/wasm/WasmLLIntGenerator.cpp	2019-11-08 03:55:47 UTC (rev 252231)
@@ -352,12 +352,16 @@
     };
 
 
-    for (uint32_t i = 0; i < gprCount; i++)
-        registers.append(newTemporary());
-    for (uint32_t i = 0; i < fprCount; i++)
-        registers.append(newTemporary());
+    if (role == CallRole::Callee) {
+        // Reuse the slots we allocated to spill the registers in addArguments
+        for (uint32_t i = gprCount + fprCount; i--;)
+            registers.append(new RegisterID(::JSC::virtualRegisterForLocal(numberOfLLIntCalleeSaveRegisters + i)));
+    } else {
+        for (uint32_t i = 0; i < gprCount; i++)
+            registers.append(newTemporary());
+        for (uint32_t i = 0; i < fprCount; i++)
+            registers.append(newTemporary());
 
-    if (role == CallRole::Caller) {
         for (uint32_t i = 0; i < signature.argumentCount(); i++)
             allocateStackRegister(signature.argument(i));
         gprIndex = 0;
@@ -629,7 +633,7 @@
 
     LLIntCallInformation info = callInformationFor(*data.m_signature, CallRole::Callee);
     unifyValuesWithBlock(info.results, returnValues);
-    WasmRet::emit(this, info.stackOffset);
+    WasmRet::emit(this);
 
     return { };
 }
@@ -747,7 +751,7 @@
 
 auto LLIntGenerator::addRefIsNull(ExpressionType value, ExpressionType& result) -> PartialResult
 {
-    result = newTemporary();
+    result = value;
     WasmRefIsNull::emit(this, result, value);
 
     return { };
@@ -763,7 +767,7 @@
 
 auto LLIntGenerator::addTableGet(unsigned tableIndex, ExpressionType index, ExpressionType& result) -> PartialResult
 {
-    result = newTemporary();
+    result = index;
     WasmTableGet::emit(this, result, index, tableIndex);
 
     return { };
@@ -786,7 +790,7 @@
 
 auto LLIntGenerator::addTableGrow(unsigned tableIndex, ExpressionType fill, ExpressionType delta, ExpressionType& result) -> PartialResult
 {
-    result = newTemporary();
+    result = fill;
     WasmTableGrow::emit(this, result, fill, delta, tableIndex);
 
     return { };
@@ -816,7 +820,7 @@
 
 auto LLIntGenerator::addGrowMemory(ExpressionType delta, ExpressionType& result) -> PartialResult
 {
-    result = newTemporary();
+    result = delta;
     WasmGrowMemory::emit(this, result, delta);
 
     return { };
@@ -824,7 +828,7 @@
 
 auto LLIntGenerator::addSelect(ExpressionType condition, ExpressionType nonZero, ExpressionType zero, ExpressionType& result) -> PartialResult
 {
-    result = newTemporary();
+    result = condition;
     WasmSelect::emit(this, result, condition, nonZero, zero);
 
     return { };
@@ -832,7 +836,7 @@
 
 auto LLIntGenerator::load(LoadOpType op, ExpressionType pointer, ExpressionType& result, uint32_t offset) -> PartialResult
 {
-    result = newTemporary();
+    result = pointer;
     switch (op) {
     case LoadOpType::I32Load8S:
         WasmI32Load8S::emit(this, result, pointer, offset);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to