Changeset 245410 in webkit
- Timestamp:
- May 16, 2019, 3:47:56 PM (7 years ago)
- Location:
- branches/safari-607.2.1.2-branch
- Files:
-
- 1 deleted
- 4 edited
-
JSTests/ChangeLog (modified) (1 diff)
-
JSTests/stress/do-not-perform-bytecode-peephole-optimization-in-jump-target.js (deleted)
-
Source/JavaScriptCore/ChangeLog (modified) (1 diff)
-
Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp (modified) (5 diffs)
-
Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/safari-607.2.1.2-branch/JSTests/ChangeLog
r245333 r245410 1 2019-05-15 Alan Coon <alancoon@apple.com>2 3 Cherry-pick r245047. rdar://problem/507549764 5 JSC: A bug in BytecodeGenerator::emitEqualityOpImpl6 https://bugs.webkit.org/show_bug.cgi?id=1974797 8 Reviewed by Saam Barati.9 10 JSTests:11 12 * stress/do-not-perform-bytecode-peephole-optimization-in-jump-target.js: Added.13 (shouldBe):14 15 Source/JavaScriptCore:16 17 Our peephole optimization in BytecodeGenerator is (1) rewinding the previous instruction and (2) emit optimized instruction instead.18 If we have jump target between the previous instruction and the subsequent instruction, this peephole optimization breaks the jump target.19 To prevent it, we had a mechanism disabling peephole optimization, setting m_lastOpcodeID = op_end and checking m_lastOpcodeID when performing20 peephole optimization. However, BytecodeGenerator::emitEqualityOpImpl checks `m_lastInstruction->is<OpTypeof>` instead of `m_lastOpcodeID == op_typeof`,21 and miss `op_end` case.22 23 This patch makes the following changes.24 25 1. Add canDoPeepholeOptimization method to clarify the intent of `m_lastInstruction = op_end`.26 2. Check canDoPeepholeOptimization status before performing peephole optimization in emitJumpIfTrue, emitJumpIfFalse, and emitEqualityOpImpl.27 3. Add `ASSERT(canDoPeepholeOptimization())` in fuseCompareAndJump and fuseTestAndJmp to ensure that peephole optimization is allowed.28 29 * bytecompiler/BytecodeGenerator.cpp:30 (JSC::BytecodeGenerator::fuseCompareAndJump):31 (JSC::BytecodeGenerator::fuseTestAndJmp):32 (JSC::BytecodeGenerator::emitJumpIfTrue):33 (JSC::BytecodeGenerator::emitJumpIfFalse):34 (JSC::BytecodeGenerator::emitEqualityOpImpl):35 * bytecompiler/BytecodeGenerator.h:36 (JSC::BytecodeGenerator::canDoPeepholeOptimization const):37 38 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245047 268f45cc-cd09-0410-ab3c-d52691b4dbfc39 40 2019-05-07 Yusuke Suzuki <ysuzuki@apple.com>41 42 JSC: A bug in BytecodeGenerator::emitEqualityOpImpl43 https://bugs.webkit.org/show_bug.cgi?id=19747944 45 Reviewed by Saam Barati.46 47 * stress/do-not-perform-bytecode-peephole-optimization-in-jump-target.js: Added.48 (shouldBe):49 50 1 2019-05-15 Alan Coon <alancoon@apple.com> 51 2 -
branches/safari-607.2.1.2-branch/Source/JavaScriptCore/ChangeLog
r245333 r245410 1 2019-05-15 Alan Coon <alancoon@apple.com>2 3 Cherry-pick r245047. rdar://problem/507549764 5 JSC: A bug in BytecodeGenerator::emitEqualityOpImpl6 https://bugs.webkit.org/show_bug.cgi?id=1974797 8 Reviewed by Saam Barati.9 10 JSTests:11 12 * stress/do-not-perform-bytecode-peephole-optimization-in-jump-target.js: Added.13 (shouldBe):14 15 Source/JavaScriptCore:16 17 Our peephole optimization in BytecodeGenerator is (1) rewinding the previous instruction and (2) emit optimized instruction instead.18 If we have jump target between the previous instruction and the subsequent instruction, this peephole optimization breaks the jump target.19 To prevent it, we had a mechanism disabling peephole optimization, setting m_lastOpcodeID = op_end and checking m_lastOpcodeID when performing20 peephole optimization. However, BytecodeGenerator::emitEqualityOpImpl checks `m_lastInstruction->is<OpTypeof>` instead of `m_lastOpcodeID == op_typeof`,21 and miss `op_end` case.22 23 This patch makes the following changes.24 25 1. Add canDoPeepholeOptimization method to clarify the intent of `m_lastInstruction = op_end`.26 2. Check canDoPeepholeOptimization status before performing peephole optimization in emitJumpIfTrue, emitJumpIfFalse, and emitEqualityOpImpl.27 3. Add `ASSERT(canDoPeepholeOptimization())` in fuseCompareAndJump and fuseTestAndJmp to ensure that peephole optimization is allowed.28 29 * bytecompiler/BytecodeGenerator.cpp:30 (JSC::BytecodeGenerator::fuseCompareAndJump):31 (JSC::BytecodeGenerator::fuseTestAndJmp):32 (JSC::BytecodeGenerator::emitJumpIfTrue):33 (JSC::BytecodeGenerator::emitJumpIfFalse):34 (JSC::BytecodeGenerator::emitEqualityOpImpl):35 * bytecompiler/BytecodeGenerator.h:36 (JSC::BytecodeGenerator::canDoPeepholeOptimization const):37 38 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245047 268f45cc-cd09-0410-ab3c-d52691b4dbfc39 40 2019-05-07 Yusuke Suzuki <ysuzuki@apple.com>41 42 JSC: A bug in BytecodeGenerator::emitEqualityOpImpl43 https://bugs.webkit.org/show_bug.cgi?id=19747944 45 Reviewed by Saam Barati.46 47 Our peephole optimization in BytecodeGenerator is (1) rewinding the previous instruction and (2) emit optimized instruction instead.48 If we have jump target between the previous instruction and the subsequent instruction, this peephole optimization breaks the jump target.49 To prevent it, we had a mechanism disabling peephole optimization, setting m_lastOpcodeID = op_end and checking m_lastOpcodeID when performing50 peephole optimization. However, BytecodeGenerator::emitEqualityOpImpl checks `m_lastInstruction->is<OpTypeof>` instead of `m_lastOpcodeID == op_typeof`,51 and miss `op_end` case.52 53 This patch makes the following changes.54 55 1. Add canDoPeepholeOptimization method to clarify the intent of `m_lastInstruction = op_end`.56 2. Check canDoPeepholeOptimization status before performing peephole optimization in emitJumpIfTrue, emitJumpIfFalse, and emitEqualityOpImpl.57 3. Add `ASSERT(canDoPeepholeOptimization())` in fuseCompareAndJump and fuseTestAndJmp to ensure that peephole optimization is allowed.58 59 * bytecompiler/BytecodeGenerator.cpp:60 (JSC::BytecodeGenerator::fuseCompareAndJump):61 (JSC::BytecodeGenerator::fuseTestAndJmp):62 (JSC::BytecodeGenerator::emitJumpIfTrue):63 (JSC::BytecodeGenerator::emitJumpIfFalse):64 (JSC::BytecodeGenerator::emitEqualityOpImpl):65 * bytecompiler/BytecodeGenerator.h:66 (JSC::BytecodeGenerator::canDoPeepholeOptimization const):67 68 1 2019-05-15 Alan Coon <alancoon@apple.com> 69 2 -
branches/safari-607.2.1.2-branch/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
r245409 r245410 1388 1388 bool BytecodeGenerator::fuseCompareAndJump(RegisterID* cond, Label& target, bool swapOperands) 1389 1389 { 1390 ASSERT(canDoPeepholeOptimization());1391 1390 auto binop = m_lastInstruction->as<BinOp>(); 1392 1391 if (cond->index() == binop.m_dst.offset() && cond->isTemporary() && !cond->refCount()) { … … 1405 1404 bool BytecodeGenerator::fuseTestAndJmp(RegisterID* cond, Label& target) 1406 1405 { 1407 ASSERT(canDoPeepholeOptimization());1408 1406 auto unop = m_lastInstruction->as<UnaryOp>(); 1409 1407 if (cond->index() == unop.m_dst.offset() && cond->isTemporary() && !cond->refCount()) { … … 1418 1416 void BytecodeGenerator::emitJumpIfTrue(RegisterID* cond, Label& target) 1419 1417 { 1420 if (canDoPeepholeOptimization()) { 1421 if (m_lastOpcodeID == op_less) { 1422 if (fuseCompareAndJump<OpLess, OpJless>(cond, target)) 1423 return; 1424 } else if (m_lastOpcodeID == op_lesseq) { 1425 if (fuseCompareAndJump<OpLesseq, OpJlesseq>(cond, target)) 1426 return; 1427 } else if (m_lastOpcodeID == op_greater) { 1428 if (fuseCompareAndJump<OpGreater, OpJgreater>(cond, target)) 1429 return; 1430 } else if (m_lastOpcodeID == op_greatereq) { 1431 if (fuseCompareAndJump<OpGreatereq, OpJgreatereq>(cond, target)) 1432 return; 1433 } else if (m_lastOpcodeID == op_eq) { 1434 if (fuseCompareAndJump<OpEq, OpJeq>(cond, target)) 1435 return; 1436 } else if (m_lastOpcodeID == op_stricteq) { 1437 if (fuseCompareAndJump<OpStricteq, OpJstricteq>(cond, target)) 1438 return; 1439 } else if (m_lastOpcodeID == op_neq) { 1440 if (fuseCompareAndJump<OpNeq, OpJneq>(cond, target)) 1441 return; 1442 } else if (m_lastOpcodeID == op_nstricteq) { 1443 if (fuseCompareAndJump<OpNstricteq, OpJnstricteq>(cond, target)) 1444 return; 1445 } else if (m_lastOpcodeID == op_below) { 1446 if (fuseCompareAndJump<OpBelow, OpJbelow>(cond, target)) 1447 return; 1448 } else if (m_lastOpcodeID == op_beloweq) { 1449 if (fuseCompareAndJump<OpBeloweq, OpJbeloweq>(cond, target)) 1450 return; 1451 } else if (m_lastOpcodeID == op_eq_null && target.isForward()) { 1452 if (fuseTestAndJmp<OpEqNull, OpJeqNull>(cond, target)) 1453 return; 1454 } else if (m_lastOpcodeID == op_neq_null && target.isForward()) { 1455 if (fuseTestAndJmp<OpNeqNull, OpJneqNull>(cond, target)) 1456 return; 1457 } 1418 1419 if (m_lastOpcodeID == op_less) { 1420 if (fuseCompareAndJump<OpLess, OpJless>(cond, target)) 1421 return; 1422 } else if (m_lastOpcodeID == op_lesseq) { 1423 if (fuseCompareAndJump<OpLesseq, OpJlesseq>(cond, target)) 1424 return; 1425 } else if (m_lastOpcodeID == op_greater) { 1426 if (fuseCompareAndJump<OpGreater, OpJgreater>(cond, target)) 1427 return; 1428 } else if (m_lastOpcodeID == op_greatereq) { 1429 if (fuseCompareAndJump<OpGreatereq, OpJgreatereq>(cond, target)) 1430 return; 1431 } else if (m_lastOpcodeID == op_eq) { 1432 if (fuseCompareAndJump<OpEq, OpJeq>(cond, target)) 1433 return; 1434 } else if (m_lastOpcodeID == op_stricteq) { 1435 if (fuseCompareAndJump<OpStricteq, OpJstricteq>(cond, target)) 1436 return; 1437 } else if (m_lastOpcodeID == op_neq) { 1438 if (fuseCompareAndJump<OpNeq, OpJneq>(cond, target)) 1439 return; 1440 } else if (m_lastOpcodeID == op_nstricteq) { 1441 if (fuseCompareAndJump<OpNstricteq, OpJnstricteq>(cond, target)) 1442 return; 1443 } else if (m_lastOpcodeID == op_below) { 1444 if (fuseCompareAndJump<OpBelow, OpJbelow>(cond, target)) 1445 return; 1446 } else if (m_lastOpcodeID == op_beloweq) { 1447 if (fuseCompareAndJump<OpBeloweq, OpJbeloweq>(cond, target)) 1448 return; 1449 } else if (m_lastOpcodeID == op_eq_null && target.isForward()) { 1450 if (fuseTestAndJmp<OpEqNull, OpJeqNull>(cond, target)) 1451 return; 1452 } else if (m_lastOpcodeID == op_neq_null && target.isForward()) { 1453 if (fuseTestAndJmp<OpNeqNull, OpJneqNull>(cond, target)) 1454 return; 1458 1455 } 1459 1456 … … 1463 1460 void BytecodeGenerator::emitJumpIfFalse(RegisterID* cond, Label& target) 1464 1461 { 1465 if (canDoPeepholeOptimization()) { 1466 if (m_lastOpcodeID == op_less && target.isForward()) { 1467 if (fuseCompareAndJump<OpLess, OpJnless>(cond, target)) 1468 return; 1469 } else if (m_lastOpcodeID == op_lesseq && target.isForward()) { 1470 if (fuseCompareAndJump<OpLesseq, OpJnlesseq>(cond, target)) 1471 return; 1472 } else if (m_lastOpcodeID == op_greater && target.isForward()) { 1473 if (fuseCompareAndJump<OpGreater, OpJngreater>(cond, target)) 1474 return; 1475 } else if (m_lastOpcodeID == op_greatereq && target.isForward()) { 1476 if (fuseCompareAndJump<OpGreatereq, OpJngreatereq>(cond, target)) 1477 return; 1478 } else if (m_lastOpcodeID == op_eq && target.isForward()) { 1479 if (fuseCompareAndJump<OpEq, OpJneq>(cond, target)) 1480 return; 1481 } else if (m_lastOpcodeID == op_stricteq && target.isForward()) { 1482 if (fuseCompareAndJump<OpStricteq, OpJnstricteq>(cond, target)) 1483 return; 1484 } else if (m_lastOpcodeID == op_neq && target.isForward()) { 1485 if (fuseCompareAndJump<OpNeq, OpJeq>(cond, target)) 1486 return; 1487 } else if (m_lastOpcodeID == op_nstricteq && target.isForward()) { 1488 if (fuseCompareAndJump<OpNstricteq, OpJstricteq>(cond, target)) 1489 return; 1490 } else if (m_lastOpcodeID == op_below && target.isForward()) { 1491 if (fuseCompareAndJump<OpBelow, OpJbeloweq>(cond, target, true)) 1492 return; 1493 } else if (m_lastOpcodeID == op_beloweq && target.isForward()) { 1494 if (fuseCompareAndJump<OpBeloweq, OpJbelow>(cond, target, true)) 1495 return; 1496 } else if (m_lastOpcodeID == op_not) { 1497 if (fuseTestAndJmp<OpNot, OpJtrue>(cond, target)) 1498 return; 1499 } else if (m_lastOpcodeID == op_eq_null && target.isForward()) { 1500 if (fuseTestAndJmp<OpEqNull, OpJneqNull>(cond, target)) 1501 return; 1502 } else if (m_lastOpcodeID == op_neq_null && target.isForward()) { 1503 if (fuseTestAndJmp<OpNeqNull, OpJeqNull>(cond, target)) 1504 return; 1505 } 1462 if (m_lastOpcodeID == op_less && target.isForward()) { 1463 if (fuseCompareAndJump<OpLess, OpJnless>(cond, target)) 1464 return; 1465 } else if (m_lastOpcodeID == op_lesseq && target.isForward()) { 1466 if (fuseCompareAndJump<OpLesseq, OpJnlesseq>(cond, target)) 1467 return; 1468 } else if (m_lastOpcodeID == op_greater && target.isForward()) { 1469 if (fuseCompareAndJump<OpGreater, OpJngreater>(cond, target)) 1470 return; 1471 } else if (m_lastOpcodeID == op_greatereq && target.isForward()) { 1472 if (fuseCompareAndJump<OpGreatereq, OpJngreatereq>(cond, target)) 1473 return; 1474 } else if (m_lastOpcodeID == op_eq && target.isForward()) { 1475 if (fuseCompareAndJump<OpEq, OpJneq>(cond, target)) 1476 return; 1477 } else if (m_lastOpcodeID == op_stricteq && target.isForward()) { 1478 if (fuseCompareAndJump<OpStricteq, OpJnstricteq>(cond, target)) 1479 return; 1480 } else if (m_lastOpcodeID == op_neq && target.isForward()) { 1481 if (fuseCompareAndJump<OpNeq, OpJeq>(cond, target)) 1482 return; 1483 } else if (m_lastOpcodeID == op_nstricteq && target.isForward()) { 1484 if (fuseCompareAndJump<OpNstricteq, OpJstricteq>(cond, target)) 1485 return; 1486 } else if (m_lastOpcodeID == op_below && target.isForward()) { 1487 if (fuseCompareAndJump<OpBelow, OpJbeloweq>(cond, target, true)) 1488 return; 1489 } else if (m_lastOpcodeID == op_beloweq && target.isForward()) { 1490 if (fuseCompareAndJump<OpBeloweq, OpJbelow>(cond, target, true)) 1491 return; 1492 } else if (m_lastOpcodeID == op_not) { 1493 if (fuseTestAndJmp<OpNot, OpJtrue>(cond, target)) 1494 return; 1495 } else if (m_lastOpcodeID == op_eq_null && target.isForward()) { 1496 if (fuseTestAndJmp<OpEqNull, OpJneqNull>(cond, target)) 1497 return; 1498 } else if (m_lastOpcodeID == op_neq_null && target.isForward()) { 1499 if (fuseTestAndJmp<OpNeqNull, OpJeqNull>(cond, target)) 1500 return; 1506 1501 } 1507 1502 … … 1712 1707 RegisterID* BytecodeGenerator::emitEqualityOp(RegisterID* dst, RegisterID* src1, RegisterID* src2) 1713 1708 { 1714 if (!canDoPeepholeOptimization())1715 return false;1716 1717 1709 if (m_lastInstruction->is<OpTypeof>()) { 1718 1710 auto op = m_lastInstruction->as<OpTypeof>(); -
branches/safari-607.2.1.2-branch/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h
r245409 r245410 1048 1048 RegisterID* emitMove(RegisterID* dst, RegisterID* src); 1049 1049 1050 bool canDoPeepholeOptimization() const { return m_lastOpcodeID != op_end; }1051 1052 1050 public: 1053 1051 bool isSuperUsedInInnerArrowFunction();
Note:
See TracChangeset
for help on using the changeset viewer.