| OLD | NEW |
| 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/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/dart_entry.h" | 8 #include "vm/dart_entry.h" |
| 9 #include "vm/flow_graph_allocator.h" | 9 #include "vm/flow_graph_allocator.h" |
| 10 #include "vm/flow_graph_builder.h" | 10 #include "vm/flow_graph_builder.h" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 for (intptr_t i = 0; i < block_order_.length(); ++i) { | 110 for (intptr_t i = 0; i < block_order_.length(); ++i) { |
| 111 BlockEntryInstr* entry = block_order_[i]; | 111 BlockEntryInstr* entry = block_order_[i]; |
| 112 entry->Accept(this); | 112 entry->Accept(this); |
| 113 for (ForwardInstructionIterator it(entry); !it.Done(); it.Advance()) { | 113 for (ForwardInstructionIterator it(entry); !it.Done(); it.Advance()) { |
| 114 it.Current()->Accept(this); | 114 it.Current()->Accept(this); |
| 115 } | 115 } |
| 116 } | 116 } |
| 117 } | 117 } |
| 118 | 118 |
| 119 | 119 |
| 120 // Returns true if the compile type of this value is more specific than the | 120 // Returns true if the static type of this value is more specific than the |
| 121 // given dst_type. | 121 // given dst_type. |
| 122 // TODO(regis): Support a set of compile types for the given value. | 122 // TODO(regis): Should we support a set of static types? |
| 123 bool Value::CompileTypeIsMoreSpecificThan(const AbstractType& dst_type) const { | 123 bool Value::StaticTypeIsMoreSpecificThan(const AbstractType& dst_type) const { |
| 124 ASSERT(!dst_type.IsMalformed()); // Should be tested by caller. | 124 ASSERT(!dst_type.IsMalformed()); // Should be tested by caller. |
| 125 ASSERT(!dst_type.IsDynamicType()); // Should be tested by caller. | 125 ASSERT(!dst_type.IsDynamicType()); // Should be tested by caller. |
| 126 ASSERT(!dst_type.IsObjectType()); // Should be tested by caller. | 126 ASSERT(!dst_type.IsObjectType()); // Should be tested by caller. |
| 127 | 127 |
| 128 // If the value is the null constant, its type (NullType) is more specific | 128 // If the value is the null constant, its type (NullType) is more specific |
| 129 // than the destination type, even if the destination type is the void type, | 129 // than the destination type, even if the destination type is the void type, |
| 130 // since a void function is allowed to return null. | 130 // since a void function is allowed to return null. |
| 131 if (IsConstant() && AsConstant()->value().IsNull()) { | 131 if (IsConstant() && AsConstant()->value().IsNull()) { |
| 132 return true; | 132 return true; |
| 133 } | 133 } |
| 134 | 134 |
| 135 // Functions that do not explicitly return a value, implicitly return null, | 135 // Functions that do not explicitly return a value, implicitly return null, |
| 136 // except generative constructors, which return the object being constructed. | 136 // except generative constructors, which return the object being constructed. |
| 137 // It is therefore acceptable for void functions to return null. | 137 // It is therefore acceptable for void functions to return null. |
| 138 // In case of a null constant, we have already returned true above, else we | 138 // In case of a null constant, we have already returned true above, else we |
| 139 // return false here. | 139 // return false here. |
| 140 if (dst_type.IsVoidType()) { | 140 if (dst_type.IsVoidType()) { |
| 141 return false; | 141 return false; |
| 142 } | 142 } |
| 143 | 143 |
| 144 // Consider the compile type of the value. | 144 // Consider the static type of the value. |
| 145 const AbstractType& compile_type = AbstractType::Handle(CompileType()); | 145 const AbstractType& static_type = AbstractType::Handle(StaticType()); |
| 146 ASSERT(!compile_type.IsMalformed()); | 146 ASSERT(!static_type.IsMalformed()); |
| 147 | 147 |
| 148 // If the compile type of the value is void, we are type checking the result | 148 // If the static type of the value is void, we are type checking the result of |
| 149 // of a void function, which was checked to be null at the return statement | 149 // a void function, which was checked to be null at the return statement |
| 150 // inside the function. | 150 // inside the function. |
| 151 if (compile_type.IsVoidType()) { | 151 if (static_type.IsVoidType()) { |
| 152 return true; | 152 return true; |
| 153 } | 153 } |
| 154 | 154 |
| 155 // If the compile type of the value is NullType, the type test is eliminated. | 155 // If the static type of the value is NullType, the type test is eliminated. |
| 156 // There are only three instances that can be of Class Null: | 156 // There are only three instances that can be of Class Null: |
| 157 // Object::null(), Object::sentinel(), and Object::transition_sentinel(). | 157 // Object::null(), Object::sentinel(), and Object::transition_sentinel(). |
| 158 // The inline code and run time code performing the type check will never | 158 // The inline code and run time code performing the type check will never |
| 159 // encounter the 2 sentinel values. The type check of a sentinel value | 159 // encounter the 2 sentinel values. The type check of a sentinel value |
| 160 // will always be eliminated here, because these sentinel values can only | 160 // will always be eliminated here, because these sentinel values can only |
| 161 // be encountered as constants, never as actual value of a heap object | 161 // be encountered as constants, never as actual value of a heap object |
| 162 // being type checked. | 162 // being type checked. |
| 163 if (compile_type.IsNullType()) { | 163 if (static_type.IsNullType()) { |
| 164 return true; | 164 return true; |
| 165 } | 165 } |
| 166 | 166 |
| 167 // The run time type of the value is guaranteed to be a subtype of the | 167 // The run time type of the value is guaranteed to be a subtype of the |
| 168 // compile time type of the value. However, establishing here that | 168 // compile time static type of the value. However, establishing here that |
| 169 // the compile time type is a subtype of the destination type does not | 169 // the static type is a subtype of the destination type does not guarantee |
| 170 // guarantee that the run time type will also be a subtype of the destination | 170 // that the run time type will also be a subtype of the destination type, |
| 171 // type, because the subtype relation is not transitive. | 171 // because the subtype relation is not transitive. |
| 172 // However, the 'more specific than' relation is transitive and is used | 172 // However, the 'more specific than' relation is transitive and is used |
| 173 // here. In other words, if the compile type of the value is more specific | 173 // here. In other words, if the static type of the value is more specific |
| 174 // than the destination type, the run time type of the value, which is | 174 // than the destination type, the run time type of the value, which is |
| 175 // guaranteed to be a subtype of the compile type, is also guaranteed to be | 175 // guaranteed to be a subtype of the static type, is also guaranteed to be |
| 176 // a subtype of the destination type and the type check can therefore be | 176 // a subtype of the destination type and the type check can therefore be |
| 177 // eliminated. | 177 // eliminated. |
| 178 return compile_type.IsMoreSpecificThan(dst_type, NULL); | 178 return static_type.IsMoreSpecificThan(dst_type, NULL); |
| 179 } | 179 } |
| 180 | 180 |
| 181 | 181 |
| 182 RawAbstractType* PhiInstr::CompileType() const { | 182 RawAbstractType* PhiInstr::StaticType() const { |
| 183 if (HasPropagatedType()) { | 183 // TODO(regis): Return the least upper bound of the input static types. |
| 184 return PropagatedType(); | 184 // It is much simpler to compute the least specific of the input static types, |
| 185 } | 185 // and it may be good enough in practice. |
| 186 // If type propagation has not yet occured, we are reaching this phi via a | 186 // Even better: we could keep the set of the input static types intact. |
| 187 // back edge phi input. Return null as compile type so that this input is | 187 AbstractType& least_specific_type = |
| 188 // ignored in the first iteration of type propagation. | 188 AbstractType::Handle(InputAt(0)->StaticType()); |
| 189 return AbstractType::null(); | |
| 190 } | |
| 191 | |
| 192 | |
| 193 RawAbstractType* PhiInstr::LeastSpecificInputType() const { | |
| 194 AbstractType& least_specific_type = AbstractType::Handle(); | |
| 195 AbstractType& input_type = AbstractType::Handle(); | 189 AbstractType& input_type = AbstractType::Handle(); |
| 196 for (intptr_t i = 0; i < InputCount(); i++) { | 190 for (intptr_t i = 1; i < InputCount(); i++) { |
| 197 input_type = InputAt(i)->CompileType(); | 191 input_type = InputAt(i)->StaticType(); |
| 198 if (input_type.IsNull()) { | 192 if (input_type.IsMoreSpecificThan(least_specific_type, NULL)) { |
| 199 // This input is on a back edge and we are in the first iteration of type | 193 // Type least_specific_type is less specific than input_type. No change. |
| 200 // propagation. Ignore it. | 194 } else if (least_specific_type.IsMoreSpecificThan(input_type, NULL)) { |
| 201 continue; | |
| 202 } | |
| 203 ASSERT(!input_type.IsNull()); | |
| 204 if (least_specific_type.IsNull() || | |
| 205 least_specific_type.IsMoreSpecificThan(input_type, NULL)) { | |
| 206 // Type input_type is less specific than the current least_specific_type. | 195 // Type input_type is less specific than the current least_specific_type. |
| 207 least_specific_type = input_type.raw(); | 196 least_specific_type = input_type.raw(); |
| 208 } else if (input_type.IsMoreSpecificThan(least_specific_type, NULL)) { | |
| 209 // Type least_specific_type is less specific than input_type. No change. | |
| 210 } else { | 197 } else { |
| 211 // The types are unrelated. No need to continue. | 198 // The types are unrelated. No need to continue. |
| 212 least_specific_type = Type::ObjectType(); | 199 least_specific_type = Type::ObjectType(); |
| 213 break; | 200 break; |
| 214 } | 201 } |
| 215 } | 202 } |
| 216 return least_specific_type.raw(); | 203 return least_specific_type.raw(); |
| 217 } | 204 } |
| 218 | 205 |
| 219 | 206 |
| 220 RawAbstractType* ParameterInstr::CompileType() const { | 207 RawAbstractType* ParameterInstr::StaticType() const { |
| 221 // TODO(regis): Can type feedback provide information about the compile type | 208 // TODO(regis): Can type feedback provide information about the static type |
| 222 // of a passed-in parameter? In that case, it would be stored in the | 209 // of a passed-in parameter? |
| 223 // propagated_type_ field. | 210 // Note that in checked mode, we could return the static type of the formal |
| 224 if (HasPropagatedType()) { | 211 // parameter. However, this would be wrong if ParameterInstr is used to type |
| 225 return PropagatedType(); | 212 // check the passed-in parameter, since the type check would then always be |
| 226 } | 213 // wrongly eliminated. |
| 227 // Note that returning the declared type of the formal parameter would be | |
| 228 // incorrect, because ParameterInstr is used as input to the type check | |
| 229 // verifying the run time type of the passed-in parameter and this check would | |
| 230 // always be wrongly eliminated. | |
| 231 return Type::DynamicType(); | 214 return Type::DynamicType(); |
| 232 } | 215 } |
| 233 | 216 |
| 234 | 217 |
| 235 intptr_t JoinEntryInstr::IndexOfPredecessor(BlockEntryInstr* pred) const { | 218 intptr_t JoinEntryInstr::IndexOfPredecessor(BlockEntryInstr* pred) const { |
| 236 for (intptr_t i = 0; i < predecessors_.length(); ++i) { | 219 for (intptr_t i = 0; i < predecessors_.length(); ++i) { |
| 237 if (predecessors_[i] == pred) return i; | 220 if (predecessors_[i] == pred) return i; |
| 238 } | 221 } |
| 239 return -1; | 222 return -1; |
| 240 } | 223 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 254 } | 237 } |
| 255 } | 238 } |
| 256 | 239 |
| 257 | 240 |
| 258 void Instruction::RecordAssignedVars(BitVector* assigned_vars, | 241 void Instruction::RecordAssignedVars(BitVector* assigned_vars, |
| 259 intptr_t fixed_parameter_count) { | 242 intptr_t fixed_parameter_count) { |
| 260 // Nothing to do for the base class. | 243 // Nothing to do for the base class. |
| 261 } | 244 } |
| 262 | 245 |
| 263 | 246 |
| 264 RawAbstractType* BindInstr::CompileType() const { | |
| 265 if (HasPropagatedType()) { | |
| 266 return PropagatedType(); | |
| 267 } | |
| 268 // The compile type may be requested when building the flow graph, i.e. before | |
| 269 // type propagation has occurred. | |
| 270 return computation()->CompileType(); | |
| 271 } | |
| 272 | |
| 273 | |
| 274 void BindInstr::RecordAssignedVars(BitVector* assigned_vars, | 247 void BindInstr::RecordAssignedVars(BitVector* assigned_vars, |
| 275 intptr_t fixed_parameter_count) { | 248 intptr_t fixed_parameter_count) { |
| 276 computation()->RecordAssignedVars(assigned_vars, fixed_parameter_count); | 249 computation()->RecordAssignedVars(assigned_vars, fixed_parameter_count); |
| 277 } | 250 } |
| 278 | 251 |
| 279 | 252 |
| 280 // ==== Postorder graph traversal. | 253 // ==== Postorder graph traversal. |
| 281 void GraphEntryInstr::DiscoverBlocks( | 254 void GraphEntryInstr::DiscoverBlocks( |
| 282 BlockEntryInstr* current_block, | 255 BlockEntryInstr* current_block, |
| 283 GrowableArray<BlockEntryInstr*>* preorder, | 256 GrowableArray<BlockEntryInstr*>* preorder, |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 ASSERT(index == 0); | 463 ASSERT(index == 0); |
| 491 return successor(); | 464 return successor(); |
| 492 } | 465 } |
| 493 | 466 |
| 494 | 467 |
| 495 void Instruction::Goto(JoinEntryInstr* entry) { | 468 void Instruction::Goto(JoinEntryInstr* entry) { |
| 496 set_next(new GotoInstr(entry)); | 469 set_next(new GotoInstr(entry)); |
| 497 } | 470 } |
| 498 | 471 |
| 499 | 472 |
| 500 RawAbstractType* ConstantVal::CompileType() const { | 473 // ==== Support for propagating static type. |
| 501 if (value().IsNull()) { | 474 RawAbstractType* ConstantVal::StaticType() const { |
| 502 return Type::NullType(); | |
| 503 } | |
| 504 if (value().IsInstance()) { | 475 if (value().IsInstance()) { |
| 505 return Instance::Cast(value()).GetType(); | 476 return Instance::Cast(value()).GetType(); |
| 506 } else { | 477 } else { |
| 507 ASSERT(value().IsAbstractTypeArguments()); | 478 UNREACHABLE(); |
| 508 return AbstractType::null(); | 479 return AbstractType::null(); |
| 509 } | 480 } |
| 510 } | 481 } |
| 511 | 482 |
| 512 | 483 |
| 513 RawAbstractType* UseVal::CompileType() const { | 484 RawAbstractType* UseVal::StaticType() const { |
| 514 return definition()->CompileType(); | 485 return definition()->StaticType(); |
| 515 } | 486 } |
| 516 | 487 |
| 517 | 488 |
| 518 RawAbstractType* AssertAssignableComp::CompileType() const { | 489 RawAbstractType* AssertAssignableComp::StaticType() const { |
| 519 const AbstractType& value_compile_type = | 490 const AbstractType& value_static_type = |
| 520 AbstractType::Handle(value()->CompileType()); | 491 AbstractType::Handle(value()->StaticType()); |
| 521 if (value_compile_type.IsMoreSpecificThan(dst_type(), NULL)) { | 492 if (value_static_type.IsMoreSpecificThan(dst_type(), NULL)) { |
| 522 return value_compile_type.raw(); | 493 return value_static_type.raw(); |
| 523 } | 494 } |
| 524 return dst_type().raw(); | 495 return dst_type().raw(); |
| 525 } | 496 } |
| 526 | 497 |
| 527 | 498 |
| 528 RawAbstractType* AssertBooleanComp::CompileType() const { | 499 RawAbstractType* AssertBooleanComp::StaticType() const { |
| 529 return Type::BoolInterface(); | 500 return Type::BoolInterface(); |
| 530 } | 501 } |
| 531 | 502 |
| 532 | 503 |
| 533 RawAbstractType* CurrentContextComp::CompileType() const { | 504 RawAbstractType* CurrentContextComp::StaticType() const { |
| 505 UNREACHABLE(); |
| 534 return AbstractType::null(); | 506 return AbstractType::null(); |
| 535 } | 507 } |
| 536 | 508 |
| 537 | 509 |
| 538 RawAbstractType* StoreContextComp::CompileType() const { | 510 RawAbstractType* StoreContextComp::StaticType() const { |
| 511 UNREACHABLE(); |
| 539 return AbstractType::null(); | 512 return AbstractType::null(); |
| 540 } | 513 } |
| 541 | 514 |
| 542 | 515 |
| 543 RawAbstractType* ClosureCallComp::CompileType() const { | 516 RawAbstractType* ClosureCallComp::StaticType() const { |
| 544 // Because of function subtyping rules, the declared return type of a closure | 517 // Because of function subtyping rules, the static return type of a closure |
| 545 // call cannot be relied upon for compile type analysis. For example, a | 518 // call cannot be relied upon for static type analysis. For example, a |
| 546 // function returning Dynamic can be assigned to a closure variable declared | 519 // function returning Dynamic can be assigned to a closure variable declared |
| 547 // to return int and may actually return a double at run-time. | 520 // to return int and may actually return a double at run-time. |
| 548 return Type::DynamicType(); | 521 return Type::DynamicType(); |
| 549 } | 522 } |
| 550 | 523 |
| 551 | 524 |
| 552 RawAbstractType* InstanceCallComp::CompileType() const { | 525 RawAbstractType* InstanceCallComp::StaticType() const { |
| 553 // TODO(regis): Return a more specific type than Dynamic for recognized | 526 // TODO(regis): Return a more specific type than Dynamic for recognized |
| 554 // combinations of receiver type and method name. | 527 // combinations of receiver static type and method name. |
| 555 return Type::DynamicType(); | 528 return Type::DynamicType(); |
| 556 } | 529 } |
| 557 | 530 |
| 558 | 531 |
| 559 RawAbstractType* PolymorphicInstanceCallComp::CompileType() const { | 532 RawAbstractType* PolymorphicInstanceCallComp::StaticType() const { |
| 560 return Type::DynamicType(); | 533 return Type::DynamicType(); |
| 561 } | 534 } |
| 562 | 535 |
| 563 | 536 |
| 564 RawAbstractType* StaticCallComp::CompileType() const { | 537 RawAbstractType* StaticCallComp::StaticType() const { |
| 565 return function().result_type(); | 538 return function().result_type(); |
| 566 } | 539 } |
| 567 | 540 |
| 568 | 541 |
| 569 RawAbstractType* LoadLocalComp::CompileType() const { | 542 RawAbstractType* LoadLocalComp::StaticType() const { |
| 543 // TODO(regis): Verify that the type of the receiver is properly set. |
| 570 if (FLAG_enable_type_checks) { | 544 if (FLAG_enable_type_checks) { |
| 571 return local().type().raw(); | 545 return local().type().raw(); |
| 572 } | 546 } |
| 573 return Type::DynamicType(); | 547 return Type::DynamicType(); |
| 574 } | 548 } |
| 575 | 549 |
| 576 | 550 |
| 577 RawAbstractType* StoreLocalComp::CompileType() const { | 551 RawAbstractType* StoreLocalComp::StaticType() const { |
| 578 return value()->CompileType(); | 552 return value()->StaticType(); |
| 579 } | 553 } |
| 580 | 554 |
| 581 | 555 |
| 582 RawAbstractType* StrictCompareComp::CompileType() const { | 556 RawAbstractType* StrictCompareComp::StaticType() const { |
| 583 return Type::BoolInterface(); | 557 return Type::BoolInterface(); |
| 584 } | 558 } |
| 585 | 559 |
| 586 | 560 |
| 587 RawAbstractType* EqualityCompareComp::CompileType() const { | 561 RawAbstractType* EqualityCompareComp::StaticType() const { |
| 588 return Type::BoolInterface(); | 562 return Type::BoolInterface(); |
| 589 } | 563 } |
| 590 | 564 |
| 591 | 565 |
| 592 RawAbstractType* RelationalOpComp::CompileType() const { | 566 RawAbstractType* RelationalOpComp::StaticType() const { |
| 593 return Type::BoolInterface(); | 567 return Type::BoolInterface(); |
| 594 } | 568 } |
| 595 | 569 |
| 596 | 570 |
| 597 RawAbstractType* NativeCallComp::CompileType() const { | 571 RawAbstractType* NativeCallComp::StaticType() const { |
| 598 // The result type of the native function is identical to the result type of | 572 // The result type of the native function is identical to the result type of |
| 599 // the enclosing native Dart function. However, we prefer to check the type | 573 // the enclosing native Dart function. However, we prefer to check the type |
| 600 // of the value returned from the native call. | 574 // of the value returned from the native call. |
| 601 return Type::DynamicType(); | 575 return Type::DynamicType(); |
| 602 } | 576 } |
| 603 | 577 |
| 604 | 578 |
| 605 RawAbstractType* LoadIndexedComp::CompileType() const { | 579 RawAbstractType* LoadIndexedComp::StaticType() const { |
| 606 return Type::DynamicType(); | 580 return Type::DynamicType(); |
| 607 } | 581 } |
| 608 | 582 |
| 609 | 583 |
| 610 RawAbstractType* StoreIndexedComp::CompileType() const { | 584 RawAbstractType* StoreIndexedComp::StaticType() const { |
| 585 UNREACHABLE(); |
| 611 return AbstractType::null(); | 586 return AbstractType::null(); |
| 612 } | 587 } |
| 613 | 588 |
| 614 | 589 |
| 615 RawAbstractType* LoadInstanceFieldComp::CompileType() const { | 590 RawAbstractType* LoadInstanceFieldComp::StaticType() const { |
| 616 if (FLAG_enable_type_checks) { | 591 if (FLAG_enable_type_checks) { |
| 617 return field().type(); | 592 return field().type(); |
| 618 } | 593 } |
| 619 return Type::DynamicType(); | 594 return Type::DynamicType(); |
| 620 } | 595 } |
| 621 | 596 |
| 622 | 597 |
| 623 RawAbstractType* StoreInstanceFieldComp::CompileType() const { | 598 RawAbstractType* StoreInstanceFieldComp::StaticType() const { |
| 624 return value()->CompileType(); | 599 return value()->StaticType(); |
| 625 } | 600 } |
| 626 | 601 |
| 627 | 602 |
| 628 RawAbstractType* LoadStaticFieldComp::CompileType() const { | 603 RawAbstractType* LoadStaticFieldComp::StaticType() const { |
| 629 if (FLAG_enable_type_checks) { | 604 if (FLAG_enable_type_checks) { |
| 630 return field().type(); | 605 return field().type(); |
| 631 } | 606 } |
| 632 return Type::DynamicType(); | 607 return Type::DynamicType(); |
| 633 } | 608 } |
| 634 | 609 |
| 635 | 610 |
| 636 RawAbstractType* StoreStaticFieldComp::CompileType() const { | 611 RawAbstractType* StoreStaticFieldComp::StaticType() const { |
| 637 return value()->CompileType(); | 612 return value()->StaticType(); |
| 638 } | 613 } |
| 639 | 614 |
| 640 | 615 |
| 641 RawAbstractType* BooleanNegateComp::CompileType() const { | 616 RawAbstractType* BooleanNegateComp::StaticType() const { |
| 642 return Type::BoolInterface(); | 617 return Type::BoolInterface(); |
| 643 } | 618 } |
| 644 | 619 |
| 645 | 620 |
| 646 RawAbstractType* InstanceOfComp::CompileType() const { | 621 RawAbstractType* InstanceOfComp::StaticType() const { |
| 647 return Type::BoolInterface(); | 622 return Type::BoolInterface(); |
| 648 } | 623 } |
| 649 | 624 |
| 650 | 625 |
| 651 RawAbstractType* CreateArrayComp::CompileType() const { | 626 RawAbstractType* CreateArrayComp::StaticType() const { |
| 652 // TODO(regis): Be more specific. | 627 UNREACHABLE(); |
| 653 return Type::DynamicType(); | 628 return AbstractType::null(); |
| 654 } | 629 } |
| 655 | 630 |
| 656 | 631 |
| 657 RawAbstractType* CreateClosureComp::CompileType() const { | 632 RawAbstractType* CreateClosureComp::StaticType() const { |
| 658 const Function& fun = function(); | 633 const Function& fun = function(); |
| 659 const Class& signature_class = Class::Handle(fun.signature_class()); | 634 const Class& signature_class = Class::Handle(fun.signature_class()); |
| 660 return signature_class.SignatureType(); | 635 return signature_class.SignatureType(); |
| 661 } | 636 } |
| 662 | 637 |
| 663 | 638 |
| 664 RawAbstractType* AllocateObjectComp::CompileType() const { | 639 RawAbstractType* AllocateObjectComp::StaticType() const { |
| 665 // TODO(regis): Be more specific. | 640 // TODO(regis): Be more specific. |
| 666 return Type::DynamicType(); | 641 return Type::DynamicType(); |
| 667 } | 642 } |
| 668 | 643 |
| 669 | 644 |
| 670 RawAbstractType* AllocateObjectWithBoundsCheckComp::CompileType() const { | 645 RawAbstractType* AllocateObjectWithBoundsCheckComp::StaticType() const { |
| 671 // TODO(regis): Be more specific. | 646 UNREACHABLE(); |
| 672 return Type::DynamicType(); | 647 return AbstractType::null(); |
| 673 } | 648 } |
| 674 | 649 |
| 675 | 650 |
| 676 RawAbstractType* LoadVMFieldComp::CompileType() const { | 651 RawAbstractType* LoadVMFieldComp::StaticType() const { |
| 677 // Type may be null if the field is a VM field, e.g. context parent. | 652 ASSERT(!type().IsNull()); |
| 678 return type().raw(); | 653 return type().raw(); |
| 679 } | 654 } |
| 680 | 655 |
| 681 | 656 |
| 682 RawAbstractType* StoreVMFieldComp::CompileType() const { | 657 RawAbstractType* StoreVMFieldComp::StaticType() const { |
| 683 return value()->CompileType(); | 658 return value()->StaticType(); |
| 684 } | 659 } |
| 685 | 660 |
| 686 | 661 |
| 687 RawAbstractType* InstantiateTypeArgumentsComp::CompileType() const { | 662 RawAbstractType* InstantiateTypeArgumentsComp::StaticType() const { |
| 663 UNREACHABLE(); |
| 688 return AbstractType::null(); | 664 return AbstractType::null(); |
| 689 } | 665 } |
| 690 | 666 |
| 691 | 667 |
| 692 RawAbstractType* ExtractConstructorTypeArgumentsComp::CompileType() const { | 668 RawAbstractType* ExtractConstructorTypeArgumentsComp::StaticType() const { |
| 669 UNREACHABLE(); |
| 693 return AbstractType::null(); | 670 return AbstractType::null(); |
| 694 } | 671 } |
| 695 | 672 |
| 696 | 673 |
| 697 RawAbstractType* ExtractConstructorInstantiatorComp::CompileType() const { | 674 RawAbstractType* ExtractConstructorInstantiatorComp::StaticType() const { |
| 675 UNREACHABLE(); |
| 698 return AbstractType::null(); | 676 return AbstractType::null(); |
| 699 } | 677 } |
| 700 | 678 |
| 701 | 679 |
| 702 RawAbstractType* AllocateContextComp::CompileType() const { | 680 RawAbstractType* AllocateContextComp::StaticType() const { |
| 681 UNREACHABLE(); |
| 703 return AbstractType::null(); | 682 return AbstractType::null(); |
| 704 } | 683 } |
| 705 | 684 |
| 706 | 685 |
| 707 RawAbstractType* ChainContextComp::CompileType() const { | 686 RawAbstractType* ChainContextComp::StaticType() const { |
| 687 UNREACHABLE(); |
| 708 return AbstractType::null(); | 688 return AbstractType::null(); |
| 709 } | 689 } |
| 710 | 690 |
| 711 | 691 |
| 712 RawAbstractType* CloneContextComp::CompileType() const { | 692 RawAbstractType* CloneContextComp::StaticType() const { |
| 693 UNREACHABLE(); |
| 713 return AbstractType::null(); | 694 return AbstractType::null(); |
| 714 } | 695 } |
| 715 | 696 |
| 716 | 697 |
| 717 RawAbstractType* CatchEntryComp::CompileType() const { | 698 RawAbstractType* CatchEntryComp::StaticType() const { |
| 699 UNREACHABLE(); |
| 718 return AbstractType::null(); | 700 return AbstractType::null(); |
| 719 } | 701 } |
| 720 | 702 |
| 721 | 703 |
| 722 RawAbstractType* CheckStackOverflowComp::CompileType() const { | 704 RawAbstractType* CheckStackOverflowComp::StaticType() const { |
| 723 return Type::VoidType(); | 705 UNREACHABLE(); |
| 706 return AbstractType::null(); |
| 724 } | 707 } |
| 725 | 708 |
| 726 | 709 |
| 727 RawAbstractType* BinaryOpComp::CompileType() const { | 710 RawAbstractType* BinaryOpComp::StaticType() const { |
| 728 // TODO(srdjan): Compute based on input types (ICData). | 711 // TODO(srdjan): Compute based on input types (ICData). |
| 729 return Type::DynamicType(); | 712 return Type::DynamicType(); |
| 730 } | 713 } |
| 731 | 714 |
| 732 | 715 |
| 733 RawAbstractType* DoubleBinaryOpComp::CompileType() const { | 716 RawAbstractType* DoubleBinaryOpComp::StaticType() const { |
| 734 return Type::DoubleInterface(); | 717 return Type::DoubleInterface(); |
| 735 } | 718 } |
| 736 | 719 |
| 737 | 720 |
| 738 RawAbstractType* UnarySmiOpComp::CompileType() const { | 721 RawAbstractType* UnarySmiOpComp::StaticType() const { |
| 739 return Type::IntInterface(); | 722 return Type::IntInterface(); |
| 740 } | 723 } |
| 741 | 724 |
| 742 | 725 |
| 743 RawAbstractType* NumberNegateComp::CompileType() const { | 726 RawAbstractType* NumberNegateComp::StaticType() const { |
| 744 return Type::NumberInterface(); | 727 return Type::NumberInterface(); |
| 745 } | 728 } |
| 746 | 729 |
| 747 | 730 |
| 748 RawAbstractType* ToDoubleComp::CompileType() const { | 731 RawAbstractType* ToDoubleComp::StaticType() const { |
| 749 return Type::DoubleInterface(); | 732 return Type::DoubleInterface(); |
| 750 } | 733 } |
| 751 | 734 |
| 752 | 735 |
| 753 // Shared code generation methods (EmitNativeCode, MakeLocationSummary, and | 736 // Shared code generation methods (EmitNativeCode, MakeLocationSummary, and |
| 754 // PrepareEntry). Only assembly code that can be shared across all architectures | 737 // PrepareEntry). Only assembly code that can be shared across all architectures |
| 755 // can be used. Machine specific register allocation and code generation | 738 // can be used. Machine specific register allocation and code generation |
| 756 // is located in intermediate_language_<arch>.cc | 739 // is located in intermediate_language_<arch>.cc |
| 757 | 740 |
| 758 | 741 |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1041 return NULL; | 1024 return NULL; |
| 1042 } | 1025 } |
| 1043 | 1026 |
| 1044 | 1027 |
| 1045 void UseVal::EmitNativeCode(FlowGraphCompiler* compiler) { | 1028 void UseVal::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 1046 UNIMPLEMENTED(); | 1029 UNIMPLEMENTED(); |
| 1047 } | 1030 } |
| 1048 | 1031 |
| 1049 | 1032 |
| 1050 void AssertAssignableComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 1033 void AssertAssignableComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 1051 if (!IsEliminated()) { | 1034 compiler->GenerateAssertAssignable(deopt_id(), |
| 1052 compiler->GenerateAssertAssignable(deopt_id(), | 1035 token_pos(), |
| 1053 token_pos(), | 1036 try_index(), |
| 1054 try_index(), | 1037 dst_type(), |
| 1055 dst_type(), | 1038 dst_name()); |
| 1056 dst_name()); | |
| 1057 } | |
| 1058 ASSERT(locs()->in(0).reg() == locs()->out().reg()); | 1039 ASSERT(locs()->in(0).reg() == locs()->out().reg()); |
| 1059 } | 1040 } |
| 1060 | 1041 |
| 1061 | 1042 |
| 1062 LocationSummary* StoreStaticFieldComp::MakeLocationSummary() const { | 1043 LocationSummary* StoreStaticFieldComp::MakeLocationSummary() const { |
| 1063 LocationSummary* locs = new LocationSummary(1, 1, LocationSummary::kNoCall); | 1044 LocationSummary* locs = new LocationSummary(1, 1, LocationSummary::kNoCall); |
| 1064 locs->set_in(0, Location::RequiresRegister()); | 1045 locs->set_in(0, Location::RequiresRegister()); |
| 1065 locs->set_temp(0, Location::RequiresRegister()); | 1046 locs->set_temp(0, Location::RequiresRegister()); |
| 1066 locs->set_out(Location::SameAsFirstInput()); | 1047 locs->set_out(Location::SameAsFirstInput()); |
| 1067 return locs; | 1048 return locs; |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1219 locations_[i] = Location::NoLocation(); | 1200 locations_[i] = Location::NoLocation(); |
| 1220 } | 1201 } |
| 1221 } | 1202 } |
| 1222 } | 1203 } |
| 1223 } | 1204 } |
| 1224 | 1205 |
| 1225 | 1206 |
| 1226 #undef __ | 1207 #undef __ |
| 1227 | 1208 |
| 1228 } // namespace dart | 1209 } // namespace dart |
| OLD | NEW |