Reviewers: danno, Vyacheslav Egorov, kisg, Paul Lind,

Description:
MIPS: Avoid embedding new space objects into code objects in the lithium gap
resolver.

Port r10301 (c91aeb4c).

BUG=
TEST=


Please review this at http://codereview.chromium.org/9032005/

Affected files:
  M src/mips/lithium-codegen-mips.h
  M src/mips/lithium-codegen-mips.cc
  M src/mips/lithium-gap-resolver-mips.cc
  M src/mips/macro-assembler-mips.h


Index: src/mips/lithium-codegen-mips.cc
diff --git a/src/mips/lithium-codegen-mips.cc b/src/mips/lithium-codegen-mips.cc index 53be7d1e17ad7756ccf3cfa55fb95a039ee48049..06e886c6bb1c9db5aca15deb9a53d43daee24941 100644
--- a/src/mips/lithium-codegen-mips.cc
+++ b/src/mips/lithium-codegen-mips.cc
@@ -353,6 +353,18 @@ DoubleRegister LCodeGen::EmitLoadDoubleRegister(LOperand* op,
 }


+Handle<Object> LCodeGen::ToHandle(LConstantOperand* op) const {
+  Handle<Object> literal = chunk_->LookupLiteral(op);
+  ASSERT(chunk_->LookupLiteralRepresentation(op).IsTagged());
+  return literal;
+}
+
+
+bool LCodeGen::IsInteger32(LConstantOperand* op) const {
+  return chunk_->LookupLiteralRepresentation(op).IsInteger32();
+}
+
+
 int LCodeGen::ToInteger32(LConstantOperand* op) const {
   Handle<Object> value = chunk_->LookupLiteral(op);
   ASSERT(chunk_->LookupLiteralRepresentation(op).IsInteger32());
Index: src/mips/lithium-codegen-mips.h
diff --git a/src/mips/lithium-codegen-mips.h b/src/mips/lithium-codegen-mips.h index 32d4fb3f4dd1fe5b3570ba7f7baf1018f072861d..68a7c5b1aa8db3f22eaba508f5afddd58850a5c9 100644
--- a/src/mips/lithium-codegen-mips.h
+++ b/src/mips/lithium-codegen-mips.h
@@ -93,6 +93,9 @@ class LCodeGen BASE_EMBEDDED {
   // Returns a MemOperand pointing to the high word of a DoubleStackSlot.
   MemOperand ToHighMemOperand(LOperand* op) const;

+  bool IsInteger32(LConstantOperand* op) const;
+  Handle<Object> ToHandle(LConstantOperand* op) const;
+
   // Try to generate code for the entire chunk, but it may fail if the
   // chunk contains constructs we cannot handle. Returns true if the
   // code generation attempt succeeded.
Index: src/mips/lithium-gap-resolver-mips.cc
diff --git a/src/mips/lithium-gap-resolver-mips.cc b/src/mips/lithium-gap-resolver-mips.cc index 8f7f89cf5d145af8b65b89ca2edfab650e0a4c7d..2e5c64e7a2ec366447ea5d1cf0eeb4b588ffc242 100644
--- a/src/mips/lithium-gap-resolver-mips.cc
+++ b/src/mips/lithium-gap-resolver-mips.cc
@@ -252,14 +252,24 @@ void LGapResolver::EmitMove(int index) {
     }

   } else if (source->IsConstantOperand()) {
-    Operand source_operand = cgen_->ToOperand(source);
+    LConstantOperand* constant_source = LConstantOperand::cast(source);
     if (destination->IsRegister()) {
-      __ li(cgen_->ToRegister(destination), source_operand);
+      Register dst = cgen_->ToRegister(destination);
+      if (cgen_->IsInteger32(constant_source)) {
+        __ li(dst, Operand(cgen_->ToInteger32(constant_source)));
+      } else {
+        __ LoadObject(dst, cgen_->ToHandle(constant_source));
+      }
     } else {
       ASSERT(destination->IsStackSlot());
ASSERT(!in_cycle_); // Constant moves happen after all cycles are gone.
-      MemOperand destination_operand = cgen_->ToMemOperand(destination);
-      __ li(kSavedValueRegister, source_operand);
+      if (cgen_->IsInteger32(constant_source)) {
+        __ li(kSavedValueRegister,
+              Operand(cgen_->ToInteger32(constant_source)));
+      } else {
+        __ LoadObject(kSavedValueRegister,
+                      cgen_->ToHandle(constant_source));
+      }
       __ sw(kSavedValueRegister, cgen_->ToMemOperand(destination));
     }

Index: src/mips/macro-assembler-mips.h
diff --git a/src/mips/macro-assembler-mips.h b/src/mips/macro-assembler-mips.h index 4e14fbf97702fb8cf914fd2cb07f4d6e54adf1b8..bd5b94f57c60744cf15eed31abd572f021b5c62e 100644
--- a/src/mips/macro-assembler-mips.h
+++ b/src/mips/macro-assembler-mips.h
@@ -264,6 +264,14 @@ class MacroAssembler: public Assembler {

   void LoadHeapObject(Register dst, Handle<HeapObject> object);

+  void LoadObject(Register result, Handle<Object> object) {
+    if (object->IsHeapObject()) {
+      LoadHeapObject(result, Handle<HeapObject>::cast(object));
+    } else {
+      li(result, object);
+    }
+  }
+
// ---------------------------------------------------------------------------
   // GC Support



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

Reply via email to