Reviewers: Jakob,

Description:
Version 3.29.88.8 (merged r24189, r24226, r24271)

X87: fixed branch distances.

X87: fix the bug which is introduced by R24169.

X87:  fix the Sqrt issue.

[email protected]
BUG=

Please review this at https://codereview.chromium.org/653893002/

Base URL: https://v8.googlecode.com/svn/branches/3.29

Affected files (+78, -16 lines):
  M src/version.cc
  M src/x87/lithium-codegen-x87.cc
  M src/x87/lithium-x87.h
  M src/x87/lithium-x87.cc


Index: src/version.cc
diff --git a/src/version.cc b/src/version.cc
index 2da13bec663fec3adb5668f4c48ec277a2951044..18f3345bd7d85922ae844801b760fc2b84ead4ac 100644
--- a/src/version.cc
+++ b/src/version.cc
@@ -35,7 +35,7 @@
 #define MAJOR_VERSION     3
 #define MINOR_VERSION     29
 #define BUILD_NUMBER      88
-#define PATCH_LEVEL       7
+#define PATCH_LEVEL       8
 // Use 1 for candidates and 0 otherwise.
 // (Boolean macro values are not supported by all preprocessors.)
 #define IS_CANDIDATE_VERSION 0
Index: src/x87/lithium-codegen-x87.cc
diff --git a/src/x87/lithium-codegen-x87.cc b/src/x87/lithium-codegen-x87.cc
index 4f79f84cbbac8e778dd764fa5c61c11f65f425cb..00bbe5e72bab8245367fd7619bdd6c09b94b1414 100644
--- a/src/x87/lithium-codegen-x87.cc
+++ b/src/x87/lithium-codegen-x87.cc
@@ -4021,12 +4021,65 @@ void LCodeGen::DoMathFround(LMathFround* instr) {


 void LCodeGen::DoMathSqrt(LMathSqrt* instr) {
-  X87Register input_reg = ToX87Register(instr->value());
-  X87Register output_reg = ToX87Register(instr->result());
-  DCHECK(output_reg.is(input_reg));
-  USE(output_reg);
-  X87Fxch(input_reg);
-  __ fsqrt();
+  X87Register input = ToX87Register(instr->value());
+  X87Register result_reg = ToX87Register(instr->result());
+  Register temp_result = ToRegister(instr->temp1());
+  Register temp = ToRegister(instr->temp2());
+  Label slow, done, smi, finish;
+  DCHECK(result_reg.is(input));
+
+  // Store input into Heap number and call runtime function kMathExpRT.
+  if (FLAG_inline_new) {
+    __ AllocateHeapNumber(temp_result, temp, no_reg, &slow);
+    __ jmp(&done, Label::kNear);
+  }
+
+  // Slow case: Call the runtime system to do the number allocation.
+  __ bind(&slow);
+  {
+    // TODO(3095996): Put a valid pointer value in the stack slot where the
+ // result register is stored, as this register is in the pointer map, but
+    // contains an integer value.
+    __ Move(temp_result, Immediate(0));
+
+    // Preserve the value of all registers.
+    PushSafepointRegistersScope scope(this);
+
+    __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
+    __ CallRuntimeSaveDoubles(Runtime::kAllocateHeapNumber);
+    RecordSafepointWithRegisters(
+       instr->pointer_map(), 0, Safepoint::kNoLazyDeopt);
+    __ StoreToSafepointRegisterSlot(temp_result, eax);
+  }
+  __ bind(&done);
+  X87LoadForUsage(input);
+  __ fstp_d(FieldOperand(temp_result, HeapNumber::kValueOffset));
+
+  {
+    // Preserve the value of all registers.
+    PushSafepointRegistersScope scope(this);
+
+    __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
+    __ push(temp_result);
+    __ CallRuntimeSaveDoubles(Runtime::kMathSqrtRT);
+    RecordSafepointWithRegisters(
+        instr->pointer_map(), 0, Safepoint::kNoLazyDeopt);
+    __ StoreToSafepointRegisterSlot(temp_result, eax);
+  }
+  X87PrepareToWrite(result_reg);
+  // return value of MathExpRT is Smi or Heap Number.
+  __ JumpIfSmi(temp_result, &smi);
+  // Heap number(double)
+  __ fld_d(FieldOperand(temp_result, HeapNumber::kValueOffset));
+  __ jmp(&finish);
+  // SMI
+  __ bind(&smi);
+  __ SmiUntag(temp_result);
+  __ push(temp_result);
+  __ fild_s(MemOperand(esp, 0));
+  __ pop(temp_result);
+  __ bind(&finish);
+  X87CommitWrite(result_reg);
 }


@@ -5302,9 +5355,10 @@ void LCodeGen::DoDoubleToI(LDoubleToI* instr) {
     Label lost_precision, is_nan, minus_zero, done;
     X87Register input_reg = ToX87Register(input);
     X87Fxch(input_reg);
+    Label::Distance dist = DeoptEveryNTimes() ? Label::kFar : Label::kNear;
     __ X87TOSToI(result_reg, instr->hydrogen()->GetMinusZeroMode(),
-                 &lost_precision, &is_nan, &minus_zero, Label::kNear);
-    __ jmp(&done, Label::kNear);
+                 &lost_precision, &is_nan, &minus_zero, dist);
+    __ jmp(&done);
     __ bind(&lost_precision);
     DeoptimizeIf(no_condition, instr, "lost precision");
     __ bind(&is_nan);
@@ -5326,10 +5380,10 @@ void LCodeGen::DoDoubleToSmi(LDoubleToSmi* instr) {
   Label lost_precision, is_nan, minus_zero, done;
   X87Register input_reg = ToX87Register(input);
   X87Fxch(input_reg);
+  Label::Distance dist = DeoptEveryNTimes() ? Label::kFar : Label::kNear;
   __ X87TOSToI(result_reg, instr->hydrogen()->GetMinusZeroMode(),
-               &lost_precision, &is_nan, &minus_zero,
-               DeoptEveryNTimes() ? Label::kFar : Label::kNear);
-  __ jmp(&done, Label::kNear);
+               &lost_precision, &is_nan, &minus_zero, dist);
+  __ jmp(&done);
   __ bind(&lost_precision);
   DeoptimizeIf(no_condition, instr, "lost precision");
   __ bind(&is_nan);
Index: src/x87/lithium-x87.cc
diff --git a/src/x87/lithium-x87.cc b/src/x87/lithium-x87.cc
index f46aef9294ebf0fe1ab5db946ebf8cf8b114560d..9304b8975cff8b21ad02bb4efd439ef910539c83 100644
--- a/src/x87/lithium-x87.cc
+++ b/src/x87/lithium-x87.cc
@@ -1252,8 +1252,10 @@ LInstruction* LChunkBuilder::DoMathExp(HUnaryMathOperation* instr) {

 LInstruction* LChunkBuilder::DoMathSqrt(HUnaryMathOperation* instr) {
   LOperand* input = UseRegisterAtStart(instr->value());
-  LMathSqrt* result = new(zone()) LMathSqrt(input);
-  return DefineSameAsFirst(result);
+  LOperand* temp1 = FixedTemp(ecx);
+  LOperand* temp2 = FixedTemp(edx);
+  LMathSqrt* result = new(zone()) LMathSqrt(input, temp1, temp2);
+  return MarkAsCall(DefineSameAsFirst(result), instr);
 }


Index: src/x87/lithium-x87.h
diff --git a/src/x87/lithium-x87.h b/src/x87/lithium-x87.h
index cf0e7b2d92c0ef9f3886e08754ea3274bfb4a4ca..dbb18ecabb78e9c1c6550cdeca3b40c1bf167444 100644
--- a/src/x87/lithium-x87.h
+++ b/src/x87/lithium-x87.h
@@ -973,13 +973,19 @@ class LMathExp FINAL : public LTemplateInstruction<1, 1, 2> {
 };


-class LMathSqrt FINAL : public LTemplateInstruction<1, 1, 0> {
+class LMathSqrt FINAL : public LTemplateInstruction<1, 1, 2> {
  public:
-  explicit LMathSqrt(LOperand* value) {
+  explicit LMathSqrt(LOperand* value,
+                     LOperand* temp1,
+                     LOperand* temp2) {
     inputs_[0] = value;
+    temps_[0] = temp1;
+    temps_[1] = temp2;
   }

   LOperand* value() { return inputs_[0]; }
+  LOperand* temp1() { return temps_[0]; }
+  LOperand* temp2() { return temps_[1]; }

   DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
 };


--
--
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.

Reply via email to