Author: [EMAIL PROTECTED]
Date: Fri Nov 14 05:40:38 2008
New Revision: 758

Modified:
    branches/experimental/toiger/src/codegen-arm.cc
    branches/experimental/toiger/src/codegen-arm.h
    branches/experimental/toiger/src/jump-target-arm.cc
    branches/experimental/toiger/src/jump-target-ia32.cc

Log:
The expected expression stack height at the return label can be
anything, so we set it to zero and special case it when generating
merge code.
Review URL: http://codereview.chromium.org/11011

Modified: branches/experimental/toiger/src/codegen-arm.cc
==============================================================================
--- branches/experimental/toiger/src/codegen-arm.cc     (original)
+++ branches/experimental/toiger/src/codegen-arm.cc     Fri Nov 14 05:40:38 2008
@@ -82,7 +82,8 @@
        frame_(NULL),
        cc_reg_(al),
        state_(NULL),
-      break_stack_height_(0) {
+      break_stack_height_(0),
+      function_return_is_shadowed_(false) {
  }


@@ -103,6 +104,7 @@
    set_frame(new VirtualFrame(this));
    cc_reg_ = al;
    function_return_.set_code_generator(this);
+  function_return_is_shadowed_ = false;
    {
      CodeGenState state(this);

@@ -267,6 +269,8 @@
    }

    // Code generation state must be reset.
+  ASSERT(!function_return_is_shadowed_);
+  function_return_.Unuse();
    scope_ = NULL;
    frame_ = NULL;
    ASSERT(!has_cc());
@@ -1819,6 +1823,8 @@
    for (int i = 0; i < nof_escapes; i++) {
      shadows.Add(new ShadowTarget(node->escaping_targets()->at(i)));
    }
+  bool function_return_was_shadowed = function_return_is_shadowed_;
+  function_return_is_shadowed_ = true;

    // Generate code for the statements in the try block.
    VisitStatements(node->try_block()->statements());
@@ -1834,6 +1840,7 @@
      shadows[i]->StopShadowing();
      if (shadows[i]->is_linked()) nof_unlinks++;
    }
+  function_return_is_shadowed_ = function_return_was_shadowed;

    const int kNextIndex = (StackHandlerConstants::kNextOffset
                            + StackHandlerConstants::kAddressDisplacement)
@@ -1916,6 +1923,8 @@
    for (int i = 0; i < nof_escapes; i++) {
      shadows.Add(new ShadowTarget(node->escaping_targets()->at(i)));
    }
+  bool function_return_was_shadowed = function_return_is_shadowed_;
+  function_return_is_shadowed_ = true;

    // Generate code for the statements in the try block.
    VisitStatements(node->try_block()->statements());
@@ -1928,6 +1937,7 @@
      shadows[i]->StopShadowing();
      if (shadows[i]->is_linked()) nof_unlinks++;
    }
+  function_return_is_shadowed_ = function_return_was_shadowed;

    // If we can fall off the end of the try block, set the state on the  
stack
    // to FALLING.
@@ -3312,6 +3322,11 @@
      if (statement_pos == RelocInfo::kNoPosition) return;
      __ RecordStatementPosition(statement_pos);
    }
+}
+
+
+bool CodeGenerator::IsActualFunctionReturn(JumpTarget* target) {
+  return (target == &function_return_ && !function_return_is_shadowed_);
  }



Modified: branches/experimental/toiger/src/codegen-arm.h
==============================================================================
--- branches/experimental/toiger/src/codegen-arm.h      (original)
+++ branches/experimental/toiger/src/codegen-arm.h      Fri Nov 14 05:40:38 2008
@@ -339,6 +339,10 @@
    // should be generated or not.
    void RecordStatementPosition(Node* node);

+  // Is the given jump target the actual (ie, non-shadowed) function return
+  // target?
+  bool IsActualFunctionReturn(JumpTarget* target);
+
    bool is_eval_;  // Tells whether code is generated for eval.
    Handle<Script> script_;
    List<DeferredCode*> deferred_;
@@ -357,7 +361,13 @@
    // Jump targets
    JumpTarget function_return_;

+  // True if the function return is shadowed (ie, jumping to the target
+  // function_return_ does not jump to the true function return, but rather
+  // to some unlinking code).
+  bool function_return_is_shadowed_;
+
    friend class VirtualFrame;
