Changeset 36480 in webkit for trunk/JavaScriptCore/VM/CodeGenerator.cpp
- Timestamp:
- Sep 15, 2008, 10:53:15 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/VM/CodeGenerator.cpp
r36463 r36480 760 760 bool CodeGenerator::findScopedProperty(const Identifier& property, int& index, size_t& stackDepth, bool forWriting, JSValue*& globalObject) 761 761 { 762 // Cases where we cannot optimise the lookup762 // Cases where we cannot statically optimise the lookup 763 763 if (property == propertyNames().arguments || !canOptimizeNonLocals()) { 764 764 stackDepth = 0; 765 765 index = missingSymbolMarker(); 766 767 if (shouldOptimizeLocals() && m_codeType == GlobalCode) { 768 ScopeChainIterator iter = m_scopeChain->begin(); 769 globalObject = *iter; 770 ASSERT((++iter) == m_scopeChain->end()); 771 } 766 772 return false; 767 773 } 768 774 775 size_t depth = 0; 776 769 777 ScopeChainIterator iter = m_scopeChain->begin(); 770 778 ScopeChainIterator end = m_scopeChain->end(); 771 size_t depth = 0;772 773 779 for (; iter != end; ++iter, ++depth) { 774 780 JSObject* currentScope = *iter; … … 821 827 int index = 0; 822 828 JSValue* globalObject = 0; 823 if (!findScopedProperty(property, index, depth, false, globalObject) ) {829 if (!findScopedProperty(property, index, depth, false, globalObject) && !globalObject) { 824 830 // We can't optimise at all :-( 825 831 emitOpcode(op_resolve); … … 829 835 } 830 836 831 if (index == missingSymbolMarker()) { 832 // In this case we are at least able to drop a few scope chains from the 833 // lookup chain, although we still need to hash from then on. 834 emitOpcode(op_resolve_skip); 837 if (index != missingSymbolMarker()) { 838 // Directly index the property lookup across multiple scopes. Yay! 839 return emitGetScopedVar(dst, depth, index, globalObject); 840 } 841 842 if (globalObject) { 843 m_codeBlock->structureIDInstructions.append(instructions().size()); 844 emitOpcode(op_resolve_global); 835 845 instructions().append(dst->index()); 846 instructions().append(static_cast<JSCell*>(globalObject)); 836 847 instructions().append(addConstant(property)); 837 instructions().append(depth); 848 instructions().append(0); 849 instructions().append(0); 838 850 return dst; 839 851 } 840 852 841 // Directly index the property lookup across multiple scopes. Yay! 842 return emitGetScopedVar(dst, depth, index, globalObject); 853 // In this case we are at least able to drop a few scope chains from the 854 // lookup chain, although we still need to hash from then on. 855 emitOpcode(op_resolve_skip); 856 instructions().append(dst->index()); 857 instructions().append(addConstant(property)); 858 instructions().append(depth); 859 return dst; 843 860 } 844 861
Note:
See TracChangeset
for help on using the changeset viewer.