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

Side by Side Diff: src/objects.cc

Issue 11091044: Transition ownership back if the descriptors were shared via elements transitions. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 2 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 | « no previous file | 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 // 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 7413 matching lines...) Expand 10 before | Expand all | Expand 10 after
7424 7424
7425 7425
7426 void String::PrintOn(FILE* file) { 7426 void String::PrintOn(FILE* file) {
7427 int length = this->length(); 7427 int length = this->length();
7428 for (int i = 0; i < length; i++) { 7428 for (int i = 0; i < length; i++) {
7429 fprintf(file, "%c", Get(i)); 7429 fprintf(file, "%c", Get(i));
7430 } 7430 }
7431 } 7431 }
7432 7432
7433 7433
7434 // Clear a possible back pointer in case the transition leads to a dead map.
7435 // Return true in case a back pointer has been cleared and false otherwise.
7436 static bool ClearBackPointer(Heap* heap, Map* target) {
7437 if (Marking::MarkBitFrom(target).Get()) return false;
7438 target->SetBackPointer(heap->undefined_value(), SKIP_WRITE_BARRIER);
7439 return true;
7440 }
7441
7442
7443 static void TrimEnumCache(Heap* heap, Map* map, DescriptorArray* descriptors) { 7434 static void TrimEnumCache(Heap* heap, Map* map, DescriptorArray* descriptors) {
7444 int live_enum = map->EnumLength(); 7435 int live_enum = map->EnumLength();
7445 if (live_enum == Map::kInvalidEnumCache) { 7436 if (live_enum == Map::kInvalidEnumCache) {
7446 live_enum = map->NumberOfDescribedProperties(OWN_DESCRIPTORS, DONT_ENUM); 7437 live_enum = map->NumberOfDescribedProperties(OWN_DESCRIPTORS, DONT_ENUM);
7447 } 7438 }
7448 if (live_enum == 0) return descriptors->ClearEnumCache(); 7439 if (live_enum == 0) return descriptors->ClearEnumCache();
7449 7440
7450 FixedArray* enum_cache = descriptors->GetEnumCache(); 7441 FixedArray* enum_cache = descriptors->GetEnumCache();
7451 7442
7452 int to_trim = enum_cache->length() - live_enum; 7443 int to_trim = enum_cache->length() - live_enum;
(...skipping 25 matching lines...) Expand all
7478 if (to_trim > keep) { 7469 if (to_trim > keep) {
7479 RightTrimFixedArray<FROM_GC>(heap, descriptors, to_trim - keep); 7470 RightTrimFixedArray<FROM_GC>(heap, descriptors, to_trim - keep);
7480 } 7471 }
7481 descriptors->SetNumberOfDescriptors(number_of_own_descriptors); 7472 descriptors->SetNumberOfDescriptors(number_of_own_descriptors);
7482 7473
7483 if (descriptors->HasEnumCache()) TrimEnumCache(heap, map, descriptors); 7474 if (descriptors->HasEnumCache()) TrimEnumCache(heap, map, descriptors);
7484 descriptors->Sort(); 7475 descriptors->Sort();
7485 } 7476 }
7486 7477
7487 7478
7479 // Clear a possible back pointer in case the transition leads to a dead map.
7480 // Return true in case a back pointer has been cleared and false otherwise.
7481 static bool ClearBackPointer(Heap* heap,
7482 Map* target,
7483 DescriptorArray* descriptors,
7484 bool* descriptors_owner_died) {
7485 if (Marking::MarkBitFrom(target).Get()) return false;
7486 if (target->instance_descriptors() == descriptors) {
7487 *descriptors_owner_died = true;
7488 }
7489 target->SetBackPointer(heap->undefined_value(), SKIP_WRITE_BARRIER);
7490 return true;
7491 }
7492
7493
7488 // TODO(mstarzinger): This method should be moved into MarkCompactCollector, 7494 // TODO(mstarzinger): This method should be moved into MarkCompactCollector,
7489 // because it cannot be called from outside the GC and we already have methods 7495 // because it cannot be called from outside the GC and we already have methods
7490 // depending on the transitions layout in the GC anyways. 7496 // depending on the transitions layout in the GC anyways.
7491 void Map::ClearNonLiveTransitions(Heap* heap) { 7497 void Map::ClearNonLiveTransitions(Heap* heap) {
7492 // If there are no transitions to be cleared, return. 7498 // If there are no transitions to be cleared, return.
7493 // TODO(verwaest) Should be an assert, otherwise back pointers are not 7499 // TODO(verwaest) Should be an assert, otherwise back pointers are not
7494 // properly cleared. 7500 // properly cleared.
7495 if (!HasTransitionArray()) return; 7501 if (!HasTransitionArray()) return;
7496 7502
7497 TransitionArray* t = transitions(); 7503 TransitionArray* t = transitions();
7498 MarkCompactCollector* collector = heap->mark_compact_collector(); 7504 MarkCompactCollector* collector = heap->mark_compact_collector();
7499 7505
7500 int transition_index = 0; 7506 int transition_index = 0;
7501 7507
7502 DescriptorArray* descriptors = t->descriptors(); 7508 DescriptorArray* descriptors = t->descriptors();
7503 bool descriptors_owner_died = false; 7509 bool descriptors_owner_died = false;
7504 7510
7505 // Compact all live descriptors to the left. 7511 // Compact all live descriptors to the left.
7506 for (int i = 0; i < t->number_of_transitions(); ++i) { 7512 for (int i = 0; i < t->number_of_transitions(); ++i) {
7507 Map* target = t->GetTarget(i); 7513 Map* target = t->GetTarget(i);
7508 if (ClearBackPointer(heap, target)) { 7514 if (!ClearBackPointer(heap, target, descriptors, &descriptors_owner_died)) {
7509 ASSERT(!Marking::IsGrey(Marking::MarkBitFrom(target)));
7510 DescriptorArray* target_descriptors = target->instance_descriptors();
7511 if ((target_descriptors->number_of_descriptors() == 0 &&
7512 target->NumberOfOwnDescriptors() > 0) ||
7513 target_descriptors == descriptors) {
7514 descriptors_owner_died = true;
7515 }
7516 } else {
7517 if (i != transition_index) { 7515 if (i != transition_index) {
7518 String* key = t->GetKey(i); 7516 String* key = t->GetKey(i);
7519 t->SetKey(transition_index, key); 7517 t->SetKey(transition_index, key);
7520 Object** key_slot = t->GetKeySlot(transition_index); 7518 Object** key_slot = t->GetKeySlot(transition_index);
7521 collector->RecordSlot(key_slot, key_slot, key); 7519 collector->RecordSlot(key_slot, key_slot, key);
7522 // Target slots do not need to be recorded since maps are not compacted. 7520 // Target slots do not need to be recorded since maps are not compacted.
7523 t->SetTarget(transition_index, t->GetTarget(i)); 7521 t->SetTarget(transition_index, t->GetTarget(i));
7524 } 7522 }
7525 transition_index++; 7523 transition_index++;
7526 } 7524 }
7527 } 7525 }
7528 7526
7529 if (t->HasElementsTransition() && 7527 if (t->HasElementsTransition() &&
7530 ClearBackPointer(heap, t->elements_transition())) { 7528 ClearBackPointer(heap,
7531 if (t->elements_transition()->instance_descriptors() == descriptors) { 7529 t->elements_transition(),
7532 descriptors_owner_died = true; 7530 descriptors,
7533 } 7531 &descriptors_owner_died)) {
7534 t->ClearElementsTransition(); 7532 t->ClearElementsTransition();
7535 } else { 7533 } else {
7536 // If there are no transitions to be cleared, return. 7534 // If there are no transitions to be cleared, return.
7537 // TODO(verwaest) Should be an assert, otherwise back pointers are not 7535 // TODO(verwaest) Should be an assert, otherwise back pointers are not
7538 // properly cleared. 7536 // properly cleared.
7539 if (transition_index == t->number_of_transitions()) return; 7537 if (transition_index == t->number_of_transitions()) return;
7540 } 7538 }
7541 7539
7542 int number_of_own_descriptors = NumberOfOwnDescriptors(); 7540 int number_of_own_descriptors = NumberOfOwnDescriptors();
7543 7541
(...skipping 5983 matching lines...) Expand 10 before | Expand all | Expand 10 after
13527 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); 13525 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER);
13528 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); 13526 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER);
13529 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); 13527 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER);
13530 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); 13528 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER);
13531 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); 13529 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER);
13532 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); 13530 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER);
13533 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); 13531 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER);
13534 } 13532 }
13535 13533
13536 } } // namespace v8::internal 13534 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698