Reviewers: Yang,

Description:
Merged r12086, r12478 into 3.8 branch.

Fix transcendental cache on ARM in optimized code.

Fix delta computation in DoDeferredInstanceOfKnownGlobal() for ARM.

BUG=v8:2234,v8:2314

[email protected]


Please review this at https://chromiumcodereview.appspot.com/10937029/

SVN Base: https://v8.googlecode.com/svn/branches/3.8

Affected files:
  M src/arm/code-stubs-arm.cc
  M src/arm/lithium-codegen-arm.cc
  M src/version.cc
  A + test/mjsunit/regress/regress-2234.js


Index: src/arm/code-stubs-arm.cc
diff --git a/src/arm/code-stubs-arm.cc b/src/arm/code-stubs-arm.cc
index c33df5cf770842d05d73095f8ad1c2e7ce67548f..1c49876cd0feeb307afa45f8f3ec6d9deebebd7f 100644
--- a/src/arm/code-stubs-arm.cc
+++ b/src/arm/code-stubs-arm.cc
@@ -3338,23 +3338,23 @@ void TranscendentalCacheStub::Generate(MacroAssembler* masm) {
         ExternalReference(RuntimeFunction(), masm->isolate());
     __ TailCallExternalReference(runtime_function, 1, 1);
   } else {
-    if (!CpuFeatures::IsSupported(VFP3)) UNREACHABLE();
+    ASSERT(CpuFeatures::IsSupported(VFP3));
     CpuFeatures::Scope scope(VFP3);

     Label no_update;
     Label skip_cache;

     // Call C function to calculate the result and update the cache.
-    // Register r0 holds precalculated cache entry address; preserve
-    // it on the stack and pop it into register cache_entry after the
-    // call.
-    __ push(cache_entry);
+    // r0: precalculated cache entry address.
+    // r2 and r3: parts of the double value.
+    // Store r0, r2 and r3 on stack for later before calling C function.
+    __ Push(r3, r2, cache_entry);
     GenerateCallCFunction(masm, scratch0);
     __ GetCFunctionDoubleResult(d2);

     // Try to update the cache. If we cannot allocate a
     // heap number, we return the result without updating.
-    __ pop(cache_entry);
+    __ Pop(r3, r2, cache_entry);
     __ LoadRoot(r5, Heap::kHeapNumberMapRootIndex);
     __ AllocateHeapNumber(r6, scratch0, scratch1, r5, &no_update);
     __ vstr(d2, FieldMemOperand(r6, HeapNumber::kValueOffset));
Index: src/arm/lithium-codegen-arm.cc
diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc
index 76c8443e7c30cc422154eab202c61dba16e5941e..98649b1273f8a55d8dad284bd3e85b5a03ce46c0 100644
--- a/src/arm/lithium-codegen-arm.cc
+++ b/src/arm/lithium-codegen-arm.cc
@@ -2210,12 +2210,18 @@ void LCodeGen::DoDeferredInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr,
   Register temp = ToRegister(instr->TempAt(0));
   ASSERT(temp.is(r4));
   __ LoadHeapObject(InstanceofStub::right(), instr->function());
-  static const int kAdditionalDelta = 4;
+  static const int kAdditionalDelta = 5;
int delta = masm_->InstructionsGeneratedSince(map_check) + kAdditionalDelta;
   Label before_push_delta;
   __ bind(&before_push_delta);
   __ BlockConstPoolFor(kAdditionalDelta);
   __ mov(temp, Operand(delta * kPointerSize));
+ // The mov above can generate one or two instructions. The delta was computed + // for two instructions, so we need to pad here in case of one instruction.
+  if (masm_->InstructionsGeneratedSince(&before_push_delta) != 2) {
+    ASSERT_EQ(1, masm_->InstructionsGeneratedSince(&before_push_delta));
+    __ nop();
+  }
   __ StoreToSafepointRegisterSlot(temp, temp);
   CallCodeGeneric(stub.GetCode(),
                   RelocInfo::CODE_TARGET,
Index: src/version.cc
diff --git a/src/version.cc b/src/version.cc
index 53cb26b1bad0cff1d006b5f7be184ae61111a506..a4ad4f2985ee8286d979f21155da6036f6169449 100644
--- a/src/version.cc
+++ b/src/version.cc
@@ -35,7 +35,7 @@
 #define MAJOR_VERSION     3
 #define MINOR_VERSION     8
 #define BUILD_NUMBER      9
-#define PATCH_LEVEL       28
+#define PATCH_LEVEL       29
 // Use 1 for candidates and 0 otherwise.
 // (Boolean macro values are not supported by all preprocessors.)
 #define IS_CANDIDATE_VERSION 0
Index: test/mjsunit/regress/regress-2234.js
diff --git a/test/mjsunit/regress/regress-110509.js b/test/mjsunit/regress/regress-2234.js
similarity index 83%
copy from test/mjsunit/regress/regress-110509.js
copy to test/mjsunit/regress/regress-2234.js
index 132bd233bee32f6c84061049224ea43901dae06a..8da513e30e45352330354d12ab8bcf6e6cf64c02 100644
--- a/test/mjsunit/regress/regress-110509.js
+++ b/test/mjsunit/regress/regress-2234.js
@@ -27,15 +27,15 @@

 // Flags: --allow-natives-syntax

-// Verify that LRandom preserves rsi correctly.
-
-function foo() {
-  Math.random();
-  new Function("");
+function test(i) {
+  // Overwrite random parts of the transcendental cache.
+  Math.sin(i / 1779 * Math.PI);
+  // Check whether the first cache line has been accidentally overwritten
+  // with incorrect key.
+  assertEquals(0, Math.sin(0));
 }

-foo();
-foo();
-foo();
-%OptimizeFunctionOnNextCall(foo);
-foo();
+for (i = 0; i < 10000; ++i) {
+  test(i);
+  if (i == 0) %OptimizeFunctionOnNextCall(test);
+}


--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to