| 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/bit_vector.h" | 7 #include "vm/bit_vector.h" |
| 8 #include "vm/cpu.h" | 8 #include "vm/cpu.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" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 | 102 |
| 103 static int LowestFirst(const intptr_t* a, const intptr_t* b) { | 103 static int LowestFirst(const intptr_t* a, const intptr_t* b) { |
| 104 return *a - *b; | 104 return *a - *b; |
| 105 } | 105 } |
| 106 | 106 |
| 107 | 107 |
| 108 CheckClassInstr::CheckClassInstr(Value* value, | 108 CheckClassInstr::CheckClassInstr(Value* value, |
| 109 intptr_t deopt_id, | 109 intptr_t deopt_id, |
| 110 const ICData& unary_checks, | 110 const ICData& unary_checks, |
| 111 intptr_t token_pos) | 111 intptr_t token_pos) |
| 112 : TemplateInstruction(deopt_id), | 112 : TemplateInstruction<1>(deopt_id), |
| 113 unary_checks_(unary_checks), | 113 unary_checks_(unary_checks), |
| 114 cids_(unary_checks.NumberOfChecks()), | 114 cids_(unary_checks.NumberOfChecks()), |
| 115 licm_hoisted_(false), | 115 licm_hoisted_(false), |
| 116 token_pos_(token_pos) { | 116 token_pos_(token_pos) { |
| 117 ASSERT(unary_checks.IsZoneHandle()); | 117 ASSERT(unary_checks.IsZoneHandle()); |
| 118 // Expected useful check data. | 118 // Expected useful check data. |
| 119 ASSERT(!unary_checks_.IsNull()); | 119 ASSERT(!unary_checks_.IsNull()); |
| 120 ASSERT(unary_checks_.NumberOfChecks() > 0); | 120 ASSERT(unary_checks_.NumberOfChecks() > 0); |
| 121 ASSERT(unary_checks_.NumArgsTested() == 1); | 121 ASSERT(unary_checks_.NumArgsTested() == 1); |
| 122 SetInputAt(0, value); | 122 SetInputAt(0, value); |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 ASSERT(other_assert != NULL); | 285 ASSERT(other_assert != NULL); |
| 286 // This predicate has to be commutative for DominatorBasedCSE to work. | 286 // This predicate has to be commutative for DominatorBasedCSE to work. |
| 287 // TODO(fschneider): Eliminate more asserts with subtype relation. | 287 // TODO(fschneider): Eliminate more asserts with subtype relation. |
| 288 return dst_type().raw() == other_assert->dst_type().raw(); | 288 return dst_type().raw() == other_assert->dst_type().raw(); |
| 289 } | 289 } |
| 290 | 290 |
| 291 | 291 |
| 292 bool StrictCompareInstr::AttributesEqual(Instruction* other) const { | 292 bool StrictCompareInstr::AttributesEqual(Instruction* other) const { |
| 293 StrictCompareInstr* other_op = other->AsStrictCompare(); | 293 StrictCompareInstr* other_op = other->AsStrictCompare(); |
| 294 ASSERT(other_op != NULL); | 294 ASSERT(other_op != NULL); |
| 295 return ComparisonInstr::AttributesEqual(other) && | 295 return kind() == other_op->kind(); |
| 296 (needs_number_check() == other_op->needs_number_check()); | |
| 297 } | 296 } |
| 298 | 297 |
| 299 | 298 |
| 300 bool MathMinMaxInstr::AttributesEqual(Instruction* other) const { | 299 bool MathMinMaxInstr::AttributesEqual(Instruction* other) const { |
| 301 MathMinMaxInstr* other_op = other->AsMathMinMax(); | 300 MathMinMaxInstr* other_op = other->AsMathMinMax(); |
| 302 ASSERT(other_op != NULL); | 301 ASSERT(other_op != NULL); |
| 303 return (op_kind() == other_op->op_kind()) && | 302 return (op_kind() == other_op->op_kind()) && |
| 304 (result_cid() == other_op->result_cid()); | 303 (result_cid() == other_op->result_cid()); |
| 305 } | 304 } |
| 306 | 305 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 } | 353 } |
| 355 | 354 |
| 356 | 355 |
| 357 const Field& LoadStaticFieldInstr::StaticField() const { | 356 const Field& LoadStaticFieldInstr::StaticField() const { |
| 358 Field& field = Field::Handle(); | 357 Field& field = Field::Handle(); |
| 359 field ^= field_value()->BoundConstant().raw(); | 358 field ^= field_value()->BoundConstant().raw(); |
| 360 return field; | 359 return field; |
| 361 } | 360 } |
| 362 | 361 |
| 363 | 362 |
| 363 EffectSet LoadIndexedInstr::Dependencies() const { |
| 364 return EffectSet::All(); |
| 365 } |
| 366 |
| 367 |
| 368 bool LoadIndexedInstr::AttributesEqual(Instruction* other) const { |
| 369 LoadIndexedInstr* other_load = other->AsLoadIndexed(); |
| 370 ASSERT(other_load != NULL); |
| 371 return class_id() == other_load->class_id(); |
| 372 } |
| 373 |
| 374 |
| 364 ConstantInstr::ConstantInstr(const Object& value) : value_(value) { | 375 ConstantInstr::ConstantInstr(const Object& value) : value_(value) { |
| 365 // Check that the value is not an incorrect Integer representation. | 376 // Check that the value is not an incorrect Integer representation. |
| 366 ASSERT(!value.IsBigint() || !Bigint::Cast(value).FitsIntoSmi()); | 377 ASSERT(!value.IsBigint() || !Bigint::Cast(value).FitsIntoSmi()); |
| 367 ASSERT(!value.IsBigint() || !Bigint::Cast(value).FitsIntoInt64()); | 378 ASSERT(!value.IsBigint() || !Bigint::Cast(value).FitsIntoInt64()); |
| 368 ASSERT(!value.IsMint() || !Smi::IsValid(Mint::Cast(value).AsInt64Value())); | 379 ASSERT(!value.IsMint() || !Smi::IsValid(Mint::Cast(value).AsInt64Value())); |
| 369 } | 380 } |
| 370 | 381 |
| 371 | 382 |
| 372 bool ConstantInstr::AttributesEqual(Instruction* other) const { | 383 bool ConstantInstr::AttributesEqual(Instruction* other) const { |
| 373 ConstantInstr* other_constant = other->AsConstant(); | 384 ConstantInstr* other_constant = other->AsConstant(); |
| (...skipping 2656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3030 return new TestCidsInstr(token_pos(), | 3041 return new TestCidsInstr(token_pos(), |
| 3031 kind(), | 3042 kind(), |
| 3032 new_left, | 3043 new_left, |
| 3033 cid_results(), | 3044 cid_results(), |
| 3034 deopt_id()); | 3045 deopt_id()); |
| 3035 } | 3046 } |
| 3036 | 3047 |
| 3037 | 3048 |
| 3038 bool TestCidsInstr::AttributesEqual(Instruction* other) const { | 3049 bool TestCidsInstr::AttributesEqual(Instruction* other) const { |
| 3039 TestCidsInstr* other_instr = other->AsTestCids(); | 3050 TestCidsInstr* other_instr = other->AsTestCids(); |
| 3040 if (!ComparisonInstr::AttributesEqual(other)) { | 3051 ASSERT(other != NULL); |
| 3052 if (kind() != other_instr->kind()) { |
| 3041 return false; | 3053 return false; |
| 3042 } | 3054 } |
| 3043 if (cid_results().length() != other_instr->cid_results().length()) { | 3055 if (cid_results().length() != other_instr->cid_results().length()) { |
| 3044 return false; | 3056 return false; |
| 3045 } | 3057 } |
| 3046 for (intptr_t i = 0; i < cid_results().length(); i++) { | 3058 for (intptr_t i = 0; i < cid_results().length(); i++) { |
| 3047 if (cid_results()[i] != other_instr->cid_results()[i]) { | 3059 if (cid_results()[i] != other_instr->cid_results()[i]) { |
| 3048 return false; | 3060 return false; |
| 3049 } | 3061 } |
| 3050 } | 3062 } |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3204 String::ZoneHandle(Symbols::New(String::Cast(result))); | 3216 String::ZoneHandle(Symbols::New(String::Cast(result))); |
| 3205 return flow_graph->GetConstant(concatenated); | 3217 return flow_graph->GetConstant(concatenated); |
| 3206 } | 3218 } |
| 3207 | 3219 |
| 3208 | 3220 |
| 3209 InvokeMathCFunctionInstr::InvokeMathCFunctionInstr( | 3221 InvokeMathCFunctionInstr::InvokeMathCFunctionInstr( |
| 3210 ZoneGrowableArray<Value*>* inputs, | 3222 ZoneGrowableArray<Value*>* inputs, |
| 3211 intptr_t deopt_id, | 3223 intptr_t deopt_id, |
| 3212 MethodRecognizer::Kind recognized_kind, | 3224 MethodRecognizer::Kind recognized_kind, |
| 3213 intptr_t token_pos) | 3225 intptr_t token_pos) |
| 3214 : PureDefinition(deopt_id), | 3226 : Definition(deopt_id), |
| 3215 inputs_(inputs), | 3227 inputs_(inputs), |
| 3216 recognized_kind_(recognized_kind), | 3228 recognized_kind_(recognized_kind), |
| 3217 token_pos_(token_pos) { | 3229 token_pos_(token_pos) { |
| 3218 ASSERT(inputs_->length() == ArgumentCountFor(recognized_kind_)); | 3230 ASSERT(inputs_->length() == ArgumentCountFor(recognized_kind_)); |
| 3219 for (intptr_t i = 0; i < inputs_->length(); ++i) { | 3231 for (intptr_t i = 0; i < inputs_->length(); ++i) { |
| 3220 ASSERT((*inputs)[i] != NULL); | 3232 ASSERT((*inputs)[i] != NULL); |
| 3221 (*inputs)[i]->set_instruction(this); | 3233 (*inputs)[i]->set_instruction(this); |
| 3222 (*inputs)[i]->set_use_index(i); | 3234 (*inputs)[i]->set_use_index(i); |
| 3223 } | 3235 } |
| 3224 } | 3236 } |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3325 case kDoubleSquare: return "double-square"; | 3337 case kDoubleSquare: return "double-square"; |
| 3326 } | 3338 } |
| 3327 UNREACHABLE(); | 3339 UNREACHABLE(); |
| 3328 return ""; | 3340 return ""; |
| 3329 } | 3341 } |
| 3330 | 3342 |
| 3331 | 3343 |
| 3332 MergedMathInstr::MergedMathInstr(ZoneGrowableArray<Value*>* inputs, | 3344 MergedMathInstr::MergedMathInstr(ZoneGrowableArray<Value*>* inputs, |
| 3333 intptr_t deopt_id, | 3345 intptr_t deopt_id, |
| 3334 MergedMathInstr::Kind kind) | 3346 MergedMathInstr::Kind kind) |
| 3335 : PureDefinition(deopt_id), | 3347 : Definition(deopt_id), |
| 3336 inputs_(inputs), | 3348 inputs_(inputs), |
| 3337 kind_(kind) { | 3349 kind_(kind) { |
| 3338 ASSERT(inputs_->length() == InputCountFor(kind_)); | 3350 ASSERT(inputs_->length() == InputCountFor(kind_)); |
| 3339 for (intptr_t i = 0; i < inputs_->length(); ++i) { | 3351 for (intptr_t i = 0; i < inputs_->length(); ++i) { |
| 3340 ASSERT((*inputs)[i] != NULL); | 3352 ASSERT((*inputs)[i] != NULL); |
| 3341 (*inputs)[i]->set_instruction(this); | 3353 (*inputs)[i]->set_instruction(this); |
| 3342 (*inputs)[i]->set_use_index(i); | 3354 (*inputs)[i]->set_use_index(i); |
| 3343 } | 3355 } |
| 3344 } | 3356 } |
| 3345 | 3357 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 3358 case Token::kTRUNCDIV: return 0; | 3370 case Token::kTRUNCDIV: return 0; |
| 3359 case Token::kMOD: return 1; | 3371 case Token::kMOD: return 1; |
| 3360 default: UNIMPLEMENTED(); return -1; | 3372 default: UNIMPLEMENTED(); return -1; |
| 3361 } | 3373 } |
| 3362 } | 3374 } |
| 3363 | 3375 |
| 3364 | 3376 |
| 3365 #undef __ | 3377 #undef __ |
| 3366 | 3378 |
| 3367 } // namespace dart | 3379 } // namespace dart |
| OLD | NEW |