Changeset 37215 in webkit for trunk/JavaScriptCore
- Timestamp:
- Oct 2, 2008, 4:48:47 PM (17 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/API/JSBase.cpp
r37184 r37215 44 44 { 45 45 ExecState* exec = toJS(ctx); 46 exec->globalData().heap ->registerThread();46 exec->globalData().heap.registerThread(); 47 47 JSLock lock(exec); 48 48 … … 70 70 { 71 71 ExecState* exec = toJS(ctx); 72 exec->globalData().heap ->registerThread();72 exec->globalData().heap.registerThread(); 73 73 JSLock lock(exec); 74 74 … … 96 96 ExecState* exec = toJS(ctx); 97 97 JSGlobalData& globalData = exec->globalData(); 98 Heap* heap = globalData.heap;99 98 100 99 JSLock lock(globalData.isSharedInstance); 101 100 102 if (! heap->isBusy())103 heap->collect();101 if (!globalData.heap.isBusy()) 102 globalData.heap.collect(); 104 103 105 104 // FIXME: Perhaps we should trigger a second mark and sweep … … 111 110 { 112 111 ExecState* exec = toJS(ctx); 113 exec->globalData().heap ->registerThread();112 exec->globalData().heap.registerThread(); 114 113 JSLock lock(exec); 115 114 116 exec->globalData().heap ->reportExtraMemoryCost(size);115 exec->globalData().heap.reportExtraMemoryCost(size); 117 116 } -
trunk/JavaScriptCore/API/JSContextRef.cpp
r36263 r37215 88 88 JSGlobalData& globalData = exec->globalData(); 89 89 90 globalData.heap ->registerThread();90 globalData.heap.registerThread(); 91 91 92 92 gcProtect(exec->dynamicGlobalObject()); … … 105 105 if (globalData.refCount() == 2) { // One reference is held by JSGlobalObject, another added by JSGlobalContextRetain(). 106 106 // The last reference was released, this is our last chance to collect. 107 Heap* heap = globalData.heap; 108 109 ASSERT(!heap->protectedObjectCount()); 110 ASSERT(!heap->isBusy()); 111 112 delete heap; 113 globalData.heap = 0; 107 ASSERT(!globalData.heap.protectedObjectCount()); 108 ASSERT(!globalData.heap.isBusy()); 109 globalData.heap.destroy(); 114 110 } else 115 globalData.heap ->collect();111 globalData.heap.collect(); 116 112 117 113 globalData.deref(); … … 121 117 { 122 118 ExecState* exec = toJS(ctx); 123 exec->globalData().heap ->registerThread();119 exec->globalData().heap.registerThread(); 124 120 JSLock lock(exec); 125 121 -
trunk/JavaScriptCore/API/JSObjectRef.cpp
r37175 r37215 74 74 { 75 75 ExecState* exec = toJS(ctx); 76 exec->globalData().heap ->registerThread();76 exec->globalData().heap.registerThread(); 77 77 JSLock lock(exec); 78 78 … … 90 90 { 91 91 ExecState* exec = toJS(ctx); 92 exec->globalData().heap ->registerThread();92 exec->globalData().heap.registerThread(); 93 93 JSLock lock(exec); 94 94 … … 101 101 { 102 102 ExecState* exec = toJS(ctx); 103 exec->globalData().heap ->registerThread();103 exec->globalData().heap.registerThread(); 104 104 JSLock lock(exec); 105 105 … … 116 116 { 117 117 ExecState* exec = toJS(ctx); 118 exec->globalData().heap ->registerThread();118 exec->globalData().heap.registerThread(); 119 119 JSLock lock(exec); 120 120 … … 139 139 { 140 140 ExecState* exec = toJS(ctx); 141 exec->globalData().heap ->registerThread();141 exec->globalData().heap.registerThread(); 142 142 JSLock lock(exec); 143 143 … … 165 165 { 166 166 ExecState* exec = toJS(ctx); 167 exec->globalData().heap ->registerThread();167 exec->globalData().heap.registerThread(); 168 168 JSLock lock(exec); 169 169 … … 186 186 { 187 187 ExecState* exec = toJS(ctx); 188 exec->globalData().heap ->registerThread();188 exec->globalData().heap.registerThread(); 189 189 JSLock lock(exec); 190 190 … … 207 207 { 208 208 ExecState* exec = toJS(ctx); 209 exec->globalData().heap ->registerThread();209 exec->globalData().heap.registerThread(); 210 210 JSLock lock(exec); 211 211 … … 242 242 { 243 243 ExecState* exec = toJS(ctx); 244 exec->globalData().heap ->registerThread();244 exec->globalData().heap.registerThread(); 245 245 JSLock lock(exec); 246 246 … … 253 253 { 254 254 ExecState* exec = toJS(ctx); 255 exec->globalData().heap ->registerThread();255 exec->globalData().heap.registerThread(); 256 256 JSLock lock(exec); 257 257 … … 270 270 { 271 271 ExecState* exec = toJS(ctx); 272 exec->globalData().heap ->registerThread();272 exec->globalData().heap.registerThread(); 273 273 JSLock lock(exec); 274 274 … … 294 294 { 295 295 ExecState* exec = toJS(ctx); 296 exec->globalData().heap ->registerThread();296 exec->globalData().heap.registerThread(); 297 297 JSLock lock(exec); 298 298 … … 312 312 { 313 313 ExecState* exec = toJS(ctx); 314 exec->globalData().heap ->registerThread();314 exec->globalData().heap.registerThread(); 315 315 JSLock lock(exec); 316 316 … … 329 329 { 330 330 ExecState* exec = toJS(ctx); 331 exec->globalData().heap ->registerThread();331 exec->globalData().heap.registerThread(); 332 332 JSLock lock(exec); 333 333 … … 379 379 { 380 380 ExecState* exec = toJS(ctx); 381 exec->globalData().heap ->registerThread();381 exec->globalData().heap.registerThread(); 382 382 JSLock lock(exec); 383 383 … … 417 417 { 418 418 ExecState* exec = toJS(ctx); 419 exec->globalData().heap ->registerThread();419 exec->globalData().heap.registerThread(); 420 420 JSLock lock(exec); 421 421 … … 456 456 JSObject* jsObject = toJS(object); 457 457 ExecState* exec = toJS(ctx); 458 exec->globalData().heap ->registerThread();458 exec->globalData().heap.registerThread(); 459 459 JSLock lock(exec); 460 460 … … 501 501 PropertyNameArray* propertyNames = toJS(array); 502 502 503 propertyNames->globalData()->heap ->registerThread();503 propertyNames->globalData()->heap.registerThread(); 504 504 JSLock lock(propertyNames->globalData()->isSharedInstance); 505 505 -
trunk/JavaScriptCore/API/JSValueRef.cpp
r36766 r37215 113 113 { 114 114 ExecState* exec = toJS(ctx); 115 exec->globalData().heap ->registerThread();115 exec->globalData().heap.registerThread(); 116 116 JSLock lock(exec); 117 117 … … 140 140 { 141 141 ExecState* exec = toJS(ctx); 142 exec->globalData().heap ->registerThread();142 exec->globalData().heap.registerThread(); 143 143 JSLock lock(exec); 144 144 … … 174 174 { 175 175 ExecState* exec = toJS(ctx); 176 exec->globalData().heap ->registerThread();176 exec->globalData().heap.registerThread(); 177 177 JSLock lock(exec); 178 178 … … 183 183 { 184 184 ExecState* exec = toJS(ctx); 185 exec->globalData().heap ->registerThread();185 exec->globalData().heap.registerThread(); 186 186 JSLock lock(exec); 187 187 … … 199 199 { 200 200 ExecState* exec = toJS(ctx); 201 exec->globalData().heap ->registerThread();201 exec->globalData().heap.registerThread(); 202 202 JSLock lock(exec); 203 203 … … 217 217 { 218 218 ExecState* exec = toJS(ctx); 219 exec->globalData().heap ->registerThread();219 exec->globalData().heap.registerThread(); 220 220 JSLock lock(exec); 221 221 … … 235 235 { 236 236 ExecState* exec = toJS(ctx); 237 exec->globalData().heap ->registerThread();237 exec->globalData().heap.registerThread(); 238 238 JSLock lock(exec); 239 239 … … 253 253 { 254 254 ExecState* exec = toJS(ctx); 255 exec->globalData().heap ->registerThread();255 exec->globalData().heap.registerThread(); 256 256 JSLock lock(exec); 257 257 … … 263 263 { 264 264 ExecState* exec = toJS(ctx); 265 exec->globalData().heap ->registerThread();265 exec->globalData().heap.registerThread(); 266 266 JSLock lock(exec); 267 267 -
trunk/JavaScriptCore/ChangeLog
r37213 r37215 1 2008-10-02 Darin Adler <[email protected]> 2 3 Reviewed by Geoff Garen. 4 5 - https://bugs.webkit.org/show_bug.cgi?id=21321 6 Bug 21321: speed up JavaScriptCore by inlining Heap in JSGlobalData 7 8 1.019x as fast on SunSpider. 9 10 * API/JSBase.cpp: 11 (JSEvaluateScript): Use heap. instead of heap-> to work with the heap. 12 (JSCheckScriptSyntax): Ditto. 13 (JSGarbageCollect): Ditto. 14 (JSReportExtraMemoryCost): Ditto. 15 * API/JSContextRef.cpp: 16 (JSGlobalContextRetain): Ditto. 17 (JSGlobalContextRelease): Destroy the heap with the destroy function instead 18 of the delete operator. 19 (JSContextGetGlobalObject): Use heap. instead of heap-> to work with the heap. 20 * API/JSObjectRef.cpp: 21 (JSObjectMake): Use heap. instead of heap-> to work with the heap. 22 (JSObjectMakeFunctionWithCallback): Ditto. 23 (JSObjectMakeConstructor): Ditto. 24 (JSObjectMakeFunction): Ditto. 25 (JSObjectMakeArray): Ditto. 26 (JSObjectMakeDate): Ditto. 27 (JSObjectMakeError): Ditto. 28 (JSObjectMakeRegExp): Ditto. 29 (JSObjectHasProperty): Ditto. 30 (JSObjectGetProperty): Ditto. 31 (JSObjectSetProperty): Ditto. 32 (JSObjectGetPropertyAtIndex): Ditto. 33 (JSObjectSetPropertyAtIndex): Ditto. 34 (JSObjectDeleteProperty): Ditto. 35 (JSObjectCallAsFunction): Ditto. 36 (JSObjectCallAsConstructor): Ditto. 37 (JSObjectCopyPropertyNames): Ditto. 38 (JSPropertyNameAccumulatorAddName): Ditto. 39 * API/JSValueRef.cpp: 40 (JSValueIsEqual): Ditto. 41 (JSValueIsInstanceOfConstructor): Ditto. 42 (JSValueMakeNumber): Ditto. 43 (JSValueMakeString): Ditto. 44 (JSValueToNumber): Ditto. 45 (JSValueToStringCopy): Ditto. 46 (JSValueToObject): Ditto. 47 (JSValueProtect): Ditto. 48 (JSValueUnprotect): Ditto. 49 50 * kjs/ExecState.h: 51 (JSC::ExecState::heap): Update to use the & operator. 52 53 * kjs/JSGlobalData.cpp: 54 (JSC::JSGlobalData::JSGlobalData): Update to initialize a heap member 55 instead of calling new to make a heap. 56 (JSC::JSGlobalData::~JSGlobalData): Destroy the heap with the destroy 57 function instead of the delete operator. 58 * kjs/JSGlobalData.h: Change from Heap* to a Heap. 59 * kjs/JSGlobalObject.cpp: 60 (JSC::JSGlobalObject::mark): Use the & operator here. 61 (JSC::JSGlobalObject::operator new): Use heap. instead of heap-> to work 62 with the heap. 63 1 64 2008-10-02 Cameron Zwarich <[email protected]> 2 65 -
trunk/JavaScriptCore/kjs/ExecState.h
r37125 r37215 83 83 static const HashTable* stringTable(ExecState* exec) { return exec->m_globalData->stringTable; } 84 84 85 Heap* heap() const { return m_globalData->heap; }85 Heap* heap() const { return &m_globalData->heap; } 86 86 87 87 private: -
trunk/JavaScriptCore/kjs/JSGlobalData.cpp
r37190 r37215 59 59 JSGlobalData::JSGlobalData(bool isShared) 60 60 : machine(new Machine) 61 , heap(new Heap(this))62 61 #if ENABLE(JSC_MULTIPLE_THREADS) 63 62 , arrayTable(new HashTable(JSC::arrayTable)) … … 90 89 , isSharedInstance(isShared) 91 90 , clientData(0) 91 , heap(this) 92 92 { 93 93 } … … 95 95 JSGlobalData::~JSGlobalData() 96 96 { 97 delete heap;97 heap.destroy(); 98 98 delete machine; 99 99 #ifndef NDEBUG 100 100 // Zeroing out to make the behavior more predictable when someone attempts to use a deleted instance. 101 heap = 0;102 101 machine = 0; 103 102 #endif -
trunk/JavaScriptCore/kjs/JSGlobalData.h
r37190 r37215 31 31 32 32 #include <wtf/Forward.h> 33 #include <wtf/HashCountedSet.h>34 33 #include <wtf/HashMap.h> 35 #include <wtf/HashSet.h>36 34 #include <wtf/RefCounted.h> 35 #include "collector.h" 37 36 #include "SmallStrings.h" 38 37 … … 65 64 66 65 Machine* machine; 67 Heap* heap;68 66 69 67 const HashTable* arrayTable; … … 105 103 HashSet<JSObject*> arrayVisitedElements; 106 104 105 Heap heap; 106 107 107 private: 108 108 JSGlobalData(bool isShared = false); -
trunk/JavaScriptCore/kjs/JSGlobalObject.cpp
r37213 r37215 360 360 RegisterFile& registerFile = globalData()->machine->registerFile(); 361 361 if (registerFile.globalObject() == this) 362 registerFile.markGlobals( globalData()->heap);362 registerFile.markGlobals(&globalData()->heap); 363 363 364 364 markIfNeeded(d()->globalExec->exception()); … … 449 449 { 450 450 #ifdef JAVASCRIPTCORE_BUILDING_ALL_IN_ONE_FILE 451 return globalData->heap ->inlineAllocate(size);451 return globalData->heap.inlineAllocate(size); 452 452 #else 453 return globalData->heap ->allocate(size);453 return globalData->heap.allocate(size); 454 454 #endif 455 455 } -
trunk/JavaScriptCore/kjs/collector.cpp
r36263 r37215 124 124 , m_globalData(globalData) 125 125 { 126 ASSERT(globalData); 127 126 128 #if ENABLE(JSC_MULTIPLE_THREADS) 127 129 int error = pthread_key_create(&m_currentThreadRegistrar, unregisterThread); … … 136 138 Heap::~Heap() 137 139 { 140 // The destroy function must already have been called, so assert this. 141 ASSERT(!m_globalData); 142 } 143 144 void Heap::destroy() 145 { 138 146 JSLock lock(false); 139 147 140 // The global object is not GC protected at this point, so sweeping may delete it (and thus the global data) 141 // before other objects that may use the global data. 148 if (!m_globalData) 149 return; 150 151 // The global object is not GC protected at this point, so sweeping may delete it 152 // (and thus the global data) before other objects that may use the global data. 142 153 RefPtr<JSGlobalData> protect(m_globalData); 143 154 … … 167 178 } 168 179 #endif 180 181 m_globalData = 0; 169 182 } 170 183 -
trunk/JavaScriptCore/kjs/collector.h
r36263 r37215 64 64 class Thread; 65 65 enum HeapType { PrimaryHeap, NumberHeap }; 66 67 void destroy(); 66 68 67 69 #ifdef JAVASCRIPTCORE_BUILDING_ALL_IN_ONE_FILE … … 79 81 bool isBusy(); // true if an allocation or collection is in progress 80 82 81 ~Heap();82 83 83 static const size_t minExtraCostSize = 256; 84 84 … … 119 119 friend class JSGlobalData; 120 120 Heap(JSGlobalData*); 121 ~Heap(); 121 122 122 123 void recordExtraCost(size_t);
Note:
See TracChangeset
for help on using the changeset viewer.