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

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

Issue 11411005: Rename SeqAsciiString (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 1 month 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/objects-debug.cc ('k') | src/objects-visiting.h » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 return StringShape(String::cast(this)).IsSliced(); 222 return StringShape(String::cast(this)).IsSliced();
223 } 223 }
224 224
225 225
226 bool Object::IsSeqString() { 226 bool Object::IsSeqString() {
227 if (!IsString()) return false; 227 if (!IsString()) return false;
228 return StringShape(String::cast(this)).IsSequential(); 228 return StringShape(String::cast(this)).IsSequential();
229 } 229 }
230 230
231 231
232 bool Object::IsSeqAsciiString() { 232 bool Object::IsSeqOneByteString() {
233 if (!IsString()) return false; 233 if (!IsString()) return false;
234 return StringShape(String::cast(this)).IsSequential() && 234 return StringShape(String::cast(this)).IsSequential() &&
235 String::cast(this)->IsAsciiRepresentation(); 235 String::cast(this)->IsAsciiRepresentation();
236 } 236 }
237 237
238 238
239 bool Object::IsSeqTwoByteString() { 239 bool Object::IsSeqTwoByteString() {
240 if (!IsString()) return false; 240 if (!IsString()) return false;
241 return StringShape(String::cast(this)).IsSequential() && 241 return StringShape(String::cast(this)).IsSequential() &&
242 String::cast(this)->IsTwoByteRepresentation(); 242 String::cast(this)->IsTwoByteRepresentation();
(...skipping 2108 matching lines...) Expand 10 before | Expand all | Expand 10 after
2351 CAST_ACCESSOR(SymbolTable) 2351 CAST_ACCESSOR(SymbolTable)
2352 CAST_ACCESSOR(JSFunctionResultCache) 2352 CAST_ACCESSOR(JSFunctionResultCache)
2353 CAST_ACCESSOR(NormalizedMapCache) 2353 CAST_ACCESSOR(NormalizedMapCache)
2354 CAST_ACCESSOR(ScopeInfo) 2354 CAST_ACCESSOR(ScopeInfo)
2355 CAST_ACCESSOR(CompilationCacheTable) 2355 CAST_ACCESSOR(CompilationCacheTable)
2356 CAST_ACCESSOR(CodeCacheHashTable) 2356 CAST_ACCESSOR(CodeCacheHashTable)
2357 CAST_ACCESSOR(PolymorphicCodeCacheHashTable) 2357 CAST_ACCESSOR(PolymorphicCodeCacheHashTable)
2358 CAST_ACCESSOR(MapCache) 2358 CAST_ACCESSOR(MapCache)
2359 CAST_ACCESSOR(String) 2359 CAST_ACCESSOR(String)
2360 CAST_ACCESSOR(SeqString) 2360 CAST_ACCESSOR(SeqString)
2361 CAST_ACCESSOR(SeqAsciiString) 2361 CAST_ACCESSOR(SeqOneByteString)
2362 CAST_ACCESSOR(SeqTwoByteString) 2362 CAST_ACCESSOR(SeqTwoByteString)
2363 CAST_ACCESSOR(SlicedString) 2363 CAST_ACCESSOR(SlicedString)
2364 CAST_ACCESSOR(ConsString) 2364 CAST_ACCESSOR(ConsString)
2365 CAST_ACCESSOR(ExternalString) 2365 CAST_ACCESSOR(ExternalString)
2366 CAST_ACCESSOR(ExternalAsciiString) 2366 CAST_ACCESSOR(ExternalAsciiString)
2367 CAST_ACCESSOR(ExternalTwoByteString) 2367 CAST_ACCESSOR(ExternalTwoByteString)
2368 CAST_ACCESSOR(JSReceiver) 2368 CAST_ACCESSOR(JSReceiver)
2369 CAST_ACCESSOR(JSObject) 2369 CAST_ACCESSOR(JSObject)
2370 CAST_ACCESSOR(Smi) 2370 CAST_ACCESSOR(Smi)
2371 CAST_ACCESSOR(HeapObject) 2371 CAST_ACCESSOR(HeapObject)
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
2456 Object* successfully_flattened; 2456 Object* successfully_flattened;
2457 if (!flat->ToObject(&successfully_flattened)) return this; 2457 if (!flat->ToObject(&successfully_flattened)) return this;
2458 return String::cast(successfully_flattened); 2458 return String::cast(successfully_flattened);
2459 } 2459 }
2460 2460
2461 2461
2462 uint16_t String::Get(int index) { 2462 uint16_t String::Get(int index) {
2463 ASSERT(index >= 0 && index < length()); 2463 ASSERT(index >= 0 && index < length());
2464 switch (StringShape(this).full_representation_tag()) { 2464 switch (StringShape(this).full_representation_tag()) {
2465 case kSeqStringTag | kOneByteStringTag: 2465 case kSeqStringTag | kOneByteStringTag:
2466 return SeqAsciiString::cast(this)->SeqAsciiStringGet(index); 2466 return SeqOneByteString::cast(this)->SeqOneByteStringGet(index);
2467 case kSeqStringTag | kTwoByteStringTag: 2467 case kSeqStringTag | kTwoByteStringTag:
2468 return SeqTwoByteString::cast(this)->SeqTwoByteStringGet(index); 2468 return SeqTwoByteString::cast(this)->SeqTwoByteStringGet(index);
2469 case kConsStringTag | kOneByteStringTag: 2469 case kConsStringTag | kOneByteStringTag:
2470 case kConsStringTag | kTwoByteStringTag: 2470 case kConsStringTag | kTwoByteStringTag:
2471 return ConsString::cast(this)->ConsStringGet(index); 2471 return ConsString::cast(this)->ConsStringGet(index);
2472 case kExternalStringTag | kOneByteStringTag: 2472 case kExternalStringTag | kOneByteStringTag:
2473 return ExternalAsciiString::cast(this)->ExternalAsciiStringGet(index); 2473 return ExternalAsciiString::cast(this)->ExternalAsciiStringGet(index);
2474 case kExternalStringTag | kTwoByteStringTag: 2474 case kExternalStringTag | kTwoByteStringTag:
2475 return ExternalTwoByteString::cast(this)->ExternalTwoByteStringGet(index); 2475 return ExternalTwoByteString::cast(this)->ExternalTwoByteStringGet(index);
2476 case kSlicedStringTag | kOneByteStringTag: 2476 case kSlicedStringTag | kOneByteStringTag:
2477 case kSlicedStringTag | kTwoByteStringTag: 2477 case kSlicedStringTag | kTwoByteStringTag:
2478 return SlicedString::cast(this)->SlicedStringGet(index); 2478 return SlicedString::cast(this)->SlicedStringGet(index);
2479 default: 2479 default:
2480 break; 2480 break;
2481 } 2481 }
2482 2482
2483 UNREACHABLE(); 2483 UNREACHABLE();
2484 return 0; 2484 return 0;
2485 } 2485 }
2486 2486
2487 2487
2488 void String::Set(int index, uint16_t value) { 2488 void String::Set(int index, uint16_t value) {
2489 ASSERT(index >= 0 && index < length()); 2489 ASSERT(index >= 0 && index < length());
2490 ASSERT(StringShape(this).IsSequential()); 2490 ASSERT(StringShape(this).IsSequential());
2491 2491
2492 return this->IsAsciiRepresentation() 2492 return this->IsAsciiRepresentation()
2493 ? SeqAsciiString::cast(this)->SeqAsciiStringSet(index, value) 2493 ? SeqOneByteString::cast(this)->SeqOneByteStringSet(index, value)
2494 : SeqTwoByteString::cast(this)->SeqTwoByteStringSet(index, value); 2494 : SeqTwoByteString::cast(this)->SeqTwoByteStringSet(index, value);
2495 } 2495 }
2496 2496
2497 2497
2498 bool String::IsFlat() { 2498 bool String::IsFlat() {
2499 if (!StringShape(this).IsCons()) return true; 2499 if (!StringShape(this).IsCons()) return true;
2500 return ConsString::cast(this)->second()->length() == 0; 2500 return ConsString::cast(this)->second()->length() == 0;
2501 } 2501 }
2502 2502
2503 2503
2504 String* String::GetUnderlying() { 2504 String* String::GetUnderlying() {
2505 // Giving direct access to underlying string only makes sense if the 2505 // Giving direct access to underlying string only makes sense if the
2506 // wrapping string is already flattened. 2506 // wrapping string is already flattened.
2507 ASSERT(this->IsFlat()); 2507 ASSERT(this->IsFlat());
2508 ASSERT(StringShape(this).IsIndirect()); 2508 ASSERT(StringShape(this).IsIndirect());
2509 STATIC_ASSERT(ConsString::kFirstOffset == SlicedString::kParentOffset); 2509 STATIC_ASSERT(ConsString::kFirstOffset == SlicedString::kParentOffset);
2510 const int kUnderlyingOffset = SlicedString::kParentOffset; 2510 const int kUnderlyingOffset = SlicedString::kParentOffset;
2511 return String::cast(READ_FIELD(this, kUnderlyingOffset)); 2511 return String::cast(READ_FIELD(this, kUnderlyingOffset));
2512 } 2512 }
2513 2513
2514 2514
2515 uint16_t SeqAsciiString::SeqAsciiStringGet(int index) { 2515 uint16_t SeqOneByteString::SeqOneByteStringGet(int index) {
2516 ASSERT(index >= 0 && index < length()); 2516 ASSERT(index >= 0 && index < length());
2517 return READ_BYTE_FIELD(this, kHeaderSize + index * kCharSize); 2517 return READ_BYTE_FIELD(this, kHeaderSize + index * kCharSize);
2518 } 2518 }
2519 2519
2520 2520
2521 void SeqAsciiString::SeqAsciiStringSet(int index, uint16_t value) { 2521 void SeqOneByteString::SeqOneByteStringSet(int index, uint16_t value) {
2522 ASSERT(index >= 0 && index < length() && value <= kMaxAsciiCharCode); 2522 ASSERT(index >= 0 && index < length() && value <= kMaxAsciiCharCode);
2523 WRITE_BYTE_FIELD(this, kHeaderSize + index * kCharSize, 2523 WRITE_BYTE_FIELD(this, kHeaderSize + index * kCharSize,
2524 static_cast<byte>(value)); 2524 static_cast<byte>(value));
2525 } 2525 }
2526 2526
2527 2527
2528 Address SeqAsciiString::GetCharsAddress() { 2528 Address SeqOneByteString::GetCharsAddress() {
2529 return FIELD_ADDR(this, kHeaderSize); 2529 return FIELD_ADDR(this, kHeaderSize);
2530 } 2530 }
2531 2531
2532 2532
2533 char* SeqAsciiString::GetChars() { 2533 char* SeqOneByteString::GetChars() {
2534 return reinterpret_cast<char*>(GetCharsAddress()); 2534 return reinterpret_cast<char*>(GetCharsAddress());
2535 } 2535 }
2536 2536
2537 2537
2538 Address SeqTwoByteString::GetCharsAddress() { 2538 Address SeqTwoByteString::GetCharsAddress() {
2539 return FIELD_ADDR(this, kHeaderSize); 2539 return FIELD_ADDR(this, kHeaderSize);
2540 } 2540 }
2541 2541
2542 2542
2543 uc16* SeqTwoByteString::GetChars() { 2543 uc16* SeqTwoByteString::GetChars() {
(...skipping 11 matching lines...) Expand all
2555 ASSERT(index >= 0 && index < length()); 2555 ASSERT(index >= 0 && index < length());
2556 WRITE_SHORT_FIELD(this, kHeaderSize + index * kShortSize, value); 2556 WRITE_SHORT_FIELD(this, kHeaderSize + index * kShortSize, value);
2557 } 2557 }
2558 2558
2559 2559
2560 int SeqTwoByteString::SeqTwoByteStringSize(InstanceType instance_type) { 2560 int SeqTwoByteString::SeqTwoByteStringSize(InstanceType instance_type) {
2561 return SizeFor(length()); 2561 return SizeFor(length());
2562 } 2562 }
2563 2563
2564 2564
2565 int SeqAsciiString::SeqAsciiStringSize(InstanceType instance_type) { 2565 int SeqOneByteString::SeqOneByteStringSize(InstanceType instance_type) {
2566 return SizeFor(length()); 2566 return SizeFor(length());
2567 } 2567 }
2568 2568
2569 2569
2570 String* SlicedString::parent() { 2570 String* SlicedString::parent() {
2571 return String::cast(READ_FIELD(this, kParentOffset)); 2571 return String::cast(READ_FIELD(this, kParentOffset));
2572 } 2572 }
2573 2573
2574 2574
2575 void SlicedString::set_parent(String* parent, WriteBarrierMode mode) { 2575 void SlicedString::set_parent(String* parent, WriteBarrierMode mode) {
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
2973 int instance_size = map->instance_size(); 2973 int instance_size = map->instance_size();
2974 if (instance_size != kVariableSizeSentinel) return instance_size; 2974 if (instance_size != kVariableSizeSentinel) return instance_size;
2975 // We can ignore the "symbol" bit becase it is only set for symbols 2975 // We can ignore the "symbol" bit becase it is only set for symbols
2976 // and implies a string type. 2976 // and implies a string type.
2977 int instance_type = static_cast<int>(map->instance_type()) & ~kIsSymbolMask; 2977 int instance_type = static_cast<int>(map->instance_type()) & ~kIsSymbolMask;
2978 // Only inline the most frequent cases. 2978 // Only inline the most frequent cases.
2979 if (instance_type == FIXED_ARRAY_TYPE) { 2979 if (instance_type == FIXED_ARRAY_TYPE) {
2980 return FixedArray::BodyDescriptor::SizeOf(map, this); 2980 return FixedArray::BodyDescriptor::SizeOf(map, this);
2981 } 2981 }
2982 if (instance_type == ASCII_STRING_TYPE) { 2982 if (instance_type == ASCII_STRING_TYPE) {
2983 return SeqAsciiString::SizeFor( 2983 return SeqOneByteString::SizeFor(
2984 reinterpret_cast<SeqAsciiString*>(this)->length()); 2984 reinterpret_cast<SeqOneByteString*>(this)->length());
2985 } 2985 }
2986 if (instance_type == BYTE_ARRAY_TYPE) { 2986 if (instance_type == BYTE_ARRAY_TYPE) {
2987 return reinterpret_cast<ByteArray*>(this)->ByteArraySize(); 2987 return reinterpret_cast<ByteArray*>(this)->ByteArraySize();
2988 } 2988 }
2989 if (instance_type == FREE_SPACE_TYPE) { 2989 if (instance_type == FREE_SPACE_TYPE) {
2990 return reinterpret_cast<FreeSpace*>(this)->size(); 2990 return reinterpret_cast<FreeSpace*>(this)->size();
2991 } 2991 }
2992 if (instance_type == STRING_TYPE) { 2992 if (instance_type == STRING_TYPE) {
2993 return SeqTwoByteString::SizeFor( 2993 return SeqTwoByteString::SizeFor(
2994 reinterpret_cast<SeqTwoByteString*>(this)->length()); 2994 reinterpret_cast<SeqTwoByteString*>(this)->length());
(...skipping 2546 matching lines...) Expand 10 before | Expand all | Expand 10 after
5541 #undef WRITE_UINT32_FIELD 5541 #undef WRITE_UINT32_FIELD
5542 #undef READ_SHORT_FIELD 5542 #undef READ_SHORT_FIELD
5543 #undef WRITE_SHORT_FIELD 5543 #undef WRITE_SHORT_FIELD
5544 #undef READ_BYTE_FIELD 5544 #undef READ_BYTE_FIELD
5545 #undef WRITE_BYTE_FIELD 5545 #undef WRITE_BYTE_FIELD
5546 5546
5547 5547
5548 } } // namespace v8::internal 5548 } } // namespace v8::internal
5549 5549
5550 #endif // V8_OBJECTS_INL_H_ 5550 #endif // V8_OBJECTS_INL_H_
OLDNEW
« no previous file with comments | « src/objects-debug.cc ('k') | src/objects-visiting.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698