| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/types.h" | 5 #include "src/types.h" |
| 6 | 6 |
| 7 #include "src/ostreams.h" | 7 #include "src/ostreams.h" |
| 8 #include "src/types-inl.h" | 8 #include "src/types-inl.h" |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 TypeHandle bound = BitsetType::New(bitset, region); | 418 TypeHandle bound = BitsetType::New(bitset, region); |
| 419 if (this->IsClass()) { | 419 if (this->IsClass()) { |
| 420 return ClassType::New(this->AsClass()->Map(), bound, region); | 420 return ClassType::New(this->AsClass()->Map(), bound, region); |
| 421 } else if (this->IsConstant()) { | 421 } else if (this->IsConstant()) { |
| 422 return ConstantType::New(this->AsConstant()->Value(), bound, region); | 422 return ConstantType::New(this->AsConstant()->Value(), bound, region); |
| 423 } else if (this->IsContext()) { | 423 } else if (this->IsContext()) { |
| 424 return ContextType::New(this->AsContext()->Outer(), bound, region); | 424 return ContextType::New(this->AsContext()->Outer(), bound, region); |
| 425 } else if (this->IsArray()) { | 425 } else if (this->IsArray()) { |
| 426 return ArrayType::New(this->AsArray()->Element(), bound, region); | 426 return ArrayType::New(this->AsArray()->Element(), bound, region); |
| 427 } else if (this->IsFunction()) { | 427 } else if (this->IsFunction()) { |
| 428 FunctionType* function = this->AsFunction(); | 428 FunctionHandle function = Config::handle(this->AsFunction()); |
| 429 int arity = function->Arity(); | 429 int arity = function->Arity(); |
| 430 FunctionHandle type = FunctionType::New( | 430 FunctionHandle type = FunctionType::New( |
| 431 function->Result(), function->Receiver(), bound, arity, region); | 431 function->Result(), function->Receiver(), bound, arity, region); |
| 432 for (int i = 0; i < arity; ++i) { | 432 for (int i = 0; i < arity; ++i) { |
| 433 type->InitParameter(i, function->Parameter(i)); | 433 type->InitParameter(i, function->Parameter(i)); |
| 434 } | 434 } |
| 435 return type; | 435 return type; |
| 436 } | 436 } |
| 437 UNREACHABLE(); | 437 UNREACHABLE(); |
| 438 return TypeHandle(); | 438 return TypeHandle(); |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 740 // ----------------------------------------------------------------------------- | 740 // ----------------------------------------------------------------------------- |
| 741 // Conversion between low-level representations. | 741 // Conversion between low-level representations. |
| 742 | 742 |
| 743 template<class Config> | 743 template<class Config> |
| 744 template<class OtherType> | 744 template<class OtherType> |
| 745 typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::Convert( | 745 typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::Convert( |
| 746 typename OtherType::TypeHandle type, Region* region) { | 746 typename OtherType::TypeHandle type, Region* region) { |
| 747 if (type->IsBitset()) { | 747 if (type->IsBitset()) { |
| 748 return BitsetType::New(type->AsBitset(), region); | 748 return BitsetType::New(type->AsBitset(), region); |
| 749 } else if (type->IsClass()) { | 749 } else if (type->IsClass()) { |
| 750 return ClassType::New( | 750 TypeHandle bound = BitsetType::New(type->BitsetLub(), region); |
| 751 type->AsClass()->Map(), | 751 return ClassType::New(type->AsClass()->Map(), bound, region); |
| 752 BitsetType::New(type->BitsetLub(), region), region); | |
| 753 } else if (type->IsConstant()) { | 752 } else if (type->IsConstant()) { |
| 754 return ConstantType::New( | 753 TypeHandle bound = Convert<OtherType>(type->AsConstant()->Bound(), region); |
| 755 type->AsConstant()->Value(), | 754 return ConstantType::New(type->AsConstant()->Value(), bound, region); |
| 756 Convert<OtherType>(type->AsConstant()->Bound(), region), region); | |
| 757 } else if (type->IsContext()) { | 755 } else if (type->IsContext()) { |
| 756 TypeHandle bound = Convert<OtherType>(type->AsContext()->Bound(), region); |
| 758 TypeHandle outer = Convert<OtherType>(type->AsContext()->Outer(), region); | 757 TypeHandle outer = Convert<OtherType>(type->AsContext()->Outer(), region); |
| 759 return ContextType::New(outer, region); | 758 return ContextType::New(outer, bound, region); |
| 760 } else if (type->IsUnion()) { | 759 } else if (type->IsUnion()) { |
| 761 int length = type->AsUnion()->Length(); | 760 int length = type->AsUnion()->Length(); |
| 762 UnionHandle unioned = UnionType::New(length, region); | 761 UnionHandle unioned = UnionType::New(length, region); |
| 763 for (int i = 0; i < length; ++i) { | 762 for (int i = 0; i < length; ++i) { |
| 764 unioned->Set(i, Convert<OtherType>(type->AsUnion()->Get(i), region)); | 763 TypeHandle t = Convert<OtherType>(type->AsUnion()->Get(i), region); |
| 764 unioned->Set(i, t); |
| 765 } | 765 } |
| 766 return unioned; | 766 return unioned; |
| 767 } else if (type->IsArray()) { | 767 } else if (type->IsArray()) { |
| 768 return ArrayType::New( | 768 TypeHandle element = Convert<OtherType>(type->AsArray()->Element(), region); |
| 769 Convert<OtherType>(type->AsArray()->Element(), region), | 769 TypeHandle bound = Convert<OtherType>(type->AsArray()->Bound(), region); |
| 770 Convert<OtherType>(type->AsArray()->Bound(), region), region); | 770 return ArrayType::New(element, bound, region); |
| 771 } else if (type->IsFunction()) { | 771 } else if (type->IsFunction()) { |
| 772 TypeHandle res = Convert<OtherType>(type->AsFunction()->Result(), region); |
| 773 TypeHandle rcv = Convert<OtherType>(type->AsFunction()->Receiver(), region); |
| 774 TypeHandle bound = Convert<OtherType>(type->AsFunction()->Bound(), region); |
| 772 FunctionHandle function = FunctionType::New( | 775 FunctionHandle function = FunctionType::New( |
| 773 Convert<OtherType>(type->AsFunction()->Result(), region), | 776 res, rcv, bound, type->AsFunction()->Arity(), region); |
| 774 Convert<OtherType>(type->AsFunction()->Receiver(), region), | |
| 775 Convert<OtherType>(type->AsFunction()->Bound(), region), | |
| 776 type->AsFunction()->Arity(), region); | |
| 777 for (int i = 0; i < function->Arity(); ++i) { | 777 for (int i = 0; i < function->Arity(); ++i) { |
| 778 function->InitParameter(i, | 778 TypeHandle param = Convert<OtherType>( |
| 779 Convert<OtherType>(type->AsFunction()->Parameter(i), region)); | 779 type->AsFunction()->Parameter(i), region); |
| 780 function->InitParameter(i, param); |
| 780 } | 781 } |
| 781 return function; | 782 return function; |
| 782 } else { | 783 } else { |
| 783 UNREACHABLE(); | 784 UNREACHABLE(); |
| 784 return None(region); | 785 return None(region); |
| 785 } | 786 } |
| 786 } | 787 } |
| 787 | 788 |
| 788 | 789 |
| 789 // ----------------------------------------------------------------------------- | 790 // ----------------------------------------------------------------------------- |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 927 template class TypeImpl<HeapTypeConfig>::Iterator<i::Object>; | 928 template class TypeImpl<HeapTypeConfig>::Iterator<i::Object>; |
| 928 | 929 |
| 929 template TypeImpl<ZoneTypeConfig>::TypeHandle | 930 template TypeImpl<ZoneTypeConfig>::TypeHandle |
| 930 TypeImpl<ZoneTypeConfig>::Convert<HeapType>( | 931 TypeImpl<ZoneTypeConfig>::Convert<HeapType>( |
| 931 TypeImpl<HeapTypeConfig>::TypeHandle, TypeImpl<ZoneTypeConfig>::Region*); | 932 TypeImpl<HeapTypeConfig>::TypeHandle, TypeImpl<ZoneTypeConfig>::Region*); |
| 932 template TypeImpl<HeapTypeConfig>::TypeHandle | 933 template TypeImpl<HeapTypeConfig>::TypeHandle |
| 933 TypeImpl<HeapTypeConfig>::Convert<Type>( | 934 TypeImpl<HeapTypeConfig>::Convert<Type>( |
| 934 TypeImpl<ZoneTypeConfig>::TypeHandle, TypeImpl<HeapTypeConfig>::Region*); | 935 TypeImpl<ZoneTypeConfig>::TypeHandle, TypeImpl<HeapTypeConfig>::Region*); |
| 935 | 936 |
| 936 } } // namespace v8::internal | 937 } } // namespace v8::internal |
| OLD | NEW |