Reviewers: William Hesse, Description: 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. Please review this at http://codereview.chromium.org/162006 SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/ Affected files: M src/cfg.h M src/cfg.cc Index: src/cfg.h =================================================================== --- src/cfg.h (revision 2628) +++ src/cfg.h (working copy) @@ -201,11 +201,13 @@ // 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(); #endif @@ -311,6 +313,7 @@ // Accessors. Location* location() { return loc_; } + void set_location(Location* loc) { loc_ = loc; } // Support for fast-compilation mode: Index: src/cfg.cc =================================================================== --- src/cfg.cc (revision 2628) +++ src/cfg.cc (working copy) @@ -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()); } --~--~---------~--~----~------------~-------~--~----~ v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev -~----------~----~----~----~------~----~------~--~---
