Chromium Code Reviews| 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 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 295 } | 295 } |
| 296 } | 296 } |
| 297 | 297 |
| 298 | 298 |
| 299 void Instruction::RecordAssignedVars(BitVector* assigned_vars, | 299 void Instruction::RecordAssignedVars(BitVector* assigned_vars, |
| 300 intptr_t fixed_parameter_count) { | 300 intptr_t fixed_parameter_count) { |
| 301 // Nothing to do for the base class. | 301 // Nothing to do for the base class. |
| 302 } | 302 } |
| 303 | 303 |
| 304 | 304 |
| 305 void Definition::ReplaceUsesWith(Definition* other) { | |
| 306 UseVal* head = use_list(); | |
| 307 if (head == NULL) return; | |
| 308 | |
| 309 UseVal* current = head; | |
| 310 while (current->next_use() != NULL) { | |
| 311 current->definition_ = other; | |
| 312 current = current->next_use(); | |
| 313 } | |
| 314 current->definition_ = other; | |
| 315 | |
| 316 current->next_use_ = other->use_list(); | |
| 317 other->use_list()->previous_use_ = current; | |
| 318 other->set_use_list(head); | |
| 319 } | |
| 320 | |
| 321 | |
| 305 RawAbstractType* BindInstr::CompileType() const { | 322 RawAbstractType* BindInstr::CompileType() const { |
| 306 if (HasPropagatedType()) { | 323 if (HasPropagatedType()) { |
| 307 return PropagatedType(); | 324 return PropagatedType(); |
| 308 } | 325 } |
| 309 // The compile type may be requested when building the flow graph, i.e. before | 326 // The compile type may be requested when building the flow graph, i.e. before |
| 310 // type propagation has occurred. | 327 // type propagation has occurred. |
| 311 return computation()->CompileType(); | 328 return computation()->CompileType(); |
| 312 } | 329 } |
| 313 | 330 |
| 314 | 331 |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 620 return value()->CompileType(); | 637 return value()->CompileType(); |
| 621 } | 638 } |
| 622 | 639 |
| 623 | 640 |
| 624 RawAbstractType* StrictCompareComp::CompileType() const { | 641 RawAbstractType* StrictCompareComp::CompileType() const { |
| 625 return Type::BoolInterface(); | 642 return Type::BoolInterface(); |
| 626 } | 643 } |
| 627 | 644 |
| 628 | 645 |
| 629 RawAbstractType* EqualityCompareComp::CompileType() const { | 646 RawAbstractType* EqualityCompareComp::CompileType() const { |
| 630 return Type::BoolInterface(); | 647 return receiver_class_id() != kObjectCid |
| 648 ? Type::BoolInterface() | |
| 649 : Type::DynamicType(); | |
| 631 } | 650 } |
| 632 | 651 |
| 633 | 652 |
| 634 RawAbstractType* RelationalOpComp::CompileType() const { | 653 RawAbstractType* RelationalOpComp::CompileType() const { |
| 635 return Type::BoolInterface(); | 654 return operands_class_id() != kObjectCid |
| 655 ? Type::BoolInterface() | |
| 656 : Type::DynamicType(); | |
| 636 } | 657 } |
| 637 | 658 |
| 638 | 659 |
| 639 RawAbstractType* NativeCallComp::CompileType() const { | 660 RawAbstractType* NativeCallComp::CompileType() const { |
| 640 // The result type of the native function is identical to the result type of | 661 // The result type of the native function is identical to the result type of |
| 641 // the enclosing native Dart function. However, we prefer to check the type | 662 // the enclosing native Dart function. However, we prefer to check the type |
| 642 // of the value returned from the native call. | 663 // of the value returned from the native call. |
| 643 return Type::DynamicType(); | 664 return Type::DynamicType(); |
| 644 } | 665 } |
| 645 | 666 |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 986 return summary; | 1007 return summary; |
| 987 } | 1008 } |
| 988 | 1009 |
| 989 | 1010 |
| 990 void StoreContextComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 1011 void StoreContextComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 991 // Nothing to do. Context register were loaded by register allocator. | 1012 // Nothing to do. Context register were loaded by register allocator. |
| 992 ASSERT(locs()->in(0).reg() == CTX); | 1013 ASSERT(locs()->in(0).reg() == CTX); |
| 993 } | 1014 } |
| 994 | 1015 |
| 995 | 1016 |
| 1017 Definition* StrictCompareComp::TryReplace(BindInstr* instr) { | |
| 1018 UseVal* left_use = left()->AsUse(); | |
| 1019 UseVal* right_use = right()->AsUse(); | |
| 1020 if (right_use == NULL || left_use == NULL) return NULL; | |
| 1021 Definition* left = left_use->definition(); | |
| 1022 BindInstr* right = right_use->definition()->AsBind(); | |
| 1023 if (right == NULL) return NULL; | |
| 1024 ConstantVal* right_constant = | |
| 1025 right_use->definition()->AsBind()->computation()->AsConstant(); | |
|
Kevin Millikin (Google)
2012/08/13 12:43:34
right->computation()->AsConstant()
Florian Schneider
2012/08/13 12:58:07
Done.
| |
| 1026 // TODO(fschneider): Handle other cases: e === false and e !== true/false. | |
| 1027 const AbstractType& left_type = | |
| 1028 AbstractType::Handle(left->HasPropagatedType() | |
| 1029 ? left->PropagatedType() | |
| 1030 : left->CompileType()); | |
| 1031 if ((left_type.raw() == Type::BoolInterface()) && | |
| 1032 (kind() == Token::kEQ_STRICT) && | |
|
Kevin Millikin (Google)
2012/08/13 12:43:34
(left_type.raw() == Type::BoolInterface()) &&
(kin
Florian Schneider
2012/08/13 12:58:07
Thanks. Done.
| |
| 1033 (right_constant->value().raw() == Bool::True())) { | |
| 1034 // Remove the constant from the graph. | |
| 1035 right->RemoveFromGraph(); | |
| 1036 // Return left subexpression as the replacement for this instruction. | |
| 1037 return left; | |
| 1038 } | |
| 1039 return NULL; | |
| 1040 } | |
| 1041 | |
| 1042 | |
| 996 LocationSummary* StrictCompareComp::MakeLocationSummary() const { | 1043 LocationSummary* StrictCompareComp::MakeLocationSummary() const { |
| 997 return LocationSummary::Make(2, | 1044 return LocationSummary::Make(2, |
| 998 Location::SameAsFirstInput(), | 1045 Location::SameAsFirstInput(), |
| 999 LocationSummary::kNoCall); | 1046 LocationSummary::kNoCall); |
| 1000 } | 1047 } |
| 1001 | 1048 |
| 1002 | 1049 |
| 1003 void StrictCompareComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 1050 void StrictCompareComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 1004 Register left = locs()->in(0).reg(); | 1051 Register left = locs()->in(0).reg(); |
| 1005 Register right = locs()->in(1).reg(); | 1052 Register right = locs()->in(1).reg(); |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1261 locations_[i] = Location::NoLocation(); | 1308 locations_[i] = Location::NoLocation(); |
| 1262 } | 1309 } |
| 1263 } | 1310 } |
| 1264 } | 1311 } |
| 1265 } | 1312 } |
| 1266 | 1313 |
| 1267 | 1314 |
| 1268 #undef __ | 1315 #undef __ |
| 1269 | 1316 |
| 1270 } // namespace dart | 1317 } // namespace dart |
| OLD | NEW |