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

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

Issue 893193004: Propagate the stack trace of the inner-most throw when using async/await. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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 "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/bit_vector.h" 9 #include "vm/bit_vector.h"
10 #include "vm/class_finalizer.h" 10 #include "vm/class_finalizer.h"
(...skipping 1466 matching lines...) Expand 10 before | Expand all | Expand 10 after
1477 instantiator_type_arguments, 1477 instantiator_type_arguments,
1478 dst_type, 1478 dst_type,
1479 dst_name, 1479 dst_name,
1480 deopt_id); 1480 deopt_id);
1481 } 1481 }
1482 1482
1483 1483
1484 void EffectGraphVisitor::BuildAwaitJump(LocalVariable* old_context, 1484 void EffectGraphVisitor::BuildAwaitJump(LocalVariable* old_context,
1485 LocalVariable* continuation_result, 1485 LocalVariable* continuation_result,
1486 LocalVariable* continuation_error, 1486 LocalVariable* continuation_error,
1487 LocalVariable* continuation_stack_trace,
1487 const intptr_t old_ctx_level, 1488 const intptr_t old_ctx_level,
1488 JoinEntryInstr* target) { 1489 JoinEntryInstr* target) {
1489 // Building a jump consists of the following actions: 1490 // Building a jump consists of the following actions:
1490 // * Record the current continuation result in a temporary. 1491 // * Record the current continuation result in a temporary.
1491 // * Restore the old context. 1492 // * Restore the old context.
1492 // * Overwrite the old context's continuation result with the temporary. 1493 // * Overwrite the old context's continuation result with the temporary.
1493 // * Append a Goto to the target's join. 1494 // * Append a Goto to the target's join.
1494 ASSERT((continuation_result != NULL) && continuation_result->is_captured()); 1495 ASSERT((continuation_result != NULL) && continuation_result->is_captured());
1495 ASSERT((continuation_error != NULL) && continuation_error->is_captured()); 1496 ASSERT((continuation_error != NULL) && continuation_error->is_captured());
1496 ASSERT((old_context != NULL) && old_context->is_captured()); 1497 ASSERT((old_context != NULL) && old_context->is_captured());
1497 // Before restoring the continuation context we need to temporary save the 1498 // Before restoring the continuation context we need to temporary save the
1498 // result and error parameter. 1499 // result and error parameter.
1499 LocalVariable* temp_result_var = EnterTempLocalScope( 1500 LocalVariable* temp_result_var = EnterTempLocalScope(
1500 Bind(BuildLoadLocal(*continuation_result))); 1501 Bind(BuildLoadLocal(*continuation_result)));
1501 LocalVariable* temp_error_var = EnterTempLocalScope( 1502 LocalVariable* temp_error_var = EnterTempLocalScope(
1502 Bind(BuildLoadLocal(*continuation_error))); 1503 Bind(BuildLoadLocal(*continuation_error)));
1504 LocalVariable* temp_stack_trace_var = EnterTempLocalScope(
1505 Bind(BuildLoadLocal(*continuation_stack_trace)));
1503 // Restore the saved continuation context. 1506 // Restore the saved continuation context.
1504 BuildRestoreContext(*old_context); 1507 BuildRestoreContext(*old_context);
1505 1508
1506 // Pass over the continuation result. 1509 // Pass over the continuation result.
1507 1510
1508 // FlowGraphBuilder is at top context level, but the await target has possibly 1511 // FlowGraphBuilder is at top context level, but the await target has possibly
1509 // been recorded in a nested context (old_ctx_level). We need to unroll 1512 // been recorded in a nested context (old_ctx_level). We need to unroll
1510 // manually here. 1513 // manually here.
1511 intptr_t delta = old_ctx_level - 1514 intptr_t delta = old_ctx_level -
1512 continuation_result->owner()->context_level(); 1515 continuation_result->owner()->context_level();
(...skipping 18 matching lines...) Expand all
1531 context_val = Bind(new(I) LoadLocalInstr(*temp_context_var)); 1534 context_val = Bind(new(I) LoadLocalInstr(*temp_context_var));
1532 store_val = Bind(new(I) LoadLocalInstr(*temp_error_var)); 1535 store_val = Bind(new(I) LoadLocalInstr(*temp_error_var));
1533 StoreInstanceFieldInstr* store2 = new(I) StoreInstanceFieldInstr( 1536 StoreInstanceFieldInstr* store2 = new(I) StoreInstanceFieldInstr(
1534 Context::variable_offset(continuation_error->index()), 1537 Context::variable_offset(continuation_error->index()),
1535 context_val, 1538 context_val,
1536 store_val, 1539 store_val,
1537 kEmitStoreBarrier, 1540 kEmitStoreBarrier,
1538 Scanner::kNoSourcePos); 1541 Scanner::kNoSourcePos);
1539 Do(store2); 1542 Do(store2);
1540 1543
1544 context_val = Bind(new(I) LoadLocalInstr(*temp_context_var));
1545 store_val = Bind(new(I) LoadLocalInstr(*temp_stack_trace_var));
1546 StoreInstanceFieldInstr* store3 = new(I) StoreInstanceFieldInstr(
1547 Context::variable_offset(continuation_stack_trace->index()),
1548 context_val,
1549 store_val,
1550 kEmitStoreBarrier,
1551 Scanner::kNoSourcePos);
1552 Do(store3);
1553
1541 Do(ExitTempLocalScope(temp_context_var)); 1554 Do(ExitTempLocalScope(temp_context_var));
1555 Do(ExitTempLocalScope(temp_stack_trace_var));
1542 Do(ExitTempLocalScope(temp_error_var)); 1556 Do(ExitTempLocalScope(temp_error_var));
1543 Do(ExitTempLocalScope(temp_result_var)); 1557 Do(ExitTempLocalScope(temp_result_var));
1544 1558
1545 // Goto saved join. 1559 // Goto saved join.
1546 Goto(target); 1560 Goto(target);
1547 } 1561 }
1548 1562
1549 1563
1550 // Used for type casts and to test assignments. 1564 // Used for type casts and to test assignments.
1551 Value* EffectGraphVisitor::BuildAssignableValue(intptr_t token_pos, 1565 Value* EffectGraphVisitor::BuildAssignableValue(intptr_t token_pos,
(...skipping 2342 matching lines...) Expand 10 before | Expand all | Expand 10 after
3894 LoadLocalNode* load_jump_count = new(I) LoadLocalNode( 3908 LoadLocalNode* load_jump_count = new(I) LoadLocalNode(
3895 Scanner::kNoSourcePos, jump_var); 3909 Scanner::kNoSourcePos, jump_var);
3896 ComparisonNode* check_jump_count; 3910 ComparisonNode* check_jump_count;
3897 const intptr_t num_await_states = owner()->await_joins()->length(); 3911 const intptr_t num_await_states = owner()->await_joins()->length();
3898 LocalVariable* old_context = top_scope->LookupVariable( 3912 LocalVariable* old_context = top_scope->LookupVariable(
3899 Symbols::AwaitContextVar(), false); 3913 Symbols::AwaitContextVar(), false);
3900 LocalVariable* continuation_result = top_scope->LookupVariable( 3914 LocalVariable* continuation_result = top_scope->LookupVariable(
3901 Symbols::AsyncOperationParam(), false); 3915 Symbols::AsyncOperationParam(), false);
3902 LocalVariable* continuation_error = top_scope->LookupVariable( 3916 LocalVariable* continuation_error = top_scope->LookupVariable(
3903 Symbols::AsyncOperationErrorParam(), false); 3917 Symbols::AsyncOperationErrorParam(), false);
3918 LocalVariable* continuation_stack_trace = top_scope->LookupVariable(
3919 Symbols::AsyncOperationStackTraceParam(), false);
3904 for (intptr_t i = 0; i < num_await_states; i++) { 3920 for (intptr_t i = 0; i < num_await_states; i++) {
3905 check_jump_count = new(I) ComparisonNode( 3921 check_jump_count = new(I) ComparisonNode(
3906 Scanner::kNoSourcePos, 3922 Scanner::kNoSourcePos,
3907 Token::kEQ, 3923 Token::kEQ,
3908 load_jump_count, 3924 load_jump_count,
3909 new(I) LiteralNode( 3925 new(I) LiteralNode(
3910 Scanner::kNoSourcePos, Smi::ZoneHandle(I, Smi::New(i)))); 3926 Scanner::kNoSourcePos, Smi::ZoneHandle(I, Smi::New(i))));
3911 TestGraphVisitor for_test(owner(), Scanner::kNoSourcePos); 3927 TestGraphVisitor for_test(owner(), Scanner::kNoSourcePos);
3912 check_jump_count->Visit(&for_test); 3928 check_jump_count->Visit(&for_test);
3913 EffectGraphVisitor for_true(owner()); 3929 EffectGraphVisitor for_true(owner());
3914 EffectGraphVisitor for_false(owner()); 3930 EffectGraphVisitor for_false(owner());
3915 3931
3916 for_true.BuildAwaitJump(old_context, 3932 for_true.BuildAwaitJump(old_context,
3917 continuation_result, 3933 continuation_result,
3918 continuation_error, 3934 continuation_error,
3935 continuation_stack_trace,
3919 (*owner()->await_levels())[i], 3936 (*owner()->await_levels())[i],
3920 (*owner()->await_joins())[i]); 3937 (*owner()->await_joins())[i]);
3921 Join(for_test, for_true, for_false); 3938 Join(for_test, for_true, for_false);
3922 3939
3923 if (i == 0) { 3940 if (i == 0) {
3924 // Manually link up the preamble start. 3941 // Manually link up the preamble start.
3925 preamble_start->previous()->set_next(for_test.entry()); 3942 preamble_start->previous()->set_next(for_test.entry());
3926 for_test.entry()->set_previous(preamble_start->previous()); 3943 for_test.entry()->set_previous(preamble_start->previous());
3927 } 3944 }
3928 if (i == (num_await_states - 1)) { 3945 if (i == (num_await_states - 1)) {
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
4311 Report::MessageF(Report::kBailout, 4328 Report::MessageF(Report::kBailout,
4312 Script::Handle(function.script()), 4329 Script::Handle(function.script()),
4313 function.token_pos(), 4330 function.token_pos(),
4314 "FlowGraphBuilder Bailout: %s %s", 4331 "FlowGraphBuilder Bailout: %s %s",
4315 String::Handle(function.name()).ToCString(), 4332 String::Handle(function.name()).ToCString(),
4316 reason); 4333 reason);
4317 UNREACHABLE(); 4334 UNREACHABLE();
4318 } 4335 }
4319 4336
4320 } // namespace dart 4337 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_builder.h ('k') | runtime/vm/parser.cc » ('j') | runtime/vm/parser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698