Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Side by Side Diff: runtime/vm/flow_graph_builder.cc

Issue 10264031: Switch from AST node ids to computation ids (cid). In addition to computations,… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/flow_graph_builder.h ('k') | runtime/vm/flow_graph_compiler_x64.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/ast_printer.h" 7 #include "vm/ast_printer.h"
8 #include "vm/code_descriptors.h" 8 #include "vm/code_descriptors.h"
9 #include "vm/dart_entry.h" 9 #include "vm/dart_entry.h"
10 #include "vm/flags.h" 10 #include "vm/flags.h"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 new DoInstr(new StoreContextComp(new UseVal(load_saved_context))); 155 new DoInstr(new StoreContextComp(new UseVal(load_saved_context)));
156 AddInstruction(store_context); 156 AddInstruction(store_context);
157 } 157 }
158 158
159 159
160 160
161 void TestGraphVisitor::ReturnValue(Value* value) { 161 void TestGraphVisitor::ReturnValue(Value* value) {
162 if (FLAG_enable_type_checks) { 162 if (FLAG_enable_type_checks) {
163 BindInstr* assert_boolean = 163 BindInstr* assert_boolean =
164 new BindInstr(temp_index(), 164 new BindInstr(temp_index(),
165 new AssertBooleanComp(condition_node_id(), 165 new AssertBooleanComp(condition_token_index(),
166 condition_token_index(),
167 owner()->try_index(), 166 owner()->try_index(),
168 value)); 167 value));
169 AddInstruction(assert_boolean); 168 AddInstruction(assert_boolean);
170 value = new UseVal(assert_boolean); 169 value = new UseVal(assert_boolean);
171 } 170 }
172 BranchInstr* branch = new BranchInstr(value); 171 BranchInstr* branch = new BranchInstr(value);
173 AddInstruction(branch); 172 AddInstruction(branch);
174 CloseFragment(); 173 CloseFragment();
175 true_successor_address_ = branch->true_successor_address(); 174 true_successor_address_ = branch->true_successor_address();
176 false_successor_address_ = branch->false_successor_address(); 175 false_successor_address_ = branch->false_successor_address();
(...skipping 27 matching lines...) Expand all
204 (kind == RawFunction::kConstImplicitGetter); 203 (kind == RawFunction::kConstImplicitGetter);
205 const bool is_static = owner()->parsed_function().function().is_static(); 204 const bool is_static = owner()->parsed_function().function().is_static();
206 // Implicit getters do not need a type check at return, unless they compute 205 // Implicit getters do not need a type check at return, unless they compute
207 // the initial value of a static field. 206 // the initial value of a static field.
208 if (is_static || !is_implicit_getter) { 207 if (is_static || !is_implicit_getter) {
209 const AbstractType& dst_type = 208 const AbstractType& dst_type =
210 AbstractType::ZoneHandle( 209 AbstractType::ZoneHandle(
211 owner()->parsed_function().function().result_type()); 210 owner()->parsed_function().function().result_type());
212 const String& dst_name = 211 const String& dst_name =
213 String::ZoneHandle(String::NewSymbol("function result")); 212 String::ZoneHandle(String::NewSymbol("function result"));
214 return_value = BuildAssignableValue(node->id(), 213 return_value = BuildAssignableValue(node->value(),
215 node->value(),
216 return_value, 214 return_value,
217 dst_type, 215 dst_type,
218 dst_name, 216 dst_name,
219 temp_index()); 217 temp_index());
220 } 218 }
221 } 219 }
222 220
223 intptr_t current_context_level = owner()->context_level(); 221 intptr_t current_context_level = owner()->context_level();
224 ASSERT(current_context_level >= 0); 222 ASSERT(current_context_level >= 0);
225 if (owner()->parsed_function().saved_context_var() != NULL) { 223 if (owner()->parsed_function().saved_context_var() != NULL) {
226 // CTX on entry was saved, but not linked as context parent. 224 // CTX on entry was saved, but not linked as context parent.
227 BuildLoadContext(*owner()->parsed_function().saved_context_var()); 225 BuildLoadContext(*owner()->parsed_function().saved_context_var());
228 } else { 226 } else {
229 while (current_context_level-- > 0) { 227 while (current_context_level-- > 0) {
230 UnchainContext(); 228 UnchainContext();
231 } 229 }
232 } 230 }
233 231
234 AddInstruction( 232 AddInstruction(
235 new ReturnInstr(node->id(), node->token_index(), return_value)); 233 new ReturnInstr(node->token_index(), return_value));
236 CloseFragment(); 234 CloseFragment();
237 } 235 }
238 236
239 237
240 // <Expression> ::= Literal { literal: Instance } 238 // <Expression> ::= Literal { literal: Instance }
241 void EffectGraphVisitor::VisitLiteralNode(LiteralNode* node) { 239 void EffectGraphVisitor::VisitLiteralNode(LiteralNode* node) {
242 return; 240 return;
243 } 241 }
244 242
245 void ValueGraphVisitor::VisitLiteralNode(LiteralNode* node) { 243 void ValueGraphVisitor::VisitLiteralNode(LiteralNode* node) {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 // dst_name: String } 308 // dst_name: String }
311 void EffectGraphVisitor::VisitAssignableNode(AssignableNode* node) { 309 void EffectGraphVisitor::VisitAssignableNode(AssignableNode* node) {
312 UNREACHABLE(); 310 UNREACHABLE();
313 } 311 }
314 312
315 313
316 void ValueGraphVisitor::VisitAssignableNode(AssignableNode* node) { 314 void ValueGraphVisitor::VisitAssignableNode(AssignableNode* node) {
317 ValueGraphVisitor for_value(owner(), temp_index()); 315 ValueGraphVisitor for_value(owner(), temp_index());
318 node->expr()->Visit(&for_value); 316 node->expr()->Visit(&for_value);
319 Append(for_value); 317 Append(for_value);
320 ReturnValue(BuildAssignableValue(node->id(), 318 ReturnValue(BuildAssignableValue(node->expr(),
321 node->expr(),
322 for_value.value(), 319 for_value.value(),
323 node->type(), 320 node->type(),
324 node->dst_name(), 321 node->dst_name(),
325 temp_index())); 322 temp_index()));
326 } 323 }
327 324
328 325
329 // <Expression> :: BinaryOp { kind: Token::Kind 326 // <Expression> :: BinaryOp { kind: Token::Kind
330 // left: <Expression> 327 // left: <Expression>
331 // right: <Expression> } 328 // right: <Expression> }
332 void EffectGraphVisitor::VisitBinaryOpNode(BinaryOpNode* node) { 329 void EffectGraphVisitor::VisitBinaryOpNode(BinaryOpNode* node) {
333 // Operators "&&" and "||" cannot be overloaded therefore do not call 330 // Operators "&&" and "||" cannot be overloaded therefore do not call
334 // operator. 331 // operator.
335 if ((node->kind() == Token::kAND) || (node->kind() == Token::kOR)) { 332 if ((node->kind() == Token::kAND) || (node->kind() == Token::kOR)) {
336 // See ValueGraphVisitor::VisitBinaryOpNode. 333 // See ValueGraphVisitor::VisitBinaryOpNode.
337 TestGraphVisitor for_left(owner(), 334 TestGraphVisitor for_left(owner(),
338 temp_index(), 335 temp_index(),
339 node->left()->id(),
340 node->left()->token_index()); 336 node->left()->token_index());
341 node->left()->Visit(&for_left); 337 node->left()->Visit(&for_left);
342 EffectGraphVisitor for_right(owner(), temp_index()); 338 EffectGraphVisitor for_right(owner(), temp_index());
343 node->right()->Visit(&for_right); 339 node->right()->Visit(&for_right);
344 EffectGraphVisitor empty(owner(), temp_index()); 340 EffectGraphVisitor empty(owner(), temp_index());
345 if (node->kind() == Token::kAND) { 341 if (node->kind() == Token::kAND) {
346 Join(for_left, for_right, empty); 342 Join(for_left, for_right, empty);
347 } else { 343 } else {
348 Join(for_left, empty, for_right); 344 Join(for_left, empty, for_right);
349 } 345 }
350 return; 346 return;
351 } 347 }
352 ValueGraphVisitor for_left_value(owner(), temp_index()); 348 ValueGraphVisitor for_left_value(owner(), temp_index());
353 node->left()->Visit(&for_left_value); 349 node->left()->Visit(&for_left_value);
354 Append(for_left_value); 350 Append(for_left_value);
355 ValueGraphVisitor for_right_value(owner(), for_left_value.temp_index()); 351 ValueGraphVisitor for_right_value(owner(), for_left_value.temp_index());
356 node->right()->Visit(&for_right_value); 352 node->right()->Visit(&for_right_value);
357 Append(for_right_value); 353 Append(for_right_value);
358 ZoneGrowableArray<Value*>* arguments = new ZoneGrowableArray<Value*>(2); 354 ZoneGrowableArray<Value*>* arguments = new ZoneGrowableArray<Value*>(2);
359 arguments->Add(for_left_value.value()); 355 arguments->Add(for_left_value.value());
360 arguments->Add(for_right_value.value()); 356 arguments->Add(for_right_value.value());
361 const String& name = String::ZoneHandle(String::NewSymbol(node->Name())); 357 const String& name = String::ZoneHandle(String::NewSymbol(node->Name()));
362 InstanceCallComp* call = new InstanceCallComp(node->id(), 358 InstanceCallComp* call = new InstanceCallComp(node->token_index(),
363 node->token_index(),
364 owner()->try_index(), 359 owner()->try_index(),
365 name, 360 name,
366 arguments, 361 arguments,
367 Array::ZoneHandle(), 362 Array::ZoneHandle(),
368 2); 363 2);
369 ReturnComputation(call); 364 ReturnComputation(call);
370 } 365 }
371 366
372 367
373 // Special handling for AND/OR. 368 // Special handling for AND/OR.
374 void ValueGraphVisitor::VisitBinaryOpNode(BinaryOpNode* node) { 369 void ValueGraphVisitor::VisitBinaryOpNode(BinaryOpNode* node) {
375 // Operators "&&" and "||" cannot be overloaded therefore do not call 370 // Operators "&&" and "||" cannot be overloaded therefore do not call
376 // operator. 371 // operator.
377 if ((node->kind() == Token::kAND) || (node->kind() == Token::kOR)) { 372 if ((node->kind() == Token::kAND) || (node->kind() == Token::kOR)) {
378 // Implement short-circuit logic: do not evaluate right if evaluation 373 // Implement short-circuit logic: do not evaluate right if evaluation
379 // of left is sufficient. 374 // of left is sufficient.
380 // AND: left ? right === true : false; 375 // AND: left ? right === true : false;
381 // OR: left ? true : right === true; 376 // OR: left ? true : right === true;
382 const Bool& bool_true = Bool::ZoneHandle(Bool::True()); 377 const Bool& bool_true = Bool::ZoneHandle(Bool::True());
383 const Bool& bool_false = Bool::ZoneHandle(Bool::False()); 378 const Bool& bool_false = Bool::ZoneHandle(Bool::False());
384 379
385 TestGraphVisitor for_test(owner(), 380 TestGraphVisitor for_test(owner(),
386 temp_index(), 381 temp_index(),
387 node->left()->id(),
388 node->left()->token_index()); 382 node->left()->token_index());
389 node->left()->Visit(&for_test); 383 node->left()->Visit(&for_test);
390 384
391 ValueGraphVisitor for_right(owner(), temp_index()); 385 ValueGraphVisitor for_right(owner(), temp_index());
392 node->right()->Visit(&for_right); 386 node->right()->Visit(&for_right);
393 Value* right_value = for_right.value(); 387 Value* right_value = for_right.value();
394 if (FLAG_enable_type_checks) { 388 if (FLAG_enable_type_checks) {
395 BindInstr* assert_boolean = 389 BindInstr* assert_boolean =
396 new BindInstr(temp_index(), 390 new BindInstr(temp_index(),
397 new AssertBooleanComp(node->right()->id(), 391 new AssertBooleanComp(node->right()->token_index(),
398 node->right()->token_index(),
399 owner()->try_index(), 392 owner()->try_index(),
400 right_value)); 393 right_value));
401 for_right.AddInstruction(assert_boolean); 394 for_right.AddInstruction(assert_boolean);
402 right_value = new UseVal(assert_boolean); 395 right_value = new UseVal(assert_boolean);
403 } 396 }
404 BindInstr* constant_true = 397 BindInstr* constant_true =
405 new BindInstr(temp_index(), new ConstantVal(bool_true)); 398 new BindInstr(temp_index(), new ConstantVal(bool_true));
406 for_right.AddInstruction(constant_true); 399 for_right.AddInstruction(constant_true);
407 StrictCompareComp* comp = new StrictCompareComp(Token::kEQ_STRICT, 400 StrictCompareComp* comp = new StrictCompareComp(Token::kEQ_STRICT,
408 right_value, new UseVal(constant_true)); 401 right_value, new UseVal(constant_true));
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 StaticCallComp* call = 488 StaticCallComp* call =
496 new StaticCallComp(node->token_index(), 489 new StaticCallComp(node->token_index(),
497 owner()->try_index(), 490 owner()->try_index(),
498 interpol_func, 491 interpol_func,
499 interpol_arg->names(), 492 interpol_arg->names(),
500 values); 493 values);
501 ReturnComputation(call); 494 ReturnComputation(call);
502 } 495 }
503 496
504 497
505 void EffectGraphVisitor::BuildAssertAssignable(intptr_t node_id, 498 void EffectGraphVisitor::BuildAssertAssignable(intptr_t token_index,
506 intptr_t token_index,
507 Value* value, 499 Value* value,
508 const AbstractType& dst_type, 500 const AbstractType& dst_type,
509 const String& dst_name, 501 const String& dst_name,
510 intptr_t start_index) { 502 intptr_t start_index) {
511 // Build the type check computation. 503 // Build the type check computation.
512 Value* instantiator_type_arguments = NULL; 504 Value* instantiator_type_arguments = NULL;
513 if (!dst_type.IsInstantiated()) { 505 if (!dst_type.IsInstantiated()) {
514 instantiator_type_arguments = 506 instantiator_type_arguments =
515 BuildInstantiatorTypeArguments(token_index, start_index + 1); 507 BuildInstantiatorTypeArguments(token_index, start_index + 1);
516 } 508 }
517 AssertAssignableComp* assert_assignable = 509 AssertAssignableComp* assert_assignable =
518 new AssertAssignableComp(node_id, 510 new AssertAssignableComp(token_index,
519 token_index,
520 owner()->try_index(), 511 owner()->try_index(),
521 value, 512 value,
522 instantiator_type_arguments, 513 instantiator_type_arguments,
523 dst_type, 514 dst_type,
524 dst_name); 515 dst_name);
525 AddInstruction(new DoInstr(assert_assignable)); 516 AddInstruction(new DoInstr(assert_assignable));
526 } 517 }
527 518
528 519
529 Value* EffectGraphVisitor::BuildAssignableValue(intptr_t node_id, 520 Value* EffectGraphVisitor::BuildAssignableValue(AstNode* value_node,
530 AstNode* value_node,
531 Value* value, 521 Value* value,
532 const AbstractType& dst_type, 522 const AbstractType& dst_type,
533 const String& dst_name, 523 const String& dst_name,
534 intptr_t start_index) { 524 intptr_t start_index) {
535 if (CanSkipTypeCheck(value_node, dst_type)) { 525 if (CanSkipTypeCheck(value_node, dst_type)) {
536 return value; 526 return value;
537 } 527 }
538 528
539 // Build the type check computation. 529 // Build the type check computation.
540 Value* instantiator_type_arguments = NULL; 530 Value* instantiator_type_arguments = NULL;
541 if (!dst_type.IsInstantiated()) { 531 if (!dst_type.IsInstantiated()) {
542 instantiator_type_arguments = 532 instantiator_type_arguments =
543 BuildInstantiatorTypeArguments(value_node->token_index(), 533 BuildInstantiatorTypeArguments(value_node->token_index(),
544 start_index + 1); 534 start_index + 1);
545 } 535 }
546 BindInstr* assert_assignable = 536 BindInstr* assert_assignable =
547 new BindInstr(start_index, 537 new BindInstr(start_index,
548 new AssertAssignableComp(node_id, 538 new AssertAssignableComp(value_node->token_index(),
549 value_node->token_index(),
550 owner()->try_index(), 539 owner()->try_index(),
551 value, 540 value,
552 instantiator_type_arguments, 541 instantiator_type_arguments,
553 dst_type, 542 dst_type,
554 dst_name)); 543 dst_name));
555 AddInstruction(assert_assignable); 544 AddInstruction(assert_assignable);
556 return new UseVal(assert_assignable); 545 return new UseVal(assert_assignable);
557 } 546 }
558 547
559 548
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 ValueGraphVisitor for_left_value(owner(), temp_index()); 606 ValueGraphVisitor for_left_value(owner(), temp_index());
618 node->left()->Visit(&for_left_value); 607 node->left()->Visit(&for_left_value);
619 Append(for_left_value); 608 Append(for_left_value);
620 Value* type_arguments = NULL; 609 Value* type_arguments = NULL;
621 if (!type.IsInstantiated()) { 610 if (!type.IsInstantiated()) {
622 type_arguments = 611 type_arguments =
623 BuildInstantiatorTypeArguments(node->token_index(), 612 BuildInstantiatorTypeArguments(node->token_index(),
624 for_left_value.temp_index()); 613 for_left_value.temp_index());
625 } 614 }
626 InstanceOfComp* instance_of = 615 InstanceOfComp* instance_of =
627 new InstanceOfComp(node->id(), 616 new InstanceOfComp(node->token_index(),
628 node->token_index(),
629 owner()->try_index(), 617 owner()->try_index(),
630 for_left_value.value(), 618 for_left_value.value(),
631 type_arguments, 619 type_arguments,
632 node->right()->AsTypeNode()->type(), 620 node->right()->AsTypeNode()->type(),
633 (node->kind() == Token::kISNOT)); 621 (node->kind() == Token::kISNOT));
634 ReturnComputation(instance_of); 622 ReturnComputation(instance_of);
635 } 623 }
636 624
637 625
638 // <Expression> :: Comparison { kind: Token::Kind 626 // <Expression> :: Comparison { kind: Token::Kind
(...skipping 20 matching lines...) Expand all
659 } 647 }
660 648
661 if ((node->kind() == Token::kEQ) || (node->kind() == Token::kNE)) { 649 if ((node->kind() == Token::kEQ) || (node->kind() == Token::kNE)) {
662 ValueGraphVisitor for_left_value(owner(), temp_index()); 650 ValueGraphVisitor for_left_value(owner(), temp_index());
663 node->left()->Visit(&for_left_value); 651 node->left()->Visit(&for_left_value);
664 Append(for_left_value); 652 Append(for_left_value);
665 ValueGraphVisitor for_right_value(owner(), for_left_value.temp_index()); 653 ValueGraphVisitor for_right_value(owner(), for_left_value.temp_index());
666 node->right()->Visit(&for_right_value); 654 node->right()->Visit(&for_right_value);
667 Append(for_right_value); 655 Append(for_right_value);
668 EqualityCompareComp* comp = new EqualityCompareComp( 656 EqualityCompareComp* comp = new EqualityCompareComp(
669 node->id(), node->token_index(), owner()->try_index(), 657 node->token_index(), owner()->try_index(),
670 for_left_value.value(), for_right_value.value()); 658 for_left_value.value(), for_right_value.value());
671 if (node->kind() == Token::kEQ) { 659 if (node->kind() == Token::kEQ) {
672 ReturnComputation(comp); 660 ReturnComputation(comp);
673 } else { 661 } else {
674 Definition* eq_result = new BindInstr(temp_index(), comp); 662 Definition* eq_result = new BindInstr(temp_index(), comp);
675 AddInstruction(eq_result); 663 AddInstruction(eq_result);
676 if (FLAG_enable_type_checks) { 664 if (FLAG_enable_type_checks) {
677 eq_result = 665 eq_result =
678 new BindInstr(temp_index(), 666 new BindInstr(temp_index(),
679 new AssertBooleanComp(node->id(), 667 new AssertBooleanComp(node->token_index(),
680 node->token_index(),
681 owner()->try_index(), 668 owner()->try_index(),
682 new UseVal(eq_result))); 669 new UseVal(eq_result)));
683 AddInstruction(eq_result); 670 AddInstruction(eq_result);
684 } 671 }
685 BooleanNegateComp* negate = new BooleanNegateComp(new UseVal(eq_result)); 672 BooleanNegateComp* negate = new BooleanNegateComp(new UseVal(eq_result));
686 ReturnComputation(negate); 673 ReturnComputation(negate);
687 } 674 }
688 return; 675 return;
689 } 676 }
690 677
691 ValueGraphVisitor for_left_value(owner(), temp_index()); 678 ValueGraphVisitor for_left_value(owner(), temp_index());
692 node->left()->Visit(&for_left_value); 679 node->left()->Visit(&for_left_value);
693 Append(for_left_value); 680 Append(for_left_value);
694 ValueGraphVisitor for_right_value(owner(), for_left_value.temp_index()); 681 ValueGraphVisitor for_right_value(owner(), for_left_value.temp_index());
695 node->right()->Visit(&for_right_value); 682 node->right()->Visit(&for_right_value);
696 Append(for_right_value); 683 Append(for_right_value);
697 ZoneGrowableArray<Value*>* arguments = new ZoneGrowableArray<Value*>(2); 684 ZoneGrowableArray<Value*>* arguments = new ZoneGrowableArray<Value*>(2);
698 arguments->Add(for_left_value.value()); 685 arguments->Add(for_left_value.value());
699 arguments->Add(for_right_value.value()); 686 arguments->Add(for_right_value.value());
700 const String& name = String::ZoneHandle(String::NewSymbol(node->Name())); 687 const String& name = String::ZoneHandle(String::NewSymbol(node->Name()));
701 InstanceCallComp* call = new InstanceCallComp( 688 InstanceCallComp* call = new InstanceCallComp(
702 node->id(), node->token_index(), owner()->try_index(), name, 689 node->token_index(), owner()->try_index(), name,
703 arguments, Array::ZoneHandle(), 2); 690 arguments, Array::ZoneHandle(), 2);
704 ReturnComputation(call); 691 ReturnComputation(call);
705 } 692 }
706 693
707 694
708 void EffectGraphVisitor::VisitUnaryOpNode(UnaryOpNode* node) { 695 void EffectGraphVisitor::VisitUnaryOpNode(UnaryOpNode* node) {
709 // "!" cannot be overloaded, therefore do not call operator. 696 // "!" cannot be overloaded, therefore do not call operator.
710 if (node->kind() == Token::kNOT) { 697 if (node->kind() == Token::kNOT) {
711 ValueGraphVisitor for_value(owner(), temp_index()); 698 ValueGraphVisitor for_value(owner(), temp_index());
712 node->operand()->Visit(&for_value); 699 node->operand()->Visit(&for_value);
713 Append(for_value); 700 Append(for_value);
714 Value* value = for_value.value(); 701 Value* value = for_value.value();
715 if (FLAG_enable_type_checks) { 702 if (FLAG_enable_type_checks) {
716 BindInstr* assert_boolean = 703 BindInstr* assert_boolean =
717 new BindInstr(temp_index(), 704 new BindInstr(temp_index(),
718 new AssertBooleanComp(node->operand()->id(), 705 new AssertBooleanComp(node->operand()->token_index(),
719 node->operand()->token_index(),
720 owner()->try_index(), 706 owner()->try_index(),
721 value)); 707 value));
722 AddInstruction(assert_boolean); 708 AddInstruction(assert_boolean);
723 value = new UseVal(assert_boolean); 709 value = new UseVal(assert_boolean);
724 } 710 }
725 BooleanNegateComp* negate = new BooleanNegateComp(value); 711 BooleanNegateComp* negate = new BooleanNegateComp(value);
726 ReturnComputation(negate); 712 ReturnComputation(negate);
727 return; 713 return;
728 } 714 }
729 ValueGraphVisitor for_value(owner(), temp_index()); 715 ValueGraphVisitor for_value(owner(), temp_index());
730 node->operand()->Visit(&for_value); 716 node->operand()->Visit(&for_value);
731 Append(for_value); 717 Append(for_value);
732 ZoneGrowableArray<Value*>* arguments = new ZoneGrowableArray<Value*>(1); 718 ZoneGrowableArray<Value*>* arguments = new ZoneGrowableArray<Value*>(1);
733 arguments->Add(for_value.value()); 719 arguments->Add(for_value.value());
734 const String& name = 720 const String& name =
735 String::ZoneHandle(String::NewSymbol((node->kind() == Token::kSUB) 721 String::ZoneHandle(String::NewSymbol((node->kind() == Token::kSUB)
736 ? Token::Str(Token::kNEGATE) 722 ? Token::Str(Token::kNEGATE)
737 : node->Name())); 723 : node->Name()));
738 InstanceCallComp* call = new InstanceCallComp( 724 InstanceCallComp* call = new InstanceCallComp(
739 node->id(), node->token_index(), owner()->try_index(), name, 725 node->token_index(), owner()->try_index(), name,
740 arguments, Array::ZoneHandle(), 1); 726 arguments, Array::ZoneHandle(), 1);
741 ReturnComputation(call); 727 ReturnComputation(call);
742 } 728 }
743 729
744 730
745 void EffectGraphVisitor::VisitIncrOpLocalNode(IncrOpLocalNode* node) { 731 void EffectGraphVisitor::VisitIncrOpLocalNode(IncrOpLocalNode* node) {
746 ASSERT((node->kind() == Token::kINCR) || (node->kind() == Token::kDECR)); 732 ASSERT((node->kind() == Token::kINCR) || (node->kind() == Token::kDECR));
747 // In an effect context, treat postincrement as if it were preincrement 733 // In an effect context, treat postincrement as if it were preincrement
748 // because its value is not needed. 734 // because its value is not needed.
749 735
750 // 1. Load the value. 736 // 1. Load the value.
751 BindInstr* load = 737 BindInstr* load =
752 new BindInstr(temp_index(), 738 new BindInstr(temp_index(),
753 new LoadLocalComp(node->local(), owner()->context_level())); 739 new LoadLocalComp(node->local(), owner()->context_level()));
754 AddInstruction(load); 740 AddInstruction(load);
755 AllocateTempIndex(); 741 AllocateTempIndex();
756 // 2. Increment. 742 // 2. Increment.
757 Definition* incr = 743 Definition* incr =
758 BuildIncrOpIncrement(node->kind(), node->id(), node->token_index(), 744 BuildIncrOpIncrement(node->kind(), node->token_index(), new UseVal(load));
759 new UseVal(load));
760 // 3. Perform the store, resulting in the new value. 745 // 3. Perform the store, resulting in the new value.
761 DeallocateTempIndex(); // Consuming incr. 746 DeallocateTempIndex(); // Consuming incr.
762 StoreLocalComp* store = new StoreLocalComp( 747 StoreLocalComp* store = new StoreLocalComp(
763 node->local(), new UseVal(incr), owner()->context_level()); 748 node->local(), new UseVal(incr), owner()->context_level());
764 ReturnComputation(store); 749 ReturnComputation(store);
765 } 750 }
766 751
767 752
768 void ValueGraphVisitor::VisitIncrOpLocalNode(IncrOpLocalNode* node) { 753 void ValueGraphVisitor::VisitIncrOpLocalNode(IncrOpLocalNode* node) {
769 ASSERT((node->kind() == Token::kINCR) || (node->kind() == Token::kDECR)); 754 ASSERT((node->kind() == Token::kINCR) || (node->kind() == Token::kDECR));
(...skipping 11 matching lines...) Expand all
781 new LoadLocalComp(node->local(), owner()->context_level())); 766 new LoadLocalComp(node->local(), owner()->context_level()));
782 AddInstruction(load); 767 AddInstruction(load);
783 AllocateTempIndex(); 768 AllocateTempIndex();
784 // 2. Duplicate it to increment. 769 // 2. Duplicate it to increment.
785 PickTempInstr* duplicate = 770 PickTempInstr* duplicate =
786 new PickTempInstr(temp_index(), load->temp_index()); 771 new PickTempInstr(temp_index(), load->temp_index());
787 AddInstruction(duplicate); 772 AddInstruction(duplicate);
788 AllocateTempIndex(); 773 AllocateTempIndex();
789 // 3. Increment. 774 // 3. Increment.
790 Definition* incr = 775 Definition* incr =
791 BuildIncrOpIncrement(node->kind(), node->id(), node->token_index(), 776 BuildIncrOpIncrement(node->kind(), node->token_index(),
792 new UseVal(duplicate)); 777 new UseVal(duplicate));
793 // 4. Perform the store and return the original value. 778 // 4. Perform the store and return the original value.
794 DeallocateTempIndex(); // Consuming incr. 779 DeallocateTempIndex(); // Consuming incr.
795 StoreLocalComp* store = new StoreLocalComp( 780 StoreLocalComp* store = new StoreLocalComp(
796 node->local(), new UseVal(incr), owner()->context_level()); 781 node->local(), new UseVal(incr), owner()->context_level());
797 AddInstruction(new DoInstr(store)); 782 AddInstruction(new DoInstr(store));
798 ReturnValue(new UseVal(load)); 783 ReturnValue(new UseVal(load));
799 } 784 }
800 785
801 786
(...skipping 14 matching lines...) Expand all
816 801
817 // Load the value. 802 // Load the value.
818 // t_n+1 <- InstanceCall(get:name, t_n+1) 803 // t_n+1 <- InstanceCall(get:name, t_n+1)
819 const String& getter_name = 804 const String& getter_name =
820 String::ZoneHandle(Field::GetterSymbol(node->field_name())); 805 String::ZoneHandle(Field::GetterSymbol(node->field_name()));
821 ZoneGrowableArray<Value*>* arguments = new ZoneGrowableArray<Value*>(1); 806 ZoneGrowableArray<Value*>* arguments = new ZoneGrowableArray<Value*>(1);
822 arguments->Add(new UseVal(duplicate)); 807 arguments->Add(new UseVal(duplicate));
823 BindInstr* load = 808 BindInstr* load =
824 new BindInstr(temp_index(), 809 new BindInstr(temp_index(),
825 new InstanceCallComp( 810 new InstanceCallComp(
826 node->getter_id(), node->token_index(), 811 node->token_index(),
827 owner()->try_index(), getter_name, arguments, 812 owner()->try_index(), getter_name, arguments,
828 Array::ZoneHandle(), 1)); 813 Array::ZoneHandle(), 1));
829 AddInstruction(load); 814 AddInstruction(load);
830 AllocateTempIndex(); 815 AllocateTempIndex();
831 816
832 *receiver = for_receiver.value(); 817 *receiver = for_receiver.value();
833 return load; 818 return load;
834 } 819 }
835 820
836 821
837 Definition* EffectGraphVisitor::BuildIncrOpIncrement(Token::Kind kind, 822 Definition* EffectGraphVisitor::BuildIncrOpIncrement(Token::Kind kind,
838 intptr_t node_id,
839 intptr_t token_index, 823 intptr_t token_index,
840 Value* original) { 824 Value* original) {
841 ASSERT((kind == Token::kINCR) || (kind == Token::kDECR)); 825 ASSERT((kind == Token::kINCR) || (kind == Token::kDECR));
842 // Assumed that t_n-1 (where n is start_index) is the field value. 826 // Assumed that t_n-1 (where n is start_index) is the field value.
843 // t_n <- #1 827 // t_n <- #1
844 // t_n-1 <- InstanceCall(op, t_n-1, t_n) 828 // t_n-1 <- InstanceCall(op, t_n-1, t_n)
845 BindInstr* one = 829 BindInstr* one =
846 new BindInstr(temp_index(), 830 new BindInstr(temp_index(),
847 new ConstantVal(Smi::ZoneHandle(Smi::New(1)))); 831 new ConstantVal(Smi::ZoneHandle(Smi::New(1))));
848 AddInstruction(one); 832 AddInstruction(one);
849 ZoneGrowableArray<Value*>* arguments = new ZoneGrowableArray<Value*>(2); 833 ZoneGrowableArray<Value*>* arguments = new ZoneGrowableArray<Value*>(2);
850 arguments->Add(original); 834 arguments->Add(original);
851 arguments->Add(new UseVal(one)); 835 arguments->Add(new UseVal(one));
852 const String& op_name = 836 const String& op_name =
853 String::ZoneHandle(String::NewSymbol((kind == Token::kINCR) ? "+" : "-")); 837 String::ZoneHandle(String::NewSymbol((kind == Token::kINCR) ? "+" : "-"));
854 DeallocateTempIndex(); // Consuming original. 838 DeallocateTempIndex(); // Consuming original.
855 BindInstr* add = 839 BindInstr* add =
856 new BindInstr(temp_index(), 840 new BindInstr(temp_index(),
857 new InstanceCallComp( 841 new InstanceCallComp(
858 node_id, token_index, owner()->try_index(), op_name, 842 token_index, owner()->try_index(), op_name,
859 arguments, Array::ZoneHandle(), 2)); 843 arguments, Array::ZoneHandle(), 2));
860 AddInstruction(add); 844 AddInstruction(add);
861 AllocateTempIndex(); 845 AllocateTempIndex();
862 return add; 846 return add;
863 } 847 }
864 848
865 849
866 void EffectGraphVisitor::VisitIncrOpInstanceFieldNode( 850 void EffectGraphVisitor::VisitIncrOpInstanceFieldNode(
867 IncrOpInstanceFieldNode* node) { 851 IncrOpInstanceFieldNode* node) {
868 ASSERT((node->kind() == Token::kINCR) || (node->kind() == Token::kDECR)); 852 ASSERT((node->kind() == Token::kINCR) || (node->kind() == Token::kDECR));
869 // In an effect context, treat postincrement as if it were preincrement 853 // In an effect context, treat postincrement as if it were preincrement
870 // because its value is not needed. 854 // because its value is not needed.
871 855
872 // 1. Load the value. 856 // 1. Load the value.
873 Value* receiver = NULL; 857 Value* receiver = NULL;
874 Definition* load = BuildIncrOpFieldLoad(node, &receiver); 858 Definition* load = BuildIncrOpFieldLoad(node, &receiver);
875 // 2. Increment. 859 // 2. Increment.
876 Definition* incr = 860 Definition* incr =
877 BuildIncrOpIncrement(node->kind(), node->operator_id(), 861 BuildIncrOpIncrement(node->kind(), node->token_index(), new UseVal(load));
878 node->token_index(), new UseVal(load));
879 // 3. Perform the store, returning the stored value. 862 // 3. Perform the store, returning the stored value.
880 InstanceSetterComp* store = 863 InstanceSetterComp* store =
881 new InstanceSetterComp(node->setter_id(), 864 new InstanceSetterComp(node->token_index(),
882 node->token_index(),
883 owner()->try_index(), 865 owner()->try_index(),
884 node->field_name(), 866 node->field_name(),
885 receiver, 867 receiver,
886 new UseVal(incr)); 868 new UseVal(incr));
887 DeallocateTempIndex(); // Consuming incr. 869 DeallocateTempIndex(); // Consuming incr.
888 DeallocateTempIndex(); // Consuming receiver. 870 DeallocateTempIndex(); // Consuming receiver.
889 ReturnComputation(store); 871 ReturnComputation(store);
890 } 872 }
891 873
892 874
(...skipping 15 matching lines...) Expand all
908 AddInstruction(placeholder); 890 AddInstruction(placeholder);
909 AllocateTempIndex(); 891 AllocateTempIndex();
910 // 2. Load the value. 892 // 2. Load the value.
911 Value* receiver = NULL; 893 Value* receiver = NULL;
912 Definition* load = BuildIncrOpFieldLoad(node, &receiver); 894 Definition* load = BuildIncrOpFieldLoad(node, &receiver);
913 // 3. Preserve the original value. 895 // 3. Preserve the original value.
914 AddInstruction(new TuckTempInstr(placeholder->temp_index(), 896 AddInstruction(new TuckTempInstr(placeholder->temp_index(),
915 load->temp_index())); 897 load->temp_index()));
916 // 4. Increment. 898 // 4. Increment.
917 Definition* incr = 899 Definition* incr =
918 BuildIncrOpIncrement(node->kind(), node->operator_id(), 900 BuildIncrOpIncrement(node->kind(), node->token_index(), new UseVal(load));
919 node->token_index(), new UseVal(load));
920 // 5. Perform the store and return the original value. 901 // 5. Perform the store and return the original value.
921 const String& setter_name = 902 const String& setter_name =
922 String::ZoneHandle(Field::SetterSymbol(node->field_name())); 903 String::ZoneHandle(Field::SetterSymbol(node->field_name()));
923 ZoneGrowableArray<Value*>* arguments = new ZoneGrowableArray<Value*>(2); 904 ZoneGrowableArray<Value*>* arguments = new ZoneGrowableArray<Value*>(2);
924 arguments->Add(receiver); 905 arguments->Add(receiver);
925 arguments->Add(new UseVal(incr)); 906 arguments->Add(new UseVal(incr));
926 InstanceCallComp* store = new InstanceCallComp( 907 InstanceCallComp* store = new InstanceCallComp(
927 node->setter_id(), node->token_index(), owner()->try_index(), 908 node->token_index(), owner()->try_index(),
928 setter_name, arguments, Array::ZoneHandle(), 1); 909 setter_name, arguments, Array::ZoneHandle(), 1);
929 DeallocateTempIndex(); // Consuming incr. 910 DeallocateTempIndex(); // Consuming incr.
930 DeallocateTempIndex(); // Consuming receiver. 911 DeallocateTempIndex(); // Consuming receiver.
931 AddInstruction(new DoInstr(store)); 912 AddInstruction(new DoInstr(store));
932 ReturnValue(new UseVal(placeholder)); 913 ReturnValue(new UseVal(placeholder));
933 } 914 }
934 915
935 916
936 Definition* EffectGraphVisitor::BuildIncrOpIndexedLoad( 917 Definition* EffectGraphVisitor::BuildIncrOpIndexedLoad(
937 IncrOpIndexedNode* node, 918 IncrOpIndexedNode* node,
(...skipping 25 matching lines...) Expand all
963 new PickTempInstr(temp_index() + 1, temp_index() - 1); 944 new PickTempInstr(temp_index() + 1, temp_index() - 1);
964 AddInstruction(duplicate_index); 945 AddInstruction(duplicate_index);
965 ZoneGrowableArray<Value*>* arguments = new ZoneGrowableArray<Value*>(2); 946 ZoneGrowableArray<Value*>* arguments = new ZoneGrowableArray<Value*>(2);
966 arguments->Add(new UseVal(duplicate_receiver)); 947 arguments->Add(new UseVal(duplicate_receiver));
967 arguments->Add(new UseVal(duplicate_index)); 948 arguments->Add(new UseVal(duplicate_index));
968 const String& load_name = 949 const String& load_name =
969 String::ZoneHandle(String::NewSymbol(Token::Str(Token::kINDEX))); 950 String::ZoneHandle(String::NewSymbol(Token::Str(Token::kINDEX)));
970 BindInstr* load = 951 BindInstr* load =
971 new BindInstr(temp_index(), 952 new BindInstr(temp_index(),
972 new InstanceCallComp( 953 new InstanceCallComp(
973 node->load_id(), node->token_index(), 954 node->token_index(),
974 owner()->try_index(), load_name, arguments, 955 owner()->try_index(), load_name, arguments,
975 Array::ZoneHandle(), 1)); 956 Array::ZoneHandle(), 1));
976 AddInstruction(load); 957 AddInstruction(load);
977 AllocateTempIndex(); 958 AllocateTempIndex();
978 959
979 *receiver = for_receiver.value(); 960 *receiver = for_receiver.value();
980 *index = for_index.value(); 961 *index = for_index.value();
981 return load; 962 return load;
982 } 963 }
983 964
984 965
985 void EffectGraphVisitor::VisitIncrOpIndexedNode(IncrOpIndexedNode* node) { 966 void EffectGraphVisitor::VisitIncrOpIndexedNode(IncrOpIndexedNode* node) {
986 ASSERT((node->kind() == Token::kINCR) || (node->kind() == Token::kDECR)); 967 ASSERT((node->kind() == Token::kINCR) || (node->kind() == Token::kDECR));
987 // In an effect context, treat postincrement as if it were preincrement 968 // In an effect context, treat postincrement as if it were preincrement
988 // because its value is not needed. 969 // because its value is not needed.
989 970
990 // 1. Load the value. 971 // 1. Load the value.
991 Value* receiver = NULL; 972 Value* receiver = NULL;
992 Value* index = NULL; 973 Value* index = NULL;
993 Definition* load = BuildIncrOpIndexedLoad(node, &receiver, &index); 974 Definition* load = BuildIncrOpIndexedLoad(node, &receiver, &index);
994 // 2. Increment. 975 // 2. Increment.
995 Definition* incr = 976 Definition* incr =
996 BuildIncrOpIncrement(node->kind(), node->operator_id(), 977 BuildIncrOpIncrement(node->kind(), node->token_index(), new UseVal(load));
997 node->token_index(), new UseVal(load));
998 // 3. Perform the store, returning the stored value. 978 // 3. Perform the store, returning the stored value.
999 StoreIndexedComp* store = new StoreIndexedComp(node->store_id(), 979 StoreIndexedComp* store = new StoreIndexedComp(node->token_index(),
1000 node->token_index(),
1001 owner()->try_index(), 980 owner()->try_index(),
1002 receiver, 981 receiver,
1003 index, 982 index,
1004 new UseVal(incr)); 983 new UseVal(incr));
1005 DeallocateTempIndex(); // Consuming incr. 984 DeallocateTempIndex(); // Consuming incr.
1006 DeallocateTempIndex(); // Consuming index. 985 DeallocateTempIndex(); // Consuming index.
1007 DeallocateTempIndex(); // Consuming receiver. 986 DeallocateTempIndex(); // Consuming receiver.
1008 ReturnComputation(store); 987 ReturnComputation(store);
1009 } 988 }
1010 989
(...skipping 16 matching lines...) Expand all
1027 AllocateTempIndex(); 1006 AllocateTempIndex();
1028 // 2. Load the value. 1007 // 2. Load the value.
1029 Value* receiver = NULL; 1008 Value* receiver = NULL;
1030 Value* index = NULL; 1009 Value* index = NULL;
1031 Definition* load = BuildIncrOpIndexedLoad(node, &receiver, &index); 1010 Definition* load = BuildIncrOpIndexedLoad(node, &receiver, &index);
1032 // 3. Preserve the original value. 1011 // 3. Preserve the original value.
1033 AddInstruction(new TuckTempInstr(placeholder->temp_index(), 1012 AddInstruction(new TuckTempInstr(placeholder->temp_index(),
1034 load->temp_index())); 1013 load->temp_index()));
1035 // 4. Increment. 1014 // 4. Increment.
1036 Definition* incr = 1015 Definition* incr =
1037 BuildIncrOpIncrement(node->kind(), node->operator_id(), 1016 BuildIncrOpIncrement(node->kind(), node->token_index(), new UseVal(load));
1038 node->token_index(), new UseVal(load));
1039 // 5. Perform the store and return the original value. 1017 // 5. Perform the store and return the original value.
1040 const String& store_name = 1018 const String& store_name =
1041 String::ZoneHandle(String::NewSymbol(Token::Str(Token::kASSIGN_INDEX))); 1019 String::ZoneHandle(String::NewSymbol(Token::Str(Token::kASSIGN_INDEX)));
1042 ZoneGrowableArray<Value*>* arguments = new ZoneGrowableArray<Value*>(3); 1020 ZoneGrowableArray<Value*>* arguments = new ZoneGrowableArray<Value*>(3);
1043 arguments->Add(receiver); 1021 arguments->Add(receiver);
1044 arguments->Add(index); 1022 arguments->Add(index);
1045 arguments->Add(new UseVal(incr)); 1023 arguments->Add(new UseVal(incr));
1046 InstanceCallComp* store = new InstanceCallComp( 1024 InstanceCallComp* store = new InstanceCallComp(
1047 node->store_id(), node->token_index(), owner()->try_index(), 1025 node->token_index(), owner()->try_index(),
1048 store_name, arguments, Array::ZoneHandle(), 1); 1026 store_name, arguments, Array::ZoneHandle(), 1);
1049 DeallocateTempIndex(); // Consuming incr. 1027 DeallocateTempIndex(); // Consuming incr.
1050 DeallocateTempIndex(); // Consuming index. 1028 DeallocateTempIndex(); // Consuming index.
1051 DeallocateTempIndex(); // Consuming receiver. 1029 DeallocateTempIndex(); // Consuming receiver.
1052 AddInstruction(new DoInstr(store)); 1030 AddInstruction(new DoInstr(store));
1053 ReturnValue(new UseVal(placeholder)); 1031 ReturnValue(new UseVal(placeholder));
1054 } 1032 }
1055 1033
1056 1034
1057 void EffectGraphVisitor::VisitConditionalExprNode(ConditionalExprNode* node) { 1035 void EffectGraphVisitor::VisitConditionalExprNode(ConditionalExprNode* node) {
1058 TestGraphVisitor for_test(owner(), 1036 TestGraphVisitor for_test(owner(),
1059 temp_index(), 1037 temp_index(),
1060 node->condition()->id(),
1061 node->condition()->token_index()); 1038 node->condition()->token_index());
1062 node->condition()->Visit(&for_test); 1039 node->condition()->Visit(&for_test);
1063 1040
1064 // Translate the subexpressions for their effects. 1041 // Translate the subexpressions for their effects.
1065 EffectGraphVisitor for_true(owner(), temp_index()); 1042 EffectGraphVisitor for_true(owner(), temp_index());
1066 node->true_expr()->Visit(&for_true); 1043 node->true_expr()->Visit(&for_true);
1067 EffectGraphVisitor for_false(owner(), temp_index()); 1044 EffectGraphVisitor for_false(owner(), temp_index());
1068 node->false_expr()->Visit(&for_false); 1045 node->false_expr()->Visit(&for_false);
1069 1046
1070 Join(for_test, for_true, for_false); 1047 Join(for_test, for_true, for_false);
1071 } 1048 }
1072 1049
1073 1050
1074 void ValueGraphVisitor::VisitConditionalExprNode(ConditionalExprNode* node) { 1051 void ValueGraphVisitor::VisitConditionalExprNode(ConditionalExprNode* node) {
1075 TestGraphVisitor for_test(owner(), 1052 TestGraphVisitor for_test(owner(),
1076 temp_index(), 1053 temp_index(),
1077 node->condition()->id(),
1078 node->condition()->token_index()); 1054 node->condition()->token_index());
1079 node->condition()->Visit(&for_test); 1055 node->condition()->Visit(&for_test);
1080 1056
1081 // Ensure that the value of the true/false subexpressions are named with 1057 // Ensure that the value of the true/false subexpressions are named with
1082 // the same temporary name. 1058 // the same temporary name.
1083 ValueGraphVisitor for_true(owner(), temp_index()); 1059 ValueGraphVisitor for_true(owner(), temp_index());
1084 node->true_expr()->Visit(&for_true); 1060 node->true_expr()->Visit(&for_true);
1085 ASSERT(for_true.is_open()); 1061 ASSERT(for_true.is_open());
1086 if (for_true.value()->IsTemp()) { 1062 if (for_true.value()->IsTemp()) {
1087 ASSERT(for_true.value()->AsTemp()->index() == temp_index()); 1063 ASSERT(for_true.value()->AsTemp()->index() == temp_index());
(...skipping 14 matching lines...) Expand all
1102 ReturnValue(new TempVal(AllocateTempIndex())); 1078 ReturnValue(new TempVal(AllocateTempIndex()));
1103 } 1079 }
1104 1080
1105 1081
1106 // <Statement> ::= If { condition: <Expression> 1082 // <Statement> ::= If { condition: <Expression>
1107 // true_branch: <Sequence> 1083 // true_branch: <Sequence>
1108 // false_branch: <Sequence> } 1084 // false_branch: <Sequence> }
1109 void EffectGraphVisitor::VisitIfNode(IfNode* node) { 1085 void EffectGraphVisitor::VisitIfNode(IfNode* node) {
1110 TestGraphVisitor for_test(owner(), 1086 TestGraphVisitor for_test(owner(),
1111 temp_index(), 1087 temp_index(),
1112 node->condition()->id(),
1113 node->condition()->token_index()); 1088 node->condition()->token_index());
1114 node->condition()->Visit(&for_test); 1089 node->condition()->Visit(&for_test);
1115 1090
1116 EffectGraphVisitor for_true(owner(), temp_index()); 1091 EffectGraphVisitor for_true(owner(), temp_index());
1117 EffectGraphVisitor for_false(owner(), temp_index()); 1092 EffectGraphVisitor for_false(owner(), temp_index());
1118 1093
1119 node->true_branch()->Visit(&for_true); 1094 node->true_branch()->Visit(&for_true);
1120 // The for_false graph fragment will be empty (default graph fragment) if 1095 // The for_false graph fragment will be empty (default graph fragment) if
1121 // we do not call Visit. 1096 // we do not call Visit.
1122 if (node->false_branch() != NULL) node->false_branch()->Visit(&for_false); 1097 if (node->false_branch() != NULL) node->false_branch()->Visit(&for_false);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1193 1168
1194 // Generate instructions for all case expressions and collect data to 1169 // Generate instructions for all case expressions and collect data to
1195 // connect them. 1170 // connect them.
1196 GrowableArray<TargetEntryInstr**> case_true_addresses; 1171 GrowableArray<TargetEntryInstr**> case_true_addresses;
1197 GrowableArray<TargetEntryInstr**> case_false_addresses; 1172 GrowableArray<TargetEntryInstr**> case_false_addresses;
1198 GrowableArray<TargetEntryInstr*> case_entries; 1173 GrowableArray<TargetEntryInstr*> case_entries;
1199 for (intptr_t i = 0; i < len; i++) { 1174 for (intptr_t i = 0; i < len; i++) {
1200 AstNode* case_expr = node->case_expressions()->NodeAt(i); 1175 AstNode* case_expr = node->case_expressions()->NodeAt(i);
1201 TestGraphVisitor for_case_expression(owner(), 1176 TestGraphVisitor for_case_expression(owner(),
1202 temp_index(), 1177 temp_index(),
1203 case_expr->id(),
1204 case_expr->token_index()); 1178 case_expr->token_index());
1205 if (i == 0) { 1179 if (i == 0) {
1206 case_entries.Add(NULL); // Not to be used 1180 case_entries.Add(NULL); // Not to be used
1207 case_expr->Visit(&for_case_expression); 1181 case_expr->Visit(&for_case_expression);
1208 // Append only the first one, everything else is connected from it. 1182 // Append only the first one, everything else is connected from it.
1209 Append(for_case_expression); 1183 Append(for_case_expression);
1210 } else { 1184 } else {
1211 TargetEntryInstr* case_entry_target = new TargetEntryInstr(); 1185 TargetEntryInstr* case_entry_target = new TargetEntryInstr();
1212 case_entries.Add(case_entry_target); 1186 case_entries.Add(case_entry_target);
1213 for_case_expression.AddInstruction(case_entry_target); 1187 for_case_expression.AddInstruction(case_entry_target);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1276 // a) continue-join (optional) 1250 // a) continue-join (optional)
1277 // b) loop-join 1251 // b) loop-join
1278 // c) [ test ] -> (body-entry-target, loop-exit-target) 1252 // c) [ test ] -> (body-entry-target, loop-exit-target)
1279 // d) body-entry-target 1253 // d) body-entry-target
1280 // e) [ body ] -> (loop-join) 1254 // e) [ body ] -> (loop-join)
1281 // f) loop-exit-target 1255 // f) loop-exit-target
1282 // g) break-join (optional) 1256 // g) break-join (optional)
1283 void EffectGraphVisitor::VisitWhileNode(WhileNode* node) { 1257 void EffectGraphVisitor::VisitWhileNode(WhileNode* node) {
1284 TestGraphVisitor for_test(owner(), 1258 TestGraphVisitor for_test(owner(),
1285 temp_index(), 1259 temp_index(),
1286 node->condition()->id(),
1287 node->condition()->token_index()); 1260 node->condition()->token_index());
1288 node->condition()->Visit(&for_test); 1261 node->condition()->Visit(&for_test);
1289 ASSERT(!for_test.is_empty()); // Language spec. 1262 ASSERT(!for_test.is_empty()); // Language spec.
1290 1263
1291 EffectGraphVisitor for_body(owner(), temp_index()); 1264 EffectGraphVisitor for_body(owner(), temp_index());
1292 node->body()->Visit(&for_body); 1265 node->body()->Visit(&for_body);
1293 1266
1294 // Labels are set after body traversal. 1267 // Labels are set after body traversal.
1295 SourceLabel* lbl = node->label(); 1268 SourceLabel* lbl = node->label();
1296 ASSERT(lbl != NULL); 1269 ASSERT(lbl != NULL);
(...skipping 15 matching lines...) Expand all
1312 // e) back-target -> (body-entry-join) 1285 // e) back-target -> (body-entry-join)
1313 // f) loop-exit-target 1286 // f) loop-exit-target
1314 // g) break-join 1287 // g) break-join
1315 void EffectGraphVisitor::VisitDoWhileNode(DoWhileNode* node) { 1288 void EffectGraphVisitor::VisitDoWhileNode(DoWhileNode* node) {
1316 // Traverse body first in order to generate continue and break labels. 1289 // Traverse body first in order to generate continue and break labels.
1317 EffectGraphVisitor for_body(owner(), temp_index()); 1290 EffectGraphVisitor for_body(owner(), temp_index());
1318 node->body()->Visit(&for_body); 1291 node->body()->Visit(&for_body);
1319 1292
1320 TestGraphVisitor for_test(owner(), 1293 TestGraphVisitor for_test(owner(),
1321 temp_index(), 1294 temp_index(),
1322 node->condition()->id(),
1323 node->condition()->token_index()); 1295 node->condition()->token_index());
1324 node->condition()->Visit(&for_test); 1296 node->condition()->Visit(&for_test);
1325 ASSERT(is_open()); 1297 ASSERT(is_open());
1326 1298
1327 // Tie do-while loop (test is after the body). 1299 // Tie do-while loop (test is after the body).
1328 JoinEntryInstr* body_entry_join = new JoinEntryInstr(); 1300 JoinEntryInstr* body_entry_join = new JoinEntryInstr();
1329 AddInstruction(body_entry_join); 1301 AddInstruction(body_entry_join);
1330 body_entry_join->SetSuccessor(for_body.entry()); 1302 body_entry_join->SetSuccessor(for_body.entry());
1331 Instruction* body_exit = 1303 Instruction* body_exit =
1332 for_body.is_empty() ? body_entry_join : for_body.exit(); 1304 for_body.is_empty() ? body_entry_join : for_body.exit();
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1421 if (node->label()->join_for_break() == NULL) { 1393 if (node->label()->join_for_break() == NULL) {
1422 CloseFragment(); 1394 CloseFragment();
1423 } else { 1395 } else {
1424 // Control flow of ForLoop continues into join_for_break. 1396 // Control flow of ForLoop continues into join_for_break.
1425 exit_ = node->label()->join_for_break(); 1397 exit_ = node->label()->join_for_break();
1426 } 1398 }
1427 } else { 1399 } else {
1428 TargetEntryInstr* loop_exit = new TargetEntryInstr(); 1400 TargetEntryInstr* loop_exit = new TargetEntryInstr();
1429 TestGraphVisitor for_test(owner(), 1401 TestGraphVisitor for_test(owner(),
1430 temp_index(), 1402 temp_index(),
1431 node->condition()->id(),
1432 node->condition()->token_index()); 1403 node->condition()->token_index());
1433 node->condition()->Visit(&for_test); 1404 node->condition()->Visit(&for_test);
1434 Append(for_test); 1405 Append(for_test);
1435 *for_test.true_successor_address() = body_entry; 1406 *for_test.true_successor_address() = body_entry;
1436 *for_test.false_successor_address() = loop_exit; 1407 *for_test.false_successor_address() = loop_exit;
1437 if (node->label()->join_for_break() == NULL) { 1408 if (node->label()->join_for_break() == NULL) {
1438 exit_ = loop_exit; 1409 exit_ = loop_exit;
1439 } else { 1410 } else {
1440 loop_exit->SetSuccessor(node->label()->join_for_break()); 1411 loop_exit->SetSuccessor(node->label()->join_for_break());
1441 exit_ = node->label()->join_for_break(); 1412 exit_ = node->label()->join_for_break();
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
1578 int length = arguments->length(); 1549 int length = arguments->length();
1579 ZoneGrowableArray<Value*>* values = new ZoneGrowableArray<Value*>(length + 1); 1550 ZoneGrowableArray<Value*>* values = new ZoneGrowableArray<Value*>(length + 1);
1580 1551
1581 ValueGraphVisitor for_receiver(owner(), temp_index()); 1552 ValueGraphVisitor for_receiver(owner(), temp_index());
1582 node->receiver()->Visit(&for_receiver); 1553 node->receiver()->Visit(&for_receiver);
1583 Append(for_receiver); 1554 Append(for_receiver);
1584 values->Add(for_receiver.value()); 1555 values->Add(for_receiver.value());
1585 1556
1586 TranslateArgumentList(*arguments, for_receiver.temp_index(), values); 1557 TranslateArgumentList(*arguments, for_receiver.temp_index(), values);
1587 InstanceCallComp* call = new InstanceCallComp( 1558 InstanceCallComp* call = new InstanceCallComp(
1588 node->id(), node->token_index(), owner()->try_index(), 1559 node->token_index(), owner()->try_index(),
1589 node->function_name(), values, 1560 node->function_name(), values,
1590 arguments->names(), 1); 1561 arguments->names(), 1);
1591 ReturnComputation(call); 1562 ReturnComputation(call);
1592 } 1563 }
1593 1564
1594 1565
1595 // <Expression> ::= StaticCall { function: Function 1566 // <Expression> ::= StaticCall { function: Function
1596 // arguments: <ArgumentList> } 1567 // arguments: <ArgumentList> }
1597 void EffectGraphVisitor::VisitStaticCallNode(StaticCallNode* node) { 1568 void EffectGraphVisitor::VisitStaticCallNode(StaticCallNode* node) {
1598 int length = node->arguments()->length(); 1569 int length = node->arguments()->length();
(...skipping 30 matching lines...) Expand all
1629 arguments); 1600 arguments);
1630 ReturnComputation(call); 1601 ReturnComputation(call);
1631 } 1602 }
1632 1603
1633 1604
1634 void EffectGraphVisitor::VisitCloneContextNode(CloneContextNode* node) { 1605 void EffectGraphVisitor::VisitCloneContextNode(CloneContextNode* node) {
1635 BindInstr* context = new BindInstr(temp_index(), new CurrentContextComp()); 1606 BindInstr* context = new BindInstr(temp_index(), new CurrentContextComp());
1636 AddInstruction(context); 1607 AddInstruction(context);
1637 BindInstr* clone = 1608 BindInstr* clone =
1638 new BindInstr(temp_index(), 1609 new BindInstr(temp_index(),
1639 new CloneContextComp(node->id(), 1610 new CloneContextComp(node->token_index(),
1640 node->token_index(),
1641 owner()->try_index(), 1611 owner()->try_index(),
1642 new UseVal(context))); 1612 new UseVal(context)));
1643 AddInstruction(clone); 1613 AddInstruction(clone);
1644 ReturnComputation(new StoreContextComp(new UseVal(clone))); 1614 ReturnComputation(new StoreContextComp(new UseVal(clone)));
1645 } 1615 }
1646 1616
1647 1617
1648 Definition* EffectGraphVisitor::BuildObjectAllocation( 1618 Definition* EffectGraphVisitor::BuildObjectAllocation(
1649 ConstructorCallNode* node) { 1619 ConstructorCallNode* node) {
1650 const Class& cls = Class::ZoneHandle(node->constructor().owner()); 1620 const Class& cls = Class::ZoneHandle(node->constructor().owner());
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
1875 1845
1876 void EffectGraphVisitor::VisitInstanceGetterNode(InstanceGetterNode* node) { 1846 void EffectGraphVisitor::VisitInstanceGetterNode(InstanceGetterNode* node) {
1877 ValueGraphVisitor for_receiver(owner(), temp_index()); 1847 ValueGraphVisitor for_receiver(owner(), temp_index());
1878 node->receiver()->Visit(&for_receiver); 1848 node->receiver()->Visit(&for_receiver);
1879 Append(for_receiver); 1849 Append(for_receiver);
1880 ZoneGrowableArray<Value*>* arguments = new ZoneGrowableArray<Value*>(1); 1850 ZoneGrowableArray<Value*>* arguments = new ZoneGrowableArray<Value*>(1);
1881 arguments->Add(for_receiver.value()); 1851 arguments->Add(for_receiver.value());
1882 const String& name = 1852 const String& name =
1883 String::ZoneHandle(Field::GetterSymbol(node->field_name())); 1853 String::ZoneHandle(Field::GetterSymbol(node->field_name()));
1884 InstanceCallComp* call = new InstanceCallComp( 1854 InstanceCallComp* call = new InstanceCallComp(
1885 node->id(), node->token_index(), owner()->try_index(), name, 1855 node->token_index(), owner()->try_index(), name,
1886 arguments, Array::ZoneHandle(), 1); 1856 arguments, Array::ZoneHandle(), 1);
1887 ReturnComputation(call); 1857 ReturnComputation(call);
1888 } 1858 }
1889 1859
1890 1860
1891 void EffectGraphVisitor::VisitInstanceSetterNode(InstanceSetterNode* node) { 1861 void EffectGraphVisitor::VisitInstanceSetterNode(InstanceSetterNode* node) {
1892 ValueGraphVisitor for_receiver(owner(), temp_index()); 1862 ValueGraphVisitor for_receiver(owner(), temp_index());
1893 node->receiver()->Visit(&for_receiver); 1863 node->receiver()->Visit(&for_receiver);
1894 Append(for_receiver); 1864 Append(for_receiver);
1895 ValueGraphVisitor for_value(owner(), for_receiver.temp_index()); 1865 ValueGraphVisitor for_value(owner(), for_receiver.temp_index());
1896 node->value()->Visit(&for_value); 1866 node->value()->Visit(&for_value);
1897 Append(for_value); 1867 Append(for_value);
1898 InstanceSetterComp* setter = 1868 InstanceSetterComp* setter =
1899 new InstanceSetterComp(node->id(), 1869 new InstanceSetterComp(node->token_index(),
1900 node->token_index(),
1901 owner()->try_index(), 1870 owner()->try_index(),
1902 node->field_name(), 1871 node->field_name(),
1903 for_receiver.value(), 1872 for_receiver.value(),
1904 for_value.value()); 1873 for_value.value());
1905 ReturnComputation(setter); 1874 ReturnComputation(setter);
1906 } 1875 }
1907 1876
1908 1877
1909 void EffectGraphVisitor::VisitStaticGetterNode(StaticGetterNode* node) { 1878 void EffectGraphVisitor::VisitStaticGetterNode(StaticGetterNode* node) {
1910 const String& getter_name = 1879 const String& getter_name =
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1966 1935
1967 1936
1968 // <Expression> ::= StoreLocal { local: LocalVariable 1937 // <Expression> ::= StoreLocal { local: LocalVariable
1969 // value: <Expression> } 1938 // value: <Expression> }
1970 void EffectGraphVisitor::VisitStoreLocalNode(StoreLocalNode* node) { 1939 void EffectGraphVisitor::VisitStoreLocalNode(StoreLocalNode* node) {
1971 ValueGraphVisitor for_value(owner(), temp_index()); 1940 ValueGraphVisitor for_value(owner(), temp_index());
1972 node->value()->Visit(&for_value); 1941 node->value()->Visit(&for_value);
1973 Append(for_value); 1942 Append(for_value);
1974 Value* store_value = for_value.value(); 1943 Value* store_value = for_value.value();
1975 if (FLAG_enable_type_checks) { 1944 if (FLAG_enable_type_checks) {
1976 store_value = BuildAssignableValue(node->id(), 1945 store_value = BuildAssignableValue(node->value(),
1977 node->value(),
1978 store_value, 1946 store_value,
1979 node->local().type(), 1947 node->local().type(),
1980 node->local().name(), 1948 node->local().name(),
1981 temp_index()); 1949 temp_index());
1982 } 1950 }
1983 StoreLocalComp* store = 1951 StoreLocalComp* store =
1984 new StoreLocalComp(node->local(), store_value, owner()->context_level()); 1952 new StoreLocalComp(node->local(), store_value, owner()->context_level());
1985 ReturnComputation(store); 1953 ReturnComputation(store);
1986 } 1954 }
1987 1955
(...skipping 14 matching lines...) Expand all
2002 ValueGraphVisitor for_instance(owner(), temp_index()); 1970 ValueGraphVisitor for_instance(owner(), temp_index());
2003 node->instance()->Visit(&for_instance); 1971 node->instance()->Visit(&for_instance);
2004 Append(for_instance); 1972 Append(for_instance);
2005 ValueGraphVisitor for_value(owner(), for_instance.temp_index()); 1973 ValueGraphVisitor for_value(owner(), for_instance.temp_index());
2006 node->value()->Visit(&for_value); 1974 node->value()->Visit(&for_value);
2007 Append(for_value); 1975 Append(for_value);
2008 Value* store_value = for_value.value(); 1976 Value* store_value = for_value.value();
2009 if (FLAG_enable_type_checks) { 1977 if (FLAG_enable_type_checks) {
2010 const AbstractType& type = AbstractType::ZoneHandle(node->field().type()); 1978 const AbstractType& type = AbstractType::ZoneHandle(node->field().type());
2011 const String& dst_name = String::ZoneHandle(node->field().name()); 1979 const String& dst_name = String::ZoneHandle(node->field().name());
2012 store_value = BuildAssignableValue(node->id(), 1980 store_value = BuildAssignableValue(node->value(),
2013 node->value(),
2014 store_value, 1981 store_value,
2015 type, 1982 type,
2016 dst_name, 1983 dst_name,
2017 for_instance.temp_index()); 1984 for_instance.temp_index());
2018 } 1985 }
2019 StoreInstanceFieldComp* store = 1986 StoreInstanceFieldComp* store =
2020 new StoreInstanceFieldComp(node, for_instance.value(), store_value); 1987 new StoreInstanceFieldComp(node, for_instance.value(), store_value);
2021 ReturnComputation(store); 1988 ReturnComputation(store);
2022 } 1989 }
2023 1990
2024 1991
2025 void EffectGraphVisitor::VisitLoadStaticFieldNode(LoadStaticFieldNode* node) { 1992 void EffectGraphVisitor::VisitLoadStaticFieldNode(LoadStaticFieldNode* node) {
2026 LoadStaticFieldComp* load = new LoadStaticFieldComp(node->field()); 1993 LoadStaticFieldComp* load = new LoadStaticFieldComp(node->field());
2027 ReturnComputation(load); 1994 ReturnComputation(load);
2028 } 1995 }
2029 1996
2030 1997
2031 void EffectGraphVisitor::VisitStoreStaticFieldNode(StoreStaticFieldNode* node) { 1998 void EffectGraphVisitor::VisitStoreStaticFieldNode(StoreStaticFieldNode* node) {
2032 ValueGraphVisitor for_value(owner(), temp_index()); 1999 ValueGraphVisitor for_value(owner(), temp_index());
2033 node->value()->Visit(&for_value); 2000 node->value()->Visit(&for_value);
2034 Append(for_value); 2001 Append(for_value);
2035 Value* store_value = for_value.value(); 2002 Value* store_value = for_value.value();
2036 if (FLAG_enable_type_checks) { 2003 if (FLAG_enable_type_checks) {
2037 const AbstractType& type = AbstractType::ZoneHandle(node->field().type()); 2004 const AbstractType& type = AbstractType::ZoneHandle(node->field().type());
2038 const String& dst_name = String::ZoneHandle(node->field().name()); 2005 const String& dst_name = String::ZoneHandle(node->field().name());
2039 store_value = BuildAssignableValue(node->id(), 2006 store_value = BuildAssignableValue(node->value(),
2040 node->value(),
2041 store_value, 2007 store_value,
2042 type, 2008 type,
2043 dst_name, 2009 dst_name,
2044 temp_index()); 2010 temp_index());
2045 } 2011 }
2046 StoreStaticFieldComp* store = 2012 StoreStaticFieldComp* store =
2047 new StoreStaticFieldComp(node->field(), store_value); 2013 new StoreStaticFieldComp(node->field(), store_value);
2048 ReturnComputation(store); 2014 ReturnComputation(store);
2049 } 2015 }
2050 2016
2051 2017
2052 void EffectGraphVisitor::VisitLoadIndexedNode(LoadIndexedNode* node) { 2018 void EffectGraphVisitor::VisitLoadIndexedNode(LoadIndexedNode* node) {
2053 ValueGraphVisitor for_array(owner(), temp_index()); 2019 ValueGraphVisitor for_array(owner(), temp_index());
2054 node->array()->Visit(&for_array); 2020 node->array()->Visit(&for_array);
2055 Append(for_array); 2021 Append(for_array);
2056 ValueGraphVisitor for_index(owner(), for_array.temp_index()); 2022 ValueGraphVisitor for_index(owner(), for_array.temp_index());
2057 node->index_expr()->Visit(&for_index); 2023 node->index_expr()->Visit(&for_index);
2058 Append(for_index); 2024 Append(for_index);
2059 ZoneGrowableArray<Value*>* arguments = new ZoneGrowableArray<Value*>(2); 2025 ZoneGrowableArray<Value*>* arguments = new ZoneGrowableArray<Value*>(2);
2060 arguments->Add(for_array.value()); 2026 arguments->Add(for_array.value());
2061 arguments->Add(for_index.value()); 2027 arguments->Add(for_index.value());
2062 const String& name = 2028 const String& name =
2063 String::ZoneHandle(String::NewSymbol(Token::Str(Token::kINDEX))); 2029 String::ZoneHandle(String::NewSymbol(Token::Str(Token::kINDEX)));
2064 InstanceCallComp* call = new InstanceCallComp( 2030 InstanceCallComp* call = new InstanceCallComp(
2065 node->id(), node->token_index(), owner()->try_index(), name, 2031 node->token_index(), owner()->try_index(), name,
2066 arguments, Array::ZoneHandle(), 1); 2032 arguments, Array::ZoneHandle(), 1);
2067 ReturnComputation(call); 2033 ReturnComputation(call);
2068 } 2034 }
2069 2035
2070 2036
2071 void EffectGraphVisitor::VisitStoreIndexedNode(StoreIndexedNode* node) { 2037 void EffectGraphVisitor::VisitStoreIndexedNode(StoreIndexedNode* node) {
2072 ValueGraphVisitor for_array(owner(), temp_index()); 2038 ValueGraphVisitor for_array(owner(), temp_index());
2073 node->array()->Visit(&for_array); 2039 node->array()->Visit(&for_array);
2074 Append(for_array); 2040 Append(for_array);
2075 ValueGraphVisitor for_index(owner(), for_array.temp_index()); 2041 ValueGraphVisitor for_index(owner(), for_array.temp_index());
2076 node->index_expr()->Visit(&for_index); 2042 node->index_expr()->Visit(&for_index);
2077 Append(for_index); 2043 Append(for_index);
2078 ValueGraphVisitor for_value(owner(), for_index.temp_index()); 2044 ValueGraphVisitor for_value(owner(), for_index.temp_index());
2079 node->value()->Visit(&for_value); 2045 node->value()->Visit(&for_value);
2080 Append(for_value); 2046 Append(for_value);
2081 StoreIndexedComp* store = new StoreIndexedComp(node->id(), 2047 StoreIndexedComp* store = new StoreIndexedComp(node->token_index(),
2082 node->token_index(),
2083 owner()->try_index(), 2048 owner()->try_index(),
2084 for_array.value(), 2049 for_array.value(),
2085 for_index.value(), 2050 for_index.value(),
2086 for_value.value()); 2051 for_value.value());
2087 ReturnComputation(store); 2052 ReturnComputation(store);
2088 } 2053 }
2089 2054
2090 2055
2091 bool EffectGraphVisitor::MustSaveRestoreContext(SequenceNode* node) const { 2056 bool EffectGraphVisitor::MustSaveRestoreContext(SequenceNode* node) const {
2092 return (node == owner()->parsed_function().node_sequence()) && 2057 return (node == owner()->parsed_function().node_sequence()) &&
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
2207 owner()->parsed_function().function().NumberOfParameters(); 2172 owner()->parsed_function().function().NumberOfParameters();
2208 for (int pos = 0; pos < num_params; pos++) { 2173 for (int pos = 0; pos < num_params; pos++) {
2209 const LocalVariable& parameter = *scope->VariableAt(pos); 2174 const LocalVariable& parameter = *scope->VariableAt(pos);
2210 ASSERT(parameter.owner() == scope); 2175 ASSERT(parameter.owner() == scope);
2211 if (!CanSkipTypeCheck(NULL, parameter.type())) { 2176 if (!CanSkipTypeCheck(NULL, parameter.type())) {
2212 BindInstr* load = 2177 BindInstr* load =
2213 new BindInstr(temp_index(), 2178 new BindInstr(temp_index(),
2214 new LoadLocalComp(parameter, 2179 new LoadLocalComp(parameter,
2215 owner()->context_level())); 2180 owner()->context_level()));
2216 AddInstruction(load); 2181 AddInstruction(load);
2217 BuildAssertAssignable(node->ParameterIdAt(pos), 2182 BuildAssertAssignable(parameter.token_index(),
2218 parameter.token_index(),
2219 new UseVal(load), 2183 new UseVal(load),
2220 parameter.type(), 2184 parameter.type(),
2221 parameter.name(), 2185 parameter.name(),
2222 temp_index()); 2186 temp_index());
2223 } 2187 }
2224 } 2188 }
2225 } 2189 }
2226 2190
2227 intptr_t i = 0; 2191 intptr_t i = 0;
2228 while (is_open() && (i < node->length())) { 2192 while (is_open() && (i < node->length())) {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
2324 } 2288 }
2325 } 2289 }
2326 2290
2327 2291
2328 void EffectGraphVisitor::BuildThrowNode(ThrowNode* node) { 2292 void EffectGraphVisitor::BuildThrowNode(ThrowNode* node) {
2329 ValueGraphVisitor for_exception(owner(), temp_index()); 2293 ValueGraphVisitor for_exception(owner(), temp_index());
2330 node->exception()->Visit(&for_exception); 2294 node->exception()->Visit(&for_exception);
2331 Append(for_exception); 2295 Append(for_exception);
2332 Instruction* instr = NULL; 2296 Instruction* instr = NULL;
2333 if (node->stacktrace() == NULL) { 2297 if (node->stacktrace() == NULL) {
2334 instr = new ThrowInstr(node->id(), 2298 instr = new ThrowInstr(node->token_index(),
2335 node->token_index(),
2336 owner()->try_index(), 2299 owner()->try_index(),
2337 for_exception.value()); 2300 for_exception.value());
2338 } else { 2301 } else {
2339 ValueGraphVisitor for_stack_trace(owner(), temp_index() + 1); 2302 ValueGraphVisitor for_stack_trace(owner(), temp_index() + 1);
2340 node->stacktrace()->Visit(&for_stack_trace); 2303 node->stacktrace()->Visit(&for_stack_trace);
2341 Append(for_stack_trace); 2304 Append(for_stack_trace);
2342 instr = new ReThrowInstr(node->id(), 2305 instr = new ReThrowInstr(node->token_index(),
2343 node->token_index(),
2344 owner()->try_index(), 2306 owner()->try_index(),
2345 for_exception.value(), 2307 for_exception.value(),
2346 for_stack_trace.value()); 2308 for_stack_trace.value());
2347 } 2309 }
2348 AddInstruction(instr); 2310 AddInstruction(instr);
2349 } 2311 }
2350 2312
2351 2313
2352 void EffectGraphVisitor::VisitThrowNode(ThrowNode* node) { 2314 void EffectGraphVisitor::VisitThrowNode(ThrowNode* node) {
2353 BuildThrowNode(node); 2315 BuildThrowNode(node);
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
2929 char* chars = reinterpret_cast<char*>( 2891 char* chars = reinterpret_cast<char*>(
2930 Isolate::Current()->current_zone()->Allocate(len)); 2892 Isolate::Current()->current_zone()->Allocate(len));
2931 OS::SNPrint(chars, len, kFormat, function_name, reason); 2893 OS::SNPrint(chars, len, kFormat, function_name, reason);
2932 const Error& error = Error::Handle( 2894 const Error& error = Error::Handle(
2933 LanguageError::New(String::Handle(String::New(chars)))); 2895 LanguageError::New(String::Handle(String::New(chars))));
2934 Isolate::Current()->long_jump_base()->Jump(1, error); 2896 Isolate::Current()->long_jump_base()->Jump(1, error);
2935 } 2897 }
2936 2898
2937 2899
2938 } // namespace dart 2900 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_builder.h ('k') | runtime/vm/flow_graph_compiler_x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698