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

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

Issue 78733002: Generalize if-conversion to arbitrary smi comparisons. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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 | « runtime/vm/intermediate_language.h ('k') | runtime/vm/intermediate_language_arm.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) 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/intermediate_language.h" 5 #include "vm/intermediate_language.h"
6 6
7 #include "vm/bigint_operations.h" 7 #include "vm/bigint_operations.h"
8 #include "vm/bit_vector.h" 8 #include "vm/bit_vector.h"
9 #include "vm/dart_entry.h" 9 #include "vm/dart_entry.h"
10 #include "vm/flow_graph_allocator.h" 10 #include "vm/flow_graph_allocator.h"
11 #include "vm/flow_graph_builder.h" 11 #include "vm/flow_graph_builder.h"
12 #include "vm/flow_graph_compiler.h" 12 #include "vm/flow_graph_compiler.h"
13 #include "vm/flow_graph_optimizer.h" 13 #include "vm/flow_graph_optimizer.h"
14 #include "vm/locations.h" 14 #include "vm/locations.h"
15 #include "vm/object.h" 15 #include "vm/object.h"
16 #include "vm/object_store.h" 16 #include "vm/object_store.h"
17 #include "vm/os.h" 17 #include "vm/os.h"
18 #include "vm/resolver.h" 18 #include "vm/resolver.h"
19 #include "vm/scopes.h" 19 #include "vm/scopes.h"
20 #include "vm/stub_code.h" 20 #include "vm/stub_code.h"
21 #include "vm/symbols.h" 21 #include "vm/symbols.h"
22 22
23 #include "vm/il_printer.h" 23 #include "vm/il_printer.h"
24 24
25 namespace dart { 25 namespace dart {
26 26
27 DEFINE_FLAG(bool, new_identity_spec, true,
28 "Use new identity check rules for numbers.");
29 DEFINE_FLAG(bool, propagate_ic_data, true, 27 DEFINE_FLAG(bool, propagate_ic_data, true,
30 "Propagate IC data from unoptimized to optimized IC calls."); 28 "Propagate IC data from unoptimized to optimized IC calls.");
31 DECLARE_FLAG(bool, enable_type_checks); 29 DECLARE_FLAG(bool, enable_type_checks);
32 DECLARE_FLAG(bool, eliminate_type_checks); 30 DECLARE_FLAG(bool, eliminate_type_checks);
33 DECLARE_FLAG(bool, trace_optimization); 31 DECLARE_FLAG(bool, trace_optimization);
34 DECLARE_FLAG(bool, trace_constant_propagation); 32 DECLARE_FLAG(bool, trace_constant_propagation);
35 DECLARE_FLAG(bool, throw_on_javascript_int_overflow); 33 DECLARE_FLAG(bool, throw_on_javascript_int_overflow);
36 34
37 Definition::Definition() 35 Definition::Definition()
38 : range_(NULL), 36 : range_(NULL),
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 } else { 746 } else {
749 other->LinkTo(next()); 747 other->LinkTo(next());
750 // Remove this definition's input uses. 748 // Remove this definition's input uses.
751 UnuseAllInputs(); 749 UnuseAllInputs();
752 } 750 }
753 set_previous(NULL); 751 set_previous(NULL);
754 set_next(NULL); 752 set_next(NULL);
755 } 753 }
756 754
757 755
758 BranchInstr::BranchInstr(ComparisonInstr* comparison, bool is_checked)
759 : comparison_(comparison),
760 is_checked_(is_checked),
761 constrained_type_(NULL),
762 constant_target_(NULL) {
763 ASSERT(comparison->env() == NULL);
764 for (intptr_t i = comparison->InputCount() - 1; i >= 0; --i) {
765 comparison->InputAt(i)->set_instruction(this);
766 }
767 }
768
769
770 void BranchInstr::RawSetInputAt(intptr_t i, Value* value) {
771 comparison()->RawSetInputAt(i, value);
772 }
773
774
775 void BranchInstr::SetComparison(ComparisonInstr* new_comparison) { 756 void BranchInstr::SetComparison(ComparisonInstr* new_comparison) {
776 for (intptr_t i = new_comparison->InputCount() - 1; i >= 0; --i) { 757 for (intptr_t i = new_comparison->InputCount() - 1; i >= 0; --i) {
777 Value* input = new_comparison->InputAt(i); 758 Value* input = new_comparison->InputAt(i);
778 input->definition()->AddInputUse(input); 759 input->definition()->AddInputUse(input);
779 input->set_instruction(this); 760 input->set_instruction(this);
780 } 761 }
781 // There should be no need to copy or unuse an environment. 762 // There should be no need to copy or unuse an environment.
782 ASSERT(comparison()->env() == NULL); 763 ASSERT(comparison()->env() == NULL);
783 ASSERT(new_comparison->env() == NULL); 764 ASSERT(new_comparison->env() == NULL);
784 // Remove the current comparison's input uses. 765 // Remove the current comparison's input uses.
(...skipping 1130 matching lines...) Expand 10 before | Expand all | Expand 10 after
1915 1896
1916 void StoreContextInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 1897 void StoreContextInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
1917 // Nothing to do. Context register was loaded by the register allocator. 1898 // Nothing to do. Context register was loaded by the register allocator.
1918 ASSERT(locs()->in(0).reg() == CTX); 1899 ASSERT(locs()->in(0).reg() == CTX);
1919 } 1900 }
1920 1901
1921 1902
1922 StrictCompareInstr::StrictCompareInstr(intptr_t token_pos, 1903 StrictCompareInstr::StrictCompareInstr(intptr_t token_pos,
1923 Token::Kind kind, 1904 Token::Kind kind,
1924 Value* left, 1905 Value* left,
1925 Value* right) 1906 Value* right,
1907 bool needs_number_check)
1926 : ComparisonInstr(token_pos, kind, left, right), 1908 : ComparisonInstr(token_pos, kind, left, right),
1927 needs_number_check_(FLAG_new_identity_spec) { 1909 needs_number_check_(needs_number_check) {
1928 ASSERT((kind == Token::kEQ_STRICT) || (kind == Token::kNE_STRICT)); 1910 ASSERT((kind == Token::kEQ_STRICT) || (kind == Token::kNE_STRICT));
1929 } 1911 }
1930 1912
1931 1913
1932 LocationSummary* InstanceCallInstr::MakeLocationSummary() const { 1914 LocationSummary* InstanceCallInstr::MakeLocationSummary() const {
1933 return MakeCallSummary(); 1915 return MakeCallSummary();
1934 } 1916 }
1935 1917
1936 1918
1937 void InstanceCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 1919 void InstanceCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
2468 range_ = new Range(RangeBoundary::FromConstant(min), 2450 range_ = new Range(RangeBoundary::FromConstant(min),
2469 RangeBoundary::FromConstant(max)); 2451 RangeBoundary::FromConstant(max));
2470 } 2452 }
2471 2453
2472 2454
2473 static bool BindsToSmiConstant(Value* value) { 2455 static bool BindsToSmiConstant(Value* value) {
2474 return value->BindsToConstant() && value->BoundConstant().IsSmi(); 2456 return value->BindsToConstant() && value->BoundConstant().IsSmi();
2475 } 2457 }
2476 2458
2477 2459
2460 ComparisonInstr* EqualityCompareInstr::CopyWithNewOperands(Value* new_left,
2461 Value* new_right) {
2462 return new EqualityCompareInstr(token_pos(),
2463 kind(),
2464 new_left,
2465 new_right,
2466 operation_cid(),
2467 deopt_id());
2468 }
2469
2470
2471 ComparisonInstr* RelationalOpInstr::CopyWithNewOperands(Value* new_left,
2472 Value* new_right) {
2473 return new RelationalOpInstr(token_pos(),
2474 kind(),
2475 new_left,
2476 new_right,
2477 operation_cid(),
2478 deopt_id());
2479 }
2480
2481
2482 ComparisonInstr* StrictCompareInstr::CopyWithNewOperands(Value* new_left,
2483 Value* new_right) {
2484 return new StrictCompareInstr(token_pos(),
2485 kind(),
2486 new_left,
2487 new_right,
2488 needs_number_check());
2489 }
2490
2491
2492
2493 ComparisonInstr* TestSmiInstr::CopyWithNewOperands(Value* new_left,
2494 Value* new_right) {
2495 return new TestSmiInstr(token_pos(), kind(), new_left, new_right);
2496 }
2497
2498
2478 bool IfThenElseInstr::Supports(ComparisonInstr* comparison, 2499 bool IfThenElseInstr::Supports(ComparisonInstr* comparison,
2479 Value* v1, 2500 Value* v1,
2480 Value* v2) { 2501 Value* v2) {
2481 if (!(comparison->IsStrictCompare() && 2502 bool is_smi_result = BindsToSmiConstant(v1) && BindsToSmiConstant(v2);
2482 !comparison->AsStrictCompare()->needs_number_check()) && 2503 if (comparison->IsStrictCompare()) {
2483 !(comparison->IsEqualityCompare() && 2504 // Strict comparison with number checks calls a stub and is not supported
2484 (comparison->AsEqualityCompare()->operation_cid() == kSmiCid))) { 2505 // by if-conversion.
2506 return is_smi_result
2507 && !comparison->AsStrictCompare()->needs_number_check();
2508 }
2509 if (comparison->operation_cid() != kSmiCid) {
2510 // Non-smi comparisons are not supported by if-conversion.
2485 return false; 2511 return false;
2486 } 2512 }
2487 2513 return is_smi_result;
2488 if (!BindsToSmiConstant(v1) || !BindsToSmiConstant(v2)) {
2489 return false;
2490 }
2491
2492 return true;
2493 } 2514 }
2494 2515
2495 2516
2496 void PhiInstr::InferRange() { 2517 void PhiInstr::InferRange() {
2497 RangeBoundary new_min; 2518 RangeBoundary new_min;
2498 RangeBoundary new_max; 2519 RangeBoundary new_max;
2499 2520
2500 for (intptr_t i = 0; i < InputCount(); i++) { 2521 for (intptr_t i = 0; i < InputCount(); i++) {
2501 Range* input_range = InputAt(i)->definition()->range(); 2522 Range* input_range = InputAt(i)->definition()->range();
2502 if (input_range == NULL) { 2523 if (input_range == NULL) {
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
2934 return kCosRuntimeEntry; 2955 return kCosRuntimeEntry;
2935 default: 2956 default:
2936 UNREACHABLE(); 2957 UNREACHABLE();
2937 } 2958 }
2938 return kSinRuntimeEntry; 2959 return kSinRuntimeEntry;
2939 } 2960 }
2940 2961
2941 #undef __ 2962 #undef __
2942 2963
2943 } // namespace dart 2964 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | runtime/vm/intermediate_language_arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698