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

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

Issue 10350003: Step toward eliminating increment nodes, starting with increment local. Fix a bug in evaluating sid… (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/opt_code_generator_ia32.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 706 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 String::ZoneHandle(String::NewSymbol((node->kind() == Token::kSUB) 717 String::ZoneHandle(String::NewSymbol((node->kind() == Token::kSUB)
718 ? Token::Str(Token::kNEGATE) 718 ? Token::Str(Token::kNEGATE)
719 : node->Name())); 719 : node->Name()));
720 InstanceCallComp* call = new InstanceCallComp( 720 InstanceCallComp* call = new InstanceCallComp(
721 node->token_index(), owner()->try_index(), name, 721 node->token_index(), owner()->try_index(), name,
722 arguments, Array::ZoneHandle(), 1); 722 arguments, Array::ZoneHandle(), 1);
723 ReturnComputation(call); 723 ReturnComputation(call);
724 } 724 }
725 725
726 726
727 void EffectGraphVisitor::VisitIncrOpLocalNode(IncrOpLocalNode* node) {
728 ASSERT((node->kind() == Token::kINCR) || (node->kind() == Token::kDECR));
729 // In an effect context, treat postincrement as if it were preincrement
730 // because its value is not needed.
731
732 // 1. Load the value.
733 BindInstr* load =
734 new BindInstr(new LoadLocalComp(node->local(), owner()->context_level()));
735 AddInstruction(load);
736 // 2. Increment.
737 Definition* incr =
738 BuildIncrOpIncrement(node->kind(), node->token_index(), new UseVal(load));
739 // 3. Perform the store, resulting in the new value.
740 StoreLocalComp* store = new StoreLocalComp(
741 node->local(), new UseVal(incr), owner()->context_level());
742 ReturnComputation(store);
743 }
744
745
746 void ValueGraphVisitor::VisitIncrOpLocalNode(IncrOpLocalNode* node) {
747 ASSERT((node->kind() == Token::kINCR) || (node->kind() == Token::kDECR));
748 if (node->prefix()) {
749 // Base class handles preincrement.
750 EffectGraphVisitor::VisitIncrOpLocalNode(node);
751 return;
752 }
753 // For postincrement, duplicate the original value to use one copy as the
754 // result.
755 //
756 // 1. Load the value.
757 BindInstr* load =
758 new BindInstr(new LoadLocalComp(node->local(), owner()->context_level()));
759 AddInstruction(load);
760 // 2. Duplicate it to increment.
761 PickTempInstr* duplicate = new PickTempInstr(load->temp_index());
762 AddInstruction(duplicate);
763 // 3. Increment.
764 Definition* incr =
765 BuildIncrOpIncrement(node->kind(), node->token_index(),
766 new UseVal(duplicate));
767 // 4. Perform the store and return the original value.
768 StoreLocalComp* store = new StoreLocalComp(
769 node->local(), new UseVal(incr), owner()->context_level());
770 AddInstruction(new DoInstr(store));
771 ReturnValue(new UseVal(load));
772 }
773
774
775 Definition* EffectGraphVisitor::BuildIncrOpFieldLoad( 727 Definition* EffectGraphVisitor::BuildIncrOpFieldLoad(
776 IncrOpInstanceFieldNode* node, 728 IncrOpInstanceFieldNode* node,
777 Value** receiver) { 729 Value** receiver) {
778 // Evaluate the receiver and duplicate it (it has two uses). 730 // Evaluate the receiver and duplicate it (it has two uses).
779 // t_n <- ... receiver ... 731 // t_n <- ... receiver ...
780 // t_n+1 <- Pick(t_n) 732 // t_n+1 <- Pick(t_n)
781 ValueGraphVisitor for_receiver(owner(), temp_index()); 733 ValueGraphVisitor for_receiver(owner(), temp_index());
782 node->receiver()->Visit(&for_receiver); 734 node->receiver()->Visit(&for_receiver);
783 Append(for_receiver); 735 Append(for_receiver);
784 ASSERT(temp_index() == for_receiver.temp_index()); 736 ASSERT(temp_index() == for_receiver.temp_index());
(...skipping 2054 matching lines...) Expand 10 before | Expand all | Expand 10 after
2839 char* chars = reinterpret_cast<char*>( 2791 char* chars = reinterpret_cast<char*>(
2840 Isolate::Current()->current_zone()->Allocate(len)); 2792 Isolate::Current()->current_zone()->Allocate(len));
2841 OS::SNPrint(chars, len, kFormat, function_name, reason); 2793 OS::SNPrint(chars, len, kFormat, function_name, reason);
2842 const Error& error = Error::Handle( 2794 const Error& error = Error::Handle(
2843 LanguageError::New(String::Handle(String::New(chars)))); 2795 LanguageError::New(String::Handle(String::New(chars))));
2844 Isolate::Current()->long_jump_base()->Jump(1, error); 2796 Isolate::Current()->long_jump_base()->Jump(1, error);
2845 } 2797 }
2846 2798
2847 2799
2848 } // namespace dart 2800 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_builder.h ('k') | runtime/vm/opt_code_generator_ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698