| OLD | NEW |
| 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 /// \file | 10 /// \file |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 | 475 |
| 476 void setDisposeGlobalVariablesAfterLowering(bool Value) { | 476 void setDisposeGlobalVariablesAfterLowering(bool Value) { |
| 477 DisposeGlobalVariablesAfterLowering = Value; | 477 DisposeGlobalVariablesAfterLowering = Value; |
| 478 } | 478 } |
| 479 /// @} | 479 /// @} |
| 480 | 480 |
| 481 LockedPtr<StringPool> getStrings() const { | 481 LockedPtr<StringPool> getStrings() const { |
| 482 return LockedPtr<StringPool>(Strings.get(), &StringsLock); | 482 return LockedPtr<StringPool>(Strings.get(), &StringsLock); |
| 483 } | 483 } |
| 484 | 484 |
| 485 LockedPtr<VariableDeclarationList> getGlobals() { |
| 486 return LockedPtr<VariableDeclarationList>(&Globals, &InitAllocLock); |
| 487 } |
| 488 |
| 489 bool getGlobalsReceived() { return GlobalsReceived; } |
| 490 |
| 485 /// Number of function blocks that can be queued before waiting for | 491 /// Number of function blocks that can be queued before waiting for |
| 486 /// translation | 492 /// translation |
| 487 /// threads to consume. | 493 /// threads to consume. |
| 488 static constexpr size_t MaxOptQSize = 1 << 16; | 494 static constexpr size_t MaxOptQSize = 1 << 16; |
| 489 | 495 |
| 490 private: | 496 private: |
| 491 // Try to ensure mutexes are allocated on separate cache lines. | 497 // Try to ensure mutexes are allocated on separate cache lines. |
| 492 | 498 |
| 493 // Destructors collaborate with Allocator | 499 // Destructors collaborate with Allocator |
| 494 ICE_CACHELINE_BOUNDARY; | 500 ICE_CACHELINE_BOUNDARY; |
| 495 // Managed by getAllocator() | 501 // Managed by getAllocator() |
| 496 mutable GlobalLockType AllocLock; | 502 mutable GlobalLockType AllocLock; |
| 497 ArenaAllocator Allocator; | 503 ArenaAllocator Allocator; |
| 498 | 504 |
| 499 ICE_CACHELINE_BOUNDARY; | 505 ICE_CACHELINE_BOUNDARY; |
| 500 // Managed by getInitializerAllocator() | 506 // Managed by getInitializerAllocator() |
| 501 mutable GlobalLockType InitAllocLock; | 507 mutable GlobalLockType InitAllocLock; |
| 502 VariableDeclarationList Globals; | 508 VariableDeclarationList Globals; |
| 509 std::atomic<bool> GlobalsReceived; |
| 503 | 510 |
| 504 ICE_CACHELINE_BOUNDARY; | 511 ICE_CACHELINE_BOUNDARY; |
| 505 // Managed by getDestructors() | 512 // Managed by getDestructors() |
| 506 using DestructorArray = std::vector<std::function<void()>>; | 513 using DestructorArray = std::vector<std::function<void()>>; |
| 507 mutable GlobalLockType DestructorsLock; | 514 mutable GlobalLockType DestructorsLock; |
| 508 DestructorArray Destructors; | 515 DestructorArray Destructors; |
| 509 | 516 |
| 510 ICE_CACHELINE_BOUNDARY; | 517 ICE_CACHELINE_BOUNDARY; |
| 511 // Managed by getStrings() | 518 // Managed by getStrings() |
| 512 mutable GlobalLockType StringsLock; | 519 mutable GlobalLockType StringsLock; |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 return LockedPtr<TimerList>(&Timers, &TimerLock); | 612 return LockedPtr<TimerList>(&Timers, &TimerLock); |
| 606 } | 613 } |
| 607 LockedPtr<DestructorArray> getDestructors() { | 614 LockedPtr<DestructorArray> getDestructors() { |
| 608 return LockedPtr<DestructorArray>(&Destructors, &DestructorsLock); | 615 return LockedPtr<DestructorArray>(&Destructors, &DestructorsLock); |
| 609 } | 616 } |
| 610 | 617 |
| 611 void accumulateGlobals(std::unique_ptr<VariableDeclarationList> Globls) { | 618 void accumulateGlobals(std::unique_ptr<VariableDeclarationList> Globls) { |
| 612 LockedPtr<VariableDeclarationList> _(&Globals, &InitAllocLock); | 619 LockedPtr<VariableDeclarationList> _(&Globals, &InitAllocLock); |
| 613 if (Globls != nullptr) { | 620 if (Globls != nullptr) { |
| 614 Globals.merge(Globls.get()); | 621 Globals.merge(Globls.get()); |
| 622 GlobalsReceived = true; |
| 615 } | 623 } |
| 616 } | 624 } |
| 617 | 625 |
| 618 void lowerGlobalsIfNoCodeHasBeenSeen() { | 626 void lowerGlobalsIfNoCodeHasBeenSeen() { |
| 619 if (HasSeenCode) | 627 if (HasSeenCode) |
| 620 return; | 628 return; |
| 621 constexpr char NoSuffix[] = ""; | 629 constexpr char NoSuffix[] = ""; |
| 622 lowerGlobals(NoSuffix); | 630 lowerGlobals(NoSuffix); |
| 623 HasSeenCode = true; | 631 HasSeenCode = true; |
| 624 } | 632 } |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 692 explicit OstreamLocker(GlobalContext *Ctx) : Ctx(Ctx) { Ctx->lockStr(); } | 700 explicit OstreamLocker(GlobalContext *Ctx) : Ctx(Ctx) { Ctx->lockStr(); } |
| 693 ~OstreamLocker() { Ctx->unlockStr(); } | 701 ~OstreamLocker() { Ctx->unlockStr(); } |
| 694 | 702 |
| 695 private: | 703 private: |
| 696 GlobalContext *const Ctx; | 704 GlobalContext *const Ctx; |
| 697 }; | 705 }; |
| 698 | 706 |
| 699 } // end of namespace Ice | 707 } // end of namespace Ice |
| 700 | 708 |
| 701 #endif // SUBZERO_SRC_ICEGLOBALCONTEXT_H | 709 #endif // SUBZERO_SRC_ICEGLOBALCONTEXT_H |
| OLD | NEW |