Author: [EMAIL PROTECTED]
Date: Fri Nov  7 07:21:53 2008
New Revision: 717

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

Log:
Remove the platform specific jump target files by making them have the
same interfaces.
Review URL: http://codereview.chromium.org/9693

Modified: branches/experimental/toiger/src/assembler-arm.h
==============================================================================
--- branches/experimental/toiger/src/assembler-arm.h    (original)
+++ branches/experimental/toiger/src/assembler-arm.h    Fri Nov  7 07:21:53  
2008
@@ -211,6 +211,12 @@
  }


+// Branch hints are not used on the ARM.  They are defined so that they can
+// appear in shared function signatures, but will be ignored in ARM
+// implementations.
+enum Hint { no_hint };
+
+
  // The pc store offset may be 8 or 12 depending on the processor  
implementation.
  int PcStoreOffset();


Modified: branches/experimental/toiger/src/codegen-ia32.cc
==============================================================================
--- branches/experimental/toiger/src/codegen-ia32.cc    (original)
+++ branches/experimental/toiger/src/codegen-ia32.cc    Fri Nov  7 07:21:53  
2008
@@ -3913,6 +3913,11 @@
  }


+bool CodeGenerator::IsActualFunctionReturn(JumpTarget* target) {
+  return (target == &function_return_ && !function_return_is_shadowed_);
+}
+
+
  #undef __
  #define __ masm->


Modified: branches/experimental/toiger/src/codegen-ia32.h
==============================================================================
--- branches/experimental/toiger/src/codegen-ia32.h     (original)
+++ branches/experimental/toiger/src/codegen-ia32.h     Fri Nov  7 07:21:53 2008
@@ -374,6 +374,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_;

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  7 07:21:53  
2008
@@ -64,7 +64,7 @@
    __ b(&label_);
  }

