Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (271499 => 271500)
--- trunk/Source/_javascript_Core/ChangeLog 2021-01-14 22:37:48 UTC (rev 271499)
+++ trunk/Source/_javascript_Core/ChangeLog 2021-01-14 22:48:43 UTC (rev 271500)
@@ -1,3 +1,55 @@
+2021-01-14 Xan Lopez <[email protected]>
+
+ [JSC] Implement a B3::ValueRep replacement for wasm-llint
+ https://bugs.webkit.org/show_bug.cgi?id=220412
+
+ Reviewed by Yusuke Suzuki.
+
+ The LLInt code in WebAssembly uses B3::ValueRep to store
+ information about the calling convention for functions. We will
+ use instead a new class with just enough functionality for those
+ needs (basically, whether a value in a function call will be in a
+ register or the stack) and convert to B3::ValueRep when
+ transitioning into B3/Air. This is part of the work needed to
+ allow WebAssembly to work without B3, and eventually in
+ interpreted mode only.
+
+ * Sources.txt: add new sources.
+ * b3/B3ValueRep.h:
+ (JSC::B3::ValueRep::ValueRep): include WasmValueLocation.h and add
+ a method to convert B3::ValueRep to Wasm::ValueLocation.
+ * _javascript_Core.xcodeproj/project.pbxproj: add new sources.
+ * wasm/WasmAirIRGenerator.cpp:
+ (JSC::Wasm::AirIRGenerator::emitCallPatchpoint): covert existing Wasm::ValueLocation into B3::ValueRep.
+ * wasm/WasmB3IRGenerator.cpp:
+ (JSC::Wasm::B3IRGenerator::createCallPatchpoint): ditto.
+ * wasm/WasmCallingConvention.h:
+ (JSC::Wasm::CallInformation::computeResultsOffsetList): use Wasm::ValueLocation.
+ * wasm/WasmOperations.cpp:
+ (JSC::Wasm::JSC_DEFINE_JIT_OPERATION): ditto.
+ * wasm/WasmValueLocation.cpp: new class, basically B3::ValueRep
+ without all the stuff we don't need in WasmLLInt.
+ (JSC::Wasm::ValueLocation::dump const):
+ (WTF::printInternal):
+ * wasm/WasmValueLocation.h: ditto.
+ (JSC::Wasm::ValueLocation::ValueLocation):
+ (JSC::Wasm::ValueLocation::reg):
+ (JSC::Wasm::ValueLocation::stack):
+ (JSC::Wasm::ValueLocation::stackArgument):
+ (JSC::Wasm::ValueLocation::kind const):
+ (JSC::Wasm::ValueLocation::isReg const):
+ (JSC::Wasm::ValueLocation::reg const):
+ (JSC::Wasm::ValueLocation::isGPR const):
+ (JSC::Wasm::ValueLocation::isFPR const):
+ (JSC::Wasm::ValueLocation::gpr const):
+ (JSC::Wasm::ValueLocation::fpr const):
+ (JSC::Wasm::ValueLocation::isStack const):
+ (JSC::Wasm::ValueLocation::offsetFromFP const):
+ (JSC::Wasm::ValueLocation::isStackArgument const):
+ (JSC::Wasm::ValueLocation::offsetFromSP const):
+ * wasm/js/JSToWasm.cpp:
+ (JSC::Wasm::marshallJSResult): use Wasm::ValueLocation.
+
2021-01-14 Saam Barati <[email protected]>
SpeculativeJIT::compileGetEnumerableLength should not use GPRFlushedCallResult
Modified: trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj (271499 => 271500)
--- trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj 2021-01-14 22:37:48 UTC (rev 271499)
+++ trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj 2021-01-14 22:48:43 UTC (rev 271500)
@@ -1247,6 +1247,7 @@
861816771FB7924200ECC4EC /* BigIntObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 861816761FB7922F00ECC4EC /* BigIntObject.h */; settings = {ATTRIBUTES = (Private, ); }; };
862553D216136E1A009F17D0 /* JSProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 862553CF16136AA5009F17D0 /* JSProxy.h */; settings = {ATTRIBUTES = (Private, ); }; };
863B23E00FC6118900703AA4 /* MacroAssemblerCodeRef.h in Headers */ = {isa = PBXBuildFile; fileRef = 863B23DF0FC60E6200703AA4 /* MacroAssemblerCodeRef.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 863FBC5A25B093B900F6C930 /* WasmValueLocation.h in Headers */ = {isa = PBXBuildFile; fileRef = 863FBC5825B093B900F6C930 /* WasmValueLocation.h */; };
865A30F1135007E100CDB49E /* JSCJSValueInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = 865A30F0135007E100CDB49E /* JSCJSValueInlines.h */; settings = {ATTRIBUTES = (Private, ); }; };
866739D213BFDE710023D87C /* BigInteger.h in Headers */ = {isa = PBXBuildFile; fileRef = 866739D013BFDE710023D87C /* BigInteger.h */; };
866739D313BFDE710023D87C /* Uint16WithFraction.h in Headers */ = {isa = PBXBuildFile; fileRef = 866739D113BFDE710023D87C /* Uint16WithFraction.h */; };
@@ -4148,6 +4149,8 @@
863C6D981521111200585E4E /* YarrCanonicalizeUCS2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = YarrCanonicalizeUCS2.cpp; path = yarr/YarrCanonicalizeUCS2.cpp; sourceTree = "<group>"; };
863C6D991521111200585E4E /* YarrCanonicalize.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = YarrCanonicalize.h; path = yarr/YarrCanonicalize.h; sourceTree = "<group>"; };
863C6D9A1521111200585E4E /* YarrCanonicalizeUCS2.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode._javascript_; name = YarrCanonicalizeUCS2.js; path = yarr/YarrCanonicalizeUCS2.js; sourceTree = "<group>"; };
+ 863FBC5725B093B800F6C930 /* WasmValueLocation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WasmValueLocation.cpp; sourceTree = "<group>"; };
+ 863FBC5825B093B900F6C930 /* WasmValueLocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WasmValueLocation.h; sourceTree = "<group>"; };
8640923B156EED3B00566CB2 /* ARM64Assembler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ARM64Assembler.h; sourceTree = "<group>"; };
8640923B156EED3B00566CC2 /* ARM64Registers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ARM64Registers.h; sourceTree = "<group>"; };
8640923C156EED3B00566CB2 /* MacroAssemblerARM64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MacroAssemblerARM64.h; sourceTree = "<group>"; };
@@ -6917,6 +6920,8 @@
7B98D1331B60CD1E0023B1A4 /* wasm */ = {
isa = PBXGroup;
children = (
+ 863FBC5725B093B800F6C930 /* WasmValueLocation.cpp */,
+ 863FBC5825B093B900F6C930 /* WasmValueLocation.h */,
AD2FCB8A1DB5840000B3E736 /* js */,
52847AD921FFB8630061A9DB /* WasmAirIRGenerator.cpp */,
52847ADA21FFB8630061A9DB /* WasmAirIRGenerator.h */,
@@ -9677,6 +9682,7 @@
0FCEFAE0180738C000472CE4 /* FTLLocation.h in Headers */,
0FEA0A10170513DB00BB722C /* FTLLowerDFGToB3.h in Headers */,
A7D89D0217A0B90400773AD8 /* FTLLoweredNodeValue.h in Headers */,
+ 863FBC5A25B093B900F6C930 /* WasmValueLocation.h in Headers */,
0F2B9CF919D0BAC100B1D1B5 /* FTLOperations.h in Headers */,
0FD8A31C17D51F2200CA2C40 /* FTLOSREntry.h in Headers */,
0F235BDD17178E1C00690C7F /* FTLOSRExit.h in Headers */,
Modified: trunk/Source/_javascript_Core/Sources.txt (271499 => 271500)
--- trunk/Source/_javascript_Core/Sources.txt 2021-01-14 22:37:48 UTC (rev 271499)
+++ trunk/Source/_javascript_Core/Sources.txt 2021-01-14 22:48:43 UTC (rev 271500)
@@ -1077,6 +1077,7 @@
wasm/WasmTable.cpp
wasm/WasmThunks.cpp
wasm/WasmTierUpCount.cpp
+wasm/WasmValueLocation.cpp
wasm/WasmWorklist.cpp
wasm/js/JSToWasm.cpp
Modified: trunk/Source/_javascript_Core/b3/B3ValueRep.h (271499 => 271500)
--- trunk/Source/_javascript_Core/b3/B3ValueRep.h 2021-01-14 22:37:48 UTC (rev 271499)
+++ trunk/Source/_javascript_Core/b3/B3ValueRep.h 2021-01-14 22:48:43 UTC (rev 271500)
@@ -34,6 +34,9 @@
#include "RegisterSet.h"
#include "ValueRecovery.h"
#include <wtf/PrintStream.h>
+#if ENABLE(WEBASSEMBLY)
+#include "WasmValueLocation.h"
+#endif
namespace JSC {
@@ -121,6 +124,28 @@
ASSERT(kind == WarmAny || kind == ColdAny || kind == LateColdAny || kind == SomeRegister || kind == SomeRegisterWithClobber || kind == SomeEarlyRegister || kind == SomeLateRegister);
}
+#if ENABLE(WEBASSEMBLY)
+ ValueRep(Wasm::ValueLocation location)
+ {
+ switch (location.kind()) {
+ case Wasm::ValueLocation::Kind::Register:
+ m_kind = Register;
+ u.reg = location.reg();
+ break;
+ case Wasm::ValueLocation::Kind::Stack:
+ m_kind = Stack;
+ u.offsetFromFP = location.offsetFromFP();
+ break;
+ case Wasm::ValueLocation::Kind::StackArgument:
+ m_kind = StackArgument;
+ u.offsetFromSP = location.offsetFromSP();
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+ }
+#endif
+
static ValueRep reg(Reg reg)
{
return ValueRep(reg);
Modified: trunk/Source/_javascript_Core/wasm/WasmAirIRGenerator.cpp (271499 => 271500)
--- trunk/Source/_javascript_Core/wasm/WasmAirIRGenerator.cpp 2021-01-14 22:37:48 UTC (rev 271499)
+++ trunk/Source/_javascript_Core/wasm/WasmAirIRGenerator.cpp 2021-01-14 22:48:43 UTC (rev 271500)
@@ -39,6 +39,7 @@
#include "B3PatchpointSpecial.h"
#include "B3Procedure.h"
#include "B3ProcedureInlines.h"
+#include "B3StackmapGenerationParams.h"
#include "BinarySwitch.h"
#include "JSCJSValueInlines.h"
#include "JSWebAssemblyInstance.h"
@@ -2964,8 +2965,12 @@
for (unsigned i = 0; i < args.size(); ++i)
patchArgs[i + offset] = ConstrainedTmp(args[i], locations.params[i]);
- if (patchpoint->type() != B3::Void)
- patchpoint->resultConstraints = WTFMove(locations.results);
+ if (patchpoint->type() != B3::Void) {
+ Vector<B3::ValueRep, 1> resultConstraints;
+ for (auto valueLocation : locations.results)
+ resultConstraints.append(B3::ValueRep(valueLocation));
+ patchpoint->resultConstraints = WTFMove(resultConstraints);
+ }
emitPatchpoint(block, patchpoint, results, WTFMove(patchArgs));
return patchpoint;
}
Modified: trunk/Source/_javascript_Core/wasm/WasmB3IRGenerator.cpp (271499 => 271500)
--- trunk/Source/_javascript_Core/wasm/WasmB3IRGenerator.cpp 2021-01-14 22:37:48 UTC (rev 271499)
+++ trunk/Source/_javascript_Core/wasm/WasmB3IRGenerator.cpp 2021-01-14 22:48:43 UTC (rev 271500)
@@ -28,6 +28,7 @@
#if ENABLE(WEBASSEMBLY)
+#include "AirCode.h"
#include "AllowMacroScratchRegisterUsageIf.h"
#include "B3BasicBlockInlines.h"
#include "B3CCallValue.h"
@@ -2151,8 +2152,12 @@
patchpointFunctor(patchpoint);
patchpoint->appendVector(constrainedArguments);
- if (returnType != B3::Void)
- patchpoint->resultConstraints = WTFMove(wasmCallInfo.results);
+ if (returnType != B3::Void) {
+ Vector<B3::ValueRep, 1> resultConstraints;
+ for (auto valueLocation : wasmCallInfo.results)
+ resultConstraints.append(B3::ValueRep(valueLocation));
+ patchpoint->resultConstraints = WTFMove(resultConstraints);
+ }
return patchpoint;
}
Modified: trunk/Source/_javascript_Core/wasm/WasmCallingConvention.h (271499 => 271500)
--- trunk/Source/_javascript_Core/wasm/WasmCallingConvention.h 2021-01-14 22:37:48 UTC (rev 271499)
+++ trunk/Source/_javascript_Core/wasm/WasmCallingConvention.h 2021-01-14 22:48:43 UTC (rev 271500)
@@ -27,16 +27,7 @@
#if ENABLE(WEBASSEMBLY)
-#include "AirCode.h"
#include "AllowMacroScratchRegisterUsage.h"
-#include "B3ArgumentRegValue.h"
-#include "B3BasicBlock.h"
-#include "B3Const64Value.h"
-#include "B3ConstrainedValue.h"
-#include "B3MemoryValue.h"
-#include "B3PatchpointValue.h"
-#include "B3Procedure.h"
-#include "B3StackmapGenerationParams.h"
#include "CallFrame.h"
#include "LinkBuffer.h"
#include "RegisterAtOffsetList.h"
@@ -43,12 +34,13 @@
#include "RegisterSet.h"
#include "WasmFormat.h"
#include "WasmSignature.h"
+#include "WasmValueLocation.h"
namespace JSC { namespace Wasm {
constexpr unsigned numberOfLLIntCalleeSaveRegisters = 2;
-using ArgumentLocation = B3::ValueRep;
+using ArgumentLocation = ValueLocation;
enum class CallRole : uint8_t {
Caller,
Callee,
@@ -64,9 +56,9 @@
RegisterAtOffsetList computeResultsOffsetList()
{
RegisterSet usedResultRegisters;
- for (B3::ValueRep rep : results) {
- if (rep.isReg())
- usedResultRegisters.set(rep.reg());
+ for (ValueLocation loc : results) {
+ if (loc.isReg())
+ usedResultRegisters.set(loc.reg());
}
RegisterAtOffsetList savedRegs(usedResultRegisters, RegisterAtOffsetList::ZeroBased);
Modified: trunk/Source/_javascript_Core/wasm/WasmOperations.cpp (271499 => 271500)
--- trunk/Source/_javascript_Core/wasm/WasmOperations.cpp 2021-01-14 22:37:48 UTC (rev 271499)
+++ trunk/Source/_javascript_Core/wasm/WasmOperations.cpp 2021-01-14 22:48:43 UTC (rev 271500)
@@ -603,12 +603,12 @@
static_assert(sizeof(JSValue) == sizeof(CPURegister), "The code below relies on this.");
for (unsigned i = 0; i < signature->returnCount(); ++i) {
- B3::ValueRep rep = wasmCallInfo.results[i];
+ ValueLocation loc = wasmCallInfo.results[i];
JSValue value;
- if (rep.isReg())
- value = stackPointerFromCallee[(registerResults.find(rep.reg())->offset() + wasmCallInfo.headerAndArgumentStackSizeInBytes) / sizeof(JSValue)];
+ if (loc.isReg())
+ value = stackPointerFromCallee[(registerResults.find(loc.reg())->offset() + wasmCallInfo.headerAndArgumentStackSizeInBytes) / sizeof(JSValue)];
else
- value = stackPointerFromCallee[rep.offsetFromSP() / sizeof(JSValue)];
+ value = stackPointerFromCallee[loc.offsetFromSP() / sizeof(JSValue)];
result->initializeIndex(initializationScope, i, value);
}
Added: trunk/Source/_javascript_Core/wasm/WasmValueLocation.cpp (0 => 271500)
--- trunk/Source/_javascript_Core/wasm/WasmValueLocation.cpp (rev 0)
+++ trunk/Source/_javascript_Core/wasm/WasmValueLocation.cpp 2021-01-14 22:48:43 UTC (rev 271500)
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2015-2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2021 Igalia S.L. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WasmValueLocation.h"
+
+#if ENABLE(WEBASSEMBLY)
+
+namespace JSC { namespace Wasm {
+
+void ValueLocation::dump(PrintStream& out) const
+{
+ out.print(m_kind);
+ switch (m_kind) {
+ case Register:
+ out.print("(", reg(), ")");
+ return;
+ case Stack:
+ out.print("(", offsetFromFP(), ")");
+ return;
+ case StackArgument:
+ out.print("(", offsetFromSP(), ")");
+ return;
+ }
+ RELEASE_ASSERT_NOT_REACHED();
+}
+
+} } // namespace JSC::Wasm
+
+namespace WTF {
+
+using namespace JSC::Wasm;
+
+void printInternal(PrintStream& out, ValueLocation::Kind kind)
+{
+ switch (kind) {
+ case ValueLocation::Register:
+ out.print("Register");
+ return;
+ case ValueLocation::Stack:
+ out.print("Stack");
+ return;
+ case ValueLocation::StackArgument:
+ out.print("StackArgument");
+ return;
+ }
+ RELEASE_ASSERT_NOT_REACHED();
+}
+
+} // namespace WTF
+
+#endif // ENABLE(WEBASSEMBLY)
Added: trunk/Source/_javascript_Core/wasm/WasmValueLocation.h (0 => 271500)
--- trunk/Source/_javascript_Core/wasm/WasmValueLocation.h (rev 0)
+++ trunk/Source/_javascript_Core/wasm/WasmValueLocation.h 2021-01-14 22:48:43 UTC (rev 271500)
@@ -0,0 +1,139 @@
+/*
+ * Copyright (C) 2015-2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2021 Igalia S.L. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(WEBASSEMBLY)
+
+#include "FPRInfo.h"
+#include "GPRInfo.h"
+#include "Reg.h"
+#include <wtf/PrintStream.h>
+
+namespace JSC {
+
+namespace Wasm {
+
+class ValueLocation {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ enum Kind : uint8_t {
+ Register,
+ Stack,
+ StackArgument,
+ };
+
+ ValueLocation()
+ : m_kind(Register)
+ {
+ }
+
+ explicit ValueLocation(Reg reg)
+ : m_kind(Register)
+ {
+ u.reg = reg;
+ }
+
+ ValueLocation(const ValueLocation&) = default;
+
+ static ValueLocation reg(Reg reg)
+ {
+ return ValueLocation(reg);
+ }
+
+ static ValueLocation stack(intptr_t offsetFromFP)
+ {
+ ValueLocation result;
+ result.m_kind = Stack;
+ result.u.offsetFromFP = offsetFromFP;
+ return result;
+ }
+
+ static ValueLocation stackArgument(intptr_t offsetFromSP)
+ {
+ ValueLocation result;
+ result.m_kind = StackArgument;
+ result.u.offsetFromSP = offsetFromSP;
+ return result;
+ }
+
+ Kind kind() const { return m_kind; }
+
+ bool isReg() const { return kind() == Register; }
+
+ Reg reg() const
+ {
+ ASSERT(isReg());
+ return u.reg;
+ }
+
+ bool isGPR() const { return isReg() && reg().isGPR(); }
+ bool isFPR() const { return isReg() && reg().isFPR(); }
+
+ GPRReg gpr() const { return reg().gpr(); }
+ FPRReg fpr() const { return reg().fpr(); }
+
+ bool isStack() const { return kind() == Stack; }
+
+ intptr_t offsetFromFP() const
+ {
+ ASSERT(isStack());
+ return u.offsetFromFP;
+ }
+
+ bool isStackArgument() const { return kind() == StackArgument; }
+
+ intptr_t offsetFromSP() const
+ {
+ ASSERT(isStackArgument());
+ return u.offsetFromSP;
+ }
+
+ JS_EXPORT_PRIVATE void dump(PrintStream&) const;
+
+private:
+ union U {
+ Reg reg;
+ intptr_t offsetFromFP;
+ intptr_t offsetFromSP;
+
+ U()
+ {
+ memset(static_cast<void*>(this), 0, sizeof(*this));
+ }
+ } u;
+ Kind m_kind;
+};
+
+} } // namespace JSC::Wasm
+
+namespace WTF {
+
+void printInternal(PrintStream&, JSC::Wasm::ValueLocation::Kind);
+
+} // namespace WTF
+
+#endif // ENABLE(WEBASSEMBLY)
Modified: trunk/Source/_javascript_Core/wasm/js/JSToWasm.cpp (271499 => 271500)
--- trunk/Source/_javascript_Core/wasm/js/JSToWasm.cpp 2021-01-14 22:37:48 UTC (rev 271499)
+++ trunk/Source/_javascript_Core/wasm/js/JSToWasm.cpp 2021-01-14 22:48:43 UTC (rev 271500)
@@ -91,19 +91,19 @@
FPRReg fprScratch = wasmCallingConvention().fprArgs[0].fpr();
bool hasI64 = false;
for (unsigned i = 0; i < signature.returnCount(); ++i) {
- B3::ValueRep rep = wasmFrameConvention.results[i];
+ ValueLocation loc = wasmFrameConvention.results[i];
Type type = signature.returnType(i);
hasI64 |= type == Wasm::I64;
- if (rep.isReg()) {
+ if (loc.isReg()) {
if (type != Wasm::I64) {
- boxWasmResult(jit, signature.returnType(i), rep.reg(), scratch);
- jit.storeValue(scratch, CCallHelpers::Address(CCallHelpers::stackPointerRegister, savedResultRegisters.find(rep.reg())->offset() + wasmFrameConvention.headerAndArgumentStackSizeInBytes));
+ boxWasmResult(jit, signature.returnType(i), loc.reg(), scratch);
+ jit.storeValue(scratch, CCallHelpers::Address(CCallHelpers::stackPointerRegister, savedResultRegisters.find(loc.reg())->offset() + wasmFrameConvention.headerAndArgumentStackSizeInBytes));
} else
- jit.storeValue(JSValueRegs { rep.reg().gpr() }, CCallHelpers::Address(CCallHelpers::stackPointerRegister, savedResultRegisters.find(rep.reg())->offset() + wasmFrameConvention.headerAndArgumentStackSizeInBytes));
+ jit.storeValue(JSValueRegs { loc.reg().gpr() }, CCallHelpers::Address(CCallHelpers::stackPointerRegister, savedResultRegisters.find(loc.reg())->offset() + wasmFrameConvention.headerAndArgumentStackSizeInBytes));
} else {
if (type != Wasm::I64) {
- auto location = CCallHelpers::Address(CCallHelpers::stackPointerRegister, rep.offsetFromSP());
+ auto location = CCallHelpers::Address(CCallHelpers::stackPointerRegister, loc.offsetFromSP());
Reg tmp = type == F32 || type == F64 ? Reg(fprScratch) : Reg(scratch.gpr());
jit.load64ToReg(location, tmp);
boxWasmResult(jit, signature.returnType(i), tmp, scratch);
@@ -129,7 +129,7 @@
// This is required to convert values to BigInt.
if (hasI64) {
for (unsigned i = 0; i < signature.returnCount(); ++i) {
- B3::ValueRep rep = wasmFrameConvention.results[i];
+ ValueLocation loc = wasmFrameConvention.results[i];
Type type = signature.returnType(i);
if (type != Wasm::I64)
continue;
@@ -141,18 +141,18 @@
jit.loadWasmContextInstance(wasmContextInstanceGPR);
}
- if (rep.isReg())
- jit.load64(CCallHelpers::Address(CCallHelpers::stackPointerRegister, savedResultRegisters.find(rep.reg())->offset() + wasmFrameConvention.headerAndArgumentStackSizeInBytes), GPRInfo::argumentGPR0);
+ if (loc.isReg())
+ jit.load64(CCallHelpers::Address(CCallHelpers::stackPointerRegister, savedResultRegisters.find(loc.reg())->offset() + wasmFrameConvention.headerAndArgumentStackSizeInBytes), GPRInfo::argumentGPR0);
else {
- auto location = CCallHelpers::Address(CCallHelpers::stackPointerRegister, rep.offsetFromSP());
+ auto location = CCallHelpers::Address(CCallHelpers::stackPointerRegister, loc.offsetFromSP());
jit.load64ToReg(location, GPRInfo::argumentGPR0);
}
jit.setupArguments<decltype(operationConvertToBigInt)>(wasmContextInstanceGPR, GPRInfo::argumentGPR0);
jit.callOperation(FunctionPtr<OperationPtrTag>(operationConvertToBigInt));
- if (rep.isReg())
- jit.storeValue(JSValueRegs { GPRInfo::returnValueGPR }, CCallHelpers::Address(CCallHelpers::stackPointerRegister, savedResultRegisters.find(rep.reg())->offset() + wasmFrameConvention.headerAndArgumentStackSizeInBytes));
+ if (loc.isReg())
+ jit.storeValue(JSValueRegs { GPRInfo::returnValueGPR }, CCallHelpers::Address(CCallHelpers::stackPointerRegister, savedResultRegisters.find(loc.reg())->offset() + wasmFrameConvention.headerAndArgumentStackSizeInBytes));
else {
- auto location = CCallHelpers::Address(CCallHelpers::stackPointerRegister, rep.offsetFromSP());
+ auto location = CCallHelpers::Address(CCallHelpers::stackPointerRegister, loc.offsetFromSP());
jit.storeValue(JSValueRegs { GPRInfo::returnValueGPR }, location);
}
}