Reviewers: Weiliang,
Message:
wl.
PTAL.
thanks.
Description:
Set the FPU precision control to double-precision.
The default double precision control of FPU is extended double-precision.
While the number definition for JavaScript is double-precision. We use
the FPU control word to set the doulbe precision and replace the original
solution which store the data to memory and load it again.
This patch also fixes the error that Sunspider 1.0.2 can not run with V8 if
sse2 support is disabled.
BUG=
Please review this at https://codereview.chromium.org/700053003/
Base URL: https://chromium.googlesource.com/external/v8.git@bleeding_edge
Affected files (+11, -6 lines):
M src/x87/lithium-codegen-x87.cc
M src/x87/macro-assembler-x87.h
M src/x87/macro-assembler-x87.cc
Index: src/x87/lithium-codegen-x87.cc
diff --git a/src/x87/lithium-codegen-x87.cc b/src/x87/lithium-codegen-x87.cc
index
2766b658fd1a0c28498173e12b527582092ece76..35d95532c1278b8d11771261b32e11906784efa5
100644
--- a/src/x87/lithium-codegen-x87.cc
+++ b/src/x87/lithium-codegen-x87.cc
@@ -2272,6 +2272,8 @@ void LCodeGen::DoArithmeticD(LArithmeticD* instr) {
if (instr->op() != Token::MOD) {
X87PrepareBinaryOp(left, right, result);
}
+ // Set the precision control to double-precision.
+ __ X87SetFPUCW(0x027F);
switch (instr->op()) {
case Token::ADD:
__ fadd_i(1);
@@ -2306,12 +2308,7 @@ void LCodeGen::DoArithmeticD(LArithmeticD* instr) {
break;
}
- // Only always explicitly storing to memory to force the round-down for
double
- // arithmetic.
- __ lea(esp, Operand(esp, -kDoubleSize));
- __ fstp_d(Operand(esp, 0));
- __ fld_d(Operand(esp, 0));
- __ lea(esp, Operand(esp, kDoubleSize));
+ __ X87SetFPUCW(0x037F);
}
Index: src/x87/macro-assembler-x87.cc
diff --git a/src/x87/macro-assembler-x87.cc b/src/x87/macro-assembler-x87.cc
index
ff5db7bdbd0bfd0c208038a0068acc7019b39012..3f522fcb1a15538281c35c0ea6ec2e41e04de381
100644
--- a/src/x87/macro-assembler-x87.cc
+++ b/src/x87/macro-assembler-x87.cc
@@ -767,6 +767,13 @@ void MacroAssembler::X87SetRC(int rc) {
}
+void MacroAssembler::X87SetFPUCW(int cw) {
+ push(Immediate(cw));
+ fldcw(MemOperand(esp, 0));
+ add(esp, Immediate(kPointerSize));
+}
+
+
void MacroAssembler::AssertNumber(Register object) {
if (emit_debug_code()) {
Label ok;
Index: src/x87/macro-assembler-x87.h
diff --git a/src/x87/macro-assembler-x87.h b/src/x87/macro-assembler-x87.h
index
07964562bb18afafb9b2cfa7110b331c22a737a3..ad308a495829d3537fe8b67aa7d40fdc1a9681c9
100644
--- a/src/x87/macro-assembler-x87.h
+++ b/src/x87/macro-assembler-x87.h
@@ -425,6 +425,7 @@ class MacroAssembler: public Assembler {
void FXamSign();
void X87CheckIA();
void X87SetRC(int rc);
+ void X87SetFPUCW(int cw);
void ClampUint8(Register reg);
void ClampTOSToUint8(Register result_reg);
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.