| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are |
| 4 // met: |
| 5 // |
| 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided |
| 11 // with the distribution. |
| 12 // * Neither the name of Google Inc. nor the names of its |
| 13 // contributors may be used to endorse or promote products derived |
| 14 // from this software without specific prior written permission. |
| 15 // |
| 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 |
| 28 #ifndef V8_OBJECTS_VISITING_INL_H_ |
| 29 #define V8_OBJECTS_VISITING_INL_H_ |
| 30 |
| 31 |
| 32 namespace v8 { |
| 33 namespace internal { |
| 34 |
| 35 template<typename StaticVisitor> |
| 36 void StaticNewSpaceVisitor<StaticVisitor>::Initialize() { |
| 37 table_.Register(kVisitShortcutCandidate, |
| 38 &FixedBodyVisitor<StaticVisitor, |
| 39 ConsString::BodyDescriptor, |
| 40 int>::Visit); |
| 41 |
| 42 table_.Register(kVisitConsString, |
| 43 &FixedBodyVisitor<StaticVisitor, |
| 44 ConsString::BodyDescriptor, |
| 45 int>::Visit); |
| 46 |
| 47 table_.Register(kVisitFixedArray, |
| 48 &FlexibleBodyVisitor<StaticVisitor, |
| 49 FixedArray::BodyDescriptor, |
| 50 int>::Visit); |
| 51 |
| 52 table_.Register(kVisitGlobalContext, |
| 53 &FixedBodyVisitor<StaticVisitor, |
| 54 Context::ScavengeBodyDescriptor, |
| 55 int>::Visit); |
| 56 |
| 57 table_.Register(kVisitByteArray, &VisitByteArray); |
| 58 |
| 59 table_.Register(kVisitSharedFunctionInfo, |
| 60 &FixedBodyVisitor<StaticVisitor, |
| 61 SharedFunctionInfo::BodyDescriptor, |
| 62 int>::Visit); |
| 63 |
| 64 table_.Register(kVisitSeqAsciiString, &VisitSeqAsciiString); |
| 65 |
| 66 table_.Register(kVisitSeqTwoByteString, &VisitSeqTwoByteString); |
| 67 |
| 68 table_.Register(kVisitJSFunction, |
| 69 &JSObjectVisitor:: |
| 70 template VisitSpecialized<JSFunction::kSize>); |
| 71 |
| 72 table_.template RegisterSpecializations<DataObjectVisitor, |
| 73 kVisitDataObject, |
| 74 kVisitDataObjectGeneric>(); |
| 75 |
| 76 table_.template RegisterSpecializations<JSObjectVisitor, |
| 77 kVisitJSObject, |
| 78 kVisitJSObjectGeneric>(); |
| 79 table_.template RegisterSpecializations<StructVisitor, |
| 80 kVisitStruct, |
| 81 kVisitStructGeneric>(); |
| 82 } |
| 83 |
| 84 |
| 85 void Code::CodeIterateBody(ObjectVisitor* v) { |
| 86 int mode_mask = RelocInfo::kCodeTargetMask | |
| 87 RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) | |
| 88 RelocInfo::ModeMask(RelocInfo::GLOBAL_PROPERTY_CELL) | |
| 89 RelocInfo::ModeMask(RelocInfo::EXTERNAL_REFERENCE) | |
| 90 RelocInfo::ModeMask(RelocInfo::JS_RETURN) | |
| 91 RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT) | |
| 92 RelocInfo::ModeMask(RelocInfo::RUNTIME_ENTRY); |
| 93 |
| 94 // Use the relocation info pointer before it is visited by |
| 95 // the heap compaction in the next statement. |
| 96 RelocIterator it(this, mode_mask); |
| 97 |
| 98 IteratePointer(v, kRelocationInfoOffset); |
| 99 IteratePointer(v, kDeoptimizationDataOffset); |
| 100 |
| 101 for (; !it.done(); it.next()) { |
| 102 it.rinfo()->Visit(v); |
| 103 } |
| 104 } |
| 105 |
| 106 |
| 107 template<typename StaticVisitor> |
| 108 void Code::CodeIterateBody(Heap* heap) { |
| 109 int mode_mask = RelocInfo::kCodeTargetMask | |
| 110 RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) | |
| 111 RelocInfo::ModeMask(RelocInfo::GLOBAL_PROPERTY_CELL) | |
| 112 RelocInfo::ModeMask(RelocInfo::EXTERNAL_REFERENCE) | |
| 113 RelocInfo::ModeMask(RelocInfo::JS_RETURN) | |
| 114 RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT) | |
| 115 RelocInfo::ModeMask(RelocInfo::RUNTIME_ENTRY); |
| 116 |
| 117 // Use the relocation info pointer before it is visited by |
| 118 // the heap compaction in the next statement. |
| 119 RelocIterator it(this, mode_mask); |
| 120 |
| 121 StaticVisitor::VisitPointer( |
| 122 heap, |
| 123 reinterpret_cast<Object**>(this->address() + kRelocationInfoOffset)); |
| 124 StaticVisitor::VisitPointer( |
| 125 heap, |
| 126 reinterpret_cast<Object**>(this->address() + kDeoptimizationDataOffset)); |
| 127 |
| 128 for (; !it.done(); it.next()) { |
| 129 it.rinfo()->template Visit<StaticVisitor>(heap); |
| 130 } |
| 131 } |
| 132 |
| 133 |
| 134 } } // namespace v8::internal |
| 135 |
| 136 #endif // V8_OBJECTS_VISITING_INL_H_ |
| OLD | NEW |