Changeset 10168 in webkit for trunk/JavaScriptCore
- Timestamp:
- Aug 12, 2005, 4:20:48 PM (20 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r10154 r10168 1 2005-08-12 Maciej Stachowiak <[email protected]> 2 3 Reviewed by John. 4 5 - two simple speed improvements for a 3% speed gain 6 7 * JavaScriptCore.xcodeproj/project.pbxproj: turn on -fstrict-aliasing 8 9 * kjs/scope_chain.h: 10 (KJS::ScopeChainIterator::ScopeChainIterator): Add a scope chain iterator 11 so you can walk a scope chain without having to make a copy that you then mutate. 12 (KJS::ScopeChainIterator::operator*): standard iterator operation 13 (KJS::ScopeChainIterator::operator->): ditto 14 (KJS::ScopeChainIterator::operator++): ditto 15 (KJS::ScopeChainIterator::operator==): ditto 16 (KJS::ScopeChainIterator::operator!=): ditto 17 (KJS::ScopeChain::begin): Iterator for the top of the scope chain 18 (KJS::ScopeChain::end): Iterator for one past the bottom (i.e. null) 19 * kjs/nodes.cpp: 20 (ResolveNode::evaluate): Use scope chain iterator instead of copying 21 a scope chain and then modifying the copy 22 (ResolveNode::evaluateReference): ditto 23 (FunctionCallResolveNode::evaluate): ditto 24 (AssignResolveNode::evaluate): ditto 25 1 26 2005-08-12 Maciej Stachowiak <[email protected]> 2 27 -
trunk/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r10084 r10168 1727 1727 HAVE_CONFIG_H, 1728 1728 ); 1729 GCC_STRICT_ALIASING = YES; 1729 1730 GCC_TREAT_WARNINGS_AS_ERRORS = YES; 1730 1731 GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; … … 1734 1735 INSTALL_PATH = /System/Library/Frameworks/WebKit.framework/Versions/A/Frameworks; 1735 1736 MACOSX_DEPLOYMENT_TARGET = 10.3; 1737 OTHER_CFLAGS = ""; 1736 1738 OTHER_LDFLAGS = ( 1737 1739 "$(STYLE_LDFLAGS)", … … 1778 1780 HAVE_CONFIG_H, 1779 1781 ); 1782 GCC_STRICT_ALIASING = YES; 1780 1783 GCC_TREAT_WARNINGS_AS_ERRORS = YES; 1781 1784 GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; … … 1785 1788 INSTALL_PATH = /System/Library/Frameworks/WebKit.framework/Versions/A/Frameworks; 1786 1789 MACOSX_DEPLOYMENT_TARGET = 10.3; 1790 OTHER_CFLAGS = ""; 1787 1791 OTHER_LDFLAGS = ( 1788 1792 "$(STYLE_LDFLAGS)", … … 1829 1833 HAVE_CONFIG_H, 1830 1834 ); 1835 GCC_STRICT_ALIASING = YES; 1831 1836 GCC_TREAT_WARNINGS_AS_ERRORS = YES; 1832 1837 GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; … … 1836 1841 INSTALL_PATH = /System/Library/Frameworks/WebKit.framework/Versions/A/Frameworks; 1837 1842 MACOSX_DEPLOYMENT_TARGET = 10.3; 1843 OTHER_CFLAGS = ""; 1838 1844 OTHER_LDFLAGS = ( 1839 1845 "$(STYLE_LDFLAGS)", … … 1880 1886 HAVE_CONFIG_H, 1881 1887 ); 1888 GCC_STRICT_ALIASING = YES; 1882 1889 GCC_TREAT_WARNINGS_AS_ERRORS = YES; 1883 1890 GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; … … 1886 1893 INFOPLIST_FILE = Info.plist; 1887 1894 INSTALL_PATH = /System/Library/Frameworks/WebKit.framework/Versions/A/Frameworks; 1895 OTHER_CFLAGS = ""; 1888 1896 OTHER_LDFLAGS = ( 1889 1897 "$(STYLE_LDFLAGS)", … … 2277 2285 isa = XCBuildConfiguration; 2278 2286 buildSettings = { 2287 GCC_ENABLE_OBJC_GC = YES; 2288 GCC_FAST_OBJC_DISPATCH = YES; 2289 GCC_STRICT_ALIASING = YES; 2279 2290 GCC_THREADSAFE_STATICS = NO; 2280 2291 }; … … 2284 2295 isa = XCBuildConfiguration; 2285 2296 buildSettings = { 2297 GCC_ENABLE_OBJC_GC = YES; 2298 GCC_FAST_OBJC_DISPATCH = YES; 2299 GCC_OPTIMIZATION_LEVEL = s; 2300 GCC_STRICT_ALIASING = YES; 2286 2301 GCC_THREADSAFE_STATICS = NO; 2287 2302 }; … … 2291 2306 isa = XCBuildConfiguration; 2292 2307 buildSettings = { 2308 GCC_ENABLE_OBJC_GC = YES; 2309 GCC_FAST_OBJC_DISPATCH = YES; 2310 GCC_STRICT_ALIASING = YES; 2293 2311 GCC_THREADSAFE_STATICS = NO; 2294 2312 }; … … 2298 2316 isa = XCBuildConfiguration; 2299 2317 buildSettings = { 2318 GCC_ENABLE_OBJC_GC = YES; 2319 GCC_FAST_OBJC_DISPATCH = YES; 2320 GCC_STRICT_ALIASING = YES; 2300 2321 GCC_THREADSAFE_STATICS = NO; 2301 2322 }; -
trunk/JavaScriptCore/kjs/nodes.cpp
r10148 r10168 334 334 ValueImp *ResolveNode::evaluate(ExecState *exec) 335 335 { 336 ScopeChain chain = exec->context().imp()->scopeChain(); 337 338 assert(!chain.isEmpty()); 336 const ScopeChain& chain = exec->context().imp()->scopeChain(); 337 ScopeChainIterator iter = chain.begin(); 338 ScopeChainIterator end = chain.end(); 339 340 // we must always have something in the scope chain 341 assert(iter != end); 339 342 340 343 PropertySlot slot; 341 344 do { 342 ObjectImp *o = chain.top();345 ObjectImp *o = *iter; 343 346 344 347 if (o->getPropertySlot(exec, ident, slot)) 345 348 return slot.getValue(exec, ident); 346 349 347 chain.pop();348 } while ( !chain.isEmpty());350 ++iter; 351 } while (iter != end); 349 352 350 353 return undefinedVariableError(exec, ident); … … 353 356 Reference ResolveNode::evaluateReference(ExecState *exec) 354 357 { 355 ScopeChain chain = exec->context().imp()->scopeChain(); 356 357 assert(!chain.isEmpty()); 358 const ScopeChain& chain = exec->context().imp()->scopeChain(); 359 ScopeChainIterator iter = chain.begin(); 360 ScopeChainIterator end = chain.end(); 361 362 // we must always have something in the scope chain 363 assert(iter != end); 358 364 359 365 PropertySlot slot; 360 366 do { 361 ObjectImp *o = chain.top();367 ObjectImp *o = *iter; 362 368 if (o->getPropertySlot(exec, ident, slot)) 363 369 return Reference(o, ident); 364 370 365 chain.pop();366 } while ( !chain.isEmpty());371 ++iter; 372 } while (iter != end); 367 373 368 374 return Reference(ident); … … 818 824 ValueImp *FunctionCallResolveNode::evaluate(ExecState *exec) 819 825 { 820 ScopeChain chain = exec->context().imp()->scopeChain(); 821 822 assert(!chain.isEmpty()); 826 const ScopeChain& chain = exec->context().imp()->scopeChain(); 827 ScopeChainIterator iter = chain.begin(); 828 ScopeChainIterator end = chain.end(); 829 830 // we must always have something in the scope chain 831 assert(iter != end); 823 832 824 833 PropertySlot slot; 825 834 ObjectImp *base; 826 835 do { 827 base = chain.top();836 base = *iter; 828 837 if (base->getPropertySlot(exec, ident, slot)) { 829 838 ValueImp *v = slot.getValue(exec, ident); … … 855 864 return func->call(exec, thisObj, argList); 856 865 } 857 chain.pop();858 } while ( !chain.isEmpty());866 ++iter; 867 } while (iter != end); 859 868 860 869 return undefinedVariableError(exec, ident); … … 1680 1689 ValueImp *AssignResolveNode::evaluate(ExecState *exec) 1681 1690 { 1682 ScopeChain chain = exec->context().imp()->scopeChain(); 1683 1684 assert(!chain.isEmpty()); 1691 const ScopeChain& chain = exec->context().imp()->scopeChain(); 1692 ScopeChainIterator iter = chain.begin(); 1693 ScopeChainIterator end = chain.end(); 1694 1695 // we must always have something in the scope chain 1696 assert(iter != end); 1685 1697 1686 1698 PropertySlot slot; 1687 1699 ObjectImp *base; 1688 1700 do { 1689 base = chain.top();1701 base = *iter; 1690 1702 if (base->getPropertySlot(exec, m_ident, slot)) 1691 1703 goto found; 1692 1704 1693 chain.pop();1694 } while ( !chain.isEmpty());1705 ++iter; 1706 } while (iter != end); 1695 1707 1696 1708 if (m_oper != OpEqual) -
trunk/JavaScriptCore/kjs/scope_chain.h
r9768 r10168 41 41 }; 42 42 43 class ScopeChainIterator { 44 public: 45 ScopeChainIterator(ScopeChainNode *node) : m_node(node) {} 46 47 ObjectImp * const & operator*() const { return m_node->object; } 48 ObjectImp * const * operator->() const { return &(operator*()); } 49 50 ScopeChainIterator& operator++() { m_node = m_node->next; return *this; } 51 52 // postfix ++ intentionally omitted 53 54 bool operator==(const ScopeChainIterator& other) const { return m_node == other.m_node; } 55 bool operator!=(const ScopeChainIterator& other) const { return m_node != other.m_node; } 56 57 private: 58 ScopeChainNode *m_node; 59 }; 60 43 61 class ScopeChain { 44 62 public: … … 54 72 55 73 ObjectImp *bottom() const; 74 75 ScopeChainIterator begin() const { return ScopeChainIterator(_node); } 76 ScopeChainIterator end() const { return ScopeChainIterator(0); } 56 77 57 78 void clear() { deref(); _node = 0; }
Note:
See TracChangeset
for help on using the changeset viewer.