Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Side by Side Diff: Source/bindings/core/v8/ScriptWrappable.h

Issue 362963005: Make ScriptWrappable's destructor empty in oilpan bulids (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(value == 0 201 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(value == 0
202 || value->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex ) == V8T::toInternalPointer(objectAsT)); 202 || value->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex ) == V8T::toInternalPointer(objectAsT));
203 } 203 }
204 204
205 inline bool containsWrapper() const { return (m_wrapperOrTypeInfo & 1); } 205 inline bool containsWrapper() const { return (m_wrapperOrTypeInfo & 1); }
206 inline bool containsTypeInfo() const { return m_wrapperOrTypeInfo && !(m_wra pperOrTypeInfo & 1); } 206 inline bool containsTypeInfo() const { return m_wrapperOrTypeInfo && !(m_wra pperOrTypeInfo & 1); }
207 207
208 protected: 208 protected:
209 ~ScriptWrappable() 209 ~ScriptWrappable()
210 { 210 {
211 // In Oilpan we don't need to call the destructor.
212 //
213 // - 'RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(!containsWrapper())' is n ot needed
214 // because Oilpan is not using reference counting at all. If containsWra pper() is true,
215 // it means that ScriptWrappable still has a wrapper. In this case, the destructor
216 // must not be called since the wrapper has a persistent handle back to this ScriptWrappable object.
217 // Assuming that Oilpan's GC is correct (If we cannot assume this, a lot of more things are
218 // already broken), we must not hit the RELEASE_ASSERT.
219 //
220 // - 'm_wrapperOrTypeInfo = 0' is not needed because Oilpan's GC zeros o ut memory when
221 // the memory is collected and added to a free list.
222 #if !ENABLE(OILPAN)
211 // We must not get deleted as long as we contain a wrapper. If this happ ens, we screwed up ref 223 // We must not get deleted as long as we contain a wrapper. If this happ ens, we screwed up ref
212 // counting somewhere. Crash here instead of crashing during a later gc cycle. 224 // counting somewhere. Crash here instead of crashing during a later gc cycle.
213 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(!containsWrapper()); 225 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(!containsWrapper());
214 ASSERT(m_wrapperOrTypeInfo); // Assert initialization via init() even if not subsequently wrapped. 226 ASSERT(m_wrapperOrTypeInfo); // Assert initialization via init() even if not subsequently wrapped.
215 m_wrapperOrTypeInfo = 0; // Break UAF attempts to wrap. 227 m_wrapperOrTypeInfo = 0; // Break UAF attempts to wrap.
228 #endif
216 } 229 }
217 230
218 private: 231 private:
219 void getPersistent(v8::Persistent<v8::Object>* persistent) const 232 void getPersistent(v8::Persistent<v8::Object>* persistent) const
220 { 233 {
221 ASSERT(persistent); 234 ASSERT(persistent);
222 235
223 // Horrible and super unsafe: Cast the Persistent to an Object*, so 236 // Horrible and super unsafe: Cast the Persistent to an Object*, so
224 // that we can inject the wrapped value. This only works because 237 // that we can inject the wrapped value. This only works because
225 // we previously 'stole' the object pointer from a Persistent in 238 // we previously 'stole' the object pointer from a Persistent in
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 // FIXME: I noticed that 50%~ of minor GC cycle times can be consumed 273 // FIXME: I noticed that 50%~ of minor GC cycle times can be consumed
261 // inside data.GetParameter()->deref(), which causes Node destructions. We should 274 // inside data.GetParameter()->deref(), which causes Node destructions. We should
262 // make Node destructions incremental. 275 // make Node destructions incremental.
263 releaseObject(data.GetValue()); 276 releaseObject(data.GetValue());
264 } 277 }
265 }; 278 };
266 279
267 } // namespace WebCore 280 } // namespace WebCore
268 281
269 #endif // ScriptWrappable_h 282 #endif // ScriptWrappable_h
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698