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

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

Issue 1121303002: VM: Improve unoptimized code size by avoid emitting field guards. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 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/flow_graph_compiler.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"
(...skipping 24 matching lines...) Expand all
35 "Eliminate type checks when allowed by static type analysis."); 35 "Eliminate type checks when allowed by static type analysis.");
36 DEFINE_FLAG(bool, print_ast, false, "Print abstract syntax tree."); 36 DEFINE_FLAG(bool, print_ast, false, "Print abstract syntax tree.");
37 DEFINE_FLAG(bool, print_scopes, false, "Print scopes of local variables."); 37 DEFINE_FLAG(bool, print_scopes, false, "Print scopes of local variables.");
38 DEFINE_FLAG(bool, trace_type_check_elimination, false, 38 DEFINE_FLAG(bool, trace_type_check_elimination, false,
39 "Trace type check elimination at compile time."); 39 "Trace type check elimination at compile time.");
40 40
41 DECLARE_FLAG(bool, enable_asserts); 41 DECLARE_FLAG(bool, enable_asserts);
42 DECLARE_FLAG(bool, enable_type_checks); 42 DECLARE_FLAG(bool, enable_type_checks);
43 DECLARE_FLAG(int, optimization_counter_threshold); 43 DECLARE_FLAG(int, optimization_counter_threshold);
44 DECLARE_FLAG(bool, warn_on_javascript_compatibility); 44 DECLARE_FLAG(bool, warn_on_javascript_compatibility);
45 DECLARE_FLAG(bool, use_field_guards);
45 46
46 // Quick access to the locally defined zone() method. 47 // Quick access to the locally defined zone() method.
47 #define Z (zone()) 48 #define Z (zone())
48 49
49 // TODO(srdjan): Allow compiler to add constants as they are encountered in 50 // TODO(srdjan): Allow compiler to add constants as they are encountered in
50 // the compilation. 51 // the compilation.
51 const double kCommonDoubleConstants[] = 52 const double kCommonDoubleConstants[] =
52 {-1.0, -0.5, -0.1, 0.0, 0.1, 0.5, 1.0, 2.0, 4.0, 5.0, 53 {-1.0, -0.5, -0.1, 0.0, 0.1, 0.5, 1.0, 2.0, 4.0, 5.0,
53 10.0, 20.0, 30.0, 64.0, 255.0, NAN, 54 10.0, 20.0, 30.0, 64.0, 255.0, NAN,
54 // From dart:math 55 // From dart:math
(...skipping 3440 matching lines...) Expand 10 before | Expand all | Expand 10 after
3495 if (Isolate::Current()->TypeChecksEnabled()) { 3496 if (Isolate::Current()->TypeChecksEnabled()) {
3496 const AbstractType& type = 3497 const AbstractType& type =
3497 AbstractType::ZoneHandle(Z, node->field().type()); 3498 AbstractType::ZoneHandle(Z, node->field().type());
3498 const String& dst_name = String::ZoneHandle(Z, node->field().name()); 3499 const String& dst_name = String::ZoneHandle(Z, node->field().name());
3499 store_value = BuildAssignableValue(node->value()->token_pos(), 3500 store_value = BuildAssignableValue(node->value()->token_pos(),
3500 store_value, 3501 store_value,
3501 type, 3502 type,
3502 dst_name); 3503 dst_name);
3503 } 3504 }
3504 3505
3505 store_value = Bind(BuildStoreExprTemp(store_value)); 3506 if (FLAG_use_field_guards) {
3506 GuardFieldClassInstr* guard_field_class = 3507 if (node->field().guarded_cid() != kDynamicCid) {
3507 new(Z) GuardFieldClassInstr(store_value, 3508 store_value = Bind(BuildStoreExprTemp(store_value));
3508 node->field(), 3509 GuardFieldClassInstr* guard_field_class =
3509 isolate()->GetNextDeoptId()); 3510 new(Z) GuardFieldClassInstr(store_value,
3510 AddInstruction(guard_field_class);
3511
3512 store_value = Bind(BuildLoadExprTemp());
3513 GuardFieldLengthInstr* guard_field_length =
3514 new(Z) GuardFieldLengthInstr(store_value,
3515 node->field(), 3511 node->field(),
3516 isolate()->GetNextDeoptId()); 3512 isolate()->GetNextDeoptId());
3517 AddInstruction(guard_field_length); 3513 AddInstruction(guard_field_class);
3518 3514 store_value = Bind(BuildLoadExprTemp());
3519 store_value = Bind(BuildLoadExprTemp()); 3515 if (node->field().guarded_list_length() != Field::kNoFixedLength) {
3516 GuardFieldLengthInstr* guard_field_length =
3517 new(Z) GuardFieldLengthInstr(store_value,
3518 node->field(),
3519 isolate()->GetNextDeoptId());
3520 AddInstruction(guard_field_length);
3521 store_value = Bind(BuildLoadExprTemp());
3522 } else {
3523 // Advance deopt-id counter to remain in sync.
3524 isolate()->GetNextDeoptId();
3525 }
3526 } else {
3527 // Advance deopt-id counter to remain in sync.
3528 isolate()->GetNextDeoptId();
3529 isolate()->GetNextDeoptId();
3530 }
3531 }
3520 StoreInstanceFieldInstr* store = 3532 StoreInstanceFieldInstr* store =
3521 new(Z) StoreInstanceFieldInstr(node->field(), 3533 new(Z) StoreInstanceFieldInstr(node->field(),
3522 for_instance.value(), 3534 for_instance.value(),
3523 store_value, 3535 store_value,
3524 kEmitStoreBarrier, 3536 kEmitStoreBarrier,
3525 node->token_pos()); 3537 node->token_pos());
3526 // Maybe initializing unboxed store. 3538 // Maybe initializing unboxed store.
3527 store->set_is_potential_unboxed_initialization(true); 3539 store->set_is_potential_unboxed_initialization(true);
3528 ReturnDefinition(store); 3540 ReturnDefinition(store);
3529 } 3541 }
(...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after
4376 Report::MessageF(Report::kBailout, 4388 Report::MessageF(Report::kBailout,
4377 Script::Handle(function.script()), 4389 Script::Handle(function.script()),
4378 function.token_pos(), 4390 function.token_pos(),
4379 "FlowGraphBuilder Bailout: %s %s", 4391 "FlowGraphBuilder Bailout: %s %s",
4380 String::Handle(function.name()).ToCString(), 4392 String::Handle(function.name()).ToCString(),
4381 reason); 4393 reason);
4382 UNREACHABLE(); 4394 UNREACHABLE();
4383 } 4395 }
4384 4396
4385 } // namespace dart 4397 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/flow_graph_compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698