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

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

Issue 2986: TryFlatten is inlined, while Flatten is not. Make an optimization to avoid t... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Comments and check for external strings. Created 12 years, 3 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 | « no previous file | 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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 1180 matching lines...) Expand 10 before | Expand all | Expand 10 after
1191 return READ_INT_FIELD(this, kLengthOffset); 1191 return READ_INT_FIELD(this, kLengthOffset);
1192 } 1192 }
1193 1193
1194 1194
1195 void String::set_length_field(int value) { 1195 void String::set_length_field(int value) {
1196 WRITE_INT_FIELD(this, kLengthOffset, value); 1196 WRITE_INT_FIELD(this, kLengthOffset, value);
1197 } 1197 }
1198 1198
1199 1199
1200 void String::TryFlatten() { 1200 void String::TryFlatten() {
1201 Flatten(); 1201 // We don't need to flatten strings that are already flat. Since this code
1202 // is inlined, it can be helpful in the flat case to not call out to Flatten.
1203 StringRepresentationTag str_type = representation_tag();
1204 if (str_type != kSeqStringTag && str_type != kExternalStringTag)
1205 Flatten();
1202 } 1206 }
1203 1207
1204 1208
1205 uint16_t String::Get(int index) { 1209 uint16_t String::Get(int index) {
1206 ASSERT(index >= 0 && index < length()); 1210 ASSERT(index >= 0 && index < length());
1207 switch (representation_tag()) { 1211 switch (representation_tag()) {
1208 case kSeqStringTag: 1212 case kSeqStringTag:
1209 return is_ascii() 1213 return is_ascii()
1210 ? AsciiString::cast(this)->AsciiStringGet(index) 1214 ? AsciiString::cast(this)->AsciiStringGet(index)
1211 : TwoByteString::cast(this)->TwoByteStringGet(index); 1215 : TwoByteString::cast(this)->TwoByteStringGet(index);
(...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after
2132 #undef WRITE_INT_FIELD 2136 #undef WRITE_INT_FIELD
2133 #undef READ_SHORT_FIELD 2137 #undef READ_SHORT_FIELD
2134 #undef WRITE_SHORT_FIELD 2138 #undef WRITE_SHORT_FIELD
2135 #undef READ_BYTE_FIELD 2139 #undef READ_BYTE_FIELD
2136 #undef WRITE_BYTE_FIELD 2140 #undef WRITE_BYTE_FIELD
2137 2141
2138 2142
2139 } } // namespace v8::internal 2143 } } // namespace v8::internal
2140 2144
2141 #endif // V8_OBJECTS_INL_H_ 2145 #endif // V8_OBJECTS_INL_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698