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

Side by Side Diff: src/objects.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/heap/heap-inl.h ('k') | src/objects-inl.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 // 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 #ifndef V8_OBJECTS_H_ 5 #ifndef V8_OBJECTS_H_
6 #define V8_OBJECTS_H_ 6 #define V8_OBJECTS_H_
7 7
8 #include <iosfwd> 8 #include <iosfwd>
9 9
10 #include "src/allocation.h" 10 #include "src/allocation.h"
(...skipping 9269 matching lines...) Expand 10 before | Expand all | Expand 10 after
9280 // external resource. It is important to ensure (externally) that the 9280 // external resource. It is important to ensure (externally) that the
9281 // resource is not deallocated while the ExternalString is live in the 9281 // resource is not deallocated while the ExternalString is live in the
9282 // V8 heap. 9282 // V8 heap.
9283 // 9283 //
9284 // The API expects that all ExternalStrings are created through the 9284 // The API expects that all ExternalStrings are created through the
9285 // API. Therefore, ExternalStrings should not be used internally. 9285 // API. Therefore, ExternalStrings should not be used internally.
9286 class ExternalString: public String { 9286 class ExternalString: public String {
9287 public: 9287 public:
9288 DECLARE_CAST(ExternalString) 9288 DECLARE_CAST(ExternalString)
9289 9289
9290 inline const void* resource_data() const;
9291
9290 // Layout description. 9292 // Layout description.
9291 static const int kResourceOffset = POINTER_SIZE_ALIGN(String::kSize); 9293 static const int kResourceOffset = POINTER_SIZE_ALIGN(String::kSize);
9292 static const int kShortSize = kResourceOffset + kPointerSize; 9294 static const int kShortSize = kResourceOffset + kPointerSize;
9293 static const int kResourceDataOffset = kResourceOffset + kPointerSize; 9295 static const int kResourceDataOffset = kResourceOffset + kPointerSize;
9294 static const int kSize = kResourceDataOffset + kPointerSize; 9296 static const int kSize = kResourceDataOffset + kPointerSize;
9295 9297
9296 static const int kMaxShortLength = 9298 static const int kMaxShortLength =
9297 (kShortSize - SeqString::kHeaderSize) / kCharSize; 9299 (kShortSize - SeqString::kHeaderSize) / kCharSize;
9298 9300
9299 // Return whether external string is short (data pointer is not cached). 9301 // Return whether external string is short (data pointer is not cached).
9300 inline bool is_short(); 9302 inline bool is_short();
9301 9303
9302 STATIC_ASSERT(kResourceOffset == Internals::kStringResourceOffset); 9304 STATIC_ASSERT(kResourceOffset == Internals::kStringResourceOffset);
9303 9305
9304 private: 9306 private:
9305 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalString); 9307 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalString);
9306 }; 9308 };
9307 9309
9308 9310
9309 // The ExternalOneByteString class is an external string backed by an 9311 // The ExternalOneByteString class is an external string backed by an
9310 // one-byte string. 9312 // one-byte string.
9311 class ExternalOneByteString : public ExternalString { 9313 class ExternalOneByteString : public ExternalString {
9312 public: 9314 public:
9313 static const bool kHasOneByteEncoding = true; 9315 static const bool kHasOneByteEncoding = true;
9314 9316
9315 typedef v8::String::ExternalOneByteStringResource Resource; 9317 typedef v8::String::ExternalOneByteStringResource Resource;
9316 9318
9317 // The underlying resource. 9319 // The underlying resource.
9318 inline const Resource* resource(); 9320 inline const Resource* resource() const;
9319 inline void set_resource(const Resource* buffer); 9321 inline void set_resource(const Resource* buffer);
9320 9322
9321 // Update the pointer cache to the external character array. 9323 // Update the pointer cache to the external character array.
9322 // The cached pointer is always valid, as the external character array does = 9324 // The cached pointer is always valid, as the external character array does =
9323 // not move during lifetime. Deserialization is the only exception, after 9325 // not move during lifetime. Deserialization is the only exception, after
9324 // which the pointer cache has to be refreshed. 9326 // which the pointer cache has to be refreshed.
9325 inline void update_data_cache(); 9327 inline void update_data_cache();
9326 9328
9327 inline const uint8_t* GetChars(); 9329 inline const uint8_t* GetChars();
9328 9330
(...skipping 15 matching lines...) Expand all
9344 9346
9345 // The ExternalTwoByteString class is an external string backed by a UTF-16 9347 // The ExternalTwoByteString class is an external string backed by a UTF-16
9346 // encoded string. 9348 // encoded string.
9347 class ExternalTwoByteString: public ExternalString { 9349 class ExternalTwoByteString: public ExternalString {
9348 public: 9350 public:
9349 static const bool kHasOneByteEncoding = false; 9351 static const bool kHasOneByteEncoding = false;
9350 9352
9351 typedef v8::String::ExternalStringResource Resource; 9353 typedef v8::String::ExternalStringResource Resource;
9352 9354
9353 // The underlying string resource. 9355 // The underlying string resource.
9354 inline const Resource* resource(); 9356 inline const Resource* resource() const;
9355 inline void set_resource(const Resource* buffer); 9357 inline void set_resource(const Resource* buffer);
9356 9358
9357 // Update the pointer cache to the external character array. 9359 // Update the pointer cache to the external character array.
9358 // The cached pointer is always valid, as the external character array does = 9360 // The cached pointer is always valid, as the external character array does =
9359 // not move during lifetime. Deserialization is the only exception, after 9361 // not move during lifetime. Deserialization is the only exception, after
9360 // which the pointer cache has to be refreshed. 9362 // which the pointer cache has to be refreshed.
9361 inline void update_data_cache(); 9363 inline void update_data_cache();
9362 9364
9363 inline const uint16_t* GetChars(); 9365 inline const uint16_t* GetChars();
9364 9366
(...skipping 1514 matching lines...) Expand 10 before | Expand all | Expand 10 after
10879 } else { 10881 } else {
10880 value &= ~(1 << bit_position); 10882 value &= ~(1 << bit_position);
10881 } 10883 }
10882 return value; 10884 return value;
10883 } 10885 }
10884 }; 10886 };
10885 10887
10886 } } // namespace v8::internal 10888 } } // namespace v8::internal
10887 10889
10888 #endif // V8_OBJECTS_H_ 10890 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/heap/heap-inl.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698