Author: whessev8
Date: Tue Dec  9 04:12:27 2008
New Revision: 949

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

Log:
A first stab at using the top of stack as the
register it is currently in, or as the constant it is.
Probably doesn't even compile.  Take a look.

Review URL: http://codereview.chromium.org/13201

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      Tue Dec  9  
04:12:27 2008
@@ -35,6 +35,27 @@

  #define __ masm_->

+
+//  
-------------------------------------------------------------------------
+// Result implementation.
+
+
+Result::Result(Register reg, CodeGenerator* cgen)
+  : type_(REGISTER),
+    cgen_(cgen) {
+  data_.reg_ = reg;
+  ASSERT(!reg().is(no_reg));
+  cgen_->allocator()->Use(reg);
+}
+
+
+void Result::Unuse() {
+  ASSERT(!reg().is(no_reg));
+  cgen_->allocator()->Unuse(reg());
+  data_.reg_ = no_reg;
+}
+
+
  //  
-------------------------------------------------------------------------
  // VirtualFrame implementation.

@@ -593,6 +614,47 @@

  void VirtualFrame::Drop() { Drop(1); }

+
+/*
+We need comparison with literal to work.
+It will get Result, is register or constant.
+Pop gives it this, from register, constant, memory, or
+reference to slot.
+
+In comparison to literal, we need register case to work.
+We need non-smi stub to exit and return with a non-spilled frame.
+*/
+
+
+Result VirtualFrame::Pop() {
+  FrameElement popped = elements_.RemoveLast();
+  bool pop_needed = (stack_pointer_ == elements_.length());
+
+  if (popped.is_constant()) {
+    if (pop_needed) {
+      stack_pointer_--;
+      __ add(Operand(esp), Immediate(kPointerSize));
+    }
+    return Result(popped.handle(), cgen_);
+  } else if (popped.is_register()) {
+    Unuse(popped.reg());
+    if (pop_needed) {
+      stack_pointer_--;
+      __ add(Operand(esp), Immediate(kPointerSize));
+    }
+    return Result(popped.reg(), cgen_);
+  } else {
+    ASSERT(popped.is_memory());
+    Register temp = cgen_->allocator()->Allocate();
+    ASSERT(!temp.is(no_reg));
+    ASSERT(pop_needed);
+    stack_pointer_--;
+    __ pop(temp);
+    // The register temp is double counted, by Allocate and Result(temp).
+    cgen_->allocator()->Unuse(temp);
+    return Result(temp, cgen_);
+  }
+}

  void VirtualFrame::EmitPop(Register reg) {
    ASSERT(stack_pointer_ == elements_.length() - 1);

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       Tue Dec  9  
04:12:27 2008
@@ -33,6 +33,61 @@

  namespace v8 { namespace internal {

+
+// The code generator's view of a frame element, when it wants to use it.
+//
+// A Result can be a register or a constant.
+class Result BASE_EMBEDDED {
+ public:
+  // Construct a register Result.
+  explicit Result(Register reg, CodeGenerator* cgen);
+
+  // Construct a Result whose value is a compile-time constant.
+  Result(Handle<Object> value, CodeGenerator * cgen) :
+      type_(CONSTANT),
+      cgen_(cgen) {
+    data_.handle_ = value.location();
+  }
+
+  ~Result() {
+    // We have called Unuse() before Result goes out of scope.
+    ASSERT(reg_.is(no_reg));
+  }
+
+  void Unuse();
+
+  bool is_register() const { return type() == REGISTER; }
+  bool is_constant() const { return type() == CONSTANT; }
+
+  Register reg() const {
+    ASSERT(type() == REGISTER);
+    return data_.reg_;
+  }
+
+  Handle<Object> handle() const {
+    ASSERT(type() == CONSTANT);
+    return Handle<Object>(data_.handle_);
+  }
+
+ private:
+  enum Type { REGISTER, CONSTANT };
+
+  Type type_;
+
+  Type type() const { return type_; }
+
+  union {
+    Register reg_;
+    Object** handle_;
+  } data_;
+
+  CodeGenerator* cgen_;
+};
+
+
+// A result in a register just means that the value can be read from the  
register
+
+
  //  
-------------------------------------------------------------------------
  // Virtual frame elements
  //
@@ -250,6 +305,10 @@

    // Drop one element.
    void Drop();
+
+  // Pop an element from the top of the expression stack.
+  // Returns a Result, which may be a constant or a register.
+  Result Pop();

    // Pop and save an element from the top of the expression stack and emit  
a
    // corresponding pop instruction.

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

Reply via email to