| 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/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 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 721 String::ZoneHandle(String::NewSymbol((node->kind() == Token::kSUB) | 721 String::ZoneHandle(String::NewSymbol((node->kind() == Token::kSUB) |
| 722 ? Token::Str(Token::kNEGATE) | 722 ? Token::Str(Token::kNEGATE) |
| 723 : node->Name())); | 723 : node->Name())); |
| 724 InstanceCallComp* call = new InstanceCallComp( | 724 InstanceCallComp* call = new InstanceCallComp( |
| 725 node->token_index(), owner()->try_index(), name, | 725 node->token_index(), owner()->try_index(), name, |
| 726 arguments, Array::ZoneHandle(), 1); | 726 arguments, Array::ZoneHandle(), 1); |
| 727 ReturnComputation(call); | 727 ReturnComputation(call); |
| 728 } | 728 } |
| 729 | 729 |
| 730 | 730 |
| 731 void EffectGraphVisitor::VisitIncrOpLocalNode(IncrOpLocalNode* node) { | |
| 732 ASSERT((node->kind() == Token::kINCR) || (node->kind() == Token::kDECR)); | |
| 733 // In an effect context, treat postincrement as if it were preincrement | |
| 734 // because its value is not needed. | |
| 735 | |
| 736 // 1. Load the value. | |
| 737 BindInstr* load = | |
| 738 new BindInstr(temp_index(), | |
| 739 new LoadLocalComp(node->local(), owner()->context_level())); | |
| 740 AddInstruction(load); | |
| 741 AllocateTempIndex(); | |
| 742 // 2. Increment. | |
| 743 Definition* incr = | |
| 744 BuildIncrOpIncrement(node->kind(), node->token_index(), new UseVal(load)); | |
| 745 // 3. Perform the store, resulting in the new value. | |
| 746 DeallocateTempIndex(); // Consuming incr. | |
| 747 StoreLocalComp* store = new StoreLocalComp( | |
| 748 node->local(), new UseVal(incr), owner()->context_level()); | |
| 749 ReturnComputation(store); | |
| 750 } | |
| 751 | |
| 752 | |
| 753 void ValueGraphVisitor::VisitIncrOpLocalNode(IncrOpLocalNode* node) { | |
| 754 ASSERT((node->kind() == Token::kINCR) || (node->kind() == Token::kDECR)); | |
| 755 if (node->prefix()) { | |
| 756 // Base class handles preincrement. | |
| 757 EffectGraphVisitor::VisitIncrOpLocalNode(node); | |
| 758 return; | |
| 759 } | |
| 760 // For postincrement, duplicate the original value to use one copy as the | |
| 761 // result. | |
| 762 // | |
| 763 // 1. Load the value. | |
| 764 BindInstr* load = | |
| 765 new BindInstr(temp_index(), | |
| 766 new LoadLocalComp(node->local(), owner()->context_level())); | |
| 767 AddInstruction(load); | |
| 768 AllocateTempIndex(); | |
| 769 // 2. Duplicate it to increment. | |
| 770 PickTempInstr* duplicate = | |
| 771 new PickTempInstr(temp_index(), load->temp_index()); | |
| 772 AddInstruction(duplicate); | |
| 773 AllocateTempIndex(); | |
| 774 // 3. Increment. | |
| 775 Definition* incr = | |
| 776 BuildIncrOpIncrement(node->kind(), node->token_index(), | |
| 777 new UseVal(duplicate)); | |
| 778 // 4. Perform the store and return the original value. | |
| 779 DeallocateTempIndex(); // Consuming incr. | |
| 780 StoreLocalComp* store = new StoreLocalComp( | |
| 781 node->local(), new UseVal(incr), owner()->context_level()); | |
| 782 AddInstruction(new DoInstr(store)); | |
| 783 ReturnValue(new UseVal(load)); | |
| 784 } | |
| 785 | |
| 786 | |
| 787 Definition* EffectGraphVisitor::BuildIncrOpFieldLoad( | 731 Definition* EffectGraphVisitor::BuildIncrOpFieldLoad( |
| 788 IncrOpInstanceFieldNode* node, | 732 IncrOpInstanceFieldNode* node, |
| 789 Value** receiver) { | 733 Value** receiver) { |
| 790 // Evaluate the receiver and duplicate it (it has two uses). | 734 // Evaluate the receiver and duplicate it (it has two uses). |
| 791 // t_n <- ... receiver ... | 735 // t_n <- ... receiver ... |
| 792 // t_n+1 <- Pick(t_n) | 736 // t_n+1 <- Pick(t_n) |
| 793 ValueGraphVisitor for_receiver(owner(), temp_index()); | 737 ValueGraphVisitor for_receiver(owner(), temp_index()); |
| 794 node->receiver()->Visit(&for_receiver); | 738 node->receiver()->Visit(&for_receiver); |
| 795 Append(for_receiver); | 739 Append(for_receiver); |
| 796 AllocateTempIndex(); | 740 AllocateTempIndex(); |
| (...skipping 2131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2928 char* chars = reinterpret_cast<char*>( | 2872 char* chars = reinterpret_cast<char*>( |
| 2929 Isolate::Current()->current_zone()->Allocate(len)); | 2873 Isolate::Current()->current_zone()->Allocate(len)); |
| 2930 OS::SNPrint(chars, len, kFormat, function_name, reason); | 2874 OS::SNPrint(chars, len, kFormat, function_name, reason); |
| 2931 const Error& error = Error::Handle( | 2875 const Error& error = Error::Handle( |
| 2932 LanguageError::New(String::Handle(String::New(chars)))); | 2876 LanguageError::New(String::Handle(String::New(chars)))); |
| 2933 Isolate::Current()->long_jump_base()->Jump(1, error); | 2877 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 2934 } | 2878 } |
| 2935 | 2879 |
| 2936 | 2880 |
| 2937 } // namespace dart | 2881 } // namespace dart |
| OLD | NEW |