Changeset 251826 in webkit for trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp
- Timestamp:
- Oct 30, 2019, 5:37:03 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp
r251669 r251826 1546 1546 compileFilterICStatus(); 1547 1547 break; 1548 case DateGetInt32OrNaN: 1549 case DateGetTime: 1550 compileDateGet(); 1551 break; 1548 1552 case DataViewGetInt: 1549 1553 case DataViewGetFloat: … … 13406 13410 RELEASE_ASSERT_NOT_REACHED(); 13407 13411 } 13412 } 13413 } 13414 13415 void compileDateGet() 13416 { 13417 LValue base = lowDateObject(m_node->child1()); 13418 13419 auto emitGetCodeWithCallback = [&] (const AbstractHeap& cachedDoubleOffset, const AbstractHeap& cachedDataOffset, auto* operation, auto callback) { 13420 LBasicBlock dataExistsCase = m_out.newBlock(); 13421 LBasicBlock fastCase = m_out.newBlock(); 13422 LBasicBlock slowCase = m_out.newBlock(); 13423 LBasicBlock continuation = m_out.newBlock(); 13424 13425 LValue data = m_out.loadPtr(base, m_heaps.DateInstance_data); 13426 m_out.branch(m_out.notZero64(data), unsure(dataExistsCase), unsure(slowCase)); 13427 13428 LBasicBlock lastNext = m_out.appendTo(dataExistsCase, fastCase); 13429 LValue milliseconds = m_out.loadDouble(base, m_heaps.DateInstance_internalNumber); 13430 LValue cachedMilliseconds = m_out.loadDouble(data, cachedDoubleOffset); 13431 m_out.branch(m_out.doubleNotEqualOrUnordered(milliseconds, cachedMilliseconds), unsure(slowCase), unsure(fastCase)); 13432 13433 m_out.appendTo(fastCase, slowCase); 13434 ValueFromBlock fastResult = m_out.anchor(boxInt32(callback(m_out.load32(data, cachedDataOffset)))); 13435 m_out.jump(continuation); 13436 13437 m_out.appendTo(slowCase, continuation); 13438 ValueFromBlock slowResult = m_out.anchor(vmCall(Int64, operation, m_vmValue, base)); 13439 m_out.jump(continuation); 13440 13441 m_out.appendTo(continuation, lastNext); 13442 setJSValue(m_out.phi(Int64, fastResult, slowResult)); 13443 }; 13444 13445 auto emitGetCode = [&] (const AbstractHeap& cachedDoubleOffset, const AbstractHeap& cachedDataOffset, auto* operation) { 13446 emitGetCodeWithCallback(cachedDoubleOffset, cachedDataOffset, operation, [] (LValue value) { return value; }); 13447 }; 13448 13449 switch (m_node->intrinsic()) { 13450 case DatePrototypeGetTimeIntrinsic: 13451 setDouble(m_out.loadDouble(base, m_heaps.DateInstance_internalNumber)); 13452 break; 13453 13454 case DatePrototypeGetMillisecondsIntrinsic: 13455 case DatePrototypeGetUTCMillisecondsIntrinsic: { 13456 LValue milliseconds = m_out.loadDouble(base, m_heaps.DateInstance_internalNumber); 13457 LValue msPerSecondConstant = m_out.constDouble(msPerSecond); 13458 LValue seconds = m_out.doubleFloor(m_out.doubleDiv(milliseconds, msPerSecondConstant)); 13459 LValue result = m_out.doubleToInt(m_out.doubleSub(milliseconds, m_out.doubleMul(seconds, msPerSecondConstant))); 13460 setJSValue(m_out.select(m_out.doubleNotEqualOrUnordered(milliseconds, milliseconds), m_out.constInt64(JSValue::encode(jsNaN())), boxInt32(result))); 13461 break; 13462 } 13463 13464 case DatePrototypeGetFullYearIntrinsic: 13465 emitGetCode(m_heaps.DateInstanceData_gregorianDateTimeCachedForMS, m_heaps.DateInstanceData_cachedGregorianDateTime_year, operationDateGetFullYear); 13466 break; 13467 case DatePrototypeGetUTCFullYearIntrinsic: 13468 emitGetCode(m_heaps.DateInstanceData_gregorianDateTimeUTCCachedForMS, m_heaps.DateInstanceData_cachedGregorianDateTimeUTC_year, operationDateGetUTCFullYear); 13469 break; 13470 case DatePrototypeGetMonthIntrinsic: 13471 emitGetCode(m_heaps.DateInstanceData_gregorianDateTimeCachedForMS, m_heaps.DateInstanceData_cachedGregorianDateTime_month, operationDateGetMonth); 13472 break; 13473 case DatePrototypeGetUTCMonthIntrinsic: 13474 emitGetCode(m_heaps.DateInstanceData_gregorianDateTimeUTCCachedForMS, m_heaps.DateInstanceData_cachedGregorianDateTimeUTC_month, operationDateGetUTCMonth); 13475 break; 13476 case DatePrototypeGetDateIntrinsic: 13477 emitGetCode(m_heaps.DateInstanceData_gregorianDateTimeCachedForMS, m_heaps.DateInstanceData_cachedGregorianDateTime_monthDay, operationDateGetDate); 13478 break; 13479 case DatePrototypeGetUTCDateIntrinsic: 13480 emitGetCode(m_heaps.DateInstanceData_gregorianDateTimeUTCCachedForMS, m_heaps.DateInstanceData_cachedGregorianDateTimeUTC_monthDay, operationDateGetUTCDate); 13481 break; 13482 case DatePrototypeGetDayIntrinsic: 13483 emitGetCode(m_heaps.DateInstanceData_gregorianDateTimeCachedForMS, m_heaps.DateInstanceData_cachedGregorianDateTime_weekDay, operationDateGetDay); 13484 break; 13485 case DatePrototypeGetUTCDayIntrinsic: 13486 emitGetCode(m_heaps.DateInstanceData_gregorianDateTimeUTCCachedForMS, m_heaps.DateInstanceData_cachedGregorianDateTimeUTC_weekDay, operationDateGetUTCDay); 13487 break; 13488 case DatePrototypeGetHoursIntrinsic: 13489 emitGetCode(m_heaps.DateInstanceData_gregorianDateTimeCachedForMS, m_heaps.DateInstanceData_cachedGregorianDateTime_hour, operationDateGetHours); 13490 break; 13491 case DatePrototypeGetUTCHoursIntrinsic: 13492 emitGetCode(m_heaps.DateInstanceData_gregorianDateTimeUTCCachedForMS, m_heaps.DateInstanceData_cachedGregorianDateTimeUTC_hour, operationDateGetUTCHours); 13493 break; 13494 case DatePrototypeGetMinutesIntrinsic: 13495 emitGetCode(m_heaps.DateInstanceData_gregorianDateTimeCachedForMS, m_heaps.DateInstanceData_cachedGregorianDateTime_minute, operationDateGetMinutes); 13496 break; 13497 case DatePrototypeGetUTCMinutesIntrinsic: 13498 emitGetCode(m_heaps.DateInstanceData_gregorianDateTimeUTCCachedForMS, m_heaps.DateInstanceData_cachedGregorianDateTimeUTC_minute, operationDateGetUTCMinutes); 13499 break; 13500 case DatePrototypeGetSecondsIntrinsic: 13501 emitGetCode(m_heaps.DateInstanceData_gregorianDateTimeCachedForMS, m_heaps.DateInstanceData_cachedGregorianDateTime_second, operationDateGetSeconds); 13502 break; 13503 case DatePrototypeGetUTCSecondsIntrinsic: 13504 emitGetCode(m_heaps.DateInstanceData_gregorianDateTimeUTCCachedForMS, m_heaps.DateInstanceData_cachedGregorianDateTimeUTC_second, operationDateGetUTCSeconds); 13505 break; 13506 13507 case DatePrototypeGetTimezoneOffsetIntrinsic: 13508 emitGetCodeWithCallback(m_heaps.DateInstanceData_gregorianDateTimeCachedForMS, m_heaps.DateInstanceData_cachedGregorianDateTime_utcOffsetInMinute, operationDateGetTimezoneOffset, [&] (LValue offset) { 13509 return m_out.neg(offset); 13510 }); 13511 break; 13512 13513 case DatePrototypeGetYearIntrinsic: 13514 emitGetCodeWithCallback(m_heaps.DateInstanceData_gregorianDateTimeCachedForMS, m_heaps.DateInstanceData_cachedGregorianDateTime_year, operationDateGetYear, [&] (LValue year) { 13515 return m_out.sub(year, m_out.constInt32(1900)); 13516 }); 13517 break; 13518 13519 default: 13520 RELEASE_ASSERT_NOT_REACHED(); 13408 13521 } 13409 13522 } … … 15757 15870 return result; 15758 15871 } 15872 15873 LValue lowDateObject(Edge edge) 15874 { 15875 LValue result = lowCell(edge); 15876 speculateDateObject(edge, result); 15877 return result; 15878 } 15759 15879 15760 15880 LValue lowString(Edge edge, OperandSpeculationMode mode = AutomaticOperandSpeculation) … … 16240 16360 case DerivedArrayUse: 16241 16361 speculateDerivedArray(edge); 16362 break; 16363 case DateObjectUse: 16364 speculateDateObject(edge); 16242 16365 break; 16243 16366 case MapObjectUse: … … 16765 16888 { 16766 16889 speculatePromiseObject(edge, lowCell(edge)); 16890 } 16891 16892 void speculateDateObject(Edge edge, LValue cell) 16893 { 16894 FTL_TYPE_CHECK( 16895 jsValueValue(cell), edge, SpecDateObject, isNotType(cell, JSDateType)); 16896 } 16897 16898 void speculateDateObject(Edge edge) 16899 { 16900 speculateDateObject(edge, lowCell(edge)); 16767 16901 } 16768 16902
Note:
See TracChangeset
for help on using the changeset viewer.