| 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 #ifndef V8_TYPES_H_ | 5 #ifndef V8_TYPES_H_ |
| 6 #define V8_TYPES_H_ | 6 #define V8_TYPES_H_ |
| 7 | 7 |
| 8 #include "src/conversions.h" | 8 #include "src/conversions.h" |
| 9 #include "src/factory.h" | 9 #include "src/factory.h" |
| 10 #include "src/handles.h" | 10 #include "src/handles.h" |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 SEMANTIC_BITSET_TYPE_LIST(V) | 263 SEMANTIC_BITSET_TYPE_LIST(V) |
| 264 | 264 |
| 265 | 265 |
| 266 // ----------------------------------------------------------------------------- | 266 // ----------------------------------------------------------------------------- |
| 267 // The abstract Type class, parameterized over the low-level representation. | 267 // The abstract Type class, parameterized over the low-level representation. |
| 268 | 268 |
| 269 // struct Config { | 269 // struct Config { |
| 270 // typedef TypeImpl<Config> Type; | 270 // typedef TypeImpl<Config> Type; |
| 271 // typedef Base; | 271 // typedef Base; |
| 272 // typedef Struct; | 272 // typedef Struct; |
| 273 // typedef Range; |
| 273 // typedef Region; | 274 // typedef Region; |
| 274 // template<class> struct Handle { typedef type; } // No template typedefs... | 275 // template<class> struct Handle { typedef type; } // No template typedefs... |
| 275 // template<class T> static Handle<T>::type null_handle(); | 276 // template<class T> static Handle<T>::type null_handle(); |
| 276 // template<class T> static Handle<T>::type handle(T* t); // !is_bitset(t) | 277 // template<class T> static Handle<T>::type handle(T* t); // !is_bitset(t) |
| 277 // template<class T> static Handle<T>::type cast(Handle<Type>::type); | 278 // template<class T> static Handle<T>::type cast(Handle<Type>::type); |
| 279 // |
| 278 // static bool is_bitset(Type*); | 280 // static bool is_bitset(Type*); |
| 279 // static bool is_class(Type*); | 281 // static bool is_class(Type*); |
| 280 // static bool is_struct(Type*, int tag); | 282 // static bool is_struct(Type*, int tag); |
| 283 // static bool is_range(Type*); |
| 284 // |
| 281 // static bitset as_bitset(Type*); | 285 // static bitset as_bitset(Type*); |
| 282 // static i::Handle<i::Map> as_class(Type*); | 286 // static i::Handle<i::Map> as_class(Type*); |
| 283 // static Handle<Struct>::type as_struct(Type*); | 287 // static Handle<Struct>::type as_struct(Type*); |
| 288 // static Handle<Range>::type as_range(Type*); |
| 289 // |
| 284 // static Type* from_bitset(bitset); | 290 // static Type* from_bitset(bitset); |
| 285 // static Handle<Type>::type from_bitset(bitset, Region*); | 291 // static Handle<Type>::type from_bitset(bitset, Region*); |
| 286 // static Handle<Type>::type from_class(i::Handle<Map>, Region*); | 292 // static Handle<Type>::type from_class(i::Handle<Map>, Region*); |
| 287 // static Handle<Type>::type from_struct(Handle<Struct>::type, int tag); | 293 // static Handle<Type>::type from_struct(Handle<Struct>::type, int tag); |
| 294 // static Handle<Type>::type from_range(Handle<Range>::type); |
| 295 // |
| 288 // static Handle<Struct>::type struct_create(int tag, int length, Region*); | 296 // static Handle<Struct>::type struct_create(int tag, int length, Region*); |
| 289 // static void struct_shrink(Handle<Struct>::type, int length); | 297 // static void struct_shrink(Handle<Struct>::type, int length); |
| 290 // static int struct_tag(Handle<Struct>::type); | 298 // static int struct_tag(Handle<Struct>::type); |
| 291 // static int struct_length(Handle<Struct>::type); | 299 // static int struct_length(Handle<Struct>::type); |
| 292 // static Handle<Type>::type struct_get(Handle<Struct>::type, int); | 300 // static Handle<Type>::type struct_get(Handle<Struct>::type, int); |
| 293 // static void struct_set(Handle<Struct>::type, int, Handle<Type>::type); | 301 // static void struct_set(Handle<Struct>::type, int, Handle<Type>::type); |
| 294 // template<class V> | 302 // template<class V> |
| 295 // static i::Handle<V> struct_get_value(Handle<Struct>::type, int); | 303 // static i::Handle<V> struct_get_value(Handle<Struct>::type, int); |
| 296 // template<class V> | 304 // template<class V> |
| 297 // static void struct_set_value(Handle<Struct>::type, int, i::Handle<V>); | 305 // static void struct_set_value(Handle<Struct>::type, int, i::Handle<V>); |
| 306 // |
| 307 // static Handle<Range>::type range_create(Region*); |
| 308 // static int range_get_bitset(Handle<Range>::type); |
| 309 // static void range_set_bitset(Handle<Range>::type, int); |
| 310 // static double range_get_double(Handle<Range>::type, int); |
| 311 // static void range_set_double(Handle<Range>::type, int, double, Region*); |
| 298 // } | 312 // } |
| 299 template<class Config> | 313 template<class Config> |
| 300 class TypeImpl : public Config::Base { | 314 class TypeImpl : public Config::Base { |
| 301 public: | 315 public: |
| 302 // Auxiliary types. | 316 // Auxiliary types. |
| 303 | 317 |
| 304 typedef uint32_t bitset; // Internal | 318 typedef uint32_t bitset; // Internal |
| 305 class BitsetType; // Internal | 319 class BitsetType; // Internal |
| 306 class StructuralType; // Internal | 320 class StructuralType; // Internal |
| 307 class UnionType; // Internal | 321 class UnionType; // Internal |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 static TypeHandle UnsignedSmall(Region* region) { | 361 static TypeHandle UnsignedSmall(Region* region) { |
| 348 return BitsetType::New(BitsetType::UnsignedSmall(), region); | 362 return BitsetType::New(BitsetType::UnsignedSmall(), region); |
| 349 } | 363 } |
| 350 | 364 |
| 351 static TypeHandle Class(i::Handle<i::Map> map, Region* region) { | 365 static TypeHandle Class(i::Handle<i::Map> map, Region* region) { |
| 352 return ClassType::New(map, region); | 366 return ClassType::New(map, region); |
| 353 } | 367 } |
| 354 static TypeHandle Constant(i::Handle<i::Object> value, Region* region) { | 368 static TypeHandle Constant(i::Handle<i::Object> value, Region* region) { |
| 355 return ConstantType::New(value, region); | 369 return ConstantType::New(value, region); |
| 356 } | 370 } |
| 357 static TypeHandle Range( | 371 static TypeHandle Range(double min, double max, Region* region) { |
| 358 i::Handle<i::Object> min, i::Handle<i::Object> max, Region* region) { | |
| 359 return RangeType::New( | 372 return RangeType::New( |
| 360 min, max, BitsetType::New(REPRESENTATION(BitsetType::kTagged | | 373 min, max, BitsetType::New(REPRESENTATION(BitsetType::kTagged | |
| 361 BitsetType::kUntaggedNumber), | 374 BitsetType::kUntaggedNumber), |
| 362 region), | 375 region), |
| 363 region); | 376 region); |
| 364 } | 377 } |
| 365 static TypeHandle Context(TypeHandle outer, Region* region) { | 378 static TypeHandle Context(TypeHandle outer, Region* region) { |
| 366 return ContextType::New(outer, region); | 379 return ContextType::New(outer, region); |
| 367 } | 380 } |
| 368 static TypeHandle Array(TypeHandle element, Region* region) { | 381 static TypeHandle Array(TypeHandle element, Region* region) { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 bool NowIs(TypeImpl* that); | 459 bool NowIs(TypeImpl* that); |
| 447 template<class TypeHandle> | 460 template<class TypeHandle> |
| 448 bool NowIs(TypeHandle that) { return this->NowIs(*that); } | 461 bool NowIs(TypeHandle that) { return this->NowIs(*that); } |
| 449 inline bool NowContains(i::Object* val); | 462 inline bool NowContains(i::Object* val); |
| 450 bool NowContains(i::Handle<i::Object> val) { return this->NowContains(*val); } | 463 bool NowContains(i::Handle<i::Object> val) { return this->NowContains(*val); } |
| 451 | 464 |
| 452 bool NowStable(); | 465 bool NowStable(); |
| 453 | 466 |
| 454 // Inspection. | 467 // Inspection. |
| 455 | 468 |
| 469 bool IsRange() { return Config::is_range(this); } |
| 456 bool IsClass() { | 470 bool IsClass() { |
| 457 return Config::is_class(this) | 471 return Config::is_class(this) |
| 458 || Config::is_struct(this, StructuralType::kClassTag); | 472 || Config::is_struct(this, StructuralType::kClassTag); |
| 459 } | 473 } |
| 460 bool IsConstant() { | 474 bool IsConstant() { |
| 461 return Config::is_struct(this, StructuralType::kConstantTag); | 475 return Config::is_struct(this, StructuralType::kConstantTag); |
| 462 } | 476 } |
| 463 bool IsRange() { | |
| 464 return Config::is_struct(this, StructuralType::kRangeTag); | |
| 465 } | |
| 466 bool IsContext() { | 477 bool IsContext() { |
| 467 return Config::is_struct(this, StructuralType::kContextTag); | 478 return Config::is_struct(this, StructuralType::kContextTag); |
| 468 } | 479 } |
| 469 bool IsArray() { | 480 bool IsArray() { |
| 470 return Config::is_struct(this, StructuralType::kArrayTag); | 481 return Config::is_struct(this, StructuralType::kArrayTag); |
| 471 } | 482 } |
| 472 bool IsFunction() { | 483 bool IsFunction() { |
| 473 return Config::is_struct(this, StructuralType::kFunctionTag); | 484 return Config::is_struct(this, StructuralType::kFunctionTag); |
| 474 } | 485 } |
| 475 | 486 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 // Printing. | 527 // Printing. |
| 517 | 528 |
| 518 enum PrintDimension { BOTH_DIMS, SEMANTIC_DIM, REPRESENTATION_DIM }; | 529 enum PrintDimension { BOTH_DIMS, SEMANTIC_DIM, REPRESENTATION_DIM }; |
| 519 | 530 |
| 520 void PrintTo(std::ostream& os, PrintDimension dim = BOTH_DIMS); // NOLINT | 531 void PrintTo(std::ostream& os, PrintDimension dim = BOTH_DIMS); // NOLINT |
| 521 | 532 |
| 522 #ifdef DEBUG | 533 #ifdef DEBUG |
| 523 void Print(); | 534 void Print(); |
| 524 #endif | 535 #endif |
| 525 | 536 |
| 537 bool IsUnionForTesting() { return IsUnion(); } |
| 538 |
| 526 protected: | 539 protected: |
| 527 // Friends. | 540 // Friends. |
| 528 | 541 |
| 529 template<class> friend class Iterator; | 542 template<class> friend class Iterator; |
| 530 template<class> friend class TypeImpl; | 543 template<class> friend class TypeImpl; |
| 531 | 544 |
| 532 // Handle conversion. | 545 // Handle conversion. |
| 533 | 546 |
| 534 template<class T> | 547 template<class T> |
| 535 static typename Config::template Handle<T>::type handle(T* type) { | 548 static typename Config::template Handle<T>::type handle(T* type) { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 558 bool SlowIs(TypeImpl* that); | 571 bool SlowIs(TypeImpl* that); |
| 559 | 572 |
| 560 static bool IsInteger(double x) { | 573 static bool IsInteger(double x) { |
| 561 return nearbyint(x) == x && !i::IsMinusZero(x); // Allows for infinities. | 574 return nearbyint(x) == x && !i::IsMinusZero(x); // Allows for infinities. |
| 562 } | 575 } |
| 563 static bool IsInteger(i::Object* x) { | 576 static bool IsInteger(i::Object* x) { |
| 564 return x->IsNumber() && IsInteger(x->Number()); | 577 return x->IsNumber() && IsInteger(x->Number()); |
| 565 } | 578 } |
| 566 | 579 |
| 567 struct Limits { | 580 struct Limits { |
| 568 i::Handle<i::Object> min; | 581 double min; |
| 569 i::Handle<i::Object> max; | 582 double max; |
| 570 bitset representation; | 583 bitset representation; |
| 571 Limits(i::Handle<i::Object> min, i::Handle<i::Object> max, | 584 Limits(double min, double max, bitset representation) |
| 572 bitset representation) | |
| 573 : min(min), max(max), representation(representation) {} | 585 : min(min), max(max), representation(representation) {} |
| 574 explicit Limits(RangeType* range) | 586 explicit Limits(RangeType* range) |
| 575 : min(range->Min()), | 587 : min(range->Min()), |
| 576 max(range->Max()), | 588 max(range->Max()), |
| 577 representation(REPRESENTATION(range->Bound()->AsBitset())) {} | 589 representation(REPRESENTATION(range->Bound())) {} |
| 578 static Limits Empty(Region* region) { | 590 static Limits Empty(Region* region) { |
| 579 // TODO(jarin) Get rid of the heap numbers. | 591 return Limits(1, 0, BitsetType::kNone); |
| 580 i::Factory* f = i::Isolate::Current()->factory(); | |
| 581 i::Handle<i::Object> min = f->NewNumber(1); | |
| 582 i::Handle<i::Object> max = f->NewNumber(0); | |
| 583 return Limits(min, max, BitsetType::kNone); | |
| 584 } | 592 } |
| 585 }; | 593 }; |
| 586 | 594 |
| 587 static bool IsEmpty(Limits lim); | 595 static bool IsEmpty(Limits lim); |
| 588 static Limits Intersect(Limits lhs, Limits rhs); | 596 static Limits Intersect(Limits lhs, Limits rhs); |
| 589 static Limits Union(Limits lhs, Limits rhs); | 597 static Limits Union(Limits lhs, Limits rhs); |
| 590 static bool Overlap(RangeType* lhs, RangeType* rhs); | 598 static bool Overlap(RangeType* lhs, RangeType* rhs); |
| 591 static bool Contains(RangeType* lhs, RangeType* rhs); | 599 static bool Contains(RangeType* lhs, RangeType* rhs); |
| 592 static bool Contains(RangeType* range, ConstantType* constant); | 600 static bool Contains(RangeType* range, ConstantType* constant); |
| 593 static bool Contains(RangeType* range, i::Object* val); | 601 static bool Contains(RangeType* range, i::Object* val); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 691 template<class Config> | 699 template<class Config> |
| 692 class TypeImpl<Config>::StructuralType : public TypeImpl<Config> { | 700 class TypeImpl<Config>::StructuralType : public TypeImpl<Config> { |
| 693 protected: | 701 protected: |
| 694 template<class> friend class TypeImpl; | 702 template<class> friend class TypeImpl; |
| 695 friend struct ZoneTypeConfig; // For tags. | 703 friend struct ZoneTypeConfig; // For tags. |
| 696 friend struct HeapTypeConfig; | 704 friend struct HeapTypeConfig; |
| 697 | 705 |
| 698 enum Tag { | 706 enum Tag { |
| 699 kClassTag, | 707 kClassTag, |
| 700 kConstantTag, | 708 kConstantTag, |
| 701 kRangeTag, | |
| 702 kContextTag, | 709 kContextTag, |
| 703 kArrayTag, | 710 kArrayTag, |
| 704 kFunctionTag, | 711 kFunctionTag, |
| 705 kUnionTag | 712 kUnionTag |
| 706 }; | 713 }; |
| 707 | 714 |
| 708 int Length() { | 715 int Length() { |
| 709 return Config::struct_length(Config::as_struct(this)); | 716 return Config::struct_length(Config::as_struct(this)); |
| 710 } | 717 } |
| 711 TypeHandle Get(int i) { | 718 TypeHandle Get(int i) { |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 817 return static_cast<ConstantType*>(type); | 824 return static_cast<ConstantType*>(type); |
| 818 } | 825 } |
| 819 }; | 826 }; |
| 820 // TODO(neis): Also cache value if numerical. | 827 // TODO(neis): Also cache value if numerical. |
| 821 // TODO(neis): Allow restricting the representation. | 828 // TODO(neis): Allow restricting the representation. |
| 822 | 829 |
| 823 | 830 |
| 824 // ----------------------------------------------------------------------------- | 831 // ----------------------------------------------------------------------------- |
| 825 // Range types. | 832 // Range types. |
| 826 | 833 |
| 827 template<class Config> | 834 template <class Config> |
| 828 class TypeImpl<Config>::RangeType : public StructuralType { | 835 class TypeImpl<Config>::RangeType : public TypeImpl<Config> { |
| 829 public: | 836 public: |
| 830 TypeHandle Bound() { return this->Get(0); } | 837 bitset Bound() { return Config::range_get_bitset(Config::as_range(this)); } |
| 831 i::Handle<i::Object> Min() { return this->template GetValue<i::Object>(1); } | 838 double Min() { return Config::range_get_double(Config::as_range(this), 0); } |
| 832 i::Handle<i::Object> Max() { return this->template GetValue<i::Object>(2); } | 839 double Max() { return Config::range_get_double(Config::as_range(this), 1); } |
| 833 | 840 |
| 834 static RangeHandle New(i::Handle<i::Object> min, i::Handle<i::Object> max, | 841 static RangeHandle New(double min, double max, TypeHandle representation, |
| 835 TypeHandle representation, Region* region) { | 842 Region* region) { |
| 836 DCHECK(IsInteger(min->Number()) && IsInteger(max->Number())); | 843 DCHECK(IsInteger(min) && IsInteger(max)); |
| 837 DCHECK(min->Number() <= max->Number()); | 844 DCHECK(min <= max); |
| 838 bitset representation_bits = representation->AsBitset(); | 845 bitset representation_bits = representation->AsBitset(); |
| 839 DCHECK(REPRESENTATION(representation_bits) == representation_bits); | 846 DCHECK(REPRESENTATION(representation_bits) == representation_bits); |
| 840 | 847 |
| 841 RangeHandle type = Config::template cast<RangeType>( | 848 typename Config::template Handle<typename Config::Range>::type range = |
| 842 StructuralType::New(StructuralType::kRangeTag, 3, region)); | 849 Config::range_create(region); |
| 843 | 850 |
| 844 bitset bits = SEMANTIC(BitsetType::Lub(min->Number(), max->Number())) | | 851 bitset bits = SEMANTIC(BitsetType::Lub(min, max)) | representation_bits; |
| 845 representation_bits; | 852 Config::range_set_bitset(range, bits); |
| 846 type->Set(0, BitsetType::New(bits, region)); | 853 Config::range_set_double(range, 0, min, region); |
| 847 type->SetValue(1, min); | 854 Config::range_set_double(range, 1, max, region); |
| 848 type->SetValue(2, max); | 855 return Config::template cast<RangeType>(Config::from_range(range)); |
| 849 return type; | |
| 850 } | 856 } |
| 851 | 857 |
| 852 static RangeHandle New(Limits lim, Region* region) { | 858 static RangeHandle New(Limits lim, Region* region) { |
| 853 return New(lim.min, lim.max, BitsetType::New(lim.representation, region), | 859 return New(lim.min, lim.max, BitsetType::New(lim.representation, region), |
| 854 region); | 860 region); |
| 855 } | 861 } |
| 856 | 862 |
| 857 static RangeType* cast(TypeImpl* type) { | 863 static RangeType* cast(TypeImpl* type) { |
| 858 DCHECK(type->IsRange()); | 864 DCHECK(type->IsRange()); |
| 859 return static_cast<RangeType*>(type); | 865 return static_cast<RangeType*>(type); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 963 | 969 |
| 964 | 970 |
| 965 // ----------------------------------------------------------------------------- | 971 // ----------------------------------------------------------------------------- |
| 966 // Zone-allocated types; they are either (odd) integers to represent bitsets, or | 972 // Zone-allocated types; they are either (odd) integers to represent bitsets, or |
| 967 // (even) pointers to structures for everything else. | 973 // (even) pointers to structures for everything else. |
| 968 | 974 |
| 969 struct ZoneTypeConfig { | 975 struct ZoneTypeConfig { |
| 970 typedef TypeImpl<ZoneTypeConfig> Type; | 976 typedef TypeImpl<ZoneTypeConfig> Type; |
| 971 class Base {}; | 977 class Base {}; |
| 972 typedef void* Struct; | 978 typedef void* Struct; |
| 979 // Hack: the Struct and Range types can be aliased in memory, the first |
| 980 // pointer word of each both must be the tag (kRangeStructTag for Range, |
| 981 // anything else for Struct) so that we can differentiate them. |
| 982 struct Range { |
| 983 void* tag; |
| 984 int bitset; |
| 985 double limits[2]; |
| 986 }; |
| 973 typedef i::Zone Region; | 987 typedef i::Zone Region; |
| 974 template<class T> struct Handle { typedef T* type; }; | 988 template<class T> struct Handle { typedef T* type; }; |
| 975 | 989 |
| 990 static const int kRangeStructTag = 0x1000; |
| 991 |
| 976 template<class T> static inline T* null_handle(); | 992 template<class T> static inline T* null_handle(); |
| 977 template<class T> static inline T* handle(T* type); | 993 template<class T> static inline T* handle(T* type); |
| 978 template<class T> static inline T* cast(Type* type); | 994 template<class T> static inline T* cast(Type* type); |
| 979 | 995 |
| 980 static inline bool is_bitset(Type* type); | 996 static inline bool is_bitset(Type* type); |
| 981 static inline bool is_class(Type* type); | 997 static inline bool is_class(Type* type); |
| 982 static inline bool is_struct(Type* type, int tag); | 998 static inline bool is_struct(Type* type, int tag); |
| 999 static inline bool is_range(Type* type); |
| 983 | 1000 |
| 984 static inline Type::bitset as_bitset(Type* type); | 1001 static inline Type::bitset as_bitset(Type* type); |
| 985 static inline i::Handle<i::Map> as_class(Type* type); | 1002 static inline i::Handle<i::Map> as_class(Type* type); |
| 986 static inline Struct* as_struct(Type* type); | 1003 static inline Struct* as_struct(Type* type); |
| 1004 static inline Range* as_range(Type* type); |
| 987 | 1005 |
| 988 static inline Type* from_bitset(Type::bitset); | 1006 static inline Type* from_bitset(Type::bitset); |
| 989 static inline Type* from_bitset(Type::bitset, Zone* zone); | 1007 static inline Type* from_bitset(Type::bitset, Zone* zone); |
| 990 static inline Type* from_class(i::Handle<i::Map> map, Zone* zone); | 1008 static inline Type* from_class(i::Handle<i::Map> map, Zone* zone); |
| 991 static inline Type* from_struct(Struct* structured); | 1009 static inline Type* from_struct(Struct* structured); |
| 1010 static inline Type* from_range(Range* range); |
| 992 | 1011 |
| 993 static inline Struct* struct_create(int tag, int length, Zone* zone); | 1012 static inline Struct* struct_create(int tag, int length, Zone* zone); |
| 994 static inline void struct_shrink(Struct* structure, int length); | 1013 static inline void struct_shrink(Struct* structure, int length); |
| 995 static inline int struct_tag(Struct* structure); | 1014 static inline int struct_tag(Struct* structure); |
| 996 static inline int struct_length(Struct* structure); | 1015 static inline int struct_length(Struct* structure); |
| 997 static inline Type* struct_get(Struct* structure, int i); | 1016 static inline Type* struct_get(Struct* structure, int i); |
| 998 static inline void struct_set(Struct* structure, int i, Type* type); | 1017 static inline void struct_set(Struct* structure, int i, Type* type); |
| 999 template<class V> | 1018 template<class V> |
| 1000 static inline i::Handle<V> struct_get_value(Struct* structure, int i); | 1019 static inline i::Handle<V> struct_get_value(Struct* structure, int i); |
| 1001 template<class V> static inline void struct_set_value( | 1020 template<class V> static inline void struct_set_value( |
| 1002 Struct* structure, int i, i::Handle<V> x); | 1021 Struct* structure, int i, i::Handle<V> x); |
| 1022 |
| 1023 static inline Range* range_create(Zone* zone); |
| 1024 static inline int range_get_bitset(Range* range); |
| 1025 static inline void range_set_bitset(Range* range, int); |
| 1026 static inline double range_get_double(Range*, int index); |
| 1027 static inline void range_set_double(Range*, int index, double value, Zone*); |
| 1003 }; | 1028 }; |
| 1004 | 1029 |
| 1005 typedef TypeImpl<ZoneTypeConfig> Type; | 1030 typedef TypeImpl<ZoneTypeConfig> Type; |
| 1006 | 1031 |
| 1007 | 1032 |
| 1008 // ----------------------------------------------------------------------------- | 1033 // ----------------------------------------------------------------------------- |
| 1009 // Heap-allocated types; either smis for bitsets, maps for classes, boxes for | 1034 // Heap-allocated types; either smis for bitsets, maps for classes, boxes for |
| 1010 // constants, or fixed arrays for unions. | 1035 // constants, or fixed arrays for unions. |
| 1011 | 1036 |
| 1012 struct HeapTypeConfig { | 1037 struct HeapTypeConfig { |
| 1013 typedef TypeImpl<HeapTypeConfig> Type; | 1038 typedef TypeImpl<HeapTypeConfig> Type; |
| 1014 typedef i::Object Base; | 1039 typedef i::Object Base; |
| 1015 typedef i::FixedArray Struct; | 1040 typedef i::FixedArray Struct; |
| 1041 typedef i::FixedArray Range; |
| 1016 typedef i::Isolate Region; | 1042 typedef i::Isolate Region; |
| 1017 template<class T> struct Handle { typedef i::Handle<T> type; }; | 1043 template<class T> struct Handle { typedef i::Handle<T> type; }; |
| 1018 | 1044 |
| 1045 static const int kRangeStructTag = 0xffff; |
| 1046 |
| 1019 template<class T> static inline i::Handle<T> null_handle(); | 1047 template<class T> static inline i::Handle<T> null_handle(); |
| 1020 template<class T> static inline i::Handle<T> handle(T* type); | 1048 template<class T> static inline i::Handle<T> handle(T* type); |
| 1021 template<class T> static inline i::Handle<T> cast(i::Handle<Type> type); | 1049 template<class T> static inline i::Handle<T> cast(i::Handle<Type> type); |
| 1022 | 1050 |
| 1023 static inline bool is_bitset(Type* type); | 1051 static inline bool is_bitset(Type* type); |
| 1024 static inline bool is_class(Type* type); | 1052 static inline bool is_class(Type* type); |
| 1025 static inline bool is_struct(Type* type, int tag); | 1053 static inline bool is_struct(Type* type, int tag); |
| 1054 static inline bool is_range(Type* type); |
| 1026 | 1055 |
| 1027 static inline Type::bitset as_bitset(Type* type); | 1056 static inline Type::bitset as_bitset(Type* type); |
| 1028 static inline i::Handle<i::Map> as_class(Type* type); | 1057 static inline i::Handle<i::Map> as_class(Type* type); |
| 1029 static inline i::Handle<Struct> as_struct(Type* type); | 1058 static inline i::Handle<Struct> as_struct(Type* type); |
| 1059 static inline i::Handle<Range> as_range(Type* type); |
| 1030 | 1060 |
| 1031 static inline Type* from_bitset(Type::bitset); | 1061 static inline Type* from_bitset(Type::bitset); |
| 1032 static inline i::Handle<Type> from_bitset(Type::bitset, Isolate* isolate); | 1062 static inline i::Handle<Type> from_bitset(Type::bitset, Isolate* isolate); |
| 1033 static inline i::Handle<Type> from_class( | 1063 static inline i::Handle<Type> from_class( |
| 1034 i::Handle<i::Map> map, Isolate* isolate); | 1064 i::Handle<i::Map> map, Isolate* isolate); |
| 1035 static inline i::Handle<Type> from_struct(i::Handle<Struct> structure); | 1065 static inline i::Handle<Type> from_struct(i::Handle<Struct> structure); |
| 1066 static inline i::Handle<Type> from_range(i::Handle<Range> range); |
| 1036 | 1067 |
| 1037 static inline i::Handle<Struct> struct_create( | 1068 static inline i::Handle<Struct> struct_create( |
| 1038 int tag, int length, Isolate* isolate); | 1069 int tag, int length, Isolate* isolate); |
| 1039 static inline void struct_shrink(i::Handle<Struct> structure, int length); | 1070 static inline void struct_shrink(i::Handle<Struct> structure, int length); |
| 1040 static inline int struct_tag(i::Handle<Struct> structure); | 1071 static inline int struct_tag(i::Handle<Struct> structure); |
| 1041 static inline int struct_length(i::Handle<Struct> structure); | 1072 static inline int struct_length(i::Handle<Struct> structure); |
| 1042 static inline i::Handle<Type> struct_get(i::Handle<Struct> structure, int i); | 1073 static inline i::Handle<Type> struct_get(i::Handle<Struct> structure, int i); |
| 1043 static inline void struct_set( | 1074 static inline void struct_set( |
| 1044 i::Handle<Struct> structure, int i, i::Handle<Type> type); | 1075 i::Handle<Struct> structure, int i, i::Handle<Type> type); |
| 1045 template<class V> | 1076 template<class V> |
| 1046 static inline i::Handle<V> struct_get_value( | 1077 static inline i::Handle<V> struct_get_value( |
| 1047 i::Handle<Struct> structure, int i); | 1078 i::Handle<Struct> structure, int i); |
| 1048 template<class V> | 1079 template<class V> |
| 1049 static inline void struct_set_value( | 1080 static inline void struct_set_value( |
| 1050 i::Handle<Struct> structure, int i, i::Handle<V> x); | 1081 i::Handle<Struct> structure, int i, i::Handle<V> x); |
| 1082 |
| 1083 static inline i::Handle<Range> range_create(Isolate* isolate); |
| 1084 static inline int range_get_bitset(i::Handle<Range> range); |
| 1085 static inline void range_set_bitset(i::Handle<Range> range, int value); |
| 1086 static inline double range_get_double(i::Handle<Range> range, int index); |
| 1087 static inline void range_set_double(i::Handle<Range> range, int index, |
| 1088 double value, Isolate* isolate); |
| 1051 }; | 1089 }; |
| 1052 | 1090 |
| 1053 typedef TypeImpl<HeapTypeConfig> HeapType; | 1091 typedef TypeImpl<HeapTypeConfig> HeapType; |
| 1054 | 1092 |
| 1055 | 1093 |
| 1056 // ----------------------------------------------------------------------------- | 1094 // ----------------------------------------------------------------------------- |
| 1057 // Type bounds. A simple struct to represent a pair of lower/upper types. | 1095 // Type bounds. A simple struct to represent a pair of lower/upper types. |
| 1058 | 1096 |
| 1059 template<class Config> | 1097 template<class Config> |
| 1060 struct BoundsImpl { | 1098 struct BoundsImpl { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1111 bool Narrows(BoundsImpl that) { | 1149 bool Narrows(BoundsImpl that) { |
| 1112 return that.lower->Is(this->lower) && this->upper->Is(that.upper); | 1150 return that.lower->Is(this->lower) && this->upper->Is(that.upper); |
| 1113 } | 1151 } |
| 1114 }; | 1152 }; |
| 1115 | 1153 |
| 1116 typedef BoundsImpl<ZoneTypeConfig> Bounds; | 1154 typedef BoundsImpl<ZoneTypeConfig> Bounds; |
| 1117 | 1155 |
| 1118 } } // namespace v8::internal | 1156 } } // namespace v8::internal |
| 1119 | 1157 |
| 1120 #endif // V8_TYPES_H_ | 1158 #endif // V8_TYPES_H_ |
| OLD | NEW |