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

Side by Side Diff: src/objects.cc

Issue 14996004: Track heap objects. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 7 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 2119 matching lines...) Expand 10 before | Expand all | Expand 10 after
2130 } 2130 }
2131 2131
2132 2132
2133 const char* Representation::Mnemonic() const { 2133 const char* Representation::Mnemonic() const {
2134 switch (kind_) { 2134 switch (kind_) {
2135 case kNone: return "v"; 2135 case kNone: return "v";
2136 case kTagged: return "t"; 2136 case kTagged: return "t";
2137 case kSmi: return "s"; 2137 case kSmi: return "s";
2138 case kDouble: return "d"; 2138 case kDouble: return "d";
2139 case kInteger32: return "i"; 2139 case kInteger32: return "i";
2140 case kHeapObject: return "h";
2140 case kExternal: return "x"; 2141 case kExternal: return "x";
2141 default: 2142 default:
2142 UNREACHABLE(); 2143 UNREACHABLE();
2143 return NULL; 2144 return NULL;
2144 } 2145 }
2145 } 2146 }
2146 2147
2147 2148
2148 enum RightTrimMode { FROM_GC, FROM_MUTATOR }; 2149 enum RightTrimMode { FROM_GC, FROM_MUTATOR };
2149 2150
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
2492 // - Walk the tree again starting from the root towards |updated|. Stop at 2493 // - Walk the tree again starting from the root towards |updated|. Stop at
2493 // |split_map|, the first map who's descriptor array does not match the merged 2494 // |split_map|, the first map who's descriptor array does not match the merged
2494 // descriptor array. 2495 // descriptor array.
2495 // - If |updated| == |split_map|, |updated| is in the expected state. Return it. 2496 // - If |updated| == |split_map|, |updated| is in the expected state. Return it.
2496 // - Otherwise, invalidate the outdated transition target from |updated|, and 2497 // - Otherwise, invalidate the outdated transition target from |updated|, and
2497 // replace its transition tree with a new branch for the updated descriptors. 2498 // replace its transition tree with a new branch for the updated descriptors.
2498 MaybeObject* Map::GeneralizeRepresentation(int modify_index, 2499 MaybeObject* Map::GeneralizeRepresentation(int modify_index,
2499 Representation new_representation) { 2500 Representation new_representation) {
2500 Map* old_map = this; 2501 Map* old_map = this;
2501 DescriptorArray* old_descriptors = old_map->instance_descriptors(); 2502 DescriptorArray* old_descriptors = old_map->instance_descriptors();
2502 Representation old_reprepresentation = 2503 Representation old_representation =
2503 old_descriptors->GetDetails(modify_index).representation(); 2504 old_descriptors->GetDetails(modify_index).representation();
2504 2505
2505 if (old_reprepresentation.IsNone()) { 2506 if (old_representation.IsNone()) {
2506 UNREACHABLE(); 2507 UNREACHABLE();
2507 old_descriptors->SetRepresentation(modify_index, new_representation); 2508 old_descriptors->SetRepresentation(modify_index, new_representation);
2508 return this; 2509 return this;
2509 } 2510 }
2510 2511
2511 int descriptors = old_map->NumberOfOwnDescriptors(); 2512 int descriptors = old_map->NumberOfOwnDescriptors();
2512 Map* root_map = old_map->FindRootMap(); 2513 Map* root_map = old_map->FindRootMap();
2513 2514
2514 if (!old_map->EquivalentToForTransition(root_map)) { 2515 if (!old_map->EquivalentToForTransition(root_map)) {
2515 return CopyGeneralizeAllRepresentations(); 2516 return CopyGeneralizeAllRepresentations();
2516 } 2517 }
2517 2518
2518 int verbatim = root_map->NumberOfOwnDescriptors(); 2519 int verbatim = root_map->NumberOfOwnDescriptors();
2519 2520
2520 Map* updated = root_map->FindUpdatedMap( 2521 Map* updated = root_map->FindUpdatedMap(
2521 verbatim, descriptors, old_descriptors); 2522 verbatim, descriptors, old_descriptors);
2522 // Check the state of the root map. 2523 // Check the state of the root map.
2523 DescriptorArray* updated_descriptors = updated->instance_descriptors(); 2524 DescriptorArray* updated_descriptors = updated->instance_descriptors();
2524 2525
2525 int valid = updated->NumberOfOwnDescriptors(); 2526 int valid = updated->NumberOfOwnDescriptors();
2526 if (updated_descriptors->IsMoreGeneralThan( 2527 if (updated_descriptors->IsMoreGeneralThan(
2527 verbatim, valid, descriptors, old_descriptors)) { 2528 verbatim, valid, descriptors, old_descriptors)) {
2528 Representation updated_representation = 2529 Representation updated_representation =
2529 updated_descriptors->GetDetails(modify_index).representation(); 2530 updated_descriptors->GetDetails(modify_index).representation();
2530 if (new_representation.fits_into(updated_representation)) { 2531 if (new_representation.fits_into(updated_representation)) {
2531 if (FLAG_trace_generalization) { 2532 if (FLAG_trace_generalization &&
2532 PrintF("migrating to existing map %p -> %p\n", 2533 !(modify_index == 0 && new_representation.IsSmi())) {
2533 static_cast<void*>(this), static_cast<void*>(updated)); 2534 PropertyDetails old_details = old_descriptors->GetDetails(modify_index);
2535 PrintF("migrating to existing map %p(%s) -> %p(%s)\n",
2536 static_cast<void*>(this),
2537 old_details.representation().Mnemonic(),
2538 static_cast<void*>(updated),
2539 updated_representation.Mnemonic());
2534 } 2540 }
2535 return updated; 2541 return updated;
2536 } 2542 }
2537 } 2543 }
2538 2544
2539 DescriptorArray* new_descriptors; 2545 DescriptorArray* new_descriptors;
2540 MaybeObject* maybe_descriptors = updated_descriptors->Merge( 2546 MaybeObject* maybe_descriptors = updated_descriptors->Merge(
2541 verbatim, valid, descriptors, old_descriptors); 2547 verbatim, valid, descriptors, old_descriptors);
2542 if (!maybe_descriptors->To(&new_descriptors)) return maybe_descriptors; 2548 if (!maybe_descriptors->To(&new_descriptors)) return maybe_descriptors;
2543 2549
2544 old_reprepresentation = 2550 old_representation =
2545 new_descriptors->GetDetails(modify_index).representation(); 2551 new_descriptors->GetDetails(modify_index).representation();
2546 new_representation = new_representation.generalize(old_reprepresentation); 2552 Representation updated_representation =
2547 new_descriptors->SetRepresentation(modify_index, new_representation); 2553 new_representation.generalize(old_representation);
2554 if (!updated_representation.Equals(old_representation)) {
2555 new_descriptors->SetRepresentation(modify_index, updated_representation);
2556 }
2548 2557
2549 Map* split_map = root_map->FindLastMatchMap( 2558 Map* split_map = root_map->FindLastMatchMap(
2550 verbatim, descriptors, new_descriptors); 2559 verbatim, descriptors, new_descriptors);
2551 2560
2552 int split_descriptors = split_map->NumberOfOwnDescriptors(); 2561 int split_descriptors = split_map->NumberOfOwnDescriptors();
2553 // This is shadowed by |updated_descriptors| being more general than 2562 // This is shadowed by |updated_descriptors| being more general than
2554 // |old_descriptors|. 2563 // |old_descriptors|.
2555 ASSERT(descriptors != split_descriptors); 2564 ASSERT(descriptors != split_descriptors);
2556 2565
2557 int descriptor = split_descriptors; 2566 int descriptor = split_descriptors;
2558 split_map->DeprecateTarget( 2567 split_map->DeprecateTarget(
2559 old_descriptors->GetKey(descriptor), new_descriptors); 2568 old_descriptors->GetKey(descriptor), new_descriptors);
2560 2569
2561 if (FLAG_trace_generalization) { 2570 if (FLAG_trace_generalization &&
2562 PrintF("migrating to new map %p -> %p (%i steps)\n", 2571 !(modify_index == 0 && new_representation.IsSmi())) {
2572 PrintF("migrating to new map %i: %p(%s) -> %p(%s) (%i steps)\n",
2573 modify_index,
2563 static_cast<void*>(this), 2574 static_cast<void*>(this),
2575 old_representation.Mnemonic(),
2564 static_cast<void*>(new_descriptors), 2576 static_cast<void*>(new_descriptors),
2577 updated_representation.Mnemonic(),
2565 descriptors - descriptor); 2578 descriptors - descriptor);
2566 } 2579 }
2567 2580
2568 Map* new_map = split_map; 2581 Map* new_map = split_map;
2569 // Add missing transitions. 2582 // Add missing transitions.
2570 for (; descriptor < descriptors; descriptor++) { 2583 for (; descriptor < descriptors; descriptor++) {
2571 MaybeObject* maybe_map = new_map->CopyInstallDescriptors( 2584 MaybeObject* maybe_map = new_map->CopyInstallDescriptors(
2572 descriptor, new_descriptors); 2585 descriptor, new_descriptors);
2573 if (!maybe_map->To(&new_map)) { 2586 if (!maybe_map->To(&new_map)) {
2574 // Create a handle for the last created map to ensure it stays alive 2587 // Create a handle for the last created map to ensure it stays alive
(...skipping 12686 matching lines...) Expand 10 before | Expand all | Expand 10 after
15261 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); 15274 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER);
15262 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); 15275 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER);
15263 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); 15276 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER);
15264 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); 15277 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER);
15265 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); 15278 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER);
15266 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); 15279 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER);
15267 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); 15280 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER);
15268 } 15281 }
15269 15282
15270 } } // namespace v8::internal 15283 } } // 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