Changeset 34170 in webkit for trunk/JavaScriptCore
- Timestamp:
- May 28, 2008, 2:47:29 AM (17 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r34165 r34170 1 2008-05-28 Alexey Proskuryakov <[email protected]> 2 3 Reviewed by Darin. 4 5 https://bugs.webkit.org/show_bug.cgi?id=19180 6 speed up SunSpider by optimizing immediate number cases 7 8 2% speedup overall, maximum 10% on controlflow-recursive and bitops-3bit-bits-in-byte, 9 but a 4% regression on bitops-bits-in-byte and bitops-bitwise-and. 10 11 * kjs/JSImmediate.h: 12 (KJS::JSImmediate::canDoFastAdditiveOperations): 13 (KJS::JSImmediate::addImmediateNumbers): 14 (KJS::JSImmediate::subImmediateNumbers): 15 Added fast cases that work with positive values less than 2^30. 16 17 * VM/Machine.cpp: 18 (KJS::Machine::privateExecute): Use the above operations. Also updated SunSpider frequencies 19 with my results (looks like tag values have changed, not sure what caused the minor variation 20 in actual frequencies). 21 1 22 2008-05-27 Adam Roben <[email protected]> 2 23 -
trunk/JavaScriptCore/VM/Machine.cpp
r34149 r34170 149 149 // <times> Add case: <t1> <t2> 150 150 // --------------------------- 151 // 5627160 Add case: 1 1 152 // 247427 Add case: 5 5 153 // 20901 Add case: 5 6 154 // 13978 Add case: 5 1 155 // 4000 Add case: 1 5 156 // 1 Add case: 3 5 151 // 5626160 Add case: 3 3 (of these, 3637690 are for immediate values, 34373 of them for negative) 152 // 247412 Add case: 5 5 153 // 20900 Add case: 5 6 154 // 13962 Add case: 5 3 155 // 4000 Add case: 3 5 157 156 158 157 static inline JSValue* jsAdd(ExecState* exec, JSValue* v1, JSValue* v2) … … 1177 1176 int src1 = (++vPC)->u.operand; 1178 1177 int src2 = (++vPC)->u.operand; 1179 JSValue* result = jsAdd(exec, r[src1].u.jsValue, r[src2].u.jsValue); 1178 JSValue* v1 = r[src1].u.jsValue; 1179 JSValue* v2 = r[src2].u.jsValue; 1180 JSValue* result; 1181 if (JSImmediate::canDoFastAdditiveOperations(v1) && JSImmediate::canDoFastAdditiveOperations(v2)) 1182 result = JSImmediate::addImmediateNumbers(v1, v2); 1183 else 1184 result = jsAdd(exec, v1, v2); 1180 1185 VM_CHECK_EXCEPTION(); 1181 1186 r[dst].u.jsValue = result; … … 1242 1247 int src1 = (++vPC)->u.operand; 1243 1248 int src2 = (++vPC)->u.operand; 1244 JSValue* result = jsNumber(r[src1].u.jsValue->toNumber(exec) - r[src2].u.jsValue->toNumber(exec)); 1249 JSValue* v1 = r[src1].u.jsValue; 1250 JSValue* v2 = r[src2].u.jsValue; 1251 JSValue* result; 1252 if (JSImmediate::canDoFastAdditiveOperations(v1) && JSImmediate::canDoFastAdditiveOperations(v2)) 1253 result = JSImmediate::subImmediateNumbers(v1, v2); 1254 else 1255 result = jsNumber(v1->toNumber(exec) - v2->toNumber(exec)); 1245 1256 VM_CHECK_EXCEPTION(); 1246 1257 r[dst].u.jsValue = result; -
trunk/JavaScriptCore/kjs/JSImmediate.h
r34149 r34170 119 119 } 120 120 121 static ALWAYS_INLINE bool canDoFastAdditiveOperations(const JSValue* v) 122 { 123 // Number is positive and an operation involving two of these can't overflow. 124 // Checking for allowed negative numbers takes more time than it's worth on SunSpider. 125 return (reinterpret_cast<uintptr_t>(v) & (NumberType + (3 << 30))) == NumberType; 126 } 127 128 static ALWAYS_INLINE JSValue* addImmediateNumbers(const JSValue* v1, const JSValue* v2) 129 { 130 ASSERT(canDoFastAdditiveOperations(v1)); 131 ASSERT(canDoFastAdditiveOperations(v2)); 132 return reinterpret_cast<JSValue*>(reinterpret_cast<uintptr_t>(v1) + (reinterpret_cast<uintptr_t>(v2) & ~NumberType)); 133 } 134 135 static ALWAYS_INLINE JSValue* subImmediateNumbers(const JSValue* v1, const JSValue* v2) 136 { 137 ASSERT(canDoFastAdditiveOperations(v1)); 138 ASSERT(canDoFastAdditiveOperations(v2)); 139 return reinterpret_cast<JSValue*>(reinterpret_cast<uintptr_t>(v1) - (reinterpret_cast<uintptr_t>(v2) & ~NumberType)); 140 } 141 121 142 static double toDouble(const JSValue*); 122 143 static bool toBoolean(const JSValue*);
Note:
See TracChangeset
for help on using the changeset viewer.