-void JumpTarget::Branch(Condition cc) {
+void JumpTarget::Branch(Condition cc, Hint ignored) {
    __ b(cc, &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  7  
07:21:53 2008
@@ -60,12 +60,6 @@
  }


-bool JumpTarget::IsActualFunctionReturn() {
-  return (this == &code_generator_->function_return_ &&
-          !code_generator_->function_return_is_shadowed_);
-}
-
-
  void JumpTarget::Jump() {
    // Precondition: there is a current frame.  There may or may not be an
    // expected frame at the label.
@@ -80,11 +74,15 @@
      code_generator_->set_frame(NULL);
      // The frame at the actual function return will always have height
      // zero.
-    if (IsActualFunctionReturn()) expected_frame_->height_ = 0;
+    if (code_generator_->IsActualFunctionReturn(this)) {
+      expected_frame_->height_ = 0;
+    }
    } else {
      // No code needs to be emitted to merge to the expected frame at the
      // actual function return.
-    if (!IsActualFunctionReturn()) current_frame->MergeTo(expected_frame_);
+    if (!code_generator_->IsActualFunctionReturn(this)) {
+      current_frame->MergeTo(expected_frame_);
+    }
      code_generator_->delete_frame();
    }

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

    __ j(cc, &label_, hint);
@@ -125,7 +127,7 @@
    // at the label.
    ASSERT(code_generator_ != NULL);
    ASSERT(masm_ != NULL);
-  ASSERT(!IsActualFunctionReturn());
+  ASSERT(!code_generator_->IsActualFunctionReturn(this));

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

    __ bind(&label_);

Modified: branches/experimental/toiger/src/jump-target.h
==============================================================================
--- branches/experimental/toiger/src/jump-target.h      (original)
+++ branches/experimental/toiger/src/jump-target.h      Fri Nov  7 07:21:53 2008
@@ -28,10 +28,148 @@
  #ifndef V8_JUMP_TARGET_H_
  #define V8_JUMP_TARGET_H_

-#if defined(ARM) || defined (__arm__) || defined(__thumb__)
-#include "jump-target-arm.h"
-#else  // ia32
-#include "jump-target-ia32.h"
+#include "virtual-frame.h"
+
+namespace v8 { namespace internal {
+
+//  
-------------------------------------------------------------------------
+// Jump targets
+//
+// A jump target is an abstraction of a control-flow target in generated
+// code.  It encapsulates an assembler label and an expected virtual frame
+// layout at that label.  The first time control flow reaches the target,
+// either via jumping or branching or by binding the target, the expected
+// frame is set.  If control flow subsequently reaches the target, code may
+// be emitted to ensure that the current frame matches the expected frame.
+//
+// A jump target must have been reached via control flow (either by  
jumping,
+// branching, or falling through) when it is bound.  In particular, this
+// means that at least one of the control-flow graph edges reaching the
+// target must be a forward edge and must be compiled before any backward
+// edges.
+
+class JumpTarget : public ZoneObject {  // Shadows are dynamically  
allocated.
+ public:
+  // Construct a jump target with a given code generator used to generate
+  // code and to provide access to a current frame.
+  explicit JumpTarget(CodeGenerator* cgen);
+
+  // Construct a jump target without a code generator.  A code generator
+  // must be supplied before using the jump target as a label.  This is
+  // useful, eg, when jump targets are embedded in AST nodes.
+  JumpTarget();
+
+  virtual ~JumpTarget() { delete expected_frame_; }
+
+  // Supply a code generator.  This function expects to be given a non-null
+  // code generator, and to be called only when the code generator is not
+  // yet set.
+  void set_code_generator(CodeGenerator* cgen);
+
+  // Accessors.
+  CodeGenerator* code_generator() const { return code_generator_; }
+
+  Label* label() { return &label_; }
+
+  VirtualFrame* expected_frame() const { return expected_frame_; }
+  void set_expected_frame(VirtualFrame* frame) {
+    expected_frame_ = frame;
+  }
+
+  // Predicates testing the state of the encapsulated label.
+  bool is_bound() const { return label_.is_bound(); }
+  bool is_linked() const { return label_.is_linked(); }
+  bool is_unused() const { return label_.is_unused(); }
+
+  // Treat the jump target as a fresh one---the label is unused and the
+  // expected frame if any is reset.
+  void Unuse() {
+    label_.Unuse();
+    delete expected_frame_;
+    expected_frame_ = NULL;
+  }
+
+  // Emit a jump to the target.  There must be a current frame before the
+  // jump and there will be no current frame after the jump.
+  void Jump();
+
+  // Emit a conditional branch to the target.  If there is no current  
frame,
+  // there must be one expected at the target.
+  void Branch(Condition cc, Hint hint = no_hint);
+
+  // Bind a jump target.  There must be a current frame and no expected
+  // frame at the target (targets are only bound once).
+  void Bind();
+
+  // Emit a call to a jump target.  There must be a current frame.  The
+  // frame at the target is the same as the current frame except for an
+  // extra return address on top of it.
+  void Call();
+
+ protected:
+  // The encapsulated assembler label.
+  Label label_;
+
+  // The expected frame where the label is bound, or NULL.
+  VirtualFrame* expected_frame_;
+
+ private:
+  // The code generator gives access to the current frame.
+  CodeGenerator* code_generator_;
+
+  // Used to emit code.
+  MacroAssembler* masm_;
+};
+
+
+//  
-------------------------------------------------------------------------
+// Shadow jump targets
+//
+// Shadow jump targets represent a jump target that is temporarily shadowed
+// by another one (represented by the original during shadowing).  They are
+// used to catch jumps to labels in certain contexts, e.g. try blocks.
+// After shadowing ends, the formerly shadowed target is again represented
+// by the original and the ShadowTarget can be used as a jump target in its
+// own right, representing the formerly shadowing target.
+
+class ShadowTarget : public JumpTarget {
+ public:
+  // Construct a shadow a jump target.  After construction, the original
+  // jump target shadows the former target, which is hidden as the
+  // newly-constructed shadow target.
+  explicit ShadowTarget(JumpTarget* original);
+
+  virtual ~ShadowTarget() {
+    ASSERT(!is_shadowing_);
+  }
+
+  // End shadowing.  After shadowing ends, the original jump target gives
+  // access to the formerly shadowed target and the shadow target object
+  // gives access to the formerly shadowing target.
+  void StopShadowing();
+
+  // During shadowing, the currently shadowing target.  After shadowing,  
the
+  // target that was shadowed.
+  JumpTarget* original_target() const { return original_target_; }
+
+ private:
+  // During shadowing, the currently shadowing target.  After shadowing,  
the
+  // target that was shadowed.
+  JumpTarget* original_target_;
+
+  // During shadowing, the saved state of the shadowed target's label.
+  int original_pos_;
+
+  // During shadowing, the saved state of the shadowed target's expected
+  // frame.
+  VirtualFrame* original_expected_frame_;
+
+#ifdef DEBUG
+  bool is_shadowing_;
  #endif
+};
+
+
+} }  // namespace v8::internal

  #endif  // V8_JUMP_TARGET_H_

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

Reply via email to