diff options
| -rw-r--r-- | runtime/interpreter/interpreter.cc | 25 | ||||
| -rw-r--r-- | runtime/interpreter/interpreter_common.h | 15 | ||||
| -rw-r--r-- | runtime/interpreter/interpreter_goto_table_impl.cc | 47 | ||||
| -rw-r--r-- | runtime/interpreter/interpreter_goto_table_impl.h | 41 | ||||
| -rw-r--r-- | runtime/interpreter/interpreter_mterp_impl.h | 41 | ||||
| -rw-r--r-- | runtime/interpreter/interpreter_switch_impl.cc | 10 | ||||
| -rw-r--r-- | runtime/interpreter/interpreter_switch_impl.h | 42 |
7 files changed, 172 insertions, 49 deletions
diff --git a/runtime/interpreter/interpreter.cc b/runtime/interpreter/interpreter.cc index f1f7f42117..101c9a1438 100644 --- a/runtime/interpreter/interpreter.cc +++ b/runtime/interpreter/interpreter.cc @@ -20,6 +20,9 @@ #include "common_throws.h" #include "interpreter_common.h" +#include "interpreter_goto_table_impl.h" +#include "interpreter_mterp_impl.h" +#include "interpreter_switch_impl.h" #include "mirror/string-inl.h" #include "scoped_thread_state_change.h" #include "ScopedLocalRef.h" @@ -242,28 +245,6 @@ static std::ostream& operator<<(std::ostream& os, const InterpreterImplKind& rhs static constexpr InterpreterImplKind kInterpreterImplKind = kMterpImplKind; -#if defined(__clang__) -// Clang 3.4 fails to build the goto interpreter implementation. -template<bool do_access_check, bool transaction_active> -JValue ExecuteGotoImpl(Thread*, const DexFile::CodeItem*, ShadowFrame&, JValue) { - LOG(FATAL) << "UNREACHABLE"; - UNREACHABLE(); -} -// Explicit definitions of ExecuteGotoImpl. -template<> SHARED_REQUIRES(Locks::mutator_lock_) -JValue ExecuteGotoImpl<true, false>(Thread* self, const DexFile::CodeItem* code_item, - ShadowFrame& shadow_frame, JValue result_register); -template<> SHARED_REQUIRES(Locks::mutator_lock_) -JValue ExecuteGotoImpl<false, false>(Thread* self, const DexFile::CodeItem* code_item, - ShadowFrame& shadow_frame, JValue result_register); -template<> SHARED_REQUIRES(Locks::mutator_lock_) -JValue ExecuteGotoImpl<true, true>(Thread* self, const DexFile::CodeItem* code_item, - ShadowFrame& shadow_frame, JValue result_register); -template<> SHARED_REQUIRES(Locks::mutator_lock_) -JValue ExecuteGotoImpl<false, true>(Thread* self, const DexFile::CodeItem* code_item, - ShadowFrame& shadow_frame, JValue result_register); -#endif - static inline JValue Execute( Thread* self, const DexFile::CodeItem* code_item, diff --git a/runtime/interpreter/interpreter_common.h b/runtime/interpreter/interpreter_common.h index 90c8227443..ce3b1eb36c 100644 --- a/runtime/interpreter/interpreter_common.h +++ b/runtime/interpreter/interpreter_common.h @@ -65,21 +65,6 @@ using ::art::mirror::Throwable; namespace art { namespace interpreter { -// External references to all interpreter implementations. - -template<bool do_access_check, bool transaction_active> -extern JValue ExecuteSwitchImpl(Thread* self, const DexFile::CodeItem* code_item, - ShadowFrame& shadow_frame, JValue result_register, - bool interpret_one_instruction); - -template<bool do_access_check, bool transaction_active> -extern JValue ExecuteGotoImpl(Thread* self, const DexFile::CodeItem* code_item, - ShadowFrame& shadow_frame, JValue result_register); - -// Mterp does not support transactions or access check, thus no templated versions. -extern "C" bool ExecuteMterpImpl(Thread* self, const DexFile::CodeItem* code_item, - ShadowFrame* shadow_frame, JValue* result_register); - void ThrowNullPointerExceptionFromInterpreter() SHARED_REQUIRES(Locks::mutator_lock_); diff --git a/runtime/interpreter/interpreter_goto_table_impl.cc b/runtime/interpreter/interpreter_goto_table_impl.cc index 43b27781e4..25cb4b3a70 100644 --- a/runtime/interpreter/interpreter_goto_table_impl.cc +++ b/runtime/interpreter/interpreter_goto_table_impl.cc @@ -14,18 +14,29 @@ * limitations under the License. */ -#if !defined(__clang__) -// Clang 3.4 fails to build the goto interpreter implementation. +#include "interpreter_goto_table_impl.h" +// Common includes +#include "base/logging.h" +#include "base/macros.h" +#include "base/mutex.h" +#include "stack.h" +#include "thread.h" +// Clang compiles the GOTO interpreter very slowly. So we skip it. These are the implementation +// details only necessary when compiling it. +#if !defined(__clang__) #include "experimental_flags.h" #include "interpreter_common.h" #include "jit/jit.h" #include "safe_math.h" +#endif namespace art { namespace interpreter { +#if !defined(__clang__) + // In the following macros, we expect the following local variables exist: // - "self": the current Thread*. // - "inst" : the current Instruction*. @@ -2558,20 +2569,40 @@ JValue ExecuteGotoImpl(Thread* self, const DexFile::CodeItem* code_item, ShadowF } // NOLINT(readability/fn_size) // Explicit definitions of ExecuteGotoImpl. -template SHARED_REQUIRES(Locks::mutator_lock_) HOT_ATTR +template HOT_ATTR JValue ExecuteGotoImpl<true, false>(Thread* self, const DexFile::CodeItem* code_item, ShadowFrame& shadow_frame, JValue result_register); -template SHARED_REQUIRES(Locks::mutator_lock_) HOT_ATTR +template HOT_ATTR JValue ExecuteGotoImpl<false, false>(Thread* self, const DexFile::CodeItem* code_item, ShadowFrame& shadow_frame, JValue result_register); -template SHARED_REQUIRES(Locks::mutator_lock_) +template JValue ExecuteGotoImpl<true, true>(Thread* self, const DexFile::CodeItem* code_item, ShadowFrame& shadow_frame, JValue result_register); -template SHARED_REQUIRES(Locks::mutator_lock_) +template JValue ExecuteGotoImpl<false, true>(Thread* self, const DexFile::CodeItem* code_item, ShadowFrame& shadow_frame, JValue result_register); -} // namespace interpreter -} // namespace art +#else +template<bool do_access_check, bool transaction_active> +JValue ExecuteGotoImpl(Thread*, const DexFile::CodeItem*, ShadowFrame&, JValue) { + LOG(FATAL) << "UNREACHABLE"; + UNREACHABLE(); +} +// Explicit definitions of ExecuteGotoImpl. +template<> +JValue ExecuteGotoImpl<true, false>(Thread* self, const DexFile::CodeItem* code_item, + ShadowFrame& shadow_frame, JValue result_register); +template<> +JValue ExecuteGotoImpl<false, false>(Thread* self, const DexFile::CodeItem* code_item, + ShadowFrame& shadow_frame, JValue result_register); +template<> +JValue ExecuteGotoImpl<true, true>(Thread* self, const DexFile::CodeItem* code_item, + ShadowFrame& shadow_frame, JValue result_register); +template<> +JValue ExecuteGotoImpl<false, true>(Thread* self, const DexFile::CodeItem* code_item, + ShadowFrame& shadow_frame, JValue result_register); #endif + +} // namespace interpreter +} // namespace art diff --git a/runtime/interpreter/interpreter_goto_table_impl.h b/runtime/interpreter/interpreter_goto_table_impl.h new file mode 100644 index 0000000000..bb9be881fe --- /dev/null +++ b/runtime/interpreter/interpreter_goto_table_impl.h @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ART_RUNTIME_INTERPRETER_INTERPRETER_GOTO_TABLE_IMPL_H_ +#define ART_RUNTIME_INTERPRETER_INTERPRETER_GOTO_TABLE_IMPL_H_ + +#include "base/macros.h" +#include "base/mutex.h" +#include "dex_file.h" +#include "jvalue.h" + +namespace art { + +class ShadowFrame; +class Thread; + +namespace interpreter { + +template<bool do_access_check, bool transaction_active> +JValue ExecuteGotoImpl(Thread* self, + const DexFile::CodeItem* code_item, + ShadowFrame& shadow_frame, + JValue result_register) SHARED_REQUIRES(Locks::mutator_lock_); + +} // namespace interpreter +} // namespace art + +#endif // ART_RUNTIME_INTERPRETER_INTERPRETER_GOTO_TABLE_IMPL_H_ diff --git a/runtime/interpreter/interpreter_mterp_impl.h b/runtime/interpreter/interpreter_mterp_impl.h new file mode 100644 index 0000000000..322df4e9e0 --- /dev/null +++ b/runtime/interpreter/interpreter_mterp_impl.h @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ART_RUNTIME_INTERPRETER_INTERPRETER_MTERP_IMPL_H_ +#define ART_RUNTIME_INTERPRETER_INTERPRETER_MTERP_IMPL_H_ + +#include "base/macros.h" +#include "base/mutex.h" +#include "dex_file.h" +#include "jvalue.h" + +namespace art { + +class ShadowFrame; +class Thread; + +namespace interpreter { + +// Mterp does not support transactions or access check, thus no templated versions. +extern "C" bool ExecuteMterpImpl(Thread* self, + const DexFile::CodeItem* code_item, + ShadowFrame* shadow_frame, + JValue* result_register) SHARED_REQUIRES(Locks::mutator_lock_); + +} // namespace interpreter +} // namespace art + +#endif // ART_RUNTIME_INTERPRETER_INTERPRETER_MTERP_IMPL_H_ diff --git a/runtime/interpreter/interpreter_switch_impl.cc b/runtime/interpreter/interpreter_switch_impl.cc index a6349fcf88..dd10052ebd 100644 --- a/runtime/interpreter/interpreter_switch_impl.cc +++ b/runtime/interpreter/interpreter_switch_impl.cc @@ -14,6 +14,8 @@ * limitations under the License. */ +#include "interpreter_switch_impl.h" + #include "base/enums.h" #include "experimental_flags.h" #include "interpreter_common.h" @@ -2337,19 +2339,19 @@ JValue ExecuteSwitchImpl(Thread* self, const DexFile::CodeItem* code_item, } // NOLINT(readability/fn_size) // Explicit definitions of ExecuteSwitchImpl. -template SHARED_REQUIRES(Locks::mutator_lock_) HOT_ATTR +template HOT_ATTR JValue ExecuteSwitchImpl<true, false>(Thread* self, const DexFile::CodeItem* code_item, ShadowFrame& shadow_frame, JValue result_register, bool interpret_one_instruction); -template SHARED_REQUIRES(Locks::mutator_lock_) HOT_ATTR +template HOT_ATTR JValue ExecuteSwitchImpl<false, false>(Thread* self, const DexFile::CodeItem* code_item, ShadowFrame& shadow_frame, JValue result_register, bool interpret_one_instruction); -template SHARED_REQUIRES(Locks::mutator_lock_) +template JValue ExecuteSwitchImpl<true, true>(Thread* self, const DexFile::CodeItem* code_item, ShadowFrame& shadow_frame, JValue result_register, bool interpret_one_instruction); -template SHARED_REQUIRES(Locks::mutator_lock_) +template JValue ExecuteSwitchImpl<false, true>(Thread* self, const DexFile::CodeItem* code_item, ShadowFrame& shadow_frame, JValue result_register, bool interpret_one_instruction); diff --git a/runtime/interpreter/interpreter_switch_impl.h b/runtime/interpreter/interpreter_switch_impl.h new file mode 100644 index 0000000000..90ec908678 --- /dev/null +++ b/runtime/interpreter/interpreter_switch_impl.h @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ART_RUNTIME_INTERPRETER_INTERPRETER_SWITCH_IMPL_H_ +#define ART_RUNTIME_INTERPRETER_INTERPRETER_SWITCH_IMPL_H_ + +#include "base/macros.h" +#include "base/mutex.h" +#include "dex_file.h" +#include "jvalue.h" + +namespace art { + +class ShadowFrame; +class Thread; + +namespace interpreter { + +template<bool do_access_check, bool transaction_active> +JValue ExecuteSwitchImpl(Thread* self, + const DexFile::CodeItem* code_item, + ShadowFrame& shadow_frame, + JValue result_register, + bool interpret_one_instruction) SHARED_REQUIRES(Locks::mutator_lock_); + +} // namespace interpreter +} // namespace art + +#endif // ART_RUNTIME_INTERPRETER_INTERPRETER_SWITCH_IMPL_H_ |