Author: [email protected]
Date: Mon Jan 26 07:24:55 2009
New Revision: 1158

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

Log:
Experimental: add a function to the API for recording assembler
positions to record the start of each compiled function.

This seemed easiest, since the deferred code expects a statement
position and there is not necessarily a statement in the body to pass
to CodeForStatement.

Since it's on the branch, it is not ported to the ARM but will be
before we merge back to bleeding_edge.
Review URL: http://codereview.chromium.org/18592

Modified: branches/experimental/toiger/src/codegen-ia32.cc
==============================================================================
--- branches/experimental/toiger/src/codegen-ia32.cc    (original)
+++ branches/experimental/toiger/src/codegen-ia32.cc    Mon Jan 26 07:24:55  
2009
@@ -126,7 +126,7 @@

  void CodeGenerator::GenCode(FunctionLiteral* fun) {
    // Record the position for debugging purposes.
-  CodeForSourcePosition(fun->start_position());
+  CodeForFunctionPosition(fun);

    ZoneList<Statement*>* body = fun->body();

@@ -1395,6 +1395,7 @@
    generator()->frame()->SpillAll();
    StackCheckStub stub;
    Result ignored = generator()->frame()->CallStub(&stub, 0);
+  ignored.Unuse();
    exit()->Jump();
  }

