Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(130)

Side by Side Diff: src/IceCfgNode.cpp

Issue 1559243002: Suzero. X8664. NaCl Sandboxing. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Adds lit tests for the sandboxed call/ret sequences; add lit tests for the new pad_to_end bundle lo… Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 //===- subzero/src/IceCfgNode.cpp - Basic block (node) implementation -----===// 1 //===- subzero/src/IceCfgNode.cpp - Basic block (node) implementation -----===//
2 // 2 //
3 // The Subzero Code Generator 3 // The Subzero Code Generator
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 /// 9 ///
10 /// \file 10 /// \file
(...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after
1099 BundleSize(1 << Asm->getBundleAlignLog2Bytes()), 1099 BundleSize(1 << Asm->getBundleAlignLog2Bytes()),
1100 BundleMaskLo(BundleSize - 1), BundleMaskHi(~BundleMaskLo) {} 1100 BundleMaskLo(BundleSize - 1), BundleMaskHi(~BundleMaskLo) {}
1101 // Check whether we're currently within a bundle_lock region. 1101 // Check whether we're currently within a bundle_lock region.
1102 bool isInBundleLockRegion() const { return BundleLockStart != End; } 1102 bool isInBundleLockRegion() const { return BundleLockStart != End; }
1103 // Check whether the current bundle_lock region has the align_to_end option. 1103 // Check whether the current bundle_lock region has the align_to_end option.
1104 bool isAlignToEnd() const { 1104 bool isAlignToEnd() const {
1105 assert(isInBundleLockRegion()); 1105 assert(isInBundleLockRegion());
1106 return llvm::cast<InstBundleLock>(getBundleLockStart())->getOption() == 1106 return llvm::cast<InstBundleLock>(getBundleLockStart())->getOption() ==
1107 InstBundleLock::Opt_AlignToEnd; 1107 InstBundleLock::Opt_AlignToEnd;
1108 } 1108 }
1109 bool isPadToEnd() const {
1110 assert(isInBundleLockRegion());
1111 return llvm::cast<InstBundleLock>(getBundleLockStart())->getOption() ==
1112 InstBundleLock::Opt_PadToEnd;
1113 }
1109 // Check whether the entire bundle_lock region falls within the same bundle. 1114 // Check whether the entire bundle_lock region falls within the same bundle.
1110 bool isSameBundle() const { 1115 bool isSameBundle() const {
1111 assert(isInBundleLockRegion()); 1116 assert(isInBundleLockRegion());
1112 return SizeSnapshotPre == SizeSnapshotPost || 1117 return SizeSnapshotPre == SizeSnapshotPost ||
1113 (SizeSnapshotPre & BundleMaskHi) == 1118 (SizeSnapshotPre & BundleMaskHi) ==
1114 ((SizeSnapshotPost - 1) & BundleMaskHi); 1119 ((SizeSnapshotPost - 1) & BundleMaskHi);
1115 } 1120 }
1116 // Get the bundle alignment of the first instruction of the bundle_lock 1121 // Get the bundle alignment of the first instruction of the bundle_lock
1117 // region. 1122 // region.
1118 intptr_t getPreAlignment() const { 1123 intptr_t getPreAlignment() const {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1164 // sequences ends precisely at a bundle boundary. 1169 // sequences ends precisely at a bundle boundary.
1165 void padForAlignToEnd() { 1170 void padForAlignToEnd() {
1166 assert(isInBundleLockRegion()); 1171 assert(isInBundleLockRegion());
1167 if (isAlignToEnd()) { 1172 if (isAlignToEnd()) {
1168 if (intptr_t Offset = getPostAlignment()) { 1173 if (intptr_t Offset = getPostAlignment()) {
1169 Asm->padWithNop(BundleSize - Offset); 1174 Asm->padWithNop(BundleSize - Offset);
1170 SizeSnapshotPre = Asm->getBufferSize(); 1175 SizeSnapshotPre = Asm->getBufferSize();
1171 } 1176 }
1172 } 1177 }
1173 } 1178 }
1174 // Update bookkeeping when rolling back for the second pass. 1179 // If pad_to_end is specified, add padding such that the first instruction
1180 // after the instruction sequence starts starts at a bundle boundary.
1181 void padForPadToEnd() {
1182 assert(isInBundleLockRegion());
1183 if (isPadToEnd()) {
1184 if (intptr_t Offset = getPostAlignment()) {
1185 Asm->padWithNop(BundleSize - Offset);
1186 SizeSnapshotPre = Asm->getBufferSize();
1187 }
1188 }
1189 } // Update bookkeeping when rolling back for the second pass.
1175 void rollback() { 1190 void rollback() {
1176 assert(isInBundleLockRegion()); 1191 assert(isInBundleLockRegion());
1177 Asm->setBufferSize(SizeSnapshotPre); 1192 Asm->setBufferSize(SizeSnapshotPre);
1178 Asm->setPreliminary(false); 1193 Asm->setPreliminary(false);
1179 } 1194 }
1180 1195
1181 private: 1196 private:
1182 Assembler *const Asm; 1197 Assembler *const Asm;
1183 // End is a sentinel value such that BundleLockStart==End implies that we are 1198 // End is a sentinel value such that BundleLockStart==End implies that we are
1184 // not in a bundle_lock region. 1199 // not in a bundle_lock region.
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1253 } 1268 }
1254 1269
1255 if (llvm::isa<InstBundleUnlock>(I)) { 1270 if (llvm::isa<InstBundleUnlock>(I)) {
1256 Helper.enterBundleUnlock(); 1271 Helper.enterBundleUnlock();
1257 if (Retrying) { 1272 if (Retrying) {
1258 // Make sure all instructions are in the same bundle. 1273 // Make sure all instructions are in the same bundle.
1259 assert(Helper.isSameBundle()); 1274 assert(Helper.isSameBundle());
1260 // If align_to_end is specified, make sure the next instruction begins 1275 // If align_to_end is specified, make sure the next instruction begins
1261 // the bundle. 1276 // the bundle.
1262 assert(!Helper.isAlignToEnd() || Helper.getPostAlignment() == 0); 1277 assert(!Helper.isAlignToEnd() || Helper.getPostAlignment() == 0);
1278 Helper.padForPadToEnd();
1263 Helper.leaveBundleLockRegion(); 1279 Helper.leaveBundleLockRegion();
1264 Retrying = false; 1280 Retrying = false;
1265 } else { 1281 } else {
1266 // This is the first pass, so roll back for the retry pass. 1282 // This is the first pass, so roll back for the retry pass.
1267 Helper.rollback(); 1283 Helper.rollback();
1268 // Pad to the next bundle if the instruction sequence crossed a bundle 1284 // Pad to the next bundle if the instruction sequence crossed a bundle
1269 // boundary. 1285 // boundary.
1270 Helper.padToNextBundle(); 1286 Helper.padToNextBundle();
1271 // Insert additional padding to make AlignToEnd work. 1287 // Insert additional padding to make AlignToEnd work.
1272 Helper.padForAlignToEnd(); 1288 Helper.padForAlignToEnd();
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
1409 auto *Inst = InstIntrinsicCall::create( 1425 auto *Inst = InstIntrinsicCall::create(
1410 Func, 5, Func->makeVariable(IceType_i64), RMWI64Name, Info->Info); 1426 Func, 5, Func->makeVariable(IceType_i64), RMWI64Name, Info->Info);
1411 Inst->addArg(AtomicRMWOp); 1427 Inst->addArg(AtomicRMWOp);
1412 Inst->addArg(Counter); 1428 Inst->addArg(Counter);
1413 Inst->addArg(One); 1429 Inst->addArg(One);
1414 Inst->addArg(OrderAcquireRelease); 1430 Inst->addArg(OrderAcquireRelease);
1415 Insts.push_front(Inst); 1431 Insts.push_front(Inst);
1416 } 1432 }
1417 1433
1418 } // end of namespace Ice 1434 } // end of namespace Ice
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698