| OLD | NEW |
| 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 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 Heap* heap, RelocInfo* rinfo) { | 306 Heap* heap, RelocInfo* rinfo) { |
| 307 ASSERT(RelocInfo::IsCodeTarget(rinfo->rmode())); | 307 ASSERT(RelocInfo::IsCodeTarget(rinfo->rmode())); |
| 308 Code* target = Code::GetCodeFromTargetAddress(rinfo->target_address()); | 308 Code* target = Code::GetCodeFromTargetAddress(rinfo->target_address()); |
| 309 // Monomorphic ICs are preserved when possible, but need to be flushed | 309 // Monomorphic ICs are preserved when possible, but need to be flushed |
| 310 // when they might be keeping a Context alive, or when the heap is about | 310 // when they might be keeping a Context alive, or when the heap is about |
| 311 // to be serialized. | 311 // to be serialized. |
| 312 if (FLAG_cleanup_code_caches_at_gc && target->is_inline_cache_stub() | 312 if (FLAG_cleanup_code_caches_at_gc && target->is_inline_cache_stub() |
| 313 && (target->ic_state() == MEGAMORPHIC || target->ic_state() == GENERIC || | 313 && (target->ic_state() == MEGAMORPHIC || target->ic_state() == GENERIC || |
| 314 target->ic_state() == POLYMORPHIC || heap->flush_monomorphic_ics() || | 314 target->ic_state() == POLYMORPHIC || heap->flush_monomorphic_ics() || |
| 315 Serializer::enabled() || target->ic_age() != heap->global_ic_age())) { | 315 Serializer::enabled() || target->ic_age() != heap->global_ic_age())) { |
| 316 IC::Clear(target->GetIsolate(), rinfo->pc()); | 316 IC::Clear(target->GetIsolate(), rinfo->pc(), |
| 317 rinfo->host()->constant_pool()); |
| 317 target = Code::GetCodeFromTargetAddress(rinfo->target_address()); | 318 target = Code::GetCodeFromTargetAddress(rinfo->target_address()); |
| 318 } | 319 } |
| 319 heap->mark_compact_collector()->RecordRelocSlot(rinfo, target); | 320 heap->mark_compact_collector()->RecordRelocSlot(rinfo, target); |
| 320 StaticVisitor::MarkObject(heap, target); | 321 StaticVisitor::MarkObject(heap, target); |
| 321 } | 322 } |
| 322 | 323 |
| 323 | 324 |
| 324 template<typename StaticVisitor> | 325 template<typename StaticVisitor> |
| 325 void StaticMarkingVisitor<StaticVisitor>::VisitCodeAgeSequence( | 326 void StaticMarkingVisitor<StaticVisitor>::VisitCodeAgeSequence( |
| 326 Heap* heap, RelocInfo* rinfo) { | 327 Heap* heap, RelocInfo* rinfo) { |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 HeapObject::RawField(object, AllocationSite::kPointerFieldsBeginOffset), | 420 HeapObject::RawField(object, AllocationSite::kPointerFieldsBeginOffset), |
| 420 HeapObject::RawField(object, AllocationSite::kPointerFieldsEndOffset)); | 421 HeapObject::RawField(object, AllocationSite::kPointerFieldsEndOffset)); |
| 421 } | 422 } |
| 422 | 423 |
| 423 | 424 |
| 424 template<typename StaticVisitor> | 425 template<typename StaticVisitor> |
| 425 void StaticMarkingVisitor<StaticVisitor>::VisitCode( | 426 void StaticMarkingVisitor<StaticVisitor>::VisitCode( |
| 426 Map* map, HeapObject* object) { | 427 Map* map, HeapObject* object) { |
| 427 Heap* heap = map->GetHeap(); | 428 Heap* heap = map->GetHeap(); |
| 428 Code* code = Code::cast(object); | 429 Code* code = Code::cast(object); |
| 429 if (FLAG_cleanup_code_caches_at_gc) { | |
| 430 code->ClearTypeFeedbackInfo(heap); | |
| 431 } | |
| 432 if (FLAG_age_code && !Serializer::enabled()) { | 430 if (FLAG_age_code && !Serializer::enabled()) { |
| 433 code->MakeOlder(heap->mark_compact_collector()->marking_parity()); | 431 code->MakeOlder(heap->mark_compact_collector()->marking_parity()); |
| 434 } | 432 } |
| 435 code->CodeIterateBody<StaticVisitor>(heap); | 433 code->CodeIterateBody<StaticVisitor>(heap); |
| 436 } | 434 } |
| 437 | 435 |
| 438 | 436 |
| 439 template<typename StaticVisitor> | 437 template<typename StaticVisitor> |
| 440 void StaticMarkingVisitor<StaticVisitor>::VisitSharedFunctionInfo( | 438 void StaticMarkingVisitor<StaticVisitor>::VisitSharedFunctionInfo( |
| 441 Map* map, HeapObject* object) { | 439 Map* map, HeapObject* object) { |
| 442 Heap* heap = map->GetHeap(); | 440 Heap* heap = map->GetHeap(); |
| 443 SharedFunctionInfo* shared = SharedFunctionInfo::cast(object); | 441 SharedFunctionInfo* shared = SharedFunctionInfo::cast(object); |
| 444 if (shared->ic_age() != heap->global_ic_age()) { | 442 if (shared->ic_age() != heap->global_ic_age()) { |
| 445 shared->ResetForNewContext(heap->global_ic_age()); | 443 shared->ResetForNewContext(heap->global_ic_age()); |
| 446 } | 444 } |
| 445 if (FLAG_cleanup_code_caches_at_gc) { |
| 446 shared->ClearTypeFeedbackInfo(heap); |
| 447 } |
| 447 if (FLAG_cache_optimized_code && | 448 if (FLAG_cache_optimized_code && |
| 448 FLAG_flush_optimized_code_cache && | 449 FLAG_flush_optimized_code_cache && |
| 449 !shared->optimized_code_map()->IsSmi()) { | 450 !shared->optimized_code_map()->IsSmi()) { |
| 450 // Always flush the optimized code map if requested by flag. | 451 // Always flush the optimized code map if requested by flag. |
| 451 shared->ClearOptimizedCodeMap(); | 452 shared->ClearOptimizedCodeMap(); |
| 452 } | 453 } |
| 453 MarkCompactCollector* collector = heap->mark_compact_collector(); | 454 MarkCompactCollector* collector = heap->mark_compact_collector(); |
| 454 if (collector->is_code_flushing_enabled()) { | 455 if (collector->is_code_flushing_enabled()) { |
| 455 if (FLAG_cache_optimized_code && !shared->optimized_code_map()->IsSmi()) { | 456 if (FLAG_cache_optimized_code && !shared->optimized_code_map()->IsSmi()) { |
| 456 // Add the shared function info holding an optimized code map to | 457 // Add the shared function info holding an optimized code map to |
| (...skipping 25 matching lines...) Expand all Loading... |
| 482 } | 483 } |
| 483 VisitSharedFunctionInfoStrongCode(heap, object); | 484 VisitSharedFunctionInfoStrongCode(heap, object); |
| 484 } | 485 } |
| 485 | 486 |
| 486 | 487 |
| 487 template<typename StaticVisitor> | 488 template<typename StaticVisitor> |
| 488 void StaticMarkingVisitor<StaticVisitor>::VisitConstantPoolArray( | 489 void StaticMarkingVisitor<StaticVisitor>::VisitConstantPoolArray( |
| 489 Map* map, HeapObject* object) { | 490 Map* map, HeapObject* object) { |
| 490 Heap* heap = map->GetHeap(); | 491 Heap* heap = map->GetHeap(); |
| 491 ConstantPoolArray* constant_pool = ConstantPoolArray::cast(object); | 492 ConstantPoolArray* constant_pool = ConstantPoolArray::cast(object); |
| 492 if (constant_pool->count_of_ptr_entries() > 0) { | 493 for (int i = 0; i < constant_pool->count_of_code_ptr_entries(); i++) { |
| 493 int first_ptr_offset = constant_pool->OffsetOfElementAt( | 494 int index = constant_pool->first_code_ptr_index() + i; |
| 494 constant_pool->first_ptr_index()); | 495 Address code_entry = |
| 495 int last_ptr_offset = constant_pool->OffsetOfElementAt( | 496 reinterpret_cast<Address>(constant_pool->RawFieldOfElementAt(index)); |
| 496 constant_pool->first_ptr_index() + | 497 StaticVisitor::VisitCodeEntry(heap, code_entry); |
| 497 constant_pool->count_of_ptr_entries() - 1); | 498 } |
| 498 StaticVisitor::VisitPointers( | 499 for (int i = 0; i < constant_pool->count_of_heap_ptr_entries(); i++) { |
| 499 heap, | 500 int index = constant_pool->first_heap_ptr_index() + i; |
| 500 HeapObject::RawField(object, first_ptr_offset), | 501 StaticVisitor::VisitPointer(heap, |
| 501 HeapObject::RawField(object, last_ptr_offset)); | 502 constant_pool->RawFieldOfElementAt(index)); |
| 502 } | 503 } |
| 503 } | 504 } |
| 504 | 505 |
| 505 | 506 |
| 506 template<typename StaticVisitor> | 507 template<typename StaticVisitor> |
| 507 void StaticMarkingVisitor<StaticVisitor>::VisitJSFunction( | 508 void StaticMarkingVisitor<StaticVisitor>::VisitJSFunction( |
| 508 Map* map, HeapObject* object) { | 509 Map* map, HeapObject* object) { |
| 509 Heap* heap = map->GetHeap(); | 510 Heap* heap = map->GetHeap(); |
| 510 JSFunction* function = JSFunction::cast(object); | 511 JSFunction* function = JSFunction::cast(object); |
| 511 MarkCompactCollector* collector = heap->mark_compact_collector(); | 512 MarkCompactCollector* collector = heap->mark_compact_collector(); |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 940 RelocIterator it(this, mode_mask); | 941 RelocIterator it(this, mode_mask); |
| 941 for (; !it.done(); it.next()) { | 942 for (; !it.done(); it.next()) { |
| 942 it.rinfo()->template Visit<StaticVisitor>(heap); | 943 it.rinfo()->template Visit<StaticVisitor>(heap); |
| 943 } | 944 } |
| 944 } | 945 } |
| 945 | 946 |
| 946 | 947 |
| 947 } } // namespace v8::internal | 948 } } // namespace v8::internal |
| 948 | 949 |
| 949 #endif // V8_OBJECTS_VISITING_INL_H_ | 950 #endif // V8_OBJECTS_VISITING_INL_H_ |
| OLD | NEW |