Changeset 252464 in webkit
- Timestamp:
- Nov 14, 2019 1:59:58 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChangeLog
r252463 r252464 1 2019-11-14 Alexey Shvayka <shvaikalesh@gmail.com> 2 3 Use toLength() and getIndexQuickly() in JSON.stringify 4 https://bugs.webkit.org/show_bug.cgi?id=204122 5 6 Reviewed by Yusuke Suzuki. 7 8 * microbenchmarks/json-stringify-array-replacer.js: Added. 9 * microbenchmarks/json-stringify-empty-array.js: Added. 10 1 11 2019-11-14 Caio Lima <ticaiolima@gmail.com> 2 12 -
trunk/Source/JavaScriptCore/ChangeLog
r252463 r252464 1 2019-11-14 Alexey Shvayka <shvaikalesh@gmail.com> 2 3 Use toLength() and getIndexQuickly() in JSON.stringify 4 https://bugs.webkit.org/show_bug.cgi?id=204122 5 6 Reviewed by Yusuke Suzuki. 7 8 Using toLength() is semantically equivalent and performance-neutral, while adding 9 JSObject::getIndexQuickly() advances microbenchmarks/json-stringify-array-replacer.js 10 by 34%. 11 12 * runtime/JSONObject.cpp: 13 (JSC::Stringifier::Stringifier): 14 (JSC::Stringifier::Holder::appendNextProperty): 15 1 16 2019-11-14 Caio Lima <ticaiolima@gmail.com> 2 17 -
trunk/Source/JavaScriptCore/runtime/JSONObject.cpp
r251425 r252464 238 238 if (isArrayReplacer) { 239 239 m_usingArrayReplacer = true; 240 JSValue lengthValue = replacerObject->get(globalObject, vm.propertyNames->length);240 unsigned length = toLength(globalObject, replacerObject); 241 241 RETURN_IF_EXCEPTION(scope, ); 242 unsigned length = lengthValue.toUInt32(globalObject); 243 RETURN_IF_EXCEPTION(scope, ); 244 for (unsigned i = 0; i < length; ++i) { 245 JSValue name = replacerObject->get(globalObject, i); 246 RETURN_IF_EXCEPTION(scope, ); 242 for (unsigned index = 0; index < length; ++index) { 243 JSValue name; 244 if (isJSArray(replacerObject) && replacerObject->canGetIndexQuickly(index)) 245 name = replacerObject->getIndexQuickly(index); 246 else { 247 name = replacerObject->get(globalObject, index); 248 RETURN_IF_EXCEPTION(scope, ); 249 } 247 250 if (name.isObject()) { 248 251 auto* nameObject = jsCast<JSObject*>(name); … … 487 490 if (!m_index) { 488 491 if (m_isArray) { 489 if (m_isJSArray) 490 m_size = asArray(m_object)->length(); 491 else { 492 JSValue value = m_object->get(globalObject, vm.propertyNames->length); 493 RETURN_IF_EXCEPTION(scope, false); 494 m_size = value.toUInt32(globalObject); 495 RETURN_IF_EXCEPTION(scope, false); 496 } 492 m_size = toLength(globalObject, m_object); 493 RETURN_IF_EXCEPTION(scope, false); 497 494 builder.append('['); 498 495 } else { … … 529 526 // Get the value. 530 527 JSValue value; 531 if (m_isJSArray && asArray(m_object)->canGetIndexQuickly(index))532 value = asArray(m_object)->getIndexQuickly(index);528 if (m_isJSArray && m_object->canGetIndexQuickly(index)) 529 value = m_object->getIndexQuickly(index); 533 530 else { 534 531 PropertySlot slot(m_object, PropertySlot::InternalMethodType::Get);
Note: See TracChangeset
for help on using the changeset viewer.