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

Side by Side Diff: src/types.cc

Issue 145083007: Type representation converter (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « src/types.h ('k') | test/cctest/test-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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 return None(region); 533 return None(region);
534 } else if (size == 1) { 534 } else if (size == 1) {
535 return Config::union_get(unioned, 0); 535 return Config::union_get(unioned, 0);
536 } else { 536 } else {
537 Config::union_shrink(unioned, size); 537 Config::union_shrink(unioned, size);
538 return Config::from_union(unioned); 538 return Config::from_union(unioned);
539 } 539 }
540 } 540 }
541 541
542 542
543 template<class Config>
544 template<class OtherType>
545 typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::Convert(
546 typename OtherType::TypeHandle type, Region* region) {
547 if (type->IsBitset()) {
548 return Config::from_bitset(type->AsBitset(), region);
549 } else if (type->IsClass()) {
550 return Config::from_class(type->AsClass(), region);
551 } else if (type->IsConstant()) {
552 return Config::from_constant(type->AsConstant(), region);
553 } else {
554 ASSERT(type->IsUnion());
555 typename OtherType::UnionedHandle unioned = type->AsUnion();
556 int length = OtherType::UnionLength(unioned);
557 UnionedHandle new_unioned = Config::union_create(length, region);
558 for (int i = 0; i < length; ++i) {
559 Config::union_set(new_unioned, i,
560 Convert<OtherType>(OtherType::UnionGet(unioned, i), region));
561 }
562 return Config::from_union(new_unioned);
563 }
564 }
565
566
543 // TODO(rossberg): this does not belong here. 567 // TODO(rossberg): this does not belong here.
544 Representation Representation::FromType(Type* type) { 568 Representation Representation::FromType(Type* type) {
545 if (type->Is(Type::None())) return Representation::None(); 569 if (type->Is(Type::None())) return Representation::None();
546 if (type->Is(Type::Smi())) return Representation::Smi(); 570 if (type->Is(Type::Smi())) return Representation::Smi();
547 if (type->Is(Type::Signed32())) return Representation::Integer32(); 571 if (type->Is(Type::Signed32())) return Representation::Integer32();
548 if (type->Is(Type::Number())) return Representation::Double(); 572 if (type->Is(Type::Number())) return Representation::Double();
549 return Representation::Tagged(); 573 return Representation::Tagged();
550 } 574 }
551 575
552 576
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 637
614 638
615 template class TypeImpl<ZoneTypeConfig>; 639 template class TypeImpl<ZoneTypeConfig>;
616 template class TypeImpl<ZoneTypeConfig>::Iterator<i::Map>; 640 template class TypeImpl<ZoneTypeConfig>::Iterator<i::Map>;
617 template class TypeImpl<ZoneTypeConfig>::Iterator<i::Object>; 641 template class TypeImpl<ZoneTypeConfig>::Iterator<i::Object>;
618 642
619 template class TypeImpl<HeapTypeConfig>; 643 template class TypeImpl<HeapTypeConfig>;
620 template class TypeImpl<HeapTypeConfig>::Iterator<i::Map>; 644 template class TypeImpl<HeapTypeConfig>::Iterator<i::Map>;
621 template class TypeImpl<HeapTypeConfig>::Iterator<i::Object>; 645 template class TypeImpl<HeapTypeConfig>::Iterator<i::Object>;
622 646
647 template TypeImpl<ZoneTypeConfig>::TypeHandle
648 TypeImpl<ZoneTypeConfig>::Convert<HeapType>(
649 TypeImpl<HeapTypeConfig>::TypeHandle, TypeImpl<ZoneTypeConfig>::Region*);
650 template TypeImpl<HeapTypeConfig>::TypeHandle
651 TypeImpl<HeapTypeConfig>::Convert<Type>(
652 TypeImpl<ZoneTypeConfig>::TypeHandle, TypeImpl<HeapTypeConfig>::Region*);
653
623 654
624 } } // namespace v8::internal 655 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/types.h ('k') | test/cctest/test-types.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698