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

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

Issue 13973026: remove memoryinstrumentation Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: remove the rest part of MemoryInstrumentation Created 7 years, 8 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 | « Source/bindings/v8/ScriptProfiler.cpp ('k') | Source/bindings/v8/V8Binding.cpp » ('j') | 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 14 matching lines...) Expand all
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #ifndef ScriptWrappable_h 31 #ifndef ScriptWrappable_h
32 #define ScriptWrappable_h 32 #define ScriptWrappable_h
33 33
34 #include "V8Utilities.h" 34 #include "V8Utilities.h"
35 #include "WebCoreMemoryInstrumentation.h"
36 #include "WrapperTypeInfo.h" 35 #include "WrapperTypeInfo.h"
37 #include <v8.h> 36 #include <v8.h>
38 37
39 namespace WebCore { 38 namespace WebCore {
40 39
41 class ScriptWrappable { 40 class ScriptWrappable {
42 friend class WeakHandleListener<ScriptWrappable>; 41 friend class WeakHandleListener<ScriptWrappable>;
43 public: 42 public:
44 ScriptWrappable() : m_maskedStorage(0) { } 43 ScriptWrappable() : m_maskedStorage(0) { }
45 44
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 85
87 return 0; 86 return 0;
88 } 87 }
89 88
90 void setTypeInfo(const WrapperTypeInfo* info) 89 void setTypeInfo(const WrapperTypeInfo* info)
91 { 90 {
92 m_maskedStorage = reinterpret_cast<uintptr_t>(info); 91 m_maskedStorage = reinterpret_cast<uintptr_t>(info);
93 ASSERT(containsTypeInfo()); 92 ASSERT(containsTypeInfo());
94 } 93 }
95 94
96 void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
97 {
98 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM);
99 info.ignoreMember(m_maskedStorage);
100 }
101
102 static bool wrapperCanBeStoredInObject(const void*) { return false; } 95 static bool wrapperCanBeStoredInObject(const void*) { return false; }
103 static bool wrapperCanBeStoredInObject(const ScriptWrappable*) { return true ; } 96 static bool wrapperCanBeStoredInObject(const ScriptWrappable*) { return true ; }
104 97
105 static v8::Handle<v8::Object> getWrapperFromObject(void*) 98 static v8::Handle<v8::Object> getWrapperFromObject(void*)
106 { 99 {
107 ASSERT_NOT_REACHED(); 100 ASSERT_NOT_REACHED();
108 return v8::Handle<v8::Object>(); 101 return v8::Handle<v8::Object>();
109 } 102 }
110 103
111 static v8::Handle<v8::Object> getWrapperFromObject(ScriptWrappable* object) 104 static v8::Handle<v8::Object> getWrapperFromObject(ScriptWrappable* object)
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 inline bool containsWrapper() const { return (m_maskedStorage & 1) == 1; } 148 inline bool containsWrapper() const { return (m_maskedStorage & 1) == 1; }
156 inline bool containsTypeInfo() const { return m_maskedStorage && ((m_maskedS torage & 1) == 0); } 149 inline bool containsTypeInfo() const { return m_maskedStorage && ((m_maskedS torage & 1) == 0); }
157 150
158 static inline uintptr_t maskOrUnmaskValue(uintptr_t value) 151 static inline uintptr_t maskOrUnmaskValue(uintptr_t value)
159 { 152 {
160 // Entropy via ASLR, bottom bit set to always toggle the bottom bit in t he result. Since masking is only 153 // 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 154 // 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 155 // 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 156 // 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. 157 // 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; 158 const uintptr_t randomMask = 15;
166 return value ^ randomMask; 159 return value ^ randomMask;
167 } 160 }
168 161
169 inline void disposeWrapper(v8::Persistent<v8::Value> value, v8::Isolate* iso late, const WrapperTypeInfo* info) 162 inline void disposeWrapper(v8::Persistent<v8::Value> value, v8::Isolate* iso late, const WrapperTypeInfo* info)
170 { 163 {
171 ASSERT(containsWrapper()); 164 ASSERT(containsWrapper());
172 ASSERT(reinterpret_cast<uintptr_t>(*value) == maskOrUnmaskValue(m_masked Storage)); 165 ASSERT(reinterpret_cast<uintptr_t>(*value) == maskOrUnmaskValue(m_masked Storage));
173 value.Dispose(isolate); 166 value.Dispose(isolate);
174 setTypeInfo(info); 167 setTypeInfo(info);
175 } 168 }
(...skipping 21 matching lines...) Expand all
197 key->disposeWrapper(value, isolate, info); 190 key->disposeWrapper(value, isolate, info);
198 // FIXME: I noticed that 50%~ of minor GC cycle times can be consumed 191 // FIXME: I noticed that 50%~ of minor GC cycle times can be consumed
199 // inside key->deref(), which causes Node destructions. We should 192 // inside key->deref(), which causes Node destructions. We should
200 // make Node destructions incremental. 193 // make Node destructions incremental.
201 info->derefObject(object); 194 info->derefObject(object);
202 } 195 }
203 196
204 } // namespace WebCore 197 } // namespace WebCore
205 198
206 #endif // ScriptWrappable_h 199 #endif // ScriptWrappable_h
OLDNEW
« no previous file with comments | « Source/bindings/v8/ScriptProfiler.cpp ('k') | Source/bindings/v8/V8Binding.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698