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

Side by Side Diff: src/IceASanInstrumentation.h

Issue 2108083002: Implemented aligning and poisoning global redzones (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Rebased onto latest master 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
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
26 namespace Ice { 28 namespace Ice {
27 29
28 class ASanInstrumentation : public Instrumentation { 30 class ASanInstrumentation : public Instrumentation {
29 ASanInstrumentation() = delete; 31 ASanInstrumentation() = delete;
30 ASanInstrumentation(const ASanInstrumentation &) = delete; 32 ASanInstrumentation(const ASanInstrumentation &) = delete;
31 ASanInstrumentation &operator=(const ASanInstrumentation &) = delete; 33 ASanInstrumentation &operator=(const ASanInstrumentation &) = delete;
32 34
33 public: 35 public:
34 ASanInstrumentation(GlobalContext *Ctx) : Instrumentation(Ctx), RzNum(0) { 36 ASanInstrumentation(GlobalContext *Ctx)
37 : Instrumentation(Ctx), RzNum(0), RzGlobalsNum(0),
38 GlobalsLock(GlobalsMutex, std::defer_lock) {
35 ICE_TLS_INIT_FIELD(LocalDtors); 39 ICE_TLS_INIT_FIELD(LocalDtors);
36 } 40 }
37 void instrumentGlobals(VariableDeclarationList &Globals) override; 41 void instrumentGlobals(VariableDeclarationList &Globals) override;
38 42
39 private: 43 private:
40 std::string nextRzName(); 44 std::string nextRzName();
41 VariableDeclaration *createRz(VariableDeclarationList *List, 45 /*
Jim Stichnoth 2016/06/29 14:08:06 Why is this declaration (and its corresponding imp
tlively 2016/06/29 16:38:30 Oops. Done.
42 VariableDeclaration *RzArray, 46 VariableDeclaration *createGlobalRz(VariableDeclarationList *List,
43 SizeT &RzArraySize, 47 VariableDeclaration *RzArray,
44 VariableDeclaration *Global); 48 VariableDeclaration *RzSizes,
49 VariableDeclaration *Global);
50 */
45 void instrumentFuncStart(LoweringContext &Context) override; 51 void instrumentFuncStart(LoweringContext &Context) override;
46 void instrumentCall(LoweringContext &Context, InstCall *Instr) override; 52 void instrumentCall(LoweringContext &Context, InstCall *Instr) override;
47 void instrumentRet(LoweringContext &Context, InstRet *Instr) override; 53 void instrumentRet(LoweringContext &Context, InstRet *Instr) override;
48 void instrumentLoad(LoweringContext &Context, InstLoad *Instr) override; 54 void instrumentLoad(LoweringContext &Context, InstLoad *Instr) override;
49 void instrumentStore(LoweringContext &Context, InstStore *Instr) override; 55 void instrumentStore(LoweringContext &Context, InstStore *Instr) override;
50 void instrumentAccess(LoweringContext &Context, Operand *Op, SizeT Size); 56 void instrumentAccess(LoweringContext &Context, Operand *Op, SizeT Size);
51 void instrumentStart(Cfg *Func) override; 57 void instrumentStart(Cfg *Func) override;
52 void finishFunc(Cfg *Func) override; 58 void finishFunc(Cfg *Func) override;
53 ICE_TLS_DECLARE_FIELD(std::vector<InstCall *> *, LocalDtors); 59 ICE_TLS_DECLARE_FIELD(std::vector<InstCall *> *, LocalDtors);
54 bool DidInsertRedZones = false;
55 std::atomic<uint32_t> RzNum; 60 std::atomic<uint32_t> RzNum;
61 bool DidProcessGlobals = false;
62 SizeT RzGlobalsNum;
Jim Stichnoth 2016/06/29 14:08:06 SizeT RzGlobalsNum = 0; then you can remove it fr
tlively 2016/06/29 16:38:30 Done.
63 std::mutex GlobalsMutex;
64 std::unique_lock<std::mutex> GlobalsLock;
65 std::condition_variable GlobalsDoneCV;
56 }; 66 };
57 } // end of namespace Ice 67 } // end of namespace Ice
58 68
59 #endif // SUBZERO_SRC_ICEASANINSTRUMENTATION_H 69 #endif // SUBZERO_SRC_ICEASANINSTRUMENTATION_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698