[V8] Introduce a QML compilation mode
[profile/ivi/qtjsbackend.git] / src / 3rdparty / v8 / src / objects-visiting-inl.h
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(kVisitSlicedString,
48                   &FixedBodyVisitor<StaticVisitor,
49                   SlicedString::BodyDescriptor,
50                   int>::Visit);
51
52   table_.Register(kVisitFixedArray,
53                   &FlexibleBodyVisitor<StaticVisitor,
54                   FixedArray::BodyDescriptor,
55                   int>::Visit);
56
57   table_.Register(kVisitFixedDoubleArray, &VisitFixedDoubleArray);
58
59   table_.Register(kVisitGlobalContext,
60                   &FixedBodyVisitor<StaticVisitor,
61                   Context::ScavengeBodyDescriptor,
62                   int>::Visit);
63
64   table_.Register(kVisitByteArray, &VisitByteArray);
65
66   table_.Register(kVisitSharedFunctionInfo,
67                   &FixedBodyVisitor<StaticVisitor,
68                   SharedFunctionInfo::BodyDescriptor,
69                   int>::Visit);
70
71   table_.Register(kVisitSeqAsciiString, &VisitSeqAsciiString);
72
73   table_.Register(kVisitSeqTwoByteString, &VisitSeqTwoByteString);
74
75   table_.Register(kVisitJSFunction, &VisitJSFunction);
76
77   table_.Register(kVisitFreeSpace, &VisitFreeSpace);
78
79   table_.Register(kVisitJSWeakMap, &JSObjectVisitor::Visit);
80
81   table_.Register(kVisitJSRegExp, &JSObjectVisitor::Visit);
82
83   table_.template RegisterSpecializations<DataObjectVisitor,
84                                           kVisitDataObject,
85                                           kVisitDataObjectGeneric>();
86
87   table_.template RegisterSpecializations<JSObjectVisitor,
88                                           kVisitJSObject,
89                                           kVisitJSObjectGeneric>();
90   table_.template RegisterSpecializations<StructVisitor,
91                                           kVisitStruct,
92                                           kVisitStructGeneric>();
93 }
94
95
96 void Code::CodeIterateBody(ObjectVisitor* v) {
97   int mode_mask = RelocInfo::kCodeTargetMask |
98                   RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) |
99                   RelocInfo::ModeMask(RelocInfo::GLOBAL_PROPERTY_CELL) |
100                   RelocInfo::ModeMask(RelocInfo::EXTERNAL_REFERENCE) |
101                   RelocInfo::ModeMask(RelocInfo::JS_RETURN) |
102                   RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT) |
103                   RelocInfo::ModeMask(RelocInfo::RUNTIME_ENTRY);
104
105   // There are two places where we iterate code bodies: here and the
106   // templated CodeIterateBody (below).  They should be kept in sync.
107   IteratePointer(v, kRelocationInfoOffset);
108   IteratePointer(v, kHandlerTableOffset);
109   IteratePointer(v, kDeoptimizationDataOffset);
110   IteratePointer(v, kTypeFeedbackInfoOffset);
111
112   RelocIterator it(this, mode_mask);
113   for (; !it.done(); it.next()) {
114     it.rinfo()->Visit(v);
115   }
116 }
117
118
119 template<typename StaticVisitor>
120 void Code::CodeIterateBody(Heap* heap) {
121   int mode_mask = RelocInfo::kCodeTargetMask |
122                   RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) |
123                   RelocInfo::ModeMask(RelocInfo::GLOBAL_PROPERTY_CELL) |
124                   RelocInfo::ModeMask(RelocInfo::EXTERNAL_REFERENCE) |
125                   RelocInfo::ModeMask(RelocInfo::JS_RETURN) |
126                   RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT) |
127                   RelocInfo::ModeMask(RelocInfo::RUNTIME_ENTRY);
128
129   // There are two places where we iterate code bodies: here and the
130   // non-templated CodeIterateBody (above).  They should be kept in sync.
131   StaticVisitor::VisitPointer(
132       heap,
133       reinterpret_cast<Object**>(this->address() + kRelocationInfoOffset));
134   StaticVisitor::VisitPointer(
135       heap,
136       reinterpret_cast<Object**>(this->address() + kHandlerTableOffset));
137   StaticVisitor::VisitPointer(
138       heap,
139       reinterpret_cast<Object**>(this->address() + kDeoptimizationDataOffset));
140   StaticVisitor::VisitPointer(
141       heap,
142       reinterpret_cast<Object**>(this->address() + kTypeFeedbackInfoOffset));
143
144   RelocIterator it(this, mode_mask);
145   for (; !it.done(); it.next()) {
146     it.rinfo()->template Visit<StaticVisitor>(heap);
147   }
148 }
149
150
151 } }  // namespace v8::internal
152
153 #endif  // V8_OBJECTS_VISITING_INL_H_