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

Side by Side Diff: src/objects.cc

Issue 149403003: A64: Synchronize with r19234. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « src/objects.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 1255 matching lines...) Expand 10 before | Expand all | Expand 10 after
1266 } 1266 }
1267 #endif // DEBUG 1267 #endif // DEBUG
1268 Heap* heap = GetHeap(); 1268 Heap* heap = GetHeap();
1269 int size = this->Size(); // Byte size of the original string. 1269 int size = this->Size(); // Byte size of the original string.
1270 if (size < ExternalString::kShortSize) { 1270 if (size < ExternalString::kShortSize) {
1271 return false; 1271 return false;
1272 } 1272 }
1273 bool is_ascii = this->IsOneByteRepresentation(); 1273 bool is_ascii = this->IsOneByteRepresentation();
1274 bool is_internalized = this->IsInternalizedString(); 1274 bool is_internalized = this->IsInternalizedString();
1275 1275
1276 // Morph the object to an external string by adjusting the map and 1276 // Morph the string to an external string by replacing the map and
1277 // reinitializing the fields. 1277 // reinitializing the fields. This won't work if
1278 if (size >= ExternalString::kSize) { 1278 // - the space the existing string occupies is too small for a regular
1279 // external string.
1280 // - the existing string is in old pointer space and the backing store of
1281 // the external string is not aligned. The GC cannot deal with fields
1282 // containing an unaligned address that points to outside of V8's heap.
1283 // In either case we resort to a short external string instead, omitting
1284 // the field caching the address of the backing store. When we encounter
1285 // short external strings in generated code, we need to bailout to runtime.
1286 if (size < ExternalString::kSize ||
1287 (!IsAligned(reinterpret_cast<intptr_t>(resource->data()), kPointerSize) &&
1288 heap->old_pointer_space()->Contains(this))) {
1279 this->set_map_no_write_barrier( 1289 this->set_map_no_write_barrier(
1280 is_internalized 1290 is_internalized
1281 ? (is_ascii 1291 ? (is_ascii
1282 ? heap->external_internalized_string_with_one_byte_data_map() 1292 ? heap->
1283 : heap->external_internalized_string_map()) 1293 short_external_internalized_string_with_one_byte_data_map()
1294 : heap->short_external_internalized_string_map())
1284 : (is_ascii 1295 : (is_ascii
1285 ? heap->external_string_with_one_byte_data_map() 1296 ? heap->short_external_string_with_one_byte_data_map()
1286 : heap->external_string_map())); 1297 : heap->short_external_string_map()));
1287 } else { 1298 } else {
1288 this->set_map_no_write_barrier( 1299 this->set_map_no_write_barrier(
1289 is_internalized 1300 is_internalized
1290 ? (is_ascii 1301 ? (is_ascii
1291 ? heap-> 1302 ? heap->external_internalized_string_with_one_byte_data_map()
1292 short_external_internalized_string_with_one_byte_data_map() 1303 : heap->external_internalized_string_map())
1293 : heap->short_external_internalized_string_map()) 1304 : (is_ascii
1294 : (is_ascii 1305 ? heap->external_string_with_one_byte_data_map()
1295 ? heap->short_external_string_with_one_byte_data_map() 1306 : heap->external_string_map()));
1296 : heap->short_external_string_map()));
1297 } 1307 }
1298 ExternalTwoByteString* self = ExternalTwoByteString::cast(this); 1308 ExternalTwoByteString* self = ExternalTwoByteString::cast(this);
1299 self->set_resource(resource); 1309 self->set_resource(resource);
1300 if (is_internalized) self->Hash(); // Force regeneration of the hash value. 1310 if (is_internalized) self->Hash(); // Force regeneration of the hash value.
1301 1311
1302 // Fill the remainder of the string with dead wood. 1312 // Fill the remainder of the string with dead wood.
1303 int new_size = this->Size(); // Byte size of the external String object. 1313 int new_size = this->Size(); // Byte size of the external String object.
1304 heap->CreateFillerObjectAt(this->address() + new_size, size - new_size); 1314 heap->CreateFillerObjectAt(this->address() + new_size, size - new_size);
1305 if (Marking::IsBlack(Marking::MarkBitFrom(this))) { 1315 if (Marking::IsBlack(Marking::MarkBitFrom(this))) {
1306 MemoryChunk::IncrementLiveBytesFromMutator(this->address(), 1316 MemoryChunk::IncrementLiveBytesFromMutator(this->address(),
(...skipping 20 matching lines...) Expand all
1327 resource->length() * sizeof(smart_chars[0])) == 0); 1337 resource->length() * sizeof(smart_chars[0])) == 0);
1328 } 1338 }
1329 #endif // DEBUG 1339 #endif // DEBUG
1330 Heap* heap = GetHeap(); 1340 Heap* heap = GetHeap();
1331 int size = this->Size(); // Byte size of the original string. 1341 int size = this->Size(); // Byte size of the original string.
1332 if (size < ExternalString::kShortSize) { 1342 if (size < ExternalString::kShortSize) {
1333 return false; 1343 return false;
1334 } 1344 }
1335 bool is_internalized = this->IsInternalizedString(); 1345 bool is_internalized = this->IsInternalizedString();
1336 1346
1337 // Morph the object to an external string by adjusting the map and 1347 // Morph the string to an external string by replacing the map and
1338 // reinitializing the fields. Use short version if space is limited. 1348 // reinitializing the fields. This won't work if
1339 if (size >= ExternalString::kSize) { 1349 // - the space the existing string occupies is too small for a regular
1350 // external string.
1351 // - the existing string is in old pointer space and the backing store of
1352 // the external string is not aligned. The GC cannot deal with fields
1353 // containing an unaligned address that points to outside of V8's heap.
1354 // In either case we resort to a short external string instead, omitting
1355 // the field caching the address of the backing store. When we encounter
1356 // short external strings in generated code, we need to bailout to runtime.
1357 if (size < ExternalString::kSize ||
1358 (!IsAligned(reinterpret_cast<intptr_t>(resource->data()), kPointerSize) &&
1359 heap->old_pointer_space()->Contains(this))) {
1360 this->set_map_no_write_barrier(
1361 is_internalized ? heap->short_external_ascii_internalized_string_map()
1362 : heap->short_external_ascii_string_map());
1363 } else {
1340 this->set_map_no_write_barrier( 1364 this->set_map_no_write_barrier(
1341 is_internalized ? heap->external_ascii_internalized_string_map() 1365 is_internalized ? heap->external_ascii_internalized_string_map()
1342 : heap->external_ascii_string_map()); 1366 : heap->external_ascii_string_map());
1343 } else {
1344 this->set_map_no_write_barrier(
1345 is_internalized ? heap->short_external_ascii_internalized_string_map()
1346 : heap->short_external_ascii_string_map());
1347 } 1367 }
1348 ExternalAsciiString* self = ExternalAsciiString::cast(this); 1368 ExternalAsciiString* self = ExternalAsciiString::cast(this);
1349 self->set_resource(resource); 1369 self->set_resource(resource);
1350 if (is_internalized) self->Hash(); // Force regeneration of the hash value. 1370 if (is_internalized) self->Hash(); // Force regeneration of the hash value.
1351 1371
1352 // Fill the remainder of the string with dead wood. 1372 // Fill the remainder of the string with dead wood.
1353 int new_size = this->Size(); // Byte size of the external String object. 1373 int new_size = this->Size(); // Byte size of the external String object.
1354 heap->CreateFillerObjectAt(this->address() + new_size, size - new_size); 1374 heap->CreateFillerObjectAt(this->address() + new_size, size - new_size);
1355 if (Marking::IsBlack(Marking::MarkBitFrom(this))) { 1375 if (Marking::IsBlack(Marking::MarkBitFrom(this))) {
1356 MemoryChunk::IncrementLiveBytesFromMutator(this->address(), 1376 MemoryChunk::IncrementLiveBytesFromMutator(this->address(),
(...skipping 9150 matching lines...) Expand 10 before | Expand all | Expand 10 after
10507 10527
10508 void Code::FindAllTypes(TypeHandleList* types) { 10528 void Code::FindAllTypes(TypeHandleList* types) {
10509 ASSERT(is_inline_cache_stub()); 10529 ASSERT(is_inline_cache_stub());
10510 DisallowHeapAllocation no_allocation; 10530 DisallowHeapAllocation no_allocation;
10511 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT); 10531 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT);
10512 for (RelocIterator it(this, mask); !it.done(); it.next()) { 10532 for (RelocIterator it(this, mask); !it.done(); it.next()) {
10513 RelocInfo* info = it.rinfo(); 10533 RelocInfo* info = it.rinfo();
10514 Object* object = info->target_object(); 10534 Object* object = info->target_object();
10515 if (object->IsMap()) { 10535 if (object->IsMap()) {
10516 Handle<Map> map(Map::cast(object)); 10536 Handle<Map> map(Map::cast(object));
10517 types->Add(IC::MapToType(map)); 10537 types->Add(IC::MapToType<HeapType>(map, map->GetIsolate()));
10518 } 10538 }
10519 } 10539 }
10520 } 10540 }
10521 10541
10522 10542
10523 void Code::ReplaceFirstMap(Map* replace_with) { 10543 void Code::ReplaceFirstMap(Map* replace_with) {
10524 ReplaceNthObject(1, GetHeap()->meta_map(), replace_with); 10544 ReplaceNthObject(1, GetHeap()->meta_map(), replace_with);
10525 } 10545 }
10526 10546
10527 10547
(...skipping 2303 matching lines...) Expand 10 before | Expand all | Expand 10 after
12831 object->UpdateAllocationSite(to_kind)); 12851 object->UpdateAllocationSite(to_kind));
12832 } 12852 }
12833 12853
12834 12854
12835 MaybeObject* JSObject::UpdateAllocationSite(ElementsKind to_kind) { 12855 MaybeObject* JSObject::UpdateAllocationSite(ElementsKind to_kind) {
12836 if (!IsJSArray()) return this; 12856 if (!IsJSArray()) return this;
12837 12857
12838 Heap* heap = GetHeap(); 12858 Heap* heap = GetHeap();
12839 if (!heap->InNewSpace(this)) return this; 12859 if (!heap->InNewSpace(this)) return this;
12840 12860
12861 // Check if there is potentially a memento behind the object. If
12862 // the last word of the momento is on another page we return
12863 // immediatelly.
12864 Address object_address = address();
12865 Address memento_address = object_address + JSArray::kSize;
12866 Address last_memento_word_address = memento_address + kPointerSize;
12867 if (!NewSpacePage::OnSamePage(object_address,
12868 last_memento_word_address)) {
12869 return this;
12870 }
12871
12841 // Either object is the last object in the new space, or there is another 12872 // Either object is the last object in the new space, or there is another
12842 // object of at least word size (the header map word) following it, so 12873 // object of at least word size (the header map word) following it, so
12843 // suffices to compare ptr and top here. 12874 // suffices to compare ptr and top here.
12844 Address ptr = address() + JSArray::kSize;
12845 Address top = heap->NewSpaceTop(); 12875 Address top = heap->NewSpaceTop();
12846 ASSERT(ptr == top || ptr + HeapObject::kHeaderSize <= top); 12876 ASSERT(memento_address == top ||
12847 if (ptr == top) return this; 12877 memento_address + HeapObject::kHeaderSize <= top);
12878 if (memento_address == top) return this;
12848 12879
12849 HeapObject* candidate = HeapObject::FromAddress(ptr); 12880 HeapObject* candidate = HeapObject::FromAddress(memento_address);
12850 if (candidate->map() != heap->allocation_memento_map()) return this; 12881 if (candidate->map() != heap->allocation_memento_map()) return this;
12851 12882
12852 AllocationMemento* memento = AllocationMemento::cast(candidate); 12883 AllocationMemento* memento = AllocationMemento::cast(candidate);
12853 if (!memento->IsValid()) return this; 12884 if (!memento->IsValid()) return this;
12854 12885
12855 // Walk through to the Allocation Site 12886 // Walk through to the Allocation Site
12856 AllocationSite* site = memento->GetAllocationSite(); 12887 AllocationSite* site = memento->GetAllocationSite();
12857 return site->DigestTransitionFeedback(to_kind); 12888 return site->DigestTransitionFeedback(to_kind);
12858 } 12889 }
12859 12890
(...skipping 3615 matching lines...) Expand 10 before | Expand all | Expand 10 after
16475 #define ERROR_MESSAGES_TEXTS(C, T) T, 16506 #define ERROR_MESSAGES_TEXTS(C, T) T,
16476 static const char* error_messages_[] = { 16507 static const char* error_messages_[] = {
16477 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 16508 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
16478 }; 16509 };
16479 #undef ERROR_MESSAGES_TEXTS 16510 #undef ERROR_MESSAGES_TEXTS
16480 return error_messages_[reason]; 16511 return error_messages_[reason];
16481 } 16512 }
16482 16513
16483 16514
16484 } } // namespace v8::internal 16515 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698