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

Side by Side Diff: src/IceGlobalContext.h

Issue 1179313004: Fix a bug that would cause subzero to fail when --threads=0. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Addresses codereview comments. Created 5 years, 6 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/IceELFObjectWriter.cpp ('k') | src/IceGlobalContext.cpp » ('j') | 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/IceGlobalContext.h - Global context defs -----*- C++ -*-===// 1 //===- subzero/src/IceGlobalContext.h - Global context defs -----*- C++ -*-===//
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 // This file declares aspects of the compilation that persist across 10 // This file declares aspects of the compilation that persist across
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 // the work queue is currently empty. Returns nullptr if there is 296 // the work queue is currently empty. Returns nullptr if there is
297 // no more work - the queue is empty and either end() has been 297 // no more work - the queue is empty and either end() has been
298 // called or the Sequential flag was set. 298 // called or the Sequential flag was set.
299 std::unique_ptr<Cfg> optQueueBlockingPop(); 299 std::unique_ptr<Cfg> optQueueBlockingPop();
300 // Notifies that no more work will be added to the work queue. 300 // Notifies that no more work will be added to the work queue.
301 void optQueueNotifyEnd() { OptQ.notifyEnd(); } 301 void optQueueNotifyEnd() { OptQ.notifyEnd(); }
302 302
303 // Emit file header for output file. 303 // Emit file header for output file.
304 void emitFileHeader(); 304 void emitFileHeader();
305 305
306 void lowerConstants();
307
306 void emitQueueBlockingPush(EmitterWorkItem *Item); 308 void emitQueueBlockingPush(EmitterWorkItem *Item);
307 EmitterWorkItem *emitQueueBlockingPop(); 309 EmitterWorkItem *emitQueueBlockingPop();
308 void emitQueueNotifyEnd() { EmitQ.notifyEnd(); } 310 void emitQueueNotifyEnd() { EmitQ.notifyEnd(); }
309 311
310 void initParserThread() { 312 void initParserThread() {
311 ThreadContext *Tls = new ThreadContext(); 313 ThreadContext *Tls = new ThreadContext();
312 auto Timers = getTimers(); 314 auto Timers = getTimers();
313 Timers->initInto(Tls->Timers); 315 Timers->initInto(Tls->Timers);
314 AllThreadContexts.push_back(Tls); 316 AllThreadContexts.push_back(Tls);
315 ICE_TLS_SET_FIELD(TLS, Tls); 317 ICE_TLS_SET_FIELD(TLS, Tls);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 375
374 // Emitter thread startup routine. 376 // Emitter thread startup routine.
375 void emitterWrapper(ThreadContext *MyTLS) { 377 void emitterWrapper(ThreadContext *MyTLS) {
376 ICE_TLS_SET_FIELD(TLS, MyTLS); 378 ICE_TLS_SET_FIELD(TLS, MyTLS);
377 emitItems(); 379 emitItems();
378 } 380 }
379 // Emit functions and global initializers from the emitter queue 381 // Emit functions and global initializers from the emitter queue
380 // until the queue is empty. 382 // until the queue is empty.
381 void emitItems(); 383 void emitItems();
382 384
385 // Uses DataLowering to lower Globals. As a side effect, clears the Globals
386 // array.
387 void lowerGlobals(const IceString &SectionSuffix);
388
389 // Lowers the profile information.
390 void lowerProfileData();
391
383 // Utility function to match a symbol name against a match string. 392 // Utility function to match a symbol name against a match string.
384 // This is used in a few cases where we want to take some action on 393 // This is used in a few cases where we want to take some action on
385 // a particular function or symbol based on a command-line argument, 394 // a particular function or symbol based on a command-line argument,
386 // such as changing the verbose level for a particular function. An 395 // such as changing the verbose level for a particular function. An
387 // empty Match argument means match everything. Returns true if 396 // empty Match argument means match everything. Returns true if
388 // there is a match. 397 // there is a match.
389 static bool matchSymbolName(const IceString &SymbolName, 398 static bool matchSymbolName(const IceString &SymbolName,
390 const IceString &Match) { 399 const IceString &Match) {
391 return Match.empty() || Match == SymbolName; 400 return Match.empty() || Match == SymbolName;
392 } 401 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 StrLockType StrLock; 434 StrLockType StrLock;
426 Ostream *StrDump; // Stream for dumping / diagnostics 435 Ostream *StrDump; // Stream for dumping / diagnostics
427 Ostream *StrEmit; // Stream for code emission 436 Ostream *StrEmit; // Stream for code emission
428 Ostream *StrError; // Stream for logging errors. 437 Ostream *StrError; // Stream for logging errors.
429 438
430 ICE_CACHELINE_BOUNDARY; 439 ICE_CACHELINE_BOUNDARY;
431 440
432 Intrinsics IntrinsicsInfo; 441 Intrinsics IntrinsicsInfo;
433 const ClFlags &Flags; 442 const ClFlags &Flags;
434 RandomNumberGenerator RNG; // TODO(stichnot): Move into Cfg. 443 RandomNumberGenerator RNG; // TODO(stichnot): Move into Cfg.
444 // TODO(jpp): move to EmitterContext.
435 std::unique_ptr<ELFObjectWriter> ObjectWriter; 445 std::unique_ptr<ELFObjectWriter> ObjectWriter;
436 BoundedProducerConsumerQueue<Cfg> OptQ; 446 BoundedProducerConsumerQueue<Cfg> OptQ;
437 BoundedProducerConsumerQueue<EmitterWorkItem> EmitQ; 447 BoundedProducerConsumerQueue<EmitterWorkItem> EmitQ;
448 // DataLowering is only ever used by a single thread at a time (either in
449 // emitItems(), or in IceCompiler::run before the compilation is over.)
450 // TODO(jpp): move to EmitterContext.
451 std::unique_ptr<TargetDataLowering> DataLowering;
452 // If !HasEmittedCode, SubZero will accumulate all Globals (which are "true"
453 // program global variables) until the first code WorkItem is seen.
454 // TODO(jpp): move to EmitterContext.
455 bool HasSeenCode;
456 // TODO(jpp): move to EmitterContext.
457 VariableDeclarationList Globals;
458 // TODO(jpp): move to EmitterContext.
459 std::unique_ptr<VariableDeclaration> ProfileBlockInfoVarDecl;
438 460
439 LockedPtr<ArenaAllocator<>> getAllocator() { 461 LockedPtr<ArenaAllocator<>> getAllocator() {
440 return LockedPtr<ArenaAllocator<>>(&Allocator, &AllocLock); 462 return LockedPtr<ArenaAllocator<>>(&Allocator, &AllocLock);
441 } 463 }
442 LockedPtr<ConstantPool> getConstPool() { 464 LockedPtr<ConstantPool> getConstPool() {
443 return LockedPtr<ConstantPool>(ConstPool.get(), &ConstPoolLock); 465 return LockedPtr<ConstantPool>(ConstPool.get(), &ConstPoolLock);
444 } 466 }
445 LockedPtr<CodeStats> getStatsCumulative() { 467 LockedPtr<CodeStats> getStatsCumulative() {
446 return LockedPtr<CodeStats>(&StatsCumulative, &StatsLock); 468 return LockedPtr<CodeStats>(&StatsCumulative, &StatsLock);
447 } 469 }
448 LockedPtr<TimerList> getTimers() { 470 LockedPtr<TimerList> getTimers() {
449 return LockedPtr<TimerList>(&Timers, &TimerLock); 471 return LockedPtr<TimerList>(&Timers, &TimerLock);
450 } 472 }
451 473
474 void accumulateGlobals(std::unique_ptr<VariableDeclarationList> Globls) {
475 if (Globls != nullptr)
476 Globals.insert(Globals.end(), Globls->begin(), Globls->end());
477 }
478
479 void lowerGlobalsIfNoCodeHasBeenSeen() {
480 if (HasSeenCode)
481 return;
482 constexpr char NoSuffix[] = "";
483 lowerGlobals(NoSuffix);
484 HasSeenCode = true;
485 }
486
452 llvm::SmallVector<ThreadContext *, 128> AllThreadContexts; 487 llvm::SmallVector<ThreadContext *, 128> AllThreadContexts;
453 llvm::SmallVector<std::thread, 128> TranslationThreads; 488 llvm::SmallVector<std::thread, 128> TranslationThreads;
454 llvm::SmallVector<std::thread, 128> EmitterThreads; 489 llvm::SmallVector<std::thread, 128> EmitterThreads;
455 // Each thread has its own TLS pointer which is also held in 490 // Each thread has its own TLS pointer which is also held in
456 // AllThreadContexts. 491 // AllThreadContexts.
457 ICE_TLS_DECLARE_FIELD(ThreadContext *, TLS); 492 ICE_TLS_DECLARE_FIELD(ThreadContext *, TLS);
458 493
459 // Private helpers for mangleName() 494 // Private helpers for mangleName()
460 typedef llvm::SmallVector<char, 32> ManglerVector; 495 typedef llvm::SmallVector<char, 32> ManglerVector;
461 void incrementSubstitutions(ManglerVector &OldName) const; 496 void incrementSubstitutions(ManglerVector &OldName) const;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 explicit OstreamLocker(GlobalContext *Ctx) : Ctx(Ctx) { Ctx->lockStr(); } 548 explicit OstreamLocker(GlobalContext *Ctx) : Ctx(Ctx) { Ctx->lockStr(); }
514 ~OstreamLocker() { Ctx->unlockStr(); } 549 ~OstreamLocker() { Ctx->unlockStr(); }
515 550
516 private: 551 private:
517 GlobalContext *const Ctx; 552 GlobalContext *const Ctx;
518 }; 553 };
519 554
520 } // end of namespace Ice 555 } // end of namespace Ice
521 556
522 #endif // SUBZERO_SRC_ICEGLOBALCONTEXT_H 557 #endif // SUBZERO_SRC_ICEGLOBALCONTEXT_H
OLDNEW
« no previous file with comments | « src/IceELFObjectWriter.cpp ('k') | src/IceGlobalContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698