Index: src/objects-inl.h |
diff --git a/src/objects-inl.h b/src/objects-inl.h |
index 11819eaa09d13db19bf029f07c9b92a960c72c31..fda9f4d2d59f6951c21379aa80e498b4cec25d6f 100644 |
--- a/src/objects-inl.h |
+++ b/src/objects-inl.h |
@@ -2297,6 +2297,11 @@ void ConsString::set_second(String* value, WriteBarrierMode mode) { |
} |
+void ExternalString::clear_data_cache() { |
+ WRITE_INTPTR_FIELD(this, kResourceDataOffset, NULL); |
+} |
+ |
+ |
const ExternalAsciiString::Resource* ExternalAsciiString::resource() { |
return *reinterpret_cast<Resource**>(FIELD_ADDR(this, kResourceOffset)); |
} |
@@ -2306,6 +2311,15 @@ void ExternalAsciiString::set_resource( |
const ExternalAsciiString::Resource* resource) { |
*reinterpret_cast<const Resource**>( |
FIELD_ADDR(this, kResourceOffset)) = resource; |
+ clear_data_cache(); |
+} |
+ |
+ |
+const char* ExternalAsciiString::GetChars() { |
+ const char** data_field = |
+ reinterpret_cast<const char**>(FIELD_ADDR(this, kResourceDataOffset)); |
+ if (*data_field == NULL) *data_field = resource()->data(); |
Lasse Reichstein
2011/11/17 13:40:18
Alternatively, we could ensure that the data_field
Yang
2011/11/17 17:06:23
I thought lazy init is nice. I'll check in another
|
+ return *data_field; |
} |
@@ -2318,6 +2332,15 @@ void ExternalTwoByteString::set_resource( |
const ExternalTwoByteString::Resource* resource) { |
*reinterpret_cast<const Resource**>( |
FIELD_ADDR(this, kResourceOffset)) = resource; |
+ clear_data_cache(); |
+} |
+ |
+ |
+const uint16_t* ExternalTwoByteString::GetChars() { |
+ const uint16_t** data_field = |
+ reinterpret_cast<const uint16_t**>(FIELD_ADDR(this, kResourceDataOffset)); |
+ if (*data_field == NULL) *data_field = resource()->data(); |
+ return *data_field; |
} |