+  friend class JumpTarget;
    friend class Reference;

    DISALLOW_COPY_AND_ASSIGN(CodeGenerator);

Modified: branches/experimental/toiger/src/jump-target-arm.cc
==============================================================================
--- branches/experimental/toiger/src/jump-target-arm.cc (original)
+++ branches/experimental/toiger/src/jump-target-arm.cc Fri Nov 14 05:40:38  
2008
@@ -70,8 +70,16 @@
    if (expected_frame_ == NULL) {
      expected_frame_ = current_frame;
      code_generator_->set_frame(NULL);
+    // The frame at the actual function return will always have height  
zero.
+    if (code_generator_->IsActualFunctionReturn(this)) {
+      expected_frame_->Forget(expected_frame_->height());
+    }
    } else {
-    current_frame->MergeTo(expected_frame_);
+    // No code needs to be emitted to merge to the expected frame at the
+    // actual function return.
+    if (!code_generator_->IsActualFunctionReturn(this)) {
+      current_frame->MergeTo(expected_frame_);
+    }
      code_generator_->delete_frame();
    }

@@ -92,8 +100,16 @@

    if (expected_frame_ == NULL) {
      expected_frame_ = new VirtualFrame(current_frame);
+    // The frame at the actual function return will always have height  
zero.
+    if (code_generator_->IsActualFunctionReturn(this)) {
+      expected_frame_->Forget(expected_frame_->height());
+    }
    } else {
-    current_frame->MergeTo(expected_frame_);
+    // No code needs to be emitted to merge to the expected frame at the
+    // actual function return.
+    if (!code_generator_->IsActualFunctionReturn(this)) {
+      current_frame->MergeTo(expected_frame_);
+    }
    }

    __ b(cc, &label_);
@@ -107,6 +123,7 @@
    // at the label.
    ASSERT(code_generator_ != NULL);
    ASSERT(masm_ != NULL);
+  ASSERT(!code_generator_->IsActualFunctionReturn(this));

    VirtualFrame* current_frame = code_generator_->frame();
    ASSERT(current_frame != NULL);
@@ -136,10 +153,18 @@

    if (expected_frame_ == NULL) {
      expected_frame_ = new VirtualFrame(current_frame);
+    // The frame at the actual function return will always have height  
zero.
+    if (code_generator_->IsActualFunctionReturn(this)) {
+      expected_frame_->Forget(expected_frame_->height());
+    }
    } else if (current_frame == NULL) {
      code_generator_->set_frame(new VirtualFrame(expected_frame_));
    } else {
-    current_frame->MergeTo(expected_frame_);
+    // No code needs to be emitted to merge to the expected frame at the
+    // actual function return.
+    if (!code_generator_->IsActualFunctionReturn(this)) {
+      current_frame->MergeTo(expected_frame_);
+    }
    }

    __ bind(&label_);

Modified: branches/experimental/toiger/src/jump-target-ia32.cc
==============================================================================
--- branches/experimental/toiger/src/jump-target-ia32.cc        (original)
+++ branches/experimental/toiger/src/jump-target-ia32.cc        Fri Nov 14  
05:40:38 2008
@@ -70,8 +70,7 @@
    if (expected_frame_ == NULL) {
      expected_frame_ = current_frame;
      code_generator_->set_frame(NULL);
-    // The frame at the actual function return will always have height
-    // zero.
+    // The frame at the actual function return will always have height  
zero.
      if (code_generator_->IsActualFunctionReturn(this)) {
        expected_frame_->Forget(expected_frame_->height());
      }
@@ -101,8 +100,7 @@

    if (expected_frame_ == NULL) {
      expected_frame_ = new VirtualFrame(current_frame);
-    // The frame at the actual function return will always have height
-    // zero.
+    // The frame at the actual function return will always have height  
zero.
      if (code_generator_->IsActualFunctionReturn(this)) {
        expected_frame_->Forget(expected_frame_->height());
      }
@@ -155,8 +153,7 @@

    if (expected_frame_ == NULL) {
      expected_frame_ = new VirtualFrame(current_frame);
-    // The frame at the actual function return will always have height
-    // zero.
+    // The frame at the actual function return will always have height  
zero.
      if (code_generator_->IsActualFunctionReturn(this)) {
        expected_frame_->Forget(expected_frame_->height());
      }

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

Reply via email to