| OLD | NEW |
| 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 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 iterator->RemoveCurrentFromGraph(); | 582 iterator->RemoveCurrentFromGraph(); |
| 583 } | 583 } |
| 584 | 584 |
| 585 | 585 |
| 586 bool FlowGraphOptimizer::Canonicalize() { | 586 bool FlowGraphOptimizer::Canonicalize() { |
| 587 bool changed = false; | 587 bool changed = false; |
| 588 for (intptr_t i = 0; i < block_order_.length(); ++i) { | 588 for (intptr_t i = 0; i < block_order_.length(); ++i) { |
| 589 BlockEntryInstr* entry = block_order_[i]; | 589 BlockEntryInstr* entry = block_order_[i]; |
| 590 for (ForwardInstructionIterator it(entry); !it.Done(); it.Advance()) { | 590 for (ForwardInstructionIterator it(entry); !it.Done(); it.Advance()) { |
| 591 Instruction* current = it.Current(); | 591 Instruction* current = it.Current(); |
| 592 if (current->HasUnmatchedInputRepresentations()) { |
| 593 // Can't canonicalize this instruction until all conversions for its |
| 594 // inputs are inserted. |
| 595 continue; |
| 596 } |
| 597 |
| 592 Instruction* replacement = current->Canonicalize(flow_graph()); | 598 Instruction* replacement = current->Canonicalize(flow_graph()); |
| 599 |
| 593 if (replacement != current) { | 600 if (replacement != current) { |
| 594 // For non-definitions Canonicalize should return either NULL or | 601 // For non-definitions Canonicalize should return either NULL or |
| 595 // this. | 602 // this. |
| 596 ASSERT((replacement == NULL) || current->IsDefinition()); | 603 ASSERT((replacement == NULL) || current->IsDefinition()); |
| 597 ReplaceCurrentInstruction(&it, current, replacement, flow_graph_); | 604 ReplaceCurrentInstruction(&it, current, replacement, flow_graph_); |
| 598 changed = true; | 605 changed = true; |
| 599 } | 606 } |
| 600 } | 607 } |
| 601 } | 608 } |
| 602 return changed; | 609 return changed; |
| (...skipping 2353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2956 StoreInstanceFieldInstr* store = new(I) StoreInstanceFieldInstr( | 2963 StoreInstanceFieldInstr* store = new(I) StoreInstanceFieldInstr( |
| 2957 GrowableObjectArray::length_offset(), | 2964 GrowableObjectArray::length_offset(), |
| 2958 new(I) Value(array), | 2965 new(I) Value(array), |
| 2959 new(I) Value(value), | 2966 new(I) Value(value), |
| 2960 kNoStoreBarrier, | 2967 kNoStoreBarrier, |
| 2961 call->token_pos()); | 2968 call->token_pos()); |
| 2962 ReplaceCall(call, store); | 2969 ReplaceCall(call, store); |
| 2963 return true; | 2970 return true; |
| 2964 } | 2971 } |
| 2965 | 2972 |
| 2966 if ((recognized_kind == MethodRecognizer::kBigint_setUsed) && | |
| 2967 (ic_data.NumberOfChecks() == 1) && | |
| 2968 (class_ids[0] == kBigintCid)) { | |
| 2969 // This is an internal method, no need to check argument types nor | |
| 2970 // range. | |
| 2971 Definition* bigint = call->ArgumentAt(0); | |
| 2972 Definition* value = call->ArgumentAt(1); | |
| 2973 StoreInstanceFieldInstr* store = new(I) StoreInstanceFieldInstr( | |
| 2974 Bigint::used_offset(), | |
| 2975 new(I) Value(bigint), | |
| 2976 new(I) Value(value), | |
| 2977 kNoStoreBarrier, | |
| 2978 call->token_pos()); | |
| 2979 ReplaceCall(call, store); | |
| 2980 return true; | |
| 2981 } | |
| 2982 | |
| 2983 if ((recognized_kind == MethodRecognizer::kBigint_setDigits) && | |
| 2984 (ic_data.NumberOfChecks() == 1) && | |
| 2985 (class_ids[0] == kBigintCid)) { | |
| 2986 // This is an internal method, no need to check argument types nor | |
| 2987 // range. | |
| 2988 Definition* bigint = call->ArgumentAt(0); | |
| 2989 Definition* value = call->ArgumentAt(1); | |
| 2990 StoreInstanceFieldInstr* store = new(I) StoreInstanceFieldInstr( | |
| 2991 Bigint::digits_offset(), | |
| 2992 new(I) Value(bigint), | |
| 2993 new(I) Value(value), | |
| 2994 kEmitStoreBarrier, | |
| 2995 call->token_pos()); | |
| 2996 ReplaceCall(call, store); | |
| 2997 return true; | |
| 2998 } | |
| 2999 | |
| 3000 if ((recognized_kind == MethodRecognizer::kBigint_setNeg) && | |
| 3001 (ic_data.NumberOfChecks() == 1) && | |
| 3002 (class_ids[0] == kBigintCid)) { | |
| 3003 // This is an internal method, no need to check argument types nor | |
| 3004 // range. | |
| 3005 Definition* bigint = call->ArgumentAt(0); | |
| 3006 Definition* value = call->ArgumentAt(1); | |
| 3007 StoreInstanceFieldInstr* store = new(I) StoreInstanceFieldInstr( | |
| 3008 Bigint::neg_offset(), | |
| 3009 new(I) Value(bigint), | |
| 3010 new(I) Value(value), | |
| 3011 kEmitStoreBarrier, | |
| 3012 call->token_pos()); | |
| 3013 ReplaceCall(call, store); | |
| 3014 return true; | |
| 3015 } | |
| 3016 | |
| 3017 if (((recognized_kind == MethodRecognizer::kStringBaseCodeUnitAt) || | 2973 if (((recognized_kind == MethodRecognizer::kStringBaseCodeUnitAt) || |
| 3018 (recognized_kind == MethodRecognizer::kStringBaseCharAt)) && | 2974 (recognized_kind == MethodRecognizer::kStringBaseCharAt)) && |
| 3019 (ic_data.NumberOfChecks() == 1) && | 2975 (ic_data.NumberOfChecks() == 1) && |
| 3020 ((class_ids[0] == kOneByteStringCid) || | 2976 ((class_ids[0] == kOneByteStringCid) || |
| 3021 (class_ids[0] == kTwoByteStringCid))) { | 2977 (class_ids[0] == kTwoByteStringCid))) { |
| 3022 return TryReplaceInstanceCallWithInline(call); | 2978 return TryReplaceInstanceCallWithInline(call); |
| 3023 } | 2979 } |
| 3024 | 2980 |
| 3025 if ((class_ids[0] == kOneByteStringCid) && (ic_data.NumberOfChecks() == 1)) { | 2981 if ((class_ids[0] == kOneByteStringCid) && (ic_data.NumberOfChecks() == 1)) { |
| 3026 if (recognized_kind == MethodRecognizer::kOneByteStringSetAt) { | 2982 if (recognized_kind == MethodRecognizer::kOneByteStringSetAt) { |
| (...skipping 6952 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9979 | 9935 |
| 9980 // Insert materializations at environment uses. | 9936 // Insert materializations at environment uses. |
| 9981 for (intptr_t i = 0; i < exits_collector_.exits().length(); i++) { | 9937 for (intptr_t i = 0; i < exits_collector_.exits().length(); i++) { |
| 9982 CreateMaterializationAt( | 9938 CreateMaterializationAt( |
| 9983 exits_collector_.exits()[i], alloc, alloc->cls(), *slots); | 9939 exits_collector_.exits()[i], alloc, alloc->cls(), *slots); |
| 9984 } | 9940 } |
| 9985 } | 9941 } |
| 9986 | 9942 |
| 9987 | 9943 |
| 9988 } // namespace dart | 9944 } // namespace dart |
| OLD | NEW |