Changeset 230273 in webkit
- Timestamp:
- Apr 4, 2018 1:29:43 PM (6 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r230266 r230273 1 2018-04-04 Filip Pizlo <fpizlo@apple.com> 2 3 Remove poisoning of typed array vector 4 https://bugs.webkit.org/show_bug.cgi?id=184313 5 6 Reviewed by Saam Barati. 7 8 * dfg/DFGFixupPhase.cpp: 9 (JSC::DFG::FixupPhase::checkArray): 10 * dfg/DFGSpeculativeJIT.cpp: 11 (JSC::DFG::SpeculativeJIT::jumpForTypedArrayIsNeuteredIfOutOfBounds): 12 (JSC::DFG::SpeculativeJIT::compileGetIndexedPropertyStorage): 13 (JSC::DFG::SpeculativeJIT::compileGetTypedArrayByteOffset): 14 (JSC::DFG::SpeculativeJIT::compileNewTypedArrayWithSize): 15 * ftl/FTLAbstractHeapRepository.h: 16 * ftl/FTLLowerDFGToB3.cpp: 17 (JSC::FTL::DFG::LowerDFGToB3::compileGetIndexedPropertyStorage): 18 (JSC::FTL::DFG::LowerDFGToB3::compileGetTypedArrayByteOffset): 19 (JSC::FTL::DFG::LowerDFGToB3::compileNewTypedArray): 20 (JSC::FTL::DFG::LowerDFGToB3::speculateTypedArrayIsNotNeutered): 21 * jit/IntrinsicEmitter.cpp: 22 (JSC::IntrinsicGetterAccessCase::emitIntrinsicGetter): 23 * jit/JITPropertyAccess.cpp: 24 (JSC::JIT::emitIntTypedArrayGetByVal): 25 (JSC::JIT::emitFloatTypedArrayGetByVal): 26 (JSC::JIT::emitIntTypedArrayPutByVal): 27 (JSC::JIT::emitFloatTypedArrayPutByVal): 28 * llint/LowLevelInterpreter.asm: 29 * llint/LowLevelInterpreter64.asm: 30 * offlineasm/arm64.rb: 31 * offlineasm/x86.rb: 32 * runtime/CagedBarrierPtr.h: 33 * runtime/JSArrayBufferView.cpp: 34 (JSC::JSArrayBufferView::JSArrayBufferView): 35 (JSC::JSArrayBufferView::finalize): 36 (JSC::JSArrayBufferView::neuter): 37 * runtime/JSArrayBufferView.h: 38 (JSC::JSArrayBufferView::vector const): 39 (JSC::JSArrayBufferView::offsetOfVector): 40 (JSC::JSArrayBufferView::offsetOfPoisonedVector): Deleted. 41 (JSC::JSArrayBufferView::poisonFor): Deleted. 42 (JSC::JSArrayBufferView::Poison::key): Deleted. 43 * runtime/JSCPoison.cpp: 44 (JSC::initializePoison): 45 * runtime/JSCPoison.h: 46 * runtime/JSGenericTypedArrayViewInlines.h: 47 (JSC::JSGenericTypedArrayView<Adaptor>::estimatedSize): 48 (JSC::JSGenericTypedArrayView<Adaptor>::visitChildren): 49 (JSC::JSGenericTypedArrayView<Adaptor>::slowDownAndWasteMemory): 50 * runtime/JSObject.h: 51 1 52 2018-04-03 Filip Pizlo <fpizlo@apple.com> 2 53 -
trunk/Source/JavaScriptCore/dfg/DFGFixupPhase.cpp
r230144 r230273 1 1 /* 2 * Copyright (C) 2012-201 8Apple Inc. All rights reserved.2 * Copyright (C) 2012-2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 2888 2888 } 2889 2889 2890 ASSERT(arrayMode.type() == Array::String || arrayMode.typedArrayType() != NotTypedArray);2891 2890 return m_insertionSet.insertNode( 2892 2891 m_indexInBlock, SpecNone, GetIndexedPropertyStorage, origin, -
trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp
r230266 r230273 2826 2826 JITCompiler::Jump hasNullVector = m_jit.branchTestPtr( 2827 2827 MacroAssembler::Zero, 2828 MacroAssembler::Address(base, JSArrayBufferView::offsetOf PoisonedVector()));2828 MacroAssembler::Address(base, JSArrayBufferView::offsetOfVector())); 2829 2829 speculationCheck(Uncountable, JSValueSource(), node, hasNullVector); 2830 2830 notWasteful.link(&m_jit); … … 6427 6427 ASSERT_UNUSED(typedArrayType, isTypedView(typedArrayType)); 6428 6428 6429 m_jit.loadPtr(JITCompiler::Address(baseReg, JSArrayBufferView::offsetOfPoisonedVector()), storageReg); 6430 #if ENABLE(POISON) 6431 m_jit.xorPtr(JITCompiler::TrustedImmPtr(JSArrayBufferView::poisonFor(typedArrayType)), storageReg); 6432 #endif 6429 m_jit.loadPtr(JITCompiler::Address(baseReg, JSArrayBufferView::offsetOfVector()), storageReg); 6433 6430 cageTypedArrayStorage(storageReg); 6434 6431 break; … … 6451 6448 ASSERT(vectorGPR != dataGPR); 6452 6449 6453 #if ENABLE(POISON)6454 GPRTemporary poison(this);6455 GPRTemporary index(this);6456 GPRReg poisonGPR = poison.gpr();6457 GPRReg indexGPR = index.gpr();6458 GPRReg arrayBufferGPR = poisonGPR;6459 #else6460 6450 GPRReg arrayBufferGPR = dataGPR; 6461 #endif6462 6451 6463 6452 JITCompiler::Jump emptyByteOffset = m_jit.branch32( … … 6466 6455 TrustedImm32(WastefulTypedArray)); 6467 6456 6468 m_jit.loadPtr(MacroAssembler::Address(baseGPR, JSArrayBufferView::offsetOf PoisonedVector()), vectorGPR);6457 m_jit.loadPtr(MacroAssembler::Address(baseGPR, JSArrayBufferView::offsetOfVector()), vectorGPR); 6469 6458 JITCompiler::Jump nullVector = m_jit.branchTestPtr(JITCompiler::Zero, vectorGPR); 6470 6459 … … 6472 6461 m_jit.cage(Gigacage::JSValue, dataGPR); 6473 6462 6474 #if ENABLE(POISON)6475 m_jit.load8(JITCompiler::Address(baseGPR, JSCell::typeInfoTypeOffset()), indexGPR);6476 m_jit.move(JITCompiler::TrustedImmPtr(&g_typedArrayPoisons), poisonGPR);6477 m_jit.sub32(JITCompiler::TrustedImm32(FirstTypedArrayType), indexGPR);6478 m_jit.and32(JITCompiler::TrustedImm32(TypedArrayPoisonIndexMask), indexGPR);6479 m_jit.loadPtr(JITCompiler::BaseIndex(poisonGPR, indexGPR, JITCompiler::timesPtr()), poisonGPR);6480 m_jit.xorPtr(poisonGPR, vectorGPR);6481 #endif6482 6463 cageTypedArrayStorage(vectorGPR); 6483 6464 … … 9314 9295 storageGPR, m_jit.vm()->primitiveGigacageAuxiliarySpace, scratchGPR, scratchGPR, 9315 9296 scratchGPR2, slowCases); 9316 9297 9298 MacroAssembler::Jump done = m_jit.branchTest32(MacroAssembler::Zero, sizeGPR); 9317 9299 m_jit.move(sizeGPR, scratchGPR); 9318 9300 if (elementSize(typedArrayType) != 4) { … … 9332 9314 MacroAssembler::BaseIndex(storageGPR, scratchGPR, MacroAssembler::TimesFour)); 9333 9315 m_jit.branchTest32(MacroAssembler::NonZero, scratchGPR).linkTo(loop, &m_jit); 9316 done.link(&m_jit); 9334 9317 9335 9318 auto butterfly = TrustedImmPtr(nullptr); … … 9338 9321 slowCases); 9339 9322 9340 #if ENABLE(POISON)9341 m_jit.move(storageGPR, scratchGPR);9342 m_jit.xorPtr(TrustedImmPtr(JSArrayBufferView::poisonFor(typedArrayType)), scratchGPR);9343 m_jit.storePtr(9344 scratchGPR,9345 MacroAssembler::Address(resultGPR, JSArrayBufferView::offsetOfPoisonedVector()));9346 #else9347 9323 m_jit.storePtr( 9348 9324 storageGPR, 9349 MacroAssembler::Address(resultGPR, JSArrayBufferView::offsetOfPoisonedVector())); 9350 #endif 9325 MacroAssembler::Address(resultGPR, JSArrayBufferView::offsetOfVector())); 9351 9326 m_jit.store32( 9352 9327 sizeGPR, -
trunk/Source/JavaScriptCore/ftl/FTLAbstractHeapRepository.h
r230266 r230273 61 61 macro(JSArrayBufferView_length, JSArrayBufferView::offsetOfLength()) \ 62 62 macro(JSArrayBufferView_mode, JSArrayBufferView::offsetOfMode()) \ 63 macro(JSArrayBufferView_ poisonedVector, JSArrayBufferView::offsetOfPoisonedVector()) \63 macro(JSArrayBufferView_vector, JSArrayBufferView::offsetOfVector()) \ 64 64 macro(JSCell_cellState, JSCell::cellStateOffset()) \ 65 65 macro(JSCell_header, 0) \ … … 150 150 macro(HasOwnPropertyCache, 0, sizeof(HasOwnPropertyCache::Entry)) \ 151 151 macro(JSFixedArray_buffer, JSFixedArray::offsetOfData(), sizeof(EncodedJSValue)) \ 152 macro(TypedArrayPoisons, 0, sizeof(uintptr_t)) \ 153 152 154 153 #define FOR_EACH_NUMBERED_ABSTRACT_HEAP(macro) \ 155 154 macro(properties) -
trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp
r230266 r230273 3496 3496 3497 3497 DFG_ASSERT(m_graph, m_node, isTypedView(m_node->arrayMode().typedArrayType()), m_node->arrayMode().typedArrayType()); 3498 LValue poisonedVector = m_out.loadPtr(cell, m_heaps.JSArrayBufferView_poisonedVector); 3499 #if ENABLE(POISON) 3500 auto typedArrayType = m_node->arrayMode().typedArrayType(); 3501 LValue vector = m_out.bitXor(m_out.constIntPtr(JSArrayBufferView::poisonFor(typedArrayType)), poisonedVector); 3502 #else 3503 LValue vector = poisonedVector; 3504 #endif 3498 LValue vector = m_out.loadPtr(cell, m_heaps.JSArrayBufferView_vector); 3505 3499 setStorage(caged(Gigacage::Primitive, vector)); 3506 3500 } … … 3541 3535 m_out.appendTo(wastefulCase, notNull); 3542 3536 3543 LValue poisonedVector = m_out.loadPtr(basePtr, m_heaps.JSArrayBufferView_poisonedVector);3544 ValueFromBlock nullVectorOut = m_out.anchor( poisonedVector);3545 m_out.branch( poisonedVector, unsure(notNull), unsure(continuation));3537 LValue vector = m_out.loadPtr(basePtr, m_heaps.JSArrayBufferView_vector); 3538 ValueFromBlock nullVectorOut = m_out.anchor(vector); 3539 m_out.branch(vector, unsure(notNull), unsure(continuation)); 3546 3540 3547 3541 m_out.appendTo(notNull, continuation); … … 3550 3544 LValue arrayBufferPtr = m_out.loadPtr(butterflyPtr, m_heaps.Butterfly_arrayBuffer); 3551 3545 3552 #if ENABLE(POISON) 3553 LValue jsType = m_out.load8ZeroExt32(basePtr, m_heaps.JSCell_typeInfoType); 3554 LValue typeIndex = m_out.sub(jsType, m_out.constInt32(FirstTypedArrayType)); 3555 LValue maskedTypeIndex = m_out.zeroExtPtr(m_out.bitAnd(typeIndex, m_out.constInt32(TypedArrayPoisonIndexMask))); 3556 LValue poisonsBasePtr = m_out.constIntPtr(&g_typedArrayPoisons); 3557 LValue poison = m_out.loadPtr(m_out.baseIndex(m_heaps.TypedArrayPoisons, poisonsBasePtr, maskedTypeIndex)); 3558 poisonedVector = m_out.bitXor(poisonedVector, poison); 3559 #endif 3560 LValue vectorPtr = caged(Gigacage::Primitive, poisonedVector); 3546 LValue vectorPtr = caged(Gigacage::Primitive, vector); 3561 3547 3562 3548 // FIXME: This needs caging. … … 5926 5912 allocateObject<JSArrayBufferView>(structure, m_out.intPtrZero, slowCase); 5927 5913 5928 #if ENABLE(POISON) 5929 storage = m_out.bitXor(m_out.constIntPtr(JSArrayBufferView::poisonFor(typedArrayType)), storage); 5930 #endif 5931 m_out.storePtr(storage, fastResultValue, m_heaps.JSArrayBufferView_poisonedVector); 5914 m_out.storePtr(storage, fastResultValue, m_heaps.JSArrayBufferView_vector); 5932 5915 m_out.store32(size, fastResultValue, m_heaps.JSArrayBufferView_length); 5933 5916 m_out.store32(m_out.constInt32(FastTypedArray), fastResultValue, m_heaps.JSArrayBufferView_mode); … … 15426 15409 15427 15410 LBasicBlock lastNext = m_out.appendTo(isWasteful, continuation); 15428 LValue vector = m_out.loadPtr(base, m_heaps.JSArrayBufferView_ poisonedVector);15411 LValue vector = m_out.loadPtr(base, m_heaps.JSArrayBufferView_vector); 15429 15412 speculate(Uncountable, jsValueValue(vector), m_node, m_out.isZero64(vector)); 15430 15413 m_out.jump(continuation); -
trunk/Source/JavaScriptCore/jit/IntrinsicEmitter.cpp
r229087 r230273 1 1 /* 2 * Copyright (C) 2015-201 8Apple Inc. All rights reserved.2 * Copyright (C) 2015-2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 108 108 GPRReg scratchGPR = state.scratchGPR; 109 109 110 CCallHelpers::Jump notEmptyByteOffset = jit.branch32(111 MacroAssembler:: Equal,110 CCallHelpers::Jump emptyByteOffset = jit.branch32( 111 MacroAssembler::NotEqual, 112 112 MacroAssembler::Address(baseGPR, JSArrayBufferView::offsetOfMode()), 113 113 TrustedImm32(WastefulTypedArray)); 114 114 115 jit.move(TrustedImmPtr(nullptr), valueGPR);116 CCallHelpers::Jump done = jit.jump();117 118 notEmptyByteOffset.link(&jit);119 120 // We need to load the butterfly before the vector because baseGPR and valueGPR121 // can be the same register.122 115 jit.loadPtr(MacroAssembler::Address(baseGPR, JSObject::butterflyOffset()), scratchGPR); 123 jit.loadPtr(MacroAssembler::Address(baseGPR, JSArrayBufferView::offsetOfPoisonedVector()), valueGPR); 124 CCallHelpers::Jump nullVector = jit.branchTestPtr(MacroAssembler::Zero, valueGPR); 125 126 #if ENABLE(POISON) 127 auto typedArrayType = structure()->classInfo()->typedArrayStorageType; 128 jit.xorPtr(TrustedImmPtr(JSArrayBufferView::poisonFor(typedArrayType)), valueGPR); 129 #endif 116 jit.loadPtr(MacroAssembler::Address(baseGPR, JSArrayBufferView::offsetOfVector()), valueGPR); 130 117 jit.loadPtr(MacroAssembler::Address(scratchGPR, Butterfly::offsetOfArrayBuffer()), scratchGPR); 131 118 jit.loadPtr(MacroAssembler::Address(scratchGPR, ArrayBuffer::offsetOfData()), scratchGPR); 132 119 jit.subPtr(scratchGPR, valueGPR); 133 120 134 nullVector.link(&jit); 121 CCallHelpers::Jump done = jit.jump(); 122 123 emptyByteOffset.link(&jit); 124 jit.move(TrustedImmPtr(nullptr), valueGPR); 125 135 126 done.link(&jit); 136 127 -
trunk/Source/JavaScriptCore/jit/JITPropertyAccess.cpp
r230266 r230273 1 1 /* 2 * Copyright (C) 2008-201 8Apple Inc. All rights reserved.2 * Copyright (C) 2008-2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 1461 1461 } 1462 1462 1463 JIT::JumpList JIT::emitIntTypedArrayGetByVal(Instruction*, PatchableJump& badType, TypedArrayType type ArrayType)1464 { 1465 ASSERT(isInt(type ArrayType));1463 JIT::JumpList JIT::emitIntTypedArrayGetByVal(Instruction*, PatchableJump& badType, TypedArrayType type) 1464 { 1465 ASSERT(isInt(type)); 1466 1466 1467 1467 // The best way to test the array type is to use the classInfo. We need to do so without … … 1484 1484 1485 1485 JumpList slowCases; 1486 JSType jsType = typeForTypedArrayType(typeArrayType); 1487 1486 1488 1487 load8(Address(base, JSCell::typeInfoTypeOffset()), scratch); 1489 badType = patchableBranch32(NotEqual, scratch, TrustedImm32( jsType));1488 badType = patchableBranch32(NotEqual, scratch, TrustedImm32(typeForTypedArrayType(type))); 1490 1489 slowCases.append(branch32(AboveOrEqual, property, Address(base, JSArrayBufferView::offsetOfLength()))); 1491 loadPtr(Address(base, JSArrayBufferView::offsetOfPoisonedVector()), scratch); 1492 #if ENABLE(POISON) 1493 xorPtr(TrustedImmPtr(JSArrayBufferView::poisonFor(jsType)), scratch); 1494 #endif 1490 loadPtr(Address(base, JSArrayBufferView::offsetOfVector()), scratch); 1495 1491 cageConditionally(Gigacage::Primitive, scratch, scratch2); 1496 1492 1497 switch (elementSize(type ArrayType)) {1493 switch (elementSize(type)) { 1498 1494 case 1: 1499 if (JSC::isSigned(type ArrayType))1495 if (JSC::isSigned(type)) 1500 1496 load8SignedExtendTo32(BaseIndex(scratch, property, TimesOne), resultPayload); 1501 1497 else … … 1503 1499 break; 1504 1500 case 2: 1505 if (JSC::isSigned(type ArrayType))1501 if (JSC::isSigned(type)) 1506 1502 load16SignedExtendTo32(BaseIndex(scratch, property, TimesTwo), resultPayload); 1507 1503 else … … 1516 1512 1517 1513 Jump done; 1518 if (type ArrayType== TypeUint32) {1514 if (type == TypeUint32) { 1519 1515 Jump canBeInt = branch32(GreaterThanOrEqual, resultPayload, TrustedImm32(0)); 1520 1516 … … 1542 1538 } 1543 1539 1544 JIT::JumpList JIT::emitFloatTypedArrayGetByVal(Instruction*, PatchableJump& badType, TypedArrayType type ArrayType)1545 { 1546 ASSERT(isFloat(type ArrayType));1540 JIT::JumpList JIT::emitFloatTypedArrayGetByVal(Instruction*, PatchableJump& badType, TypedArrayType type) 1541 { 1542 ASSERT(isFloat(type)); 1547 1543 1548 1544 #if USE(JSVALUE64) … … 1562 1558 1563 1559 JumpList slowCases; 1564 JSType jsType = typeForTypedArrayType(typeArrayType);1565 1560 1566 1561 load8(Address(base, JSCell::typeInfoTypeOffset()), scratch); 1567 badType = patchableBranch32(NotEqual, scratch, TrustedImm32( jsType));1562 badType = patchableBranch32(NotEqual, scratch, TrustedImm32(typeForTypedArrayType(type))); 1568 1563 slowCases.append(branch32(AboveOrEqual, property, Address(base, JSArrayBufferView::offsetOfLength()))); 1569 loadPtr(Address(base, JSArrayBufferView::offsetOfPoisonedVector()), scratch); 1570 #if ENABLE(POISON) 1571 xorPtr(TrustedImmPtr(JSArrayBufferView::poisonFor(jsType)), scratch); 1572 #endif 1564 loadPtr(Address(base, JSArrayBufferView::offsetOfVector()), scratch); 1573 1565 cageConditionally(Gigacage::Primitive, scratch, scratch2); 1574 1566 1575 switch (elementSize(type ArrayType)) {1567 switch (elementSize(type)) { 1576 1568 case 4: 1577 1569 loadFloat(BaseIndex(scratch, property, TimesFour), fpRegT0); … … 1600 1592 } 1601 1593 1602 JIT::JumpList JIT::emitIntTypedArrayPutByVal(Instruction* currentInstruction, PatchableJump& badType, TypedArrayType type ArrayType)1594 JIT::JumpList JIT::emitIntTypedArrayPutByVal(Instruction* currentInstruction, PatchableJump& badType, TypedArrayType type) 1603 1595 { 1604 1596 ArrayProfile* profile = currentInstruction[4].u.arrayProfile; 1605 ASSERT(isInt(type ArrayType));1597 ASSERT(isInt(type)); 1606 1598 1607 1599 int value = currentInstruction[3].u.operand; … … 1622 1614 1623 1615 JumpList slowCases; 1624 JSType jsType = typeForTypedArrayType(typeArrayType); 1625 1616 1626 1617 load8(Address(base, JSCell::typeInfoTypeOffset()), earlyScratch); 1627 badType = patchableBranch32(NotEqual, earlyScratch, TrustedImm32( jsType));1618 badType = patchableBranch32(NotEqual, earlyScratch, TrustedImm32(typeForTypedArrayType(type))); 1628 1619 Jump inBounds = branch32(Below, property, Address(base, JSArrayBufferView::offsetOfLength())); 1629 1620 emitArrayProfileOutOfBoundsSpecialCase(profile); … … 1641 1632 // We would be loading this into base as in get_by_val, except that the slow 1642 1633 // path expects the base to be unclobbered. 1643 loadPtr(Address(base, JSArrayBufferView::offsetOfPoisonedVector()), lateScratch); 1644 #if ENABLE(POISON) 1645 xorPtr(TrustedImmPtr(JSArrayBufferView::poisonFor(jsType)), lateScratch); 1646 #endif 1634 loadPtr(Address(base, JSArrayBufferView::offsetOfVector()), lateScratch); 1647 1635 cageConditionally(Gigacage::Primitive, lateScratch, lateScratch2); 1648 1636 1649 if (isClamped(type ArrayType)) {1650 ASSERT(elementSize(type ArrayType) == 1);1651 ASSERT(!JSC::isSigned(type ArrayType));1637 if (isClamped(type)) { 1638 ASSERT(elementSize(type) == 1); 1639 ASSERT(!JSC::isSigned(type)); 1652 1640 Jump inBounds = branch32(BelowOrEqual, earlyScratch, TrustedImm32(0xff)); 1653 1641 Jump tooBig = branch32(GreaterThan, earlyScratch, TrustedImm32(0xff)); … … 1660 1648 } 1661 1649 1662 switch (elementSize(type ArrayType)) {1650 switch (elementSize(type)) { 1663 1651 case 1: 1664 1652 store8(earlyScratch, BaseIndex(lateScratch, property, TimesOne)); … … 1677 1665 } 1678 1666 1679 JIT::JumpList JIT::emitFloatTypedArrayPutByVal(Instruction* currentInstruction, PatchableJump& badType, TypedArrayType type ArrayType)1667 JIT::JumpList JIT::emitFloatTypedArrayPutByVal(Instruction* currentInstruction, PatchableJump& badType, TypedArrayType type) 1680 1668 { 1681 1669 ArrayProfile* profile = currentInstruction[4].u.arrayProfile; 1682 ASSERT(isFloat(type ArrayType));1670 ASSERT(isFloat(type)); 1683 1671 1684 1672 int value = currentInstruction[3].u.operand; … … 1699 1687 1700 1688 JumpList slowCases; 1701 JSType jsType = typeForTypedArrayType(typeArrayType); 1702 1689 1703 1690 load8(Address(base, JSCell::typeInfoTypeOffset()), earlyScratch); 1704 badType = patchableBranch32(NotEqual, earlyScratch, TrustedImm32( jsType));1691 badType = patchableBranch32(NotEqual, earlyScratch, TrustedImm32(typeForTypedArrayType(type))); 1705 1692 Jump inBounds = branch32(Below, property, Address(base, JSArrayBufferView::offsetOfLength())); 1706 1693 emitArrayProfileOutOfBoundsSpecialCase(profile); … … 1731 1718 // We would be loading this into base as in get_by_val, except that the slow 1732 1719 // path expects the base to be unclobbered. 1733 loadPtr(Address(base, JSArrayBufferView::offsetOfPoisonedVector()), lateScratch); 1734 #if ENABLE(POISON) 1735 xorPtr(TrustedImmPtr(JSArrayBufferView::poisonFor(jsType)), lateScratch); 1736 #endif 1720 loadPtr(Address(base, JSArrayBufferView::offsetOfVector()), lateScratch); 1737 1721 cageConditionally(Gigacage::Primitive, lateScratch, lateScratch2); 1738 1722 1739 switch (elementSize(type ArrayType)) {1723 switch (elementSize(type)) { 1740 1724 case 4: 1741 1725 convertDoubleToFloat(fpRegT0, fpRegT0); -
trunk/Source/JavaScriptCore/llint/LowLevelInterpreter.asm
r230266 r230273 404 404 const FirstTypedArrayType = constexpr FirstTypedArrayType 405 405 const NumberOfTypedArrayTypesExcludingDataView = constexpr NumberOfTypedArrayTypesExcludingDataView 406 const TypedArrayPoisonIndexMask = constexpr TypedArrayPoisonIndexMask407 406 408 407 # Type flags constants. -
trunk/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm
r230266 r230273 392 392 end 393 393 394 macro loadTypedArrayCaged(basePtr, mask, source, typeIndex, dest, scratch)395 if POISON396 leap _g_typedArrayPoisons, dest397 loadp (typeIndex - FirstTypedArrayType) * 8[dest], dest398 loadp source, scratch399 xorp scratch, dest400 else401 loadp source, dest402 end403 uncage(basePtr, mask, dest, scratch)404 end405 406 394 macro loadVariable(operand, value) 407 395 loadisFromInstruction(operand, value) … … 1637 1625 1638 1626 # We have Int8ArrayType. 1639 load TypedArrayCaged(_g_gigacageBasePtrs + Gigacage::BasePtrs::primitive, constexpr PRIMITIVE_GIGACAGE_MASK, JSArrayBufferView::m_poisonedVector[t0], Int8ArrayType, t3, t2)1627 loadCaged(_g_gigacageBasePtrs + Gigacage::BasePtrs::primitive, constexpr PRIMITIVE_GIGACAGE_MASK, JSArrayBufferView::m_vector[t0], t3, t2) 1640 1628 loadbs [t3, t1], t0 1641 1629 finishIntGetByVal(t0, t1) … … 1645 1633 1646 1634 # We have Uint8ArrayType. 1647 load TypedArrayCaged(_g_gigacageBasePtrs + Gigacage::BasePtrs::primitive, constexpr PRIMITIVE_GIGACAGE_MASK, JSArrayBufferView::m_poisonedVector[t0], Uint8ArrayType, t3, t2)1635 loadCaged(_g_gigacageBasePtrs + Gigacage::BasePtrs::primitive, constexpr PRIMITIVE_GIGACAGE_MASK, JSArrayBufferView::m_vector[t0], t3, t2) 1648 1636 loadb [t3, t1], t0 1649 1637 finishIntGetByVal(t0, t1) … … 1651 1639 .opGetByValUint8ClampedArray: 1652 1640 # We have Uint8ClampedArrayType. 1653 load TypedArrayCaged(_g_gigacageBasePtrs + Gigacage::BasePtrs::primitive, constexpr PRIMITIVE_GIGACAGE_MASK, JSArrayBufferView::m_poisonedVector[t0], Uint8ClampedArrayType, t3, t2)1641 loadCaged(_g_gigacageBasePtrs + Gigacage::BasePtrs::primitive, constexpr PRIMITIVE_GIGACAGE_MASK, JSArrayBufferView::m_vector[t0], t3, t2) 1654 1642 loadb [t3, t1], t0 1655 1643 finishIntGetByVal(t0, t1) … … 1660 1648 1661 1649 # We have Int16ArrayType. 1662 load TypedArrayCaged(_g_gigacageBasePtrs + Gigacage::BasePtrs::primitive, constexpr PRIMITIVE_GIGACAGE_MASK, JSArrayBufferView::m_poisonedVector[t0], Int16ArrayType, t3, t2)1650 loadCaged(_g_gigacageBasePtrs + Gigacage::BasePtrs::primitive, constexpr PRIMITIVE_GIGACAGE_MASK, JSArrayBufferView::m_vector[t0], t3, t2) 1663 1651 loadhs [t3, t1, 2], t0 1664 1652 finishIntGetByVal(t0, t1) … … 1666 1654 .opGetByValUint16Array: 1667 1655 # We have Uint16ArrayType. 1668 load TypedArrayCaged(_g_gigacageBasePtrs + Gigacage::BasePtrs::primitive, constexpr PRIMITIVE_GIGACAGE_MASK, JSArrayBufferView::m_poisonedVector[t0], Uint16ArrayType, t3, t2)1656 loadCaged(_g_gigacageBasePtrs + Gigacage::BasePtrs::primitive, constexpr PRIMITIVE_GIGACAGE_MASK, JSArrayBufferView::m_vector[t0], t3, t2) 1669 1657 loadh [t3, t1, 2], t0 1670 1658 finishIntGetByVal(t0, t1) … … 1678 1666 1679 1667 # We have Int32ArrayType. 1680 load TypedArrayCaged(_g_gigacageBasePtrs + Gigacage::BasePtrs::primitive, constexpr PRIMITIVE_GIGACAGE_MASK, JSArrayBufferView::m_poisonedVector[t0], Int32ArrayType, t3, t2)1668 loadCaged(_g_gigacageBasePtrs + Gigacage::BasePtrs::primitive, constexpr PRIMITIVE_GIGACAGE_MASK, JSArrayBufferView::m_vector[t0], t3, t2) 1681 1669 loadi [t3, t1, 4], t0 1682 1670 finishIntGetByVal(t0, t1) … … 1684 1672 .opGetByValUint32Array: 1685 1673 # We have Uint32ArrayType. 1686 load TypedArrayCaged(_g_gigacageBasePtrs + Gigacage::BasePtrs::primitive, constexpr PRIMITIVE_GIGACAGE_MASK, JSArrayBufferView::m_poisonedVector[t0], Uint32ArrayType, t3, t2)1674 loadCaged(_g_gigacageBasePtrs + Gigacage::BasePtrs::primitive, constexpr PRIMITIVE_GIGACAGE_MASK, JSArrayBufferView::m_vector[t0], t3, t2) 1687 1675 # This is the hardest part because of large unsigned values. 1688 1676 loadi [t3, t1, 4], t0 … … 1696 1684 1697 1685 # We have Float64ArrayType. 1698 load TypedArrayCaged(_g_gigacageBasePtrs + Gigacage::BasePtrs::primitive, constexpr PRIMITIVE_GIGACAGE_MASK, JSArrayBufferView::m_poisonedVector[t0], Float64ArrayType, t3, t2)1686 loadCaged(_g_gigacageBasePtrs + Gigacage::BasePtrs::primitive, constexpr PRIMITIVE_GIGACAGE_MASK, JSArrayBufferView::m_vector[t0], t3, t2) 1699 1687 loadd [t3, t1, 8], ft0 1700 1688 bdnequn ft0, ft0, .opGetByValSlow -
trunk/Source/JavaScriptCore/offlineasm/arm64.rb
r228402 r230273 273 273 newList << Instruction.new(codeOrigin, "globaladdr", [LabelReference.new(node.codeOrigin, labelRef.label), tmp]) 274 274 newList << Instruction.new(codeOrigin, node.opcode, [Address.new(node.codeOrigin, tmp, Immediate.new(node.codeOrigin, labelRef.offset)), node.operands[1]]) 275 else276 newList << node277 end278 when "leai", "leap", "leaq"279 labelRef = node.operands[0]280 if labelRef.is_a? LabelReference281 newList << Instruction.new(codeOrigin, "globaladdr", [LabelReference.new(node.codeOrigin, labelRef.label), node.operands[1]])282 275 else 283 276 newList << node -
trunk/Source/JavaScriptCore/offlineasm/x86.rb
r229912 r230273 468 468 $asm.puts "movq #{asmLabel}@GOTPCREL(%rip), #{dst.x86Operand(:ptr)}" 469 469 "#{offset}(#{dst.x86Operand(kind)})" 470 end471 def x86AddressOperand(addressKind)472 # FIXME: Implement this on platforms that aren't Mach-O.473 # https://bugs.webkit.org/show_bug.cgi?id=175104474 "#{asmLabel}@GOTPCREL(%rip)"475 470 end 476 471 end … … 1552 1547 $asm.puts "jnz #{operands[0].asmLabel}" 1553 1548 when "leai" 1554 emitX86Lea(operands[0], operands[1], :int)1549 $asm.puts "lea#{x86Suffix(:int)} #{orderOperands(operands[0].x86AddressOperand(:int), operands[1].x86Operand(:int))}" 1555 1550 when "leap" 1556 emitX86Lea(operands[0], operands[1], :ptr)1551 $asm.puts "lea#{x86Suffix(:ptr)} #{orderOperands(operands[0].x86AddressOperand(:ptr), operands[1].x86Operand(:ptr))}" 1557 1552 when "memfence" 1558 1553 sp = RegisterID.new(nil, "sp") -
trunk/Source/JavaScriptCore/runtime/CagedBarrierPtr.h
r227874 r230273 1 1 /* 2 * Copyright (C) 2017 -2018Apple Inc. All rights reserved.2 * Copyright (C) 2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 27 27 28 28 #include "AuxiliaryBarrier.h" 29 #include <type_traits>30 29 #include <wtf/CagedPtr.h> 31 32 namespace WTF {33 34 template<typename Poison, typename T> struct PoisonedPtrTraits;35 36 } // namespace WTF37 30 38 31 namespace JSC { … … 43 36 // This is a convenient combo of AuxiliaryBarrier and CagedPtr. 44 37 45 template<Gigacage::Kind passedKind, typename T , typename PtrTraits = WTF::DumbPtrTraits<T>>38 template<Gigacage::Kind passedKind, typename T> 46 39 class CagedBarrierPtr { 47 40 public: … … 93 86 94 87 private: 95 AuxiliaryBarrier<CagedPtr<kind, T , PtrTraits>> m_barrier;88 AuxiliaryBarrier<CagedPtr<kind, T>> m_barrier; 96 89 }; 97 90 98 template<Gigacage::Kind passedKind , typename PtrTraits>99 class CagedBarrierPtr<passedKind, void , PtrTraits> {91 template<Gigacage::Kind passedKind> 92 class CagedBarrierPtr<passedKind, void> { 100 93 public: 101 94 static constexpr Gigacage::Kind kind = passedKind; … … 140 133 141 134 private: 142 AuxiliaryBarrier<CagedPtr<kind, void , PtrTraits>> m_barrier;135 AuxiliaryBarrier<CagedPtr<kind, void>> m_barrier; 143 136 }; 144 137 145 template<typename Poison, Gigacage::Kind passedKind, typename T>146 using PoisonedCagedBarrierPtr = CagedBarrierPtr<passedKind, T, WTF::PoisonedPtrTraits<Poison, T>>;147 148 138 } // namespace JSC -
trunk/Source/JavaScriptCore/runtime/JSArrayBufferView.cpp
r230144 r230273 1 1 /* 2 * Copyright (C) 2013-201 8Apple Inc. All rights reserved.2 * Copyright (C) 2013-2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 133 133 { 134 134 setButterfly(vm, context.butterfly()); 135 m_ poisonedVector.setWithoutBarrier(context.vector());135 m_vector.setWithoutBarrier(context.vector()); 136 136 } 137 137 … … 195 195 ASSERT(thisObject->m_mode == OversizeTypedArray || thisObject->m_mode == WastefulTypedArray); 196 196 if (thisObject->m_mode == OversizeTypedArray) 197 Gigacage::free(Gigacage::Primitive, thisObject->m_ poisonedVector.get());197 Gigacage::free(Gigacage::Primitive, thisObject->m_vector.get()); 198 198 } 199 199 … … 213 213 RELEASE_ASSERT(!isShared()); 214 214 m_length = 0; 215 m_ poisonedVector.clear();215 m_vector.clear(); 216 216 } 217 217 -
trunk/Source/JavaScriptCore/runtime/JSArrayBufferView.h
r227874 r230273 1 1 /* 2 * Copyright (C) 2013 -2018Apple Inc. All rights reserved.2 * Copyright (C) 2013, 2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 27 27 28 28 #include "AuxiliaryBarrier.h" 29 #include "CagedBarrierPtr.h"30 #include "JSCPoison.h"31 29 #include "JSObject.h" 32 #include "TypedArrayType.h"33 #include <wtf/MathExtras.h>34 30 35 31 namespace JSC { 36 32 37 33 class LLIntOffsetsExtractor; 38 39 // Since we'll be indexing into the g_typedArrayPoisons array based on the TypedArray type,40 // we'll index mask the index value and round up to the array size to the next power of 2 to41 // ensure that we'll never be able to access beyond the bounds of this array.42 static constexpr uint32_t NumberOfTypedArrayPoisons = WTF::roundUpToPowerOfTwo(NumberOfTypedArrayTypes);43 static constexpr uint32_t TypedArrayPoisonIndexMask = NumberOfTypedArrayPoisons - 1;44 34 45 35 // This class serves two purposes: … … 178 168 void neuter(); 179 169 180 void* vector() const { return m_ poisonedVector.getMayBeNull(); }170 void* vector() const { return m_vector.getMayBeNull(); } 181 171 182 172 unsigned byteOffset(); … … 185 175 DECLARE_EXPORT_INFO; 186 176 187 static ptrdiff_t offsetOf PoisonedVector() { return OBJECT_OFFSETOF(JSArrayBufferView, m_poisonedVector); }177 static ptrdiff_t offsetOfVector() { return OBJECT_OFFSETOF(JSArrayBufferView, m_vector); } 188 178 static ptrdiff_t offsetOfLength() { return OBJECT_OFFSETOF(JSArrayBufferView, m_length); } 189 179 static ptrdiff_t offsetOfMode() { return OBJECT_OFFSETOF(JSArrayBufferView, m_mode); } … … 191 181 static RefPtr<ArrayBufferView> toWrapped(VM&, JSValue); 192 182 193 static uintptr_t poisonFor(JSType type)194 {195 return g_typedArrayPoisons[(type - FirstTypedArrayType) & TypedArrayPoisonIndexMask];196 }197 198 static uintptr_t poisonFor(TypedArrayType typedArrayType)199 {200 ASSERT(isTypedView(typedArrayType));201 return poisonFor(typeForTypedArrayType(typedArrayType));202 }203 204 183 private: 205 184 static void finalize(JSCell*); … … 212 191 static String toStringName(const JSObject*, ExecState*); 213 192 214 class Poison { 215 public: 216 template<typename PoisonedType> 217 inline static uintptr_t key(const PoisonedType* poisonedPtr) 218 { 219 uintptr_t poisonedVectorAddress = bitwise_cast<uintptr_t>(poisonedPtr); 220 uintptr_t baseAddress = poisonedVectorAddress - OBJECT_OFFSETOF(JSArrayBufferView, m_poisonedVector); 221 JSArrayBufferView* thisObject = bitwise_cast<JSArrayBufferView*>(baseAddress); 222 return poisonFor(thisObject->type()); 223 } 224 }; 225 226 PoisonedCagedBarrierPtr<Poison, Gigacage::Primitive, void> m_poisonedVector; 193 CagedBarrierPtr<Gigacage::Primitive, void> m_vector; 227 194 uint32_t m_length; 228 195 TypedArrayMode m_mode; -
trunk/Source/JavaScriptCore/runtime/JSCPoison.cpp
r227874 r230273 27 27 #include "JSCPoison.h" 28 28 29 #include "JSArrayBufferView.h"30 29 #include "Options.h" 31 30 #include <mutex> … … 37 36 uintptr_t POISON_KEY_NAME(poisonID); 38 37 FOR_EACH_JSC_POISON(DEFINE_POISON) 39 40 uintptr_t g_typedArrayPoisons[NumberOfTypedArrayPoisons];41 38 42 39 void initializePoison() … … 51 48 52 49 FOR_EACH_JSC_POISON(INITIALIZE_POISON) 53 54 for (uint32_t i = 0; i < NumberOfTypedArrayPoisons; ++i)55 g_typedArrayPoisons[i] = makePoison();56 50 }); 57 51 } -
trunk/Source/JavaScriptCore/runtime/JSCPoison.h
r230266 r230273 67 67 #undef DECLARE_POISON 68 68 69 extern "C" JS_EXPORT_PRIVATE uintptr_t g_typedArrayPoisons[];70 71 69 struct ClassInfo; 72 70 -
trunk/Source/JavaScriptCore/runtime/JSGenericTypedArrayViewInlines.h
r230144 r230273 1 1 /* 2 * Copyright (C) 2013 -2018Apple Inc. All rights reserved.2 * Copyright (C) 2013, 2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 505 505 if (thisObject->m_mode == OversizeTypedArray) 506 506 return Base::estimatedSize(thisObject) + thisObject->byteSize(); 507 if (thisObject->m_mode == FastTypedArray && thisObject->m_ poisonedVector)507 if (thisObject->m_mode == FastTypedArray && thisObject->m_vector) 508 508 return Base::estimatedSize(thisObject) + thisObject->byteSize(); 509 509 … … 518 518 switch (thisObject->m_mode) { 519 519 case FastTypedArray: { 520 if (void* vector = thisObject->m_ poisonedVector.getMayBeNull())520 if (void* vector = thisObject->m_vector.getMayBeNull()) 521 521 visitor.markAuxiliary(vector); 522 522 break; … … 585 585 586 586 thisObject->butterfly()->indexingHeader()->setArrayBuffer(buffer.get()); 587 thisObject->m_ poisonedVector.setWithoutBarrier(buffer->data());587 thisObject->m_vector.setWithoutBarrier(buffer->data()); 588 588 WTF::storeStoreFence(); 589 589 thisObject->m_mode = WastefulTypedArray; -
trunk/Source/JavaScriptCore/runtime/JSObject.h
r230144 r230273 25 25 #include "ArrayConventions.h" 26 26 #include "ArrayStorage.h" 27 #include "AuxiliaryBarrier.h"28 27 #include "Butterfly.h" 29 28 #include "CPU.h" 29 #include "CagedBarrierPtr.h" 30 30 #include "CallFrame.h" 31 31 #include "ClassInfo.h"
Note: See TracChangeset
for help on using the changeset viewer.