Chromium Code Reviews| 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/ostreams.h" | 9 #include "src/ostreams.h" |
| 10 #include "src/types-inl.h" | 10 #include "src/types-inl.h" |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 167 bitset |= SEMANTIC(type->AsUnion()->Get(i)->BitsetLub()); | 167 bitset |= SEMANTIC(type->AsUnion()->Get(i)->BitsetLub()); |
| 168 } | 168 } |
| 169 return bitset; | 169 return bitset; |
| 170 } | 170 } |
| 171 if (type->IsClass()) return type->AsClass()->Lub(); | 171 if (type->IsClass()) return type->AsClass()->Lub(); |
| 172 if (type->IsConstant()) return type->AsConstant()->Lub(); | 172 if (type->IsConstant()) return type->AsConstant()->Lub(); |
| 173 if (type->IsRange()) return type->AsRange()->Lub(); | 173 if (type->IsRange()) return type->AsRange()->Lub(); |
| 174 if (type->IsContext()) return kInternal & kTaggedPointer; | 174 if (type->IsContext()) return kInternal & kTaggedPointer; |
| 175 if (type->IsArray()) return kOtherObject; | 175 if (type->IsArray()) return kOtherObject; |
| 176 if (type->IsFunction()) return kFunction; | 176 if (type->IsFunction()) return kFunction; |
| 177 if (type->IsTuple()) return kInternal; | |
| 177 UNREACHABLE(); | 178 UNREACHABLE(); |
| 178 return kNone; | 179 return kNone; |
| 179 } | 180 } |
| 180 | 181 |
| 181 | 182 |
| 182 template<class Config> | 183 template<class Config> |
| 183 typename TypeImpl<Config>::bitset | 184 typename TypeImpl<Config>::bitset |
| 184 TypeImpl<Config>::BitsetType::Lub(i::Map* map) { | 185 TypeImpl<Config>::BitsetType::Lub(i::Map* map) { |
| 185 DisallowHeapAllocation no_allocation; | 186 DisallowHeapAllocation no_allocation; |
| 186 switch (map->instance_type()) { | 187 switch (map->instance_type()) { |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 496 if (this_fun->Arity() != that_fun->Arity() || | 497 if (this_fun->Arity() != that_fun->Arity() || |
| 497 !this_fun->Result()->Equals(that_fun->Result()) || | 498 !this_fun->Result()->Equals(that_fun->Result()) || |
| 498 !this_fun->Receiver()->Equals(that_fun->Receiver())) { | 499 !this_fun->Receiver()->Equals(that_fun->Receiver())) { |
| 499 return false; | 500 return false; |
| 500 } | 501 } |
| 501 for (int i = 0, n = this_fun->Arity(); i < n; ++i) { | 502 for (int i = 0, n = this_fun->Arity(); i < n; ++i) { |
| 502 if (!this_fun->Parameter(i)->Equals(that_fun->Parameter(i))) return false; | 503 if (!this_fun->Parameter(i)->Equals(that_fun->Parameter(i))) return false; |
| 503 } | 504 } |
| 504 return true; | 505 return true; |
| 505 } | 506 } |
| 507 if (this->IsTuple()) { | |
|
Jarin
2016/01/25 10:00:26
There should be a comment somewhere (probably on t
Benedikt Meurer
2016/01/25 10:05:05
As discussed offline, not saying anything about th
| |
| 508 if (!that->IsTuple()) return false; | |
| 509 TupleType* this_tuple = this->AsTuple(); | |
| 510 TupleType* that_tuple = that->AsTuple(); | |
| 511 if (this_tuple->Arity() != that_tuple->Arity()) { | |
| 512 return false; | |
| 513 } | |
| 514 for (int i = 0, n = this_tuple->Arity(); i < n; ++i) { | |
| 515 if (!this_tuple->Element(i)->Equals(that_tuple->Element(i))) return false; | |
| 516 } | |
| 517 return true; | |
| 518 } | |
| 506 UNREACHABLE(); | 519 UNREACHABLE(); |
| 507 return false; | 520 return false; |
| 508 } | 521 } |
| 509 | 522 |
| 510 | 523 |
| 511 template <class Config> | 524 template <class Config> |
| 512 typename TypeImpl<Config>::bitset TypeImpl<Config>::Representation() { | 525 typename TypeImpl<Config>::bitset TypeImpl<Config>::Representation() { |
| 513 return REPRESENTATION(this->BitsetLub()); | 526 return REPRESENTATION(this->BitsetLub()); |
| 514 } | 527 } |
| 515 | 528 |
| (...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1231 TypeHandle res = Convert<OtherType>(type->AsFunction()->Result(), region); | 1244 TypeHandle res = Convert<OtherType>(type->AsFunction()->Result(), region); |
| 1232 TypeHandle rcv = Convert<OtherType>(type->AsFunction()->Receiver(), region); | 1245 TypeHandle rcv = Convert<OtherType>(type->AsFunction()->Receiver(), region); |
| 1233 FunctionHandle function = FunctionType::New( | 1246 FunctionHandle function = FunctionType::New( |
| 1234 res, rcv, type->AsFunction()->Arity(), region); | 1247 res, rcv, type->AsFunction()->Arity(), region); |
| 1235 for (int i = 0; i < function->Arity(); ++i) { | 1248 for (int i = 0; i < function->Arity(); ++i) { |
| 1236 TypeHandle param = Convert<OtherType>( | 1249 TypeHandle param = Convert<OtherType>( |
| 1237 type->AsFunction()->Parameter(i), region); | 1250 type->AsFunction()->Parameter(i), region); |
| 1238 function->InitParameter(i, param); | 1251 function->InitParameter(i, param); |
| 1239 } | 1252 } |
| 1240 return function; | 1253 return function; |
| 1254 } else if (type->IsTuple()) { | |
| 1255 TupleHandle tuple = TupleType::New(type->AsTuple()->Arity(), region); | |
| 1256 for (int i = 0; i < tuple->Arity(); ++i) { | |
| 1257 tuple->InitElement( | |
| 1258 i, Convert<OtherType>(type->AsTuple()->Element(i), region)); | |
| 1259 } | |
| 1260 return tuple; | |
| 1241 } else { | 1261 } else { |
| 1242 UNREACHABLE(); | 1262 UNREACHABLE(); |
| 1243 return None(region); | 1263 return None(region); |
| 1244 } | 1264 } |
| 1245 } | 1265 } |
| 1246 | 1266 |
| 1247 | 1267 |
| 1248 // ----------------------------------------------------------------------------- | 1268 // ----------------------------------------------------------------------------- |
| 1249 // Printing. | 1269 // Printing. |
| 1250 | 1270 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1348 this->AsFunction()->Receiver()->PrintTo(os, dim); | 1368 this->AsFunction()->Receiver()->PrintTo(os, dim); |
| 1349 os << "."; | 1369 os << "."; |
| 1350 } | 1370 } |
| 1351 os << "("; | 1371 os << "("; |
| 1352 for (int i = 0; i < this->AsFunction()->Arity(); ++i) { | 1372 for (int i = 0; i < this->AsFunction()->Arity(); ++i) { |
| 1353 if (i > 0) os << ", "; | 1373 if (i > 0) os << ", "; |
| 1354 this->AsFunction()->Parameter(i)->PrintTo(os, dim); | 1374 this->AsFunction()->Parameter(i)->PrintTo(os, dim); |
| 1355 } | 1375 } |
| 1356 os << ")->"; | 1376 os << ")->"; |
| 1357 this->AsFunction()->Result()->PrintTo(os, dim); | 1377 this->AsFunction()->Result()->PrintTo(os, dim); |
| 1378 } else if (this->IsTuple()) { | |
| 1379 os << "<"; | |
| 1380 for (int i = 0, n = this->AsTuple()->Arity(); i < n; ++i) { | |
| 1381 TypeHandle type_i = this->AsTuple()->Element(i); | |
| 1382 if (i > 0) os << ", "; | |
| 1383 type_i->PrintTo(os, dim); | |
| 1384 } | |
| 1385 os << ">"; | |
| 1358 } else { | 1386 } else { |
| 1359 UNREACHABLE(); | 1387 UNREACHABLE(); |
| 1360 } | 1388 } |
| 1361 } | 1389 } |
| 1362 if (dim == BOTH_DIMS) os << "/"; | 1390 if (dim == BOTH_DIMS) os << "/"; |
| 1363 if (dim != SEMANTIC_DIM) { | 1391 if (dim != SEMANTIC_DIM) { |
| 1364 BitsetType::Print(os, REPRESENTATION(this->BitsetLub())); | 1392 BitsetType::Print(os, REPRESENTATION(this->BitsetLub())); |
| 1365 } | 1393 } |
| 1366 } | 1394 } |
| 1367 | 1395 |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 1395 | 1423 |
| 1396 template TypeImpl<ZoneTypeConfig>::TypeHandle | 1424 template TypeImpl<ZoneTypeConfig>::TypeHandle |
| 1397 TypeImpl<ZoneTypeConfig>::Convert<HeapType>( | 1425 TypeImpl<ZoneTypeConfig>::Convert<HeapType>( |
| 1398 TypeImpl<HeapTypeConfig>::TypeHandle, TypeImpl<ZoneTypeConfig>::Region*); | 1426 TypeImpl<HeapTypeConfig>::TypeHandle, TypeImpl<ZoneTypeConfig>::Region*); |
| 1399 template TypeImpl<HeapTypeConfig>::TypeHandle | 1427 template TypeImpl<HeapTypeConfig>::TypeHandle |
| 1400 TypeImpl<HeapTypeConfig>::Convert<Type>( | 1428 TypeImpl<HeapTypeConfig>::Convert<Type>( |
| 1401 TypeImpl<ZoneTypeConfig>::TypeHandle, TypeImpl<HeapTypeConfig>::Region*); | 1429 TypeImpl<ZoneTypeConfig>::TypeHandle, TypeImpl<HeapTypeConfig>::Region*); |
| 1402 | 1430 |
| 1403 } // namespace internal | 1431 } // namespace internal |
| 1404 } // namespace v8 | 1432 } // namespace v8 |
| OLD | NEW |