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

Side by Side Diff: src/heap/objects-visiting-inl.h

Issue 1508703002: Use WeakCells in the optimized code map rather than traversing in pause. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fixed nit. Created 5 years 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
« no previous file with comments | « src/heap/objects-visiting.h ('k') | src/objects.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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_OBJECTS_VISITING_INL_H_ 5 #ifndef V8_OBJECTS_VISITING_INL_H_
6 #define V8_OBJECTS_VISITING_INL_H_ 6 #define V8_OBJECTS_VISITING_INL_H_
7 7
8 #include "src/heap/array-buffer-tracker.h" 8 #include "src/heap/array-buffer-tracker.h"
9 #include "src/heap/objects-visiting.h" 9 #include "src/heap/objects-visiting.h"
10 #include "src/ic/ic-state.h" 10 #include "src/ic/ic-state.h"
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 shared->ResetForNewContext(heap->global_ic_age()); 447 shared->ResetForNewContext(heap->global_ic_age());
448 } 448 }
449 if (FLAG_cleanup_code_caches_at_gc) { 449 if (FLAG_cleanup_code_caches_at_gc) {
450 shared->ClearTypeFeedbackInfoAtGCTime(); 450 shared->ClearTypeFeedbackInfoAtGCTime();
451 } 451 }
452 if (FLAG_flush_optimized_code_cache) { 452 if (FLAG_flush_optimized_code_cache) {
453 if (!shared->OptimizedCodeMapIsCleared()) { 453 if (!shared->OptimizedCodeMapIsCleared()) {
454 // Always flush the optimized code map if requested by flag. 454 // Always flush the optimized code map if requested by flag.
455 shared->ClearOptimizedCodeMap(); 455 shared->ClearOptimizedCodeMap();
456 } 456 }
457 } else {
458 if (!shared->OptimizedCodeMapIsCleared()) {
459 // Treat some references within the code map weakly by marking the
460 // code map itself but not pushing it onto the marking deque. The
461 // map will be processed after marking.
462 FixedArray* code_map = shared->optimized_code_map();
463 MarkOptimizedCodeMap(heap, code_map);
464 }
465 } 457 }
466 MarkCompactCollector* collector = heap->mark_compact_collector(); 458 MarkCompactCollector* collector = heap->mark_compact_collector();
467 if (collector->is_code_flushing_enabled()) { 459 if (collector->is_code_flushing_enabled()) {
468 if (IsFlushable(heap, shared)) { 460 if (IsFlushable(heap, shared)) {
469 // This function's code looks flushable. But we have to postpone 461 // This function's code looks flushable. But we have to postpone
470 // the decision until we see all functions that point to the same 462 // the decision until we see all functions that point to the same
471 // SharedFunctionInfo because some of them might be optimized. 463 // SharedFunctionInfo because some of them might be optimized.
472 // That would also make the non-optimized version of the code 464 // That would also make the non-optimized version of the code
473 // non-flushable, because it is required for bailing out from 465 // non-flushable, because it is required for bailing out from
474 // optimized code. 466 // optimized code.
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 563
572 // Mark the pointer fields of the Map. Since the transitions array has 564 // Mark the pointer fields of the Map. Since the transitions array has
573 // been marked already, it is fine that one of these fields contains a 565 // been marked already, it is fine that one of these fields contains a
574 // pointer to it. 566 // pointer to it.
575 StaticVisitor::VisitPointers( 567 StaticVisitor::VisitPointers(
576 heap, map, HeapObject::RawField(map, Map::kPointerFieldsBeginOffset), 568 heap, map, HeapObject::RawField(map, Map::kPointerFieldsBeginOffset),
577 HeapObject::RawField(map, Map::kPointerFieldsEndOffset)); 569 HeapObject::RawField(map, Map::kPointerFieldsEndOffset));
578 } 570 }
579 571
580 572
581 template <typename StaticVisitor>
582 void StaticMarkingVisitor<StaticVisitor>::MarkOptimizedCodeMap(
583 Heap* heap, FixedArray* code_map) {
584 if (!StaticVisitor::MarkObjectWithoutPush(heap, code_map)) return;
585
586 // Mark the context-independent entry in the optimized code map. Depending on
587 // the age of the code object, we treat it as a strong or a weak reference.
588 Object* shared_object = code_map->get(SharedFunctionInfo::kSharedCodeIndex);
589 if (FLAG_turbo_preserve_shared_code && shared_object->IsCode() &&
590 FLAG_age_code && !Code::cast(shared_object)->IsOld()) {
591 StaticVisitor::VisitPointer(
592 heap, code_map,
593 code_map->RawFieldOfElementAt(SharedFunctionInfo::kSharedCodeIndex));
594 }
595 }
596
597
598 inline static bool HasSourceCode(Heap* heap, SharedFunctionInfo* info) { 573 inline static bool HasSourceCode(Heap* heap, SharedFunctionInfo* info) {
599 Object* undefined = heap->undefined_value(); 574 Object* undefined = heap->undefined_value();
600 return (info->script() != undefined) && 575 return (info->script() != undefined) &&
601 (reinterpret_cast<Script*>(info->script())->source() != undefined); 576 (reinterpret_cast<Script*>(info->script())->source() != undefined);
602 } 577 }
603 578
604 579
605 template <typename StaticVisitor> 580 template <typename StaticVisitor>
606 bool StaticMarkingVisitor<StaticVisitor>::IsFlushable(Heap* heap, 581 bool StaticMarkingVisitor<StaticVisitor>::IsFlushable(Heap* heap,
607 JSFunction* function) { 582 JSFunction* function) {
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 typedef FlexibleBodyVisitor<StaticVisitor, JSFunction::BodyDescriptorWeakCode, 719 typedef FlexibleBodyVisitor<StaticVisitor, JSFunction::BodyDescriptorWeakCode,
745 void> JSFunctionWeakCodeBodyVisitor; 720 void> JSFunctionWeakCodeBodyVisitor;
746 JSFunctionWeakCodeBodyVisitor::Visit(map, object); 721 JSFunctionWeakCodeBodyVisitor::Visit(map, object);
747 } 722 }
748 723
749 724
750 } // namespace internal 725 } // namespace internal
751 } // namespace v8 726 } // namespace v8
752 727
753 #endif // V8_OBJECTS_VISITING_INL_H_ 728 #endif // V8_OBJECTS_VISITING_INL_H_
OLDNEW
« no previous file with comments | « src/heap/objects-visiting.h ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698