OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 11 matching lines...) Expand all Loading... |
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
23 * THE POSSIBILITY OF SUCH DAMAGE. | 23 * THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #include "config.h" | 26 #include "config.h" |
27 #include "V8PerIsolateData.h" | 27 #include "V8PerIsolateData.h" |
28 | 28 |
29 #include "ScriptGCEvent.h" | 29 #include "ScriptGCEvent.h" |
30 #include "ScriptProfiler.h" | 30 #include "ScriptProfiler.h" |
31 #include "V8Binding.h" | 31 #include "V8Binding.h" |
32 #include <wtf/MemoryInstrumentationHashMap.h> | |
33 #include <wtf/MemoryInstrumentationVector.h> | |
34 | |
35 namespace WTF { | |
36 | |
37 // WrapperTypeInfo are statically allocated, don't count them. | |
38 template<> struct SequenceMemoryInstrumentationTraits<WebCore::WrapperTypeInfo*>
{ | |
39 template <typename I> static void reportMemoryUsage(I, I, MemoryClassInfo&)
{ } | |
40 }; | |
41 | |
42 } | |
43 | |
44 namespace WebCore { | 32 namespace WebCore { |
45 | 33 |
46 V8PerIsolateData::V8PerIsolateData(v8::Isolate* isolate) | 34 V8PerIsolateData::V8PerIsolateData(v8::Isolate* isolate) |
47 : m_isolate(isolate) | 35 : m_isolate(isolate) |
48 , m_stringCache(adoptPtr(new StringCache())) | 36 , m_stringCache(adoptPtr(new StringCache())) |
49 , m_integerCache(adoptPtr(new IntegerCache())) | 37 , m_integerCache(adoptPtr(new IntegerCache())) |
50 , m_workerDomDataStore(0) | 38 , m_workerDomDataStore(0) |
51 , m_hiddenPropertyName(adoptPtr(new V8HiddenPropertyName())) | 39 , m_hiddenPropertyName(adoptPtr(new V8HiddenPropertyName())) |
52 , m_constructorMode(ConstructorMode::CreateNewObject) | 40 , m_constructorMode(ConstructorMode::CreateNewObject) |
53 , m_recursionLevel(0) | 41 , m_recursionLevel(0) |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 isolate->SetData(0); | 82 isolate->SetData(0); |
95 } | 83 } |
96 | 84 |
97 v8::Handle<v8::FunctionTemplate> V8PerIsolateData::toStringTemplate() | 85 v8::Handle<v8::FunctionTemplate> V8PerIsolateData::toStringTemplate() |
98 { | 86 { |
99 if (m_toStringTemplate.isEmpty()) | 87 if (m_toStringTemplate.isEmpty()) |
100 m_toStringTemplate.set(v8::FunctionTemplate::New(constructorOfToString))
; | 88 m_toStringTemplate.set(v8::FunctionTemplate::New(constructorOfToString))
; |
101 return v8::Local<v8::FunctionTemplate>::New(m_toStringTemplate.get()); | 89 return v8::Local<v8::FunctionTemplate>::New(m_toStringTemplate.get()); |
102 } | 90 } |
103 | 91 |
104 void V8PerIsolateData::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) con
st | |
105 { | |
106 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::Binding); | |
107 info.addMember(m_rawTemplatesForMainWorld, "rawTemplatesForMainWorld"); | |
108 info.addMember(m_rawTemplatesForNonMainWorld, "rawTemplatesForNonMainWorld")
; | |
109 info.addMember(m_templatesForMainWorld, "templatesForMainWorld"); | |
110 info.addMember(m_templatesForNonMainWorld, "templatesForNonMainWorld"); | |
111 info.addMember(m_stringCache, "stringCache"); | |
112 info.addMember(m_integerCache, "integerCache"); | |
113 info.addMember(m_domDataList, "domDataList"); | |
114 info.addMember(m_workerDomDataStore, "workerDomDataStore"); | |
115 info.addMember(m_hiddenPropertyName, "hiddenPropertyName"); | |
116 info.addMember(m_gcEventData, "gcEventData"); | |
117 | |
118 info.addPrivateBuffer(ScriptProfiler::profilerSnapshotsSize(), WebCoreMemory
Types::InspectorProfilerAgent, "HeapSnapshots", "snapshots"); | |
119 | |
120 info.ignoreMember(m_toStringTemplate); | |
121 info.ignoreMember(m_lazyEventListenerToStringTemplate); | |
122 info.ignoreMember(m_v8Null); | |
123 info.ignoreMember(m_liveRoot); | |
124 info.ignoreMember(m_auxiliaryContext); | |
125 } | |
126 | |
127 bool V8PerIsolateData::hasPrivateTemplate(WrapperWorldType currentWorldType, voi
d* privatePointer) | 92 bool V8PerIsolateData::hasPrivateTemplate(WrapperWorldType currentWorldType, voi
d* privatePointer) |
128 { | 93 { |
129 if (currentWorldType == MainWorld) | 94 if (currentWorldType == MainWorld) |
130 return m_templatesForMainWorld.find(privatePointer) != m_templatesForMai
nWorld.end(); | 95 return m_templatesForMainWorld.find(privatePointer) != m_templatesForMai
nWorld.end(); |
131 return m_templatesForNonMainWorld.find(privatePointer) != m_templatesForNonM
ainWorld.end(); | 96 return m_templatesForNonMainWorld.find(privatePointer) != m_templatesForNonM
ainWorld.end(); |
132 } | 97 } |
133 | 98 |
134 v8::Persistent<v8::FunctionTemplate> V8PerIsolateData::privateTemplate(WrapperWo
rldType currentWorldType, void* privatePointer, v8::InvocationCallback callback,
v8::Handle<v8::Value> data, v8::Handle<v8::Signature> signature, int length) | 99 v8::Persistent<v8::FunctionTemplate> V8PerIsolateData::privateTemplate(WrapperWo
rldType currentWorldType, void* privatePointer, v8::InvocationCallback callback,
v8::Handle<v8::Value> data, v8::Handle<v8::Signature> signature, int length) |
135 { | 100 { |
136 v8::Persistent<v8::FunctionTemplate> privateTemplate; | 101 v8::Persistent<v8::FunctionTemplate> privateTemplate; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 // changes to a DOM constructor's toString's toString will cause the | 159 // changes to a DOM constructor's toString's toString will cause the |
195 // toString of the DOM constructor itself to change. This is extremely | 160 // toString of the DOM constructor itself to change. This is extremely |
196 // obscure and unlikely to be a problem. | 161 // obscure and unlikely to be a problem. |
197 v8::Handle<v8::Value> value = args.Callee()->Get(v8::String::NewSymbol("toSt
ring")); | 162 v8::Handle<v8::Value> value = args.Callee()->Get(v8::String::NewSymbol("toSt
ring")); |
198 if (!value->IsFunction()) | 163 if (!value->IsFunction()) |
199 return v8::String::Empty(args.GetIsolate()); | 164 return v8::String::Empty(args.GetIsolate()); |
200 return v8::Handle<v8::Function>::Cast(value)->Call(args.This(), 0, 0); | 165 return v8::Handle<v8::Function>::Cast(value)->Call(args.This(), 0, 0); |
201 } | 166 } |
202 | 167 |
203 } // namespace WebCore | 168 } // namespace WebCore |
OLD | NEW |