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

Side by Side Diff: src/types.cc

Issue 186743002: Types: cache lub bitset to avoid heap access (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Comment Created 6 years, 9 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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 if (this->IsBitset()) { 134 if (this->IsBitset()) {
135 return this->AsBitset(); 135 return this->AsBitset();
136 } else if (this->IsUnion()) { 136 } else if (this->IsUnion()) {
137 UnionedHandle unioned = this->AsUnion(); 137 UnionedHandle unioned = this->AsUnion();
138 int bitset = kNone; 138 int bitset = kNone;
139 for (int i = 0; i < Config::union_length(unioned); ++i) { 139 for (int i = 0; i < Config::union_length(unioned); ++i) {
140 bitset |= Config::union_get(unioned, i)->LubBitset(); 140 bitset |= Config::union_get(unioned, i)->LubBitset();
141 } 141 }
142 return bitset; 142 return bitset;
143 } else if (this->IsClass()) { 143 } else if (this->IsClass()) {
144 return LubBitset(*this->AsClass()); 144 int bitset = Config::lub_bitset(this);
145 return bitset ? bitset : LubBitset(*this->AsClass());
145 } else { 146 } else {
146 return LubBitset(*this->AsConstant()); 147 int bitset = Config::lub_bitset(this);
148 return bitset ? bitset : LubBitset(*this->AsConstant());
147 } 149 }
148 } 150 }
149 151
150 152
151 template<class Config> 153 template<class Config>
152 int TypeImpl<Config>::LubBitset(i::Object* value) { 154 int TypeImpl<Config>::LubBitset(i::Object* value) {
153 if (value->IsSmi()) return kSmi; 155 if (value->IsSmi()) return kSmi;
154 i::Map* map = i::HeapObject::cast(value)->map(); 156 i::Map* map = i::HeapObject::cast(value)->map();
155 if (map->instance_type() == HEAP_NUMBER_TYPE) { 157 if (map->instance_type() == HEAP_NUMBER_TYPE) {
156 int32_t i; 158 int32_t i;
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 } 543 }
542 544
543 545
544 template<class Config> 546 template<class Config>
545 template<class OtherType> 547 template<class OtherType>
546 typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::Convert( 548 typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::Convert(
547 typename OtherType::TypeHandle type, Region* region) { 549 typename OtherType::TypeHandle type, Region* region) {
548 if (type->IsBitset()) { 550 if (type->IsBitset()) {
549 return Config::from_bitset(type->AsBitset(), region); 551 return Config::from_bitset(type->AsBitset(), region);
550 } else if (type->IsClass()) { 552 } else if (type->IsClass()) {
551 return Config::from_class(type->AsClass(), region); 553 return Config::from_class(type->AsClass(), type->LubBitset(), region);
552 } else if (type->IsConstant()) { 554 } else if (type->IsConstant()) {
553 return Config::from_constant(type->AsConstant(), region); 555 return Config::from_constant(type->AsConstant(), type->LubBitset(), region);
554 } else { 556 } else {
555 ASSERT(type->IsUnion()); 557 ASSERT(type->IsUnion());
556 typename OtherType::UnionedHandle unioned = type->AsUnion(); 558 typename OtherType::UnionedHandle unioned = type->AsUnion();
557 int length = OtherType::UnionLength(unioned); 559 int length = OtherType::UnionLength(unioned);
558 UnionedHandle new_unioned = Config::union_create(length, region); 560 UnionedHandle new_unioned = Config::union_create(length, region);
559 for (int i = 0; i < length; ++i) { 561 for (int i = 0; i < length; ++i) {
560 Config::union_set(new_unioned, i, 562 Config::union_set(new_unioned, i,
561 Convert<OtherType>(OtherType::UnionGet(unioned, i), region)); 563 Convert<OtherType>(OtherType::UnionGet(unioned, i), region));
562 } 564 }
563 return Config::from_union(new_unioned); 565 return Config::from_union(new_unioned);
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 649
648 template TypeImpl<ZoneTypeConfig>::TypeHandle 650 template TypeImpl<ZoneTypeConfig>::TypeHandle
649 TypeImpl<ZoneTypeConfig>::Convert<HeapType>( 651 TypeImpl<ZoneTypeConfig>::Convert<HeapType>(
650 TypeImpl<HeapTypeConfig>::TypeHandle, TypeImpl<ZoneTypeConfig>::Region*); 652 TypeImpl<HeapTypeConfig>::TypeHandle, TypeImpl<ZoneTypeConfig>::Region*);
651 template TypeImpl<HeapTypeConfig>::TypeHandle 653 template TypeImpl<HeapTypeConfig>::TypeHandle
652 TypeImpl<HeapTypeConfig>::Convert<Type>( 654 TypeImpl<HeapTypeConfig>::Convert<Type>(
653 TypeImpl<ZoneTypeConfig>::TypeHandle, TypeImpl<HeapTypeConfig>::Region*); 655 TypeImpl<ZoneTypeConfig>::TypeHandle, TypeImpl<HeapTypeConfig>::Region*);
654 656
655 657
656 } } // namespace v8::internal 658 } } // 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