diff --git a/src/cfg.cc b/src/cfg.cc index af54ac7bf4..bd4c8ae5a9 100644 --- a/src/cfg.cc +++ b/src/cfg.cc @@ -424,7 +424,19 @@ void StatementBuilder::VisitBlock(Block* stmt) { 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()); } diff --git a/src/cfg.h b/src/cfg.h index 62b93f911a..02a99f4389 100644 --- a/src/cfg.h +++ b/src/cfg.h @@ -201,11 +201,13 @@ class Location : public Value { // 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 @@ class Instruction : public ZoneObject { // Accessors. Location* location() { return loc_; } + void set_location(Location* loc) { loc_ = loc; } // Support for fast-compilation mode: