OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
92 m_maskedStorage = reinterpret_cast<uintptr_t>(info); | 92 m_maskedStorage = reinterpret_cast<uintptr_t>(info); |
93 ASSERT(containsTypeInfo()); | 93 ASSERT(containsTypeInfo()); |
94 } | 94 } |
95 | 95 |
96 void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const | 96 void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const |
97 { | 97 { |
98 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM); | 98 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM); |
99 info.ignoreMember(m_maskedStorage); | 99 info.ignoreMember(m_maskedStorage); |
100 } | 100 } |
101 | 101 |
102 bool containsWrapper() const { return (m_maskedStorage & 1) == 1; } | |
103 | |
102 static bool wrapperCanBeStoredInObject(const void*) { return false; } | 104 static bool wrapperCanBeStoredInObject(const void*) { return false; } |
103 static bool wrapperCanBeStoredInObject(const ScriptWrappable*) { return true ; } | 105 static bool wrapperCanBeStoredInObject(const ScriptWrappable*) { return true ; } |
104 | 106 |
105 static v8::Handle<v8::Object> getWrapperFromObject(void*) | 107 static v8::Handle<v8::Object> getWrapperFromObject(void*) |
106 { | 108 { |
107 ASSERT_NOT_REACHED(); | 109 ASSERT_NOT_REACHED(); |
108 return v8::Handle<v8::Object>(); | 110 return v8::Handle<v8::Object>(); |
109 } | 111 } |
110 | 112 |
111 static v8::Handle<v8::Object> getWrapperFromObject(ScriptWrappable* object) | 113 static v8::Handle<v8::Object> getWrapperFromObject(ScriptWrappable* object) |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
145 } | 147 } |
146 | 148 |
147 protected: | 149 protected: |
148 ~ScriptWrappable() | 150 ~ScriptWrappable() |
149 { | 151 { |
150 ASSERT(m_maskedStorage); // Assert initialization via init() even if no t subsequently wrapped. | 152 ASSERT(m_maskedStorage); // Assert initialization via init() even if no t subsequently wrapped. |
151 m_maskedStorage = 0; // Break UAF attempts to wrap. | 153 m_maskedStorage = 0; // Break UAF attempts to wrap. |
152 } | 154 } |
153 | 155 |
154 private: | 156 private: |
155 inline bool containsWrapper() const { return (m_maskedStorage & 1) == 1; } | 157 friend class MinorGCWrapperVisitor; // For calling rawWrapper(). |
haraken
2013/04/26 13:42:23
Is this the only function we need to make a friend
marja
2013/04/26 13:48:17
Afaics, the only other use of wrapper() is in DOMD
| |
158 | |
159 v8::Object* rawWrapper() const | |
160 { | |
161 if (!containsWrapper()) | |
162 return NULL; | |
haraken
2013/04/26 13:42:23
NULL => 0
marja
2013/04/26 13:48:17
Done.
| |
163 return reinterpret_cast<v8::Object*>(maskOrUnmaskValue(m_maskedStorage)) ; | |
164 } | |
165 | |
156 inline bool containsTypeInfo() const { return m_maskedStorage && ((m_maskedS torage & 1) == 0); } | 166 inline bool containsTypeInfo() const { return m_maskedStorage && ((m_maskedS torage & 1) == 0); } |
157 | 167 |
158 static inline uintptr_t maskOrUnmaskValue(uintptr_t value) | 168 static inline uintptr_t maskOrUnmaskValue(uintptr_t value) |
159 { | 169 { |
160 // Entropy via ASLR, bottom bit set to always toggle the bottom bit in t he result. Since masking is only | 170 // Entropy via ASLR, bottom bit set to always toggle the bottom bit in t he result. Since masking is only |
161 // applied to wrappers, not wrapper type infos, and these are aligned po itners with zeros in the bottom | 171 // applied to wrappers, not wrapper type infos, and these are aligned po itners with zeros in the bottom |
162 // bit(s), this automatically set the wrapper flag in the bottom bit upo n encoding. Simiarlry,this | 172 // bit(s), this automatically set the wrapper flag in the bottom bit upo n encoding. Simiarlry,this |
163 // automatically zeros out the bit upon decoding. Additionally, since se tWrapper() now performs an explicit | 173 // automatically zeros out the bit upon decoding. Additionally, since se tWrapper() now performs an explicit |
164 // null test, and wrapper() requires the bottom bit to be set, there is no need to preserve null here. | 174 // null test, and wrapper() requires the bottom bit to be set, there is no need to preserve null here. |
165 const uintptr_t randomMask = ~((reinterpret_cast<uintptr_t>(&WebCoreMemo ryTypes::DOM) >> 13)) | 1; | 175 const uintptr_t randomMask = ~((reinterpret_cast<uintptr_t>(&WebCoreMemo ryTypes::DOM) >> 13)) | 1; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
197 key->disposeWrapper(value, isolate, info); | 207 key->disposeWrapper(value, isolate, info); |
198 // FIXME: I noticed that 50%~ of minor GC cycle times can be consumed | 208 // FIXME: I noticed that 50%~ of minor GC cycle times can be consumed |
199 // inside key->deref(), which causes Node destructions. We should | 209 // inside key->deref(), which causes Node destructions. We should |
200 // make Node destructions incremental. | 210 // make Node destructions incremental. |
201 info->derefObject(object); | 211 info->derefObject(object); |
202 } | 212 } |
203 | 213 |
204 } // namespace WebCore | 214 } // namespace WebCore |
205 | 215 |
206 #endif // ScriptWrappable_h | 216 #endif // ScriptWrappable_h |
OLD | NEW |