Bug 1383303 - Support void returns from VM functions. r=jandem
MozReview-Commit-ID: JBPQ9aTqHAH
--- a/js/src/jit/VMFunctions.h
+++ b/js/src/jit/VMFunctions.h
@@ -257,28 +257,32 @@ struct VMFunction
outParam(o.outParam),
returnType(o.returnType),
argumentRootTypes(o.argumentRootTypes),
outParamRootType(o.outParamRootType),
extraValuesToPop(o.extraValuesToPop),
expectTailCall(o.expectTailCall)
{
// Check for valid failure/return type.
- MOZ_ASSERT_IF(outParam != Type_Void, returnType == Type_Bool);
- MOZ_ASSERT(returnType == Type_Bool ||
+ MOZ_ASSERT_IF(outParam != Type_Void,
+ returnType == Type_Void ||
+ returnType == Type_Bool);
+ MOZ_ASSERT(returnType == Type_Void ||
+ returnType == Type_Bool ||
returnType == Type_Object);
addToFunctions();
}
private:
// Add this to the global list of VMFunctions.
void addToFunctions();
};
template <class> struct TypeToDataType { /* Unexpected return type for a VMFunction. */ };
+template <> struct TypeToDataType<void> { static const DataType result = Type_Void; };
template <> struct TypeToDataType<bool> { static const DataType result = Type_Bool; };
template <> struct TypeToDataType<JSObject*> { static const DataType result = Type_Object; };
template <> struct TypeToDataType<JSFunction*> { static const DataType result = Type_Object; };
template <> struct TypeToDataType<NativeObject*> { static const DataType result = Type_Object; };
template <> struct TypeToDataType<PlainObject*> { static const DataType result = Type_Object; };
template <> struct TypeToDataType<InlineTypedObject*> { static const DataType result = Type_Object; };
template <> struct TypeToDataType<NamedLambdaObject*> { static const DataType result = Type_Object; };
template <> struct TypeToDataType<LexicalEnvironmentObject*> { static const DataType result = Type_Object; };
--- a/js/src/jit/arm/Trampoline-arm.cpp
+++ b/js/src/jit/arm/Trampoline-arm.cpp
@@ -890,16 +890,18 @@ JitRuntime::generateVMWrapper(JSContext*
// Test for failure.
switch (f.failType()) {
case Type_Object:
masm.branchTestPtr(Assembler::Zero, r0, r0, masm.failureLabel());
break;
case Type_Bool:
masm.branchIfFalseBool(r0, masm.failureLabel());
break;
+ case Type_Void:
+ break;
default:
MOZ_CRASH("unknown failure kind");
}
// Load the outparam and free any allocated stack.
switch (f.outParam) {
case Type_Handle:
masm.popRooted(f.outParamRootType, ReturnReg, JSReturnOperand);
--- a/js/src/jit/arm64/Trampoline-arm64.cpp
+++ b/js/src/jit/arm64/Trampoline-arm64.cpp
@@ -689,16 +689,18 @@ JitRuntime::generateVMWrapper(JSContext*
// Test for failure.
switch (f.failType()) {
case Type_Object:
masm.branchTestPtr(Assembler::Zero, r0, r0, masm.failureLabel());
break;
case Type_Bool:
masm.branchIfFalseBool(r0, masm.failureLabel());
break;
+ case Type_Void:
+ break;
default:
MOZ_CRASH("unknown failure kind");
}
// Load the outparam and free any allocated stack.
switch (f.outParam) {
case Type_Value:
masm.Ldr(ARMRegister(JSReturnReg, 64), MemOperand(masm.GetStackPointer64()));
--- a/js/src/jit/mips32/Trampoline-mips32.cpp
+++ b/js/src/jit/mips32/Trampoline-mips32.cpp
@@ -856,16 +856,18 @@ JitRuntime::generateVMWrapper(JSContext*
switch (f.failType()) {
case Type_Object:
masm.branchTestPtr(Assembler::Zero, v0, v0, masm.failureLabel());
break;
case Type_Bool:
// Called functions return bools, which are 0/false and non-zero/true
masm.branchIfFalseBool(v0, masm.failureLabel());
break;
+ case Type_Void:
+ break;
default:
MOZ_CRASH("unknown failure kind");
}
masm.freeStack(outParamOffset);
// Load the outparam and free any allocated stack.
switch (f.outParam) {
--- a/js/src/jit/mips64/Trampoline-mips64.cpp
+++ b/js/src/jit/mips64/Trampoline-mips64.cpp
@@ -802,16 +802,18 @@ JitRuntime::generateVMWrapper(JSContext*
switch (f.failType()) {
case Type_Object:
masm.branchTestPtr(Assembler::Zero, v0, v0, masm.failureLabel());
break;
case Type_Bool:
// Called functions return bools, which are 0/false and non-zero/true
masm.branchIfFalseBool(v0, masm.failureLabel());
break;
+ case Type_Void:
+ break;
default:
MOZ_CRASH("unknown failure kind");
}
// Load the outparam and free any allocated stack.
switch (f.outParam) {
case Type_Handle:
masm.popRooted(f.outParamRootType, ReturnReg, JSReturnOperand);
--- a/js/src/jit/x64/Trampoline-x64.cpp
+++ b/js/src/jit/x64/Trampoline-x64.cpp
@@ -774,16 +774,18 @@ JitRuntime::generateVMWrapper(JSContext*
switch (f.failType()) {
case Type_Object:
masm.branchTestPtr(Assembler::Zero, rax, rax, masm.failureLabel());
break;
case Type_Bool:
masm.testb(rax, rax);
masm.j(Assembler::Zero, masm.failureLabel());
break;
+ case Type_Void:
+ break;
default:
MOZ_CRASH("unknown failure kind");
}
// Load the outparam and free any allocated stack.
switch (f.outParam) {
case Type_Handle:
masm.popRooted(f.outParamRootType, ReturnReg, JSReturnOperand);
--- a/js/src/jit/x86/Trampoline-x86.cpp
+++ b/js/src/jit/x86/Trampoline-x86.cpp
@@ -804,16 +804,18 @@ JitRuntime::generateVMWrapper(JSContext*
switch (f.failType()) {
case Type_Object:
masm.branchTestPtr(Assembler::Zero, eax, eax, masm.failureLabel());
break;
case Type_Bool:
masm.testb(eax, eax);
masm.j(Assembler::Zero, masm.failureLabel());
break;
+ case Type_Void:
+ break;
default:
MOZ_CRASH("unknown failure kind");
}
// Load the outparam and free any allocated stack.
switch (f.outParam) {
case Type_Handle:
masm.popRooted(f.outParamRootType, ReturnReg, JSReturnOperand);