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

Side by Side Diff: src/IceASanInstrumentation.h

Issue 2165493002: Subzero: Fixed deadlock with _start but no globals (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Moved an include to the proper file Created 4 years, 5 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 | « no previous file | src/IceASanInstrumentation.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/IceASanInstrumentation.h - AddressSanitizer --*- C++ -*-===// 1 //===- subzero/src/IceASanInstrumentation.h - AddressSanitizer --*- 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
11 /// \brief Declares the AddressSanitizer instrumentation class. 11 /// \brief Declares the AddressSanitizer instrumentation class.
12 /// 12 ///
13 /// This class is responsible for inserting redzones around global and stack 13 /// This class is responsible for inserting redzones around global and stack
14 /// variables, inserting code responsible for poisoning those redzones, and 14 /// variables, inserting code responsible for poisoning those redzones, and
15 /// performing any other instrumentation necessary to implement 15 /// performing any other instrumentation necessary to implement
16 /// AddressSanitizer. 16 /// AddressSanitizer.
17 /// 17 ///
18 //===----------------------------------------------------------------------===// 18 //===----------------------------------------------------------------------===//
19 19
20 #ifndef SUBZERO_SRC_ICEASANINSTRUMENTATION_H 20 #ifndef SUBZERO_SRC_ICEASANINSTRUMENTATION_H
21 #define SUBZERO_SRC_ICEASANINSTRUMENTATION_H 21 #define SUBZERO_SRC_ICEASANINSTRUMENTATION_H
22 22
23 #include "IceGlobalInits.h" 23 #include "IceGlobalInits.h"
24 #include "IceInstrumentation.h" 24 #include "IceInstrumentation.h"
25 25
26 #include <condition_variable>
27
28 namespace Ice { 26 namespace Ice {
29 27
30 class ASanInstrumentation : public Instrumentation { 28 class ASanInstrumentation : public Instrumentation {
31 ASanInstrumentation() = delete; 29 ASanInstrumentation() = delete;
32 ASanInstrumentation(const ASanInstrumentation &) = delete; 30 ASanInstrumentation(const ASanInstrumentation &) = delete;
33 ASanInstrumentation &operator=(const ASanInstrumentation &) = delete; 31 ASanInstrumentation &operator=(const ASanInstrumentation &) = delete;
34 32
35 public: 33 public:
36 ASanInstrumentation(GlobalContext *Ctx) 34 ASanInstrumentation(GlobalContext *Ctx) : Instrumentation(Ctx), RzNum(0) {
37 : Instrumentation(Ctx), RzNum(0),
38 GlobalsLock(GlobalsMutex, std::defer_lock) {
39 ICE_TLS_INIT_FIELD(LocalDtors); 35 ICE_TLS_INIT_FIELD(LocalDtors);
40 } 36 }
41 void instrumentGlobals(VariableDeclarationList &Globals) override; 37 void instrumentGlobals(VariableDeclarationList &Globals) override;
42 38
43 private: 39 private:
44 std::string nextRzName(); 40 std::string nextRzName();
45 bool isInstrumentable(Cfg *Func) override; 41 bool isInstrumentable(Cfg *Func) override;
46 void instrumentFuncStart(LoweringContext &Context) override; 42 void instrumentFuncStart(LoweringContext &Context) override;
47 void instrumentCall(LoweringContext &Context, InstCall *Instr) override; 43 void instrumentCall(LoweringContext &Context, InstCall *Instr) override;
48 void instrumentRet(LoweringContext &Context, InstRet *Instr) override; 44 void instrumentRet(LoweringContext &Context, InstRet *Instr) override;
49 void instrumentLoad(LoweringContext &Context, InstLoad *Instr) override; 45 void instrumentLoad(LoweringContext &Context, InstLoad *Instr) override;
50 void instrumentStore(LoweringContext &Context, InstStore *Instr) override; 46 void instrumentStore(LoweringContext &Context, InstStore *Instr) override;
51 void instrumentAccess(LoweringContext &Context, Operand *Op, SizeT Size, 47 void instrumentAccess(LoweringContext &Context, Operand *Op, SizeT Size,
52 Constant *AccessFunc); 48 Constant *AccessFunc);
53 void instrumentStart(Cfg *Func) override; 49 void instrumentStart(Cfg *Func) override;
54 void finishFunc(Cfg *Func) override; 50 void finishFunc(Cfg *Func) override;
55 ICE_TLS_DECLARE_FIELD(std::vector<InstCall *> *, LocalDtors); 51 ICE_TLS_DECLARE_FIELD(std::vector<InstCall *> *, LocalDtors);
56 std::atomic<uint32_t> RzNum; 52 std::atomic<uint32_t> RzNum;
57 bool DidProcessGlobals = false; 53 bool DidProcessGlobals = false;
58 SizeT RzGlobalsNum = 0; 54 SizeT RzGlobalsNum = 0;
59 std::mutex GlobalsMutex; 55 std::mutex GlobalsMutex;
60 std::unique_lock<std::mutex> GlobalsLock;
61 std::condition_variable GlobalsDoneCV;
62 }; 56 };
63 } // end of namespace Ice 57 } // end of namespace Ice
64 58
65 #endif // SUBZERO_SRC_ICEASANINSTRUMENTATION_H 59 #endif // SUBZERO_SRC_ICEASANINSTRUMENTATION_H
OLDNEW
« no previous file with comments | « no previous file | src/IceASanInstrumentation.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698