OLD | NEW |
---|---|
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 2279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2290 return READ_FIELD(this, kSecondOffset); | 2290 return READ_FIELD(this, kSecondOffset); |
2291 } | 2291 } |
2292 | 2292 |
2293 | 2293 |
2294 void ConsString::set_second(String* value, WriteBarrierMode mode) { | 2294 void ConsString::set_second(String* value, WriteBarrierMode mode) { |
2295 WRITE_FIELD(this, kSecondOffset, value); | 2295 WRITE_FIELD(this, kSecondOffset, value); |
2296 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kSecondOffset, value, mode); | 2296 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kSecondOffset, value, mode); |
2297 } | 2297 } |
2298 | 2298 |
2299 | 2299 |
2300 void ExternalString::clear_data_cache() { | |
2301 WRITE_INTPTR_FIELD(this, kResourceDataOffset, NULL); | |
2302 } | |
2303 | |
2304 | |
2300 const ExternalAsciiString::Resource* ExternalAsciiString::resource() { | 2305 const ExternalAsciiString::Resource* ExternalAsciiString::resource() { |
2301 return *reinterpret_cast<Resource**>(FIELD_ADDR(this, kResourceOffset)); | 2306 return *reinterpret_cast<Resource**>(FIELD_ADDR(this, kResourceOffset)); |
2302 } | 2307 } |
2303 | 2308 |
2304 | 2309 |
2305 void ExternalAsciiString::set_resource( | 2310 void ExternalAsciiString::set_resource( |
2306 const ExternalAsciiString::Resource* resource) { | 2311 const ExternalAsciiString::Resource* resource) { |
2307 *reinterpret_cast<const Resource**>( | 2312 *reinterpret_cast<const Resource**>( |
2308 FIELD_ADDR(this, kResourceOffset)) = resource; | 2313 FIELD_ADDR(this, kResourceOffset)) = resource; |
2314 clear_data_cache(); | |
2309 } | 2315 } |
2310 | 2316 |
2311 | 2317 |
2318 const char* ExternalAsciiString::GetChars() { | |
2319 const char** data_field = | |
2320 reinterpret_cast<const char**>(FIELD_ADDR(this, kResourceDataOffset)); | |
2321 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
| |
2322 return *data_field; | |
2323 } | |
2324 | |
2325 | |
2312 const ExternalTwoByteString::Resource* ExternalTwoByteString::resource() { | 2326 const ExternalTwoByteString::Resource* ExternalTwoByteString::resource() { |
2313 return *reinterpret_cast<Resource**>(FIELD_ADDR(this, kResourceOffset)); | 2327 return *reinterpret_cast<Resource**>(FIELD_ADDR(this, kResourceOffset)); |
2314 } | 2328 } |
2315 | 2329 |
2316 | 2330 |
2317 void ExternalTwoByteString::set_resource( | 2331 void ExternalTwoByteString::set_resource( |
2318 const ExternalTwoByteString::Resource* resource) { | 2332 const ExternalTwoByteString::Resource* resource) { |
2319 *reinterpret_cast<const Resource**>( | 2333 *reinterpret_cast<const Resource**>( |
2320 FIELD_ADDR(this, kResourceOffset)) = resource; | 2334 FIELD_ADDR(this, kResourceOffset)) = resource; |
2335 clear_data_cache(); | |
2321 } | 2336 } |
2322 | 2337 |
2323 | 2338 |
2339 const uint16_t* ExternalTwoByteString::GetChars() { | |
2340 const uint16_t** data_field = | |
2341 reinterpret_cast<const uint16_t**>(FIELD_ADDR(this, kResourceDataOffset)); | |
2342 if (*data_field == NULL) *data_field = resource()->data(); | |
2343 return *data_field; | |
2344 } | |
2345 | |
2346 | |
2324 void JSFunctionResultCache::MakeZeroSize() { | 2347 void JSFunctionResultCache::MakeZeroSize() { |
2325 set_finger_index(kEntriesIndex); | 2348 set_finger_index(kEntriesIndex); |
2326 set_size(kEntriesIndex); | 2349 set_size(kEntriesIndex); |
2327 } | 2350 } |
2328 | 2351 |
2329 | 2352 |
2330 void JSFunctionResultCache::Clear() { | 2353 void JSFunctionResultCache::Clear() { |
2331 int cache_size = size(); | 2354 int cache_size = size(); |
2332 Object** entries_start = RawField(this, OffsetOfElementAt(kEntriesIndex)); | 2355 Object** entries_start = RawField(this, OffsetOfElementAt(kEntriesIndex)); |
2333 MemsetPointer(entries_start, | 2356 MemsetPointer(entries_start, |
(...skipping 2294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4628 #undef WRITE_INT_FIELD | 4651 #undef WRITE_INT_FIELD |
4629 #undef READ_SHORT_FIELD | 4652 #undef READ_SHORT_FIELD |
4630 #undef WRITE_SHORT_FIELD | 4653 #undef WRITE_SHORT_FIELD |
4631 #undef READ_BYTE_FIELD | 4654 #undef READ_BYTE_FIELD |
4632 #undef WRITE_BYTE_FIELD | 4655 #undef WRITE_BYTE_FIELD |
4633 | 4656 |
4634 | 4657 |
4635 } } // namespace v8::internal | 4658 } } // namespace v8::internal |
4636 | 4659 |
4637 #endif // V8_OBJECTS_INL_H_ | 4660 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |