Author: whessev8
Date: Thu Jan 22 05:19:31 2009
New Revision: 1125

Modified:
    branches/experimental/toiger/src/codegen-ia32.cc
    branches/experimental/toiger/src/virtual-frame-ia32.cc
    branches/experimental/toiger/src/virtual-frame-ia32.h

Log:
Remove spilled frame from some function entry code.
Remove spilled frame from AddSmiImmediate code.
Add Push(Smi*).
Review URL: http://codereview.chromium.org/18616

Modified: branches/experimental/toiger/src/codegen-ia32.cc
==============================================================================
--- branches/experimental/toiger/src/codegen-ia32.cc    (original)
+++ branches/experimental/toiger/src/codegen-ia32.cc    Thu Jan 22 05:19:31  
2009
@@ -174,11 +174,9 @@
        ASSERT(scope_->arguments_shadow() != NULL);
        Comment cmnt(masm_, "[ Allocate arguments object");
        ArgumentsAccessStub stub(ArgumentsAccessStub::NEW_OBJECT);
-      VirtualFrame::SpilledScope spilled_scope(this);
-      __ lea(eax, frame_->Receiver());
-      frame_->EmitPush(frame_->Function());
-      frame_->EmitPush(eax);
-      frame_->EmitPush(Immediate(Smi::FromInt(scope_->num_parameters())));
+      frame_->PushFunction();
+      frame_->PushReceiverSlotAddress();
+      frame_->Push(Smi::FromInt(scope_->num_parameters()));
        Result answer = frame_->CallStub(&stub, 3);
        frame_->Push(&answer);
      }
@@ -187,14 +185,15 @@
        Comment cmnt(masm_, "[ allocate local context");
        // Allocate local context.
        // Get outer context and create a new context based on it.
-      VirtualFrame::SpilledScope spilled_scope(this);
-      frame_->EmitPush(frame_->Function());
-      frame_->CallRuntime(Runtime::kNewContext, 1);  // eax holds the  
result
+      frame_->PushFunction();
+      Result context = frame_->CallRuntime(Runtime::kNewContext, 1);

        if (kDebug) {
+        frame_->SpillAll();  // Needed for breakpoint below.
          JumpTarget verified_true(this);
          // Verify eax and esi are the same in debug mode
-        __ cmp(eax, Operand(esi));
+        __ cmp(context.reg(), Operand(esi));
+        context.Unuse();
          verified_true.Branch(equal);
          __ int3();
          verified_true.Bind();
@@ -863,18 +862,17 @@
    }

    virtual void Generate() {
-    // The argument is actually passed in eax.
-    enter()->Bind();
-    VirtualFrame::SpilledScope spilled_scope(generator());
+    Result arg(generator());
+    enter()->Bind(&arg);
+    arg.ToRegister();
+    generator()->frame()->Spill(arg.reg());
      // Undo the optimistic add operation and call the shared stub.
-    Immediate immediate(Smi::FromInt(value_));
-    __ sub(Operand(eax), immediate);
-    generator()->frame()->EmitPush(eax);
-    generator()->frame()->EmitPush(immediate);
+    __ sub(Operand(arg.reg()), Immediate(Smi::FromInt(value_)));
+    generator()->frame()->Push(&arg);
+    generator()->frame()->Push(Smi::FromInt(value_));
      GenericBinaryOpStub igostub(Token::ADD, overwrite_mode_,  
SMI_CODE_INLINED);
-    generator()->frame()->CallStub(&igostub, 2);
-    // The result is actually returned in eax.
-    exit()->Jump();
+    Result result = generator()->frame()->CallStub(&igostub, 2);
+    exit()->Jump(&result);
    }

   private:
@@ -892,18 +890,18 @@
    }

    virtual void Generate() {
-    // The argument is actually passed in eax.
-    enter()->Bind();
-    VirtualFrame::SpilledScope spilled_scope(generator());
+    Result arg(generator());
+    enter()->Bind(&arg);
+    arg.ToRegister();
+    generator()->frame()->Spill(arg.reg());  // Should not be needed.
      // Undo the optimistic add operation and call the shared stub.
      Immediate immediate(Smi::FromInt(value_));
-    __ sub(Operand(eax), immediate);
-    generator()->frame()->EmitPush(immediate);
-    generator()->frame()->EmitPush(eax);
+    __ sub(Operand(arg.reg()), immediate);
+    generator()->frame()->Push(Smi::FromInt(value_));
+    generator()->frame()->Push(&arg);
      GenericBinaryOpStub igostub(Token::ADD, overwrite_mode_,  
SMI_CODE_INLINED);
-    generator()->frame()->CallStub(&igostub, 2);
-    // The result is actually returned in eax.
-    exit()->Jump();
+    arg = generator()->frame()->CallStub(&igostub, 2);
+    exit()->Jump(&arg);
    }

   private:
