Revision: 2630
Author: [email protected]
Date: Thu Aug  6 00:51:44 2009
Log: Added support for expression statements to the CFG builder and
fast-mode compiler.

This will generate a compiler temporary for complex expressions and
then immediately throw it away, so a better approach (to be
implemented later) is to pass to the expression builder whether an
expression is in an effect or value context.

Review URL: http://codereview.chromium.org/162006
http://code.google.com/p/v8/source/detail?r=2630

Modified:
  /branches/bleeding_edge/src/cfg.cc
  /branches/bleeding_edge/src/cfg.h

=======================================
--- /branches/bleeding_edge/src/cfg.cc  Wed Aug  5 05:52:31 2009
+++ /branches/bleeding_edge/src/cfg.cc  Thu Aug  6 00:51:44 2009
@@ -424,7 +424,19 @@


  void StatementBuilder::VisitExpressionStatement(ExpressionStatement* stmt)  
{
-  BAILOUT("ExpressionStatement");
+  ExpressionBuilder builder;
+  builder.Build(stmt->expression());
+  if (builder.cfg() == NULL) {
+    BAILOUT("unsupported expression in expression statement");
+  }
+  // Here's a temporary hack: we bang on the last instruction of the
+  // expression (if any) to set its location to Effect.
+  if (!builder.cfg()->is_empty()) {
+    InstructionBlock* block =  
InstructionBlock::cast(builder.cfg()->exit());
+    Instruction* instr = block->instructions()->last();
+    instr->set_location(CfgGlobals::current()->effect_location());
+  }
+  cfg_->Concatenate(builder.cfg());
  }


=======================================
--- /branches/bleeding_edge/src/cfg.h   Wed Aug  5 05:52:31 2009
+++ /branches/bleeding_edge/src/cfg.h   Thu Aug  6 00:51:44 2009
@@ -201,10 +201,12 @@
  // computation is not needed (though its side effects are).
  class Effect : public Location {
   public:
-  // We should not try to emit code to read or write to Effect.
+  // We should not try to emit code to read Effect.
    void Get(MacroAssembler* masm, Register reg) { UNREACHABLE(); }
-  void Set(MacroAssembler* masm, Register reg) { UNREACHABLE(); }
    void Push(MacroAssembler* masm) { UNREACHABLE(); }
+
+  // Setting Effect is ignored.
+  void Set(MacroAssembler* masm, Register reg) {}

  #ifdef DEBUG
    void Print();
@@ -311,6 +313,7 @@

    // Accessors.
    Location* location() { return loc_; }
+  void set_location(Location* loc) { loc_ = loc; }

    // Support for fast-compilation mode:


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

Reply via email to