Delete 2 unused IROPs.
[hiphop-php.git] / hphp / runtime / vm / jit / irlower-exception.cpp
blobd5a6329f883072a79e74fb02de24923d9c528eeb
1 /*
2 +----------------------------------------------------------------------+
3 | HipHop for PHP |
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/irlower-internal.h"
19 #include "hphp/runtime/base/stats.h"
21 #include "hphp/runtime/vm/jit/types.h"
22 #include "hphp/runtime/vm/jit/abi.h"
23 #include "hphp/runtime/vm/jit/code-gen-helpers.h"
24 #include "hphp/runtime/vm/jit/ir-instruction.h"
25 #include "hphp/runtime/vm/jit/ir-opcode.h"
26 #include "hphp/runtime/vm/jit/ssa-tmp.h"
27 #include "hphp/runtime/vm/jit/tc.h"
28 #include "hphp/runtime/vm/jit/unique-stubs.h"
29 #include "hphp/runtime/vm/jit/unwind-itanium.h"
30 #include "hphp/runtime/vm/jit/vasm-gen.h"
31 #include "hphp/runtime/vm/jit/vasm-instr.h"
32 #include "hphp/runtime/vm/jit/vasm-reg.h"
34 #include "hphp/util/asm-x64.h"
35 #include "hphp/util/text-util.h"
36 #include "hphp/util/trace.h"
38 namespace HPHP { namespace jit { namespace irlower {
40 TRACE_SET_MOD(irlower);
42 ///////////////////////////////////////////////////////////////////////////////
44 void cgBeginCatch(IRLS& env, const IRInstruction* /*inst*/) {
45 auto& v = vmain(env);
47 v << landingpad{};
48 emitIncStat(v, Stats::TC_CatchTrace);
51 void cgEndCatch(IRLS& env, const IRInstruction* inst) {
52 auto& v = vmain(env);
54 auto const helper =
55 inst->extra<EndCatch>()->stublogue == EndCatchData::FrameMode::Stublogue
56 ? tc::ustubs().endCatchStublogueHelper
57 : tc::ustubs().endCatchHelper;
59 // endCatch*Helpers only expect vm_regs_no_sp() to be alive.
60 v << jmpi{helper, vm_regs_no_sp()};
63 void cgUnwindCheckSideExit(IRLS& env, const IRInstruction* inst) {
64 auto& v = vmain(env);
66 auto const sf = v.makeReg();
67 v << cmpbim{0, rvmtl()[unwinderSideExitOff()], sf};
68 fwdJcc(v, env, CC_E, sf, inst->taken());
70 // doSideExit == true, so fall through to the side exit code.
71 emitIncStat(v, Stats::TC_CatchSideExit);
74 void cgLdUnwinderValue(IRLS& env, const IRInstruction* inst) {
75 auto& v = vmain(env);
76 loadTV(v, inst->dst(), dstLoc(env, inst, 0), rvmtl()[unwinderTVOff()]);
79 void cgEnterTCUnwind(IRLS& env, const IRInstruction* inst) {
80 auto& v = vmain(env);
81 auto const exn = srcLoc(env, inst, 0).reg();
82 v << storebi{1, rvmtl()[unwinderSideEnterOff()]};
83 v << store{exn, rvmtl()[unwinderExnOff()]};
84 v << copy{rvmfp(), rarg(0)};
85 v << call{TCA(tc_unwind_resume), arg_regs(1)};
86 v << copy{rret(1), rvmfp()};
87 v << jmpr{rret(0), vm_regs_with_sp()};
90 IMPL_OPCODE_CALL(DebugBacktrace)
91 IMPL_OPCODE_CALL(DebugBacktraceFast)
93 ///////////////////////////////////////////////////////////////////////////////
95 static void raiseHackArrCompatNotice(const StringData* msg) {
96 raise_hackarr_compat_notice(msg->toCppString());
99 void cgRaiseHackArrCompatNotice(IRLS& env, const IRInstruction* inst) {
100 cgCallHelper(vmain(env), env, CallSpec::direct(raiseHackArrCompatNotice),
101 kVoidDest, SyncOptions::Sync, argGroup(env, inst).ssa(0));
104 static void raiseForbiddenDynCall(const Func* func) {
105 assertx(!func->isDynamicallyCallable() ||
106 RuntimeOption::EvalForbidDynamicCallsWithAttr);
107 int dynCallErrorLevel = func->isMethod() ?
109 func->isStatic() ?
110 RuntimeOption::EvalForbidDynamicCallsToClsMeth :
111 RuntimeOption::EvalForbidDynamicCallsToInstMeth
113 RuntimeOption::EvalForbidDynamicCallsToFunc;
114 if (dynCallErrorLevel <= 0) return;
116 auto error_msg = func->isDynamicallyCallable() ?
117 Strings::FUNCTION_CALLED_DYNAMICALLY_WITH_ATTRIBUTE :
118 Strings::FUNCTION_CALLED_DYNAMICALLY_WITHOUT_ATTRIBUTE;
119 if (dynCallErrorLevel >= 2) {
120 std::string msg;
121 string_printf(
122 msg,
123 error_msg,
124 func->fullName()->data()
126 throw_invalid_operation_exception(makeStaticString(msg));
127 } else {
128 raise_notice(
129 error_msg,
130 func->fullName()->data()
135 static void raiseForbiddenDynConstruct(const Class* cls) {
136 assertx(RuntimeOption::EvalForbidDynamicConstructs > 0);
137 assertx(!cls->isDynamicallyConstructible());
139 if (RuntimeOption::EvalForbidDynamicConstructs >= 2) {
140 std::string msg;
141 string_printf(
142 msg,
143 Strings::CLASS_CONSTRUCTED_DYNAMICALLY,
144 cls->name()->data()
146 throw_invalid_operation_exception(makeStaticString(msg));
147 } else {
148 raise_notice(
149 Strings::CLASS_CONSTRUCTED_DYNAMICALLY,
150 cls->name()->data()
155 void cgRaiseForbiddenDynCall(IRLS& env, const IRInstruction* inst) {
156 cgCallHelper(vmain(env), env, CallSpec::direct(raiseForbiddenDynCall),
157 kVoidDest, SyncOptions::Sync, argGroup(env, inst).ssa(0));
160 void cgRaiseForbiddenDynConstruct(IRLS& env, const IRInstruction* inst) {
161 cgCallHelper(vmain(env), env, CallSpec::direct(raiseForbiddenDynConstruct),
162 kVoidDest, SyncOptions::Sync, argGroup(env, inst).ssa(0));
165 void cgThrowLateInitPropError(IRLS& env, const IRInstruction* inst) {
166 cgCallHelper(vmain(env), env, CallSpec::direct(throw_late_init_prop),
167 kVoidDest, SyncOptions::Sync,
168 argGroup(env, inst).ssa(0).ssa(1).ssa(2));
171 ///////////////////////////////////////////////////////////////////////////////
173 IMPL_OPCODE_CALL(InitThrowableFileAndLine)
174 IMPL_OPCODE_CALL(ZeroErrorLevel)
175 IMPL_OPCODE_CALL(RestoreErrorLevel)
177 ///////////////////////////////////////////////////////////////////////////////
179 IMPL_OPCODE_CALL(CheckClsReifiedGenericMismatch)
180 IMPL_OPCODE_CALL(CheckFunReifiedGenericMismatch)
181 IMPL_OPCODE_CALL(RaiseErrorOnInvalidIsAsExpressionType)
182 IMPL_OPCODE_CALL(RaiseClsMethPropConvertNotice)
183 IMPL_OPCODE_CALL(RaiseError)
184 IMPL_OPCODE_CALL(RaiseTooManyArg)
185 IMPL_OPCODE_CALL(RaiseNotice)
186 IMPL_OPCODE_CALL(RaiseUndefProp)
187 IMPL_OPCODE_CALL(RaiseUninitLoc)
188 IMPL_OPCODE_CALL(RaiseWarning)
189 IMPL_OPCODE_CALL(RaiseRxCallViolation)
190 IMPL_OPCODE_CALL(ThrowArrayIndexException)
191 IMPL_OPCODE_CALL(ThrowArrayKeyException)
192 IMPL_OPCODE_CALL(ThrowAsTypeStructException)
193 IMPL_OPCODE_CALL(ThrowCallReifiedFunctionWithoutGenerics)
194 IMPL_OPCODE_CALL(ThrowDivisionByZeroException)
195 IMPL_OPCODE_CALL(ThrowHasThisNeedStatic)
196 IMPL_OPCODE_CALL(ThrowInvalidArrayKey)
197 IMPL_OPCODE_CALL(ThrowInvalidOperation)
198 IMPL_OPCODE_CALL(ThrowMissingArg)
199 IMPL_OPCODE_CALL(ThrowMissingThis)
200 IMPL_OPCODE_CALL(ThrowOutOfBounds)
201 IMPL_OPCODE_CALL(ThrowParameterWrongType)
202 IMPL_OPCODE_CALL(ThrowParamInOutMismatch)
203 IMPL_OPCODE_CALL(ThrowParamInOutMismatchRange)
205 ///////////////////////////////////////////////////////////////////////////////