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

Side by Side Diff: src/compiler/type-cache.h

Issue 2296593002: [turbofan] Sanitize typing of Date builtins. (Closed)
Patch Set: Fix comment. 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 | « no previous file | src/compiler/typer.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_COMPILER_TYPE_CACHE_H_ 5 #ifndef V8_COMPILER_TYPE_CACHE_H_
6 #define V8_COMPILER_TYPE_CACHE_H_ 6 #define V8_COMPILER_TYPE_CACHE_H_
7 7
8 #include "src/date.h" 8 #include "src/date.h"
9 #include "src/types.h" 9 #include "src/types.h"
10 10
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 // The JSTyped::length property always contains a tagged number in the range 97 // The JSTyped::length property always contains a tagged number in the range
98 // [0, kMaxSmiValue]. 98 // [0, kMaxSmiValue].
99 Type* const kJSTypedArrayLengthType = 99 Type* const kJSTypedArrayLengthType =
100 CreateNative(Type::UnsignedSmall(), Type::TaggedSigned()); 100 CreateNative(Type::UnsignedSmall(), Type::TaggedSigned());
101 101
102 // The String::length property always contains a smi in the range 102 // The String::length property always contains a smi in the range
103 // [0, String::kMaxLength]. 103 // [0, String::kMaxLength].
104 Type* const kStringLengthType = 104 Type* const kStringLengthType =
105 CreateNative(CreateRange(0.0, String::kMaxLength), Type::TaggedSigned()); 105 CreateNative(CreateRange(0.0, String::kMaxLength), Type::TaggedSigned());
106 106
107 // The JSDate::value properties always contains a tagged number in the range 107 // The JSDate::day property always contains a tagged number in the range
108 // [1, 31] or NaN.
109 Type* const kJSDateDayType =
110 Type::Union(CreateRange(1, 31.0), Type::NaN(), zone());
111
112 // The JSDate::hour property always contains a tagged number in the range
113 // [0, 23] or NaN.
114 Type* const kJSDateHourType =
115 Type::Union(CreateRange(0, 23.0), Type::NaN(), zone());
116
117 // The JSDate::minute property always contains a tagged number in the range
118 // [0, 59] or NaN.
119 Type* const kJSDateMinuteType =
120 Type::Union(CreateRange(0, 59.0), Type::NaN(), zone());
121
122 // The JSDate::month property always contains a tagged number in the range
123 // [0, 11] or NaN.
124 Type* const kJSDateMonthType =
125 Type::Union(CreateRange(0, 11.0), Type::NaN(), zone());
126
127 // The JSDate::second property always contains a tagged number in the range
128 // [0, 59] or NaN.
129 Type* const kJSDateSecondType = kJSDateMinuteType;
130
131 // The JSDate::value property always contains a tagged number in the range
108 // [-kMaxTimeInMs, kMaxTimeInMs] or NaN. 132 // [-kMaxTimeInMs, kMaxTimeInMs] or NaN.
109 Type* const kJSDateValueType = Type::Union( 133 Type* const kJSDateValueType = Type::Union(
110 CreateRange(-DateCache::kMaxTimeInMs, DateCache::kMaxTimeInMs), 134 CreateRange(-DateCache::kMaxTimeInMs, DateCache::kMaxTimeInMs),
111 Type::NaN(), zone()); 135 Type::NaN(), zone());
112 136
137 // The JSDate::weekday property always contains a tagged number in the range
138 // [0, 6] or NaN.
139 Type* const kJSDateWeekdayType =
140 Type::Union(CreateRange(0, 6.0), Type::NaN(), zone());
141
142 // The JSDate::year property always contains a tagged number in the signed
143 // small range or NaN.
144 Type* const kJSDateYearType =
145 Type::Union(Type::SignedSmall(), Type::NaN(), zone());
146
113 #define TYPED_ARRAY(TypeName, type_name, TYPE_NAME, ctype, size) \ 147 #define TYPED_ARRAY(TypeName, type_name, TYPE_NAME, ctype, size) \
114 Type* const k##TypeName##Array = CreateArray(k##TypeName); 148 Type* const k##TypeName##Array = CreateArray(k##TypeName);
115 TYPED_ARRAYS(TYPED_ARRAY) 149 TYPED_ARRAYS(TYPED_ARRAY)
116 #undef TYPED_ARRAY 150 #undef TYPED_ARRAY
117 151
118 private: 152 private:
119 Type* CreateArray(Type* element) { return Type::Array(element, zone()); } 153 Type* CreateArray(Type* element) { return Type::Array(element, zone()); }
120 154
121 Type* CreateArrayFunction(Type* array) { 155 Type* CreateArrayFunction(Type* array) {
122 Type* arg1 = Type::Union(Type::Unsigned32(), Type::Object(), zone()); 156 Type* arg1 = Type::Union(Type::Unsigned32(), Type::Object(), zone());
(...skipping 17 matching lines...) Expand all
140 } 174 }
141 175
142 Zone* zone() { return &zone_; } 176 Zone* zone() { return &zone_; }
143 }; 177 };
144 178
145 } // namespace compiler 179 } // namespace compiler
146 } // namespace internal 180 } // namespace internal
147 } // namespace v8 181 } // namespace v8
148 182
149 #endif // V8_COMPILER_TYPE_CACHE_H_ 183 #endif // V8_COMPILER_TYPE_CACHE_H_
OLDNEW
« no previous file with comments | « no previous file | src/compiler/typer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698