2 +----------------------------------------------------------------------+
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-present 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 +----------------------------------------------------------------------+
17 #include "hphp/runtime/vm/jit/smashable-instr.h"
19 #include "hphp/runtime/vm/jit/smashable-instr-arm.h"
20 #include "hphp/runtime/vm/jit/smashable-instr-x64.h"
21 #include "hphp/runtime/vm/jit/smashable-instr-ppc64.h"
22 #include "hphp/runtime/vm/jit/tc.h"
24 #include "hphp/util/arch.h"
25 #include "hphp/util/asm-x64.h"
26 #include "hphp/util/data-block.h"
28 namespace HPHP
{ namespace jit
{
30 ///////////////////////////////////////////////////////////////////////////////
32 size_t smashableMovqLen() {
33 return ARCH_SWITCH_CALL(smashableMovqLen
);
35 size_t smashableCmpqLen() {
36 return ARCH_SWITCH_CALL(smashableCmpqLen
);
38 size_t smashableCallLen() {
39 return ARCH_SWITCH_CALL(smashableCallLen
);
41 size_t smashableJmpLen() {
42 return ARCH_SWITCH_CALL(smashableJmpLen
);
44 size_t smashableJccLen() {
45 return ARCH_SWITCH_CALL(smashableJccLen
);
48 TCA
emitSmashableMovq(CodeBlock
& cb
, CGMeta
& fixups
, uint64_t imm
,
50 return ARCH_SWITCH_CALL(emitSmashableMovq
, cb
, fixups
, imm
, d
);
52 TCA
emitSmashableCmpq(CodeBlock
& cb
, CGMeta
& fixups
, int32_t imm
,
53 PhysReg r
, int8_t disp
) {
54 return ARCH_SWITCH_CALL(emitSmashableCmpq
, cb
, fixups
, imm
, r
, disp
);
56 TCA
emitSmashableCall(CodeBlock
& cb
, CGMeta
& fixups
, TCA target
) {
57 return ARCH_SWITCH_CALL(emitSmashableCall
, cb
, fixups
, target
);
59 TCA
emitSmashableJmp(CodeBlock
& cb
, CGMeta
& fixups
, TCA target
) {
60 return ARCH_SWITCH_CALL(emitSmashableJmp
, cb
, fixups
, target
);
62 TCA
emitSmashableJcc(CodeBlock
& cb
, CGMeta
& fixups
, TCA target
,
64 return ARCH_SWITCH_CALL(emitSmashableJcc
, cb
, fixups
, target
, cc
);
67 void smashMovq(TCA inst
, uint64_t imm
) {
68 return ARCH_SWITCH_CALL(smashMovq
, inst
, imm
);
70 void smashCmpq(TCA inst
, uint32_t imm
) {
71 return ARCH_SWITCH_CALL(smashCmpq
, inst
, imm
);
73 void smashCall(TCA inst
, TCA target
) {
74 return ARCH_SWITCH_CALL(smashCall
, inst
, target
);
76 void smashJmp(TCA inst
, TCA target
) {
77 return ARCH_SWITCH_CALL(smashJmp
, inst
, target
);
79 void smashJcc(TCA inst
, TCA target
) {
80 return ARCH_SWITCH_CALL(smashJcc
, inst
, target
);
83 uint64_t smashableMovqImm(TCA inst
) {
84 return ARCH_SWITCH_CALL(smashableMovqImm
, inst
);
86 uint32_t smashableCmpqImm(TCA inst
) {
87 return ARCH_SWITCH_CALL(smashableCmpqImm
, inst
);
89 TCA
smashableCallTarget(TCA inst
) {
90 return ARCH_SWITCH_CALL(smashableCallTarget
, inst
);
92 TCA
smashableJmpTarget(TCA inst
) {
93 return ARCH_SWITCH_CALL(smashableJmpTarget
, inst
);
95 TCA
smashableJccTarget(TCA inst
) {
96 return ARCH_SWITCH_CALL(smashableJccTarget
, inst
);
98 ConditionCode
smashableJccCond(TCA inst
) {
99 return ARCH_SWITCH_CALL(smashableJccCond
, inst
);
103 * Right now, our smashable calls are always a known size. If this ever
104 * changes, this implementation will need to be architecture-dependent (and
105 * the sizeof* routine will probably need to take a TCA).
107 TCA
smashableCallFromRet(TCA ret
) {
108 return ret
- smashableCallLen();
111 ///////////////////////////////////////////////////////////////////////////////