Reviewers: Jakob,

Description:
Fix transcendental cache on ARM in optimized code.


[email protected]
BUG=v8:2234
TEST=regress-2234.js


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

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

Affected files:
  M src/arm/code-stubs-arm.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 169a032fb030c242448f4d491174348cc892a5ad..d402694e40431dd62eda4c9b3f2650a1841d4f00 100644
--- a/src/arm/code-stubs-arm.cc
+++ b/src/arm/code-stubs-arm.cc
@@ -3410,16 +3410,16 @@ void TranscendentalCacheStub::Generate(MacroAssembler* masm) {
     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.
+    __ stm(db_w, sp, cache_entry.bit() | r2.bit() | r3.bit());
     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);
+    __ ldm(ia_w, sp, cache_entry.bit() | r2.bit() | r3.bit());
     __ LoadRoot(r5, Heap::kHeapNumberMapRootIndex);
     __ AllocateHeapNumber(r6, scratch0, scratch1, r5, &no_update);
     __ vstr(d2, FieldMemOperand(r6, HeapNumber::kValueOffset));
Index: test/mjsunit/regress/regress-2234.js
diff --git a/test/mjsunit/regress/regress-2045.js b/test/mjsunit/regress/regress-2234.js
similarity index 85%
copy from test/mjsunit/regress/regress-2045.js
copy to test/mjsunit/regress/regress-2234.js
index 822ee1fa4641b4a0ba15eee2c2a2e59411db7d4d..3f37e23d40552c3983fd010655deadbb30bf3947 100644
--- a/test/mjsunit/regress/regress-2045.js
+++ b/test/mjsunit/regress/regress-2234.js
@@ -25,25 +25,14 @@
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

-// Flags: --allow-natives-syntax
-
-function foo() {
-  assertEquals(2, arguments.length);
-}
-
-function bar() {
-  G.x;
-  return foo.apply(this, arguments);
+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));
 }

-function baz() {
-  return bar(1, 2);
+for (i = 0; i < 1000; ++i) {
+  test(i);
 }
-
-G = {x: 0};
-baz();
-baz();
-%OptimizeFunctionOnNextCall(baz);
-baz();
-delete G.x;
-baz();


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

Reply via email to