Bug 996561 - IonMonkey MIPS: MIPS Simulator integration part 1. r=jandem

This commit is contained in:
Svetozar Janjic 2014-04-16 15:54:29 +02:00
parent 7cbab1e33d
commit c341f95e4c
4 changed files with 96 additions and 5 deletions

View File

@ -6,8 +6,6 @@
#include "jit/mips/Architecture-mips.h"
#include <elf.h>
#include <fcntl.h>
#include <unistd.h>
@ -23,6 +21,12 @@ uint32_t GetMIPSFlags()
static uint32_t flags = 0;
if (isSet)
return flags;
#ifdef JS_MIPS_SIMULATOR
isSet = true;
flags |= HWCAP_FPU;
return flags;
#else
#if WTF_OS_LINUX
FILE *fp = fopen("/proc/cpuinfo", "r");
if (!fp)
@ -40,6 +44,7 @@ uint32_t GetMIPSFlags()
#endif
return false;
#endif // JS_MIPS_SIMULATOR
}
bool hasFPU()

View File

@ -179,6 +179,20 @@ static const uint32_t Imm26Bits = 26;
static const uint32_t Imm28Shift = 0;
static const uint32_t Imm28Bits = 28;
static const uint32_t ImmFieldShift = 2;
static const uint32_t FRBits = 5;
static const uint32_t FRShift = 21;
static const uint32_t FSShift = 11;
static const uint32_t FSBits = 5;
static const uint32_t FTShift = 16;
static const uint32_t FTBits = 5;
static const uint32_t FDShift = 6;
static const uint32_t FDBits = 5;
static const uint32_t FCccShift = 8;
static const uint32_t FCccBits = 3;
static const uint32_t FBccShift = 18;
static const uint32_t FBccBits = 3;
static const uint32_t FBtrueShift = 16;
static const uint32_t FBtrueBits = 1;
static const uint32_t FccMask = 0x7;
static const uint32_t FccShift = 2;
@ -285,6 +299,7 @@ enum RSField {
rs_s = 16 << RSShift,
rs_d = 17 << RSShift,
rs_w = 20 << RSShift,
rs_l = 21 << RSShift,
rs_ps = 22 << RSShift
};
@ -333,6 +348,13 @@ enum FunctionField {
ff_slt = 42,
ff_sltu = 43,
ff_tge = 48,
ff_tgeu = 49,
ff_tlt = 50,
ff_tltu = 51,
ff_teq = 52,
ff_tne = 54,
// special2 encoding of function field.
ff_mul = 2,
ff_clz = 32,
@ -352,6 +374,11 @@ enum FunctionField {
ff_mov_fmt = 6,
ff_neg_fmt = 7,
ff_round_l_fmt = 8,
ff_trunc_l_fmt = 9,
ff_ceil_l_fmt = 10,
ff_floor_l_fmt = 11,
ff_round_w_fmt = 12,
ff_trunc_w_fmt = 13,
ff_ceil_w_fmt = 14,
@ -360,6 +387,8 @@ enum FunctionField {
ff_cvt_s_fmt = 32,
ff_cvt_d_fmt = 33,
ff_cvt_w_fmt = 36,
ff_cvt_l_fmt = 37,
ff_cvt_ps_s = 38,
ff_c_f_fmt = 48,
ff_c_un_fmt = 49,
@ -369,6 +398,11 @@ enum FunctionField {
ff_c_ult_fmt = 53,
ff_c_ole_fmt = 54,
ff_c_ule_fmt = 55,
ff_madd_s = 32,
ff_madd_d = 33,
ff_null = 0
};
class MacroAssemblerMIPS;
@ -1002,14 +1036,14 @@ class Assembler : public AssemblerShared
}
}; // Assembler
// sll zero, zero, 0
const uint32_t NopInst = 0x00000000;
// An Instruction is a structure for both encoding and decoding any and all
// MIPS instructions.
class Instruction
{
protected:
// sll zero, zero, 0
static const uint32_t NopInst = 0x00000000;
uint32_t data;
// Standard constructor

View File

@ -13,6 +13,7 @@
#include "jit/BaselineFrame.h"
#include "jit/BaselineRegisters.h"
#include "jit/IonFrames.h"
#include "jit/mips/Simulator-mips.h"
#include "jit/MoveEmitter.h"
using namespace js;
@ -2986,6 +2987,7 @@ MacroAssemblerMIPSCompat::setupABICall(uint32_t args)
inCall_ = true;
args_ = args;
passedArgs_ = 0;
passedArgTypes_ = 0;
usedArgSlots_ = 0;
firstArgType = MoveOp::GENERAL;
@ -3043,6 +3045,7 @@ MacroAssemblerMIPSCompat::passABIArg(const MoveOperand &from, MoveOp::Type type)
}
}
usedArgSlots_++;
passedArgTypes_ = (passedArgTypes_ << ArgType_Shift) | ArgType_Float32;
break;
case MoveOp::DOUBLE:
if (!usedArgSlots_) {
@ -3070,6 +3073,7 @@ MacroAssemblerMIPSCompat::passABIArg(const MoveOperand &from, MoveOp::Type type)
enoughMemory_ = moveResolver_.addMove(from, MoveOperand(sp, disp), type);
usedArgSlots_ += 2;
}
passedArgTypes_ = (passedArgTypes_ << ArgType_Shift) | ArgType_Double;
break;
case MoveOp::GENERAL:
Register destReg;
@ -3084,6 +3088,7 @@ MacroAssemblerMIPSCompat::passABIArg(const MoveOperand &from, MoveOp::Type type)
enoughMemory_ = moveResolver_.addMove(from, MoveOperand(sp, disp), type);
}
usedArgSlots_++;
passedArgTypes_ = (passedArgTypes_ << ArgType_Shift) | ArgType_General;
break;
default:
MOZ_ASSUME_UNREACHABLE("Unexpected argument type");
@ -3180,9 +3185,55 @@ MacroAssemblerMIPSCompat::callWithABIPost(uint32_t stackAdjust, MoveOp::Type res
inCall_ = false;
}
#if defined(DEBUG) && defined(JS_MIPS_SIMULATOR)
static void
AssertValidABIFunctionType(uint32_t passedArgTypes)
{
switch (passedArgTypes) {
case Args_General0:
case Args_General1:
case Args_General2:
case Args_General3:
case Args_General4:
case Args_General5:
case Args_General6:
case Args_General7:
case Args_General8:
case Args_Double_None:
case Args_Int_Double:
case Args_Float32_Float32:
case Args_Double_Double:
case Args_Double_Int:
case Args_Double_DoubleInt:
case Args_Double_DoubleDouble:
case Args_Double_IntDouble:
case Args_Int_IntDouble:
break;
default:
MOZ_ASSUME_UNREACHABLE("Unexpected type");
}
}
#endif
void
MacroAssemblerMIPSCompat::callWithABI(void *fun, MoveOp::Type result)
{
#ifdef JS_MIPS_SIMULATOR
MOZ_ASSERT(passedArgs_ <= 15);
passedArgTypes_ <<= ArgType_Shift;
switch (result) {
case MoveOp::GENERAL: passedArgTypes_ |= ArgType_General; break;
case MoveOp::DOUBLE: passedArgTypes_ |= ArgType_Double; break;
case MoveOp::FLOAT32: passedArgTypes_ |= ArgType_Float32; break;
default: MOZ_ASSUME_UNREACHABLE("Invalid return type");
}
#ifdef DEBUG
AssertValidABIFunctionType(passedArgTypes_);
#endif
ABIFunctionType type = ABIFunctionType(passedArgTypes_);
fun = Simulator::RedirectNativeFunction(fun, type);
#endif
uint32_t stackAdjust;
callWithABIPre(&stackAdjust);
ma_call(ImmPtr(fun));

View File

@ -330,6 +330,7 @@ class MacroAssemblerMIPSCompat : public MacroAssemblerMIPS
// The actual number of arguments that were passed, used to assert that
// the initial number of arguments declared was correct.
uint32_t passedArgs_;
uint32_t passedArgTypes_;
uint32_t usedArgSlots_;
MoveOp::Type firstArgType;