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

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

Issue 179003005: VM: Eliminate a redundant store of the context at function entry. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 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
« 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 3442 matching lines...) Expand 10 before | Expand all | Expand 10 after
3453 Value* allocated_context = 3453 Value* allocated_context =
3454 Bind(new AllocateContextInstr(node->token_pos(), 3454 Bind(new AllocateContextInstr(node->token_pos(),
3455 num_context_variables)); 3455 num_context_variables));
3456 { LocalVariable* tmp_var = EnterTempLocalScope(allocated_context); 3456 { LocalVariable* tmp_var = EnterTempLocalScope(allocated_context);
3457 // If this node_sequence is the body of the function being compiled, and 3457 // If this node_sequence is the body of the function being compiled, and
3458 // if this function allocates context variables, but none of its enclosing 3458 // if this function allocates context variables, but none of its enclosing
3459 // functions do, the context on entry is not linked as parent of the 3459 // functions do, the context on entry is not linked as parent of the
3460 // allocated context but saved on entry and restored on exit as to prevent 3460 // allocated context but saved on entry and restored on exit as to prevent
3461 // memory leaks. 3461 // memory leaks.
3462 // In this case, the parser pre-allocates a variable to save the context. 3462 // In this case, the parser pre-allocates a variable to save the context.
3463 Value* parent_context = NULL;
3463 if (MustSaveRestoreContext(node)) { 3464 if (MustSaveRestoreContext(node)) {
3464 BuildSaveContext( 3465 BuildSaveContext(
3465 *owner()->parsed_function()->saved_entry_context_var()); 3466 *owner()->parsed_function()->saved_entry_context_var());
3466 Value* null_context = Bind(new ConstantInstr(Object::ZoneHandle())); 3467 parent_context = Bind(new ConstantInstr(Object::ZoneHandle()));
3467 AddInstruction(new StoreContextInstr(null_context)); 3468 } else {
3469 parent_context = Bind(new CurrentContextInstr());
3468 } 3470 }
3469 Value* current_context = Bind(new CurrentContextInstr());
3470 Value* tmp_val = Bind(new LoadLocalInstr(*tmp_var)); 3471 Value* tmp_val = Bind(new LoadLocalInstr(*tmp_var));
3471 Do(new StoreVMFieldInstr(tmp_val, 3472 Do(new StoreVMFieldInstr(tmp_val,
3472 Context::parent_offset(), 3473 Context::parent_offset(),
3473 current_context, 3474 parent_context,
3474 Type::ZoneHandle())); 3475 Type::ZoneHandle()));
3475 AddInstruction( 3476 AddInstruction(
3476 new StoreContextInstr(Bind(ExitTempLocalScope(tmp_var)))); 3477 new StoreContextInstr(Bind(ExitTempLocalScope(tmp_var))));
3477 } 3478 }
3478 3479
3479 // If this node_sequence is the body of the function being compiled, copy 3480 // If this node_sequence is the body of the function being compiled, copy
3480 // the captured parameters from the frame into the context. 3481 // the captured parameters from the frame into the context.
3481 if (node == owner()->parsed_function()->node_sequence()) { 3482 if (node == owner()->parsed_function()->node_sequence()) {
3482 ASSERT(scope->context_level() == 1); 3483 ASSERT(scope->context_level() == 1);
3483 const Function& function = owner()->parsed_function()->function(); 3484 const Function& function = owner()->parsed_function()->function();
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
3941 LanguageError::kError, 3942 LanguageError::kError,
3942 Heap::kNew, 3943 Heap::kNew,
3943 "FlowGraphBuilder Bailout: %s %s", 3944 "FlowGraphBuilder Bailout: %s %s",
3944 String::Handle(function.name()).ToCString(), 3945 String::Handle(function.name()).ToCString(),
3945 reason)); 3946 reason));
3946 Isolate::Current()->long_jump_base()->Jump(1, error); 3947 Isolate::Current()->long_jump_base()->Jump(1, error);
3947 } 3948 }
3948 3949
3949 3950
3950 } // namespace dart 3951 } // 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