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

Side by Side Diff: src/mark-compact.cc

Issue 17895004: Add DependentCode to PropertyCells (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Moar review feedback Created 7 years, 5 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/mark-compact.h ('k') | src/mips/lithium-codegen-mips.cc » ('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 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 2233 matching lines...) Expand 10 before | Expand all | Expand 10 after
2244 } 2244 }
2245 } 2245 }
2246 } 2246 }
2247 { 2247 {
2248 HeapObjectIterator js_global_property_cell_iterator( 2248 HeapObjectIterator js_global_property_cell_iterator(
2249 heap()->property_cell_space()); 2249 heap()->property_cell_space());
2250 HeapObject* cell; 2250 HeapObject* cell;
2251 while ((cell = js_global_property_cell_iterator.Next()) != NULL) { 2251 while ((cell = js_global_property_cell_iterator.Next()) != NULL) {
2252 ASSERT(cell->IsPropertyCell()); 2252 ASSERT(cell->IsPropertyCell());
2253 if (IsMarked(cell)) { 2253 if (IsMarked(cell)) {
2254 int offset = PropertyCell::kValueOffset; 2254 MarkCompactMarkingVisitor::VisitPropertyCell(cell->map(), cell);
2255 MarkCompactMarkingVisitor::VisitPointer(
2256 heap(),
2257 reinterpret_cast<Object**>(cell->address() + offset));
2258 offset = PropertyCell::kTypeOffset;
2259 MarkCompactMarkingVisitor::VisitPointer(
2260 heap(),
2261 reinterpret_cast<Object**>(cell->address() + offset));
2262 } 2255 }
2263 } 2256 }
2264 } 2257 }
2265 } 2258 }
2266 2259
2267 RootMarkingVisitor root_visitor(heap()); 2260 RootMarkingVisitor root_visitor(heap());
2268 MarkRoots(&root_visitor); 2261 MarkRoots(&root_visitor);
2269 2262
2270 // The objects reachable from the roots are marked, yet unreachable 2263 // The objects reachable from the roots are marked, yet unreachable
2271 // objects are unmarked. Mark objects reachable due to host 2264 // objects are unmarked. Mark objects reachable due to host
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
2430 // This map is used for inobject slack tracking and has been detached 2423 // This map is used for inobject slack tracking and has been detached
2431 // from SharedFunctionInfo during the mark phase. 2424 // from SharedFunctionInfo during the mark phase.
2432 // Since it survived the GC, reattach it now. 2425 // Since it survived the GC, reattach it now.
2433 JSFunction::cast(map->constructor())->shared()->AttachInitialMap(map); 2426 JSFunction::cast(map->constructor())->shared()->AttachInitialMap(map);
2434 } 2427 }
2435 2428
2436 ClearNonLivePrototypeTransitions(map); 2429 ClearNonLivePrototypeTransitions(map);
2437 ClearNonLiveMapTransitions(map, map_mark); 2430 ClearNonLiveMapTransitions(map, map_mark);
2438 2431
2439 if (map_mark.Get()) { 2432 if (map_mark.Get()) {
2440 ClearNonLiveDependentCode(map); 2433 ClearNonLiveDependentCode(map->dependent_code());
2441 } else { 2434 } else {
2442 ClearAndDeoptimizeDependentCode(map); 2435 ClearAndDeoptimizeDependentCode(map);
2443 } 2436 }
2444 } 2437 }
2438
2439 // Iterate over property cell space, removing dependent code that is not
2440 // otherwise kept alive by strong references.
2441 HeapObjectIterator cell_iterator(heap_->property_cell_space());
2442 for (HeapObject* cell = cell_iterator.Next();
2443 cell != NULL;
2444 cell = cell_iterator.Next()) {
2445 if (IsMarked(cell)) {
2446 ClearNonLiveDependentCode(PropertyCell::cast(cell)->dependent_code());
2447 }
2448 }
2445 } 2449 }
2446 2450
2447 2451
2448 void MarkCompactCollector::ClearNonLivePrototypeTransitions(Map* map) { 2452 void MarkCompactCollector::ClearNonLivePrototypeTransitions(Map* map) {
2449 int number_of_transitions = map->NumberOfProtoTransitions(); 2453 int number_of_transitions = map->NumberOfProtoTransitions();
2450 FixedArray* prototype_transitions = map->GetPrototypeTransitions(); 2454 FixedArray* prototype_transitions = map->GetPrototypeTransitions();
2451 2455
2452 int new_number_of_transitions = 0; 2456 int new_number_of_transitions = 0;
2453 const int header = Map::kProtoTransitionHeaderSize; 2457 const int header = Map::kProtoTransitionHeaderSize;
2454 const int proto_offset = header + Map::kProtoTransitionPrototypeOffset; 2458 const int proto_offset = header + Map::kProtoTransitionPrototypeOffset;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
2520 Code* code = entries->code_at(i); 2524 Code* code = entries->code_at(i);
2521 if (IsMarked(code) && !code->marked_for_deoptimization()) { 2525 if (IsMarked(code) && !code->marked_for_deoptimization()) {
2522 code->set_marked_for_deoptimization(true); 2526 code->set_marked_for_deoptimization(true);
2523 } 2527 }
2524 entries->clear_at(i); 2528 entries->clear_at(i);
2525 } 2529 }
2526 map->set_dependent_code(DependentCode::cast(heap()->empty_fixed_array())); 2530 map->set_dependent_code(DependentCode::cast(heap()->empty_fixed_array()));
2527 } 2531 }
2528 2532
2529 2533
2530 void MarkCompactCollector::ClearNonLiveDependentCode(Map* map) { 2534 void MarkCompactCollector::ClearNonLiveDependentCode(DependentCode* entries) {
2531 DisallowHeapAllocation no_allocation; 2535 DisallowHeapAllocation no_allocation;
2532 DependentCode* entries = map->dependent_code();
2533 DependentCode::GroupStartIndexes starts(entries); 2536 DependentCode::GroupStartIndexes starts(entries);
2534 int number_of_entries = starts.number_of_entries(); 2537 int number_of_entries = starts.number_of_entries();
2535 if (number_of_entries == 0) return; 2538 if (number_of_entries == 0) return;
2536 int new_number_of_entries = 0; 2539 int new_number_of_entries = 0;
2537 // Go through all groups, remove dead codes and compact. 2540 // Go through all groups, remove dead codes and compact.
2538 for (int g = 0; g < DependentCode::kGroupCount; g++) { 2541 for (int g = 0; g < DependentCode::kGroupCount; g++) {
2539 int group_number_of_entries = 0; 2542 int group_number_of_entries = 0;
2540 for (int i = starts.at(g); i < starts.at(g + 1); i++) { 2543 for (int i = starts.at(g); i < starts.at(g + 1); i++) {
2541 Object* obj = entries->object_at(i); 2544 Object* obj = entries->object_at(i);
2542 ASSERT(obj->IsCode() || IsMarked(obj)); 2545 ASSERT(obj->IsCode() || IsMarked(obj));
(...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after
3391 } 3394 }
3392 3395
3393 GCTracer::Scope gc_scope(tracer_, GCTracer::Scope::MC_UPDATE_MISC_POINTERS); 3396 GCTracer::Scope gc_scope(tracer_, GCTracer::Scope::MC_UPDATE_MISC_POINTERS);
3394 3397
3395 // Update pointers from cells. 3398 // Update pointers from cells.
3396 HeapObjectIterator cell_iterator(heap_->cell_space()); 3399 HeapObjectIterator cell_iterator(heap_->cell_space());
3397 for (HeapObject* cell = cell_iterator.Next(); 3400 for (HeapObject* cell = cell_iterator.Next();
3398 cell != NULL; 3401 cell != NULL;
3399 cell = cell_iterator.Next()) { 3402 cell = cell_iterator.Next()) {
3400 if (cell->IsCell()) { 3403 if (cell->IsCell()) {
3401 Address value_address = reinterpret_cast<Address>(cell) + 3404 Cell::BodyDescriptor::IterateBody(cell, &updating_visitor);
3402 (Cell::kValueOffset - kHeapObjectTag);
3403 updating_visitor.VisitPointer(reinterpret_cast<Object**>(value_address));
3404 } 3405 }
3405 } 3406 }
3406 3407
3407 HeapObjectIterator js_global_property_cell_iterator( 3408 HeapObjectIterator js_global_property_cell_iterator(
3408 heap_->property_cell_space()); 3409 heap_->property_cell_space());
3409 for (HeapObject* cell = js_global_property_cell_iterator.Next(); 3410 for (HeapObject* cell = js_global_property_cell_iterator.Next();
3410 cell != NULL; 3411 cell != NULL;
3411 cell = js_global_property_cell_iterator.Next()) { 3412 cell = js_global_property_cell_iterator.Next()) {
3412 if (cell->IsPropertyCell()) { 3413 if (cell->IsPropertyCell()) {
3413 Address value_address = 3414 PropertyCell::BodyDescriptor::IterateBody(cell, &updating_visitor);
3414 reinterpret_cast<Address>(cell) +
3415 (PropertyCell::kValueOffset - kHeapObjectTag);
3416 updating_visitor.VisitPointer(reinterpret_cast<Object**>(value_address));
3417 Address type_address =
3418 reinterpret_cast<Address>(cell) +
3419 (PropertyCell::kTypeOffset - kHeapObjectTag);
3420 updating_visitor.VisitPointer(reinterpret_cast<Object**>(type_address));
3421 } 3415 }
3422 } 3416 }
3423 3417
3424 // Update pointer from the native contexts list. 3418 // Update pointer from the native contexts list.
3425 updating_visitor.VisitPointer(heap_->native_contexts_list_address()); 3419 updating_visitor.VisitPointer(heap_->native_contexts_list_address());
3426 3420
3427 heap_->string_table()->Iterate(&updating_visitor); 3421 heap_->string_table()->Iterate(&updating_visitor);
3428 3422
3429 // Update pointers from external string table. 3423 // Update pointers from external string table.
3430 heap_->UpdateReferencesInExternalStringTable( 3424 heap_->UpdateReferencesInExternalStringTable(
(...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after
4295 while (buffer != NULL) { 4289 while (buffer != NULL) {
4296 SlotsBuffer* next_buffer = buffer->next(); 4290 SlotsBuffer* next_buffer = buffer->next();
4297 DeallocateBuffer(buffer); 4291 DeallocateBuffer(buffer);
4298 buffer = next_buffer; 4292 buffer = next_buffer;
4299 } 4293 }
4300 *buffer_address = NULL; 4294 *buffer_address = NULL;
4301 } 4295 }
4302 4296
4303 4297
4304 } } // namespace v8::internal 4298 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/mark-compact.h ('k') | src/mips/lithium-codegen-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698