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

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

Issue 266783002: Save the entry context for a function that has captured loop variables. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 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/object.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 "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"
11 #include "vm/exceptions.h" 11 #include "vm/exceptions.h"
12 #include "vm/flags.h" 12 #include "vm/flags.h"
13 #include "vm/flow_graph.h" 13 #include "vm/flow_graph.h"
14 #include "vm/flow_graph_compiler.h" 14 #include "vm/flow_graph_compiler.h"
15 #include "vm/heap.h" 15 #include "vm/heap.h"
16 #include "vm/il_printer.h" 16 #include "vm/il_printer.h"
17 #include "vm/intermediate_language.h" 17 #include "vm/intermediate_language.h"
18 #include "vm/isolate.h" 18 #include "vm/isolate.h"
19 #include "vm/longjump.h" 19 #include "vm/longjump.h"
20 #include "vm/object.h" 20 #include "vm/object.h"
21 #include "vm/object_store.h"
21 #include "vm/os.h" 22 #include "vm/os.h"
22 #include "vm/parser.h" 23 #include "vm/parser.h"
23 #include "vm/resolver.h" 24 #include "vm/resolver.h"
24 #include "vm/scopes.h" 25 #include "vm/scopes.h"
25 #include "vm/stack_frame.h" 26 #include "vm/stack_frame.h"
26 #include "vm/stub_code.h" 27 #include "vm/stub_code.h"
27 #include "vm/symbols.h" 28 #include "vm/symbols.h"
28 #include "vm/token.h" 29 #include "vm/token.h"
29 #include "vm/zone.h" 30 #include "vm/zone.h"
30 31
(...skipping 3426 matching lines...) Expand 10 before | Expand all | Expand 10 after
3457 Do(BuildStoreLocal(parameter, load)); 3458 Do(BuildStoreLocal(parameter, load));
3458 // Write NULL to the source location to detect buggy accesses and 3459 // Write NULL to the source location to detect buggy accesses and
3459 // allow GC of passed value if it gets overwritten by a new value in 3460 // allow GC of passed value if it gets overwritten by a new value in
3460 // the function. 3461 // the function.
3461 Value* null_constant = 3462 Value* null_constant =
3462 Bind(new ConstantInstr(Object::ZoneHandle())); 3463 Bind(new ConstantInstr(Object::ZoneHandle()));
3463 Do(BuildStoreLocal(*temp_local, null_constant)); 3464 Do(BuildStoreLocal(*temp_local, null_constant));
3464 } 3465 }
3465 } 3466 }
3466 } 3467 }
3468 } else if (MustSaveRestoreContext(node)) {
3469 // Even when the current scope has no context variables, we may
3470 // still need to save the current context if, for example, there
3471 // are loop scopes below this which will allocate a context
3472 // object.
3473 BuildSaveContext(
3474 *owner()->parsed_function()->saved_entry_context_var());
3475 AddInstruction(
3476 new StoreContextInstr(Bind(new ConstantInstr(Object::ZoneHandle(
3477 Isolate::Current()->object_store()->empty_context())))));
3467 } 3478 }
3468 3479
3469 // This check may be deleted if the generated code is leaf. 3480 // This check may be deleted if the generated code is leaf.
3470 // Native functions don't need a stack check at entry. 3481 // Native functions don't need a stack check at entry.
3471 const Function& function = owner()->parsed_function()->function(); 3482 const Function& function = owner()->parsed_function()->function();
3472 if ((node == owner()->parsed_function()->node_sequence()) && 3483 if ((node == owner()->parsed_function()->node_sequence()) &&
3473 !function.is_native()) { 3484 !function.is_native()) {
3474 // Always allocate CheckOverflowInstr so that deopt-ids match regardless 3485 // Always allocate CheckOverflowInstr so that deopt-ids match regardless
3475 // if we inline or not. 3486 // if we inline or not.
3476 CheckStackOverflowInstr* check = 3487 CheckStackOverflowInstr* check =
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
3524 node->NodeAt(i++)->Visit(&for_effect); 3535 node->NodeAt(i++)->Visit(&for_effect);
3525 Append(for_effect); 3536 Append(for_effect);
3526 if (!is_open()) { 3537 if (!is_open()) {
3527 // E.g., because of a JumpNode. 3538 // E.g., because of a JumpNode.
3528 break; 3539 break;
3529 } 3540 }
3530 } 3541 }
3531 3542
3532 if (is_open()) { 3543 if (is_open()) {
3533 if (MustSaveRestoreContext(node)) { 3544 if (MustSaveRestoreContext(node)) {
3534 ASSERT(num_context_variables > 0);
3535 BuildRestoreContext( 3545 BuildRestoreContext(
3536 *owner()->parsed_function()->saved_entry_context_var()); 3546 *owner()->parsed_function()->saved_entry_context_var());
3537 } else if (num_context_variables > 0) { 3547 } else if (num_context_variables > 0) {
3538 UnchainContexts(1); 3548 UnchainContexts(1);
3539 } 3549 }
3540 } 3550 }
3541 3551
3542 // If this node sequence is labeled, a break out of the sequence will have 3552 // If this node sequence is labeled, a break out of the sequence will have
3543 // taken care of unchaining the context. 3553 // taken care of unchaining the context.
3544 if (nested_block.break_target() != NULL) { 3554 if (nested_block.break_target() != NULL) {
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
3899 function.token_pos(), 3909 function.token_pos(),
3900 LanguageError::kError, 3910 LanguageError::kError,
3901 Heap::kNew, 3911 Heap::kNew,
3902 "FlowGraphBuilder Bailout: %s %s", 3912 "FlowGraphBuilder Bailout: %s %s",
3903 String::Handle(function.name()).ToCString(), 3913 String::Handle(function.name()).ToCString(),
3904 reason)); 3914 reason));
3905 Isolate::Current()->long_jump_base()->Jump(1, error); 3915 Isolate::Current()->long_jump_base()->Jump(1, error);
3906 } 3916 }
3907 3917
3908 } // namespace dart 3918 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698