Changeset 59055 in webkit for trunk/JavaScriptCore
- Timestamp:
- May 9, 2010, 4:18:25 AM (15 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r59049 r59055 1 2010-05-09 Maciej Stachowiak <[email protected]> 2 3 Fixed version of: "Optimized o[s] where o is a cell and s is a string" 4 https://bugs.webkit.org/show_bug.cgi?id=38815 5 6 Fixed the previous patch for this from Geoff Garen. 7 8 The two problems were a missing exception check and a PropertySlot 9 initialized improperly, leading to crashes and failures in the case 10 of getters accessed with bracket syntax. 11 12 Previous patch: 13 14 Optimized o[s] where o is a cell and s is a string, removing some old 15 code that wasn't really tuned for the JIT. 16 17 SunSpider says 0.8% faster. 18 19 * jit/JITStubs.cpp: 20 (JSC::DEFINE_STUB_FUNCTION): 21 * runtime/JSCell.h: 22 1 23 2010-05-08 Laszlo Gombos <[email protected]> 2 24 -
trunk/JavaScriptCore/jit/JITStubs.cpp
r58995 r59055 2088 2088 JSValue subscript = stackFrame.args[1].jsValue(); 2089 2089 2090 JSValue result; 2091 2092 if (LIKELY(subscript.isUInt32())) { 2090 if (LIKELY(baseValue.isCell() && subscript.isString())) { 2091 Identifier propertyName(callFrame, asString(subscript)->value(callFrame)); 2092 PropertySlot slot(asCell(baseValue)); 2093 if (asCell(baseValue)->fastGetOwnPropertySlot(callFrame, propertyName, slot)) { 2094 JSValue result = slot.getValue(callFrame, propertyName); 2095 CHECK_FOR_EXCEPTION(); 2096 return JSValue::encode(result); 2097 } 2098 } 2099 2100 if (subscript.isUInt32()) { 2093 2101 uint32_t i = subscript.asUInt32(); 2094 if (isJSArray(globalData, baseValue)) { 2095 JSArray* jsArray = asArray(baseValue); 2096 if (jsArray->canGetIndex(i)) 2097 result = jsArray->getIndex(i); 2098 else 2099 result = jsArray->JSArray::get(callFrame, i); 2100 } else if (isJSString(globalData, baseValue) && asString(baseValue)->canGetIndex(i)) { 2101 // All fast byte array accesses are safe from exceptions so return immediately to avoid exception checks. 2102 if (isJSString(globalData, baseValue) && asString(baseValue)->canGetIndex(i)) { 2102 2103 ctiPatchCallByReturnAddress(callFrame->codeBlock(), STUB_RETURN_ADDRESS, FunctionPtr(cti_op_get_by_val_string)); 2103 result = asString(baseValue)->getIndex(callFrame, i); 2104 } else if (isJSByteArray(globalData, baseValue) && asByteArray(baseValue)->canAccessIndex(i)) { 2104 JSValue result = asString(baseValue)->getIndex(callFrame, i); 2105 CHECK_FOR_EXCEPTION(); 2106 return JSValue::encode(result); 2107 } 2108 if (isJSByteArray(globalData, baseValue) && asByteArray(baseValue)->canAccessIndex(i)) { 2105 2109 // All fast byte array accesses are safe from exceptions so return immediately to avoid exception checks. 2106 2110 ctiPatchCallByReturnAddress(callFrame->codeBlock(), STUB_RETURN_ADDRESS, FunctionPtr(cti_op_get_by_val_byte_array)); 2107 2111 return JSValue::encode(asByteArray(baseValue)->getIndex(callFrame, i)); 2108 } else 2109 result = baseValue.get(callFrame, i); 2110 } else { 2111 Identifier property(callFrame, subscript.toString(callFrame)); 2112 result = baseValue.get(callFrame, property); 2113 } 2114 2112 } 2113 JSValue result = baseValue.get(callFrame, i); 2114 CHECK_FOR_EXCEPTION(); 2115 return JSValue::encode(result); 2116 } 2117 2118 Identifier property(callFrame, subscript.toString(callFrame)); 2119 JSValue result = baseValue.get(callFrame, property); 2115 2120 CHECK_FOR_EXCEPTION_AT_END(); 2116 2121 return JSValue::encode(result); -
trunk/JavaScriptCore/runtime/JSCell.h
r58995 r59055 112 112 void setVPtr(void* vptr) { *reinterpret_cast<void**>(this) = vptr; } 113 113 114 // FIXME: Rename getOwnPropertySlot to virtualGetOwnPropertySlot, and 115 // fastGetOwnPropertySlot to getOwnPropertySlot. Callers should always 116 // call this function, not its slower virtual counterpart. (For integer 117 // property names, we want a similar interface with appropriate optimizations.) 118 bool fastGetOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&); 119 114 120 protected: 115 121 static const unsigned AnonymousSlotCount = 0; … … 117 123 private: 118 124 // Base implementation; for non-object classes implements getPropertySlot. 119 bool fastGetOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);120 125 virtual bool getOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&); 121 126 virtual bool getOwnPropertySlot(ExecState*, unsigned propertyName, PropertySlot&);
Note:
See TracChangeset
for help on using the changeset viewer.