Changeset 47267 in webkit
- Timestamp:
- Aug 13, 2009 10:35:33 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 31 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/API/JSCallbackConstructor.h
r43122 r47267 42 42 static PassRefPtr<Structure> createStructure(JSValue proto) 43 43 { 44 return Structure::create(proto, TypeInfo(ObjectType, ImplementsHasInstance | HasStandardGetOwnPropertySlot ));44 return Structure::create(proto, TypeInfo(ObjectType, ImplementsHasInstance | HasStandardGetOwnPropertySlot | HasDefaultMark)); 45 45 } 46 46 -
trunk/JavaScriptCore/API/JSCallbackFunction.h
r43372 r47267 42 42 static PassRefPtr<Structure> createStructure(JSValue proto) 43 43 { 44 return Structure::create(proto, TypeInfo(ObjectType, HasStandardGetOwnPropertySlot ));44 return Structure::create(proto, TypeInfo(ObjectType, HasStandardGetOwnPropertySlot | HasDefaultMark)); 45 45 } 46 46 -
trunk/JavaScriptCore/ChangeLog
r47265 r47267 1 2009-08-13 Oliver Hunt <oliver@apple.com> 2 3 Reviewed by Maciej Stachowiak. 4 5 Devirtualise marking 6 https://bugs.webkit.org/show_bug.cgi?id=28294 7 8 Add a bit to TypeInfo to indicate that an object uses the standard 9 JSObject::markChildren method. This allows us to devirtualise marking 10 of most objects (though a branch is still needed). We also add a branch 11 to identify arrays thus devirtualising marking in that case as well. 12 13 In order to make the best use of this devirtualisation I've also reworked 14 the MarkStack::drain() logic to make the iteration more efficient. 15 16 * API/JSCallbackConstructor.h: 17 (JSC::JSCallbackConstructor::createStructure): 18 * API/JSCallbackFunction.h: 19 (JSC::JSCallbackFunction::createStructure): 20 * JavaScriptCore.exp: 21 * runtime/BooleanObject.h: 22 (JSC::BooleanObject::createStructure): 23 * runtime/FunctionPrototype.h: 24 (JSC::FunctionPrototype::createStructure): 25 * runtime/InternalFunction.h: 26 (JSC::InternalFunction::createStructure): 27 * runtime/JSAPIValueWrapper.h: 28 (JSC::JSAPIValueWrapper::JSAPIValueWrapper): 29 * runtime/JSArray.cpp: 30 (JSC::JSArray::markChildren): 31 * runtime/JSArray.h: 32 (JSC::JSArray::markChildrenDirect): 33 (JSC::MarkStack::drain): 34 * runtime/JSByteArray.cpp: 35 (JSC::JSByteArray::createStructure): 36 * runtime/JSCell.h: 37 (JSC::MarkStack::append): 38 * runtime/JSGlobalData.cpp: 39 (JSC::JSGlobalData::JSGlobalData): 40 * runtime/JSNumberCell.h: 41 (JSC::JSNumberCell::createStructure): 42 * runtime/JSONObject.h: 43 (JSC::JSONObject::createStructure): 44 * runtime/JSObject.cpp: 45 (JSC::JSObject::markChildren): 46 * runtime/JSObject.h: 47 (JSC::JSObject::markChildrenDirect): 48 (JSC::JSObject::createStructure): 49 * runtime/JSString.h: 50 (JSC::JSString::createStructure): 51 * runtime/JSType.h: 52 (JSC::): 53 * runtime/MarkStack.h: 54 (JSC::MarkStack::MarkStack): 55 (JSC::MarkStack::MarkSet::MarkSet): 56 (JSC::MarkStack::MarkStackArray::last): 57 * runtime/MathObject.h: 58 (JSC::MathObject::createStructure): 59 * runtime/NumberConstructor.h: 60 (JSC::NumberConstructor::createStructure): 61 * runtime/NumberObject.h: 62 (JSC::NumberObject::createStructure): 63 * runtime/RegExpConstructor.h: 64 (JSC::RegExpConstructor::createStructure): 65 * runtime/RegExpObject.h: 66 (JSC::RegExpObject::createStructure): 67 * runtime/StringObjectThatMasqueradesAsUndefined.h: 68 (JSC::StringObjectThatMasqueradesAsUndefined::createStructure): 69 * runtime/TypeInfo.h: 70 (JSC::TypeInfo::hasDefaultMark): 71 1 72 2009-08-13 Darin Adler <darin@apple.com> 2 73 -
trunk/JavaScriptCore/JavaScriptCore.exp
r47236 r47267 263 263 __ZN3JSC9MarkStack13allocateStackEm 264 264 __ZN3JSC9MarkStack18initializePagesizeEv 265 __ZN3JSC9MarkStack5drainEv 265 266 __ZN3JSC9Structure17stopIgnoringLeaksEv 266 267 __ZN3JSC9Structure18startIgnoringLeaksEv -
trunk/JavaScriptCore/runtime/BooleanObject.h
r43122 r47267 32 32 virtual const ClassInfo* classInfo() const { return &info; } 33 33 static const ClassInfo info; 34 35 static PassRefPtr<Structure> createStructure(JSValue prototype) 36 { 37 return Structure::create(prototype, TypeInfo(ObjectType, HasStandardGetOwnPropertySlot | HasDefaultMark)); 38 } 34 39 }; 35 40 -
trunk/JavaScriptCore/runtime/FunctionPrototype.h
r43225 r47267 35 35 static PassRefPtr<Structure> createStructure(JSValue proto) 36 36 { 37 return Structure::create(proto, TypeInfo(ObjectType, HasStandardGetOwnPropertySlot ));37 return Structure::create(proto, TypeInfo(ObjectType, HasStandardGetOwnPropertySlot | HasDefaultMark)); 38 38 } 39 39 -
trunk/JavaScriptCore/runtime/InternalFunction.h
r43122 r47267 43 43 static PassRefPtr<Structure> createStructure(JSValue proto) 44 44 { 45 return Structure::create(proto, TypeInfo(ObjectType, ImplementsHasInstance | HasStandardGetOwnPropertySlot ));45 return Structure::create(proto, TypeInfo(ObjectType, ImplementsHasInstance | HasStandardGetOwnPropertySlot | HasDefaultMark)); 46 46 } 47 47 -
trunk/JavaScriptCore/runtime/JSAPIValueWrapper.h
r47022 r47267 55 55 , m_value(value) 56 56 { 57 ASSERT(!value.isCell()); 57 58 } 58 59 -
trunk/JavaScriptCore/runtime/JSArray.cpp
r47239 r47267 603 603 void JSArray::markChildren(MarkStack& markStack) 604 604 { 605 JSObject::markChildren(markStack); 606 607 ArrayStorage* storage = m_storage; 608 609 unsigned usedVectorLength = min(storage->m_length, storage->m_vectorLength); 610 markStack.appendValues(storage->m_vector, usedVectorLength, MayContainNullValues); 611 612 if (SparseArrayValueMap* map = storage->m_sparseValueMap) { 613 SparseArrayValueMap::iterator end = map->end(); 614 for (SparseArrayValueMap::iterator it = map->begin(); it != end; ++it) 615 markStack.append(it->second); 616 } 605 markChildrenDirect(markStack); 617 606 } 618 607 -
trunk/JavaScriptCore/runtime/JSArray.h
r47022 r47267 83 83 return Structure::create(prototype, TypeInfo(ObjectType)); 84 84 } 85 86 inline void markChildrenDirect(MarkStack& markStack); 85 87 86 88 protected: … … 126 128 inline bool isJSArray(JSGlobalData* globalData, JSValue v) { return v.isCell() && v.asCell()->vptr() == globalData->jsArrayVPtr; } 127 129 130 void JSArray::markChildrenDirect(MarkStack& markStack) { 131 JSObject::markChildrenDirect(markStack); 132 133 ArrayStorage* storage = m_storage; 134 135 unsigned usedVectorLength = std::min(storage->m_length, storage->m_vectorLength); 136 markStack.appendValues(storage->m_vector, usedVectorLength, MayContainNullValues); 137 138 if (SparseArrayValueMap* map = storage->m_sparseValueMap) { 139 SparseArrayValueMap::iterator end = map->end(); 140 for (SparseArrayValueMap::iterator it = map->begin(); it != end; ++it) 141 markStack.append(it->second); 142 } 143 } 144 145 inline void MarkStack::drain() 146 { 147 while (!m_markSets.isEmpty() || !m_values.isEmpty()) { 148 while (!m_markSets.isEmpty() && m_values.size() < 50) { 149 ASSERT(!m_markSets.isEmpty()); 150 MarkSet& current = m_markSets.last(); 151 ASSERT(current.m_values); 152 JSValue* end = current.m_end; 153 ASSERT(current.m_values); 154 ASSERT(current.m_values != end); 155 findNextUnmarkedNullValue: 156 ASSERT(current.m_values != end); 157 JSValue v = *current.m_values; 158 current.m_values++; 159 160 if (!v || v.marked()) { 161 if (current.m_values == end) { 162 m_markSets.removeLast(); 163 continue; 164 } 165 goto findNextUnmarkedNullValue; 166 } 167 168 JSCell* currentCell = v.asCell(); 169 currentCell->markCellDirect(); 170 if (currentCell->structure()->typeInfo().type() < CompoundType) { 171 if (current.m_values == end) { 172 m_markSets.removeLast(); 173 continue; 174 } 175 goto findNextUnmarkedNullValue; 176 } 177 178 if (current.m_values == end) 179 m_markSets.removeLast(); 180 181 if (currentCell->structure()->typeInfo().hasDefaultMark()) 182 static_cast<JSObject*>(currentCell)->markChildrenDirect(*this); 183 else if (currentCell->vptr() == m_jsArrayVPtr) 184 static_cast<JSArray*>(currentCell)->markChildrenDirect(*this); 185 else 186 currentCell->markChildren(*this); 187 } 188 while (!m_values.isEmpty()) { 189 JSCell* current = m_values.removeLast(); 190 ASSERT(current->marked()); 191 if (current->structure()->typeInfo().hasDefaultMark()) 192 static_cast<JSObject*>(current)->markChildrenDirect(*this); 193 else if (current->vptr() == m_jsArrayVPtr) 194 static_cast<JSArray*>(current)->markChildrenDirect(*this); 195 else 196 current->markChildren(*this); 197 } 198 } 199 // printf("virtual: %d nonvirtual: %d\n", virtualMark, nonVirtualMark); 200 } 201 128 202 } // namespace JSC 129 203 -
trunk/JavaScriptCore/runtime/JSByteArray.cpp
r43122 r47267 46 46 PassRefPtr<Structure> JSByteArray::createStructure(JSValue prototype) 47 47 { 48 PassRefPtr<Structure> result = Structure::create(prototype, TypeInfo(ObjectType ));48 PassRefPtr<Structure> result = Structure::create(prototype, TypeInfo(ObjectType, HasDefaultMark)); 49 49 return result; 50 50 } -
trunk/JavaScriptCore/runtime/JSCell.h
r47022 r47267 380 380 m_values.append(cell); 381 381 } 382 383 inline void MarkStack::drain() {384 while (!m_markSets.isEmpty() || !m_values.isEmpty()) {385 while ((!m_markSets.isEmpty()) && m_values.size() < 50) {386 const MarkSet& current = m_markSets.removeLast();387 JSValue* ptr = current.m_values;388 JSValue* end = current.m_end;389 if (current.m_properties == NoNullValues) {390 while (ptr != end)391 append(*ptr++);392 } else {393 while (ptr != end) {394 if (JSValue value = *ptr++)395 append(value);396 }397 }398 }399 while (!m_values.isEmpty()) {400 JSCell* current = m_values.removeLast();401 ASSERT(current->marked());402 current->markChildren(*this);403 }404 }405 }406 382 } // namespace JSC 407 383 -
trunk/JavaScriptCore/runtime/JSGlobalData.cpp
r47022 r47267 147 147 , scopeNodeBeingReparsed(0) 148 148 , firstStringifierToMark(0) 149 , markStack(vptrSet.jsArrayVPtr) 149 150 { 150 151 #if PLATFORM(MAC) -
trunk/JavaScriptCore/runtime/JSNumberCell.h
r46598 r47267 85 85 } 86 86 87 static PassRefPtr<Structure> createStructure(JSValue proto) { return Structure::create(proto, TypeInfo(NumberType, NeedsThisConversion )); }87 static PassRefPtr<Structure> createStructure(JSValue proto) { return Structure::create(proto, TypeInfo(NumberType, NeedsThisConversion | HasDefaultMark)); } 88 88 89 89 private: -
trunk/JavaScriptCore/runtime/JSONObject.h
r47022 r47267 42 42 static PassRefPtr<Structure> createStructure(JSValue prototype) 43 43 { 44 return Structure::create(prototype, TypeInfo(ObjectType ));44 return Structure::create(prototype, TypeInfo(ObjectType, HasDefaultMark)); 45 45 } 46 46 -
trunk/JavaScriptCore/runtime/JSObject.cpp
r47022 r47267 38 38 #include <wtf/Assertions.h> 39 39 40 #define JSOBJECT_MARK_TRACING 041 42 #if JSOBJECT_MARK_TRACING43 44 #define JSOBJECT_MARK_BEGIN() \45 static int markStackDepth = 0; \46 for (int i = 0; i < markStackDepth; i++) \47 putchar('-'); \48 printf("%s (%p)\n", className().UTF8String().c_str(), this); \49 markStackDepth++; \50 51 #define JSOBJECT_MARK_END() \52 markStackDepth--;53 54 #else // JSOBJECT_MARK_TRACING55 56 #define JSOBJECT_MARK_BEGIN()57 #define JSOBJECT_MARK_END()58 59 #endif // JSOBJECT_MARK_TRACING60 40 61 41 namespace JSC { … … 65 45 void JSObject::markChildren(MarkStack& markStack) 66 46 { 67 JSOBJECT_MARK_BEGIN(); 68 69 JSCell::markChildren(markStack); 70 m_structure->markAggregate(markStack); 71 72 PropertyStorage storage = propertyStorage(); 73 size_t storageSize = m_structure->propertyStorageSize(); 74 markStack.appendValues(reinterpret_cast<JSValue*>(storage), storageSize); 75 76 JSOBJECT_MARK_END(); 47 markChildrenDirect(markStack); 77 48 } 78 49 -
trunk/JavaScriptCore/runtime/JSObject.h
r47022 r47267 28 28 #include "CommonIdentifiers.h" 29 29 #include "CallFrame.h" 30 #include "JSCell.h" 30 31 #include "JSNumberCell.h" 32 #include "MarkStack.h" 31 33 #include "PropertySlot.h" 32 34 #include "PutPropertySlot.h" … … 75 77 76 78 virtual void markChildren(MarkStack&); 79 ALWAYS_INLINE void markChildrenDirect(MarkStack& markStack); 77 80 78 81 // The inline virtual destructor cannot be the first virtual function declared … … 202 205 static PassRefPtr<Structure> createStructure(JSValue prototype) 203 206 { 204 return Structure::create(prototype, TypeInfo(ObjectType, HasStandardGetOwnPropertySlot ));207 return Structure::create(prototype, TypeInfo(ObjectType, HasStandardGetOwnPropertySlot | HasDefaultMark)); 205 208 } 206 209 … … 628 631 } 629 632 633 ALWAYS_INLINE void JSObject::markChildrenDirect(MarkStack& markStack) 634 { 635 JSCell::markChildren(markStack); 636 m_structure->markAggregate(markStack); 637 638 PropertyStorage storage = propertyStorage(); 639 size_t storageSize = m_structure->propertyStorageSize(); 640 markStack.appendValues(reinterpret_cast<JSValue*>(storage), storageSize); 641 } 642 630 643 } // namespace JSC 631 644 -
trunk/JavaScriptCore/runtime/JSString.h
r46598 r47267 91 91 JSString* getIndex(JSGlobalData*, unsigned); 92 92 93 static PassRefPtr<Structure> createStructure(JSValue proto) { return Structure::create(proto, TypeInfo(StringType, NeedsThisConversion )); }93 static PassRefPtr<Structure> createStructure(JSValue proto) { return Structure::create(proto, TypeInfo(StringType, NeedsThisConversion | HasDefaultMark)); } 94 94 95 95 private: -
trunk/JavaScriptCore/runtime/JSType.h
r47022 r47267 34 34 NullType = 4, 35 35 StringType = 5, 36 37 36 // The CompoundType value must come before any JSType that may have children 38 37 CompoundType = 6, -
trunk/JavaScriptCore/runtime/MarkStack.h
r47159 r47267 32 32 33 33 namespace JSC { 34 class JSGlobalData; 34 35 class Register; 35 36 … … 38 39 class MarkStack : Noncopyable { 39 40 public: 40 MarkStack() 41 : m_markSets() 42 , m_values() 41 MarkStack(void* jsArrayVPtr) 42 : m_jsArrayVPtr(jsArrayVPtr) 43 43 { 44 44 } … … 83 83 , m_properties(properties) 84 84 { 85 ASSERT(values); 85 86 } 86 87 JSValue* m_values; … … 137 138 return m_data[--m_top]; 138 139 } 140 141 inline T& last() 142 { 143 ASSERT(m_top); 144 return m_data[m_top - 1]; 145 } 139 146 140 147 inline bool isEmpty() … … 170 177 }; 171 178 179 void* m_jsArrayVPtr; 172 180 MarkStackArray<MarkSet> m_markSets; 173 181 MarkStackArray<JSCell*> m_values; -
trunk/JavaScriptCore/runtime/MathObject.h
r43122 r47267 37 37 static PassRefPtr<Structure> createStructure(JSValue prototype) 38 38 { 39 return Structure::create(prototype, TypeInfo(ObjectType ));39 return Structure::create(prototype, TypeInfo(ObjectType, HasDefaultMark)); 40 40 } 41 41 }; -
trunk/JavaScriptCore/runtime/NumberConstructor.h
r43122 r47267 39 39 static PassRefPtr<Structure> createStructure(JSValue proto) 40 40 { 41 return Structure::create(proto, TypeInfo(ObjectType, ImplementsHasInstance ));41 return Structure::create(proto, TypeInfo(ObjectType, ImplementsHasInstance | HasDefaultMark)); 42 42 } 43 43 -
trunk/JavaScriptCore/runtime/NumberObject.h
r43122 r47267 31 31 32 32 static const ClassInfo info; 33 34 static PassRefPtr<Structure> createStructure(JSValue prototype) 35 { 36 return Structure::create(prototype, TypeInfo(ObjectType, HasStandardGetOwnPropertySlot | HasDefaultMark)); 37 } 33 38 34 39 private: -
trunk/JavaScriptCore/runtime/RegExpConstructor.h
r44224 r47267 37 37 static PassRefPtr<Structure> createStructure(JSValue prototype) 38 38 { 39 return Structure::create(prototype, TypeInfo(ObjectType, ImplementsHasInstance ));39 return Structure::create(prototype, TypeInfo(ObjectType, ImplementsHasInstance | HasDefaultMark)); 40 40 } 41 41 -
trunk/JavaScriptCore/runtime/RegExpObject.h
r46907 r47267 49 49 static PassRefPtr<Structure> createStructure(JSValue prototype) 50 50 { 51 return Structure::create(prototype, TypeInfo(ObjectType ));51 return Structure::create(prototype, TypeInfo(ObjectType, HasDefaultMark)); 52 52 } 53 53 -
trunk/JavaScriptCore/runtime/StringObjectThatMasqueradesAsUndefined.h
r43122 r47267 45 45 static PassRefPtr<Structure> createStructure(JSValue proto) 46 46 { 47 return Structure::create(proto, TypeInfo(ObjectType, MasqueradesAsUndefined ));47 return Structure::create(proto, TypeInfo(ObjectType, MasqueradesAsUndefined | HasDefaultMark)); 48 48 } 49 49 -
trunk/JavaScriptCore/runtime/TypeInfo.h
r44224 r47267 39 39 static const unsigned NeedsThisConversion = 1 << 4; 40 40 static const unsigned HasStandardGetOwnPropertySlot = 1 << 5; 41 static const unsigned HasDefaultMark = 1 << 6; 41 42 42 43 class TypeInfo { … … 60 61 bool needsThisConversion() const { return m_flags & NeedsThisConversion; } 61 62 bool hasStandardGetOwnPropertySlot() const { return m_flags & HasStandardGetOwnPropertySlot; } 62 63 bool hasDefaultMark() const { return m_flags & HasDefaultMark; } 63 64 unsigned flags() const { return m_flags; } 64 65 -
trunk/JavaScriptGlue/ChangeLog
r47022 r47267 1 2009-08-13 Oliver Hunt <oliver@apple.com> 2 3 Reviewed by Maciej Stachowiak. 4 5 Devirtualise marking 6 https://bugs.webkit.org/show_bug.cgi?id=28294 7 8 Continue to jump through hoops to deal with the exposed marking routines 9 in JavaScriptGlue. 10 11 * JSValueWrapper.cpp: 12 (JSValueWrapper::JSObjectMark): 13 1 14 2009-08-07 Oliver Hunt <oliver@apple.com> 2 15 -
trunk/JavaScriptGlue/JSValueWrapper.cpp
r47022 r47267 30 30 #include "JSValueWrapper.h" 31 31 #include "JSRun.h" 32 #include <JavaScriptCore/JSArray.h> 32 33 #include <JavaScriptCore/PropertyNameArray.h> 33 34 #include <pthread.h> … … 198 199 { 199 200 // This results in recursive marking but will be otherwise safe and correct. 200 MarkStack markStack; 201 // We claim the array vptr is 0 because we don't have access to it here, and 202 // claiming 0 is functionally harmless -- it merely means that we can't 203 // devirtualise marking of arrays when recursing from this point. 204 MarkStack markStack(0); 201 205 markStack.append(ptr->fValue.get()); 202 206 markStack.drain(); -
trunk/WebCore/ChangeLog
r47266 r47267 1 2009-08-13 Oliver Hunt <oliver@apple.com> 2 3 Reviewed by Maciej Stachowiak. 4 5 Devirtualise marking 6 https://bugs.webkit.org/show_bug.cgi?id=28294 7 8 Make sure we override the JSObject createStructure method on those 9 objects that have custom marking routines. 10 11 * bindings/scripts/CodeGeneratorJS.pm: 12 1 13 2009-08-13 Darin Adler <darin@apple.com> 2 14 -
trunk/WebCore/bindings/scripts/CodeGeneratorJS.pm
r47022 r47267 665 665 push(@headerContent, " bool getOwnPropertySlotDelegate(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&);\n") if $dataNode->extendedAttributes->{"DelegatingPrototypeGetOwnPropertySlot"}; 666 666 667 push(@headerContent, 668 " static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype)\n" . 669 " {\n" . 670 " return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType" . ($dataNode->extendedAttributes->{"CustomMarkFunction"} ? "" : ", JSC::HasDefaultMark") . "));\n" . 671 " }\n"); 672 } elsif ($dataNode->extendedAttributes->{"CustomMarkFunction"}) { 667 673 push(@headerContent, 668 674 " static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype)\n" .
Note: See TracChangeset
for help on using the changeset viewer.