Revision: 17463
Author:   [email protected]
Date:     Tue Nov  5 01:31:22 2013 UTC
Log: MIPS: Handle constants in new space by making macro-assembler smarter.

Port r17376 (9af4f51)

BUG=
[email protected]

Review URL: https://codereview.chromium.org/57873004

Patch from Balazs Kilvady <[email protected]>.
http://code.google.com/p/v8/source/detail?r=17463

Modified:
 /branches/bleeding_edge/src/mips/full-codegen-mips.cc
 /branches/bleeding_edge/src/mips/lithium-codegen-mips.cc
 /branches/bleeding_edge/src/mips/lithium-codegen-mips.h
 /branches/bleeding_edge/src/mips/lithium-gap-resolver-mips.cc
 /branches/bleeding_edge/src/mips/macro-assembler-mips.cc
 /branches/bleeding_edge/src/mips/macro-assembler-mips.h
 /branches/bleeding_edge/src/mips/stub-cache-mips.cc

=======================================
--- /branches/bleeding_edge/src/mips/full-codegen-mips.cc Wed Oct 23 13:48:04 2013 UTC +++ /branches/bleeding_edge/src/mips/full-codegen-mips.cc Tue Nov 5 01:31:22 2013 UTC
@@ -1162,7 +1162,7 @@
       Handle<Object>(Smi::FromInt(TypeFeedbackCells::kForInFastCaseMarker),
                      isolate()));
   RecordTypeFeedbackCell(stmt->ForInFeedbackId(), cell);
-  __ LoadHeapObject(a1, cell);
+  __ li(a1, cell);
__ li(a2, Operand(Smi::FromInt(TypeFeedbackCells::kForInSlowCaseMarker)));
   __ sw(a2, FieldMemOperand(a1, Cell::kValueOffset));

=======================================
--- /branches/bleeding_edge/src/mips/lithium-codegen-mips.cc Thu Oct 31 14:32:08 2013 UTC +++ /branches/bleeding_edge/src/mips/lithium-codegen-mips.cc Tue Nov 5 01:31:22 2013 UTC
@@ -366,7 +366,7 @@
       Abort(kEmitLoadRegisterUnsupportedDoubleImmediate);
     } else {
       ASSERT(r.IsSmiOrTagged());
-      __ LoadObject(scratch, literal);
+      __ li(scratch, literal);
     }
     return scratch;
   } else if (op->IsStackSlot() || op->IsArgument()) {
@@ -668,7 +668,7 @@
   } else if (context->IsConstantOperand()) {
     HConstant* constant =
         chunk_->LookupConstant(LConstantOperand::cast(context));
-    __ LoadObject(cp, Handle<Object>::cast(constant->handle(isolate())));
+    __ li(cp, Handle<Object>::cast(constant->handle(isolate())));
   } else {
     UNREACHABLE();
   }
@@ -1647,7 +1647,7 @@
 void LCodeGen::DoConstantT(LConstantT* instr) {
   Handle<Object> value = instr->value(isolate());
   AllowDeferredHandleDereference smi_check;
-  __ LoadObject(ToRegister(instr->result()), value);
+  __ li(ToRegister(instr->result()), value);
 }


@@ -2651,7 +2651,7 @@
   // offset to the location of the map check.
   Register temp = ToRegister(instr->temp());
   ASSERT(temp.is(t0));
-  __ LoadHeapObject(InstanceofStub::right(), instr->function());
+  __ li(InstanceofStub::right(), instr->function());
   static const int kAdditionalDelta = 7;
int delta = masm_->InstructionsGeneratedSince(map_check) + kAdditionalDelta;
   Label before_push_delta;
