source: webkit/trunk/JavaScriptCore/JavaScriptCore.exp@ 24714

Last change on this file since 24714 was 24633, checked in by mjs, 18 years ago

JavaScriptCore:

Reviewed by Darin.


  • JavaScriptCore part of fix for <rdar://problem/5300291> Optimize GC to reclaim big, temporary objects (like XMLHttpRequest.responseXML) quickly


Also, as a side effect of optimizations included in this patch:

  • 7% speedup on JavaScript iBench
  • 4% speedup on "Celtic Kane" JS benchmark


The basic idea is explained in a big comment in collector.cpp. When unusually
large objecs are allocated, we push the next GC closer on the assumption that
most objects are short-lived.


I also did the following two optimizations in the course of tuning
this not to be a performance regression:

1) Change UString::Rep to hold a self-pointer as the baseString in
the unshared case, instead of a null pointer; this removes a
number of null checks in hot code because many places already
wanted to use the rep itself or the baseString as appropriate.


2) Avoid creating duplicate StringImpls when creating a
StringInstance (the object wrapper for a JS string) or calling
their methods. Since a temporary wrapper object is made every time
a string method is called, this resulted in two useless extra
StringImpls being allocated for no reason whenever a String method
was invoked on a string value. Now we bypass those.


  • kjs/collector.cpp: (KJS::): (KJS::Collector::recordExtraCost): Basics of the extra cost mechanism. (KJS::Collector::allocate): ditto (KJS::Collector::collect): ditto
  • kjs/collector.h: (KJS::Collector::reportExtraMemoryCost): ditto
  • kjs/array_object.cpp: (ArrayInstance::ArrayInstance): record extra cost
  • kjs/internal.cpp: (KJS::StringImp::toObject): don't create a whole new StringImpl just to be the internal value of a StringInstance! StringImpls are immutable so there's no point tot his.
  • kjs/internal.h: (KJS::StringImp::StringImp): report extra cost
  • kjs/string_object.cpp: (KJS::StringInstance::StringInstance): new version that takes a StringImp (KJS::StringProtoFunc::callAsFunction): don't create a whole new StringImpl just to convert self to string! we already have one in the internal value
  • kjs/string_object.h: report extra cost
  • kjs/ustring.cpp: All changes to handle baseString being self instead of null in the unshared case. (KJS::): (KJS::UString::Rep::create): (KJS::UString::Rep::destroy): (KJS::UString::usedCapacity): (KJS::UString::usedPreCapacity): (KJS::UString::expandCapacity): (KJS::UString::expandPreCapacity): (KJS::UString::UString): (KJS::UString::append): (KJS::UString::operator=): (KJS::UString::copyForWriting):
  • kjs/ustring.h: (KJS::UString::Rep::baseIsSelf): new method, now that baseString is self instead of null in the unshared case we can't just null check. (KJS::UString::Rep::data): adjusted as mentioned above (KJS::UString::cost): new method to compute the cost for a UString, for use by StringImpl.
  • kjs/value.cpp: (KJS::jsString): style fixups. (KJS::jsOwnedString): new method, use this for strings allocated from UStrings held by the parse tree. Tracking their cost as part of string cost is pointless, because garbage collecting them will not actually free the relevant string buffer.
  • kjs/value.h: prototyped jsOwnedString.
  • kjs/nodes.cpp: (StringNode::evaluate): use jsOwnedString as appropriate (RegExpNode::evaluate): ditto (PropertyNameNode::evaluate): ditto (ForInNode::execute): ditto


WebCore:

Reviewed by Darin.

  • fixed <rdar://problem/5300291> Optimize GC to reclaim big, temporary objects (like XMLHttpRequest.responseXML) quickly


With this plus related JavaScriptCore changes, a number of XMLHttpRequest situations that
result in huge data sets are addressed, including a single huge responseXML on an XMR done
repeatedly, or accessing responseText repeatedly during loading of a single large XHR.


