Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/flow_graph_builder.h" | 5 #include "vm/flow_graph_builder.h" |
| 6 | 6 |
| 7 #include "vm/flags.h" | 7 #include "vm/flags.h" |
| 8 #include "vm/intermediate_language.h" | 8 #include "vm/intermediate_language.h" |
| 9 #include "vm/longjump.h" | 9 #include "vm/longjump.h" |
| 10 #include "vm/os.h" | 10 #include "vm/os.h" |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 127 true_successor_address_ = branch->true_successor_address(); | 127 true_successor_address_ = branch->true_successor_address(); |
| 128 false_successor_address_ = branch->false_successor_address(); | 128 false_successor_address_ = branch->false_successor_address(); |
| 129 } | 129 } |
| 130 | 130 |
| 131 | 131 |
| 132 void EffectGraphVisitor::Bailout(const char* reason) { | 132 void EffectGraphVisitor::Bailout(const char* reason) { |
| 133 owner()->Bailout(reason); | 133 owner()->Bailout(reason); |
| 134 } | 134 } |
| 135 | 135 |
| 136 | 136 |
| 137 // 'bailout' is a statement (without a semicolon), typically a return. | |
| 138 #define CHECK_ALIVE(bailout) \ | |
| 139 do { \ | |
| 140 if (!is_open()) { \ | |
| 141 bailout; \ | |
| 142 } \ | |
| 143 } while (false) | |
| 144 | |
| 145 | |
| 146 // <Statement> ::= Return { value: <Expression> | 137 // <Statement> ::= Return { value: <Expression> |
| 147 // inlined_finally_list: <InlinedFinally>* } | 138 // inlined_finally_list: <InlinedFinally>* } |
| 148 void EffectGraphVisitor::VisitReturnNode(ReturnNode* node) { | 139 void EffectGraphVisitor::VisitReturnNode(ReturnNode* node) { |
| 149 ValueGraphVisitor for_value(owner(), temp_index()); | 140 ValueGraphVisitor for_value(owner(), temp_index()); |
| 150 node->value()->Visit(&for_value); | 141 node->value()->Visit(&for_value); |
| 151 Append(for_value); | 142 Append(for_value); |
| 152 CHECK_ALIVE(return); | |
| 153 | 143 |
| 154 for (intptr_t i = 0; i < node->inlined_finally_list_length(); i++) { | 144 for (intptr_t i = 0; i < node->inlined_finally_list_length(); i++) { |
| 155 EffectGraphVisitor for_effect(owner(), for_value.temp_index()); | 145 EffectGraphVisitor for_effect(owner(), for_value.temp_index()); |
| 156 node->InlinedFinallyNodeAt(i)->Visit(&for_effect); | 146 node->InlinedFinallyNodeAt(i)->Visit(&for_effect); |
| 157 Append(for_effect); | 147 Append(for_effect); |
|
Kevin Millikin (Google)
2012/03/01 09:13:53
I think we also need
if (!is_open()) return;
imm
srdjan
2012/03/01 16:54:58
Done.
| |
| 158 CHECK_ALIVE(return); | |
| 159 } | 148 } |
| 160 | 149 |
| 161 Value* return_value = for_value.value(); | 150 Value* return_value = for_value.value(); |
| 162 if (FLAG_enable_type_checks) { | 151 if (FLAG_enable_type_checks) { |
| 163 const RawFunction::Kind kind = owner()->parsed_function().function().kind(); | 152 const RawFunction::Kind kind = owner()->parsed_function().function().kind(); |
| 164 // Implicit getters do not need a type check at return. | 153 // Implicit getters do not need a type check at return. |
| 165 if ((kind != RawFunction::kImplicitGetter) && | 154 if ((kind != RawFunction::kImplicitGetter) && |
| 166 (kind != RawFunction::kConstImplicitGetter)) { | 155 (kind != RawFunction::kConstImplicitGetter)) { |
| 167 const AbstractType& type = | 156 const AbstractType& type = |
| 168 AbstractType::ZoneHandle( | 157 AbstractType::ZoneHandle( |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 204 | 193 |
| 205 | 194 |
| 206 // <Expression> :: Assignable { expr: <Expression> | 195 // <Expression> :: Assignable { expr: <Expression> |
| 207 // type: AbstractType | 196 // type: AbstractType |
| 208 // dst_name: String } | 197 // dst_name: String } |
| 209 AssertAssignableComp* EffectGraphVisitor::TranslateAssignable( | 198 AssertAssignableComp* EffectGraphVisitor::TranslateAssignable( |
| 210 const AssignableNode& node) { | 199 const AssignableNode& node) { |
| 211 ValueGraphVisitor for_value(owner(), temp_index()); | 200 ValueGraphVisitor for_value(owner(), temp_index()); |
| 212 node.expr()->Visit(&for_value); | 201 node.expr()->Visit(&for_value); |
| 213 Append(for_value); | 202 Append(for_value); |
| 214 CHECK_ALIVE(return NULL); | |
| 215 | 203 |
| 216 return new AssertAssignableComp(for_value.value(), node.type()); | 204 return new AssertAssignableComp(for_value.value(), node.type()); |
| 217 } | 205 } |
| 218 | 206 |
| 219 void EffectGraphVisitor::VisitAssignableNode(AssignableNode* node) { | 207 void EffectGraphVisitor::VisitAssignableNode(AssignableNode* node) { |
| 220 AssertAssignableComp* assert = TranslateAssignable(*node); | 208 AssertAssignableComp* assert = TranslateAssignable(*node); |
| 221 CHECK_ALIVE(return); | |
| 222 DoComputation(assert); | 209 DoComputation(assert); |
| 223 } | 210 } |
| 224 | 211 |
| 225 void ValueGraphVisitor::VisitAssignableNode(AssignableNode* node) { | 212 void ValueGraphVisitor::VisitAssignableNode(AssignableNode* node) { |
| 226 AssertAssignableComp* assert = TranslateAssignable(*node); | 213 AssertAssignableComp* assert = TranslateAssignable(*node); |
| 227 CHECK_ALIVE(return); | |
| 228 ReturnValueOf(assert); | 214 ReturnValueOf(assert); |
| 229 } | 215 } |
| 230 | 216 |
| 231 | 217 |
| 232 void TestGraphVisitor::VisitAssignableNode(AssignableNode* node) { | 218 void TestGraphVisitor::VisitAssignableNode(AssignableNode* node) { |
| 233 AssertAssignableComp* assert = TranslateAssignable(*node); | 219 AssertAssignableComp* assert = TranslateAssignable(*node); |
| 234 CHECK_ALIVE(return); | |
| 235 BranchOnValueOf(assert); | 220 BranchOnValueOf(assert); |
| 236 } | 221 } |
| 237 | 222 |
| 238 | 223 |
| 239 // <Expression> :: BinaryOp { kind: Token::Kind | 224 // <Expression> :: BinaryOp { kind: Token::Kind |
| 240 // left: <Expression> | 225 // left: <Expression> |
| 241 // right: <Expression> } | 226 // right: <Expression> } |
| 242 InstanceCallComp* EffectGraphVisitor::TranslateBinaryOp( | 227 InstanceCallComp* EffectGraphVisitor::TranslateBinaryOp( |
| 243 const BinaryOpNode& node) { | 228 const BinaryOpNode& node) { |
| 244 // Operators "&&" and "||" cannot be overloaded therefore do not call | 229 // Operators "&&" and "||" cannot be overloaded therefore do not call |
| 245 // operator. | 230 // operator. |
| 246 if ((node.kind() == Token::kAND) || (node.kind() == Token::kOR)) { | 231 if ((node.kind() == Token::kAND) || (node.kind() == Token::kOR)) { |
| 247 Bailout("EffectGraphVisitor::VisitBinaryOpNode AND/OR"); | 232 Bailout("EffectGraphVisitor::VisitBinaryOpNode AND/OR"); |
| 248 } | 233 } |
| 249 ValueGraphVisitor for_left_value(owner(), temp_index()); | 234 ValueGraphVisitor for_left_value(owner(), temp_index()); |
| 250 node.left()->Visit(&for_left_value); | 235 node.left()->Visit(&for_left_value); |
| 251 Append(for_left_value); | 236 Append(for_left_value); |
| 252 CHECK_ALIVE(return NULL); | |
| 253 ValueGraphVisitor for_right_value(owner(), for_left_value.temp_index()); | 237 ValueGraphVisitor for_right_value(owner(), for_left_value.temp_index()); |
| 254 node.right()->Visit(&for_right_value); | 238 node.right()->Visit(&for_right_value); |
| 255 Append(for_right_value); | 239 Append(for_right_value); |
| 256 CHECK_ALIVE(return NULL); | |
| 257 ZoneGrowableArray<Value*>* arguments = new ZoneGrowableArray<Value*>(2); | 240 ZoneGrowableArray<Value*>* arguments = new ZoneGrowableArray<Value*>(2); |
| 258 arguments->Add(for_left_value.value()); | 241 arguments->Add(for_left_value.value()); |
| 259 arguments->Add(for_right_value.value()); | 242 arguments->Add(for_right_value.value()); |
| 260 return new InstanceCallComp(node.Name(), arguments); | 243 return new InstanceCallComp(node.Name(), arguments); |
| 261 } | 244 } |
| 262 | 245 |
| 263 void EffectGraphVisitor::VisitBinaryOpNode(BinaryOpNode* node) { | 246 void EffectGraphVisitor::VisitBinaryOpNode(BinaryOpNode* node) { |
| 264 InstanceCallComp* call = TranslateBinaryOp(*node); | 247 InstanceCallComp* call = TranslateBinaryOp(*node); |
| 265 CHECK_ALIVE(return); | |
| 266 DoComputation(call); | 248 DoComputation(call); |
| 267 } | 249 } |
| 268 | 250 |
| 269 void ValueGraphVisitor::VisitBinaryOpNode(BinaryOpNode* node) { | 251 void ValueGraphVisitor::VisitBinaryOpNode(BinaryOpNode* node) { |
| 270 InstanceCallComp* call = TranslateBinaryOp(*node); | 252 InstanceCallComp* call = TranslateBinaryOp(*node); |
| 271 CHECK_ALIVE(return); | |
| 272 ReturnValueOf(call); | 253 ReturnValueOf(call); |
| 273 } | 254 } |
| 274 | 255 |
| 275 void TestGraphVisitor::VisitBinaryOpNode(BinaryOpNode* node) { | 256 void TestGraphVisitor::VisitBinaryOpNode(BinaryOpNode* node) { |
| 276 InstanceCallComp* call = TranslateBinaryOp(*node); | 257 InstanceCallComp* call = TranslateBinaryOp(*node); |
| 277 CHECK_ALIVE(return); | |
| 278 BranchOnValueOf(call); | 258 BranchOnValueOf(call); |
| 279 } | 259 } |
| 280 | 260 |
| 281 | 261 |
| 282 void EffectGraphVisitor::VisitStringConcatNode(StringConcatNode* node) { | 262 void EffectGraphVisitor::VisitStringConcatNode(StringConcatNode* node) { |
| 283 Bailout("EffectGraphVisitor::VisitStringConcatNode"); | 263 Bailout("EffectGraphVisitor::VisitStringConcatNode"); |
| 284 } | 264 } |
| 285 void ValueGraphVisitor::VisitStringConcatNode(StringConcatNode* node) { | 265 void ValueGraphVisitor::VisitStringConcatNode(StringConcatNode* node) { |
| 286 Bailout("ValueGraphVisitor::VisitStringConcatNode"); | 266 Bailout("ValueGraphVisitor::VisitStringConcatNode"); |
| 287 } | 267 } |
| 288 void TestGraphVisitor::VisitStringConcatNode(StringConcatNode* node) { | 268 void TestGraphVisitor::VisitStringConcatNode(StringConcatNode* node) { |
| 289 Bailout("TestGraphVisitor::VisitStringConcatNode"); | 269 Bailout("TestGraphVisitor::VisitStringConcatNode"); |
| 290 } | 270 } |
| 291 | 271 |
| 292 | 272 |
| 293 // <Expression> :: Comparison { kind: Token::Kind | 273 // <Expression> :: Comparison { kind: Token::Kind |
| 294 // left: <Expression> | 274 // left: <Expression> |
| 295 // right: <Expression> } | 275 // right: <Expression> } |
| 296 Computation* EffectGraphVisitor::TranslateComparison( | 276 Computation* EffectGraphVisitor::TranslateComparison( |
| 297 const ComparisonNode& node) { | 277 const ComparisonNode& node) { |
| 298 if (Token::IsInstanceofOperator(node.kind())) { | 278 if (Token::IsInstanceofOperator(node.kind())) { |
| 299 Bailout("instanceof not yet implemented"); | 279 Bailout("instanceof not yet implemented"); |
| 300 } else if ((node.kind() == Token::kEQ) || (node.kind() == Token::kNE)) { | 280 } else if ((node.kind() == Token::kEQ) || (node.kind() == Token::kNE)) { |
| 301 Bailout("'==' or '!=' comparison not yet implemented"); | 281 Bailout("'==' or '!=' comparison not yet implemented"); |
| 302 } | 282 } |
| 303 ValueGraphVisitor for_left_value(owner(), temp_index()); | 283 ValueGraphVisitor for_left_value(owner(), temp_index()); |
| 304 node.left()->Visit(&for_left_value); | 284 node.left()->Visit(&for_left_value); |
| 305 Append(for_left_value); | 285 Append(for_left_value); |
| 306 CHECK_ALIVE(return NULL); | |
| 307 ValueGraphVisitor for_right_value(owner(), for_left_value.temp_index()); | 286 ValueGraphVisitor for_right_value(owner(), for_left_value.temp_index()); |
| 308 node.right()->Visit(&for_right_value); | 287 node.right()->Visit(&for_right_value); |
| 309 Append(for_right_value); | 288 Append(for_right_value); |
| 310 CHECK_ALIVE(return NULL); | |
| 311 if ((node.kind() == Token::kEQ_STRICT) || | 289 if ((node.kind() == Token::kEQ_STRICT) || |
| 312 (node.kind() == Token::kNE_STRICT)) { | 290 (node.kind() == Token::kNE_STRICT)) { |
| 313 return new StrictCompareComp( | 291 return new StrictCompareComp( |
| 314 node.kind(), for_left_value.value(), for_right_value.value()); | 292 node.kind(), for_left_value.value(), for_right_value.value()); |
| 315 } | 293 } |
| 316 ZoneGrowableArray<Value*>* arguments = new ZoneGrowableArray<Value*>(2); | 294 ZoneGrowableArray<Value*>* arguments = new ZoneGrowableArray<Value*>(2); |
| 317 arguments->Add(for_left_value.value()); | 295 arguments->Add(for_left_value.value()); |
| 318 arguments->Add(for_right_value.value()); | 296 arguments->Add(for_right_value.value()); |
| 319 return new InstanceCallComp(node.Name(), arguments); | 297 return new InstanceCallComp(node.Name(), arguments); |
| 320 } | 298 } |
| 321 | 299 |
| 322 void EffectGraphVisitor::VisitComparisonNode(ComparisonNode* node) { | 300 void EffectGraphVisitor::VisitComparisonNode(ComparisonNode* node) { |
| 323 Computation* call = TranslateComparison(*node); | 301 Computation* call = TranslateComparison(*node); |
| 324 CHECK_ALIVE(return); | |
| 325 DoComputation(call); | 302 DoComputation(call); |
| 326 } | 303 } |
| 327 | 304 |
| 328 void ValueGraphVisitor::VisitComparisonNode(ComparisonNode* node) { | 305 void ValueGraphVisitor::VisitComparisonNode(ComparisonNode* node) { |
| 329 Computation* call = TranslateComparison(*node); | 306 Computation* call = TranslateComparison(*node); |
| 330 CHECK_ALIVE(return); | |
| 331 ReturnValueOf(call); | 307 ReturnValueOf(call); |
| 332 } | 308 } |
| 333 | 309 |
| 334 void TestGraphVisitor::VisitComparisonNode(ComparisonNode* node) { | 310 void TestGraphVisitor::VisitComparisonNode(ComparisonNode* node) { |
| 335 Computation* call = TranslateComparison(*node); | 311 Computation* call = TranslateComparison(*node); |
| 336 CHECK_ALIVE(return); | |
| 337 BranchOnValueOf(call); | 312 BranchOnValueOf(call); |
| 338 } | 313 } |
| 339 | 314 |
| 340 | 315 |
| 341 | 316 |
| 342 InstanceCallComp* EffectGraphVisitor::TranslateUnaryOp( | 317 InstanceCallComp* EffectGraphVisitor::TranslateUnaryOp( |
| 343 const UnaryOpNode& node) { | 318 const UnaryOpNode& node) { |
| 344 // "!" cannot be overloaded, therefore do not call operator. | 319 // "!" cannot be overloaded, therefore do not call operator. |
| 345 if (node.kind() == Token::kNOT) { | 320 if (node.kind() == Token::kNOT) { |
| 346 Bailout("EffectGraphVisitor::VisitUnaryOpNode NOT"); | 321 Bailout("EffectGraphVisitor::VisitUnaryOpNode NOT"); |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 556 | 531 |
| 557 | 532 |
| 558 InstanceCallComp* EffectGraphVisitor::TranslateInstanceCall( | 533 InstanceCallComp* EffectGraphVisitor::TranslateInstanceCall( |
| 559 const InstanceCallNode& node) { | 534 const InstanceCallNode& node) { |
| 560 ArgumentListNode* arguments = node.arguments(); | 535 ArgumentListNode* arguments = node.arguments(); |
| 561 int length = arguments->length(); | 536 int length = arguments->length(); |
| 562 ZoneGrowableArray<Value*>* values = new ZoneGrowableArray<Value*>(length + 1); | 537 ZoneGrowableArray<Value*>* values = new ZoneGrowableArray<Value*>(length + 1); |
| 563 ValueGraphVisitor for_receiver(owner(), temp_index()); | 538 ValueGraphVisitor for_receiver(owner(), temp_index()); |
| 564 node.receiver()->Visit(&for_receiver); | 539 node.receiver()->Visit(&for_receiver); |
| 565 Append(for_receiver); | 540 Append(for_receiver); |
| 566 CHECK_ALIVE(return NULL); | |
| 567 values->Add(for_receiver.value()); | 541 values->Add(for_receiver.value()); |
| 568 int index = temp_index(); | 542 int index = temp_index(); |
| 569 for (intptr_t i = 0; i < length; ++i) { | 543 for (intptr_t i = 0; i < length; ++i) { |
| 570 ValueGraphVisitor for_value(owner(), index); | 544 ValueGraphVisitor for_value(owner(), index); |
| 571 arguments->NodeAt(i)->Visit(&for_value); | 545 arguments->NodeAt(i)->Visit(&for_value); |
| 572 Append(for_value); | 546 Append(for_value); |
| 573 CHECK_ALIVE(return NULL); | |
| 574 values->Add(for_value.value()); | 547 values->Add(for_value.value()); |
| 575 index = for_value.temp_index(); | 548 index = for_value.temp_index(); |
| 576 } | 549 } |
| 577 return new InstanceCallComp(node.function_name().ToCString(), values); | 550 return new InstanceCallComp(node.function_name().ToCString(), values); |
| 578 } | 551 } |
| 579 | 552 |
| 580 | 553 |
| 581 void EffectGraphVisitor::VisitInstanceCallNode(InstanceCallNode* node) { | 554 void EffectGraphVisitor::VisitInstanceCallNode(InstanceCallNode* node) { |
| 582 InstanceCallComp* call = TranslateInstanceCall(*node); | 555 InstanceCallComp* call = TranslateInstanceCall(*node); |
| 583 CHECK_ALIVE(return); | |
| 584 DoComputation(call); | 556 DoComputation(call); |
| 585 } | 557 } |
| 586 void ValueGraphVisitor::VisitInstanceCallNode(InstanceCallNode* node) { | 558 void ValueGraphVisitor::VisitInstanceCallNode(InstanceCallNode* node) { |
| 587 InstanceCallComp* call = TranslateInstanceCall(*node); | 559 InstanceCallComp* call = TranslateInstanceCall(*node); |
| 588 CHECK_ALIVE(return); | |
| 589 ReturnValueOf(call); | 560 ReturnValueOf(call); |
| 590 } | 561 } |
| 591 void TestGraphVisitor::VisitInstanceCallNode(InstanceCallNode* node) { | 562 void TestGraphVisitor::VisitInstanceCallNode(InstanceCallNode* node) { |
| 592 InstanceCallComp* call = TranslateInstanceCall(*node); | 563 InstanceCallComp* call = TranslateInstanceCall(*node); |
| 593 CHECK_ALIVE(return); | |
| 594 BranchOnValueOf(call); | 564 BranchOnValueOf(call); |
| 595 } | 565 } |
| 596 | 566 |
| 597 | 567 |
| 598 void EffectGraphVisitor::TranslateArgumentList( | 568 void EffectGraphVisitor::TranslateArgumentList( |
| 599 const ArgumentListNode& node, ZoneGrowableArray<Value*>* values) { | 569 const ArgumentListNode& node, ZoneGrowableArray<Value*>* values) { |
| 600 int index = temp_index(); | 570 int index = temp_index(); |
| 601 for (intptr_t i = 0; i < node.length(); ++i) { | 571 for (intptr_t i = 0; i < node.length(); ++i) { |
| 602 ValueGraphVisitor for_value(owner(), index); | 572 ValueGraphVisitor for_value(owner(), index); |
| 603 node.NodeAt(i)->Visit(&for_value); | 573 node.NodeAt(i)->Visit(&for_value); |
| 604 Append(for_value); | 574 Append(for_value); |
| 605 CHECK_ALIVE(return); | |
| 606 Value* argument_value = for_value.value(); | 575 Value* argument_value = for_value.value(); |
| 607 index = for_value.temp_index(); | 576 index = for_value.temp_index(); |
| 608 if (argument_value->IsConstant()) { | 577 if (argument_value->IsConstant()) { |
| 609 AddInstruction(new BindInstr(index, argument_value)); | 578 AddInstruction(new BindInstr(index, argument_value)); |
| 610 argument_value = new TempVal(index++); | 579 argument_value = new TempVal(index++); |
| 611 } | 580 } |
| 612 values->Add(argument_value); | 581 values->Add(argument_value); |
| 613 } | 582 } |
| 614 } | 583 } |
| 615 | 584 |
| 616 // <Expression> ::= StaticCall { function: Function | 585 // <Expression> ::= StaticCall { function: Function |
| 617 // arguments: <ArgumentList> } | 586 // arguments: <ArgumentList> } |
| 618 StaticCallComp* EffectGraphVisitor::TranslateStaticCall( | 587 StaticCallComp* EffectGraphVisitor::TranslateStaticCall( |
| 619 const StaticCallNode& node) { | 588 const StaticCallNode& node) { |
| 620 int length = node.arguments()->length(); | 589 int length = node.arguments()->length(); |
| 621 ZoneGrowableArray<Value*>* values = new ZoneGrowableArray<Value*>(length); | 590 ZoneGrowableArray<Value*>* values = new ZoneGrowableArray<Value*>(length); |
| 622 TranslateArgumentList(*node.arguments(), values); | 591 TranslateArgumentList(*node.arguments(), values); |
| 623 CHECK_ALIVE(return NULL); | |
| 624 return new StaticCallComp(node.function(), values); | 592 return new StaticCallComp(node.function(), values); |
| 625 } | 593 } |
| 626 | 594 |
| 627 void EffectGraphVisitor::VisitStaticCallNode(StaticCallNode* node) { | 595 void EffectGraphVisitor::VisitStaticCallNode(StaticCallNode* node) { |
| 628 StaticCallComp* call = TranslateStaticCall(*node); | 596 StaticCallComp* call = TranslateStaticCall(*node); |
| 629 CHECK_ALIVE(return); | |
| 630 DoComputation(call); | 597 DoComputation(call); |
| 631 } | 598 } |
| 632 | 599 |
| 633 void ValueGraphVisitor::VisitStaticCallNode(StaticCallNode* node) { | 600 void ValueGraphVisitor::VisitStaticCallNode(StaticCallNode* node) { |
| 634 StaticCallComp* call = TranslateStaticCall(*node); | 601 StaticCallComp* call = TranslateStaticCall(*node); |
| 635 CHECK_ALIVE(return); | |
| 636 ReturnValueOf(call); | 602 ReturnValueOf(call); |
| 637 } | 603 } |
| 638 | 604 |
| 639 void TestGraphVisitor::VisitStaticCallNode(StaticCallNode* node) { | 605 void TestGraphVisitor::VisitStaticCallNode(StaticCallNode* node) { |
| 640 StaticCallComp* call = TranslateStaticCall(*node); | 606 StaticCallComp* call = TranslateStaticCall(*node); |
| 641 CHECK_ALIVE(return); | |
| 642 BranchOnValueOf(call); | 607 BranchOnValueOf(call); |
| 643 } | 608 } |
| 644 | 609 |
| 645 | 610 |
| 646 void EffectGraphVisitor::VisitClosureCallNode(ClosureCallNode* node) { | 611 void EffectGraphVisitor::VisitClosureCallNode(ClosureCallNode* node) { |
| 647 Bailout("EffectGraphVisitor::VisitClosureCallNode"); | 612 Bailout("EffectGraphVisitor::VisitClosureCallNode"); |
| 648 } | 613 } |
| 649 void ValueGraphVisitor::VisitClosureCallNode(ClosureCallNode* node) { | 614 void ValueGraphVisitor::VisitClosureCallNode(ClosureCallNode* node) { |
| 650 Bailout("ValueGraphVisitor::VisitClosureCallNode"); | 615 Bailout("ValueGraphVisitor::VisitClosureCallNode"); |
| 651 } | 616 } |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 758 } | 723 } |
| 759 | 724 |
| 760 | 725 |
| 761 // <Expression> ::= StoreLocal { local: LocalVariable | 726 // <Expression> ::= StoreLocal { local: LocalVariable |
| 762 // value: <Expression> } | 727 // value: <Expression> } |
| 763 StoreLocalComp* EffectGraphVisitor::TranslateStoreLocal( | 728 StoreLocalComp* EffectGraphVisitor::TranslateStoreLocal( |
| 764 const StoreLocalNode& node) { | 729 const StoreLocalNode& node) { |
| 765 ValueGraphVisitor for_value(owner(), temp_index()); | 730 ValueGraphVisitor for_value(owner(), temp_index()); |
| 766 node.value()->Visit(&for_value); | 731 node.value()->Visit(&for_value); |
| 767 Append(for_value); | 732 Append(for_value); |
| 768 CHECK_ALIVE(return NULL); | |
| 769 return new StoreLocalComp(node.local(), for_value.value()); | 733 return new StoreLocalComp(node.local(), for_value.value()); |
| 770 } | 734 } |
| 771 | 735 |
| 772 void EffectGraphVisitor::VisitStoreLocalNode(StoreLocalNode* node) { | 736 void EffectGraphVisitor::VisitStoreLocalNode(StoreLocalNode* node) { |
| 773 StoreLocalComp* store = TranslateStoreLocal(*node); | 737 StoreLocalComp* store = TranslateStoreLocal(*node); |
| 774 CHECK_ALIVE(return); | |
| 775 DoComputation(store); | 738 DoComputation(store); |
| 776 } | 739 } |
| 777 | 740 |
| 778 void ValueGraphVisitor::VisitStoreLocalNode(StoreLocalNode* node) { | 741 void ValueGraphVisitor::VisitStoreLocalNode(StoreLocalNode* node) { |
| 779 StoreLocalComp* store = TranslateStoreLocal(*node); | 742 StoreLocalComp* store = TranslateStoreLocal(*node); |
| 780 CHECK_ALIVE(return); | |
| 781 ReturnValueOf(store); | 743 ReturnValueOf(store); |
| 782 } | 744 } |
| 783 | 745 |
| 784 void TestGraphVisitor::VisitStoreLocalNode(StoreLocalNode* node) { | 746 void TestGraphVisitor::VisitStoreLocalNode(StoreLocalNode* node) { |
| 785 StoreLocalComp* store = TranslateStoreLocal(*node); | 747 StoreLocalComp* store = TranslateStoreLocal(*node); |
| 786 CHECK_ALIVE(return); | |
| 787 BranchOnValueOf(store); | 748 BranchOnValueOf(store); |
| 788 } | 749 } |
| 789 | 750 |
| 790 | 751 |
| 791 void EffectGraphVisitor::VisitLoadInstanceFieldNode( | 752 void EffectGraphVisitor::VisitLoadInstanceFieldNode( |
| 792 LoadInstanceFieldNode* node) { | 753 LoadInstanceFieldNode* node) { |
| 793 Bailout("EffectGraphVisitor::VisitLoadInstanceFieldNode"); | 754 Bailout("EffectGraphVisitor::VisitLoadInstanceFieldNode"); |
| 794 } | 755 } |
| 795 void ValueGraphVisitor::VisitLoadInstanceFieldNode( | 756 void ValueGraphVisitor::VisitLoadInstanceFieldNode( |
| 796 LoadInstanceFieldNode* node) { | 757 LoadInstanceFieldNode* node) { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 860 | 821 |
| 861 | 822 |
| 862 // <Statement> ::= Sequence { scope: LocalScope | 823 // <Statement> ::= Sequence { scope: LocalScope |
| 863 // nodes: <Statement>* | 824 // nodes: <Statement>* |
| 864 // label: SourceLabel } | 825 // label: SourceLabel } |
| 865 void EffectGraphVisitor::VisitSequenceNode(SequenceNode* node) { | 826 void EffectGraphVisitor::VisitSequenceNode(SequenceNode* node) { |
| 866 if ((node->scope() != NULL) && | 827 if ((node->scope() != NULL) && |
| 867 (node->scope()->num_context_variables() != 0)) { | 828 (node->scope()->num_context_variables() != 0)) { |
| 868 Bailout("Sequence needs a context. Gotta have a context."); | 829 Bailout("Sequence needs a context. Gotta have a context."); |
| 869 } | 830 } |
| 870 for (intptr_t i = 0; i < node->length(); ++i) { | 831 intptr_t i = 0; |
| 832 while (is_open() && (i < node->length())) { | |
| 871 EffectGraphVisitor for_effect(owner(), temp_index()); | 833 EffectGraphVisitor for_effect(owner(), temp_index()); |
| 872 node->NodeAt(i)->Visit(&for_effect); | 834 node->NodeAt(i++)->Visit(&for_effect); |
| 873 Append(for_effect); | 835 Append(for_effect); |
| 874 CHECK_ALIVE(return); | |
| 875 } | 836 } |
| 876 } | 837 } |
| 877 | 838 |
| 878 void ValueGraphVisitor::VisitSequenceNode(SequenceNode* node) { UNREACHABLE(); } | 839 void ValueGraphVisitor::VisitSequenceNode(SequenceNode* node) { UNREACHABLE(); } |
| 879 void TestGraphVisitor::VisitSequenceNode(SequenceNode* node) { UNREACHABLE(); } | 840 void TestGraphVisitor::VisitSequenceNode(SequenceNode* node) { UNREACHABLE(); } |
| 880 | 841 |
| 881 | 842 |
| 882 void EffectGraphVisitor::VisitCatchClauseNode(CatchClauseNode* node) { | 843 void EffectGraphVisitor::VisitCatchClauseNode(CatchClauseNode* node) { |
| 883 Bailout("EffectGraphVisitor::VisitCatchClauseNode"); | 844 Bailout("EffectGraphVisitor::VisitCatchClauseNode"); |
| 884 } | 845 } |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1070 OS::Print(" if "); | 1031 OS::Print(" if "); |
| 1071 instr->value()->Accept(this); | 1032 instr->value()->Accept(this); |
| 1072 OS::Print(" goto(%d, %d)", instr->true_successor()->block_number(), | 1033 OS::Print(" goto(%d, %d)", instr->true_successor()->block_number(), |
| 1073 instr->false_successor()->block_number()); | 1034 instr->false_successor()->block_number()); |
| 1074 } | 1035 } |
| 1075 | 1036 |
| 1076 | 1037 |
| 1077 void FlowGraphBuilder::BuildGraph() { | 1038 void FlowGraphBuilder::BuildGraph() { |
| 1078 EffectGraphVisitor for_effect(this, 0); | 1039 EffectGraphVisitor for_effect(this, 0); |
| 1079 for_effect.AddInstruction(new TargetEntryInstr()); | 1040 for_effect.AddInstruction(new TargetEntryInstr()); |
| 1080 parsed_function().node_sequence()->Visit(&for_effect); | 1041 parsed_function().node_sequence()->Visit(&for_effect); |
|
Kevin Millikin (Google)
2012/03/01 09:13:53
And after this call, I think we should be able to
srdjan
2012/03/01 16:54:58
Done.
| |
| 1081 if (for_effect.entry() != NULL) { | 1042 if (for_effect.entry() != NULL) { |
| 1082 // Accumulate basic block entries via postorder traversal. | 1043 // Accumulate basic block entries via postorder traversal. |
| 1083 for_effect.entry()->Postorder(&postorder_block_entries_); | 1044 for_effect.entry()->Postorder(&postorder_block_entries_); |
| 1084 // Number the blocks in reverse postorder starting with 0. | 1045 // Number the blocks in reverse postorder starting with 0. |
| 1085 intptr_t last_index = postorder_block_entries_.length() - 1; | 1046 intptr_t last_index = postorder_block_entries_.length() - 1; |
| 1086 for (intptr_t i = last_index; i >= 0; --i) { | 1047 for (intptr_t i = last_index; i >= 0; --i) { |
| 1087 postorder_block_entries_[i]->set_block_number(last_index - i); | 1048 postorder_block_entries_[i]->set_block_number(last_index - i); |
| 1088 } | 1049 } |
| 1089 } | 1050 } |
| 1090 if (FLAG_print_flow_graph) { | 1051 if (FLAG_print_flow_graph) { |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 1101 char* chars = reinterpret_cast<char*>( | 1062 char* chars = reinterpret_cast<char*>( |
| 1102 Isolate::Current()->current_zone()->Allocate(len)); | 1063 Isolate::Current()->current_zone()->Allocate(len)); |
| 1103 OS::SNPrint(chars, len, kFormat, function_name, reason); | 1064 OS::SNPrint(chars, len, kFormat, function_name, reason); |
| 1104 const Error& error = Error::Handle( | 1065 const Error& error = Error::Handle( |
| 1105 LanguageError::New(String::Handle(String::New(chars)))); | 1066 LanguageError::New(String::Handle(String::New(chars)))); |
| 1106 Isolate::Current()->long_jump_base()->Jump(1, error); | 1067 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 1107 } | 1068 } |
| 1108 | 1069 |
| 1109 | 1070 |
| 1110 } // namespace dart | 1071 } // namespace dart |
| OLD | NEW |