| 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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 table_.Register(kVisitSharedFunctionInfo, &VisitSharedFunctionInfo); | 189 table_.Register(kVisitSharedFunctionInfo, &VisitSharedFunctionInfo); |
| 190 | 190 |
| 191 table_.Register(kVisitJSFunction, &VisitJSFunction); | 191 table_.Register(kVisitJSFunction, &VisitJSFunction); |
| 192 | 192 |
| 193 table_.Register(kVisitJSArrayBuffer, &VisitJSArrayBuffer); | 193 table_.Register(kVisitJSArrayBuffer, &VisitJSArrayBuffer); |
| 194 | 194 |
| 195 table_.Register(kVisitJSTypedArray, &VisitJSTypedArray); | 195 table_.Register(kVisitJSTypedArray, &VisitJSTypedArray); |
| 196 | 196 |
| 197 // Registration for kVisitJSRegExp is done by StaticVisitor. | 197 // Registration for kVisitJSRegExp is done by StaticVisitor. |
| 198 | 198 |
| 199 table_.Register(kVisitCell, |
| 200 &FixedBodyVisitor<StaticVisitor, |
| 201 Cell::BodyDescriptor, |
| 202 void>::Visit); |
| 203 |
| 199 table_.Register(kVisitPropertyCell, | 204 table_.Register(kVisitPropertyCell, |
| 200 &FixedBodyVisitor<StaticVisitor, | 205 &FixedBodyVisitor<StaticVisitor, |
| 201 JSGlobalPropertyCell::BodyDescriptor, | 206 PropertyCell::BodyDescriptor, |
| 202 void>::Visit); | 207 void>::Visit); |
| 203 | 208 |
| 204 table_.template RegisterSpecializations<DataObjectVisitor, | 209 table_.template RegisterSpecializations<DataObjectVisitor, |
| 205 kVisitDataObject, | 210 kVisitDataObject, |
| 206 kVisitDataObjectGeneric>(); | 211 kVisitDataObjectGeneric>(); |
| 207 | 212 |
| 208 table_.template RegisterSpecializations<JSObjectVisitor, | 213 table_.template RegisterSpecializations<JSObjectVisitor, |
| 209 kVisitJSObject, | 214 kVisitJSObject, |
| 210 kVisitJSObjectGeneric>(); | 215 kVisitJSObjectGeneric>(); |
| 211 | 216 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 233 if (!FLAG_weak_embedded_maps_in_optimized_code || !FLAG_collect_maps || | 238 if (!FLAG_weak_embedded_maps_in_optimized_code || !FLAG_collect_maps || |
| 234 rinfo->host()->kind() != Code::OPTIMIZED_FUNCTION || | 239 rinfo->host()->kind() != Code::OPTIMIZED_FUNCTION || |
| 235 !object->IsMap() || !Map::cast(object)->CanTransition()) { | 240 !object->IsMap() || !Map::cast(object)->CanTransition()) { |
| 236 heap->mark_compact_collector()->RecordRelocSlot(rinfo, object); | 241 heap->mark_compact_collector()->RecordRelocSlot(rinfo, object); |
| 237 StaticVisitor::MarkObject(heap, object); | 242 StaticVisitor::MarkObject(heap, object); |
| 238 } | 243 } |
| 239 } | 244 } |
| 240 | 245 |
| 241 | 246 |
| 242 template<typename StaticVisitor> | 247 template<typename StaticVisitor> |
| 243 void StaticMarkingVisitor<StaticVisitor>::VisitGlobalPropertyCell( | 248 void StaticMarkingVisitor<StaticVisitor>::VisitCell( |
| 244 Heap* heap, RelocInfo* rinfo) { | 249 Heap* heap, RelocInfo* rinfo) { |
| 245 ASSERT(rinfo->rmode() == RelocInfo::GLOBAL_PROPERTY_CELL); | 250 ASSERT(rinfo->rmode() == RelocInfo::CELL); |
| 246 JSGlobalPropertyCell* cell = rinfo->target_cell(); | 251 Cell* cell = rinfo->target_cell(); |
| 247 StaticVisitor::MarkObject(heap, cell); | 252 StaticVisitor::MarkObject(heap, cell); |
| 248 } | 253 } |
| 249 | 254 |
| 250 | 255 |
| 251 template<typename StaticVisitor> | 256 template<typename StaticVisitor> |
| 252 void StaticMarkingVisitor<StaticVisitor>::VisitDebugTarget( | 257 void StaticMarkingVisitor<StaticVisitor>::VisitDebugTarget( |
| 253 Heap* heap, RelocInfo* rinfo) { | 258 Heap* heap, RelocInfo* rinfo) { |
| 254 ASSERT((RelocInfo::IsJSReturn(rinfo->rmode()) && | 259 ASSERT((RelocInfo::IsJSReturn(rinfo->rmode()) && |
| 255 rinfo->IsPatchedReturnSequence()) || | 260 rinfo->IsPatchedReturnSequence()) || |
| 256 (RelocInfo::IsDebugBreakSlot(rinfo->rmode()) && | 261 (RelocInfo::IsDebugBreakSlot(rinfo->rmode()) && |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 // This function's code looks flushable. But we have to postpone | 412 // This function's code looks flushable. But we have to postpone |
| 408 // the decision until we see all functions that point to the same | 413 // the decision until we see all functions that point to the same |
| 409 // SharedFunctionInfo because some of them might be optimized. | 414 // SharedFunctionInfo because some of them might be optimized. |
| 410 // That would also make the non-optimized version of the code | 415 // That would also make the non-optimized version of the code |
| 411 // non-flushable, because it is required for bailing out from | 416 // non-flushable, because it is required for bailing out from |
| 412 // optimized code. | 417 // optimized code. |
| 413 collector->code_flusher()->AddCandidate(function); | 418 collector->code_flusher()->AddCandidate(function); |
| 414 // Visit shared function info immediately to avoid double checking | 419 // Visit shared function info immediately to avoid double checking |
| 415 // of its flushability later. This is just an optimization because | 420 // of its flushability later. This is just an optimization because |
| 416 // the shared function info would eventually be visited. | 421 // the shared function info would eventually be visited. |
| 417 SharedFunctionInfo* shared = function->unchecked_shared(); | 422 SharedFunctionInfo* shared = function->shared(); |
| 418 if (StaticVisitor::MarkObjectWithoutPush(heap, shared)) { | 423 if (StaticVisitor::MarkObjectWithoutPush(heap, shared)) { |
| 419 StaticVisitor::MarkObject(heap, shared->map()); | 424 StaticVisitor::MarkObject(heap, shared->map()); |
| 420 VisitSharedFunctionInfoWeakCode(heap, shared); | 425 VisitSharedFunctionInfoWeakCode(heap, shared); |
| 421 } | 426 } |
| 422 // Treat the reference to the code object weakly. | 427 // Treat the reference to the code object weakly. |
| 423 VisitJSFunctionWeakCode(heap, object); | 428 VisitJSFunctionWeakCode(heap, object); |
| 424 return; | 429 return; |
| 425 } else { | 430 } else { |
| 426 // Visit all unoptimized code objects to prevent flushing them. | 431 // Visit all unoptimized code objects to prevent flushing them. |
| 427 StaticVisitor::MarkObject(heap, function->shared()->code()); | 432 StaticVisitor::MarkObject(heap, function->shared()->code()); |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 inline static bool HasSourceCode(Heap* heap, SharedFunctionInfo* info) { | 593 inline static bool HasSourceCode(Heap* heap, SharedFunctionInfo* info) { |
| 589 Object* undefined = heap->undefined_value(); | 594 Object* undefined = heap->undefined_value(); |
| 590 return (info->script() != undefined) && | 595 return (info->script() != undefined) && |
| 591 (reinterpret_cast<Script*>(info->script())->source() != undefined); | 596 (reinterpret_cast<Script*>(info->script())->source() != undefined); |
| 592 } | 597 } |
| 593 | 598 |
| 594 | 599 |
| 595 template<typename StaticVisitor> | 600 template<typename StaticVisitor> |
| 596 bool StaticMarkingVisitor<StaticVisitor>::IsFlushable( | 601 bool StaticMarkingVisitor<StaticVisitor>::IsFlushable( |
| 597 Heap* heap, JSFunction* function) { | 602 Heap* heap, JSFunction* function) { |
| 598 SharedFunctionInfo* shared_info = function->unchecked_shared(); | 603 SharedFunctionInfo* shared_info = function->shared(); |
| 599 | 604 |
| 600 // Code is either on stack, in compilation cache or referenced | 605 // Code is either on stack, in compilation cache or referenced |
| 601 // by optimized version of function. | 606 // by optimized version of function. |
| 602 MarkBit code_mark = Marking::MarkBitFrom(function->code()); | 607 MarkBit code_mark = Marking::MarkBitFrom(function->code()); |
| 603 if (code_mark.Get()) { | 608 if (code_mark.Get()) { |
| 604 if (!FLAG_age_code) { | 609 if (!FLAG_age_code) { |
| 605 if (!Marking::MarkBitFrom(shared_info).Get()) { | 610 if (!Marking::MarkBitFrom(shared_info).Get()) { |
| 606 shared_info->set_code_age(0); | 611 shared_info->set_code_age(0); |
| 607 } | 612 } |
| 608 } | 613 } |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 770 HeapObject::RawField(object, JSFunction::kPrototypeOrInitialMapOffset); | 775 HeapObject::RawField(object, JSFunction::kPrototypeOrInitialMapOffset); |
| 771 end_slot = | 776 end_slot = |
| 772 HeapObject::RawField(object, JSFunction::kNonWeakFieldsEndOffset); | 777 HeapObject::RawField(object, JSFunction::kNonWeakFieldsEndOffset); |
| 773 StaticVisitor::VisitPointers(heap, start_slot, end_slot); | 778 StaticVisitor::VisitPointers(heap, start_slot, end_slot); |
| 774 } | 779 } |
| 775 | 780 |
| 776 | 781 |
| 777 void Code::CodeIterateBody(ObjectVisitor* v) { | 782 void Code::CodeIterateBody(ObjectVisitor* v) { |
| 778 int mode_mask = RelocInfo::kCodeTargetMask | | 783 int mode_mask = RelocInfo::kCodeTargetMask | |
| 779 RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) | | 784 RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) | |
| 780 RelocInfo::ModeMask(RelocInfo::GLOBAL_PROPERTY_CELL) | | 785 RelocInfo::ModeMask(RelocInfo::CELL) | |
| 781 RelocInfo::ModeMask(RelocInfo::EXTERNAL_REFERENCE) | | 786 RelocInfo::ModeMask(RelocInfo::EXTERNAL_REFERENCE) | |
| 782 RelocInfo::ModeMask(RelocInfo::JS_RETURN) | | 787 RelocInfo::ModeMask(RelocInfo::JS_RETURN) | |
| 783 RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT) | | 788 RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT) | |
| 784 RelocInfo::ModeMask(RelocInfo::RUNTIME_ENTRY); | 789 RelocInfo::ModeMask(RelocInfo::RUNTIME_ENTRY); |
| 785 | 790 |
| 786 // There are two places where we iterate code bodies: here and the | 791 // There are two places where we iterate code bodies: here and the |
| 787 // templated CodeIterateBody (below). They should be kept in sync. | 792 // templated CodeIterateBody (below). They should be kept in sync. |
| 788 IteratePointer(v, kRelocationInfoOffset); | 793 IteratePointer(v, kRelocationInfoOffset); |
| 789 IteratePointer(v, kHandlerTableOffset); | 794 IteratePointer(v, kHandlerTableOffset); |
| 790 IteratePointer(v, kDeoptimizationDataOffset); | 795 IteratePointer(v, kDeoptimizationDataOffset); |
| 791 IteratePointer(v, kTypeFeedbackInfoOffset); | 796 IteratePointer(v, kTypeFeedbackInfoOffset); |
| 792 | 797 |
| 793 RelocIterator it(this, mode_mask); | 798 RelocIterator it(this, mode_mask); |
| 794 for (; !it.done(); it.next()) { | 799 for (; !it.done(); it.next()) { |
| 795 it.rinfo()->Visit(v); | 800 it.rinfo()->Visit(v); |
| 796 } | 801 } |
| 797 } | 802 } |
| 798 | 803 |
| 799 | 804 |
| 800 template<typename StaticVisitor> | 805 template<typename StaticVisitor> |
| 801 void Code::CodeIterateBody(Heap* heap) { | 806 void Code::CodeIterateBody(Heap* heap) { |
| 802 int mode_mask = RelocInfo::kCodeTargetMask | | 807 int mode_mask = RelocInfo::kCodeTargetMask | |
| 803 RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) | | 808 RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) | |
| 804 RelocInfo::ModeMask(RelocInfo::GLOBAL_PROPERTY_CELL) | | 809 RelocInfo::ModeMask(RelocInfo::CELL) | |
| 805 RelocInfo::ModeMask(RelocInfo::EXTERNAL_REFERENCE) | | 810 RelocInfo::ModeMask(RelocInfo::EXTERNAL_REFERENCE) | |
| 806 RelocInfo::ModeMask(RelocInfo::JS_RETURN) | | 811 RelocInfo::ModeMask(RelocInfo::JS_RETURN) | |
| 807 RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT) | | 812 RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT) | |
| 808 RelocInfo::ModeMask(RelocInfo::RUNTIME_ENTRY); | 813 RelocInfo::ModeMask(RelocInfo::RUNTIME_ENTRY); |
| 809 | 814 |
| 810 // There are two places where we iterate code bodies: here and the non- | 815 // There are two places where we iterate code bodies: here and the non- |
| 811 // templated CodeIterateBody (above). They should be kept in sync. | 816 // templated CodeIterateBody (above). They should be kept in sync. |
| 812 StaticVisitor::VisitPointer( | 817 StaticVisitor::VisitPointer( |
| 813 heap, | 818 heap, |
| 814 reinterpret_cast<Object**>(this->address() + kRelocationInfoOffset)); | 819 reinterpret_cast<Object**>(this->address() + kRelocationInfoOffset)); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 825 RelocIterator it(this, mode_mask); | 830 RelocIterator it(this, mode_mask); |
| 826 for (; !it.done(); it.next()) { | 831 for (; !it.done(); it.next()) { |
| 827 it.rinfo()->template Visit<StaticVisitor>(heap); | 832 it.rinfo()->template Visit<StaticVisitor>(heap); |
| 828 } | 833 } |
| 829 } | 834 } |
| 830 | 835 |
| 831 | 836 |
| 832 } } // namespace v8::internal | 837 } } // namespace v8::internal |
| 833 | 838 |
| 834 #endif // V8_OBJECTS_VISITING_INL_H_ | 839 #endif // V8_OBJECTS_VISITING_INL_H_ |
| OLD | NEW |