In addition to the GC changes in JavaScriptCore, I changed responseText to be stored as a
KJS::UString instead of a WebCore::String so that the JavaScript responseText value can
share the buffer (indeed multiple intermediate responseTexts can share its buffer).


First of all, here's some manual test cases that will each blow out the process VM without this fix,
but will settle into decent steady state with.


  • manual-tests/memory: Added.
  • manual-tests/memory/MessageUidsAlreadyDownloaded2: Added.
  • manual-tests/memory/string-growth.html: Added.
  • manual-tests/memory/xhr-multiple-requests-responseText.html: Added.
  • manual-tests/memory/xhr-multiple-requests-responseXML.html: Added.
  • manual-tests/memory/xhr-multiple-requests.html: Added.
  • manual-tests/memory/xhr-repeated-string-access.xml: Added.

And here's the actual code changes:


  • WebCore.xcodeproj/project.pbxproj:
  • bindings/js/JSDocumentCustom.cpp: (WebCore::toJS): Record extra cost if the document is frameless (counting the nodes doesn't make a measurable performance difference here in any case I could find)
  • bindings/js/JSXMLHttpRequest.cpp: (KJS::JSXMLHttpRequest::getValueProperty): Adjust for the fact that ressponseText is now stored as a UString.
  • bindings/js/kjs_binding.cpp: (KJS::jsOwnedStringOrNull): New helper.
  • bindings/js/kjs_binding.h:
  • xml/XMLHttpRequest.cpp: (WebCore::XMLHttpRequest::getResponseText): It's a UString! (WebCore::XMLHttpRequest::getResponseXML): handle the fact that m_responseText is a UString. (WebCore::XMLHttpRequest::XMLHttpRequest): ditto. (WebCore::XMLHttpRequest::abort): call dropProtection (WebCore::XMLHttpRequest::didFinishLoading): call dropProtection (WebCore::XMLHttpRequest::dropProtection): after removing our GC protection, report extra cost of this XHR's responseText buffer.
  • xml/XMLHttpRequest.h:
File size: 10.2 KB
Line 
1_JSCheckScriptSyntax
2_JSClassCreate
3_JSClassRelease
4_JSClassRetain
5_JSContextGetGlobalObject
6_JSEvaluateScript
7_JSGarbageCollect
8_JSGlobalContextCreate
9_JSGlobalContextRelease
10_JSGlobalContextRetain
11_JSObjectCallAsConstructor
12_JSObjectCallAsFunction
13_JSObjectCopyPropertyNames
14_JSObjectDeleteProperty
15_JSObjectGetPrivate
16_JSObjectGetProperty
17_JSObjectGetPropertyAtIndex
18_JSObjectGetPrototype
19_JSObjectHasProperty
20_JSObjectIsConstructor
21_JSObjectIsFunction
22_JSObjectMake
23_JSObjectMakeConstructor
24_JSObjectMakeFunction
25_JSObjectMakeFunctionWithCallback
26_JSObjectSetPrivate
27_JSObjectSetProperty
28_JSObjectSetPropertyAtIndex
29_JSObjectSetPrototype
30_JSPropertyNameAccumulatorAddName
31_JSPropertyNameArrayGetCount
32_JSPropertyNameArrayGetNameAtIndex
33_JSPropertyNameArrayRelease
34_JSPropertyNameArrayRetain
35_JSStringCopyCFString
36_JSStringCreateWithCFString
37_JSStringCreateWithCharacters
38_JSStringCreateWithUTF8CString
39_JSStringGetCharactersPtr
40_JSStringGetLength
41_JSStringGetMaximumUTF8CStringSize
42_JSStringGetUTF8CString
43_JSStringIsEqual
44_JSStringIsEqualToUTF8CString
45_JSStringRelease
46_JSStringRetain
47_JSValueGetType
48_JSValueIsBoolean
49_JSValueIsEqual
50_JSValueIsInstanceOfConstructor
51_JSValueIsNull
52_JSValueIsNumber
53_JSValueIsObject
54_JSValueIsObjectOfClass
55_JSValueIsStrictEqual
56_JSValueIsString
57_JSValueIsUndefined
58_JSValueMakeBoolean
59_JSValueMakeNull
60_JSValueMakeNumber
61_JSValueMakeString
62_JSValueMakeUndefined
63_JSValueProtect
64_JSValueToBoolean
65_JSValueToNumber
66_JSValueToObject
67_JSValueToStringCopy
68_JSValueUnprotect
69_KJS_JSCreateNativeJSObject
70_KJS_JSObject_JSFinalize
71_KJS_JSObject_JSObjectCall
72_KJS_JSObject_JSObjectEval
73_KJS_JSObject_JSObjectGetMember
74_KJS_JSObject_JSObjectGetSlot
75_KJS_JSObject_JSObjectRemoveMember
76_KJS_JSObject_JSObjectSetMember
77_KJS_JSObject_JSObjectSetSlot
78_KJS_JSObject_JSObjectToString
79_WTFLog
80_WTFReportArgumentAssertionFailure
81_WTFReportAssertionFailure
82_WTFReportAssertionFailureWithMessage
83_WTFReportError
84_WTFReportFatalError
85__NPN_CreateObject
86__NPN_DeallocateObject
87__NPN_Enumerate
88__NPN_Evaluate
89__NPN_GetIntIdentifier
90__NPN_GetProperty
91__NPN_GetStringIdentifier
92__NPN_GetStringIdentifiers
93__NPN_IdentifierIsString
94__NPN_Invoke
95__NPN_InvokeDefault
96__NPN_ReleaseObject
97__NPN_ReleaseVariantValue
98__NPN_RemoveProperty
99__NPN_RetainObject
100__NPN_SetException
101__NPN_SetProperty
102__NPN_UTF8FromIdentifier
103__Z23_NPN_CreateScriptObjectP4_NPPPN3KJS8JSObjectEN3WTF10PassRefPtrINS1_8Bindings10RootObjectEEES8_
104__Z25_NPN_CreateNoScriptObjectv
105__ZN3KJS10Identifier3addEPKNS_5UCharEi
106__ZN3KJS10Identifier3addEPKc
107__ZN3KJS10Identifier3addEPNS_7UString3RepE
108__ZN3KJS10Identifier5equalEPKNS_7UString3RepEPKc
109__ZN3KJS10throwErrorEPNS_9ExecStateENS_9ErrorTypeE
110__ZN3KJS10throwErrorEPNS_9ExecStateENS_9ErrorTypeEPKc
111__ZN3KJS11Interpreter10globalExecEv
112__ZN3KJS11Interpreter11checkSyntaxERKNS_7UStringEiPKNS_5UCharEi
113__ZN3KJS11Interpreter11checkSyntaxERKNS_7UStringEiS3_
114__ZN3KJS11Interpreter15restoreBuiltinsERKNS_13SavedBuiltinsE
115__ZN3KJS11Interpreter16initGlobalObjectEv
116__ZN3KJS11Interpreter16stopTimeoutCheckEv
117__ZN3KJS11Interpreter17startTimeoutCheckEv
118__ZN3KJS11Interpreter21shouldPrintExceptionsEv
119__ZN3KJS11Interpreter24setShouldPrintExceptionsEb
120__ZN3KJS11Interpreter4markEv
121__ZN3KJS11Interpreter6s_hookE
122__ZN3KJS11Interpreter8evaluateERKNS_7UStringEiPKNS_5UCharEiPNS_7JSValueE
123__ZN3KJS11Interpreter8evaluateERKNS_7UStringEiS3_PNS_7JSValueE
124__ZN3KJS11InterpreterC1EPNS_8JSObjectE
125__ZN3KJS11InterpreterC1Ev
126__ZN3KJS11InterpreterC2EPNS_8JSObjectE
127__ZN3KJS11InterpreterD1Ev
128__ZN3KJS11InterpreterD2Ev
129__ZN3KJS11JSImmediate4typeEPKNS_7JSValueE
130__ZN3KJS11JSImmediate8toObjectEPKNS_7JSValueEPNS_9ExecStateE
131__ZN3KJS11JSImmediate8toStringEPKNS_7JSValueE
132__ZN3KJS11PropertyMap11getLocationERKNS_10IdentifierE
133__ZN3KJS11PropertyMap5clearEv
134__ZN3KJS11PropertyMap7restoreERKNS_15SavedPropertiesE
135__ZN3KJS11PropertyMapD1Ev
136__ZN3KJS12DateInstance4infoE
137__ZN3KJS12PropertySlot15undefinedGetterEPNS_9ExecStateEPNS_8JSObjectERKNS_10IdentifierERKS0_
138__ZN3KJS12jsNumberCellEd
139__ZN3KJS13ArrayInstance4infoE
140__ZN3KJS13SavedBuiltinsC1Ev
141__ZN3KJS13SavedBuiltinsD1Ev
142__ZN3KJS14StringInstance14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE
143__ZN3KJS14StringInstance16getPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayE
144__ZN3KJS14StringInstance18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE
145__ZN3KJS14StringInstance3putEPNS_9ExecStateERKNS_10IdentifierEPNS_7JSValueEi
146__ZN3KJS14StringInstance4infoE
147__ZN3KJS14StringInstanceC1EPNS_8JSObjectERKNS_7UStringE
148__ZN3KJS14StringInstanceC2EPNS_8JSObjectERKNS_7UStringE
149__ZN3KJS15JSWrapperObject4markEv
150__ZN3KJS15SavedPropertiesC1Ev
151__ZN3KJS15SavedPropertiesD1Ev
152__ZN3KJS16RuntimeObjectImp4infoE
153__ZN3KJS16RuntimeObjectImpC1EPNS_8Bindings8InstanceE
154__ZN3KJS17PropertyNameArray3addERKNS_10IdentifierE
155__ZN3KJS19InternalFunctionImp4infoE
156__ZN3KJS19InternalFunctionImpC2EPNS_17FunctionPrototypeERKNS_10IdentifierE
157__ZN3KJS4List6appendEPNS_7JSValueE
158__ZN3KJS4List7releaseEv
159__ZN3KJS4ListC1Ev
160__ZN3KJS6JSCell9getObjectEv
161__ZN3KJS6JSCellnwEm
162__ZN3KJS6JSLock12DropAllLocksC1Ev
163__ZN3KJS6JSLock12DropAllLocksD1Ev
164__ZN3KJS6JSLock14registerThreadEv
165__ZN3KJS6JSLock4lockEv
166__ZN3KJS6JSLock6unlockEv
167__ZN3KJS6JSLock9lockCountEv
168__ZN3KJS6Lookup9findEntryEPKNS_9HashTableERKNS_10IdentifierE
169__ZN3KJS6Parser11prettyPrintERKNS_7UStringEPiPS1_
170__ZN3KJS7CStringD1Ev
171__ZN3KJS7UString3Rep4nullE
172__ZN3KJS7UString3Rep7destroyEv
173__ZN3KJS7UString6appendERKS0_
174__ZN3KJS7UStringC1EPKNS_5UCharEi
175__ZN3KJS7UStringC1EPKc
176__ZN3KJS7UStringC1ERKS0_S2_
177__ZN3KJS7UStringaSEPKc
178__ZN3KJS8Bindings10RootObject10invalidateEv
179__ZN3KJS8Bindings10RootObject11gcUnprotectEPNS_8JSObjectE
180__ZN3KJS8Bindings10RootObject17_createRootObjectE
181__ZN3KJS8Bindings10RootObject19setCreateRootObjectEPFN3WTF10PassRefPtrIS1_EEPvE
182__ZN3KJS8Bindings10RootObject6createEPKvN3WTF10PassRefPtrINS_11InterpreterEEE
183__ZN3KJS8Bindings10RootObject9gcProtectEPNS_8JSObjectE
184__ZN3KJS8Bindings10RootObjectD1Ev
185__ZN3KJS8Bindings10throwErrorEPNS_9ExecStateENS_9ErrorTypeEP8NSString
186__ZN3KJS8Bindings23convertObjcValueToValueEPNS_9ExecStateEPvNS0_13ObjcValueTypeEPNS0_10RootObjectE
187__ZN3KJS8Bindings23convertValueToObjcValueEPNS_9ExecStateEPNS_7JSValueENS0_13ObjcValueTypeE
188__ZN3KJS8Bindings8Instance18didExecuteFunctionEv
189__ZN3KJS8Bindings8Instance21setDidExecuteFunctionEPFvPNS_9ExecStateEPNS_8JSObjectEE
190__ZN3KJS8Bindings8Instance32createBindingForLanguageInstanceENS1_15BindingLanguageEPvN3WTF10PassRefPtrINS0_10RootObjectEEE
191__ZN3KJS8Debugger12sourceUnusedEPNS_9ExecStateEi
192__ZN3KJS8Debugger6attachEPNS_11InterpreterE
193__ZN3KJS8Debugger9exceptionEPNS_9ExecStateEiiPNS_7JSValueE
194__ZN3KJS8DebuggerC2Ev
195__ZN3KJS8DebuggerD2Ev
196__ZN3KJS8JSObject11hasInstanceEPNS_9ExecStateEPNS_7JSValueE
197__ZN3KJS8JSObject14callAsFunctionEPNS_9ExecStateEPS0_RKNS_4ListE
198__ZN3KJS8JSObject14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE
199__ZN3KJS8JSObject14deletePropertyEPNS_9ExecStateEj
200__ZN3KJS8JSObject16getPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayE
201__ZN3KJS8JSObject18getOwnPropertySlotEPNS_9ExecStateEjRNS_12PropertySlotE
202__ZN3KJS8JSObject22fillGetterPropertySlotERNS_12PropertySlotEPPNS_7JSValueE
203__ZN3KJS8JSObject3putEPNS_9ExecStateERKNS_10IdentifierEPNS_7JSValueEi
204__ZN3KJS8JSObject3putEPNS_9ExecStateEjPNS_7JSValueEi
205__ZN3KJS8JSObject4callEPNS_9ExecStateEPS0_RKNS_4ListE
206__ZN3KJS8JSObject4markEv
207__ZN3KJS8JSObject9constructEPNS_9ExecStateERKNS_4ListE
208__ZN3KJS8JSObject9constructEPNS_9ExecStateERKNS_4ListERKNS_10IdentifierERKNS_7UStringEi
209__ZN3KJS8JSObject9putDirectERKNS_10IdentifierEPNS_7JSValueEi
210__ZN3KJS8JSObject9putDirectERKNS_10IdentifierEii
211__ZN3KJS8jsStringEPKc
212__ZN3KJS8jsStringERKNS_7UStringE
213__ZN3KJS13jsOwnedStringERKNS_7UStringE
214__ZN3KJS9Collector15numInterpretersEv
215__ZN3KJS9Collector15recordExtraCostEm
216__ZN3KJS9Collector19numProtectedObjectsEv
217__ZN3KJS9Collector20rootObjectTypeCountsEv
218__ZN3KJS9Collector23collectOnMainThreadOnlyEPNS_7JSValueE
219__ZN3KJS9Collector4sizeEv
220__ZN3KJS9Collector7collectEv
221__ZN3KJS9Collector7protectEPNS_7JSValueE
222__ZN3KJS9Collector9unprotectEPNS_7JSValueE
223__ZN3KJSeqERKNS_7UStringEPKc
224__ZN3WTF10fastCallocEmm
225__ZN3WTF10fastMallocEm
226__ZN3WTF11fastReallocEPvm
227__ZN3WTF8fastFreeEPv
228__ZNK3KJS11Interpreter12builtinArrayEv
229__ZNK3KJS11Interpreter12globalObjectEv
230__ZNK3KJS11Interpreter12saveBuiltinsERNS_13SavedBuiltinsE
231__ZNK3KJS11Interpreter15builtinFunctionEv
232__ZNK3KJS11Interpreter22builtinObjectPrototypeEv
233__ZNK3KJS11Interpreter22builtinStringPrototypeEv
234__ZNK3KJS11Interpreter24builtinFunctionPrototypeEv
235__ZNK3KJS11PropertyMap3getERKNS_10IdentifierE
236__ZNK3KJS11PropertyMap4saveERNS_15SavedPropertiesE
237__ZNK3KJS12DateInstance7getTimeERdRi
238__ZNK3KJS13ArrayInstance7getItemEj
239__ZNK3KJS19InternalFunctionImp14implementsCallEv
240__ZNK3KJS19InternalFunctionImp21implementsHasInstanceEv
241__ZNK3KJS4List2atEi
242__ZNK3KJS4List8copyTailEv
243__ZNK3KJS6JSCell9getNumberERd
244__ZNK3KJS6JSCell9getNumberEv
245__ZNK3KJS6JSCell9getStringERNS_7UStringE
246__ZNK3KJS6JSCell9getStringEv
247__ZNK3KJS6JSCell9getUInt32ERj
248__ZNK3KJS7JSValue7toFloatEPNS_9ExecStateE
249__ZNK3KJS7JSValue7toInt32EPNS_9ExecStateE
250__ZNK3KJS7JSValue7toInt32EPNS_9ExecStateERb
251__ZNK3KJS7JSValue8toUInt32EPNS_9ExecStateE
252__ZNK3KJS7JSValue8toUInt32EPNS_9ExecStateERb
253__ZNK3KJS7JSValue9toIntegerEPNS_9ExecStateE
254__ZNK3KJS7UString10UTF8StringEv
255__ZNK3KJS7UString14toStrictUInt32EPb
256__ZNK3KJS7UString5asciiEv
257__ZNK3KJS7UString6is8BitEv
258__ZNK3KJS7UString8toUInt32EPb
259__ZNK3KJS7UString8toUInt32EPbb
260__ZNK3KJS8Bindings10RootObject11interpreterEv
261__ZNK3KJS8Bindings8Instance10rootObjectEv
262__ZNK3KJS8JSObject11hasPropertyEPNS_9ExecStateERKNS_10IdentifierE
263__ZNK3KJS8JSObject12defaultValueEPNS_9ExecStateENS_6JSTypeE
264__ZNK3KJS8JSObject14implementsCallEv
265__ZNK3KJS8JSObject19implementsConstructEv
266__ZNK3KJS8JSObject21implementsHasInstanceEv
267__ZNK3KJS8JSObject3getEPNS_9ExecStateERKNS_10IdentifierE
268__ZNK3KJS8JSObject3getEPNS_9ExecStateEj
269__ZNK3KJS8JSObject4typeEv
270__ZNK3KJS8JSObject6canPutEPNS_9ExecStateERKNS_10IdentifierE
271__ZNK3KJS8JSObject8toNumberEPNS_9ExecStateE
272__ZNK3KJS8JSObject8toObjectEPNS_9ExecStateE
273__ZNK3KJS8JSObject8toStringEPNS_9ExecStateE
274__ZNK3KJS8JSObject9classInfoEv
275__ZNK3KJS8JSObject9classNameEv
276__ZNK3KJS8JSObject9toBooleanEPNS_9ExecStateE
277__ZNK3KJS9ExecState18lexicalInterpreterEv
278__ZTVN3KJS14StringInstanceE
279__ZTVN3KJS15JSWrapperObjectE
280__ZTVN3KJS19InternalFunctionImpE
281__ZTVN3KJS8JSObjectE
282_kJSClassDefinitionEmpty
283_kjs_pcre_compile
284_kjs_pcre_exec
285_kjs_pcre_free
286_kjs_pcre_free_substring
287_kjs_pcre_get_substring
288_kjs_strtod
Note: See TracBrowser for help on using the repository browser.