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

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

Issue 16146008: Simplify AST by extending LetNode and replace CommaNode. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 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/parser.cc » ('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 "lib/invocation_mirror.h" 7 #include "lib/invocation_mirror.h"
8 #include "vm/ast_printer.h" 8 #include "vm/ast_printer.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 1859 matching lines...) Expand 10 before | Expand all | Expand 10 after
1870 Append(for_value); 1870 Append(for_value);
1871 Value* temp_val = for_value.value(); 1871 Value* temp_val = for_value.value();
1872 node->TempAt(i)->set_index(GetCurrentTempLocalIndex()); 1872 node->TempAt(i)->set_index(GetCurrentTempLocalIndex());
1873 Do(new PushTempInstr(temp_val)); 1873 Do(new PushTempInstr(temp_val));
1874 AllocateTempIndex(); 1874 AllocateTempIndex();
1875 } 1875 }
1876 } 1876 }
1877 1877
1878 1878
1879 void EffectGraphVisitor::VisitLetNode(LetNode* node) { 1879 void EffectGraphVisitor::VisitLetNode(LetNode* node) {
1880 BuildLetTempExpressions(node);
1881 intptr_t num_temps = node->num_temps(); 1880 intptr_t num_temps = node->num_temps();
1881 if (num_temps > 0) {
1882 BuildLetTempExpressions(node);
1883 // TODO(fschneider): Generate better code for effect context by visiting the
1884 // body for effect. Currently, the value of the body expression is
1885 // materialized and then dropped. This also requires changing DropTempsInstr
1886 // to have zero or one inputs.
1882 1887
1883 // TODO(fschneider): Generate better code for effect context by visiting the 1888 // Visit body.
1884 // body for effect. Currently, the value of the body expression is 1889 for (intptr_t i = 0; i < node->nodes().length() - 1; ++i) {
1885 // materialized and then dropped. This also requires changing DropTempsInstr 1890 EffectGraphVisitor for_effect(owner(), temp_index());
1886 // to have zero or one inputs. 1891 node->nodes()[i]->Visit(&for_effect);
1887 ValueGraphVisitor for_value(owner(), temp_index()); 1892 Append(for_effect);
1888 node->body()->Visit(&for_value); 1893 }
1889 Append(for_value); 1894 // Visit the last body expression for value.
1890 Value* result_value = for_value.value(); 1895 ValueGraphVisitor for_value(owner(), temp_index());
1891 DeallocateTempIndex(num_temps); 1896 node->nodes()[node->nodes().length() - 1]->Visit(&for_value);
Kevin Millikin (Google) 2013/06/06 12:18:33 node->nodes()->Last()
Florian Schneider 2013/06/06 12:33:39 Done.
1892 Do(new DropTempsInstr(num_temps, result_value)); 1897 Append(for_value);
1898 Value* result_value = for_value.value();
1899 DeallocateTempIndex(num_temps);
1900 Do(new DropTempsInstr(num_temps, result_value));
1901 } else {
1902 ASSERT(num_temps == 0);
1903 for (intptr_t i = 0; i < node->nodes().length(); ++i) {
1904 EffectGraphVisitor for_effect(owner(), temp_index());
1905 node->nodes()[i]->Visit(&for_effect);
1906 Append(for_effect);
1907 }
1908 }
1893 } 1909 }
1894 1910
1895 1911
1896 void ValueGraphVisitor::VisitLetNode(LetNode* node) { 1912 void ValueGraphVisitor::VisitLetNode(LetNode* node) {
1897 BuildLetTempExpressions(node); 1913 BuildLetTempExpressions(node);
1898 1914
1915 // Visit body.
1916 for (intptr_t i = 0; i < node->nodes().length() - 1; ++i) {
1917 EffectGraphVisitor for_effect(owner(), temp_index());
1918 node->nodes()[i]->Visit(&for_effect);
1919 Append(for_effect);
1920 }
1921 // Visit the last body expression for value.
1899 ValueGraphVisitor for_value(owner(), temp_index()); 1922 ValueGraphVisitor for_value(owner(), temp_index());
1900 node->body()->Visit(&for_value); 1923 node->nodes()[node->nodes().length() - 1]->Visit(&for_value);
Kevin Millikin (Google) 2013/06/06 12:18:33 Also here.
Florian Schneider 2013/06/06 12:33:39 Done.
1901 Append(for_value); 1924 Append(for_value);
1902 Value* result_value = for_value.value(); 1925 Value* result_value = for_value.value();
1926
1903 intptr_t num_temps = node->num_temps(); 1927 intptr_t num_temps = node->num_temps();
1904 if (num_temps > 0) { 1928 if (num_temps > 0) {
1905 DeallocateTempIndex(num_temps); 1929 DeallocateTempIndex(num_temps);
1906 ReturnDefinition(new DropTempsInstr(num_temps, result_value)); 1930 ReturnDefinition(new DropTempsInstr(num_temps, result_value));
1907 } else { 1931 } else {
1908 ReturnValue(result_value); 1932 ReturnValue(result_value);
1909 } 1933 }
1910 } 1934 }
1911 1935
1912 1936
(...skipping 1295 matching lines...) Expand 10 before | Expand all | Expand 10 after
3208 AddInstruction( 3232 AddInstruction(
3209 new CatchEntryInstr(node->exception_var(), node->stacktrace_var())); 3233 new CatchEntryInstr(node->exception_var(), node->stacktrace_var()));
3210 BuildLoadContext(node->context_var()); 3234 BuildLoadContext(node->context_var());
3211 3235
3212 EffectGraphVisitor for_catch(owner(), temp_index()); 3236 EffectGraphVisitor for_catch(owner(), temp_index());
3213 node->VisitChildren(&for_catch); 3237 node->VisitChildren(&for_catch);
3214 Append(for_catch); 3238 Append(for_catch);
3215 } 3239 }
3216 3240
3217 3241
3218 void EffectGraphVisitor::VisitCommaNode(CommaNode* node) {
3219 EffectGraphVisitor for_effect_first(owner(), temp_index());
3220 node->first()->Visit(&for_effect_first);
3221 Append(for_effect_first);
3222
3223 EffectGraphVisitor for_effect_second(owner(), temp_index());
3224 node->second()->Visit(&for_effect_second);
3225 Append(for_effect_second);
3226 }
3227
3228
3229 void ValueGraphVisitor::VisitCommaNode(CommaNode* node) {
3230 EffectGraphVisitor for_effect(owner(), temp_index());
3231 node->first()->Visit(&for_effect);
3232 Append(for_effect);
3233
3234 ValueGraphVisitor for_value(owner(), temp_index());
3235 node->second()->Visit(&for_value);
3236 Append(for_value);
3237 ReturnValue(for_value.value());
3238 }
3239
3240
3241 void EffectGraphVisitor::VisitTryCatchNode(TryCatchNode* node) { 3242 void EffectGraphVisitor::VisitTryCatchNode(TryCatchNode* node) {
3242 InlineBailout("EffectGraphVisitor::VisitTryCatchNode (exception)"); 3243 InlineBailout("EffectGraphVisitor::VisitTryCatchNode (exception)");
3243 intptr_t old_try_index = owner()->try_index(); 3244 intptr_t old_try_index = owner()->try_index();
3244 intptr_t try_index = owner()->AllocateTryIndex(); 3245 intptr_t try_index = owner()->AllocateTryIndex();
3245 owner()->set_try_index(try_index); 3246 owner()->set_try_index(try_index);
3246 3247
3247 // Preserve CTX into local variable '%saved_context'. 3248 // Preserve CTX into local variable '%saved_context'.
3248 BuildStoreContext(node->context_var()); 3249 BuildStoreContext(node->context_var());
3249 3250
3250 EffectGraphVisitor for_try_block(owner(), temp_index()); 3251 EffectGraphVisitor for_try_block(owner(), temp_index());
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
3489 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; 3490 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1;
3490 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 3491 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
3491 OS::SNPrint(chars, len, kFormat, function_name, reason); 3492 OS::SNPrint(chars, len, kFormat, function_name, reason);
3492 const Error& error = Error::Handle( 3493 const Error& error = Error::Handle(
3493 LanguageError::New(String::Handle(String::New(chars)))); 3494 LanguageError::New(String::Handle(String::New(chars))));
3494 Isolate::Current()->long_jump_base()->Jump(1, error); 3495 Isolate::Current()->long_jump_base()->Jump(1, error);
3495 } 3496 }
3496 3497
3497 3498
3498 } // namespace dart 3499 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_builder.h ('k') | runtime/vm/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698