@@ -3403,7 +3403,7 @@

 void LCodeGen::DoDeclareGlobals(LDeclareGlobals* instr) {
   ASSERT(ToRegister(instr->context()).is(cp));
-  __ LoadHeapObject(scratch0(), instr->hydrogen()->pairs());
+  __ li(scratch0(), instr->hydrogen()->pairs());
   __ li(scratch1(), Operand(Smi::FromInt(instr->hydrogen()->flags())));
   // The context is the first argument.
   __ Push(cp, scratch0(), scratch1());
@@ -3440,7 +3440,7 @@

   if (can_invoke_directly) {
     if (a1_state == A1_UNINITIALIZED) {
-      __ LoadHeapObject(a1, function);
+      __ li(a1, function);
     }

     // Change context.
@@ -5374,7 +5374,7 @@
   // a2 and t0-t2 are used as temporaries.
   int literal_offset =
       FixedArray::OffsetOfElementAt(instr->hydrogen()->literal_index());
-  __ LoadHeapObject(t3, instr->hydrogen()->literals());
+  __ li(t3, instr->hydrogen()->literals());
   __ lw(a1, FieldMemOperand(t3, literal_offset));
   __ LoadRoot(at, Heap::kUndefinedValueRootIndex);
   __ Branch(&materialized, ne, a1, Operand(at));
=======================================
--- /branches/bleeding_edge/src/mips/lithium-codegen-mips.h Mon Oct 21 22:20:45 2013 UTC +++ /branches/bleeding_edge/src/mips/lithium-codegen-mips.h Tue Nov 5 01:31:22 2013 UTC
@@ -242,8 +242,6 @@
                          CallKind call_kind,
                          A1State a1_state);

-  void LoadHeapObject(Register result, Handle<HeapObject> object);
-
   void RecordSafepointWithLazyDeopt(LInstruction* instr,
                                     SafepointMode safepoint_mode);

=======================================
--- /branches/bleeding_edge/src/mips/lithium-gap-resolver-mips.cc Tue Aug 6 14:46:50 2013 UTC +++ /branches/bleeding_edge/src/mips/lithium-gap-resolver-mips.cc Tue Nov 5 01:31:22 2013 UTC
@@ -256,7 +256,7 @@
       if (cgen_->IsInteger32(constant_source)) {
         __ li(dst, Operand(cgen_->ToRepresentation(constant_source, r)));
       } else {
-        __ LoadObject(dst, cgen_->ToHandle(constant_source));
+        __ li(dst, cgen_->ToHandle(constant_source));
       }
     } else if (destination->IsDoubleRegister()) {
       DoubleRegister result = cgen_->ToDoubleRegister(destination);
@@ -271,8 +271,7 @@
         __ li(kLithiumScratchReg,
               Operand(cgen_->ToRepresentation(constant_source, r)));
       } else {
-        __ LoadObject(kLithiumScratchReg,
-                      cgen_->ToHandle(constant_source));
+        __ li(kLithiumScratchReg, cgen_->ToHandle(constant_source));
       }
       __ sw(kLithiumScratchReg, cgen_->ToMemOperand(destination));
     }
=======================================
--- /branches/bleeding_edge/src/mips/macro-assembler-mips.cc Thu Oct 31 11:43:23 2013 UTC +++ /branches/bleeding_edge/src/mips/macro-assembler-mips.cc Tue Nov 5 01:31:22 2013 UTC
@@ -81,19 +81,6 @@
   Branch(2, NegateCondition(cond), src1, src2);
   sw(source, MemOperand(s6, index << kPointerSizeLog2));
 }
-
-
-void MacroAssembler::LoadHeapObject(Register result,
-                                    Handle<HeapObject> object) {
-  AllowDeferredHandleDereference using_raw_address;
-  if (isolate()->heap()->InNewSpace(*object)) {
-    Handle<Cell> cell = isolate()->factory()->NewCell(object);
-    li(result, Operand(cell));
-    lw(result, FieldMemOperand(result, Cell::kValueOffset));
-  } else {
-    li(result, Operand(object));
-  }
-}


 // Push and pop all registers that can hold pointers.
@@ -768,6 +755,23 @@

 //------------Pseudo-instructions-------------

