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

Side by Side Diff: vm/flow_graph_builder.cc

Issue 10836239: Change indexed load and store IL instructions to fit with SSA backend. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 4 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 2015 matching lines...) Expand 10 before | Expand all | Expand 10 after
2026 type, 2026 type,
2027 dst_name); 2027 dst_name);
2028 } 2028 }
2029 StoreStaticFieldComp* store = 2029 StoreStaticFieldComp* store =
2030 new StoreStaticFieldComp(node->field(), store_value); 2030 new StoreStaticFieldComp(node->field(), store_value);
2031 ReturnComputation(store); 2031 ReturnComputation(store);
2032 } 2032 }
2033 2033
2034 2034
2035 void EffectGraphVisitor::VisitLoadIndexedNode(LoadIndexedNode* node) { 2035 void EffectGraphVisitor::VisitLoadIndexedNode(LoadIndexedNode* node) {
2036 ZoneGrowableArray<PushArgumentInstr*>* arguments =
2037 new ZoneGrowableArray<PushArgumentInstr*>(2);
2036 ValueGraphVisitor for_array(owner(), temp_index()); 2038 ValueGraphVisitor for_array(owner(), temp_index());
2037 node->array()->Visit(&for_array); 2039 node->array()->Visit(&for_array);
2038 Append(for_array); 2040 Append(for_array);
2039 ValueGraphVisitor for_index(owner(), for_array.temp_index()); 2041 arguments->Add(PushArgument(for_array.value()));
2042
2043 ValueGraphVisitor for_index(owner(), temp_index());
2040 node->index_expr()->Visit(&for_index); 2044 node->index_expr()->Visit(&for_index);
2041 Append(for_index); 2045 Append(for_index);
2046 arguments->Add(PushArgument(for_index.value()));
2042 2047
2043 LoadIndexedComp* load = new LoadIndexedComp( 2048 const intptr_t checked_argument_count = 1;
2044 node->token_pos(), 2049 const String& name =
2045 owner()->try_index(), 2050 String::ZoneHandle(Symbols::New(Token::Str(Token::kINDEX)));
2046 for_array.value(), 2051 InstanceCallComp* load = new InstanceCallComp(node->token_pos(),
2047 for_index.value()); 2052 owner()->try_index(),
2053 name,
2054 Token::kINDEX,
2055 arguments,
2056 Array::ZoneHandle(),
2057 checked_argument_count);
2048 ReturnComputation(load); 2058 ReturnComputation(load);
2049 } 2059 }
2050 2060
2051 2061
2052 void EffectGraphVisitor::BuildStoreIndexedValues( 2062 Computation* EffectGraphVisitor::BuildStoreIndexedValues(
2053 StoreIndexedNode* node, Value** array, Value** index, Value** value) { 2063 StoreIndexedNode* node,
2064 bool result_is_needed) {
2065 ZoneGrowableArray<PushArgumentInstr*>* arguments =
2066 new ZoneGrowableArray<PushArgumentInstr*>(3);
2054 ValueGraphVisitor for_array(owner(), temp_index()); 2067 ValueGraphVisitor for_array(owner(), temp_index());
2055 node->array()->Visit(&for_array); 2068 node->array()->Visit(&for_array);
2056 Append(for_array); 2069 Append(for_array);
2057 ValueGraphVisitor for_index(owner(), for_array.temp_index()); 2070 arguments->Add(PushArgument(for_array.value()));
2071
2072 ValueGraphVisitor for_index(owner(), temp_index());
2058 node->index_expr()->Visit(&for_index); 2073 node->index_expr()->Visit(&for_index);
2059 Append(for_index); 2074 Append(for_index);
2060 ValueGraphVisitor for_value(owner(), for_index.temp_index()); 2075 arguments->Add(PushArgument(for_index.value()));
2076
2077 ValueGraphVisitor for_value(owner(), temp_index());
2061 node->value()->Visit(&for_value); 2078 node->value()->Visit(&for_value);
2062 Append(for_value); 2079 Append(for_value);
2063 *array = for_array.value(); 2080 Value* value = NULL;
2064 *index = for_index.value(); 2081 if (result_is_needed) {
2065 *value = for_value.value(); 2082 value = Bind(
2083 BuildStoreLocal(*owner()->parsed_function().expression_temp_var(),
2084 for_value.value()));
2085 } else {
2086 value = for_value.value();
2087 }
2088 arguments->Add(PushArgument(value));
2089
2090 const intptr_t checked_argument_count = 1;
2091 const String& name =
2092 String::ZoneHandle(Symbols::New(Token::Str(Token::kASSIGN_INDEX)));
2093 InstanceCallComp* store = new InstanceCallComp(node->token_pos(),
2094 owner()->try_index(),
2095 name,
2096 Token::kASSIGN_INDEX,
2097 arguments,
2098 Array::ZoneHandle(),
2099 checked_argument_count);
2100 if (result_is_needed) {
2101 Do(store);
2102 return BuildLoadLocal(*owner()->parsed_function().expression_temp_var());
2103 } else {
2104 return store;
2105 }
2066 } 2106 }
2067 2107
2068 2108
2069 void EffectGraphVisitor::VisitStoreIndexedNode(StoreIndexedNode* node) { 2109 void EffectGraphVisitor::VisitStoreIndexedNode(StoreIndexedNode* node) {
2070 Value *array, *index, *value; 2110 ReturnComputation(BuildStoreIndexedValues(node,
2071 BuildStoreIndexedValues(node, &array, &index, &value); 2111 false)); // Result not needed.
Vyacheslav Egorov (Google) 2012/08/15 13:16:09 It's not the first place where we pass boolean as
Florian Schneider 2012/08/15 13:53:51 Since there is only two very localized call-sites
2072 StoreIndexedComp* store = new StoreIndexedComp(node->token_pos(),
2073 owner()->try_index(),
2074 array,
2075 index,
2076 value);
2077 ReturnComputation(store);
2078 } 2112 }
2079 2113
2080 2114
2081 void ValueGraphVisitor::VisitStoreIndexedNode(StoreIndexedNode* node) { 2115 void ValueGraphVisitor::VisitStoreIndexedNode(StoreIndexedNode* node) {
2082 Value *array, *index, *value; 2116 ReturnComputation(BuildStoreIndexedValues(node,
2083 BuildStoreIndexedValues(node, &array, &index, &value); 2117 true)); // Result is needed.
2084 Value* saved_value = Bind(
2085 BuildStoreLocal(*owner()->parsed_function().expression_temp_var(),
2086 value));
2087 Do(new StoreIndexedComp(node->token_pos(),
2088 owner()->try_index(),
2089 array,
2090 index,
2091 saved_value));
2092 ReturnComputation(
2093 BuildLoadLocal(*owner()->parsed_function().expression_temp_var()));
2094 } 2118 }
2095 2119
2096 2120
2097 bool EffectGraphVisitor::MustSaveRestoreContext(SequenceNode* node) const { 2121 bool EffectGraphVisitor::MustSaveRestoreContext(SequenceNode* node) const {
2098 return (node == owner()->parsed_function().node_sequence()) && 2122 return (node == owner()->parsed_function().node_sequence()) &&
2099 (owner()->parsed_function().saved_context_var() != NULL); 2123 (owner()->parsed_function().saved_context_var() != NULL);
2100 } 2124 }
2101 2125
2102 2126
2103 void EffectGraphVisitor::UnchainContext() { 2127 void EffectGraphVisitor::UnchainContext() {
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after
2823 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; 2847 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1;
2824 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 2848 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
2825 OS::SNPrint(chars, len, kFormat, function_name, reason); 2849 OS::SNPrint(chars, len, kFormat, function_name, reason);
2826 const Error& error = Error::Handle( 2850 const Error& error = Error::Handle(
2827 LanguageError::New(String::Handle(String::New(chars)))); 2851 LanguageError::New(String::Handle(String::New(chars))));
2828 Isolate::Current()->long_jump_base()->Jump(1, error); 2852 Isolate::Current()->long_jump_base()->Jump(1, error);
2829 } 2853 }
2830 2854
2831 2855
2832 } // namespace dart 2856 } // namespace dart
OLDNEW
« no previous file with comments | « vm/flow_graph_builder.h ('k') | vm/flow_graph_compiler.cc » ('j') | vm/flow_graph_optimizer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698