2 +----------------------------------------------------------------------+
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010- Facebook, Inc. (http://www.facebook.com) |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
16 #include <util/base.h>
17 #include <runtime/vm/translator/x64-util.h>
18 #include <runtime/vm/translator/translator-x64.h>
19 #include <runtime/vm/stats.h>
27 __thread
uint64_t tl_counters
[kNumStatCounters
];
28 __thread
uint64_t tl_helper_counters
[kMaxNumTrampolines
];
30 // Only the thread holding the write lease will set the entries in the
31 // helperNames array but other threads may concurrently read these
32 // entries, so each entry is volatile (or an atomic type per the new
34 const char* volatile helperNames
[kMaxNumTrampolines
];
37 emitInc(Transl::X64Assembler
& a
,uint64_t* tl_table
,uint index
,int n
) {
38 using namespace HPHP::VM::Transl
;
39 uintptr_t virtualAddress
= uintptr_t(&tl_table
[index
]) - tlsBase();
40 emitImmReg(a
, virtualAddress
, reg::rScratch
);
42 a
. add_imm64_disp_reg64(n
, 0, reg::rScratch
);
47 void emitInc(Transl::X64Assembler
& a
, StatCounter stat
, int n
/* = 1*/) {
48 if (!enabled()) return;
49 emitInc(a
,&tl_counters
[0],stat
,n
);
52 void emitIncTranslOp(Transl::X64Assembler
& a
, Opcode opc
) {
53 if (!enableInstrCount()) return;
54 emitInc(a
, &tl_counters
[0], opcodeToTranslStatCounter(opc
), 1);
57 static __thread int64 epoch
;
59 if (!enabled()) return;
60 TRACE(1, "STATS %lld %s\n", epoch
, g_context
->getRequestUrl(50).c_str());
61 #include "runtime/vm/stats-opcodeDef.h"
63 if (tl_counters[s]) TRACE(1, "STAT %-50s %15ld\n", \
68 for (int i
=0; helperNames
[i
]; i
++) {
69 if (tl_helper_counters
[i
]) {
70 TRACE(1, "STAT %-50s %15ld\n",
72 tl_helper_counters
[i
]);
78 if (!enabled()) return;
80 memset(&tl_counters
[0], 0, sizeof(tl_counters
));
81 memset(&tl_helper_counters
[0], 0, sizeof(tl_helper_counters
));