Bug 1242342: Set return type accordingly to the compilation mode; r=luke

This commit is contained in:
Benjamin Bouvier 2016-02-03 18:43:38 +01:00
parent 62e9a4d06c
commit 15bd606c5a
5 changed files with 28 additions and 15 deletions

View File

@ -724,6 +724,7 @@ typedef Vector<uint32_t, 0, SystemAllocPolicy> Uint32Vector;
class FuncBytecode
{
// Function metadata
ModuleKind kind_;
const DeclaredSig& sig_;
ValTypeVector locals_;
uint32_t lineOrBytecode_;
@ -742,8 +743,10 @@ class FuncBytecode
ValTypeVector&& locals,
uint32_t lineOrBytecode,
Uint32Vector&& callSiteLineNums,
unsigned generateTime)
: sig_(sig),
unsigned generateTime,
ModuleKind kind)
: kind_(kind),
sig_(sig),
locals_(Move(locals)),
lineOrBytecode_(lineOrBytecode),
callSiteLineNums_(Move(callSiteLineNums)),
@ -764,6 +767,7 @@ class FuncBytecode
ValType localType(size_t i) const { return locals_[i]; }
unsigned generateTime() const { return generateTime_; }
bool isAsmJS() const { return kind_ == ModuleKind::AsmJS; }
};
typedef UniquePtr<FuncBytecode> UniqueFuncBytecode;

View File

@ -488,7 +488,8 @@ ModuleGenerator::finishFuncDef(uint32_t funcIndex, unsigned generateTime, Functi
Move(fg->locals_),
fg->lineOrBytecode_,
Move(fg->callSiteLineNums_),
generateTime);
generateTime,
module_->kind);
if (!func)
return false;

View File

@ -2579,7 +2579,7 @@ EmitRet(FunctionCompiler& f)
return true;
}
MDefinition *def = nullptr;
MDefinition* def;
if (!EmitExpr(f, ret, &def))
return false;
f.returnExpr(def);
@ -2992,12 +2992,20 @@ wasm::IonCompileFunction(IonCompileTask* task)
return false;
MDefinition* last = nullptr;
if (func.isAsmJS()) {
while (!f.done()) {
if (!EmitExprStmt(f, &last))
return false;
}
} else {
if (!EmitExpr(f, f.sig().ret(), &last))
return false;
MOZ_ASSERT(f.done());
}
if (IsVoid(f.sig().ret()) || !last)
MOZ_ASSERT(IsVoid(f.sig().ret()) || f.inDeadCode() || last);
if (IsVoid(f.sig().ret()))
f.returnVoid();
else
f.returnExpr(last);

View File

@ -348,14 +348,6 @@ UsesHeap(HeapUsage heapUsage)
return bool(heapUsage);
}
// A Module can either be asm.js or wasm.
enum ModuleKind
{
Wasm,
AsmJS
};
// ModuleCacheablePod holds the trivially-memcpy()able serializable portion of
// ModuleData.

View File

@ -41,6 +41,14 @@ using mozilla::Move;
using mozilla::DebugOnly;
using mozilla::MallocSizeOf;
// A Module can either be asm.js or wasm.
enum ModuleKind
{
Wasm,
AsmJS
};
// The ValType enum represents the WebAssembly "value type", which are used to
// specify the type of locals and parameters.