@@ -1001,13 +999,15 @@
          deferred = new DeferredInlinedSmiAddReversed(this, int_value,
                                                       overwrite_mode);
        }
-      frame_->EmitPop(eax);
-      __ add(Operand(eax), Immediate(value));
-      deferred->enter()->Branch(overflow, not_taken);
-      __ test(eax, Immediate(kSmiTagMask));
-      deferred->enter()->Branch(not_zero, not_taken);
-      deferred->exit()->Bind();
-      frame_->EmitPush(eax);
+      Result operand = frame_->Pop();
+      operand.ToRegister();
+      frame_->Spill(operand.reg());
+      __ add(Operand(operand.reg()), Immediate(value));
+      deferred->enter()->Branch(overflow, &operand, not_taken);
+      __ test(Operand(operand.reg()), Immediate(kSmiTagMask));
+      deferred->enter()->Branch(not_zero, &operand, not_taken);
+      deferred->exit()->Bind(&operand);
+      frame_->Push(&operand);
        break;
      }

@@ -3015,7 +3015,7 @@
      if (target.is_illegal()) {
        // Fool the virtual frame into thinking that we left the assignment's
        // value on the frame.
-      frame_->Push(Handle<Object>(Smi::FromInt(0)));
+      frame_->Push(Smi::FromInt(0));
        return;
      }

@@ -3865,7 +3865,7 @@

    // Postfix: Make room for the result.
    if (is_postfix) {
-    frame_->Push(Handle<Object>(Smi::FromInt(0)));
+    frame_->Push(Smi::FromInt(0));
    }

    { Reference target(this, node->expression());
@@ -3873,7 +3873,7 @@
        // Spoof the virtual frame to have the expected height (one higher
        // than on entry).
        if (!is_postfix) {
-        frame_->Push(Handle<Object>(Smi::FromInt(0)));
+        frame_->Push(Smi::FromInt(0));
        }
        return;
      }

Modified: branches/experimental/toiger/src/virtual-frame-ia32.cc
==============================================================================
--- branches/experimental/toiger/src/virtual-frame-ia32.cc      (original)
+++ branches/experimental/toiger/src/virtual-frame-ia32.cc      Thu Jan 22  
05:19:31 2009
@@ -750,6 +750,14 @@
  }


+void VirtualFrame::PushReceiverSlotAddress() {
+  Result temp = cgen_->allocator()->Allocate();
+  ASSERT(temp.is_valid());
+  __ lea(temp.reg(), ParameterAt(-1));
+  Push(&temp);
+}
+
+
  void VirtualFrame::LoadFrameSlotAt(int index) {
    ASSERT(index >= 0);
    ASSERT(index < elements_.length());

Modified: branches/experimental/toiger/src/virtual-frame-ia32.h
==============================================================================
--- branches/experimental/toiger/src/virtual-frame-ia32.h       (original)
+++ branches/experimental/toiger/src/virtual-frame-ia32.h       Thu Jan 22  
05:19:31 2009
@@ -293,6 +293,12 @@
    // The function frame slot.
    Operand Function() const { return Operand(ebp, kFunctionOffset); }

+  // Push the address of the receiver slot on the frame.
+  void PushReceiverSlotAddress();
+
+  // Push the function on top of the frame.
+  void PushFunction() { LoadFrameSlotAt(function_index()); }
+
    // Lazily save the value of the esi register to the context frame slot.
    void SaveContextRegister();

@@ -386,6 +392,7 @@
    // Push an element on the virtual frame.
    void Push(Register reg);
    void Push(Handle<Object> value);
+  void Push(Smi* value) { Push(Handle<Object>(value)); }

    // Pushing a result invalidates it (its contents become owned by the
    // frame).

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

Reply via email to