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

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

Issue 1149563011: Verify a bit more about external strings (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates 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 3450 matching lines...) Expand 10 before | Expand all | Expand 10 after
3461 return READ_FIELD(this, kSecondOffset); 3461 return READ_FIELD(this, kSecondOffset);
3462 } 3462 }
3463 3463
3464 3464
3465 void ConsString::set_second(String* value, WriteBarrierMode mode) { 3465 void ConsString::set_second(String* value, WriteBarrierMode mode) {
3466 WRITE_FIELD(this, kSecondOffset, value); 3466 WRITE_FIELD(this, kSecondOffset, value);
3467 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kSecondOffset, value, mode); 3467 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kSecondOffset, value, mode);
3468 } 3468 }
3469 3469
3470 3470
3471 const void* ExternalString::resource_data() const {
3472 return *reinterpret_cast<const void* const*>(
3473 FIELD_ADDR_CONST(this, kResourceDataOffset));
3474 }
3475
3476
3471 bool ExternalString::is_short() { 3477 bool ExternalString::is_short() {
3472 InstanceType type = map()->instance_type(); 3478 InstanceType type = map()->instance_type();
3473 return (type & kShortExternalStringMask) == kShortExternalStringTag; 3479 return (type & kShortExternalStringMask) == kShortExternalStringTag;
3474 } 3480 }
3475 3481
3476 3482
3477 const ExternalOneByteString::Resource* ExternalOneByteString::resource() { 3483 const ExternalOneByteString::Resource* ExternalOneByteString::resource() const {
3478 return *reinterpret_cast<Resource**>(FIELD_ADDR(this, kResourceOffset)); 3484 return *reinterpret_cast<const Resource* const*>(
3485 FIELD_ADDR_CONST(this, kResourceOffset));
3479 } 3486 }
3480 3487
3481 3488
3482 void ExternalOneByteString::update_data_cache() { 3489 void ExternalOneByteString::update_data_cache() {
3483 if (is_short()) return; 3490 if (is_short()) return;
3484 const char** data_field = 3491 const char** data_field =
3485 reinterpret_cast<const char**>(FIELD_ADDR(this, kResourceDataOffset)); 3492 reinterpret_cast<const char**>(FIELD_ADDR(this, kResourceDataOffset));
3486 *data_field = resource()->data(); 3493 *data_field = resource()->data();
3487 } 3494 }
3488 3495
(...skipping 11 matching lines...) Expand all
3500 return reinterpret_cast<const uint8_t*>(resource()->data()); 3507 return reinterpret_cast<const uint8_t*>(resource()->data());
3501 } 3508 }
3502 3509
3503 3510
3504 uint16_t ExternalOneByteString::ExternalOneByteStringGet(int index) { 3511 uint16_t ExternalOneByteString::ExternalOneByteStringGet(int index) {
3505 DCHECK(index >= 0 && index < length()); 3512 DCHECK(index >= 0 && index < length());
3506 return GetChars()[index]; 3513 return GetChars()[index];
3507 } 3514 }
3508 3515
3509 3516
3510 const ExternalTwoByteString::Resource* ExternalTwoByteString::resource() { 3517 const ExternalTwoByteString::Resource* ExternalTwoByteString::resource() const {
3511 return *reinterpret_cast<Resource**>(FIELD_ADDR(this, kResourceOffset)); 3518 return *reinterpret_cast<const Resource* const*>(
3519 FIELD_ADDR_CONST(this, kResourceOffset));
3512 } 3520 }
3513 3521
3514 3522
3515 void ExternalTwoByteString::update_data_cache() { 3523 void ExternalTwoByteString::update_data_cache() {
3516 if (is_short()) return; 3524 if (is_short()) return;
3517 const uint16_t** data_field = 3525 const uint16_t** data_field =
3518 reinterpret_cast<const uint16_t**>(FIELD_ADDR(this, kResourceDataOffset)); 3526 reinterpret_cast<const uint16_t**>(FIELD_ADDR(this, kResourceDataOffset));
3519 *data_field = resource()->data(); 3527 *data_field = resource()->data();
3520 } 3528 }
3521 3529
(...skipping 3853 matching lines...) Expand 10 before | Expand all | Expand 10 after
7375 #undef READ_SHORT_FIELD 7383 #undef READ_SHORT_FIELD
7376 #undef WRITE_SHORT_FIELD 7384 #undef WRITE_SHORT_FIELD
7377 #undef READ_BYTE_FIELD 7385 #undef READ_BYTE_FIELD
7378 #undef WRITE_BYTE_FIELD 7386 #undef WRITE_BYTE_FIELD
7379 #undef NOBARRIER_READ_BYTE_FIELD 7387 #undef NOBARRIER_READ_BYTE_FIELD
7380 #undef NOBARRIER_WRITE_BYTE_FIELD 7388 #undef NOBARRIER_WRITE_BYTE_FIELD
7381 7389
7382 } } // namespace v8::internal 7390 } } // namespace v8::internal
7383 7391
7384 #endif // V8_OBJECTS_INL_H_ 7392 #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