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

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

Issue 183513015: Move StackOverflow check after context chaining at function entry so that the context is properly s… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 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 | no next file » | 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/bit_vector.h" 9 #include "vm/bit_vector.h"
10 #include "vm/class_finalizer.h" 10 #include "vm/class_finalizer.h"
(...skipping 3473 matching lines...) Expand 10 before | Expand all | Expand 10 after
3484 // allow GC of passed value if it gets overwritten by a new value in 3484 // allow GC of passed value if it gets overwritten by a new value in
3485 // the function. 3485 // the function.
3486 Value* null_constant = 3486 Value* null_constant =
3487 Bind(new ConstantInstr(Object::ZoneHandle())); 3487 Bind(new ConstantInstr(Object::ZoneHandle()));
3488 Do(BuildStoreLocal(*temp_local, null_constant)); 3488 Do(BuildStoreLocal(*temp_local, null_constant));
3489 } 3489 }
3490 } 3490 }
3491 } 3491 }
3492 } 3492 }
3493 3493
3494 // This check may be deleted if the generated code is leaf.
3495 // Native functions don't need a stack check at entry.
3496 const Function& function = owner()->parsed_function()->function();
3497 if ((node == owner()->parsed_function()->node_sequence()) &&
3498 !function.is_native()) {
3499 // Always allocate CheckOverflowInstr so that deopt-ids match regardless
3500 // if we inline or not.
3501 CheckStackOverflowInstr* check =
3502 new CheckStackOverflowInstr(function.token_pos(), 0);
3503 // If we are inlining don't actually attach the stack check. We must still
3504 // create the stack check in order to allocate a deopt id.
3505 if (!owner()->IsInlining()) {
3506 AddInstruction(check);
3507 }
3508 }
3509
3494 if (FLAG_enable_type_checks && 3510 if (FLAG_enable_type_checks &&
3495 (node == owner()->parsed_function()->node_sequence())) { 3511 (node == owner()->parsed_function()->node_sequence())) {
3496 const Function& function = owner()->parsed_function()->function(); 3512 const Function& function = owner()->parsed_function()->function();
3497 const int num_params = function.NumParameters(); 3513 const int num_params = function.NumParameters();
3498 int pos = 0; 3514 int pos = 0;
3499 if (function.IsConstructor()) { 3515 if (function.IsConstructor()) {
3500 // Skip type checking of receiver and phase for constructor functions. 3516 // Skip type checking of receiver and phase for constructor functions.
3501 pos = 2; 3517 pos = 2;
3502 } else if (function.IsFactory() || function.IsDynamicFunction()) { 3518 } else if (function.IsFactory() || function.IsDynamicFunction()) {
3503 // Skip type checking of type arguments for factory functions. 3519 // Skip type checking of type arguments for factory functions.
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
3859 3875
3860 3876
3861 FlowGraph* FlowGraphBuilder::BuildGraph() { 3877 FlowGraph* FlowGraphBuilder::BuildGraph() {
3862 if (FLAG_print_ast) { 3878 if (FLAG_print_ast) {
3863 // Print the function ast before IL generation. 3879 // Print the function ast before IL generation.
3864 AstPrinter::PrintFunctionNodes(*parsed_function()); 3880 AstPrinter::PrintFunctionNodes(*parsed_function());
3865 } 3881 }
3866 if (FLAG_print_scopes) { 3882 if (FLAG_print_scopes) {
3867 AstPrinter::PrintFunctionScope(*parsed_function()); 3883 AstPrinter::PrintFunctionScope(*parsed_function());
3868 } 3884 }
3869 const Function& function = parsed_function()->function();
3870 TargetEntryInstr* normal_entry = 3885 TargetEntryInstr* normal_entry =
3871 new TargetEntryInstr(AllocateBlockId(), 3886 new TargetEntryInstr(AllocateBlockId(),
3872 CatchClauseNode::kInvalidTryIndex); 3887 CatchClauseNode::kInvalidTryIndex);
3873 graph_entry_ = new GraphEntryInstr(parsed_function(), normal_entry, osr_id_); 3888 graph_entry_ = new GraphEntryInstr(parsed_function(), normal_entry, osr_id_);
3874 EffectGraphVisitor for_effect(this); 3889 EffectGraphVisitor for_effect(this);
3875 // This check may be deleted if the generated code is leaf.
3876 // Native functions don't need a stack check at entry.
3877 if (!function.is_native()) {
3878 CheckStackOverflowInstr* check =
3879 new CheckStackOverflowInstr(function.token_pos(), 0);
3880 // If we are inlining don't actually attach the stack check. We must still
3881 // create the stack check in order to allocate a deopt id.
3882 if (!IsInlining()) {
3883 for_effect.AddInstruction(check);
3884 }
3885 }
3886 parsed_function()->node_sequence()->Visit(&for_effect); 3890 parsed_function()->node_sequence()->Visit(&for_effect);
3887 AppendFragment(normal_entry, for_effect); 3891 AppendFragment(normal_entry, for_effect);
3888 // Check that the graph is properly terminated. 3892 // Check that the graph is properly terminated.
3889 ASSERT(!for_effect.is_open()); 3893 ASSERT(!for_effect.is_open());
3890 3894
3891 // When compiling for OSR, use a depth first search to prune instructions 3895 // When compiling for OSR, use a depth first search to prune instructions
3892 // unreachable from the OSR entry. Catch entries are not (yet) properly 3896 // unreachable from the OSR entry. Catch entries are not (yet) properly
3893 // recognized as reachable. 3897 // recognized as reachable.
3894 if (osr_id_ != Isolate::kNoDeoptId) { 3898 if (osr_id_ != Isolate::kNoDeoptId) {
3895 if (graph_entry_->SuccessorCount() > 1) { 3899 if (graph_entry_->SuccessorCount() > 1) {
(...skipping 25 matching lines...) Expand all
3921 LanguageError::kError, 3925 LanguageError::kError,
3922 Heap::kNew, 3926 Heap::kNew,
3923 "FlowGraphBuilder Bailout: %s %s", 3927 "FlowGraphBuilder Bailout: %s %s",
3924 String::Handle(function.name()).ToCString(), 3928 String::Handle(function.name()).ToCString(),
3925 reason)); 3929 reason));
3926 Isolate::Current()->long_jump_base()->Jump(1, error); 3930 Isolate::Current()->long_jump_base()->Jump(1, error);
3927 } 3931 }
3928 3932
3929 3933
3930 } // namespace dart 3934 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698