| 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 1930 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1941 if ((node->end_catch_label() != NULL) && | 1941 if ((node->end_catch_label() != NULL) && |
| 1942 (node->end_catch_label()->join_for_continue() != NULL)) { | 1942 (node->end_catch_label()->join_for_continue() != NULL)) { |
| 1943 if (is_open()) { | 1943 if (is_open()) { |
| 1944 AddInstruction(node->end_catch_label()->join_for_continue()); | 1944 AddInstruction(node->end_catch_label()->join_for_continue()); |
| 1945 } else { | 1945 } else { |
| 1946 exit_ = node->end_catch_label()->join_for_continue(); | 1946 exit_ = node->end_catch_label()->join_for_continue(); |
| 1947 } | 1947 } |
| 1948 } | 1948 } |
| 1949 } | 1949 } |
| 1950 | 1950 |
| 1951 if (node->finally_block() != NULL) { | 1951 // Generate code for the finally block if one exists. |
| 1952 Bailout("EffectGraphVisitor::VisitTryCatchNode finally"); | 1952 if ((node->finally_block() != NULL) && is_open()) { |
| 1953 EffectGraphVisitor for_finally_block(owner(), temp_index()); |
| 1954 node->finally_block()->Visit(&for_finally_block); |
| 1955 Append(for_finally_block); |
| 1953 } | 1956 } |
| 1954 } | 1957 } |
| 1955 | 1958 |
| 1956 | 1959 |
| 1957 void EffectGraphVisitor::BuildThrowNode(ThrowNode* node) { | 1960 void EffectGraphVisitor::BuildThrowNode(ThrowNode* node) { |
| 1958 ValueGraphVisitor for_exception(owner(), temp_index()); | 1961 ValueGraphVisitor for_exception(owner(), temp_index()); |
| 1959 node->exception()->Visit(&for_exception); | 1962 node->exception()->Visit(&for_exception); |
| 1960 Append(for_exception); | 1963 Append(for_exception); |
| 1961 Instruction* instr = NULL; | 1964 Instruction* instr = NULL; |
| 1962 if (node->stacktrace() == NULL) { | 1965 if (node->stacktrace() == NULL) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1987 // A throw cannot be part of an expression, however, the parser may replace | 1990 // A throw cannot be part of an expression, however, the parser may replace |
| 1988 // certain expression nodes with a throw. In that case generate a literal null | 1991 // certain expression nodes with a throw. In that case generate a literal null |
| 1989 // so that the fragment is not closed in the middle of an expression. | 1992 // so that the fragment is not closed in the middle of an expression. |
| 1990 void ValueGraphVisitor::VisitThrowNode(ThrowNode* node) { | 1993 void ValueGraphVisitor::VisitThrowNode(ThrowNode* node) { |
| 1991 BuildThrowNode(node); | 1994 BuildThrowNode(node); |
| 1992 ReturnValue(new ConstantVal(Instance::ZoneHandle())); | 1995 ReturnValue(new ConstantVal(Instance::ZoneHandle())); |
| 1993 } | 1996 } |
| 1994 | 1997 |
| 1995 | 1998 |
| 1996 void EffectGraphVisitor::VisitInlinedFinallyNode(InlinedFinallyNode* node) { | 1999 void EffectGraphVisitor::VisitInlinedFinallyNode(InlinedFinallyNode* node) { |
| 1997 Bailout("EffectGraphVisitor::VisitInlinedFinallyNode"); | 2000 const intptr_t try_index = owner()->try_index(); |
| 2001 if (try_index >= 0) { |
| 2002 // We are about to generate code for an inlined finally block. Exceptions |
| 2003 // thrown in this block of code should be treated as though they are |
| 2004 // thrown not from the current try block but the outer try block if any. |
| 2005 owner()->set_try_index((try_index - 1)); |
| 2006 } |
| 2007 BuildLoadContext(node->context_var(), temp_index()); |
| 2008 EffectGraphVisitor for_finally_block(owner(), temp_index()); |
| 2009 node->finally_block()->Visit(&for_finally_block); |
| 2010 Append(for_finally_block); |
| 2011 if (try_index >= 0) { |
| 2012 owner()->set_try_index(try_index); |
| 2013 } |
| 1998 } | 2014 } |
| 1999 | 2015 |
| 2000 | 2016 |
| 2001 // Graph printing. | 2017 // Graph printing. |
| 2002 class FlowGraphPrinter : public FlowGraphVisitor { | 2018 class FlowGraphPrinter : public FlowGraphVisitor { |
| 2003 public: | 2019 public: |
| 2004 FlowGraphPrinter(const Function& function, | 2020 FlowGraphPrinter(const Function& function, |
| 2005 const GrowableArray<BlockEntryInstr*>& block_order) | 2021 const GrowableArray<BlockEntryInstr*>& block_order) |
| 2006 : FlowGraphVisitor(block_order), function_(function) { } | 2022 : FlowGraphVisitor(block_order), function_(function) { } |
| 2007 | 2023 |
| (...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2513 char* chars = reinterpret_cast<char*>( | 2529 char* chars = reinterpret_cast<char*>( |
| 2514 Isolate::Current()->current_zone()->Allocate(len)); | 2530 Isolate::Current()->current_zone()->Allocate(len)); |
| 2515 OS::SNPrint(chars, len, kFormat, function_name, reason); | 2531 OS::SNPrint(chars, len, kFormat, function_name, reason); |
| 2516 const Error& error = Error::Handle( | 2532 const Error& error = Error::Handle( |
| 2517 LanguageError::New(String::Handle(String::New(chars)))); | 2533 LanguageError::New(String::Handle(String::New(chars)))); |
| 2518 Isolate::Current()->long_jump_base()->Jump(1, error); | 2534 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 2519 } | 2535 } |
| 2520 | 2536 |
| 2521 | 2537 |
| 2522 } // namespace dart | 2538 } // namespace dart |
| OLD | NEW |