Changeset 285152 in webkit
- Timestamp:
- Nov 1, 2021, 8:42:34 PM (5 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 3 edited
-
ChangeLog (modified) (1 diff)
-
llint/LowLevelInterpreter32_64.asm (modified) (8 diffs)
-
llint/LowLevelInterpreter64.asm (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r285149 r285152 1 2021-11-01 Ross Kirsling <ross.kirsling@sony.com> 2 3 [JSC][LLInt] Non-commutative binops are hard to reason about when operands are labelled in reverse 4 https://bugs.webkit.org/show_bug.cgi?id=232598 5 6 Reviewed by Saam Barati. 7 8 In offlineasm, `OP a, b, c` is `c = a OP b` but `OP a, b` is `b = b OP a`. 9 10 This can make identifiers like `left` and `right` quite confusing -- 11 simple cases like `subd left, right` are already misleading, while OpDiv literally 12 passes its RHS to a macro as `left` and then checks `left` for division by zero. 13 It becomes difficult to keep this all in one's brain without rewriting it on paper. 14 15 This patch may not constitute a "complete solution", but it at least makes our naming honest: 16 1. Use 3-argument syntax (as `left, right, result`) whenever possible. 17 2. When not possible (e.g. because `bsubio` isn't flexible about its arguments or 18 because x86 doesn't have 3-argument shift operations), then say `rhs, lhs` explicitly. 19 20 * llint/LowLevelInterpreter32_64.asm: 21 * llint/LowLevelInterpreter64.asm: 22 1 23 2021-11-01 Yusuke Suzuki <ysuzuki@apple.com> 2 24 -
trunk/Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm
r284923 r285152 1119 1119 updateBinaryArithProfile(size, opcodeStruct, ArithProfileIntInt, t5, t2) 1120 1120 get(m_dst, t2) 1121 integerOperationAndStore(t3, t 1, t0, .slow, t2)1121 integerOperationAndStore(t3, t0, t1, .slow, t2) 1122 1122 dispatch() 1123 1123 … … 1136 1136 get(m_dst, t1) 1137 1137 fii2d t0, t2, ft0 1138 doubleOperation(ft 1, ft0)1138 doubleOperation(ft0, ft1, ft0) 1139 1139 stored ft0, [cfr, t1, 8] 1140 1140 dispatch() … … 1147 1147 ci2ds t0, ft0 1148 1148 fii2d t1, t3, ft1 1149 doubleOperation(ft 1, ft0)1149 doubleOperation(ft0, ft1, ft0) 1150 1150 stored ft0, [cfr, t2, 8] 1151 1151 dispatch() … … 1159 1159 macro binaryOp(opcodeName, opcodeStruct, integerOperation, doubleOperation) 1160 1160 binaryOpCustomStore(opcodeName, opcodeStruct, 1161 macro (int32Tag, l eft, right, slow, index)1162 integerOperation(l eft, right, slow)1161 macro (int32Tag, lhs, rhs, slow, index) 1162 integerOperation(lhs, rhs, slow) 1163 1163 storei int32Tag, TagOffset[cfr, index, 8] 1164 storei right, PayloadOffset[cfr, index, 8]1164 storei lhs, PayloadOffset[cfr, index, 8] 1165 1165 end, 1166 1166 doubleOperation) … … 1168 1168 1169 1169 binaryOp(add, OpAdd, 1170 macro (l eft, right, slow) baddio left, right, slow end,1171 macro (left, right ) addd left, right end)1170 macro (lhs, rhs, slow) baddio rhs, lhs, slow end, 1171 macro (left, right, result) addd left, right, result end) 1172 1172 1173 1173 1174 1174 binaryOpCustomStore(mul, OpMul, 1175 macro (int32Tag, l eft, right, slow, index)1175 macro (int32Tag, lhs, rhs, slow, index) 1176 1176 const scratch = int32Tag # We know that we can reuse the int32Tag register since it has a constant. 1177 move right, scratch1178 bmulio left, scratch, slow1177 move lhs, scratch 1178 bmulio rhs, scratch, slow 1179 1179 btinz scratch, .done 1180 bilt left, 0, slow1181 bilt right, 0, slow1180 bilt rhs, 0, slow 1181 bilt lhs, 0, slow 1182 1182 .done: 1183 1183 storei Int32Tag, TagOffset[cfr, index, 8] 1184 1184 storei scratch, PayloadOffset[cfr, index, 8] 1185 1185 end, 1186 macro (left, right ) muld left, right end)1186 macro (left, right, result) muld left, right, result end) 1187 1187 1188 1188 1189 1189 binaryOp(sub, OpSub, 1190 macro (l eft, right, slow) bsubio left, right, slow end,1191 macro (left, right ) subd left, right end)1190 macro (lhs, rhs, slow) bsubio rhs, lhs, slow end, 1191 macro (left, right, result) subd left, right, result end) 1192 1192 1193 1193 1194 1194 binaryOpCustomStore(div, OpDiv, 1195 macro (int32Tag, l eft, right, slow, index)1196 ci2ds left, ft01197 ci2ds right, ft11195 macro (int32Tag, lhs, rhs, slow, index) 1196 ci2ds rhs, ft0 1197 ci2ds lhs, ft1 1198 1198 divd ft0, ft1 1199 bcd2i ft1, right, .notInt1199 bcd2i ft1, lhs, .notInt 1200 1200 storei int32Tag, TagOffset[cfr, index, 8] 1201 storei right, PayloadOffset[cfr, index, 8]1201 storei lhs, PayloadOffset[cfr, index, 8] 1202 1202 jmp .done 1203 1203 .notInt: … … 1205 1205 .done: 1206 1206 end, 1207 macro (left, right ) divd left, right end)1207 macro (left, right, result) divd left, right, result end) 1208 1208 1209 1209 … … 1227 1227 bineq t3, Int32Tag, .slow 1228 1228 bineq t2, Int32Tag, .slow 1229 operation(t 1, t0)1229 operation(t0, t1) 1230 1230 return (t3, t0) 1231 1231 … … 1246 1246 1247 1247 bitOpProfiled(lshift, OpLshift, 1248 macro (l eft, right) lshifti left, rightend)1248 macro (lhs, rhs) lshifti rhs, lhs end) 1249 1249 1250 1250 1251 1251 bitOp(rshift, OpRshift, 1252 macro (l eft, right) rshifti left, rightend)1252 macro (lhs, rhs) rshifti rhs, lhs end) 1253 1253 1254 1254 1255 1255 bitOp(urshift, OpUrshift, 1256 macro (l eft, right) urshifti left, rightend)1256 macro (lhs, rhs) urshifti rhs, lhs end) 1257 1257 1258 1258 bitOpProfiled(bitxor, OpBitxor, 1259 macro (l eft, right) xori left, rightend)1259 macro (lhs, rhs) xori rhs, lhs end) 1260 1260 1261 1261 bitOpProfiled(bitand, OpBitand, 1262 macro (l eft, right) andi left, rightend)1262 macro (lhs, rhs) andi rhs, lhs end) 1263 1263 1264 1264 bitOpProfiled(bitor, OpBitor, 1265 macro (l eft, right) ori left, rightend)1265 macro (lhs, rhs) ori rhs, lhs end) 1266 1266 1267 1267 llintOpWithProfile(op_bitnot, OpBitnot, macro (size, get, dispatch, return) -
trunk/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm
r284923 r285152 1179 1179 bqb t1, numberTag, .op2NotInt 1180 1180 get(m_dst, t2) 1181 integerOperationAndStore(t 1, t0, .slow, t2)1181 integerOperationAndStore(t0, t1, .slow, t2) 1182 1182 1183 1183 updateBinaryArithProfile(size, opcodeStruct, ArithProfileIntInt, t5, t2) … … 1200 1200 addq numberTag, t0 1201 1201 fq2d t0, ft0 1202 doubleOperation(ft 1, ft0)1202 doubleOperation(ft0, ft1, ft0) 1203 1203 fd2q ft0, t0 1204 1204 subq numberTag, t0 … … 1214 1214 addq numberTag, t1 1215 1215 fq2d t1, ft1 1216 doubleOperation(ft 1, ft0)1216 doubleOperation(ft0, ft1, ft0) 1217 1217 fd2q ft0, t0 1218 1218 subq numberTag, t0 … … 1228 1228 if X86_64 or X86_64_WIN 1229 1229 binaryOpCustomStore(div, OpDiv, 1230 macro (l eft, right, slow, index)1230 macro (lhs, rhs, slow, index) 1231 1231 # Assume t3 is scratchable. 1232 btiz left, slow1233 bineq left, -1, .notNeg2TwoThe31DivByNeg11234 bieq right, -2147483648, .slow1232 btiz rhs, slow 1233 bineq rhs, -1, .notNeg2TwoThe31DivByNeg1 1234 bieq lhs, -2147483648, .slow 1235 1235 .notNeg2TwoThe31DivByNeg1: 1236 btinz right, .intOK1237 bilt left, 0, slow1236 btinz lhs, .intOK 1237 bilt rhs, 0, slow 1238 1238 .intOK: 1239 move left, t31240 move right, t01239 move rhs, t3 1240 move lhs, t0 1241 1241 cdqi 1242 1242 idivi t3 … … 1245 1245 storeq t0, [cfr, index, 8] 1246 1246 end, 1247 macro (left, right ) divd left, right end)1247 macro (left, right, result) divd left, right, result end) 1248 1248 else 1249 1249 slowPathOp(div) … … 1252 1252 1253 1253 binaryOpCustomStore(mul, OpMul, 1254 macro (l eft, right, slow, index)1254 macro (lhs, rhs, slow, index) 1255 1255 # Assume t3 is scratchable. 1256 move right, t31257 bmulio left, t3, slow1256 move lhs, t3 1257 bmulio rhs, t3, slow 1258 1258 btinz t3, .done 1259 bilt left, 0, slow1260 bilt right, 0, slow1259 bilt rhs, 0, slow 1260 bilt lhs, 0, slow 1261 1261 .done: 1262 1262 orq numberTag, t3 1263 1263 storeq t3, [cfr, index, 8] 1264 1264 end, 1265 macro (left, right ) muld left, right end)1265 macro (left, right, result) muld left, right, result end) 1266 1266 1267 1267 1268 1268 macro binaryOp(opcodeName, opcodeStruct, integerOperation, doubleOperation) 1269 1269 binaryOpCustomStore(opcodeName, opcodeStruct, 1270 macro (l eft, right, slow, index)1271 integerOperation(l eft, right, slow)1272 orq numberTag, right1273 storeq right, [cfr, index, 8]1270 macro (lhs, rhs, slow, index) 1271 integerOperation(lhs, rhs, slow) 1272 orq numberTag, lhs 1273 storeq lhs, [cfr, index, 8] 1274 1274 end, 1275 1275 doubleOperation) … … 1277 1277 1278 1278 binaryOp(add, OpAdd, 1279 macro (l eft, right, slow) baddio left, right, slow end,1280 macro (left, right ) addd left, right end)1279 macro (lhs, rhs, slow) baddio rhs, lhs, slow end, 1280 macro (left, right, result) addd left, right, result end) 1281 1281 1282 1282 1283 1283 binaryOp(sub, OpSub, 1284 macro (l eft, right, slow) bsubio left, right, slow end,1285 macro (left, right ) subd left, right end)1284 macro (lhs, rhs, slow) bsubio rhs, lhs, slow end, 1285 macro (left, right, result) subd left, right, result end) 1286 1286 1287 1287 … … 1305 1305 bqb t0, numberTag, .slow 1306 1306 bqb t1, numberTag, .slow 1307 operation(t 1, t0)1307 operation(t0, t1) 1308 1308 orq numberTag, t0 1309 1309 return(t0) … … 1324 1324 1325 1325 bitOpProfiled(lshift, OpLshift, 1326 macro (l eft, right) lshifti left, rightend)1326 macro (lhs, rhs) lshifti rhs, lhs end) 1327 1327 1328 1328 1329 1329 bitOpProfiled(rshift, OpRshift, 1330 macro (l eft, right) rshifti left, rightend)1330 macro (lhs, rhs) rshifti rhs, lhs end) 1331 1331 1332 1332 1333 1333 bitOp(urshift, OpUrshift, 1334 macro (l eft, right) urshifti left, rightend)1334 macro (lhs, rhs) urshifti rhs, lhs end) 1335 1335 1336 1336 bitOpProfiled(bitand, OpBitand, 1337 macro (l eft, right) andi left, rightend)1337 macro (lhs, rhs) andi rhs, lhs end) 1338 1338 1339 1339 bitOpProfiled(bitor, OpBitor, 1340 macro (l eft, right) ori left, rightend)1340 macro (lhs, rhs) ori rhs, lhs end) 1341 1341 1342 1342 bitOpProfiled(bitxor, OpBitxor, 1343 macro (l eft, right) xori left, rightend)1343 macro (lhs, rhs) xori rhs, lhs end) 1344 1344 1345 1345 llintOpWithProfile(op_bitnot, OpBitnot, macro (size, get, dispatch, return)
Note:
See TracChangeset
for help on using the changeset viewer.