Line data Source code
1 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 : * vim: set ts=8 sts=4 et sw=4 tw=99:
3 : * This Source Code Form is subject to the terms of the Mozilla Public
4 : * License, v. 2.0. If a copy of the MPL was not distributed with this
5 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 :
7 : #ifndef jit_CacheIRSpewer_h
8 : #define jit_CacheIRSpewer_h
9 :
10 : #ifdef JS_CACHEIR_SPEW
11 :
12 : #include "mozilla/Maybe.h"
13 :
14 : #include "jit/CacheIR.h"
15 : #include "js/TypeDecls.h"
16 : #include "threading/LockGuard.h"
17 : #include "vm/JSONPrinter.h"
18 : #include "vm/MutexIDs.h"
19 :
20 : namespace js {
21 : namespace jit {
22 :
23 : class CacheIRSpewer
24 : {
25 : Mutex outputLock;
26 : Fprinter output;
27 : mozilla::Maybe<JSONPrinter> json;
28 : static CacheIRSpewer cacheIRspewer;
29 :
30 : public:
31 :
32 : CacheIRSpewer();
33 : ~CacheIRSpewer();
34 :
35 7514 : static CacheIRSpewer& singleton() { return cacheIRspewer; }
36 :
37 : bool init();
38 7514 : bool enabled() { return json.isSome(); }
39 :
40 : // These methods can only be called when enabled() is true.
41 0 : Mutex& lock() { MOZ_ASSERT(enabled()); return outputLock; }
42 :
43 : void beginCache(LockGuard<Mutex>&, const IRGenerator& generator);
44 : void valueProperty(LockGuard<Mutex>&, const char* name, const Value& v);
45 : void attached(LockGuard<Mutex>&, const char* name);
46 : void endCache(LockGuard<Mutex>&);
47 : };
48 :
49 : } // namespace jit
50 : } // namespace js
51 :
52 : #endif /* JS_CACHEIR_SPEW */
53 :
54 : #endif /* jit_CacheIRSpewer_h */
|