Reviewers: Jakob,

Message:
PTAL

Description:
Fix index register assignment in LoadFieldByIndex for arm, arm64, and mips.

This instruciton clobber the index register.

BUG=368243
LOG=N
TEST=mjsunit/regress/regress-368243

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

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

Affected files (+19, -14 lines):
  M src/arm/lithium-arm.cc
  M src/arm64/lithium-arm64.cc
  M src/mips/lithium-mips.cc
  A + test/mjsunit/regress/regress-368243.js


Index: src/arm/lithium-arm.cc
diff --git a/src/arm/lithium-arm.cc b/src/arm/lithium-arm.cc
index 0c10a65c217f7841fa70c5ba780ec84bc633a787..c9201a80708139b6b4c2922c0a09945cd9bdcf92 100644
--- a/src/arm/lithium-arm.cc
+++ b/src/arm/lithium-arm.cc
@@ -2556,7 +2556,7 @@ LInstruction* LChunkBuilder::DoCheckMapValue(HCheckMapValue* instr) {

 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) {
   LOperand* object = UseRegister(instr->object());
-  LOperand* index = UseRegister(instr->index());
+  LOperand* index = UseTempRegister(instr->index());
   LLoadFieldByIndex* load = new(zone()) LLoadFieldByIndex(object, index);
   LInstruction* result = DefineSameAsFirst(load);
   return AssignPointerMap(result);
Index: src/arm64/lithium-arm64.cc
diff --git a/src/arm64/lithium-arm64.cc b/src/arm64/lithium-arm64.cc
index 2411b7074d15f2ca22dfd3956e393d9fd74d0f23..f5f6b8e2cd08acea33a316981547afa2e60ce9fe 100644
--- a/src/arm64/lithium-arm64.cc
+++ b/src/arm64/lithium-arm64.cc
@@ -2686,7 +2686,7 @@ LInstruction* LChunkBuilder::DoCheckMapValue(HCheckMapValue* instr) {

 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) {
   LOperand* object = UseRegisterAtStart(instr->object());
-  LOperand* index = UseRegister(instr->index());
+  LOperand* index = UseRegisterAndClobber(instr->index());
   LLoadFieldByIndex* load = new(zone()) LLoadFieldByIndex(object, index);
   LInstruction* result = DefineSameAsFirst(load);
   return AssignPointerMap(result);
Index: src/mips/lithium-mips.cc
diff --git a/src/mips/lithium-mips.cc b/src/mips/lithium-mips.cc
index eb960a4bb2c06629272c6e81c19ae1a1adb69c37..e882655d21501d6cf94718cdff670f5a457ed6b2 100644
--- a/src/mips/lithium-mips.cc
+++ b/src/mips/lithium-mips.cc
@@ -2507,7 +2507,7 @@ LInstruction* LChunkBuilder::DoCheckMapValue(HCheckMapValue* instr) {

 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) {
   LOperand* object = UseRegister(instr->object());
-  LOperand* index = UseRegister(instr->index());
+  LOperand* index = UseTempRegister(instr->index());
   LLoadFieldByIndex* load = new(zone()) LLoadFieldByIndex(object, index);
   LInstruction* result = DefineSameAsFirst(load);
   return AssignPointerMap(result);
Index: test/mjsunit/regress/regress-368243.js
diff --git a/test/mjsunit/regress/regress-361608.js b/test/mjsunit/regress/regress-368243.js
similarity index 50%
copy from test/mjsunit/regress/regress-361608.js
copy to test/mjsunit/regress/regress-368243.js
index b3cc90cfd4b06afb3c7424758e23f91d685e3aa2..02bcca26119cb4230a11d221a628a5280778edfd 100644
--- a/test/mjsunit/regress/regress-361608.js
+++ b/test/mjsunit/regress/regress-368243.js
@@ -4,17 +4,22 @@

 // Flags: --allow-natives-syntax

-function f() {};
-int_array = [1];
-
-function foo() {
-  var x;
-  for (var i = -1; i < 0; i++) {
-    x = int_array[i + 1];
-    f(function() { x = i; });
+function foo(a, c){
+  for(var f in c) {
+    if ("object" === typeof c[f]) {
+      a[f]=c[f];
+      foo(a[f],c[f]);
+    }
   }
-}
+};
+
+c = {
+  "one" : { x : 1},
+  "two" : { x : 2},
+  "thr" : { x : 3, z : 4},
+};

-foo();
+foo({}, c);
+foo({}, c);
 %OptimizeFunctionOnNextCall(foo);
-foo();
+foo({}, c);


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