Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(107)

Side by Side Diff: src/types.h

Issue 2305383002: [turbofan] Nuke the context types. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/verifier.cc ('k') | src/types.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/handles.h" 9 #include "src/handles.h"
10 #include "src/objects.h" 10 #include "src/objects.h"
(...skipping 30 matching lines...) Expand all
41 // Receiver = Object \/ Proxy 41 // Receiver = Object \/ Proxy
42 // Array < Object 42 // Array < Object
43 // Function < Object 43 // Function < Object
44 // RegExp < Object 44 // RegExp < Object
45 // OtherUndetectable < Object 45 // OtherUndetectable < Object
46 // DetectableReceiver = Receiver - OtherUndetectable 46 // DetectableReceiver = Receiver - OtherUndetectable
47 // 47 //
48 // Constant(x) < T iff instance_type(map(x)) < T 48 // Constant(x) < T iff instance_type(map(x)) < T
49 // Array(T) < Array 49 // Array(T) < Array
50 // Function(R, S, T0, T1, ...) < Function 50 // Function(R, S, T0, T1, ...) < Function
51 // Context(T) < Internal
52 // 51 //
53 // Both structural Array and Function types are invariant in all parameters; 52 // Both structural Array and Function types are invariant in all parameters;
54 // relaxing this would make Union and Intersect operations more involved. 53 // relaxing this would make Union and Intersect operations more involved.
55 // There is no subtyping relation between Array, Function, or Context types 54 // There is no subtyping relation between Array or Function types and
56 // and respective Constant types, since these types cannot be reconstructed 55 // respective Constant types, since these types cannot be reconstructed
57 // for arbitrary heap values. 56 // for arbitrary heap values.
58 // 57 //
59 // 58 //
60 // REPRESENTATIONAL DIMENSION 59 // REPRESENTATIONAL DIMENSION
61 // 60 //
62 // For the representation axis, the following holds: 61 // For the representation axis, the following holds:
63 // 62 //
64 // None <= R 63 // None <= R
65 // R <= Any 64 // R <= Any
66 // 65 //
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 }; 341 };
343 342
344 // ----------------------------------------------------------------------------- 343 // -----------------------------------------------------------------------------
345 // Superclass for non-bitset types (internal). 344 // Superclass for non-bitset types (internal).
346 class TypeBase { 345 class TypeBase {
347 protected: 346 protected:
348 friend class Type; 347 friend class Type;
349 348
350 enum Kind { 349 enum Kind {
351 kConstant, 350 kConstant,
352 kContext,
353 kArray, 351 kArray,
354 kFunction, 352 kFunction,
355 kTuple, 353 kTuple,
356 kUnion, 354 kUnion,
357 kRange 355 kRange
358 }; 356 };
359 357
360 Kind kind() const { return kind_; } 358 Kind kind() const { return kind_; }
361 explicit TypeBase(Kind kind) : kind_(kind) {} 359 explicit TypeBase(Kind kind) : kind_(kind) {}
362 360
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 RangeType(BitsetType::bitset bitset, Limits limits) 458 RangeType(BitsetType::bitset bitset, Limits limits)
461 : TypeBase(kRange), bitset_(bitset), limits_(limits) {} 459 : TypeBase(kRange), bitset_(bitset), limits_(limits) {}
462 460
463 BitsetType::bitset Lub() { return bitset_; } 461 BitsetType::bitset Lub() { return bitset_; }
464 462
465 BitsetType::bitset bitset_; 463 BitsetType::bitset bitset_;
466 Limits limits_; 464 Limits limits_;
467 }; 465 };
468 466
469 // ----------------------------------------------------------------------------- 467 // -----------------------------------------------------------------------------
470 // Context types.
471
472 class ContextType : public TypeBase {
473 public:
474 Type* Outer() { return outer_; }
475
476 private:
477 friend class Type;
478
479 static Type* New(Type* outer, Zone* zone) {
480 return AsType(new (zone->New(sizeof(ContextType))) ContextType(outer));
481 }
482
483 static ContextType* cast(Type* type) {
484 DCHECK(IsKind(type, kContext));
485 return static_cast<ContextType*>(FromType(type));
486 }
487
488 explicit ContextType(Type* outer) : TypeBase(kContext), outer_(outer) {}
489
490 Type* outer_;
491 };
492
493 // -----------------------------------------------------------------------------
494 // Array types. 468 // Array types.
495 469
496 class ArrayType : public TypeBase { 470 class ArrayType : public TypeBase {
497 public: 471 public:
498 Type* Element() { return element_; } 472 Type* Element() { return element_; }
499 473
500 private: 474 private:
501 friend class Type; 475 friend class Type;
502 476
503 explicit ArrayType(Type* element) : TypeBase(kArray), element_(element) {} 477 explicit ArrayType(Type* element) : TypeBase(kArray), element_(element) {}
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 } 625 }
652 626
653 static Type* Constant(i::Handle<i::Object> value, Zone* zone) { 627 static Type* Constant(i::Handle<i::Object> value, Zone* zone) {
654 return ConstantType::New(value, zone); 628 return ConstantType::New(value, zone);
655 } 629 }
656 static Type* Range(double min, double max, Zone* zone) { 630 static Type* Range(double min, double max, Zone* zone) {
657 return RangeType::New(min, max, REPRESENTATION(BitsetType::kTagged | 631 return RangeType::New(min, max, REPRESENTATION(BitsetType::kTagged |
658 BitsetType::kUntaggedNumber), 632 BitsetType::kUntaggedNumber),
659 zone); 633 zone);
660 } 634 }
661 static Type* Context(Type* outer, Zone* zone) {
662 return ContextType::New(outer, zone);
663 }
664 static Type* Array(Type* element, Zone* zone) { 635 static Type* Array(Type* element, Zone* zone) {
665 return ArrayType::New(element, zone); 636 return ArrayType::New(element, zone);
666 } 637 }
667 static Type* Function(Type* result, Type* receiver, int arity, Zone* zone) { 638 static Type* Function(Type* result, Type* receiver, int arity, Zone* zone) {
668 return FunctionType::New(result, receiver, arity, zone); 639 return FunctionType::New(result, receiver, arity, zone);
669 } 640 }
670 static Type* Function(Type* result, Zone* zone) { 641 static Type* Function(Type* result, Zone* zone) {
671 return Function(result, Any(), 0, zone); 642 return Function(result, Any(), 0, zone);
672 } 643 }
673 static Type* Function(Type* result, Type* param0, Zone* zone) { 644 static Type* Function(Type* result, Type* param0, Zone* zone) {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 bool Maybe(Type* that); 704 bool Maybe(Type* that);
734 bool Equals(Type* that) { return this->Is(that) && that->Is(this); } 705 bool Equals(Type* that) { return this->Is(that) && that->Is(this); }
735 706
736 // Equivalent to Constant(val)->Is(this), but avoiding allocation. 707 // Equivalent to Constant(val)->Is(this), but avoiding allocation.
737 bool Contains(i::Object* val); 708 bool Contains(i::Object* val);
738 bool Contains(i::Handle<i::Object> val) { return this->Contains(*val); } 709 bool Contains(i::Handle<i::Object> val) { return this->Contains(*val); }
739 710
740 // Inspection. 711 // Inspection.
741 bool IsRange() { return IsKind(TypeBase::kRange); } 712 bool IsRange() { return IsKind(TypeBase::kRange); }
742 bool IsConstant() { return IsKind(TypeBase::kConstant); } 713 bool IsConstant() { return IsKind(TypeBase::kConstant); }
743 bool IsContext() { return IsKind(TypeBase::kContext); }
744 bool IsArray() { return IsKind(TypeBase::kArray); } 714 bool IsArray() { return IsKind(TypeBase::kArray); }
745 bool IsFunction() { return IsKind(TypeBase::kFunction); } 715 bool IsFunction() { return IsKind(TypeBase::kFunction); }
746 bool IsTuple() { return IsKind(TypeBase::kTuple); } 716 bool IsTuple() { return IsKind(TypeBase::kTuple); }
747 717
748 ConstantType* AsConstant() { return ConstantType::cast(this); } 718 ConstantType* AsConstant() { return ConstantType::cast(this); }
749 RangeType* AsRange() { return RangeType::cast(this); } 719 RangeType* AsRange() { return RangeType::cast(this); }
750 ContextType* AsContext() { return ContextType::cast(this); }
751 ArrayType* AsArray() { return ArrayType::cast(this); } 720 ArrayType* AsArray() { return ArrayType::cast(this); }
752 FunctionType* AsFunction() { return FunctionType::cast(this); } 721 FunctionType* AsFunction() { return FunctionType::cast(this); }
753 TupleType* AsTuple() { return TupleType::cast(this); } 722 TupleType* AsTuple() { return TupleType::cast(this); }
754 723
755 // Minimum and maximum of a numeric type. 724 // Minimum and maximum of a numeric type.
756 // These functions do not distinguish between -0 and +0. If the type equals 725 // These functions do not distinguish between -0 and +0. If the type equals
757 // kNaN, they return NaN; otherwise kNaN is ignored. Only call these 726 // kNaN, they return NaN; otherwise kNaN is ignored. Only call these
758 // functions on subtypes of Number. 727 // functions on subtypes of Number.
759 double Min(); 728 double Min();
760 double Max(); 729 double Max();
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
911 } 880 }
912 881
913 bool Narrows(Bounds that) { 882 bool Narrows(Bounds that) {
914 return that.lower->Is(this->lower) && this->upper->Is(that.upper); 883 return that.lower->Is(this->lower) && this->upper->Is(that.upper);
915 } 884 }
916 }; 885 };
917 } // namespace internal 886 } // namespace internal
918 } // namespace v8 887 } // namespace v8
919 888
920 #endif // V8_TYPES_H_ 889 #endif // V8_TYPES_H_
OLDNEW
« no previous file with comments | « src/compiler/verifier.cc ('k') | src/types.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698