]>
Commit | Line | Data |
---|---|---|
81345200 A |
1 | /* |
2 | * Copyright (C) 2013 Apple Inc. All rights reserved. | |
3 | * | |
4 | * Redistribution and use in source and binary forms, with or without | |
5 | * modification, are permitted provided that the following conditions | |
6 | * are met: | |
7 | * 1. Redistributions of source code must retain the above copyright | |
8 | * notice, this list of conditions and the following disclaimer. | |
9 | * 2. Redistributions in binary form must reproduce the above copyright | |
10 | * notice, this list of conditions and the following disclaimer in the | |
11 | * documentation and/or other materials provided with the distribution. | |
12 | * | |
13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY | |
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR | |
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | |
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
24 | */ | |
25 | ||
26 | #include "config.h" | |
27 | ||
28 | #if ENABLE(ASSEMBLER) && CPU(ARM_THUMB2) | |
29 | #include "MacroAssemblerARMv7.h" | |
30 | ||
31 | #if USE(MASM_PROBE) | |
32 | #include <wtf/StdLibExtras.h> | |
33 | #endif | |
34 | ||
35 | namespace JSC { | |
36 | ||
37 | #if USE(MASM_PROBE) | |
38 | ||
39 | void MacroAssemblerARMv7::ProbeContext::dumpCPURegisters(const char* indentation) | |
40 | { | |
41 | #define DUMP_GPREGISTER(_type, _regName) { \ | |
42 | int32_t value = reinterpret_cast<int32_t>(cpu._regName); \ | |
43 | dataLogF("%s %5s: 0x%08x %d\n", indentation, #_regName, value, value) ; \ | |
44 | } | |
45 | FOR_EACH_CPU_GPREGISTER(DUMP_GPREGISTER) | |
46 | FOR_EACH_CPU_SPECIAL_REGISTER(DUMP_GPREGISTER) | |
47 | #undef DUMP_GPREGISTER | |
48 | ||
49 | #define DUMP_FPREGISTER(_type, _regName) { \ | |
50 | uint32_t* u = reinterpret_cast<uint32_t*>(&cpu._regName); \ | |
51 | double* d = reinterpret_cast<double*>(&cpu._regName); \ | |
52 | dataLogF("%s %5s: 0x %08x %08x %12g\n", \ | |
53 | indentation, #_regName, u[1], u[0], d[0]); \ | |
54 | } | |
55 | FOR_EACH_CPU_FPREGISTER(DUMP_FPREGISTER) | |
56 | #undef DUMP_FPREGISTER | |
57 | } | |
58 | ||
59 | void MacroAssemblerARMv7::ProbeContext::dump(const char* indentation) | |
60 | { | |
61 | if (!indentation) | |
62 | indentation = ""; | |
63 | ||
64 | dataLogF("%sProbeContext %p {\n", indentation, this); | |
65 | dataLogF("%s probeFunction: %p\n", indentation, probeFunction); | |
66 | dataLogF("%s arg1: %p %llu\n", indentation, arg1, reinterpret_cast<int64_t>(arg1)); | |
67 | dataLogF("%s arg2: %p %llu\n", indentation, arg2, reinterpret_cast<int64_t>(arg2)); | |
68 | dataLogF("%s cpu: {\n", indentation); | |
69 | ||
70 | dumpCPURegisters(indentation); | |
71 | ||
72 | dataLogF("%s }\n", indentation); | |
73 | dataLogF("%s}\n", indentation); | |
74 | } | |
75 | ||
76 | ||
77 | extern "C" void ctiMasmProbeTrampoline(); | |
78 | ||
79 | // For details on "What code is emitted for the probe?" and "What values are in | |
80 | // the saved registers?", see comment for MacroAssemblerX86::probe() in | |
81 | // MacroAssemblerX86_64.h. | |
82 | ||
83 | void MacroAssemblerARMv7::probe(MacroAssemblerARMv7::ProbeFunction function, void* arg1, void* arg2) | |
84 | { | |
85 | push(RegisterID::lr); | |
86 | push(RegisterID::lr); | |
87 | add32(TrustedImm32(8), RegisterID::sp, RegisterID::lr); | |
88 | store32(RegisterID::lr, ArmAddress(RegisterID::sp, 4)); | |
89 | push(RegisterID::ip); | |
90 | push(RegisterID::r0); | |
91 | // The following uses RegisterID::ip. So, they must come after we push ip above. | |
92 | push(trustedImm32FromPtr(arg2)); | |
93 | push(trustedImm32FromPtr(arg1)); | |
94 | push(trustedImm32FromPtr(function)); | |
95 | ||
96 | move(trustedImm32FromPtr(ctiMasmProbeTrampoline), RegisterID::ip); | |
97 | m_assembler.blx(RegisterID::ip); | |
98 | } | |
99 | #endif // USE(MASM_PROBE) | |
100 | ||
101 | } // namespace JSC | |
102 | ||
103 | #endif // ENABLE(ASSEMBLER) | |
104 |