Changeset 224276 in webkit for trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp
- Timestamp:
- Nov 1, 2017, 6:25:21 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp
r224258 r224276 1515 1515 1516 1516 jump(notTaken); 1517 } 1518 1519 void SpeculativeJIT::compileStringSlice(Node* node) 1520 { 1521 SpeculateCellOperand string(this, node->child1()); 1522 GPRTemporary startIndex(this); 1523 GPRTemporary temp(this); 1524 GPRTemporary temp2(this); 1525 1526 GPRReg stringGPR = string.gpr(); 1527 GPRReg startIndexGPR = startIndex.gpr(); 1528 GPRReg tempGPR = temp.gpr(); 1529 GPRReg temp2GPR = temp2.gpr(); 1530 1531 speculateString(node->child1(), stringGPR); 1532 1533 { 1534 m_jit.load32(JITCompiler::Address(stringGPR, JSString::offsetOfLength()), temp2GPR); 1535 1536 emitPopulateSliceIndex(node->child2(), temp2GPR, startIndexGPR); 1537 if (node->child3()) 1538 emitPopulateSliceIndex(node->child3(), temp2GPR, tempGPR); 1539 else 1540 m_jit.move(temp2GPR, tempGPR); 1541 } 1542 1543 CCallHelpers::JumpList doneCases; 1544 CCallHelpers::JumpList slowCases; 1545 1546 auto nonEmptyCase = m_jit.branch32(MacroAssembler::Below, startIndexGPR, tempGPR); 1547 m_jit.move(TrustedImmPtr::weakPointer(m_jit.graph(), jsEmptyString(&vm())), tempGPR); 1548 doneCases.append(m_jit.jump()); 1549 1550 nonEmptyCase.link(&m_jit); 1551 m_jit.sub32(startIndexGPR, tempGPR); // the size of the sliced string. 1552 slowCases.append(m_jit.branch32(MacroAssembler::NotEqual, tempGPR, TrustedImm32(1))); 1553 1554 m_jit.loadPtr(MacroAssembler::Address(stringGPR, JSString::offsetOfValue()), temp2GPR); 1555 slowCases.append(m_jit.branchTestPtr(MacroAssembler::Zero, temp2GPR)); 1556 1557 m_jit.loadPtr(MacroAssembler::Address(temp2GPR, StringImpl::dataOffset()), tempGPR); 1558 1559 // Load the character into scratchReg 1560 m_jit.zeroExtend32ToPtr(startIndexGPR, startIndexGPR); 1561 auto is16Bit = m_jit.branchTest32(MacroAssembler::Zero, MacroAssembler::Address(temp2GPR, StringImpl::flagsOffset()), TrustedImm32(StringImpl::flagIs8Bit())); 1562 1563 m_jit.load8(MacroAssembler::BaseIndex(tempGPR, startIndexGPR, MacroAssembler::TimesOne, 0), tempGPR); 1564 auto cont8Bit = m_jit.jump(); 1565 1566 is16Bit.link(&m_jit); 1567 m_jit.load16(MacroAssembler::BaseIndex(tempGPR, startIndexGPR, MacroAssembler::TimesTwo, 0), tempGPR); 1568 1569 auto bigCharacter = m_jit.branch32(MacroAssembler::AboveOrEqual, tempGPR, TrustedImm32(0x100)); 1570 1571 // 8 bit string values don't need the isASCII check. 1572 cont8Bit.link(&m_jit); 1573 1574 m_jit.lshift32(MacroAssembler::TrustedImm32(sizeof(void*) == 4 ? 2 : 3), tempGPR); 1575 m_jit.addPtr(TrustedImmPtr(m_jit.vm()->smallStrings.singleCharacterStrings()), tempGPR); 1576 m_jit.loadPtr(tempGPR, tempGPR); 1577 1578 addSlowPathGenerator( 1579 slowPathCall( 1580 bigCharacter, this, operationSingleCharacterString, tempGPR, tempGPR)); 1581 1582 addSlowPathGenerator( 1583 slowPathCall( 1584 slowCases, this, operationStringSubstr, tempGPR, stringGPR, startIndexGPR, tempGPR)); 1585 1586 doneCases.link(&m_jit); 1587 cellResult(tempGPR, node); 1517 1588 } 1518 1589 … … 7494 7565 } 7495 7566 7567 void SpeculativeJIT::emitPopulateSliceIndex(Edge& target, GPRReg length, GPRReg result) 7568 { 7569 SpeculateInt32Operand index(this, target); 7570 GPRReg indexGPR = index.gpr(); 7571 MacroAssembler::JumpList done; 7572 auto isPositive = m_jit.branch32(MacroAssembler::GreaterThanOrEqual, indexGPR, TrustedImm32(0)); 7573 m_jit.move(length, result); 7574 done.append(m_jit.branchAdd32(MacroAssembler::PositiveOrZero, indexGPR, result)); 7575 m_jit.move(TrustedImm32(0), result); 7576 done.append(m_jit.jump()); 7577 7578 isPositive.link(&m_jit); 7579 m_jit.move(indexGPR, result); 7580 done.append(m_jit.branch32(MacroAssembler::BelowOrEqual, result, length)); 7581 m_jit.move(length, result); 7582 7583 done.link(&m_jit); 7584 } 7585 7496 7586 void SpeculativeJIT::compileArraySlice(Node* node) 7497 7587 { … … 7507 7597 GPRReg resultGPR = result.gpr(); 7508 7598 GPRReg tempGPR = temp.gpr(); 7509 7510 auto populateIndex = [&] (unsigned childIndex, GPRReg length, GPRReg result) {7511 SpeculateInt32Operand index(this, m_jit.graph().varArgChild(node, childIndex));7512 GPRReg indexGPR = index.gpr();7513 MacroAssembler::JumpList done;7514 auto isPositive = m_jit.branch32(MacroAssembler::GreaterThanOrEqual, indexGPR, TrustedImm32(0));7515 m_jit.move(length, result);7516 done.append(m_jit.branchAdd32(MacroAssembler::PositiveOrZero, indexGPR, result));7517 m_jit.move(TrustedImm32(0), result);7518 done.append(m_jit.jump());7519 7520 isPositive.link(&m_jit);7521 m_jit.move(indexGPR, result);7522 done.append(m_jit.branch32(MacroAssembler::BelowOrEqual, result, length));7523 m_jit.move(length, result);7524 7525 done.link(&m_jit);7526 };7527 7599 7528 7600 { … … 7532 7604 7533 7605 if (node->numChildren() == 4) 7534 populateIndex(2, lengthGPR, tempGPR);7606 emitPopulateSliceIndex(m_jit.graph().varArgChild(node, 2), lengthGPR, tempGPR); 7535 7607 else 7536 7608 m_jit.move(lengthGPR, tempGPR); … … 7538 7610 GPRTemporary tempStartIndex(this); 7539 7611 GPRReg startGPR = tempStartIndex.gpr(); 7540 populateIndex(1, lengthGPR, startGPR);7612 emitPopulateSliceIndex(m_jit.graph().varArgChild(node, 1), lengthGPR, startGPR); 7541 7613 7542 7614 auto tooBig = m_jit.branch32(MacroAssembler::Above, startGPR, tempGPR); … … 7629 7701 m_jit.load32(MacroAssembler::Address(storageGPR, Butterfly::offsetOfPublicLength()), tempValue); 7630 7702 if (node->numChildren() == 4) 7631 populateIndex(2, tempValue, tempGPR);7703 emitPopulateSliceIndex(m_jit.graph().varArgChild(node, 2), tempValue, tempGPR); 7632 7704 else 7633 7705 m_jit.move(tempValue, tempGPR); 7634 populateIndex(1, tempValue, loadIndex);7706 emitPopulateSliceIndex(m_jit.graph().varArgChild(node, 1), tempValue, loadIndex); 7635 7707 7636 7708 GPRTemporary temp5(this); … … 7685 7757 m_jit.load32(MacroAssembler::Address(storageGPR, Butterfly::offsetOfPublicLength()), lengthGPR); 7686 7758 7687 if (node->numChildren() == 4) { 7688 SpeculateInt32Operand startIndex(this, m_jit.graph().varArgChild(node, 2)); 7689 GPRReg startIndexGPR = startIndex.gpr(); 7690 MacroAssembler::JumpList done; 7691 auto isPositive = m_jit.branch32(MacroAssembler::GreaterThanOrEqual, startIndexGPR, TrustedImm32(0)); 7692 m_jit.move(lengthGPR, indexGPR); 7693 done.append(m_jit.branchAdd32(MacroAssembler::PositiveOrZero, startIndexGPR, indexGPR)); 7694 m_jit.move(TrustedImm32(0), indexGPR); 7695 done.append(m_jit.jump()); 7696 7697 isPositive.link(&m_jit); 7698 m_jit.move(startIndexGPR, indexGPR); 7699 done.append(m_jit.branch32(MacroAssembler::BelowOrEqual, indexGPR, lengthGPR)); 7700 m_jit.move(lengthGPR, indexGPR); 7701 7702 done.link(&m_jit); 7703 } else 7759 if (node->numChildren() == 4) 7760 emitPopulateSliceIndex(m_jit.graph().varArgChild(node, 2), lengthGPR, indexGPR); 7761 else 7704 7762 m_jit.move(TrustedImm32(0), indexGPR); 7705 7763
Note:
See TracChangeset
for help on using the changeset viewer.