| 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/dart_entry.h" | 8 #include "vm/dart_entry.h" |
| 9 #include "vm/flags.h" | 9 #include "vm/flags.h" |
| 10 #include "vm/intermediate_language.h" | 10 #include "vm/intermediate_language.h" |
| (...skipping 1825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1836 void EffectGraphVisitor::VisitCatchClauseNode(CatchClauseNode* node) { | 1836 void EffectGraphVisitor::VisitCatchClauseNode(CatchClauseNode* node) { |
| 1837 Bailout("EffectGraphVisitor::VisitCatchClauseNode"); | 1837 Bailout("EffectGraphVisitor::VisitCatchClauseNode"); |
| 1838 } | 1838 } |
| 1839 | 1839 |
| 1840 | 1840 |
| 1841 void EffectGraphVisitor::VisitTryCatchNode(TryCatchNode* node) { | 1841 void EffectGraphVisitor::VisitTryCatchNode(TryCatchNode* node) { |
| 1842 Bailout("EffectGraphVisitor::VisitTryCatchNode"); | 1842 Bailout("EffectGraphVisitor::VisitTryCatchNode"); |
| 1843 } | 1843 } |
| 1844 | 1844 |
| 1845 | 1845 |
| 1846 void EffectGraphVisitor::VisitThrowNode(ThrowNode* node) { | 1846 void EffectGraphVisitor::BuildThrowNode(ThrowNode* node) { |
| 1847 ValueGraphVisitor for_exception(owner(), temp_index()); | 1847 ValueGraphVisitor for_exception(owner(), temp_index()); |
| 1848 node->exception()->Visit(&for_exception); | 1848 node->exception()->Visit(&for_exception); |
| 1849 Append(for_exception); | 1849 Append(for_exception); |
| 1850 Instruction* instr = NULL; | 1850 Instruction* instr = NULL; |
| 1851 if (node->stacktrace() == NULL) { | 1851 if (node->stacktrace() == NULL) { |
| 1852 instr = new ThrowInstr( | 1852 instr = new ThrowInstr( |
| 1853 node->id(), node->token_index(), for_exception.value()); | 1853 node->id(), node->token_index(), for_exception.value()); |
| 1854 } else { | 1854 } else { |
| 1855 ValueGraphVisitor for_stack_trace(owner(), temp_index() + 1); | 1855 ValueGraphVisitor for_stack_trace(owner(), temp_index() + 1); |
| 1856 node->stacktrace()->Visit(&for_stack_trace); | 1856 node->stacktrace()->Visit(&for_stack_trace); |
| 1857 Append(for_stack_trace); | 1857 Append(for_stack_trace); |
| 1858 instr = new ReThrowInstr(node->id(), | 1858 instr = new ReThrowInstr(node->id(), |
| 1859 node->token_index(), | 1859 node->token_index(), |
| 1860 for_exception.value(), | 1860 for_exception.value(), |
| 1861 for_stack_trace.value()); | 1861 for_stack_trace.value()); |
| 1862 } | 1862 } |
| 1863 AddInstruction(instr); | 1863 AddInstruction(instr); |
| 1864 } |
| 1865 |
| 1866 |
| 1867 void EffectGraphVisitor::VisitThrowNode(ThrowNode* node) { |
| 1868 BuildThrowNode(node); |
| 1864 CloseFragment(); | 1869 CloseFragment(); |
| 1865 } | 1870 } |
| 1866 | 1871 |
| 1867 | 1872 |
| 1873 // A throw cannot be part of an expression, however, the parser may replace |
| 1874 // certain expression nodes with a throw. In that case generate a literal null |
| 1875 // so that the fragment is not closed in the middle of an expression. |
| 1876 void ValueGraphVisitor::VisitThrowNode(ThrowNode* node) { |
| 1877 BuildThrowNode(node); |
| 1878 ReturnValue(new ConstantVal(Instance::ZoneHandle())); |
| 1879 } |
| 1880 |
| 1881 |
| 1868 void EffectGraphVisitor::VisitInlinedFinallyNode(InlinedFinallyNode* node) { | 1882 void EffectGraphVisitor::VisitInlinedFinallyNode(InlinedFinallyNode* node) { |
| 1869 Bailout("EffectGraphVisitor::VisitInlinedFinallyNode"); | 1883 Bailout("EffectGraphVisitor::VisitInlinedFinallyNode"); |
| 1870 } | 1884 } |
| 1871 | 1885 |
| 1872 | 1886 |
| 1873 // Graph printing. | 1887 // Graph printing. |
| 1874 class FlowGraphPrinter : public FlowGraphVisitor { | 1888 class FlowGraphPrinter : public FlowGraphVisitor { |
| 1875 public: | 1889 public: |
| 1876 FlowGraphPrinter(const Function& function, | 1890 FlowGraphPrinter(const Function& function, |
| 1877 const GrowableArray<BlockEntryInstr*>& block_order) | 1891 const GrowableArray<BlockEntryInstr*>& block_order) |
| (...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2366 char* chars = reinterpret_cast<char*>( | 2380 char* chars = reinterpret_cast<char*>( |
| 2367 Isolate::Current()->current_zone()->Allocate(len)); | 2381 Isolate::Current()->current_zone()->Allocate(len)); |
| 2368 OS::SNPrint(chars, len, kFormat, function_name, reason); | 2382 OS::SNPrint(chars, len, kFormat, function_name, reason); |
| 2369 const Error& error = Error::Handle( | 2383 const Error& error = Error::Handle( |
| 2370 LanguageError::New(String::Handle(String::New(chars)))); | 2384 LanguageError::New(String::Handle(String::New(chars)))); |
| 2371 Isolate::Current()->long_jump_base()->Jump(1, error); | 2385 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 2372 } | 2386 } |
| 2373 | 2387 |
| 2374 | 2388 |
| 2375 } // namespace dart | 2389 } // namespace dart |
| OLD | NEW |