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

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

Issue 9699090: Make Throw and ReThrow instructions instead of computations. That way they can terminate a basic bl… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 9 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 | « no previous file | runtime/vm/flow_graph_compiler_x64.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 "vm/ast_printer.h" 7 #include "vm/ast_printer.h"
8 #include "vm/flags.h" 8 #include "vm/flags.h"
9 #include "vm/intermediate_language.h" 9 #include "vm/intermediate_language.h"
10 #include "vm/longjump.h" 10 #include "vm/longjump.h"
(...skipping 1256 matching lines...) Expand 10 before | Expand all | Expand 10 after
1267 for_index.value(), 1267 for_index.value(),
1268 for_value.value()); 1268 for_value.value());
1269 ReturnComputation(store); 1269 ReturnComputation(store);
1270 } 1270 }
1271 1271
1272 1272
1273 // <Statement> ::= Sequence { scope: LocalScope 1273 // <Statement> ::= Sequence { scope: LocalScope
1274 // nodes: <Statement>* 1274 // nodes: <Statement>*
1275 // label: SourceLabel } 1275 // label: SourceLabel }
1276 void EffectGraphVisitor::VisitSequenceNode(SequenceNode* node) { 1276 void EffectGraphVisitor::VisitSequenceNode(SequenceNode* node) {
1277 if (FLAG_enable_type_checks &&
1278 (node == owner()->parsed_function().node_sequence())) {
1279 Bailout("VisitSequenceNode GenerateArgumentTypeChecks()");
1280 }
1277 if ((node->scope() != NULL) && 1281 if ((node->scope() != NULL) &&
1278 (node->scope()->num_context_variables() != 0)) { 1282 (node->scope()->num_context_variables() != 0)) {
1279 Bailout("Sequence needs a context. Gotta have a context."); 1283 Bailout("Sequence needs a context. Gotta have a context.");
1280 } 1284 }
1281 intptr_t i = 0; 1285 intptr_t i = 0;
1282 while (is_open() && (i < node->length())) { 1286 while (is_open() && (i < node->length())) {
1283 EffectGraphVisitor for_effect(owner(), temp_index()); 1287 EffectGraphVisitor for_effect(owner(), temp_index());
1284 node->NodeAt(i++)->Visit(&for_effect); 1288 node->NodeAt(i++)->Visit(&for_effect);
1285 Append(for_effect); 1289 Append(for_effect);
1286 } 1290 }
1287 } 1291 }
1288 1292
1289 1293
1290 void EffectGraphVisitor::VisitCatchClauseNode(CatchClauseNode* node) { 1294 void EffectGraphVisitor::VisitCatchClauseNode(CatchClauseNode* node) {
1291 Bailout("EffectGraphVisitor::VisitCatchClauseNode"); 1295 Bailout("EffectGraphVisitor::VisitCatchClauseNode");
1292 } 1296 }
1293 1297
1294 1298
1295 void EffectGraphVisitor::VisitTryCatchNode(TryCatchNode* node) { 1299 void EffectGraphVisitor::VisitTryCatchNode(TryCatchNode* node) {
1296 Bailout("EffectGraphVisitor::VisitTryCatchNode"); 1300 Bailout("EffectGraphVisitor::VisitTryCatchNode");
1297 } 1301 }
1298 1302
1299 1303
1300 void EffectGraphVisitor::VisitThrowNode(ThrowNode* node) { 1304 void EffectGraphVisitor::VisitThrowNode(ThrowNode* node) {
1301 ValueGraphVisitor for_exception(owner(), temp_index()); 1305 ValueGraphVisitor for_exception(owner(), temp_index());
1302 node->exception()->Visit(&for_exception); 1306 node->exception()->Visit(&for_exception);
1303 Append(for_exception); 1307 Append(for_exception);
1308 Instruction* instr = NULL;
1304 if (node->stacktrace() == NULL) { 1309 if (node->stacktrace() == NULL) {
1305 ThrowComp* comp = 1310 instr = new ThrowInstr(
1306 new ThrowComp(node->id(), node->token_index(), for_exception.value()); 1311 node->id(), node->token_index(), for_exception.value());
1307 AddInstruction(new DoInstr(comp));
1308 } else { 1312 } else {
1309 ValueGraphVisitor for_stack_trace(owner(), temp_index() + 1); 1313 ValueGraphVisitor for_stack_trace(owner(), temp_index() + 1);
1310 node->stacktrace()->Visit(&for_stack_trace); 1314 node->stacktrace()->Visit(&for_stack_trace);
1311 Append(for_stack_trace); 1315 Append(for_stack_trace);
1312 ReThrowComp* comp = new ReThrowComp(node->id(), 1316 instr = new ReThrowInstr(node->id(),
1313 node->token_index(), 1317 node->token_index(),
1314 for_exception.value(), 1318 for_exception.value(),
1315 for_stack_trace.value()); 1319 for_stack_trace.value());
1316 AddInstruction(new DoInstr(comp));
1317 } 1320 }
1321 AddInstruction(instr);
1322 CloseFragment();
1318 } 1323 }
1319 1324
1320 1325
1321 void EffectGraphVisitor::VisitInlinedFinallyNode(InlinedFinallyNode* node) { 1326 void EffectGraphVisitor::VisitInlinedFinallyNode(InlinedFinallyNode* node) {
1322 Bailout("EffectGraphVisitor::VisitInlinedFinallyNode"); 1327 Bailout("EffectGraphVisitor::VisitInlinedFinallyNode");
1323 } 1328 }
1324 1329
1325 1330
1326 // Graph printing. 1331 // Graph printing.
1327 class FlowGraphPrinter : public FlowGraphVisitor { 1332 class FlowGraphPrinter : public FlowGraphVisitor {
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
1546 } 1551 }
1547 OS::Print(")"); 1552 OS::Print(")");
1548 } 1553 }
1549 1554
1550 1555
1551 void FlowGraphPrinter::VisitCreateClosure(CreateClosureComp* comp) { 1556 void FlowGraphPrinter::VisitCreateClosure(CreateClosureComp* comp) {
1552 OS::Print("CreateClosure(%s)", comp->function().ToCString()); 1557 OS::Print("CreateClosure(%s)", comp->function().ToCString());
1553 } 1558 }
1554 1559
1555 1560
1556 void FlowGraphPrinter::VisitThrow(ThrowComp* comp) {
1557 OS::Print("Throw(");
1558 comp->exception()->Accept(this);
1559 OS::Print(")");
1560 }
1561
1562
1563 void FlowGraphPrinter::VisitReThrow(ReThrowComp* comp) {
1564 OS::Print("ReThrow(");
1565 comp->exception()->Accept(this);
1566 OS::Print(", ");
1567 comp->stack_trace()->Accept(this);
1568 OS::Print(")");
1569 }
1570
1571
1572 void FlowGraphPrinter::VisitNativeLoadField(NativeLoadFieldComp* comp) { 1561 void FlowGraphPrinter::VisitNativeLoadField(NativeLoadFieldComp* comp) {
1573 OS::Print("NativeLoadField("); 1562 OS::Print("NativeLoadField(");
1574 comp->value()->Accept(this); 1563 comp->value()->Accept(this);
1575 OS::Print(", %d)", comp->offset_in_bytes()); 1564 OS::Print(", %d)", comp->offset_in_bytes());
1576 } 1565 }
1577 1566
1578 1567
1579 void FlowGraphPrinter::VisitExtractFactoryTypeArguments( 1568 void FlowGraphPrinter::VisitExtractFactoryTypeArguments(
1580 ExtractFactoryTypeArgumentsComp* comp) { 1569 ExtractFactoryTypeArgumentsComp* comp) {
1581 OS::Print("ExtractFactoryTypeArguments("); 1570 OS::Print("ExtractFactoryTypeArguments(");
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1633 instr->computation()->Accept(this); 1622 instr->computation()->Accept(this);
1634 } 1623 }
1635 1624
1636 1625
1637 void FlowGraphPrinter::VisitReturn(ReturnInstr* instr) { 1626 void FlowGraphPrinter::VisitReturn(ReturnInstr* instr) {
1638 OS::Print(" return "); 1627 OS::Print(" return ");
1639 instr->value()->Accept(this); 1628 instr->value()->Accept(this);
1640 } 1629 }
1641 1630
1642 1631
1632 void FlowGraphPrinter::VisitThrow(ThrowInstr* instr) {
1633 OS::Print("Throw(");
1634 instr->exception()->Accept(this);
1635 OS::Print(")");
1636 }
1637
1638
1639 void FlowGraphPrinter::VisitReThrow(ReThrowInstr* instr) {
1640 OS::Print("ReThrow(");
1641 instr->exception()->Accept(this);
1642 OS::Print(", ");
1643 instr->stack_trace()->Accept(this);
1644 OS::Print(")");
1645 }
1646
1647
1643 void FlowGraphPrinter::VisitBranch(BranchInstr* instr) { 1648 void FlowGraphPrinter::VisitBranch(BranchInstr* instr) {
1644 OS::Print(" if "); 1649 OS::Print(" if ");
1645 instr->value()->Accept(this); 1650 instr->value()->Accept(this);
1646 OS::Print(" goto(%d, %d)", instr->true_successor()->block_number(), 1651 OS::Print(" goto(%d, %d)", instr->true_successor()->block_number(),
1647 instr->false_successor()->block_number()); 1652 instr->false_successor()->block_number());
1648 } 1653 }
1649 1654
1650 1655
1651 void FlowGraphBuilder::BuildGraph() { 1656 void FlowGraphBuilder::BuildGraph() {
1652 if (FLAG_print_ast) { 1657 if (FLAG_print_ast) {
(...skipping 29 matching lines...) Expand all
1682 char* chars = reinterpret_cast<char*>( 1687 char* chars = reinterpret_cast<char*>(
1683 Isolate::Current()->current_zone()->Allocate(len)); 1688 Isolate::Current()->current_zone()->Allocate(len));
1684 OS::SNPrint(chars, len, kFormat, function_name, reason); 1689 OS::SNPrint(chars, len, kFormat, function_name, reason);
1685 const Error& error = Error::Handle( 1690 const Error& error = Error::Handle(
1686 LanguageError::New(String::Handle(String::New(chars)))); 1691 LanguageError::New(String::Handle(String::New(chars))));
1687 Isolate::Current()->long_jump_base()->Jump(1, error); 1692 Isolate::Current()->long_jump_base()->Jump(1, error);
1688 } 1693 }
1689 1694
1690 1695
1691 } // namespace dart 1696 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/flow_graph_compiler_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698