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

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

Issue 10446019: - Port AssertBool and AssertAssigneable to new location template. (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
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/bit_vector.h" 8 #include "vm/bit_vector.h"
9 #include "vm/code_descriptors.h" 9 #include "vm/code_descriptors.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 StaticCallComp* call = 574 StaticCallComp* call =
575 new StaticCallComp(node->token_index(), 575 new StaticCallComp(node->token_index(),
576 owner()->try_index(), 576 owner()->try_index(),
577 interpol_func, 577 interpol_func,
578 interpol_arg->names(), 578 interpol_arg->names(),
579 values); 579 values);
580 ReturnComputation(call); 580 ReturnComputation(call);
581 } 581 }
582 582
583 583
584 // instantiator_type_arguments are on TOS, instantiator is at TOS + 1.
regis 2012/05/24 19:56:18 extra space
srdjan 2012/05/24 20:24:44 That comment has been removed, forgot to upload. :
584 void EffectGraphVisitor::BuildTypecheckArguments( 585 void EffectGraphVisitor::BuildTypecheckArguments(
585 intptr_t token_index, 586 intptr_t token_index,
586 Value** instantiator_result, 587 Value** instantiator_result,
587 Value** instantiator_type_arguments_result) { 588 Value** instantiator_type_arguments_result) {
588 Value* instantiator = NULL; 589 Value* instantiator = NULL;
589 Value* instantiator_type_arguments = NULL; 590 Value* instantiator_type_arguments = NULL;
590 const Class& instantiator_class = Class::Handle( 591 const Class& instantiator_class = Class::Handle(
591 owner()->parsed_function().function().owner()); 592 owner()->parsed_function().function().owner());
592 // Since called only when type tested against is not instantiated. 593 // Since called only when type tested against is not instantiated.
593 ASSERT(instantiator_class.NumTypeParameters() > 0); 594 ASSERT(instantiator_class.NumTypeParameters() > 0);
594 instantiator = BuildInstantiator(); 595 instantiator = BuildInstantiator();
595 if (instantiator == NULL) { 596 if (instantiator == NULL) {
596 // No instantiator when inside factory. 597 // No instantiator when inside factory.
598 instantiator = BuildNullValue();
597 instantiator_type_arguments = 599 instantiator_type_arguments =
598 BuildInstantiatorTypeArguments(token_index, NULL); 600 BuildInstantiatorTypeArguments(token_index, NULL);
599 } else { 601 } else {
600 // Preserve instantiator. 602 // Preserve instantiator.
601 const LocalVariable& expr_temp = 603 const LocalVariable& expr_temp =
602 *owner()->parsed_function().expression_temp_var(); 604 *owner()->parsed_function().expression_temp_var();
603 BindInstr* saved = 605 BindInstr* saved =
604 new BindInstr(BuildStoreLocal(expr_temp, instantiator)); 606 new BindInstr(BuildStoreLocal(expr_temp, instantiator));
605 AddInstruction(saved); 607 AddInstruction(saved);
606 instantiator = new UseVal(saved); 608 instantiator = new UseVal(saved);
607 BindInstr* loaded = new BindInstr(BuildLoadLocal(expr_temp)); 609 BindInstr* loaded = new BindInstr(BuildLoadLocal(expr_temp));
608 AddInstruction(loaded); 610 AddInstruction(loaded);
609 instantiator_type_arguments = 611 instantiator_type_arguments =
610 BuildInstantiatorTypeArguments(token_index, new UseVal(loaded)); 612 BuildInstantiatorTypeArguments(token_index, new UseVal(loaded));
611 } 613 }
612 *instantiator_result = instantiator; 614 *instantiator_result = instantiator;
613 *instantiator_type_arguments_result = instantiator_type_arguments; 615 *instantiator_type_arguments_result = instantiator_type_arguments;
614 } 616 }
615 617
616 618
619 Value* EffectGraphVisitor::BuildNullValue() {
620 BindInstr* instr = new BindInstr(new ConstantVal(Object::ZoneHandle()));
621 AddInstruction(instr);
622 return new UseVal(instr);
623 }
624
625
617 // Used for testing incoming arguments. 626 // Used for testing incoming arguments.
618 AssertAssignableComp* EffectGraphVisitor::BuildAssertAssignable( 627 AssertAssignableComp* EffectGraphVisitor::BuildAssertAssignable(
619 intptr_t token_index, 628 intptr_t token_index,
620 Value* value, 629 Value* value,
621 const AbstractType& dst_type, 630 const AbstractType& dst_type,
622 const String& dst_name) { 631 const String& dst_name) {
623 // Build the type check computation. 632 // Build the type check computation.
624 Value* instantiator = NULL; 633 Value* instantiator = NULL;
625 Value* instantiator_type_arguments = NULL; 634 Value* instantiator_type_arguments = NULL;
626 if (!dst_type.IsInstantiated()) { 635 if (dst_type.IsInstantiated()) {
636 instantiator = BuildNullValue();
637 instantiator_type_arguments = BuildNullValue();
638 } else {
627 BuildTypecheckArguments(token_index, 639 BuildTypecheckArguments(token_index,
628 &instantiator, 640 &instantiator,
629 &instantiator_type_arguments); 641 &instantiator_type_arguments);
630 } 642 }
631 return new AssertAssignableComp(token_index, 643 return new AssertAssignableComp(token_index,
632 owner()->try_index(), 644 owner()->try_index(),
633 value, 645 value,
634 instantiator, 646 instantiator,
635 instantiator_type_arguments, 647 instantiator_type_arguments,
636 dst_type, 648 dst_type,
(...skipping 1758 matching lines...) Expand 10 before | Expand all | Expand 10 after
2395 char* chars = reinterpret_cast<char*>( 2407 char* chars = reinterpret_cast<char*>(
2396 Isolate::Current()->current_zone()->Allocate(len)); 2408 Isolate::Current()->current_zone()->Allocate(len));
2397 OS::SNPrint(chars, len, kFormat, function_name, reason); 2409 OS::SNPrint(chars, len, kFormat, function_name, reason);
2398 const Error& error = Error::Handle( 2410 const Error& error = Error::Handle(
2399 LanguageError::New(String::Handle(String::New(chars)))); 2411 LanguageError::New(String::Handle(String::New(chars))));
2400 Isolate::Current()->long_jump_base()->Jump(1, error); 2412 Isolate::Current()->long_jump_base()->Jump(1, error);
2401 } 2413 }
2402 2414
2403 2415
2404 } // namespace dart 2416 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698