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

Side by Side Diff: src/PNaClTranslator.cpp

Issue 1783113002: Subzero: Improve the behavior of resizing vectors. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « src/IceUtils.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/src/PNaClTranslator.cpp - ICE from bitcode -----------------===// 1 //===- subzero/src/PNaClTranslator.cpp - ICE from bitcode -----------------===//
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 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 if (ID >= TypeIDValues.size()) { 268 if (ID >= TypeIDValues.size()) {
269 if (ID >= NaClBcIndexSize_t_Max) { 269 if (ID >= NaClBcIndexSize_t_Max) {
270 std::string Buffer; 270 std::string Buffer;
271 raw_string_ostream StrBuf(Buffer); 271 raw_string_ostream StrBuf(Buffer);
272 StrBuf << "Can't define more than " << NaClBcIndexSize_t_Max 272 StrBuf << "Can't define more than " << NaClBcIndexSize_t_Max
273 << " types\n"; 273 << " types\n";
274 blockError(StrBuf.str()); 274 blockError(StrBuf.str());
275 // Recover by using existing type slot. 275 // Recover by using existing type slot.
276 return &TypeIDValues[0]; 276 return &TypeIDValues[0];
277 } 277 }
278 TypeIDValues.resize(ID + 1); 278 Ice::Utils::reserveAndResize(TypeIDValues, ID + 1);
279 } 279 }
280 return &TypeIDValues[ID]; 280 return &TypeIDValues[ID];
281 } 281 }
282 282
283 /// Returns the type associated with the given index. 283 /// Returns the type associated with the given index.
284 Ice::Type getSimpleTypeByID(NaClBcIndexSize_t ID) { 284 Ice::Type getSimpleTypeByID(NaClBcIndexSize_t ID) {
285 const ExtendedType *Ty = getTypeByIDAsKind(ID, ExtendedType::Simple); 285 const ExtendedType *Ty = getTypeByIDAsKind(ID, ExtendedType::Simple);
286 if (Ty == nullptr) 286 if (Ty == nullptr)
287 // Return error recovery value. 287 // Return error recovery value.
288 return Ice::IceType_void; 288 return Ice::IceType_void;
(...skipping 1270 matching lines...) Expand 10 before | Expand all | Expand 10 after
1559 if (LocalIndex > MaxRecordsInBlock) { 1559 if (LocalIndex > MaxRecordsInBlock) {
1560 std::string Buffer; 1560 std::string Buffer;
1561 raw_string_ostream StrBuf(Buffer); 1561 raw_string_ostream StrBuf(Buffer);
1562 StrBuf << "Forward reference @" << Index << " too big. Have " 1562 StrBuf << "Forward reference @" << Index << " too big. Have "
1563 << CachedNumGlobalValueIDs << " globals and function contains " 1563 << CachedNumGlobalValueIDs << " globals and function contains "
1564 << NumBytesDefiningFunction << " bytes"; 1564 << NumBytesDefiningFunction << " bytes";
1565 Fatal(StrBuf.str()); 1565 Fatal(StrBuf.str());
1566 // Recover by using index one beyond the maximal allowed. 1566 // Recover by using index one beyond the maximal allowed.
1567 LocalIndex = MaxRecordsInBlock; 1567 LocalIndex = MaxRecordsInBlock;
1568 } 1568 }
1569 LocalOperands.resize(LocalIndex + 1); 1569 Ice::Utils::reserveAndResize(LocalOperands, LocalIndex + 1);
1570 } 1570 }
1571 1571
1572 // If element not defined, set it. 1572 // If element not defined, set it.
1573 Ice::Operand *OldOp = LocalOperands[LocalIndex]; 1573 Ice::Operand *OldOp = LocalOperands[LocalIndex];
1574 if (OldOp == nullptr) { 1574 if (OldOp == nullptr) {
1575 LocalOperands[LocalIndex] = Op; 1575 LocalOperands[LocalIndex] = Op;
1576 return; 1576 return;
1577 } 1577 }
1578 1578
1579 // See if forward reference matches. 1579 // See if forward reference matches.
(...skipping 1622 matching lines...) Expand 10 before | Expand all | Expand 10 after
3202 raw_string_ostream StrBuf(Buffer); 3202 raw_string_ostream StrBuf(Buffer);
3203 StrBuf << IRFilename << ": Does not contain a module!"; 3203 StrBuf << IRFilename << ": Does not contain a module!";
3204 llvm::report_fatal_error(StrBuf.str()); 3204 llvm::report_fatal_error(StrBuf.str());
3205 } 3205 }
3206 if (InputStreamFile.getBitcodeBytes().getExtent() % 4 != 0) { 3206 if (InputStreamFile.getBitcodeBytes().getExtent() % 4 != 0) {
3207 llvm::report_fatal_error("Bitcode stream should be a multiple of 4 bytes"); 3207 llvm::report_fatal_error("Bitcode stream should be a multiple of 4 bytes");
3208 } 3208 }
3209 } 3209 }
3210 3210
3211 } // end of namespace Ice 3211 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceUtils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698