@@ -1422,7 +1423,7 @@
  void CodeGenerator::VisitBlock(Block* node) {
    ASSERT(!in_spilled_code());
    Comment cmnt(masm_, "[ Block");
-  CodeForStatement(node);
+  CodeForStatementPosition(node);
    node->set_break_stack_height(break_stack_height_);
    node->break_target()->Initialize(this);
    VisitStatements(node->statements());
@@ -1444,7 +1445,7 @@

  void CodeGenerator::VisitDeclaration(Declaration* node) {
    Comment cmnt(masm_, "[ Declaration");
-  CodeForStatement(node);
+  CodeForStatementPosition(node);
    Variable* var = node->proxy()->var();
    ASSERT(var != NULL);  // must have been resolved
    Slot* slot = var->slot();
@@ -1509,7 +1510,7 @@
  void CodeGenerator::VisitExpressionStatement(ExpressionStatement* node) {
    ASSERT(!in_spilled_code());
    Comment cmnt(masm_, "[ ExpressionStatement");
-  CodeForStatement(node);
+  CodeForStatementPosition(node);
    Expression* expression = node->expression();
    expression->MarkAsStatement();
    Load(expression);
@@ -1521,7 +1522,7 @@
  void CodeGenerator::VisitEmptyStatement(EmptyStatement* node) {
    ASSERT(!in_spilled_code());
    Comment cmnt(masm_, "// EmptyStatement");
-  CodeForStatement(node);
+  CodeForStatementPosition(node);
    // nothing to do
  }

@@ -1534,7 +1535,7 @@
    bool has_then_stm = node->HasThenStatement();
    bool has_else_stm = node->HasElseStatement();

-  CodeForStatement(node);
+  CodeForStatementPosition(node);
    JumpTarget exit(this);
    if (has_then_stm && has_else_stm) {
      JumpTarget then(this);
@@ -1600,7 +1601,7 @@
  void CodeGenerator::VisitContinueStatement(ContinueStatement* node) {
    ASSERT(!in_spilled_code());
    Comment cmnt(masm_, "[ ContinueStatement");
-  CodeForStatement(node);
+  CodeForStatementPosition(node);
    CleanStack(break_stack_height_ - node->target()->break_stack_height());
    node->target()->continue_target()->Jump();
  }
@@ -1609,7 +1610,7 @@
  void CodeGenerator::VisitBreakStatement(BreakStatement* node) {
    ASSERT(!in_spilled_code());
    Comment cmnt(masm_, "[ BreakStatement");
-  CodeForStatement(node);
+  CodeForStatementPosition(node);
    CleanStack(break_stack_height_ - node->target()->break_stack_height());
    node->target()->break_target()->Jump();
  }
@@ -1623,13 +1624,13 @@
      // If the function return is shadowed, we spill all information
      // and just jump to the label.
      VirtualFrame::SpilledScope spilled_scope(this);
-    CodeForStatement(node);
+    CodeForStatementPosition(node);
      LoadAndSpill(node->expression());
      frame_->EmitPop(eax);
      function_return_.Jump();
    } else {
      // Load the returned value.
-    CodeForStatement(node);
+    CodeForStatementPosition(node);
      Load(node->expression());

      // Pop the result from the frame and prepare the frame for
@@ -1686,7 +1687,7 @@
  void CodeGenerator::VisitWithEnterStatement(WithEnterStatement* node) {
    ASSERT(!in_spilled_code());
    Comment cmnt(masm_, "[ WithEnterStatement");
-  CodeForStatement(node);
+  CodeForStatementPosition(node);
    Load(node->expression());
    Result context(this);
    if (node->is_catch_block()) {
@@ -1715,7 +1716,7 @@
  void CodeGenerator::VisitWithExitStatement(WithExitStatement* node) {
    ASSERT(!in_spilled_code());
    Comment cmnt(masm_, "[ WithExitStatement");
-  CodeForStatement(node);
+  CodeForStatementPosition(node);
    // Pop context.
    __ mov(esi, ContextOperand(esi, Context::PREVIOUS_INDEX));
    // Update context local.
@@ -1804,7 +1805,7 @@
  void CodeGenerator::VisitSwitchStatement(SwitchStatement* node) {
    ASSERT(!in_spilled_code());
    Comment cmnt(masm_, "[ SwitchStatement");
-  CodeForStatement(node);
+  CodeForStatementPosition(node);
    node->set_break_stack_height(break_stack_height_);
    node->break_target()->Initialize(this);

@@ -1903,7 +1904,7 @@
  void CodeGenerator::VisitLoopStatement(LoopStatement* node) {
    ASSERT(!in_spilled_code());
    Comment cmnt(masm_, "[ LoopStatement");
-  CodeForStatement(node);
+  CodeForStatementPosition(node);
    node->set_break_stack_height(break_stack_height_);
    node->break_target()->Initialize(this);

@@ -2064,7 +2065,7 @@
              // Record source position of the statement as this code which  
is
              // after the code for the body actually belongs to the loop
              // statement and not the body.
-            CodeForStatement(node);
+            CodeForStatementPosition(node);
              ASSERT(node->type() == LoopStatement::FOR_LOOP);
              Visit(node->next());
              loop.Jump();
@@ -2086,7 +2087,7 @@
    ASSERT(!in_spilled_code());
    VirtualFrame::SpilledScope spilled_scope(this);
    Comment cmnt(masm_, "[ ForInStatement");
-  CodeForStatement(node);
+  CodeForStatementPosition(node);

    // We keep stuff on the stack while the body is executing.
    // Record it, so that a break/continue crossing this statement
@@ -2278,7 +2279,7 @@
    ASSERT(!in_spilled_code());
    VirtualFrame::SpilledScope spilled_scope(this);
    Comment cmnt(masm_, "[ TryCatch");
-  CodeForStatement(node);
+  CodeForStatementPosition(node);

    JumpTarget try_block(this);
    JumpTarget exit(this);
@@ -2407,7 +2408,7 @@
    ASSERT(!in_spilled_code());
    VirtualFrame::SpilledScope spilled_scope(this);
    Comment cmnt(masm_, "[ TryFinally");
-  CodeForStatement(node);
+  CodeForStatementPosition(node);

    // State: Used to keep track of reason for entering the finally
    // block. Should probably be extended to hold information for
@@ -2575,7 +2576,7 @@
  void CodeGenerator::VisitDebuggerStatement(DebuggerStatement* node) {
    ASSERT(!in_spilled_code());
    Comment cmnt(masm_, "[ DebuggerStatement");
-  CodeForStatement(node);
+  CodeForStatementPosition(node);
    // Spill everything, even constants, to the frame.
    frame_->SpillAll();
    frame_->CallRuntime(Runtime::kDebugBreak, 0);
@@ -3080,7 +3081,7 @@

  void CodeGenerator::VisitAssignment(Assignment* node) {
    Comment cmnt(masm_, "[ Assignment");
-  CodeForStatement(node);
+  CodeForStatementPosition(node);

    { Reference target(this, node->target());
      if (target.is_illegal()) {
@@ -3131,7 +3132,7 @@
  void CodeGenerator::VisitThrow(Throw* node) {
    VirtualFrame::SpilledScope spilled_scope(this);
    Comment cmnt(masm_, "[ Throw");
-  CodeForStatement(node);
+  CodeForStatementPosition(node);

    LoadAndSpill(node->exception());
    frame_->CallRuntime(Runtime::kThrow, 1);
@@ -3151,7 +3152,7 @@

    ZoneList<Expression*>* args = node->arguments();

-  CodeForStatement(node);
+  CodeForStatementPosition(node);

    // Check if the function is a variable or a property.
    Expression* function = node->expression();
@@ -3287,7 +3288,7 @@

  void CodeGenerator::VisitCallNew(CallNew* node) {
    Comment cmnt(masm_, "[ CallNew");
-  CodeForStatement(node);
+  CodeForStatementPosition(node);

    // According to ECMA-262, section 11.2.2, page 44, the function
    // expression in new calls must be evaluated before the
@@ -3345,7 +3346,7 @@
    ZoneList<Expression*>* args = node->arguments();
    Expression* function = node->expression();

-  CodeForStatement(node);
+  CodeForStatementPosition(node);

    // Prepare stack for call to resolved function.
    LoadAndSpill(function);

Modified: branches/experimental/toiger/src/codegen-ia32.h
==============================================================================
--- branches/experimental/toiger/src/codegen-ia32.h     (original)
+++ branches/experimental/toiger/src/codegen-ia32.h     Mon Jan 26 07:24:55 2009
@@ -462,7 +462,8 @@
    // Methods used to indicate which source code is generated for. Source
    // positions are collected by the assembler and emitted with the  
relocation
    // information.
-  void CodeForStatement(Node* node);
+  void CodeForFunctionPosition(FunctionLiteral* fun);
+  void CodeForStatementPosition(Node* node);
    void CodeForSourcePosition(int pos);

    bool is_eval_;  // Tells whether code is generated for eval.

Modified: branches/experimental/toiger/src/codegen.cc
==============================================================================
--- branches/experimental/toiger/src/codegen.cc (original)
+++ branches/experimental/toiger/src/codegen.cc Mon Jan 26 07:24:55 2009
@@ -494,7 +494,18 @@
  }


-void CodeGenerator::CodeForStatement(Node* node) {
+void CodeGenerator::CodeForFunctionPosition(FunctionLiteral* fun) {
+  if (FLAG_debug_info) {
+    int pos = fun->start_position();
+    if (pos != RelocInfo::kNoPosition) {
+      masm()->RecordStatementPosition(pos);
+      masm()->RecordPosition(pos);
+    }
+  }
+}
+
+
+void CodeGenerator::CodeForStatementPosition(Node* node) {
    if (FLAG_debug_info) {
      int pos = node->statement_pos();
      if (pos != RelocInfo::kNoPosition) {

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

Reply via email to