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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2630 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 23507e34
...@@ -424,7 +424,19 @@ void StatementBuilder::VisitBlock(Block* stmt) { ...@@ -424,7 +424,19 @@ void StatementBuilder::VisitBlock(Block* stmt) {
void StatementBuilder::VisitExpressionStatement(ExpressionStatement* 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());
} }
......
...@@ -201,11 +201,13 @@ class Location : public Value { ...@@ -201,11 +201,13 @@ class Location : public Value {
// computation is not needed (though its side effects are). // computation is not needed (though its side effects are).
class Effect : public Location { class Effect : public Location {
public: 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 Get(MacroAssembler* masm, Register reg) { UNREACHABLE(); }
void Set(MacroAssembler* masm, Register reg) { UNREACHABLE(); }
void Push(MacroAssembler* masm) { UNREACHABLE(); } void Push(MacroAssembler* masm) { UNREACHABLE(); }
// Setting Effect is ignored.
void Set(MacroAssembler* masm, Register reg) {}
#ifdef DEBUG #ifdef DEBUG
void Print(); void Print();
#endif #endif
...@@ -311,6 +313,7 @@ class Instruction : public ZoneObject { ...@@ -311,6 +313,7 @@ class Instruction : public ZoneObject {
// Accessors. // Accessors.
Location* location() { return loc_; } Location* location() { return loc_; }
void set_location(Location* loc) { loc_ = loc; }
// Support for fast-compilation mode: // Support for fast-compilation mode:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment