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

Side by Side Diff: src/objects-inl.h

Issue 1177043009: Make sure to flatten names before lookup. Lookup using cons strings is really slow. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 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 | « src/objects.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 // Review notes: 5 // Review notes:
6 // 6 //
7 // - The use of macros in these inline functions may seem superfluous 7 // - The use of macros in these inline functions may seem superfluous
8 // but it is absolutely needed to make sure gcc generates optimal 8 // but it is absolutely needed to make sure gcc generates optimal
9 // code. gcc is not happy when attempting to inline too deep. 9 // code. gcc is not happy when attempting to inline too deep.
10 // 10 //
(...skipping 3208 matching lines...) Expand 10 before | Expand all | Expand 10 after
3219 3219
3220 3220
3221 Handle<String> String::Flatten(Handle<String> string, PretenureFlag pretenure) { 3221 Handle<String> String::Flatten(Handle<String> string, PretenureFlag pretenure) {
3222 if (!string->IsConsString()) return string; 3222 if (!string->IsConsString()) return string;
3223 Handle<ConsString> cons = Handle<ConsString>::cast(string); 3223 Handle<ConsString> cons = Handle<ConsString>::cast(string);
3224 if (cons->IsFlat()) return handle(cons->first()); 3224 if (cons->IsFlat()) return handle(cons->first());
3225 return SlowFlatten(cons, pretenure); 3225 return SlowFlatten(cons, pretenure);
3226 } 3226 }
3227 3227
3228 3228
3229 Handle<Name> Name::Flatten(Handle<Name> name, PretenureFlag pretenure) {
3230 if (name->IsSymbol()) return name;
3231 return String::Flatten(Handle<String>::cast(name));
3232 }
3233
3234
3229 uint16_t String::Get(int index) { 3235 uint16_t String::Get(int index) {
3230 DCHECK(index >= 0 && index < length()); 3236 DCHECK(index >= 0 && index < length());
3231 switch (StringShape(this).full_representation_tag()) { 3237 switch (StringShape(this).full_representation_tag()) {
3232 case kSeqStringTag | kOneByteStringTag: 3238 case kSeqStringTag | kOneByteStringTag:
3233 return SeqOneByteString::cast(this)->SeqOneByteStringGet(index); 3239 return SeqOneByteString::cast(this)->SeqOneByteStringGet(index);
3234 case kSeqStringTag | kTwoByteStringTag: 3240 case kSeqStringTag | kTwoByteStringTag:
3235 return SeqTwoByteString::cast(this)->SeqTwoByteStringGet(index); 3241 return SeqTwoByteString::cast(this)->SeqTwoByteStringGet(index);
3236 case kConsStringTag | kOneByteStringTag: 3242 case kConsStringTag | kOneByteStringTag:
3237 case kConsStringTag | kTwoByteStringTag: 3243 case kConsStringTag | kTwoByteStringTag:
3238 return ConsString::cast(this)->ConsStringGet(index); 3244 return ConsString::cast(this)->ConsStringGet(index);
(...skipping 4119 matching lines...) Expand 10 before | Expand all | Expand 10 after
7358 #undef READ_SHORT_FIELD 7364 #undef READ_SHORT_FIELD
7359 #undef WRITE_SHORT_FIELD 7365 #undef WRITE_SHORT_FIELD
7360 #undef READ_BYTE_FIELD 7366 #undef READ_BYTE_FIELD
7361 #undef WRITE_BYTE_FIELD 7367 #undef WRITE_BYTE_FIELD
7362 #undef NOBARRIER_READ_BYTE_FIELD 7368 #undef NOBARRIER_READ_BYTE_FIELD
7363 #undef NOBARRIER_WRITE_BYTE_FIELD 7369 #undef NOBARRIER_WRITE_BYTE_FIELD
7364 7370
7365 } } // namespace v8::internal 7371 } } // namespace v8::internal
7366 7372
7367 #endif // V8_OBJECTS_INL_H_ 7373 #endif // V8_OBJECTS_INL_H_
OLDNEW
« no previous file with comments | « src/objects.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698