Changeset 227434 in webkit
- Timestamp:
- Jan 23, 2018, 12:39:34 PM (7 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r227431 r227434 1 2018-01-23 Mark Lam <mark.lam@apple.com> 2 3 Re-arrange TypedArray JSTypes to match the order of the TypedArrayType enum list. 4 https://bugs.webkit.org/show_bug.cgi?id=181976 5 <rdar://problem/36766936> 6 7 Reviewed by Filip Pizlo. 8 9 1. The order of TypedArray JSTypes now matches the order the TypedArrayType enum 10 list. I also added static asserts in TypedArrayType.h to enforce this. 11 12 Also redefined FOR_EACH_TYPED_ARRAY_TYPE() in terms of 13 14 2. Define 4 new values: 15 a. FirstTypedArrayType 16 b. LastTypedArrayType 17 c. NumberOfTypedArrayTypesExcludingDataView 18 d. NumberOfTypedArrayTypes 19 20 Use these everywhere where we iterate or bisect the TypedArray JSTypes. 21 22 3. Removed NUMBER_OF_TYPED_ARRAY_TYPES, and use NumberOfTypedArrayTypes instead. 23 24 4. Simplify the code that converts between TypedArrayType and JSType. 25 26 Changed typedArrayTypeForType() to be the mirror image of typeForTypedArrayType(). 27 Previously, typedArrayTypeForType() converts DataViewType to NotTypedArray 28 instead of TypeDataView. Now, it converts to TypeDataView. 29 30 This does not result in any change of behavior because typedArrayTypeForType() 31 is only called in Structure::hasIndexingHeader(), and its result is passed to 32 isTypedView(), which handles TypeDataView correctly. 33 34 5. Also fixed a bug in SpeculativeJIT::compileGetTypedArrayByteOffset(). 35 If the vector is null, we can skip the rest of the checks. While the current 36 code does not result in incorrect behavior, it is inefficient, and communicates 37 wrong information to the reader i.e. implying that there's something in the 38 dataGPR when there's not. The dataGPR should also be null in this case. 39 40 * dfg/DFGByteCodeParser.cpp: 41 (JSC::DFG::ByteCodeParser::handleConstantInternalFunction): 42 * dfg/DFGSpeculativeJIT.cpp: 43 (JSC::DFG::SpeculativeJIT::compileIsTypedArrayView): 44 (JSC::DFG::SpeculativeJIT::compileGetTypedArrayByteOffset): 45 * ftl/FTLLowerDFGToB3.cpp: 46 (JSC::FTL::DFG::LowerDFGToB3::isTypedArrayView): 47 * ftl/FTLOSRExit.cpp: 48 * llint/LowLevelInterpreter.asm: 49 * llint/LowLevelInterpreter64.asm: 50 * runtime/JSGlobalObject.cpp: 51 (JSC::JSGlobalObject::visitChildren): 52 * runtime/JSType.h: 53 * runtime/TypedArrayType.cpp: 54 (JSC::typeForTypedArrayType): Deleted. 55 * runtime/TypedArrayType.h: 56 (JSC::typedArrayTypeForType): 57 (JSC::typeForTypedArrayType): 58 1 59 2018-01-23 Filip Pizlo <fpizlo@apple.com> 2 60 -
trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp
r227431 r227434 3441 3441 } 3442 3442 3443 for (unsigned typeIndex = 0; typeIndex < N UMBER_OF_TYPED_ARRAY_TYPES; ++typeIndex) {3443 for (unsigned typeIndex = 0; typeIndex < NumberOfTypedArrayTypes; ++typeIndex) { 3444 3444 bool result = handleTypedArrayConstructor( 3445 3445 resultOperand, function, registerOffset, argumentCountIncludingThis, -
trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp
r227410 r227434 4034 4034 4035 4035 m_jit.load8(JITCompiler::Address(valueRegs.payloadGPR(), JSCell::typeInfoTypeOffset()), resultGPR); 4036 m_jit.sub32(TrustedImm32( Int8ArrayType), resultGPR);4037 m_jit.compare32(JITCompiler::Below OrEqual,4036 m_jit.sub32(TrustedImm32(FirstTypedArrayType), resultGPR); 4037 m_jit.compare32(JITCompiler::Below, 4038 4038 resultGPR, 4039 TrustedImm32( Float64ArrayType - Int8ArrayType),4039 TrustedImm32(NumberOfTypedArrayTypesExcludingDataView), 4040 4040 resultGPR); 4041 4041 blessBoolean(resultGPR); … … 6388 6388 JITCompiler::Jump nullVector = m_jit.branchTestPtr(JITCompiler::Zero, vectorGPR); 6389 6389 cageTypedArrayStorage(vectorGPR); 6390 nullVector.link(&m_jit); 6390 6391 6391 m_jit.loadPtr(MacroAssembler::Address(dataGPR, Butterfly::offsetOfArrayBuffer()), dataGPR); 6392 6392 // FIXME: This needs caging. … … 6401 6401 6402 6402 done.link(&m_jit); 6403 nullVector.link(&m_jit); 6403 6404 6404 6405 int32Result(vectorGPR, node); -
trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp
r227410 r227434 14388 14388 LValue jsType = m_out.sub( 14389 14389 m_out.load8ZeroExt32(cell, m_heaps.JSCell_typeInfoType), 14390 m_out.constInt32( Int8ArrayType));14391 return m_out.below OrEqual(14390 m_out.constInt32(FirstTypedArrayType)); 14391 return m_out.below( 14392 14392 jsType, 14393 m_out.constInt32( Float64ArrayType - Int8ArrayType));14393 m_out.constInt32(NumberOfTypedArrayTypesExcludingDataView)); 14394 14394 } 14395 14395 -
trunk/Source/JavaScriptCore/ftl/FTLOSRExit.cpp
r201182 r227434 119 119 #endif // ENABLE(FTL_JIT) 120 120 121 -
trunk/Source/JavaScriptCore/llint/LowLevelInterpreter.asm
r226940 r227434 384 384 # switch statement in get_by_val and put_by_val. 385 385 const Int8ArrayType = constexpr Int8ArrayType 386 const Int16ArrayType = constexpr Int16ArrayType387 const Int32ArrayType = constexpr Int32ArrayType388 386 const Uint8ArrayType = constexpr Uint8ArrayType 389 387 const Uint8ClampedArrayType = constexpr Uint8ClampedArrayType 388 const Int16ArrayType = constexpr Int16ArrayType 390 389 const Uint16ArrayType = constexpr Uint16ArrayType 390 const Int32ArrayType = constexpr Int32ArrayType 391 391 const Uint32ArrayType = constexpr Uint32ArrayType 392 392 const Float32ArrayType = constexpr Float32ArrayType 393 393 const Float64ArrayType = constexpr Float64ArrayType 394 394 395 const FirstArrayType = Int8ArrayType396 const LastArrayType = Float64ArrayType395 const FirstArrayType = constexpr FirstTypedArrayType 396 const NumberOfTypedArrayTypesExcludingDataView = constexpr NumberOfTypedArrayTypesExcludingDataView 397 397 398 398 # Type flags constants. -
trunk/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm
r226940 r227434 1539 1539 loadb JSCell::m_type[t0], t2 1540 1540 subi FirstArrayType, t2 1541 bia t2, LastArrayType - FirstArrayType, .opGetByValSlow1541 biaeq t2, NumberOfTypedArrayTypesExcludingDataView, .opGetByValSlow 1542 1542 1543 1543 # Sweet, now we know that we have a typed array. Do some basic things now. … … 1545 1545 biaeq t1, JSArrayBufferView::m_length[t0], .opGetByValSlow 1546 1546 1547 # Now bisect through the various types. Note that we can treat Uint8ArrayType and 1548 # Uint8ClampedArrayType the same. 1549 bia t2, Uint8ClampedArrayType - FirstArrayType, .opGetByValAboveUint8ClampedArray 1550 1551 # We have one of Int8ArrayType .. Uint8ClampedArrayType. 1552 bia t2, Int16ArrayType - FirstArrayType, .opGetByValInt32ArrayOrUint8Array 1553 1554 # We have one of Int8ArrayType or Int16ArrayType 1555 bineq t2, Int8ArrayType - FirstArrayType, .opGetByValInt16Array 1556 1547 # Now bisect through the various types: 1548 # Int8ArrayType, 1549 # Uint8ArrayType, 1550 # Uint8ClampedArrayType, 1551 # Int16ArrayType, 1552 # Uint16ArrayType, 1553 # Int32ArrayType, 1554 # Uint32ArrayType, 1555 # Float32ArrayType, 1556 # Float64ArrayType, 1557 1558 bia t2, Uint16ArrayType - FirstArrayType, .opGetByValAboveUint16Array 1559 1560 # We have one of Int8ArrayType .. Uint16ArrayType. 1561 bia t2, Uint8ClampedArrayType - FirstArrayType, .opGetByValInt16ArrayOrUint16Array 1562 1563 # We have one of Int8ArrayType ... Uint8ClampedArrayType 1564 bineq t2, Int8ArrayType - FirstArrayType, .opGetByValUint8ArrayOrUint8ClampedArray 1565 1557 1566 # We have Int8ArrayType 1558 1567 loadbs [t3, t1], t0 1559 1568 finishIntGetByVal(t0, t1) 1560 1569 1561 .opGetByValInt16Array: 1570 .opGetByValUint8ArrayOrUint8ClampedArray: 1571 # We have either Uint8ArrayType or Uint8ClampedArrayType. They behave the same so that's cool. 1572 loadb [t3, t1], t0 1573 finishIntGetByVal(t0, t1) 1574 1575 .opGetByValInt16ArrayOrUint16Array: 1576 # We have either Int16ArrayType or Uint16ClampedArrayType. 1577 bieq t2, Uint16ArrayType - FirstArrayType, .opGetByValUint16Array 1578 1579 # We have Int16ArrayType. 1562 1580 loadhs [t3, t1, 2], t0 1563 1581 finishIntGetByVal(t0, t1) 1564 1582 1565 .opGetByValInt32ArrayOrUint8Array: 1566 # We have one of Int16Array, Uint8Array, or Uint8ClampedArray. 1567 bieq t2, Int32ArrayType - FirstArrayType, .opGetByValInt32Array 1568 1569 # We have either Uint8Array or Uint8ClampedArray. They behave the same so that's cool. 1570 loadb [t3, t1], t0 1571 finishIntGetByVal(t0, t1) 1572 1573 .opGetByValInt32Array: 1574 loadi [t3, t1, 4], t0 1575 finishIntGetByVal(t0, t1) 1576 1577 .opGetByValAboveUint8ClampedArray: 1578 # We have one of Uint16ArrayType .. Float64ArrayType. 1579 bia t2, Uint32ArrayType - FirstArrayType, .opGetByValAboveUint32Array 1580 1581 # We have either Uint16ArrayType or Uint32ArrayType. 1582 bieq t2, Uint32ArrayType - FirstArrayType, .opGetByValUint32Array 1583 1583 .opGetByValUint16Array: 1584 1584 # We have Uint16ArrayType. 1585 1585 loadh [t3, t1, 2], t0 1586 1586 finishIntGetByVal(t0, t1) 1587 1587 1588 .opGetByValAboveUint16Array: 1589 # We have one of Int32ArrayType .. Float64ArrayType. 1590 bia t2, Uint32ArrayType - FirstArrayType, .opGetByValFloat32ArrayOrFloat64Array 1591 1592 # We have either Int32ArrayType or Uint32ArrayType 1593 bineq t2, Int32ArrayType - FirstArrayType, .opGetByValUint32Array 1594 1595 # We have Int32ArrayType 1596 loadi [t3, t1, 4], t0 1597 finishIntGetByVal(t0, t1) 1598 1588 1599 .opGetByValUint32Array: 1600 # We have Uint32ArrayType. 1589 1601 # This is the hardest part because of large unsigned values. 1590 1602 loadi [t3, t1, 4], t0 … … 1592 1604 finishIntGetByVal(t0, t1) 1593 1605 1594 .opGetByVal AboveUint32Array:1606 .opGetByValFloat32ArrayOrFloat64Array: 1595 1607 # We have one of Float32ArrayType or Float64ArrayType. Sadly, we cannot handle Float32Array 1596 1608 # inline yet. That would require some offlineasm changes. -
trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp
r227104 r227434 1421 1421 #undef VISIT_LAZY_TYPE 1422 1422 1423 for (unsigned i = N UMBER_OF_TYPED_ARRAY_TYPES; i--;)1423 for (unsigned i = NumberOfTypedArrayTypes; i--;) 1424 1424 thisObject->lazyTypedArrayStructure(indexToTypedArrayType(i)).visit(visitor); 1425 1425 -
trunk/Source/JavaScriptCore/runtime/JSType.h
r226783 r227434 1 1 /* 2 * Copyright (C) 2006-201 1, 2015-2016Apple Inc. All rights reserved.2 * Copyright (C) 2006-2018 Apple Inc. All rights reserved. 3 3 * 4 4 * This library is free software; you can redistribute it and/or … … 71 71 72 72 Int8ArrayType, 73 Int16ArrayType,74 Int32ArrayType,75 73 Uint8ArrayType, 76 74 Uint8ClampedArrayType, 75 Int16ArrayType, 77 76 Uint16ArrayType, 77 Int32ArrayType, 78 78 Uint32ArrayType, 79 79 Float32ArrayType, … … 105 105 }; 106 106 107 static const uint32_t FirstTypedArrayType = Int8ArrayType; 108 static const uint32_t LastTypedArrayType = DataViewType; 109 static constexpr uint32_t NumberOfTypedArrayTypes = LastTypedArrayType - FirstTypedArrayType + 1; 110 static constexpr uint32_t NumberOfTypedArrayTypesExcludingDataView = NumberOfTypedArrayTypes - 1; 111 107 112 static_assert(sizeof(JSType) == sizeof(uint8_t), "sizeof(JSType) is one byte."); 108 113 static_assert(LastJSCObjectType < 128, "The highest bit is reserved for embedder's extension."); -
trunk/Source/JavaScriptCore/runtime/TypedArrayType.cpp
r226311 r227434 1 1 /* 2 * Copyright (C) 2013 Apple Inc. All rights reserved.2 * Copyright (C) 2013-2018 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 32 32 33 33 namespace JSC { 34 35 JSType typeForTypedArrayType(TypedArrayType type)36 {37 switch (type) {38 case NotTypedArray:39 RELEASE_ASSERT_NOT_REACHED();40 return Int8ArrayType;41 case TypeInt8:42 return Int8ArrayType;43 case TypeUint8:44 return Uint8ArrayType;45 case TypeUint8Clamped:46 return Uint8ClampedArrayType;47 case TypeInt16:48 return Int16ArrayType;49 case TypeUint16:50 return Uint16ArrayType;51 case TypeInt32:52 return Int32ArrayType;53 case TypeUint32:54 return Uint32ArrayType;55 case TypeFloat32:56 return Float32ArrayType;57 case TypeFloat64:58 return Float64ArrayType;59 case TypeDataView:60 return DataViewType;61 62 default:63 RELEASE_ASSERT_NOT_REACHED();64 return Int8ArrayType;65 }66 }67 34 68 35 const ClassInfo* constructorClassInfoForType(TypedArrayType type) -
trunk/Source/JavaScriptCore/runtime/TypedArrayType.h
r218794 r227434 1 1 /* 2 * Copyright (C) 2013 , 2016Apple Inc. All rights reserved.2 * Copyright (C) 2013-2018 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 33 33 struct ClassInfo; 34 34 35 #define FOR_EACH_TYPED_ARRAY_TYPE(macro) \36 macro(Int8) \37 macro(Uint8) \38 macro(Uint8Clamped) \39 macro(Int16) \40 macro(Uint16) \41 macro(Int32) \42 macro(Uint32) \43 macro(Float32) \44 macro(Float64) \45 macro(DataView)46 47 35 #define FOR_EACH_TYPED_ARRAY_TYPE_EXCLUDING_DATA_VIEW(macro) \ 48 36 macro(Int8) \ … … 56 44 macro(Float64) 57 45 46 #define FOR_EACH_TYPED_ARRAY_TYPE(macro) \ 47 FOR_EACH_TYPED_ARRAY_TYPE_EXCLUDING_DATA_VIEW(macro) \ 48 macro(DataView) 49 58 50 enum TypedArrayType { 59 51 NotTypedArray, … … 63 55 }; 64 56 65 #define NUMBER_OF_TYPED_ARRAY_TYPES TypeDataView 57 #define ASSERT_TYPED_ARRAY_TYPE(name) \ 58 static_assert(Type ## name == (name ## ArrayType - FirstTypedArrayType + TypeInt8), ""); 59 FOR_EACH_TYPED_ARRAY_TYPE_EXCLUDING_DATA_VIEW(ASSERT_TYPED_ARRAY_TYPE) 60 #undef ASSERT_TYPED_ARRAY_TYPE 61 62 static_assert(TypeDataView == (DataViewType - FirstTypedArrayType + TypeInt8), ""); 66 63 67 64 inline unsigned toIndex(TypedArrayType type) … … 118 115 119 116 const ClassInfo* constructorClassInfoForType(TypedArrayType); 120 JSType typeForTypedArrayType(TypedArrayType);121 117 122 118 inline TypedArrayType typedArrayTypeForType(JSType type) 123 119 { 124 switch (type) { 125 case Int8ArrayType: 126 return TypeInt8; 127 case Int16ArrayType: 128 return TypeInt16; 129 case Int32ArrayType: 130 return TypeInt32; 131 case Uint8ArrayType: 132 return TypeUint8; 133 case Uint8ClampedArrayType: 134 return TypeUint8Clamped; 135 case Uint16ArrayType: 136 return TypeUint16; 137 case Uint32ArrayType: 138 return TypeUint32; 139 case Float32ArrayType: 140 return TypeFloat32; 141 case Float64ArrayType: 142 return TypeFloat64; 143 default: 144 return NotTypedArray; 145 } 120 if (type >= FirstTypedArrayType && type <= LastTypedArrayType) 121 return static_cast<TypedArrayType>(type - FirstTypedArrayType + TypeInt8); 122 return NotTypedArray; 123 } 124 125 inline JSType typeForTypedArrayType(TypedArrayType type) 126 { 127 if (type >= TypeInt8 && type <= TypeDataView) 128 return static_cast<JSType>(type - TypeInt8 + FirstTypedArrayType); 129 130 RELEASE_ASSERT_NOT_REACHED(); 131 return Int8ArrayType; 146 132 } 147 133
Note:
See TracChangeset
for help on using the changeset viewer.