1*795d594fSAndroid Build Coastguard Worker /*
2*795d594fSAndroid Build Coastguard Worker * Copyright (C) 2012 The Android Open Source Project
3*795d594fSAndroid Build Coastguard Worker *
4*795d594fSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License");
5*795d594fSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License.
6*795d594fSAndroid Build Coastguard Worker * You may obtain a copy of the License at
7*795d594fSAndroid Build Coastguard Worker *
8*795d594fSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0
9*795d594fSAndroid Build Coastguard Worker *
10*795d594fSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software
11*795d594fSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS,
12*795d594fSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*795d594fSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and
14*795d594fSAndroid Build Coastguard Worker * limitations under the License.
15*795d594fSAndroid Build Coastguard Worker */
16*795d594fSAndroid Build Coastguard Worker
17*795d594fSAndroid Build Coastguard Worker #include "arch/context.h"
18*795d594fSAndroid Build Coastguard Worker #include "base/logging.h" // For VLOG_IS_ON.
19*795d594fSAndroid Build Coastguard Worker #include "base/mutex.h"
20*795d594fSAndroid Build Coastguard Worker #include "callee_save_frame.h"
21*795d594fSAndroid Build Coastguard Worker #include "interpreter/interpreter.h"
22*795d594fSAndroid Build Coastguard Worker #include "obj_ptr-inl.h" // TODO: Find the other include that isn't complete, and clean this up.
23*795d594fSAndroid Build Coastguard Worker #include "quick_exception_handler.h"
24*795d594fSAndroid Build Coastguard Worker #include "runtime.h"
25*795d594fSAndroid Build Coastguard Worker #include "thread.h"
26*795d594fSAndroid Build Coastguard Worker
27*795d594fSAndroid Build Coastguard Worker namespace art HIDDEN {
28*795d594fSAndroid Build Coastguard Worker
artDeoptimize(Thread * self,bool skip_method_exit_callbacks)29*795d594fSAndroid Build Coastguard Worker extern "C" Context* artDeoptimize(Thread* self, bool skip_method_exit_callbacks)
30*795d594fSAndroid Build Coastguard Worker REQUIRES_SHARED(Locks::mutator_lock_) {
31*795d594fSAndroid Build Coastguard Worker ScopedQuickEntrypointChecks sqec(self);
32*795d594fSAndroid Build Coastguard Worker std::unique_ptr<Context> context = self->Deoptimize(DeoptimizationKind::kFullFrame,
33*795d594fSAndroid Build Coastguard Worker /*single_frame=*/ false,
34*795d594fSAndroid Build Coastguard Worker skip_method_exit_callbacks);
35*795d594fSAndroid Build Coastguard Worker DCHECK(context != nullptr);
36*795d594fSAndroid Build Coastguard Worker return context.release();
37*795d594fSAndroid Build Coastguard Worker }
38*795d594fSAndroid Build Coastguard Worker
39*795d594fSAndroid Build Coastguard Worker // This is called directly from compiled code by an HDeoptimize.
artDeoptimizeFromCompiledCode(DeoptimizationKind kind,Thread * self)40*795d594fSAndroid Build Coastguard Worker extern "C" Context* artDeoptimizeFromCompiledCode(DeoptimizationKind kind, Thread* self)
41*795d594fSAndroid Build Coastguard Worker REQUIRES_SHARED(Locks::mutator_lock_) {
42*795d594fSAndroid Build Coastguard Worker ScopedQuickEntrypointChecks sqec(self);
43*795d594fSAndroid Build Coastguard Worker // Before deoptimizing to interpreter, we must push the deoptimization context.
44*795d594fSAndroid Build Coastguard Worker JValue return_value;
45*795d594fSAndroid Build Coastguard Worker return_value.SetJ(0); // we never deoptimize from compiled code with an invoke result.
46*795d594fSAndroid Build Coastguard Worker self->PushDeoptimizationContext(return_value,
47*795d594fSAndroid Build Coastguard Worker /* is_reference= */ false,
48*795d594fSAndroid Build Coastguard Worker self->GetException(),
49*795d594fSAndroid Build Coastguard Worker /* from_code= */ true,
50*795d594fSAndroid Build Coastguard Worker DeoptimizationMethodType::kDefault);
51*795d594fSAndroid Build Coastguard Worker // Deopting from compiled code, so method exit haven't run yet. Don't skip method exit callbacks
52*795d594fSAndroid Build Coastguard Worker // if required.
53*795d594fSAndroid Build Coastguard Worker std::unique_ptr<Context> context = self->Deoptimize(kind,
54*795d594fSAndroid Build Coastguard Worker /*single_frame=*/ true,
55*795d594fSAndroid Build Coastguard Worker /* skip_method_exit_callbacks= */ false);
56*795d594fSAndroid Build Coastguard Worker DCHECK(context != nullptr);
57*795d594fSAndroid Build Coastguard Worker return context.release();
58*795d594fSAndroid Build Coastguard Worker }
59*795d594fSAndroid Build Coastguard Worker
60*795d594fSAndroid Build Coastguard Worker } // namespace art
61