summaryrefslogtreecommitdiffstats
path: root/V8Binding/v8/src/cfg.cc
diff options
context:
space:
mode:
Diffstat (limited to 'V8Binding/v8/src/cfg.cc')
-rw-r--r--V8Binding/v8/src/cfg.cc142
1 files changed, 82 insertions, 60 deletions
diff --git a/V8Binding/v8/src/cfg.cc b/V8Binding/v8/src/cfg.cc
index 32f614b..d2dff52 100644
--- a/V8Binding/v8/src/cfg.cc
+++ b/V8Binding/v8/src/cfg.cc
@@ -60,10 +60,10 @@ Cfg* Cfg::Build() {
if (fun->scope()->num_heap_slots() > 0) {
BAILOUT("function has context slots");
}
- if (fun->scope()->num_stack_slots() > kPointerSize) {
+ if (fun->scope()->num_stack_slots() > kBitsPerPointer) {
BAILOUT("function has too many locals");
}
- if (fun->scope()->num_parameters() > kPointerSize - 1) {
+ if (fun->scope()->num_parameters() > kBitsPerPointer - 1) {
BAILOUT("function has too many parameters");
}
if (fun->scope()->arguments() != NULL) {
@@ -200,43 +200,22 @@ Handle<Code> Cfg::Compile(Handle<Script> script) {
}
-void MoveInstr::FastAllocate(TempLocation* temp) {
- ASSERT(temp->where() == TempLocation::NOT_ALLOCATED);
- if (temp == value()) {
- temp->set_where(TempLocation::ACCUMULATOR);
- } else {
- temp->set_where(TempLocation::STACK);
- }
+void ZeroOperandInstruction::FastAllocate(TempLocation* temp) {
+ temp->set_where(TempLocation::STACK);
}
-void PropLoadInstr::FastAllocate(TempLocation* temp) {
- ASSERT(temp->where() == TempLocation::NOT_ALLOCATED);
- if (temp == object() || temp == key()) {
- temp->set_where(TempLocation::ACCUMULATOR);
- } else {
- temp->set_where(TempLocation::STACK);
- }
+void OneOperandInstruction::FastAllocate(TempLocation* temp) {
+ temp->set_where((temp == value_)
+ ? TempLocation::ACCUMULATOR
+ : TempLocation::STACK);
}
-void BinaryOpInstr::FastAllocate(TempLocation* temp) {
- ASSERT(temp->where() == TempLocation::NOT_ALLOCATED);
- if (temp == left() || temp == right()) {
- temp->set_where(TempLocation::ACCUMULATOR);
- } else {
- temp->set_where(TempLocation::STACK);
- }
-}
-
-
-void ReturnInstr::FastAllocate(TempLocation* temp) {
- ASSERT(temp->where() == TempLocation::NOT_ALLOCATED);
- if (temp == value()) {
- temp->set_where(TempLocation::ACCUMULATOR);
- } else {
- temp->set_where(TempLocation::STACK);
- }
+void TwoOperandInstruction::FastAllocate(TempLocation* temp) {
+ temp->set_where((temp == value0_ || temp == value1_)
+ ? TempLocation::ACCUMULATOR
+ : TempLocation::STACK);
}
@@ -341,6 +320,7 @@ void ExpressionCfgBuilder::VisitAssignment(Assignment* expr) {
if (lhs->AsProperty() != NULL) {
BAILOUT("unsupported property assignment");
}
+
Variable* var = lhs->AsVariableProxy()->AsVariable();
if (var == NULL) {
BAILOUT("unsupported invalid left-hand side");
@@ -354,6 +334,7 @@ void ExpressionCfgBuilder::VisitAssignment(Assignment* expr) {
BAILOUT("unsupported slot lhs (not a parameter or local)");
}
+ // Parameter and local slot assignments.
ExpressionCfgBuilder builder;
SlotLocation* loc = new SlotLocation(slot->type(), slot->index());
builder.Build(expr->value(), loc);
@@ -382,11 +363,11 @@ void ExpressionCfgBuilder::VisitProperty(Property* expr) {
ExpressionCfgBuilder object, key;
object.Build(expr->obj(), NULL);
if (object.graph() == NULL) {
- BAILOUT("unsupported object subexpression in propref");
+ BAILOUT("unsupported object subexpression in propload");
}
key.Build(expr->key(), NULL);
if (key.graph() == NULL) {
- BAILOUT("unsupported key subexpression in propref");
+ BAILOUT("unsupported key subexpression in propload");
}
if (destination_ == NULL) destination_ = new TempLocation();
@@ -639,9 +620,8 @@ void Cfg::Print() {
void Constant::Print() {
- PrintF("Constant(");
+ PrintF("Constant ");
handle_->Print();
- PrintF(")");
}
@@ -651,13 +631,13 @@ void Nowhere::Print() {
void SlotLocation::Print() {
- PrintF("Slot(");
+ PrintF("Slot ");
switch (type_) {
case Slot::PARAMETER:
- PrintF("PARAMETER, %d)", index_);
+ PrintF("(PARAMETER, %d)", index_);
break;
case Slot::LOCAL:
- PrintF("LOCAL, %d)", index_);
+ PrintF("(LOCAL, %d)", index_);
break;
default:
UNREACHABLE();
@@ -666,45 +646,87 @@ void SlotLocation::Print() {
void TempLocation::Print() {
- PrintF("Temp(%d)", number());
+ PrintF("Temp %d", number());
}
-void MoveInstr::Print() {
- PrintF("Move(");
+void OneOperandInstruction::Print() {
+ PrintF("(");
location()->Print();
PrintF(", ");
value_->Print();
- PrintF(")\n");
+ PrintF(")");
}
-void PropLoadInstr::Print() {
- PrintF("PropLoad(");
+void TwoOperandInstruction::Print() {
+ PrintF("(");
location()->Print();
PrintF(", ");
- object()->Print();
+ value0_->Print();
PrintF(", ");
- key()->Print();
- PrintF(")\n");
+ value1_->Print();
+ PrintF(")");
+}
+
+
+void MoveInstr::Print() {
+ PrintF("Move ");
+ OneOperandInstruction::Print();
+ PrintF("\n");
+}
+
+
+void PropLoadInstr::Print() {
+ PrintF("PropLoad ");
+ TwoOperandInstruction::Print();
+ PrintF("\n");
}
void BinaryOpInstr::Print() {
- PrintF("BinaryOp(");
- location()->Print();
- PrintF(", %s, ", Token::Name(op()));
- left()->Print();
- PrintF(", ");
- right()->Print();
- PrintF(")\n");
+ switch (op()) {
+ case Token::OR:
+ // Two character operand.
+ PrintF("BinaryOp[OR] ");
+ break;
+ case Token::AND:
+ case Token::SHL:
+ case Token::SAR:
+ case Token::SHR:
+ case Token::ADD:
+ case Token::SUB:
+ case Token::MUL:
+ case Token::DIV:
+ case Token::MOD:
+ // Three character operands.
+ PrintF("BinaryOp[%s] ", Token::Name(op()));
+ break;
+ case Token::COMMA:
+ // Five character operand.
+ PrintF("BinaryOp[COMMA] ");
+ break;
+ case Token::BIT_OR:
+ // Six character operand.
+ PrintF("BinaryOp[BIT_OR] ");
+ break;
+ case Token::BIT_XOR:
+ case Token::BIT_AND:
+ // Seven character operands.
+ PrintF("BinaryOp[%s] ", Token::Name(op()));
+ break;
+ default:
+ UNREACHABLE();
+ }
+ TwoOperandInstruction::Print();
+ PrintF("\n");
}
void ReturnInstr::Print() {
- PrintF("Return(");
- value_->Print();
- PrintF(")\n");
+ PrintF("Return ");
+ OneOperandInstruction::Print();
+ PrintF("\n");
}
@@ -715,7 +737,7 @@ void InstructionBlock::Print() {
for (int i = 0, len = instructions_.length(); i < len; i++) {
instructions_[i]->Print();
}
- PrintF("Goto L%d\n\n", successor_->number());
+ PrintF("Goto L%d\n\n", successor_->number());
successor_->Print();
}
}