+void MacroAssembler::li(Register dst, Handle<Object> value, LiFlags mode) {
+  AllowDeferredHandleDereference smi_check;
+  if (value->IsSmi()) {
+    li(dst, Operand(value), mode);
+  } else {
+    ASSERT(value->IsHeapObject());
+    if (isolate()->heap()->InNewSpace(*value)) {
+      Handle<Cell> cell = isolate()->factory()->NewCell(value);
+      li(dst, Operand(cell));
+      lw(dst, FieldMemOperand(dst, Cell::kValueOffset));
+    } else {
+      li(dst, Operand(value));
+    }
+  }
+}
+
+
 void MacroAssembler::li(Register rd, Operand j, LiFlags mode) {
   ASSERT(!j.is_reg());
   BlockTrampolinePoolScope block_trampoline_pool(this);
@@ -3697,7 +3701,7 @@
   ASSERT(flag == JUMP_FUNCTION || has_frame());

   // Get the function and setup the context.
-  LoadHeapObject(a1, function);
+  li(a1, function);
   lw(cp, FieldMemOperand(a1, JSFunction::kContextOffset));

   // We call indirectly through the code field in the function to
=======================================
--- /branches/bleeding_edge/src/mips/macro-assembler-mips.h Wed Oct 23 13:48:04 2013 UTC +++ /branches/bleeding_edge/src/mips/macro-assembler-mips.h Tue Nov 5 01:31:22 2013 UTC
@@ -292,17 +292,6 @@
   void StoreRoot(Register source,
                  Heap::RootListIndex index,
                  Condition cond, Register src1, const Operand& src2);
-
-  void LoadHeapObject(Register dst, Handle<HeapObject> object);
-
-  void LoadObject(Register result, Handle<Object> object) {
-    AllowDeferredHandleDereference heap_object_check;
-    if (object->IsHeapObject()) {
-      LoadHeapObject(result, Handle<HeapObject>::cast(object));
-    } else {
-      li(result, object);
-    }
-  }

// ---------------------------------------------------------------------------
   // GC Support
@@ -620,10 +609,7 @@
   inline void li(Register rd, int32_t j, LiFlags mode = OPTIMIZE_SIZE) {
     li(rd, Operand(j), mode);
   }
-  inline void li(Register dst, Handle<Object> value,
-                 LiFlags mode = OPTIMIZE_SIZE) {
-    li(dst, Operand(value), mode);
-  }
+ void li(Register dst, Handle<Object> value, LiFlags mode = OPTIMIZE_SIZE);

   // Push multiple registers on the stack.
   // Registers are saved in numerical order, with higher numbered registers
=======================================
--- /branches/bleeding_edge/src/mips/stub-cache-mips.cc Mon Nov 4 14:14:09 2013 UTC +++ /branches/bleeding_edge/src/mips/stub-cache-mips.cc Tue Nov 5 01:31:22 2013 UTC
@@ -461,7 +461,7 @@

   if (details.type() == CONSTANT) {
Handle<Object> constant(descriptors->GetValue(descriptor), masm->isolate());
-    __ LoadObject(scratch1, constant);
+    __ li(scratch1, constant);
     __ Branch(miss_label, ne, value_reg, Operand(scratch1));
   } else if (FLAG_track_fields && representation.IsSmi()) {
     __ JumpIfNotSmi(value_reg, miss_label);
@@ -837,7 +837,7 @@
   __ sw(cp, MemOperand(sp, FCA::kContextSaveIndex * kPointerSize));
   // Get the function and setup the context.
   Handle<JSFunction> function = optimization.constant_function();
-  __ LoadHeapObject(t1, function);
+  __ li(t1, function);
   __ lw(cp, FieldMemOperand(t1, JSFunction::kContextOffset));
   __ sw(t1, MemOperand(sp, FCA::kCalleeIndex * kPointerSize));

@@ -1376,7 +1376,7 @@

 void LoadStubCompiler::GenerateLoadConstant(Handle<Object> value) {
   // Return the constant value.
-  __ LoadObject(v0, value);
+  __ li(v0, value);
   __ Ret();
 }

--
--
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/groups/opt_out.

Reply via email to