Revision: 6298
Author: [email protected]
Date: Thu Jan 13 04:21:47 2011
Log: Landing for Rodolph Perfetta.
Implementing Math.floor and Math.sqrt for crankshaft.
BUG=none
TEST=none
Code review URL: http://codereview.chromium.org/6250002/
http://code.google.com/p/v8/source/detail?r=6298
Modified:
/branches/bleeding_edge/src/arm/assembler-arm.h
/branches/bleeding_edge/src/arm/lithium-arm.cc
/branches/bleeding_edge/src/arm/lithium-arm.h
/branches/bleeding_edge/src/arm/lithium-codegen-arm.cc
/branches/bleeding_edge/src/arm/lithium-codegen-arm.h
=======================================
--- /branches/bleeding_edge/src/arm/assembler-arm.h Tue Jan 11 23:47:13 2011
+++ /branches/bleeding_edge/src/arm/assembler-arm.h Thu Jan 13 04:21:47 2011
@@ -167,8 +167,11 @@
struct DwVfpRegister {
// d0 has been excluded from allocation. This is following ia32
// where xmm0 is excluded. This should be revisited.
+ // Currently d0 is used as a scratch register.
+ // d1 has also been excluded from allocation to be used as a scratch
+ // register as well.
static const int kNumRegisters = 16;
- static const int kNumAllocatableRegisters = 15;
+ static const int kNumAllocatableRegisters = 14;
static int ToAllocationIndex(DwVfpRegister reg) {
ASSERT(reg.code() != 0);
@@ -177,13 +180,12 @@
static DwVfpRegister FromAllocationIndex(int index) {
ASSERT(index >= 0 && index < kNumAllocatableRegisters);
- return from_code(index + 1);
+ return from_code(index + 2);
}
static const char* AllocationIndexToString(int index) {
ASSERT(index >= 0 && index < kNumAllocatableRegisters);
const char* const names[] = {
- "d1",
"d2",
"d3",
"d4",
=======================================
--- /branches/bleeding_edge/src/arm/lithium-arm.cc Wed Jan 12 07:46:39 2011
+++ /branches/bleeding_edge/src/arm/lithium-arm.cc Thu Jan 13 04:21:47 2011
@@ -1120,7 +1120,8 @@
LInstruction* LChunkBuilder::DoUnaryMathOperation(HUnaryMathOperation*
instr) {
BuiltinFunctionId op = instr->op();
LOperand* input = UseRegisterAtStart(instr->value());
- LInstruction* result = new LUnaryMathOperation(input);
+ LOperand* temp = (op == kMathFloor) ? TempRegister() : NULL;
+ LInstruction* result = new LUnaryMathOperation(input, temp);
switch (op) {
case kMathAbs:
return
AssignEnvironment(AssignPointerMap(DefineSameAsFirst(result)));
=======================================
--- /branches/bleeding_edge/src/arm/lithium-arm.h Wed Jan 12 16:34:08 2011
+++ /branches/bleeding_edge/src/arm/lithium-arm.h Thu Jan 13 04:21:47 2011
@@ -621,14 +621,18 @@
class LUnaryMathOperation: public LUnaryOperation {
public:
- explicit LUnaryMathOperation(LOperand* value)
- : LUnaryOperation(value) { }
+ explicit LUnaryMathOperation(LOperand* value, LOperand* temp)
+ : LUnaryOperation(value), temp_(temp) { }
DECLARE_CONCRETE_INSTRUCTION(UnaryMathOperation, "unary-math-operation")
DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
virtual void PrintDataTo(StringStream* stream) const;
BuiltinFunctionId op() const { return hydrogen()->op(); }
+ LOperand* temp() const { return temp_; }
+
+ private:
+ LOperand* temp_;
};
=======================================
--- /branches/bleeding_edge/src/arm/lithium-codegen-arm.cc Wed Jan 12
16:34:08 2011
+++ /branches/bleeding_edge/src/arm/lithium-codegen-arm.cc Thu Jan 13
04:21:47 2011
@@ -1980,12 +1980,44 @@
void LCodeGen::DoMathFloor(LUnaryMathOperation* instr) {
- Abort("DoMathFloor unimplemented.");
+ DoubleRegister input = ToDoubleRegister(instr->input());
+ Register result = ToRegister(instr->result());
+ Register prev_fpscr = ToRegister(instr->temp());
+ SwVfpRegister single_scratch = single_scratch0();
+ Register scratch = scratch0();
+
+ // Set custom FPCSR:
+ // - Set rounding mode to "Round towards Minus Infinity".
+ // - Clear vfp cumulative exception flags.
+ // - Make sure Flush-to-zero mode control bit is unset.
+ __ vmrs(prev_fpscr);
+ __ bic(scratch, prev_fpscr,
+ Operand(kVFPExceptionMask | kVFPRoundingModeMask |
kVFPFlushToZeroMask));
+ __ orr(scratch, scratch, Operand(kVFPRoundToMinusInfinityBits));
+ __ vmsr(scratch);
+
+ // Convert the argument to an integer.
+ __ vcvt_s32_f64(single_scratch,
+ input,
+ Assembler::FPSCRRounding,
+ al);
+
+ // Retrieve FPSCR and check for vfp exceptions.
+ __ vmrs(scratch);
+ // Restore FPSCR
+ __ vmsr(prev_fpscr);
+ __ tst(scratch, Operand(kVFPExceptionMask));
+ DeoptimizeIf(ne, instr->environment());
+
+ // Move the result back to general purpose register r0.
+ __ vmov(result, single_scratch);
}
void LCodeGen::DoMathSqrt(LUnaryMathOperation* instr) {
- Abort("DoMathSqrt unimplemented.");
+ DoubleRegister input = ToDoubleRegister(instr->input());
+ ASSERT(ToDoubleRegister(instr->result()).is(input));
+ __ vsqrt(input, input);
}
=======================================
--- /branches/bleeding_edge/src/arm/lithium-codegen-arm.h Tue Jan 11
07:51:08 2011
+++ /branches/bleeding_edge/src/arm/lithium-codegen-arm.h Thu Jan 13
04:21:47 2011
@@ -107,6 +107,9 @@
MacroAssembler* masm() const { return masm_; }
Register scratch0() { return r9; }
+ SwVfpRegister single_scratch0() { return s0; }
+ SwVfpRegister single_scratch1() { return s1; }
+ DwVfpRegister double_scratch0() { return d1; }
int GetNextEmittedBlock(int block);
LInstruction* GetNextInstruction();
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev