Changeset 53371 in webkit for trunk/JavaScriptCore
- Timestamp:
- Jan 16, 2010, 11:18:38 PM (15 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r53354 r53371 1 2010-01-16 Maciej Stachowiak <[email protected]> 2 3 Reviewed by Oliver Hunt. 4 5 Cache JS string values made from DOM strings (Dromaeo speedup) 6 https://bugs.webkit.org/show_bug.cgi?id=33768 7 <rdar://problem/7353576> 8 9 * runtime/JSString.h: 10 (JSC::jsStringWithFinalizer): Added new mechanism for a string to have an optional 11 finalizer callback, for the benefit of weak-referencing caches. 12 (JSC::): 13 (JSC::Fiber::JSString): 14 (JSC::Fiber::~JSString): 15 * runtime/JSString.cpp: 16 (JSC::JSString::resolveRope): Clear fibers so this doesn't look like a string with a finalizer. 17 * runtime/WeakGCMap.h: Include "Collector.h" to make this header includable by itself. 18 1 19 2010-01-15 Sam Weinig <[email protected]> 2 20 -
trunk/JavaScriptCore/runtime/JSString.cpp
r53323 r53371 86 86 m_value = newImpl; 87 87 else { 88 for (unsigned i = 0; i < m_ropeLength; ++i) 88 for (unsigned i = 0; i < m_ropeLength; ++i) { 89 89 m_fibers[i].deref(); 90 m_fibers[i] = static_cast<void*>(0); 91 } 90 92 m_ropeLength = 0; 91 93 ASSERT(!isRope()); … … 121 123 // Create a string from the UChar buffer, clear the rope RefPtr. 122 124 ASSERT(buffer == position); 123 for (unsigned i = 0; i < m_ropeLength; ++i) 125 for (unsigned i = 0; i < m_ropeLength; ++i) { 124 126 m_fibers[i].deref(); 127 m_fibers[i] = static_cast<void*>(0); 128 } 125 129 m_ropeLength = 0; 126 130 -
trunk/JavaScriptCore/runtime/JSString.h
r52956 r53371 60 60 JSString* jsOwnedString(ExecState*, const UString&); 61 61 62 typedef void (*JSStringFinalizerCallback)(JSString*, void* context); 63 JSString* jsStringWithFinalizer(ExecState*, const UString&, JSStringFinalizerCallback callback, void* context); 64 62 65 class JS_EXPORTCLASS JSString : public JSCell { 63 66 public: … … 72 75 class Fiber { 73 76 public: 74 Fiber() {}77 Fiber() : m_value(0) {} 75 78 Fiber(UString::Rep* string) : m_value(reinterpret_cast<intptr_t>(string)) {} 76 79 Fiber(Rope* rope) : m_value(reinterpret_cast<intptr_t>(rope) | 1) {} 80 81 Fiber(void* nonFiber) : m_value(reinterpret_cast<intptr_t>(nonFiber)) {} 77 82 78 83 void deref() … … 110 115 UString::Rep* string() { return reinterpret_cast<UString::Rep*>(m_value); } 111 116 117 void* nonFiber() { return reinterpret_cast<void*>(m_value); } 112 118 private: 113 119 intptr_t m_value; … … 246 252 } 247 253 254 JSString(JSGlobalData* globalData, const UString& value, JSStringFinalizerCallback finalizer, void* context) 255 : JSCell(globalData->stringStructure.get()) 256 , m_stringLength(value.size()) 257 , m_value(value) 258 , m_ropeLength(0) 259 { 260 // nasty hack because we can't union non-POD types 261 m_fibers[0] = reinterpret_cast<void*>(finalizer); 262 m_fibers[1] = context; 263 Heap::heap(this)->reportExtraMemoryCost(value.cost()); 264 } 265 248 266 ~JSString() 249 267 { … … 251 269 for (unsigned i = 0; i < m_ropeLength; ++i) 252 270 m_fibers[i].deref(); 271 272 if (!m_ropeLength && m_fibers[0].nonFiber()) { 273 JSStringFinalizerCallback finalizer = reinterpret_cast<JSStringFinalizerCallback>(m_fibers[0].nonFiber()); 274 finalizer(this, m_fibers[1].nonFiber()); 275 } 253 276 } 254 277 … … 348 371 friend JSValue jsString(ExecState* exec, Register* strings, unsigned count); 349 372 friend JSValue jsString(ExecState* exec, JSValue thisValue, const ArgList& args); 373 friend JSString* jsStringWithFinalizer(ExecState*, const UString&, JSStringFinalizerCallback callback, void* context); 350 374 }; 351 375 … … 420 444 } 421 445 return fixupVPtr(globalData, new (globalData) JSString(globalData, s)); 446 } 447 448 inline JSString* jsStringWithFinalizer(ExecState* exec, const UString& s, JSStringFinalizerCallback callback, void* context) 449 { 450 ASSERT(s.size() && (s.size() > 1 || s.data()[0] > 0xFF)); 451 JSGlobalData* globalData = &exec->globalData(); 452 return fixupVPtr(globalData, new (globalData) JSString(globalData, s, callback, context)); 422 453 } 423 454 -
trunk/JavaScriptCore/runtime/WeakGCMap.h
r52171 r53371 27 27 #define WeakGCMap_h 28 28 29 #include "Collector.h" 29 30 #include <wtf/HashMap.h> 30 31
Note:
See TracChangeset
for help on using the changeset viewer.