| 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 <iomanip> | 5 #include <iomanip> |
| 6 | 6 |
| 7 #include "src/types.h" | 7 #include "src/types.h" |
| 8 | 8 |
| 9 #include "src/handles-inl.h" | 9 #include "src/handles-inl.h" |
| 10 #include "src/ostreams.h" | 10 #include "src/ostreams.h" |
| (...skipping 1240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1251 PrintTo(os); | 1251 PrintTo(os); |
| 1252 os << std::endl; | 1252 os << std::endl; |
| 1253 } | 1253 } |
| 1254 void BitsetType::Print(bitset bits) { | 1254 void BitsetType::Print(bitset bits) { |
| 1255 OFStream os(stdout); | 1255 OFStream os(stdout); |
| 1256 Print(os, bits); | 1256 Print(os, bits); |
| 1257 os << std::endl; | 1257 os << std::endl; |
| 1258 } | 1258 } |
| 1259 #endif | 1259 #endif |
| 1260 | 1260 |
| 1261 // static | |
| 1262 FieldType* FieldType::None() { | |
| 1263 return reinterpret_cast<FieldType*>(Smi::FromInt(0)); | |
| 1264 } | |
| 1265 | |
| 1266 // static | |
| 1267 FieldType* FieldType::Any() { | |
| 1268 return reinterpret_cast<FieldType*>(Smi::FromInt(1)); | |
| 1269 } | |
| 1270 | |
| 1271 // static | |
| 1272 Handle<FieldType> FieldType::None(Isolate* isolate) { | |
| 1273 return handle(None(), isolate); | |
| 1274 } | |
| 1275 | |
| 1276 // static | |
| 1277 Handle<FieldType> FieldType::Any(Isolate* isolate) { | |
| 1278 return handle(Any(), isolate); | |
| 1279 } | |
| 1280 | |
| 1281 // static | |
| 1282 FieldType* FieldType::Class(i::Map* map) { return FieldType::cast(map); } | |
| 1283 | |
| 1284 // static | |
| 1285 Handle<FieldType> FieldType::Class(i::Handle<i::Map> map, Isolate* isolate) { | |
| 1286 return handle(Class(*map), isolate); | |
| 1287 } | |
| 1288 | |
| 1289 // static | |
| 1290 FieldType* FieldType::cast(Object* object) { | |
| 1291 DCHECK(object == None() || object == Any() || object->IsMap()); | |
| 1292 return reinterpret_cast<FieldType*>(object); | |
| 1293 } | |
| 1294 | |
| 1295 bool FieldType::NowContains(Object* value) { | |
| 1296 if (this == Any()) return true; | |
| 1297 if (this == None()) return false; | |
| 1298 if (!value->IsHeapObject()) return false; | |
| 1299 return HeapObject::cast(value)->map() == Map::cast(this); | |
| 1300 } | |
| 1301 | |
| 1302 bool FieldType::NowContains(Handle<Object> value) { | |
| 1303 return NowContains(*value); | |
| 1304 } | |
| 1305 | |
| 1306 bool FieldType::IsClass() { return this->IsMap(); } | |
| 1307 | |
| 1308 Handle<i::Map> FieldType::AsClass() { | |
| 1309 DCHECK(IsClass()); | |
| 1310 i::Map* map = Map::cast(this); | |
| 1311 return handle(map, map->GetIsolate()); | |
| 1312 } | |
| 1313 | |
| 1314 bool FieldType::NowStable() { | |
| 1315 return !this->IsClass() || this->AsClass()->is_stable(); | |
| 1316 } | |
| 1317 | |
| 1318 bool FieldType::NowIs(FieldType* other) { | |
| 1319 if (other->IsAny()) return true; | |
| 1320 if (IsNone()) return true; | |
| 1321 if (other->IsNone()) return false; | |
| 1322 if (IsAny()) return false; | |
| 1323 DCHECK(IsClass()); | |
| 1324 DCHECK(other->IsClass()); | |
| 1325 return this == other; | |
| 1326 } | |
| 1327 | |
| 1328 bool FieldType::NowIs(Handle<FieldType> other) { return NowIs(*other); } | |
| 1329 | |
| 1330 Type* FieldType::Convert(Zone* zone) { | |
| 1331 if (IsAny()) return Type::Any(); | |
| 1332 if (IsNone()) return Type::None(); | |
| 1333 DCHECK(IsClass()); | |
| 1334 return Type::Class(AsClass(), zone); | |
| 1335 } | |
| 1336 | |
| 1337 void FieldType::PrintTo(std::ostream& os) { | |
| 1338 if (IsAny()) { | |
| 1339 os << "Any"; | |
| 1340 } else if (IsNone()) { | |
| 1341 os << "None"; | |
| 1342 } else { | |
| 1343 DCHECK(IsClass()); | |
| 1344 os << "Class(" << static_cast<void*>(*AsClass()) << ")"; | |
| 1345 } | |
| 1346 } | |
| 1347 | |
| 1348 BitsetType::bitset BitsetType::SignedSmall() { | 1261 BitsetType::bitset BitsetType::SignedSmall() { |
| 1349 return i::SmiValuesAre31Bits() ? kSigned31 : kSigned32; | 1262 return i::SmiValuesAre31Bits() ? kSigned31 : kSigned32; |
| 1350 } | 1263 } |
| 1351 | 1264 |
| 1352 BitsetType::bitset BitsetType::UnsignedSmall() { | 1265 BitsetType::bitset BitsetType::UnsignedSmall() { |
| 1353 return i::SmiValuesAre31Bits() ? kUnsigned30 : kUnsigned31; | 1266 return i::SmiValuesAre31Bits() ? kUnsigned30 : kUnsigned31; |
| 1354 } | 1267 } |
| 1355 | 1268 |
| 1356 #define CONSTRUCT_SIMD_TYPE(NAME, Name, name, lane_count, lane_type) \ | 1269 #define CONSTRUCT_SIMD_TYPE(NAME, Name, name, lane_count, lane_type) \ |
| 1357 Type* Type::Name(Isolate* isolate, Zone* zone) { \ | 1270 Type* Type::Name(Isolate* isolate, Zone* zone) { \ |
| 1358 return Class(i::handle(isolate->heap()->name##_map()), zone); \ | 1271 return Class(i::handle(isolate->heap()->name##_map()), zone); \ |
| 1359 } | 1272 } |
| 1360 SIMD128_TYPES(CONSTRUCT_SIMD_TYPE) | 1273 SIMD128_TYPES(CONSTRUCT_SIMD_TYPE) |
| 1361 #undef CONSTRUCT_SIMD_TYPE | 1274 #undef CONSTRUCT_SIMD_TYPE |
| 1362 | 1275 |
| 1363 // ----------------------------------------------------------------------------- | 1276 // ----------------------------------------------------------------------------- |
| 1364 // Instantiations. | 1277 // Instantiations. |
| 1365 | 1278 |
| 1366 template class Type::Iterator<i::Map>; | 1279 template class Type::Iterator<i::Map>; |
| 1367 template class Type::Iterator<i::Object>; | 1280 template class Type::Iterator<i::Object>; |
| 1368 | 1281 |
| 1369 } // namespace internal | 1282 } // namespace internal |
| 1370 } // namespace v8 | 1283 } // namespace v8 |
| OLD | NEW |