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

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

Issue 701113003: VM: Load-forwarding of non-final field values at allocations. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 1 month 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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_optimizer.h" 5 #include "vm/flow_graph_optimizer.h"
6 6
7 #include "vm/bit_vector.h" 7 #include "vm/bit_vector.h"
8 #include "vm/cha.h" 8 #include "vm/cha.h"
9 #include "vm/cpu.h" 9 #include "vm/cpu.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 6295 matching lines...) Expand 10 before | Expand all | Expand 10 after
6306 gen->RemoveAll(aliased_set_->aliased_by_effects()); 6306 gen->RemoveAll(aliased_set_->aliased_by_effects());
6307 continue; 6307 continue;
6308 } 6308 }
6309 6309
6310 Definition* defn = instr->AsDefinition(); 6310 Definition* defn = instr->AsDefinition();
6311 if (defn == NULL) { 6311 if (defn == NULL) {
6312 continue; 6312 continue;
6313 } 6313 }
6314 6314
6315 // For object allocation forward initial values of the fields to 6315 // For object allocation forward initial values of the fields to
6316 // subsequent loads. For simplicity we ignore escaping objects. 6316 // subsequent loads. For skip final fields. Final fields are
6317 //
6318 // The reason to ignore escaping objects is that final fields are
6319 // initialized in constructor that potentially can be not inlined into 6317 // initialized in constructor that potentially can be not inlined into
6320 // the function that we are currently optimizing. However at the same 6318 // the function that we are currently optimizing. However at the same
6321 // time we assume that values of the final fields can be forwarded 6319 // time we assume that values of the final fields can be forwarded
6322 // across side-effects. If we add 'null' as known values for these 6320 // across side-effects. If we add 'null' as known values for these
6323 // fields here we will incorrectly propagate this null across 6321 // fields here we will incorrectly propagate this null across
6324 // constructor invocation. 6322 // constructor invocation.
6325 // TODO(vegorov): record null-values at least for not final fields of
6326 // escaping object.
6327 AllocateObjectInstr* alloc = instr->AsAllocateObject(); 6323 AllocateObjectInstr* alloc = instr->AsAllocateObject();
6328 if ((alloc != NULL) && !aliased_set_->CanBeAliased(alloc)) { 6324 if ((alloc != NULL)) {
6329 for (Value* use = alloc->input_use_list(); 6325 for (Value* use = alloc->input_use_list();
6330 use != NULL; 6326 use != NULL;
6331 use = use->next_use()) { 6327 use = use->next_use()) {
6332 // Look for all immediate loads from this object. 6328 // Look for all immediate loads from this object.
6333 if (use->use_index() != 0) { 6329 if (use->use_index() != 0) {
6334 continue; 6330 continue;
6335 } 6331 }
6336 6332
6337 LoadFieldInstr* load = use->instruction()->AsLoadField(); 6333 LoadFieldInstr* load = use->instruction()->AsLoadField();
6338 if (load != NULL) { 6334 if (load != NULL) {
6339 // Found a load. Initialize current value of the field to null for 6335 // Found a load. Initialize current value of the field to null for
6340 // normal fields, or with type arguments. 6336 // normal fields, or with type arguments.
6341 gen->Add(load->place_id());
6342 if (out_values == NULL) out_values = CreateBlockOutValues();
6343 6337
6338 // Forward for all fields for non-escaping objects and only
6339 // non-final fields and type arguments for escaping ones.
6340 bool forward = !aliased_set_->CanBeAliased(alloc) ||
Vyacheslav Egorov (Google) 2014/11/05 14:13:47 Maybe you can do if (aliased_set_->CanBeAliased(
Florian Schneider 2014/11/05 14:53:43 Done.
6341 (load->field() != NULL && !load->field()->is_final());
6342
6343 Definition* forward_def = graph_->constant_null();
6344 if (alloc->ArgumentCount() > 0) { 6344 if (alloc->ArgumentCount() > 0) {
6345 ASSERT(alloc->ArgumentCount() == 1); 6345 ASSERT(alloc->ArgumentCount() == 1);
6346 intptr_t type_args_offset = 6346 intptr_t type_args_offset =
6347 alloc->cls().type_arguments_field_offset(); 6347 alloc->cls().type_arguments_field_offset();
6348 if (load->offset_in_bytes() == type_args_offset) { 6348 if (load->offset_in_bytes() == type_args_offset) {
6349 (*out_values)[load->place_id()] = 6349 forward = true; // Always forward type arguments.
6350 alloc->PushArgumentAt(0)->value()->definition(); 6350 forward_def = alloc->PushArgumentAt(0)->value()->definition();
6351 continue; 6351 continue;
Vyacheslav Egorov (Google) 2014/11/05 14:13:47 Should not this |continue;| go away?
Florian Schneider 2014/11/05 14:53:43 Done.
6352 } 6352 }
6353 } 6353 }
6354 (*out_values)[load->place_id()] = graph_->constant_null(); 6354 if (forward) {
6355 gen->Add(load->place_id());
6356 if (out_values == NULL) out_values = CreateBlockOutValues();
6357 (*out_values)[load->place_id()] = forward_def;
6358 }
6355 } 6359 }
6356 } 6360 }
6357 continue; 6361 continue;
6358 } 6362 }
6359 6363
6360 if (!IsLoadEliminationCandidate(defn)) { 6364 if (!IsLoadEliminationCandidate(defn)) {
6361 continue; 6365 continue;
6362 } 6366 }
6363 6367
6364 const intptr_t place_id = defn->place_id(); 6368 const intptr_t place_id = defn->place_id();
(...skipping 3559 matching lines...) Expand 10 before | Expand all | Expand 10 after
9924 9928
9925 // Insert materializations at environment uses. 9929 // Insert materializations at environment uses.
9926 for (intptr_t i = 0; i < exits_collector_.exits().length(); i++) { 9930 for (intptr_t i = 0; i < exits_collector_.exits().length(); i++) {
9927 CreateMaterializationAt( 9931 CreateMaterializationAt(
9928 exits_collector_.exits()[i], alloc, alloc->cls(), *slots); 9932 exits_collector_.exits()[i], alloc, alloc->cls(), *slots);
9929 } 9933 }
9930 } 9934 }
9931 9935
9932 9936
9933 } // namespace dart 9937 } // 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