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/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/cpu.h" | 9 #include "vm/cpu.h" |
10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 DECLARE_FLAG(bool, trace_optimization); | 34 DECLARE_FLAG(bool, trace_optimization); |
35 DECLARE_FLAG(bool, trace_constant_propagation); | 35 DECLARE_FLAG(bool, trace_constant_propagation); |
36 DECLARE_FLAG(bool, throw_on_javascript_int_overflow); | 36 DECLARE_FLAG(bool, throw_on_javascript_int_overflow); |
37 DECLARE_FLAG(bool, enable_type_checks); | 37 DECLARE_FLAG(bool, enable_type_checks); |
38 | 38 |
39 Definition::Definition() | 39 Definition::Definition() |
40 : range_(NULL), | 40 : range_(NULL), |
41 type_(NULL), | 41 type_(NULL), |
42 temp_index_(-1), | 42 temp_index_(-1), |
43 ssa_temp_index_(-1), | 43 ssa_temp_index_(-1), |
| 44 ssa_temp_index2_(-1), |
44 input_use_list_(NULL), | 45 input_use_list_(NULL), |
45 env_use_list_(NULL), | 46 env_use_list_(NULL), |
46 use_kind_(kValue), // Phis and parameters rely on this default. | 47 use_kind_(kValue), // Phis and parameters rely on this default. |
47 constant_value_(Object::ZoneHandle(ConstantPropagator::Unknown())) { | 48 constant_value_(Object::ZoneHandle(ConstantPropagator::Unknown())) { |
48 } | 49 } |
49 | 50 |
50 | 51 |
51 ICData* Instruction::GetICData(const Array& ic_data_array) const { | 52 ICData* Instruction::GetICData(const Array& ic_data_array) const { |
52 ICData& ic_data = ICData::ZoneHandle(); | 53 ICData& ic_data = ICData::ZoneHandle(); |
53 // The deopt_id can be outside the range of the IC data array for | 54 // The deopt_id can be outside the range of the IC data array for |
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
798 input->definition()->AddInputUse(input); | 799 input->definition()->AddInputUse(input); |
799 } | 800 } |
800 // Take other's environment from this definition. | 801 // Take other's environment from this definition. |
801 ASSERT(other->env() == NULL); | 802 ASSERT(other->env() == NULL); |
802 other->SetEnvironment(env()); | 803 other->SetEnvironment(env()); |
803 env_ = NULL; | 804 env_ = NULL; |
804 // Replace all uses of this definition with other. | 805 // Replace all uses of this definition with other. |
805 ReplaceUsesWith(other); | 806 ReplaceUsesWith(other); |
806 // Reuse this instruction's SSA name for other. | 807 // Reuse this instruction's SSA name for other. |
807 ASSERT(!other->HasSSATemp()); | 808 ASSERT(!other->HasSSATemp()); |
808 if (HasSSATemp()) other->set_ssa_temp_index(ssa_temp_index()); | 809 if (HasSSATemp()) { |
| 810 other->set_ssa_temp_index(ssa_temp_index()); |
| 811 if (RequiresTwoSSATempIndexes()) { |
| 812 ASSERT(other->RequiresTwoSSATempIndexes()); |
| 813 other->set_ssa_temp_index2(ssa_temp_index2()); |
| 814 } |
| 815 } |
809 | 816 |
810 // Finally insert the other definition in place of this one in the graph. | 817 // Finally insert the other definition in place of this one in the graph. |
811 previous()->LinkTo(other); | 818 previous()->LinkTo(other); |
812 if ((iterator != NULL) && (this == iterator->Current())) { | 819 if ((iterator != NULL) && (this == iterator->Current())) { |
813 // Remove through the iterator. | 820 // Remove through the iterator. |
814 other->LinkTo(this); | 821 other->LinkTo(this); |
815 iterator->RemoveCurrentFromGraph(); | 822 iterator->RemoveCurrentFromGraph(); |
816 } else { | 823 } else { |
817 other->LinkTo(next()); | 824 other->LinkTo(next()); |
818 // Remove this definition's input uses. | 825 // Remove this definition's input uses. |
(...skipping 2387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3206 return kSinRuntimeEntry; | 3213 return kSinRuntimeEntry; |
3207 case MethodRecognizer::kMathCos: | 3214 case MethodRecognizer::kMathCos: |
3208 return kCosRuntimeEntry; | 3215 return kCosRuntimeEntry; |
3209 default: | 3216 default: |
3210 UNREACHABLE(); | 3217 UNREACHABLE(); |
3211 } | 3218 } |
3212 return kSinRuntimeEntry; | 3219 return kSinRuntimeEntry; |
3213 } | 3220 } |
3214 | 3221 |
3215 | 3222 |
| 3223 MergedMath2Instr::MergedMath2Instr(ZoneGrowableArray<Value*>* inputs, |
| 3224 intptr_t original_deopt_id, |
| 3225 MergedMath2Instr::Kind kind) |
| 3226 : inputs_(inputs), |
| 3227 kind_(kind) { |
| 3228 ASSERT(inputs_->length() == InputCountFor(kind_)); |
| 3229 for (intptr_t i = 0; i < inputs_->length(); ++i) { |
| 3230 ASSERT((*inputs)[i] != NULL); |
| 3231 (*inputs)[i]->set_instruction(this); |
| 3232 (*inputs)[i]->set_use_index(i); |
| 3233 } |
| 3234 deopt_id_ = original_deopt_id; |
| 3235 } |
| 3236 |
| 3237 |
| 3238 intptr_t MergedMath2Instr::OutputIndexOf(intptr_t kind) { |
| 3239 switch (kind) { |
| 3240 case MethodRecognizer::kMathSin: return 1; |
| 3241 case MethodRecognizer::kMathCos: return 0; |
| 3242 default: UNIMPLEMENTED(); return -1; |
| 3243 } |
| 3244 } |
| 3245 |
| 3246 |
| 3247 intptr_t MergedMath2Instr::OutputIndexOf(Token::Kind token) { |
| 3248 switch (token) { |
| 3249 case Token::kTRUNCDIV: return 0; |
| 3250 case Token::kMOD: return 1; |
| 3251 default: UNIMPLEMENTED(); return -1; |
| 3252 } |
| 3253 } |
| 3254 |
| 3255 |
3216 MergedMathInstr::MergedMathInstr(ZoneGrowableArray<Value*>* inputs, | 3256 MergedMathInstr::MergedMathInstr(ZoneGrowableArray<Value*>* inputs, |
3217 intptr_t original_deopt_id, | 3257 intptr_t original_deopt_id, |
3218 MergedMathInstr::Kind kind) | 3258 MergedMathInstr::Kind kind) |
3219 : inputs_(inputs), | 3259 : inputs_(inputs), |
3220 kind_(kind) { | 3260 kind_(kind) { |
3221 ASSERT(inputs_->length() == InputCountFor(kind_)); | 3261 ASSERT(inputs_->length() == InputCountFor(kind_)); |
3222 for (intptr_t i = 0; i < inputs_->length(); ++i) { | 3262 for (intptr_t i = 0; i < inputs_->length(); ++i) { |
3223 ASSERT((*inputs)[i] != NULL); | 3263 ASSERT((*inputs)[i] != NULL); |
3224 (*inputs)[i]->set_instruction(this); | 3264 (*inputs)[i]->set_instruction(this); |
3225 (*inputs)[i]->set_use_index(i); | 3265 (*inputs)[i]->set_use_index(i); |
(...skipping 16 matching lines...) Expand all Loading... |
3242 case Token::kTRUNCDIV: return 0; | 3282 case Token::kTRUNCDIV: return 0; |
3243 case Token::kMOD: return 1; | 3283 case Token::kMOD: return 1; |
3244 default: UNIMPLEMENTED(); return -1; | 3284 default: UNIMPLEMENTED(); return -1; |
3245 } | 3285 } |
3246 } | 3286 } |
3247 | 3287 |
3248 | 3288 |
3249 #undef __ | 3289 #undef __ |
3250 | 3290 |
3251 } // namespace dart | 3291 } // namespace dart |
OLD | NEW |