From 848871b4d8481229c32e0d048a9856e5a9a17ef9 Mon Sep 17 00:00:00 2001 From: Ian Rogers Date: Mon, 5 Aug 2013 10:56:33 -0700 Subject: Entry point clean up. Create set of entry points needed for image methods to avoid fix-up at load time: - interpreter - bridge to interpreter, bridge to compiled code - jni - dlsym lookup - quick - resolution and bridge to interpreter - portable - resolution and bridge to interpreter Fix JNI work around to use JNI work around argument rewriting code that'd been accidentally disabled. Remove abstact method error stub, use interpreter bridge instead. Consolidate trampoline (previously stub) generation in generic helper. Simplify trampolines to jump directly into assembly code, keeps stack crawlable. Dex: replace use of int with ThreadOffset for values that are thread offsets. Tidy entry point routines between interpreter, jni, quick and portable. Change-Id: I52a7c2bbb1b7e0ff8a3c3100b774212309d0828e --- compiler/driver/compiler_driver.cc | 78 +++++++++++++------------------------- 1 file changed, 26 insertions(+), 52 deletions(-) (limited to 'compiler/driver/compiler_driver.cc') diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc index 38d00a0804..8b09df7e92 100644 --- a/compiler/driver/compiler_driver.cc +++ b/compiler/driver/compiler_driver.cc @@ -41,9 +41,9 @@ #include "mirror/throwable.h" #include "scoped_thread_state_change.h" #include "ScopedLocalRef.h" -#include "stubs/stubs.h" #include "thread.h" #include "thread_pool.h" +#include "trampolines/trampoline_compiler.h" #include "verifier/method_verifier.h" #if defined(ART_USE_PORTABLE_COMPILER) @@ -433,64 +433,38 @@ CompilerTls* CompilerDriver::GetTls() { return res; } +const std::vector* CompilerDriver::CreateInterpreterToInterpreterBridge() const { + return CreateTrampoline(instruction_set_, kInterpreterAbi, + INTERPRETER_ENTRYPOINT_OFFSET(pInterpreterToInterpreterBridge)); +} + +const std::vector* CompilerDriver::CreateInterpreterToCompiledCodeBridge() const { + return CreateTrampoline(instruction_set_, kInterpreterAbi, + INTERPRETER_ENTRYPOINT_OFFSET(pInterpreterToCompiledCodeBridge)); +} + +const std::vector* CompilerDriver::CreateJniDlsymLookup() const { + return CreateTrampoline(instruction_set_, kJniAbi, JNI_ENTRYPOINT_OFFSET(pDlsymLookup)); +} + const std::vector* CompilerDriver::CreatePortableResolutionTrampoline() const { - switch (instruction_set_) { - case kArm: - case kThumb2: - return arm::CreatePortableResolutionTrampoline(); - case kMips: - return mips::CreatePortableResolutionTrampoline(); - case kX86: - return x86::CreatePortableResolutionTrampoline(); - default: - LOG(FATAL) << "Unknown InstructionSet: " << instruction_set_; - return NULL; - } + return CreateTrampoline(instruction_set_, kPortableAbi, + PORTABLE_ENTRYPOINT_OFFSET(pPortableResolutionTrampoline)); } -const std::vector* CompilerDriver::CreateQuickResolutionTrampoline() const { - switch (instruction_set_) { - case kArm: - case kThumb2: - return arm::CreateQuickResolutionTrampoline(); - case kMips: - return mips::CreateQuickResolutionTrampoline(); - case kX86: - return x86::CreateQuickResolutionTrampoline(); - default: - LOG(FATAL) << "Unknown InstructionSet: " << instruction_set_; - return NULL; - } +const std::vector* CompilerDriver::CreatePortableToInterpreterBridge() const { + return CreateTrampoline(instruction_set_, kPortableAbi, + PORTABLE_ENTRYPOINT_OFFSET(pPortableToInterpreterBridge)); } -const std::vector* CompilerDriver::CreateInterpreterToInterpreterEntry() const { - switch (instruction_set_) { - case kArm: - case kThumb2: - return arm::CreateInterpreterToInterpreterEntry(); - case kMips: - return mips::CreateInterpreterToInterpreterEntry(); - case kX86: - return x86::CreateInterpreterToInterpreterEntry(); - default: - LOG(FATAL) << "Unknown InstructionSet: " << instruction_set_; - return NULL; - } +const std::vector* CompilerDriver::CreateQuickResolutionTrampoline() const { + return CreateTrampoline(instruction_set_, kQuickAbi, + QUICK_ENTRYPOINT_OFFSET(pQuickResolutionTrampoline)); } -const std::vector* CompilerDriver::CreateInterpreterToQuickEntry() const { - switch (instruction_set_) { - case kArm: - case kThumb2: - return arm::CreateInterpreterToQuickEntry(); - case kMips: - return mips::CreateInterpreterToQuickEntry(); - case kX86: - return x86::CreateInterpreterToQuickEntry(); - default: - LOG(FATAL) << "Unknown InstructionSet: " << instruction_set_; - return NULL; - } +const std::vector* CompilerDriver::CreateQuickToInterpreterBridge() const { + return CreateTrampoline(instruction_set_, kQuickAbi, + QUICK_ENTRYPOINT_OFFSET(pQuickToInterpreterBridge)); } void CompilerDriver::CompileAll(jobject class_loader, -- cgit v1.2.3-59-g8ed1b From a024a0686c3b0fea13f362bff70d65981e5febc5 Mon Sep 17 00:00:00 2001 From: buzbee Date: Wed, 31 Jul 2013 10:47:37 -0700 Subject: Compilation filter This CL introduces a static compilation filter mechanism intended to allow us to reduce compilation time and space requirements until we have a profiling mechanism in place. It supports 5 modes of filtering: o interpret-only (compile nothing) o deferred-compilation (compile only those methods believe to be compute-intensive) o space (optimized for space) o balanced (best return on space investment) o speed (compile everything) A future CL will allow the default filtering mode to be set via system property. For now, you can pass it in via command line as follows: dalvikvm -compiler-filter:[interpret-only|defer-compilation| space|balanced|speed] or dex2oat --runtime-arg -compiler-filter:[one of the above modes] Creating a file named art/SMALL_ART will force the filter default to interpret-only. Later on we'll move this capability to a persistent system property. or modify kDefaultCompilerFilter in runtime.h It also changes the compiler driver to allow the compilers to decline to compile a method by return NULL. Change-Id: Ic73411818f8bb845a4a19a05b0395c50902c534f --- compiler/Android.mk | 1 + compiler/dex/frontend.cc | 5 + compiler/dex/frontend.h | 1 + compiler/dex/mir_analysis.cc | 1056 +++++++++++++++++++++++++++++++++++ compiler/dex/mir_graph.h | 45 ++ compiler/driver/compiler_driver.cc | 10 +- dex2oat/dex2oat.cc | 18 +- runtime/class_linker.cc | 24 + runtime/runtime.cc | 44 +- runtime/runtime.h | 73 ++- runtime/verifier/method_verifier.cc | 11 +- 11 files changed, 1228 insertions(+), 60 deletions(-) create mode 100644 compiler/dex/mir_analysis.cc (limited to 'compiler/driver/compiler_driver.cc') diff --git a/compiler/Android.mk b/compiler/Android.mk index df77853abf..fec1e11c47 100644 --- a/compiler/Android.mk +++ b/compiler/Android.mk @@ -53,6 +53,7 @@ LIBART_COMPILER_SRC_FILES := \ dex/mir_optimization.cc \ dex/frontend.cc \ dex/mir_graph.cc \ + dex/mir_analysis.cc \ dex/vreg_analysis.cc \ dex/ssa_transformation.cc \ driver/compiler_driver.cc \ diff --git a/compiler/dex/frontend.cc b/compiler/dex/frontend.cc index 9cc4d18d37..8da1520c30 100644 --- a/compiler/dex/frontend.cc +++ b/compiler/dex/frontend.cc @@ -103,6 +103,7 @@ static uint32_t kCompilerDebugFlags = 0 | // Enable debug/testing modes // (1 << kDebugDumpBitcodeFile) | // (1 << kDebugVerifyBitcode) | // (1 << kDebugShowSummaryMemoryUsage) | + // (1 << kDebugShowFilterStats) | 0; static CompiledMethod* CompileMethod(CompilerDriver& compiler, @@ -180,6 +181,10 @@ static CompiledMethod* CompileMethod(CompilerDriver& compiler, cu->mir_graph->InlineMethod(code_item, access_flags, invoke_type, class_def_idx, method_idx, class_loader, dex_file); + if (cu->mir_graph->SkipCompilation(Runtime::Current()->GetCompilerFilter())) { + return NULL; + } + /* Do a code layout pass */ cu->mir_graph->CodeLayout(); diff --git a/compiler/dex/frontend.h b/compiler/dex/frontend.h index 5c68ab4244..bafa46892c 100644 --- a/compiler/dex/frontend.h +++ b/compiler/dex/frontend.h @@ -77,6 +77,7 @@ enum debugControlVector { kDebugDumpBitcodeFile, kDebugVerifyBitcode, kDebugShowSummaryMemoryUsage, + kDebugShowFilterStats, }; class LLVMInfo { diff --git a/compiler/dex/mir_analysis.cc b/compiler/dex/mir_analysis.cc new file mode 100644 index 0000000000..8321ff63d3 --- /dev/null +++ b/compiler/dex/mir_analysis.cc @@ -0,0 +1,1056 @@ +/* + * Copyright (C) 2013 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. + */ + +#include "compiler_internals.h" +#include "dataflow_iterator-inl.h" + +namespace art { + + // Instruction characteristics used to statically identify computation-intensive methods. +const uint32_t MIRGraph::analysis_attributes_[kMirOpLast] = { + // 00 NOP + AN_NONE, + + // 01 MOVE vA, vB + AN_MOVE, + + // 02 MOVE_FROM16 vAA, vBBBB + AN_MOVE, + + // 03 MOVE_16 vAAAA, vBBBB + AN_MOVE, + + // 04 MOVE_WIDE vA, vB + AN_MOVE, + + // 05 MOVE_WIDE_FROM16 vAA, vBBBB + AN_MOVE, + + // 06 MOVE_WIDE_16 vAAAA, vBBBB + AN_MOVE, + + // 07 MOVE_OBJECT vA, vB + AN_MOVE, + + // 08 MOVE_OBJECT_FROM16 vAA, vBBBB + AN_MOVE, + + // 09 MOVE_OBJECT_16 vAAAA, vBBBB + AN_MOVE, + + // 0A MOVE_RESULT vAA + AN_MOVE, + + // 0B MOVE_RESULT_WIDE vAA + AN_MOVE, + + // 0C MOVE_RESULT_OBJECT vAA + AN_MOVE, + + // 0D MOVE_EXCEPTION vAA + AN_MOVE, + + // 0E RETURN_VOID + AN_BRANCH, + + // 0F RETURN vAA + AN_BRANCH, + + // 10 RETURN_WIDE vAA + AN_BRANCH, + + // 11 RETURN_OBJECT vAA + AN_BRANCH, + + // 12 CONST_4 vA, #+B + AN_SIMPLECONST, + + // 13 CONST_16 vAA, #+BBBB + AN_SIMPLECONST, + + // 14 CONST vAA, #+BBBBBBBB + AN_SIMPLECONST, + + // 15 CONST_HIGH16 VAA, #+BBBB0000 + AN_SIMPLECONST, + + // 16 CONST_WIDE_16 vAA, #+BBBB + AN_SIMPLECONST, + + // 17 CONST_WIDE_32 vAA, #+BBBBBBBB + AN_SIMPLECONST, + + // 18 CONST_WIDE vAA, #+BBBBBBBBBBBBBBBB + AN_SIMPLECONST, + + // 19 CONST_WIDE_HIGH16 vAA, #+BBBB000000000000 + AN_SIMPLECONST, + + // 1A CONST_STRING vAA, string@BBBB + AN_NONE, + + // 1B CONST_STRING_JUMBO vAA, string@BBBBBBBB + AN_NONE, + + // 1C CONST_CLASS vAA, type@BBBB + AN_NONE, + + // 1D MONITOR_ENTER vAA + AN_NONE, + + // 1E MONITOR_EXIT vAA + AN_NONE, + + // 1F CHK_CAST vAA, type@BBBB + AN_NONE, + + // 20 INSTANCE_OF vA, vB, type@CCCC + AN_NONE, + + // 21 ARRAY_LENGTH vA, vB + AN_ARRAYOP, + + // 22 NEW_INSTANCE vAA, type@BBBB + AN_HEAVYWEIGHT, + + // 23 NEW_ARRAY vA, vB, type@CCCC + AN_HEAVYWEIGHT, + + // 24 FILLED_NEW_ARRAY {vD, vE, vF, vG, vA} + AN_HEAVYWEIGHT, + + // 25 FILLED_NEW_ARRAY_RANGE {vCCCC .. vNNNN}, type@BBBB + AN_HEAVYWEIGHT, + + // 26 FILL_ARRAY_DATA vAA, +BBBBBBBB + AN_NONE, + + // 27 THROW vAA + AN_HEAVYWEIGHT | AN_BRANCH, + + // 28 GOTO + AN_BRANCH, + + // 29 GOTO_16 + AN_BRANCH, + + // 2A GOTO_32 + AN_BRANCH, + + // 2B PACKED_SWITCH vAA, +BBBBBBBB + AN_NONE, + + // 2C SPARSE_SWITCH vAA, +BBBBBBBB + AN_NONE, + + // 2D CMPL_FLOAT vAA, vBB, vCC + AN_MATH | AN_FP | AN_SINGLE, + + // 2E CMPG_FLOAT vAA, vBB, vCC + AN_MATH | AN_FP | AN_SINGLE, + + // 2F CMPL_DOUBLE vAA, vBB, vCC + AN_MATH | AN_FP | AN_DOUBLE, + + // 30 CMPG_DOUBLE vAA, vBB, vCC + AN_MATH | AN_FP | AN_DOUBLE, + + // 31 CMP_LONG vAA, vBB, vCC + AN_MATH | AN_LONG, + + // 32 IF_EQ vA, vB, +CCCC + AN_MATH | AN_BRANCH | AN_INT, + + // 33 IF_NE vA, vB, +CCCC + AN_MATH | AN_BRANCH | AN_INT, + + // 34 IF_LT vA, vB, +CCCC + AN_MATH | AN_BRANCH | AN_INT, + + // 35 IF_GE vA, vB, +CCCC + AN_MATH | AN_BRANCH | AN_INT, + + // 36 IF_GT vA, vB, +CCCC + AN_MATH | AN_BRANCH | AN_INT, + + // 37 IF_LE vA, vB, +CCCC + AN_MATH | AN_BRANCH | AN_INT, + + // 38 IF_EQZ vAA, +BBBB + AN_MATH | AN_BRANCH | AN_INT, + + // 39 IF_NEZ vAA, +BBBB + AN_MATH | AN_BRANCH | AN_INT, + + // 3A IF_LTZ vAA, +BBBB + AN_MATH | AN_BRANCH | AN_INT, + + // 3B IF_GEZ vAA, +BBBB + AN_MATH | AN_BRANCH | AN_INT, + + // 3C IF_GTZ vAA, +BBBB + AN_MATH | AN_BRANCH | AN_INT, + + // 3D IF_LEZ vAA, +BBBB + AN_MATH | AN_BRANCH | AN_INT, + + // 3E UNUSED_3E + AN_NONE, + + // 3F UNUSED_3F + AN_NONE, + + // 40 UNUSED_40 + AN_NONE, + + // 41 UNUSED_41 + AN_NONE, + + // 42 UNUSED_42 + AN_NONE, + + // 43 UNUSED_43 + AN_NONE, + + // 44 AGET vAA, vBB, vCC + AN_ARRAYOP, + + // 45 AGET_WIDE vAA, vBB, vCC + AN_ARRAYOP, + + // 46 AGET_OBJECT vAA, vBB, vCC + AN_ARRAYOP, + + // 47 AGET_BOOLEAN vAA, vBB, vCC + AN_ARRAYOP, + + // 48 AGET_BYTE vAA, vBB, vCC + AN_ARRAYOP, + + // 49 AGET_CHAR vAA, vBB, vCC + AN_ARRAYOP, + + // 4A AGET_SHORT vAA, vBB, vCC + AN_ARRAYOP, + + // 4B APUT vAA, vBB, vCC + AN_ARRAYOP, + + // 4C APUT_WIDE vAA, vBB, vCC + AN_ARRAYOP, + + // 4D APUT_OBJECT vAA, vBB, vCC + AN_ARRAYOP, + + // 4E APUT_BOOLEAN vAA, vBB, vCC + AN_ARRAYOP, + + // 4F APUT_BYTE vAA, vBB, vCC + AN_ARRAYOP, + + // 50 APUT_CHAR vAA, vBB, vCC + AN_ARRAYOP, + + // 51 APUT_SHORT vAA, vBB, vCC + AN_ARRAYOP, + + // 52 IGET vA, vB, field@CCCC + AN_NONE, + + // 53 IGET_WIDE vA, vB, field@CCCC + AN_NONE, + + // 54 IGET_OBJECT vA, vB, field@CCCC + AN_NONE, + + // 55 IGET_BOOLEAN vA, vB, field@CCCC + AN_NONE, + + // 56 IGET_BYTE vA, vB, field@CCCC + AN_NONE, + + // 57 IGET_CHAR vA, vB, field@CCCC + AN_NONE, + + // 58 IGET_SHORT vA, vB, field@CCCC + AN_NONE, + + // 59 IPUT vA, vB, field@CCCC + AN_NONE, + + // 5A IPUT_WIDE vA, vB, field@CCCC + AN_NONE, + + // 5B IPUT_OBJECT vA, vB, field@CCCC + AN_NONE, + + // 5C IPUT_BOOLEAN vA, vB, field@CCCC + AN_NONE, + + // 5D IPUT_BYTE vA, vB, field@CCCC + AN_NONE, + + // 5E IPUT_CHAR vA, vB, field@CCCC + AN_NONE, + + // 5F IPUT_SHORT vA, vB, field@CCCC + AN_NONE, + + // 60 SGET vAA, field@BBBB + AN_NONE, + + // 61 SGET_WIDE vAA, field@BBBB + AN_NONE, + + // 62 SGET_OBJECT vAA, field@BBBB + AN_NONE, + + // 63 SGET_BOOLEAN vAA, field@BBBB + AN_NONE, + + // 64 SGET_BYTE vAA, field@BBBB + AN_NONE, + + // 65 SGET_CHAR vAA, field@BBBB + AN_NONE, + + // 66 SGET_SHORT vAA, field@BBBB + AN_NONE, + + // 67 SPUT vAA, field@BBBB + AN_NONE, + + // 68 SPUT_WIDE vAA, field@BBBB + AN_NONE, + + // 69 SPUT_OBJECT vAA, field@BBBB + AN_NONE, + + // 6A SPUT_BOOLEAN vAA, field@BBBB + AN_NONE, + + // 6B SPUT_BYTE vAA, field@BBBB + AN_NONE, + + // 6C SPUT_CHAR vAA, field@BBBB + AN_NONE, + + // 6D SPUT_SHORT vAA, field@BBBB + AN_NONE, + + // 6E INVOKE_VIRTUAL {vD, vE, vF, vG, vA} + AN_INVOKE | AN_HEAVYWEIGHT, + + // 6F INVOKE_SUPER {vD, vE, vF, vG, vA} + AN_INVOKE | AN_HEAVYWEIGHT, + + // 70 INVOKE_DIRECT {vD, vE, vF, vG, vA} + AN_INVOKE | AN_HEAVYWEIGHT, + + // 71 INVOKE_STATIC {vD, vE, vF, vG, vA} + AN_INVOKE | AN_HEAVYWEIGHT, + + // 72 INVOKE_INTERFACE {vD, vE, vF, vG, vA} + AN_INVOKE | AN_HEAVYWEIGHT, + + // 73 UNUSED_73 + AN_NONE, + + // 74 INVOKE_VIRTUAL_RANGE {vCCCC .. vNNNN} + AN_INVOKE | AN_HEAVYWEIGHT, + + // 75 INVOKE_SUPER_RANGE {vCCCC .. vNNNN} + AN_INVOKE | AN_HEAVYWEIGHT, + + // 76 INVOKE_DIRECT_RANGE {vCCCC .. vNNNN} + AN_INVOKE | AN_HEAVYWEIGHT, + + // 77 INVOKE_STATIC_RANGE {vCCCC .. vNNNN} + AN_INVOKE | AN_HEAVYWEIGHT, + + // 78 INVOKE_INTERFACE_RANGE {vCCCC .. vNNNN} + AN_INVOKE | AN_HEAVYWEIGHT, + + // 79 UNUSED_79 + AN_NONE, + + // 7A UNUSED_7A + AN_NONE, + + // 7B NEG_INT vA, vB + AN_MATH | AN_INT, + + // 7C NOT_INT vA, vB + AN_MATH | AN_INT, + + // 7D NEG_LONG vA, vB + AN_MATH | AN_LONG, + + // 7E NOT_LONG vA, vB + AN_MATH | AN_LONG, + + // 7F NEG_FLOAT vA, vB + AN_MATH | AN_FP | AN_SINGLE, + + // 80 NEG_DOUBLE vA, vB + AN_MATH | AN_FP | AN_DOUBLE, + + // 81 INT_TO_LONG vA, vB + AN_MATH | AN_INT | AN_LONG, + + // 82 INT_TO_FLOAT vA, vB + AN_MATH | AN_FP | AN_INT | AN_SINGLE, + + // 83 INT_TO_DOUBLE vA, vB + AN_MATH | AN_FP | AN_INT | AN_DOUBLE, + + // 84 LONG_TO_INT vA, vB + AN_MATH | AN_INT | AN_LONG, + + // 85 LONG_TO_FLOAT vA, vB + AN_MATH | AN_FP | AN_LONG | AN_SINGLE, + + // 86 LONG_TO_DOUBLE vA, vB + AN_MATH | AN_FP | AN_LONG | AN_DOUBLE, + + // 87 FLOAT_TO_INT vA, vB + AN_MATH | AN_FP | AN_INT | AN_SINGLE, + + // 88 FLOAT_TO_LONG vA, vB + AN_MATH | AN_FP | AN_LONG | AN_SINGLE, + + // 89 FLOAT_TO_DOUBLE vA, vB + AN_MATH | AN_FP | AN_SINGLE | AN_DOUBLE, + + // 8A DOUBLE_TO_INT vA, vB + AN_MATH | AN_FP | AN_INT | AN_DOUBLE, + + // 8B DOUBLE_TO_LONG vA, vB + AN_MATH | AN_FP | AN_LONG | AN_DOUBLE, + + // 8C DOUBLE_TO_FLOAT vA, vB + AN_MATH | AN_FP | AN_SINGLE | AN_DOUBLE, + + // 8D INT_TO_BYTE vA, vB + AN_MATH | AN_INT, + + // 8E INT_TO_CHAR vA, vB + AN_MATH | AN_INT, + + // 8F INT_TO_SHORT vA, vB + AN_MATH | AN_INT, + + // 90 ADD_INT vAA, vBB, vCC + AN_MATH | AN_INT, + + // 91 SUB_INT vAA, vBB, vCC + AN_MATH | AN_INT, + + // 92 MUL_INT vAA, vBB, vCC + AN_MATH | AN_INT, + + // 93 DIV_INT vAA, vBB, vCC + AN_MATH | AN_INT, + + // 94 REM_INT vAA, vBB, vCC + AN_MATH | AN_INT, + + // 95 AND_INT vAA, vBB, vCC + AN_MATH | AN_INT, + + // 96 OR_INT vAA, vBB, vCC + AN_MATH | AN_INT, + + // 97 XOR_INT vAA, vBB, vCC + AN_MATH | AN_INT, + + // 98 SHL_INT vAA, vBB, vCC + AN_MATH | AN_INT, + + // 99 SHR_INT vAA, vBB, vCC + AN_MATH | AN_INT, + + // 9A USHR_INT vAA, vBB, vCC + AN_MATH | AN_INT, + + // 9B ADD_LONG vAA, vBB, vCC + AN_MATH | AN_LONG, + + // 9C SUB_LONG vAA, vBB, vCC + AN_MATH | AN_LONG, + + // 9D MUL_LONG vAA, vBB, vCC + AN_MATH | AN_LONG, + + // 9E DIV_LONG vAA, vBB, vCC + AN_MATH | AN_LONG, + + // 9F REM_LONG vAA, vBB, vCC + AN_MATH | AN_LONG, + + // A0 AND_LONG vAA, vBB, vCC + AN_MATH | AN_LONG, + + // A1 OR_LONG vAA, vBB, vCC + AN_MATH | AN_LONG, + + // A2 XOR_LONG vAA, vBB, vCC + AN_MATH | AN_LONG, + + // A3 SHL_LONG vAA, vBB, vCC + AN_MATH | AN_LONG, + + // A4 SHR_LONG vAA, vBB, vCC + AN_MATH | AN_LONG, + + // A5 USHR_LONG vAA, vBB, vCC + AN_MATH | AN_LONG, + + // A6 ADD_FLOAT vAA, vBB, vCC + AN_MATH | AN_FP | AN_SINGLE, + + // A7 SUB_FLOAT vAA, vBB, vCC + AN_MATH | AN_FP | AN_SINGLE, + + // A8 MUL_FLOAT vAA, vBB, vCC + AN_MATH | AN_FP | AN_SINGLE, + + // A9 DIV_FLOAT vAA, vBB, vCC + AN_MATH | AN_FP | AN_SINGLE, + + // AA REM_FLOAT vAA, vBB, vCC + AN_MATH | AN_FP | AN_SINGLE, + + // AB ADD_DOUBLE vAA, vBB, vCC + AN_MATH | AN_FP | AN_DOUBLE, + + // AC SUB_DOUBLE vAA, vBB, vCC + AN_MATH | AN_FP | AN_DOUBLE, + + // AD MUL_DOUBLE vAA, vBB, vCC + AN_MATH | AN_FP | AN_DOUBLE, + + // AE DIV_DOUBLE vAA, vBB, vCC + AN_MATH | AN_FP | AN_DOUBLE, + + // AF REM_DOUBLE vAA, vBB, vCC + AN_MATH | AN_FP | AN_DOUBLE, + + // B0 ADD_INT_2ADDR vA, vB + AN_MATH | AN_INT, + + // B1 SUB_INT_2ADDR vA, vB + AN_MATH | AN_INT, + + // B2 MUL_INT_2ADDR vA, vB + AN_MATH | AN_INT, + + // B3 DIV_INT_2ADDR vA, vB + AN_MATH | AN_INT, + + // B4 REM_INT_2ADDR vA, vB + AN_MATH | AN_INT, + + // B5 AND_INT_2ADDR vA, vB + AN_MATH | AN_INT, + + // B6 OR_INT_2ADDR vA, vB + AN_MATH | AN_INT, + + // B7 XOR_INT_2ADDR vA, vB + AN_MATH | AN_INT, + + // B8 SHL_INT_2ADDR vA, vB + AN_MATH | AN_INT, + + // B9 SHR_INT_2ADDR vA, vB + AN_MATH | AN_INT, + + // BA USHR_INT_2ADDR vA, vB + AN_MATH | AN_INT, + + // BB ADD_LONG_2ADDR vA, vB + AN_MATH | AN_LONG, + + // BC SUB_LONG_2ADDR vA, vB + AN_MATH | AN_LONG, + + // BD MUL_LONG_2ADDR vA, vB + AN_MATH | AN_LONG, + + // BE DIV_LONG_2ADDR vA, vB + AN_MATH | AN_LONG, + + // BF REM_LONG_2ADDR vA, vB + AN_MATH | AN_LONG, + + // C0 AND_LONG_2ADDR vA, vB + AN_MATH | AN_LONG, + + // C1 OR_LONG_2ADDR vA, vB + AN_MATH | AN_LONG, + + // C2 XOR_LONG_2ADDR vA, vB + AN_MATH | AN_LONG, + + // C3 SHL_LONG_2ADDR vA, vB + AN_MATH | AN_LONG, + + // C4 SHR_LONG_2ADDR vA, vB + AN_MATH | AN_LONG, + + // C5 USHR_LONG_2ADDR vA, vB + AN_MATH | AN_LONG, + + // C6 ADD_FLOAT_2ADDR vA, vB + AN_MATH | AN_FP | AN_SINGLE, + + // C7 SUB_FLOAT_2ADDR vA, vB + AN_MATH | AN_FP | AN_SINGLE, + + // C8 MUL_FLOAT_2ADDR vA, vB + AN_MATH | AN_FP | AN_SINGLE, + + // C9 DIV_FLOAT_2ADDR vA, vB + AN_MATH | AN_FP | AN_SINGLE, + + // CA REM_FLOAT_2ADDR vA, vB + AN_MATH | AN_FP | AN_SINGLE, + + // CB ADD_DOUBLE_2ADDR vA, vB + AN_MATH | AN_FP | AN_DOUBLE, + + // CC SUB_DOUBLE_2ADDR vA, vB + AN_MATH | AN_FP | AN_DOUBLE, + + // CD MUL_DOUBLE_2ADDR vA, vB + AN_MATH | AN_FP | AN_DOUBLE, + + // CE DIV_DOUBLE_2ADDR vA, vB + AN_MATH | AN_FP | AN_DOUBLE, + + // CF REM_DOUBLE_2ADDR vA, vB + AN_MATH | AN_FP | AN_DOUBLE, + + // D0 ADD_INT_LIT16 vA, vB, #+CCCC + AN_MATH | AN_INT, + + // D1 RSUB_INT vA, vB, #+CCCC + AN_MATH | AN_INT, + + // D2 MUL_INT_LIT16 vA, vB, #+CCCC + AN_MATH | AN_INT, + + // D3 DIV_INT_LIT16 vA, vB, #+CCCC + AN_MATH | AN_INT, + + // D4 REM_INT_LIT16 vA, vB, #+CCCC + AN_MATH | AN_INT, + + // D5 AND_INT_LIT16 vA, vB, #+CCCC + AN_MATH | AN_INT, + + // D6 OR_INT_LIT16 vA, vB, #+CCCC + AN_MATH | AN_INT, + + // D7 XOR_INT_LIT16 vA, vB, #+CCCC + AN_MATH | AN_INT, + + // D8 ADD_INT_LIT8 vAA, vBB, #+CC + AN_MATH | AN_INT, + + // D9 RSUB_INT_LIT8 vAA, vBB, #+CC + AN_MATH | AN_INT, + + // DA MUL_INT_LIT8 vAA, vBB, #+CC + AN_MATH | AN_INT, + + // DB DIV_INT_LIT8 vAA, vBB, #+CC + AN_MATH | AN_INT, + + // DC REM_INT_LIT8 vAA, vBB, #+CC + AN_MATH | AN_INT, + + // DD AND_INT_LIT8 vAA, vBB, #+CC + AN_MATH | AN_INT, + + // DE OR_INT_LIT8 vAA, vBB, #+CC + AN_MATH | AN_INT, + + // DF XOR_INT_LIT8 vAA, vBB, #+CC + AN_MATH | AN_INT, + + // E0 SHL_INT_LIT8 vAA, vBB, #+CC + AN_MATH | AN_INT, + + // E1 SHR_INT_LIT8 vAA, vBB, #+CC + AN_MATH | AN_INT, + + // E2 USHR_INT_LIT8 vAA, vBB, #+CC + AN_MATH | AN_INT, + + // E3 IGET_VOLATILE + AN_NONE, + + // E4 IPUT_VOLATILE + AN_NONE, + + // E5 SGET_VOLATILE + AN_NONE, + + // E6 SPUT_VOLATILE + AN_NONE, + + // E7 IGET_OBJECT_VOLATILE + AN_NONE, + + // E8 IGET_WIDE_VOLATILE + AN_NONE, + + // E9 IPUT_WIDE_VOLATILE + AN_NONE, + + // EA SGET_WIDE_VOLATILE + AN_NONE, + + // EB SPUT_WIDE_VOLATILE + AN_NONE, + + // EC BREAKPOINT + AN_NONE, + + // ED THROW_VERIFICATION_ERROR + AN_HEAVYWEIGHT | AN_BRANCH, + + // EE EXECUTE_INLINE + AN_NONE, + + // EF EXECUTE_INLINE_RANGE + AN_NONE, + + // F0 INVOKE_OBJECT_INIT_RANGE + AN_INVOKE | AN_HEAVYWEIGHT, + + // F1 RETURN_VOID_BARRIER + AN_BRANCH, + + // F2 IGET_QUICK + AN_NONE, + + // F3 IGET_WIDE_QUICK + AN_NONE, + + // F4 IGET_OBJECT_QUICK + AN_NONE, + + // F5 IPUT_QUICK + AN_NONE, + + // F6 IPUT_WIDE_QUICK + AN_NONE, + + // F7 IPUT_OBJECT_QUICK + AN_NONE, + + // F8 INVOKE_VIRTUAL_QUICK + AN_INVOKE | AN_HEAVYWEIGHT, + + // F9 INVOKE_VIRTUAL_QUICK_RANGE + AN_INVOKE | AN_HEAVYWEIGHT, + + // FA INVOKE_SUPER_QUICK + AN_INVOKE | AN_HEAVYWEIGHT, + + // FB INVOKE_SUPER_QUICK_RANGE + AN_INVOKE | AN_HEAVYWEIGHT, + + // FC IPUT_OBJECT_VOLATILE + AN_NONE, + + // FD SGET_OBJECT_VOLATILE + AN_NONE, + + // FE SPUT_OBJECT_VOLATILE + AN_NONE, + + // FF UNUSED_FF + AN_NONE, + + // Beginning of extended MIR opcodes + // 100 MIR_PHI + AN_NONE, + + // 101 MIR_COPY + AN_NONE, + + // 102 MIR_FUSED_CMPL_FLOAT + AN_NONE, + + // 103 MIR_FUSED_CMPG_FLOAT + AN_NONE, + + // 104 MIR_FUSED_CMPL_DOUBLE + AN_NONE, + + // 105 MIR_FUSED_CMPG_DOUBLE + AN_NONE, + + // 106 MIR_FUSED_CMP_LONG + AN_NONE, + + // 107 MIR_NOP + AN_NONE, + + // 108 MIR_NULL_CHECK + AN_NONE, + + // 109 MIR_RANGE_CHECK + AN_NONE, + + // 110 MIR_DIV_ZERO_CHECK + AN_NONE, + + // 111 MIR_CHECK + AN_NONE, + + // 112 MIR_CHECKPART2 + AN_NONE, + + // 113 MIR_SELECT + AN_NONE, +}; + +struct MethodStats { + int dex_instructions; + int math_ops; + int fp_ops; + int array_ops; + int branch_ops; + int heavyweight_ops; + bool has_computational_loop; + float math_ratio; + float fp_ratio; + float array_ratio; + float branch_ratio; + float heavyweight_ratio; +}; + +void MIRGraph::AnalyzeBlock(BasicBlock* bb, MethodStats* stats) { + if (bb->visited || (bb->block_type != kDalvikByteCode)) { + return; + } + bool computational_block = true; + bool has_math = false; + /* + * For the purposes of this scan, we want to treat the set of basic blocks broken + * by an exception edge as a single basic block. We'll scan forward along the fallthrough + * edges until we reach an explicit branch or return. + */ + BasicBlock* ending_bb = bb; + if (ending_bb->last_mir_insn != NULL) { + uint32_t ending_flags = analysis_attributes_[ending_bb->last_mir_insn->dalvikInsn.opcode]; + while ((ending_flags & AN_BRANCH) == 0) { + ending_bb = ending_bb->fall_through; + ending_flags = analysis_attributes_[ending_bb->last_mir_insn->dalvikInsn.opcode]; + } + } + /* + * Ideally, we'd weight the operations by loop nesting level, but to do so we'd + * first need to do some expensive loop detection - and the point of this is to make + * an informed guess before investing in computation. However, we can cheaply detect + * many simple loop forms without having to do full dataflow analysis. + */ + int loop_scale_factor = 1; + // Simple for and while loops + if ((ending_bb->taken != NULL) && (ending_bb->fall_through == NULL)) { + if ((ending_bb->taken->taken == bb) || (ending_bb->taken->fall_through == bb)) { + loop_scale_factor = 25; + } + } + // Simple do-while loop + if ((ending_bb->taken != NULL) && (ending_bb->taken == bb)) { + loop_scale_factor = 25; + } + + BasicBlock* tbb = bb; + bool done = false; + while (!done) { + tbb->visited = true; + for (MIR* mir = tbb->first_mir_insn; mir != NULL; mir = mir->next) { + if (static_cast(mir->dalvikInsn.opcode) >= kMirOpFirst) { + // Skip any MIR pseudo-op. + continue; + } + uint32_t flags = analysis_attributes_[mir->dalvikInsn.opcode]; + stats->dex_instructions += loop_scale_factor; + if ((flags & AN_BRANCH) == 0) { + computational_block &= ((flags & AN_COMPUTATIONAL) != 0); + } else { + stats->branch_ops += loop_scale_factor; + } + if ((flags & AN_MATH) != 0) { + stats->math_ops += loop_scale_factor; + has_math = true; + } + if ((flags & AN_FP) != 0) { + stats->fp_ops += loop_scale_factor; + } + if ((flags & AN_ARRAYOP) != 0) { + stats->array_ops += loop_scale_factor; + } + if ((flags & AN_HEAVYWEIGHT) != 0) { + stats->heavyweight_ops += loop_scale_factor; + } + } + if (tbb == ending_bb) { + done = true; + } else { + tbb = tbb->fall_through; + } + } + if (has_math && computational_block && (loop_scale_factor > 1)) { + stats->has_computational_loop = true; + } +} + +bool MIRGraph::ComputeSkipCompilation(MethodStats* stats, bool skip_default) { + float count = stats->dex_instructions; + stats->math_ratio = stats->math_ops / count; + stats->fp_ratio = stats->fp_ops / count; + stats->branch_ratio = stats->branch_ops / count; + stats->array_ratio = stats->array_ops / count; + stats->heavyweight_ratio = stats->heavyweight_ops / count; + + if (cu_->enable_debug & (1 << kDebugShowFilterStats)) { + LOG(INFO) << "STATS " << stats->dex_instructions << ", math:" + << stats->math_ratio << ", fp:" + << stats->fp_ratio << ", br:" + << stats->branch_ratio << ", hw:" + << stats-> heavyweight_ratio << ", arr:" + << stats->array_ratio << ", hot:" + << stats->has_computational_loop << ", " + << PrettyMethod(cu_->method_idx, *cu_->dex_file); + } + + // Computation intensive? + if (stats->has_computational_loop && (stats->heavyweight_ratio < 0.04)) { + return false; + } + + // Complex, logic-intensive? + if ((GetNumDalvikInsns() > Runtime::Current()->GetSmallMethodThreshold()) && + stats->branch_ratio > 0.3) { + return false; + } + + // Significant floating point? + if (stats->fp_ratio > 0.05) { + return false; + } + + // Significant generic math? + if (stats->math_ratio > 0.3) { + return false; + } + + // If array-intensive, compiling is probably worthwhile. + if (stats->array_ratio > 0.1) { + return false; + } + + // If high proportion of expensive operations, skip. + if (stats->heavyweight_ratio > 0.3) { + return true; + } + + return skip_default; +} + + /* + * Will eventually want this to be a bit more sophisticated and happen at verification time. + * Ultimate goal is to drive with profile data. + */ +bool MIRGraph::SkipCompilation(Runtime::CompilerFilter compiler_filter) { + if (compiler_filter == Runtime::kSpeed) { + // If going for speed, compile everything. + return false; + } + + if (compiler_filter == Runtime::kInterpretOnly) { + LOG(WARNING) << "InterpretOnly should ideally be filtered out prior to parsing."; + return true; + } + + // Filter 1: Skip huge methods (generally machine-generated initialization methods). + if (GetNumDalvikInsns() > Runtime::Current()->GetHugeMethodThreshold()) { + // Ain't nobody got time for that. + return true; + } + + // Filter 2: Skip class initializers. + if (((cu_->access_flags & kAccConstructor) != 0) && ((cu_->access_flags & kAccStatic) != 0)) { + return true; + } + + // Filter 3: if this method is a special pattern, go ahead and emit the canned pattern. + if (IsSpecialCase()) { + return false; + } + + /* In balanced mode, we generally assume that we'll be compiling, and then detect + * methods that won't benefit and remove them. In space or deferred mode, we do the + * opposite: assume no compilation and then add back presumed hot methods. + */ + bool skip_compilation = (compiler_filter == Runtime::kBalanced) ? false : true; + + + // Filter 4: go ahead and compile the small ones. + size_t small_cutoff = 0; + switch (compiler_filter) { + case Runtime::kBalanced: + small_cutoff = Runtime::Current()->GetSmallMethodThreshold(); + break; + case Runtime::kSpace: + small_cutoff = Runtime::Current()->GetTinyMethodThreshold(); + break; + case Runtime::kDeferCompilation: + small_cutoff = 0; + break; + default: + LOG(FATAL) << "Unexpected compiler_filter_: " << compiler_filter; + } + if (GetNumDalvikInsns() < small_cutoff) { + return false; + } + + // Analyze graph for: + // o floating point computation + // o basic blocks contained in loop with heavy arithmetic. + // o proportion of conditional branches. + + MethodStats stats; + memset(&stats, 0, sizeof(stats)); + + ClearAllVisitedFlags(); + AllNodesIterator iter(this, false /* not iterative */); + for (BasicBlock* bb = iter.Next(); bb != NULL; bb = iter.Next()) { + AnalyzeBlock(bb, &stats); + } + + return ComputeSkipCompilation(&stats, skip_compilation); +} + +} // namespace art diff --git a/compiler/dex/mir_graph.h b/compiler/dex/mir_graph.h index e9ec949f23..84ab2590b0 100644 --- a/compiler/dex/mir_graph.h +++ b/compiler/dex/mir_graph.h @@ -25,6 +25,38 @@ namespace art { +enum InstructionAnalysisAttributePos { + kUninterestingOp = 0, + kArithmeticOp, + kFPOp, + kSingleOp, + kDoubleOp, + kIntOp, + kLongOp, + kBranchOp, + kInvokeOp, + kArrayOp, + kHeavyweightOp, + kSimpleConstOp, + kMoveOp +}; + +#define AN_NONE (1 << kUninterestingOp) +#define AN_MATH (1 << kArithmeticOp) +#define AN_FP (1 << kFPOp) +#define AN_LONG (1 << kLongOp) +#define AN_INT (1 << kIntOp) +#define AN_SINGLE (1 << kSingleOp) +#define AN_DOUBLE (1 << kDoubleOp) +#define AN_FLOATMATH (1 << kFPOp) +#define AN_BRANCH (1 << kBranchOp) +#define AN_INVOKE (1 << kInvokeOp) +#define AN_ARRAYOP (1 << kArrayOp) +#define AN_HEAVYWEIGHT (1 << kHeavyweightOp) +#define AN_SIMPLECONST (1 << kSimpleConstOp) +#define AN_MOVE (1 << kMoveOp) +#define AN_COMPUTATIONAL (AN_MATH | AN_ARRAYOP | AN_MOVE | AN_SIMPLECONST) + enum DataFlowAttributePos { kUA = 0, kUB, @@ -312,6 +344,12 @@ class MIRGraph { MIRGraph(CompilationUnit* cu, ArenaAllocator* arena); ~MIRGraph(); + /* + * Examine the graph to determine whether it's worthwile to spend the time compiling + * this method. + */ + bool SkipCompilation(Runtime::CompilerFilter compiler_filter); + /* * Parse dex method and add MIR at current insert point. Returns id (which is * actually the index of the method in the m_units_ array). @@ -337,6 +375,10 @@ class MIRGraph { return num_blocks_; } + size_t GetNumDalvikInsns() const { + return cu_->code_item->insns_size_in_code_units_; + } + ArenaBitVector* GetTryBlockAddr() const { return try_block_addr_; } @@ -559,6 +601,7 @@ class MIRGraph { static const int oat_data_flow_attributes_[kMirOpLast]; static const char* extended_mir_op_names_[kMirOpLast - kMirOpFirst]; + static const uint32_t analysis_attributes_[kMirOpLast]; private: int FindCommonParent(int block1, int block2); @@ -621,6 +664,8 @@ class MIRGraph { void DoConstantPropogation(BasicBlock* bb); void CountChecks(BasicBlock* bb); bool CombineBlocks(BasicBlock* bb); + void AnalyzeBlock(BasicBlock* bb, struct MethodStats* stats); + bool ComputeSkipCompilation(struct MethodStats* stats, bool skip_default); CompilationUnit* const cu_; GrowableArray* ssa_base_vregs_; diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc index 38d00a0804..e7ba402b21 100644 --- a/compiler/driver/compiler_driver.cc +++ b/compiler/driver/compiler_driver.cc @@ -334,8 +334,8 @@ extern "C" void compilerLLVMSetBitcodeFileName(art::CompilerDriver& driver, std::string const& filename); CompilerDriver::CompilerDriver(CompilerBackend compiler_backend, InstructionSet instruction_set, - bool image, DescriptorSet* image_classes, - size_t thread_count, bool dump_stats) + bool image, DescriptorSet* image_classes, size_t thread_count, + bool dump_stats) : compiler_backend_(compiler_backend), instruction_set_(instruction_set), freezing_constructor_lock_("freezing constructor lock"), @@ -2253,6 +2253,10 @@ void CompilerDriver::CompileMethod(const DexFile::CodeItem* code_item, uint32_t } else { bool compile = verifier::MethodVerifier::IsCandidateForCompilation(code_item, access_flags); if (compile) { + // If we're doing the image, override the compiler filter to force full compilation. + if ((image_classes_.get() != NULL) && (image_classes_->size() != 0)) { + Runtime::Current()->SetCompilerFilter(Runtime::kSpeed); + } CompilerFn compiler = compiler_; #ifdef ART_SEA_IR_MODE bool use_sea = Runtime::Current()->IsSeaIRMode(); @@ -2261,9 +2265,9 @@ void CompilerDriver::CompileMethod(const DexFile::CodeItem* code_item, uint32_t compiler = sea_ir_compiler_; } #endif + // NOTE: if compiler declines to compile this method, it will return NULL. compiled_method = (*compiler)(*this, code_item, access_flags, invoke_type, class_def_idx, method_idx, class_loader, dex_file); - CHECK(compiled_method != NULL) << PrettyMethod(method_idx, dex_file); } else if (dex_to_dex_compilation_level != kDontDexToDexCompile) { // TODO: add a mode to disable DEX-to-DEX compilation ? (*dex_to_dex_compiler_)(*this, code_item, access_flags, diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc index c8c43476dc..b33997448e 100644 --- a/dex2oat/dex2oat.cc +++ b/dex2oat/dex2oat.cc @@ -847,11 +847,6 @@ static int dex2oat(int argc, char** argv) { options.push_back(std::make_pair(runtime_args[i], reinterpret_cast(NULL))); } -#if ART_SMALL_MODE - options.push_back(std::make_pair("-small", reinterpret_cast(NULL))); -#endif // ART_SMALL_MODE - - #ifdef ART_SEA_IR_MODE options.push_back(std::make_pair("-sea_ir", reinterpret_cast(NULL))); #endif @@ -910,18 +905,19 @@ static int dex2oat(int argc, char** argv) { } } - // If we're in small mode, but the program is small, turn off small mode. - // It doesn't make a difference for the boot image, so let's skip the check - // altogether. - if (Runtime::Current()->IsSmallMode() && !image) { + /* + * If we're not in interpret-only mode, go ahead and compile small applications. Don't + * bother to check if we're doing the image. + */ + if (!image && (Runtime::Current()->GetCompilerFilter() != Runtime::kInterpretOnly)) { size_t num_methods = 0; for (size_t i = 0; i != dex_files.size(); ++i) { const DexFile* dex_file = dex_files[i]; CHECK(dex_file != NULL); num_methods += dex_file->NumMethodIds(); } - if (num_methods <= Runtime::Current()->GetSmallModeMethodThreshold()) { - Runtime::Current()->SetSmallMode(false); + if (num_methods <= Runtime::Current()->GetNumDexMethodsThreshold()) { + Runtime::Current()->SetCompilerFilter(Runtime::kSpeed); LOG(INFO) << "Below method threshold, compiling anyways"; } } diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc index 84f186d4b3..6052993c6b 100644 --- a/runtime/class_linker.cc +++ b/runtime/class_linker.cc @@ -609,6 +609,28 @@ bool ClassLinker::GenerateOatFile(const std::string& dex_filename, oat_location_option_string += oat_cache_filename; const char* oat_location_option = oat_location_option_string.c_str(); + std::string oat_compiler_filter_string("-compiler-filter:"); + switch (Runtime::Current()->GetCompilerFilter()) { + case Runtime::kInterpretOnly: + oat_compiler_filter_string += "interpret-only"; + break; + case Runtime::kDeferCompilation: + oat_compiler_filter_string += "defer-compilation"; + break; + case Runtime::kSpace: + oat_compiler_filter_string += "space"; + break; + case Runtime::kBalanced: + oat_compiler_filter_string += "balanced"; + break; + case Runtime::kSpeed: + oat_compiler_filter_string += "speed"; + break; + default: + LOG(FATAL) << "Unexpected case."; + } + const char* oat_compiler_filter_option = oat_compiler_filter_string.c_str(); + // fork and exec dex2oat pid_t pid = fork(); if (pid == 0) { @@ -622,6 +644,7 @@ bool ClassLinker::GenerateOatFile(const std::string& dex_filename, << " --runtime-arg -Xmx64m" << " --runtime-arg -classpath" << " --runtime-arg " << class_path + << " --runtime-arg " << oat_compiler_filter_option #if !defined(ART_TARGET) << " --host" #endif @@ -635,6 +658,7 @@ bool ClassLinker::GenerateOatFile(const std::string& dex_filename, "--runtime-arg", "-Xmx64m", "--runtime-arg", "-classpath", "--runtime-arg", class_path, + "--runtime-arg", oat_compiler_filter_option, #if !defined(ART_TARGET) "--host", #endif diff --git a/runtime/runtime.cc b/runtime/runtime.cc index 5298181f19..70d8816401 100644 --- a/runtime/runtime.cc +++ b/runtime/runtime.cc @@ -355,9 +355,12 @@ Runtime::ParsedOptions* Runtime::ParsedOptions::Create(const Options& options, b parsed->hook_exit_ = exit; parsed->hook_abort_ = NULL; // We don't call abort(3) by default; see Runtime::Abort. - parsed->small_mode_ = false; - parsed->small_mode_method_threshold_ = Runtime::kDefaultSmallModeMethodThreshold; - parsed->small_mode_method_dex_size_limit_ = Runtime::kDefaultSmallModeMethodDexSizeLimit; + parsed->compiler_filter_ = Runtime::kDefaultCompilerFilter; + parsed->huge_method_threshold_ = Runtime::kDefaultHugeMethodThreshold; + parsed->large_method_threshold_ = Runtime::kDefaultLargeMethodThreshold; + parsed->small_method_threshold_ = Runtime::kDefaultSmallMethodThreshold; + parsed->tiny_method_threshold_ = Runtime::kDefaultTinyMethodThreshold; + parsed->num_dex_methods_threshold_ = Runtime::kDefaultNumDexMethodsThreshold; parsed->sea_ir_mode_ = false; // gLogVerbosity.class_linker = true; // TODO: don't check this in! @@ -572,14 +575,28 @@ Runtime::ParsedOptions* Runtime::ParsedOptions::Create(const Options& options, b Trace::SetDefaultClockSource(kProfilerClockSourceWall); } else if (option == "-Xprofile:dualclock") { Trace::SetDefaultClockSource(kProfilerClockSourceDual); - } else if (option == "-small") { - parsed->small_mode_ = true; + } else if (option == "-compiler-filter:interpret-only") { + parsed->compiler_filter_ = kInterpretOnly; + } else if (option == "-compiler-filter:defer-compilation") { + parsed->compiler_filter_ = kDeferCompilation; + } else if (option == "-compiler-filter:space") { + parsed->compiler_filter_ = kSpace; + } else if (option == "-compiler-filter:balanced") { + parsed->compiler_filter_ = kBalanced; + } else if (option == "-compiler-filter:speed") { + parsed->compiler_filter_ = kSpeed; } else if (option == "-sea_ir") { parsed->sea_ir_mode_ = true; - } else if (StartsWith(option, "-small-mode-methods-max:")) { - parsed->small_mode_method_threshold_ = ParseIntegerOrDie(option); - } else if (StartsWith(option, "-small-mode-methods-size-max:")) { - parsed->small_mode_method_dex_size_limit_ = ParseIntegerOrDie(option); + } else if (StartsWith(option, "-huge-method-max:")) { + parsed->huge_method_threshold_ = ParseIntegerOrDie(option); + } else if (StartsWith(option, "-large-method-max:")) { + parsed->large_method_threshold_ = ParseIntegerOrDie(option); + } else if (StartsWith(option, "-small-method-max:")) { + parsed->small_method_threshold_ = ParseIntegerOrDie(option); + } else if (StartsWith(option, "-tiny-method-max:")) { + parsed->tiny_method_threshold_ = ParseIntegerOrDie(option); + } else if (StartsWith(option, "-num-dex-methods-max:")) { + parsed->num_dex_methods_threshold_ = ParseIntegerOrDie(option); } else { if (!ignore_unrecognized) { // TODO: print usage via vfprintf @@ -809,9 +826,12 @@ bool Runtime::Init(const Options& raw_options, bool ignore_unrecognized) { is_zygote_ = options->is_zygote_; is_concurrent_gc_enabled_ = options->is_concurrent_gc_enabled_; - small_mode_ = options->small_mode_; - small_mode_method_threshold_ = options->small_mode_method_threshold_; - small_mode_method_dex_size_limit_ = options->small_mode_method_dex_size_limit_; + compiler_filter_ = options->compiler_filter_; + huge_method_threshold_ = options->huge_method_threshold_; + large_method_threshold_ = options->large_method_threshold_; + small_method_threshold_ = options->small_method_threshold_; + tiny_method_threshold_ = options->tiny_method_threshold_; + num_dex_methods_threshold_ = options->num_dex_methods_threshold_; sea_ir_mode_ = options->sea_ir_mode_; vfprintf_ = options->hook_vfprintf_; diff --git a/runtime/runtime.h b/runtime/runtime.h index 47fff29cb6..d67265a42d 100644 --- a/runtime/runtime.h +++ b/runtime/runtime.h @@ -63,15 +63,25 @@ class Runtime { public: typedef std::vector > Options; - // In small mode, apps with fewer than this number of methods will be compiled - // anyways. - // TODO: come up with a reasonable default. - static const size_t kDefaultSmallModeMethodThreshold = 0; + enum CompilerFilter { + kInterpretOnly, // Compile nothing. + kDeferCompilation, // Temporary minimal compilation, will redo during device idle time. + kSpace, // Maximize space savings. + kBalanced, // Try to get the best performance return on compilation investment. + kSpeed // Compile all methods. + }; - // In small mode, methods smaller than this dex op count limit will get compiled - // anyways. - // TODO: come up with a reasonable default. - static const size_t kDefaultSmallModeMethodDexSizeLimit = 300; + // Guide heuristics to determine whether to compile method if profile data not available. +#if ART_SMALL_MODE + static const CompilerFilter kDefaultCompilerFilter = kInterpretOnly; +#else + static const CompilerFilter kDefaultCompilerFilter = kSpeed; +#endif + static const size_t kDefaultHugeMethodThreshold = 6000; + static const size_t kDefaultLargeMethodThreshold = 1000; + static const size_t kDefaultSmallMethodThreshold = 200; + static const size_t kDefaultTinyMethodThreshold = 10; + static const size_t kDefaultNumDexMethodsThreshold = 900; class ParsedOptions { public: @@ -108,11 +118,12 @@ class Runtime { void (*hook_exit_)(jint status); void (*hook_abort_)(); std::vector properties_; - bool small_mode_; - - size_t small_mode_method_threshold_; - size_t small_mode_method_dex_size_limit_; - + CompilerFilter compiler_filter_; + size_t huge_method_threshold_; + size_t large_method_threshold_; + size_t small_method_threshold_; + size_t tiny_method_threshold_; + size_t num_dex_methods_threshold_; bool sea_ir_mode_; private: @@ -145,21 +156,32 @@ class Runtime { sea_ir_mode_ = sea_ir_mode; } - bool IsSmallMode() const { - return small_mode_; + CompilerFilter GetCompilerFilter() const { + return compiler_filter_; } + void SetCompilerFilter(CompilerFilter compiler_filter) { + compiler_filter_ = compiler_filter; + } + + size_t GetHugeMethodThreshold() const { + return huge_method_threshold_; + } + + size_t GetLargeMethodThreshold() const { + return large_method_threshold_; + } - void SetSmallMode(bool small_mode) { - small_mode_ = small_mode; + size_t GetSmallMethodThreshold() const { + return small_method_threshold_; } - size_t GetSmallModeMethodThreshold() const { - return small_mode_method_threshold_; + size_t GetTinyMethodThreshold() const { + return tiny_method_threshold_; } - size_t GetSmallModeMethodDexSizeLimit() const { - return small_mode_method_dex_size_limit_; + size_t GetNumDexMethodsThreshold() const { + return num_dex_methods_threshold_; } const std::string& GetHostPrefix() const { @@ -384,9 +406,12 @@ class Runtime { bool is_zygote_; bool is_concurrent_gc_enabled_; - bool small_mode_; - size_t small_mode_method_threshold_; - size_t small_mode_method_dex_size_limit_; + CompilerFilter compiler_filter_; + size_t huge_method_threshold_; + size_t large_method_threshold_; + size_t small_method_threshold_; + size_t tiny_method_threshold_; + size_t num_dex_methods_threshold_; bool sea_ir_mode_; diff --git a/runtime/verifier/method_verifier.cc b/runtime/verifier/method_verifier.cc index 9f0d911aa5..f1de565046 100644 --- a/runtime/verifier/method_verifier.cc +++ b/runtime/verifier/method_verifier.cc @@ -4180,16 +4180,7 @@ bool MethodVerifier::IsCandidateForCompilation(const DexFile::CodeItem* code_ite if (((access_flags & kAccConstructor) != 0) && ((access_flags & kAccStatic) != 0)) { return false; } - - const Runtime* runtime = Runtime::Current(); - if (runtime->IsSmallMode() && runtime->UseCompileTimeClassPath()) { - // In Small mode, we only compile small methods. - const uint32_t code_size = code_item->insns_size_in_code_units_; - return (code_size < runtime->GetSmallModeMethodDexSizeLimit()); - } else { - // In normal mode, we compile everything. - return true; - } + return (Runtime::Current()->GetCompilerFilter() != Runtime::kInterpretOnly); } ReaderWriterMutex* MethodVerifier::dex_gc_maps_lock_ = NULL; -- cgit v1.2.3-59-g8ed1b From 155ecba1c9b56ce1b468135e6a591a3fe9258c52 Mon Sep 17 00:00:00 2001 From: buzbee Date: Mon, 12 Aug 2013 16:15:53 -0700 Subject: Fix SMALL_ART On all art builds, the images classes must be compiled. When doing a small art build, it is necessary to override the default compiler filter to force compilation. A merge mistake broke this logic for dalvik-dev. Change-Id: I88186bd89d0ccb4316ee0910e9324ddc3e6a1f75 --- compiler/driver/compiler_driver.cc | 4 ---- dex2oat/dex2oat.cc | 5 +++++ 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'compiler/driver/compiler_driver.cc') diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc index 56b629c576..ae001004df 100644 --- a/compiler/driver/compiler_driver.cc +++ b/compiler/driver/compiler_driver.cc @@ -2227,10 +2227,6 @@ void CompilerDriver::CompileMethod(const DexFile::CodeItem* code_item, uint32_t } else { bool compile = verifier::MethodVerifier::IsCandidateForCompilation(code_item, access_flags); if (compile) { - // If we're doing the image, override the compiler filter to force full compilation. - if ((image_classes_.get() != NULL) && (image_classes_->size() != 0)) { - Runtime::Current()->SetCompilerFilter(Runtime::kSpeed); - } CompilerFn compiler = compiler_; #ifdef ART_SEA_IR_MODE bool use_sea = Runtime::Current()->IsSeaIRMode(); diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc index b33997448e..b85378d9ec 100644 --- a/dex2oat/dex2oat.cc +++ b/dex2oat/dex2oat.cc @@ -905,6 +905,11 @@ static int dex2oat(int argc, char** argv) { } } + // If we're doing the image, override the compiler filter to force full compilation. + if (image && Runtime::Current()->GetCompilerFilter() == Runtime::kInterpretOnly) { + Runtime::Current()->SetCompilerFilter(Runtime::kSpeed); + } + /* * If we're not in interpret-only mode, go ahead and compile small applications. Don't * bother to check if we're doing the image. -- cgit v1.2.3-59-g8ed1b From 67f99418f648c3a95256ed3dcd8e8b64eef0b372 Mon Sep 17 00:00:00 2001 From: Anwar Ghuloum Date: Mon, 12 Aug 2013 14:19:48 -0700 Subject: Yet more timing logger cleanup Some cleanup of timing logger placement, additional systrace placement for threaded compilation work, tweaking/hiding of some type names per previous review comments. Change-Id: Ic7db2e02747282ac7f474b9a060df9803bfdfa5e --- compiler/driver/compiler_driver.cc | 11 ++++++++--- runtime/base/timing_logger.cc | 8 ++++---- runtime/base/timing_logger.h | 8 ++++---- runtime/gc/heap.cc | 28 ++++++++++++---------------- 4 files changed, 28 insertions(+), 27 deletions(-) (limited to 'compiler/driver/compiler_driver.cc') diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc index ae001004df..144271d581 100644 --- a/compiler/driver/compiler_driver.cc +++ b/compiler/driver/compiler_driver.cc @@ -16,8 +16,10 @@ #include "compiler_driver.h" -#include +#define ATRACE_TAG ATRACE_TAG_DALVIK +#include +#include #include #include "base/stl_util.h" @@ -1562,14 +1564,14 @@ void CompilerDriver::Verify(jobject class_loader, const std::vectorGetDexFile()->GetClassDef(class_def_index); const char* descriptor = manager->GetDexFile()->GetClassDescriptor(class_def); mirror::Class* klass = manager->GetClassLinker()->FindClass(descriptor, soa.Decode(manager->GetClassLoader())); - if (klass == NULL) { - CHECK(soa.Self()->IsExceptionPending()); + if (klass == NULL) { CHECK(soa.Self()->IsExceptionPending()); soa.Self()->ClearException(); /* @@ -1600,6 +1602,7 @@ static void VerifyClass(const ParallelCompilationManager* manager, size_t class_ soa.Self()->ClearException(); } + CHECK(klass->IsCompileTimeVerified() || klass->IsErroneous()) << PrettyDescriptor(klass) << ": state=" << klass->GetStatus(); soa.Self()->AssertNoPendingException(); @@ -2135,6 +2138,7 @@ void CompilerDriver::Compile(jobject class_loader, const std::vectorGetClassLoader(); const DexFile& dex_file = *manager->GetDexFile(); const DexFile::ClassDef& class_def = dex_file.GetClassDef(class_def_index); @@ -2155,6 +2159,7 @@ void CompilerDriver::CompileClass(const ParallelCompilationManager* manager, siz // empty class, probably a marker interface return; } + // Can we run DEX-to-DEX compiler on this class ? DexToDexCompilationLevel dex_to_dex_compilation_level = kDontDexToDexCompile; { diff --git a/runtime/base/timing_logger.cc b/runtime/base/timing_logger.cc index 1dcad0ec91..11dc54271e 100644 --- a/runtime/base/timing_logger.cc +++ b/runtime/base/timing_logger.cc @@ -77,7 +77,7 @@ uint64_t CumulativeLogger::GetTotalTime() const { void CumulativeLogger::AddLogger(const base::TimingLogger &logger) { MutexLock mu(Thread::Current(), lock_); const base::TimingLogger::SplitTimings& splits = logger.GetSplits(); - for (base::TimingLogger::SplitsIterator it = splits.begin(), end = splits.end(); + for (base::TimingLogger::SplitTimingsIterator it = splits.begin(), end = splits.end(); it != end; ++it) { base::TimingLogger::SplitTiming split = *it; uint64_t split_time = split.first; @@ -155,7 +155,7 @@ void TimingLogger::NewSplit(const char* new_split_label) { uint64_t TimingLogger::GetTotalNs() const { uint64_t total_ns = 0; - for (base::TimingLogger::SplitsIterator it = splits_.begin(), end = splits_.end(); + for (base::TimingLogger::SplitTimingsIterator it = splits_.begin(), end = splits_.end(); it != end; ++it) { base::TimingLogger::SplitTiming split = *it; total_ns += split.first; @@ -166,7 +166,7 @@ uint64_t TimingLogger::GetTotalNs() const { void TimingLogger::Dump(std::ostream &os) const { uint64_t longest_split = 0; uint64_t total_ns = 0; - for (base::TimingLogger::SplitsIterator it = splits_.begin(), end = splits_.end(); + for (base::TimingLogger::SplitTimingsIterator it = splits_.begin(), end = splits_.end(); it != end; ++it) { base::TimingLogger::SplitTiming split = *it; uint64_t split_time = split.first; @@ -177,7 +177,7 @@ void TimingLogger::Dump(std::ostream &os) const { TimeUnit tu = GetAppropriateTimeUnit(longest_split); uint64_t divisor = GetNsToTimeUnitDivisor(tu); // Print formatted splits. - for (base::TimingLogger::SplitsIterator it = splits_.begin(), end = splits_.end(); + for (base::TimingLogger::SplitTimingsIterator it = splits_.begin(), end = splits_.end(); it != end; ++it) { base::TimingLogger::SplitTiming split = *it; uint64_t split_time = split.first; diff --git a/runtime/base/timing_logger.h b/runtime/base/timing_logger.h index 777d3f09ae..07d1ee00e0 100644 --- a/runtime/base/timing_logger.h +++ b/runtime/base/timing_logger.h @@ -33,9 +33,6 @@ namespace base { class CumulativeLogger { public: - typedef std::map *> Histograms; - typedef std::map *>::const_iterator HistogramsIterator; - explicit CumulativeLogger(const std::string& name); void prepare_stats(); ~CumulativeLogger(); @@ -50,6 +47,9 @@ class CumulativeLogger { void AddLogger(const base::TimingLogger& logger) LOCKS_EXCLUDED(lock_); private: + typedef std::map *> Histograms; + typedef std::map *>::const_iterator HistogramsIterator; + void AddPair(const std::string &label, uint64_t delta_time) EXCLUSIVE_LOCKS_REQUIRED(lock_); void DumpHistogram(std::ostream &os) EXCLUSIVE_LOCKS_REQUIRED(lock_); @@ -73,7 +73,7 @@ class TimingLogger { // Splits are nanosecond times and split names. typedef std::pair SplitTiming; typedef std::vector SplitTimings; - typedef std::vector::const_iterator SplitsIterator; + typedef std::vector::const_iterator SplitTimingsIterator; explicit TimingLogger(const char* name, bool precise, bool verbose); diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc index 6dcdab9b60..df1f3fe92e 100644 --- a/runtime/gc/heap.cc +++ b/runtime/gc/heap.cc @@ -1171,6 +1171,12 @@ void Heap::MarkAllocStack(accounting::SpaceBitmap* bitmap, accounting::SpaceSetM } } + +const char* gc_cause_and_type_strings[3][4] = { + {"", "GC Alloc Sticky", "GC Alloc Partial", "GC Alloc Full"}, + {"", "GC Background Sticky", "GC Background Partial", "GC Background Full"}, + {"", "GC Explicit Sticky", "GC Explicit Partial", "GC Explicit Full"}}; + collector::GcType Heap::CollectGarbageInternal(collector::GcType gc_type, GcCause gc_cause, bool clear_soft_references) { Thread* self = Thread::Current(); @@ -1225,20 +1231,12 @@ collector::GcType Heap::CollectGarbageInternal(collector::GcType gc_type, GcCaus gc_type = collector::kGcTypePartial; } - switch (gc_cause) { - case kGcCauseForAlloc: - ATRACE_BEGIN("GC (alloc)"); - break; - case kGcCauseBackground: - ATRACE_BEGIN("GC (background)"); - break; - case kGcCauseExplicit: - ATRACE_BEGIN("GC (explicit)"); - break; - } - DCHECK_LT(gc_type, collector::kGcTypeMax); DCHECK_NE(gc_type, collector::kGcTypeNone); + DCHECK_LE(gc_cause, kGcCauseExplicit); + + ATRACE_BEGIN(gc_cause_and_type_strings[gc_cause][gc_type]); + collector::MarkSweep* collector = NULL; typedef std::vector::iterator It; for (It it = mark_sweep_collectors_.begin(), end = mark_sweep_collectors_.end(); @@ -1658,11 +1656,10 @@ void Heap::PreGcVerification(collector::GarbageCollector* gc) { } void Heap::PreSweepingGcVerification(collector::GarbageCollector* gc) { - ThreadList* thread_list = Runtime::Current()->GetThreadList(); - // Called before sweeping occurs since we want to make sure we are not going so reclaim any // reachable objects. if (verify_post_gc_heap_) { + ThreadList* thread_list = Runtime::Current()->GetThreadList(); Thread* self = Thread::Current(); CHECK_NE(self->GetState(), kRunnable); Locks::mutator_lock_->SharedUnlock(self); @@ -1682,9 +1679,8 @@ void Heap::PreSweepingGcVerification(collector::GarbageCollector* gc) { } void Heap::PostGcVerification(collector::GarbageCollector* gc) { - Thread* self = Thread::Current(); - if (verify_system_weaks_) { + Thread* self = Thread::Current(); ReaderMutexLock mu(self, *Locks::heap_bitmap_lock_); collector::MarkSweep* mark_sweep = down_cast(gc); mark_sweep->VerifySystemWeaks(); -- cgit v1.2.3-59-g8ed1b From ea46f950e7a51585db293cd7f047de190a482414 Mon Sep 17 00:00:00 2001 From: Brian Carlstrom Date: Tue, 30 Jul 2013 01:26:50 -0700 Subject: Refactor java.lang.reflect implementation Cherry-picked from commit ed41d5c44299ec5d44b8514f6e17f802f48094d1. Move to ArtMethod/Field instead of AbstractMethod/Field and have java.lang.reflect APIs delegate to ArtMethod/ArtField. Bug: 10014286. Change-Id: Iafc1d8c5b62562c9af8fb9fd8c5e1d61270536e7 --- compiler/dex/dex_to_dex_compiler.cc | 4 +- compiler/dex/quick/gen_common.cc | 26 +- compiler/dex/quick/gen_invoke.cc | 10 +- compiler/driver/compiler_driver.cc | 34 +- compiler/driver/compiler_driver.h | 6 +- compiler/driver/compiler_driver_test.cc | 6 +- compiler/elf_writer.cc | 2 +- compiler/elf_writer_mclinker.cc | 6 +- compiler/image_writer.cc | 46 +- compiler/image_writer.h | 2 +- compiler/jni/jni_compiler_test.cc | 4 +- compiler/jni/portable/jni_compiler.cc | 6 +- compiler/jni/portable/jni_compiler.h | 2 +- compiler/jni/quick/jni_compiler.cc | 4 +- compiler/llvm/compiler_llvm.h | 2 +- compiler/llvm/gbc_expander.cc | 20 +- compiler/oat_writer.cc | 4 +- dex2oat/dex2oat.cc | 4 +- oatdump/oatdump.cc | 46 +- runtime/Android.mk | 4 +- runtime/arch/arm/context_arm.cc | 4 +- runtime/arch/arm/entrypoints_init_arm.cc | 8 +- runtime/arch/mips/context_mips.cc | 4 +- runtime/arch/mips/entrypoints_init_mips.cc | 8 +- runtime/arch/x86/context_x86.cc | 4 +- runtime/arch/x86/entrypoints_init_x86.cc | 8 +- runtime/check_jni.cc | 38 +- runtime/class_linker-inl.h | 48 +-- runtime/class_linker.cc | 379 +++++++---------- runtime/class_linker.h | 103 +++-- runtime/class_linker_test.cc | 470 ++++++++++---------- runtime/common_test.h | 10 +- runtime/common_throws.cc | 51 +-- runtime/common_throws.h | 34 +- runtime/debugger.cc | 110 ++--- runtime/debugger.h | 10 +- runtime/dex_file.cc | 9 +- runtime/dex_file.h | 12 +- runtime/entrypoints/entrypoint_utils.cc | 46 +- runtime/entrypoints/entrypoint_utils.h | 52 +-- .../interpreter/interpreter_entrypoints.cc | 4 +- runtime/entrypoints/jni/jni_entrypoints.cc | 6 +- .../portable/portable_alloc_entrypoints.cc | 14 +- .../portable/portable_dexcache_entrypoints.cc | 10 +- .../entrypoints/portable/portable_entrypoints.h | 6 +- .../portable/portable_field_entrypoints.cc | 60 +-- .../portable/portable_fillarray_entrypoints.cc | 4 +- .../portable/portable_invoke_entrypoints.cc | 20 +- .../portable/portable_jni_entrypoints.cc | 2 +- .../portable/portable_thread_entrypoints.cc | 6 +- .../portable/portable_throw_entrypoints.cc | 4 +- .../portable/portable_trampoline_entrypoints.cc | 24 +- runtime/entrypoints/quick/callee_save_frame.h | 4 +- .../entrypoints/quick/quick_alloc_entrypoints.cc | 26 +- .../entrypoints/quick/quick_cast_entrypoints.cc | 4 +- .../quick/quick_deoptimization_entrypoints.cc | 4 +- .../quick/quick_dexcache_entrypoints.cc | 18 +- runtime/entrypoints/quick/quick_entrypoints.h | 10 +- .../entrypoints/quick/quick_field_entrypoints.cc | 112 ++--- .../quick/quick_fillarray_entrypoints.cc | 2 +- .../quick/quick_instrumentation_entrypoints.cc | 10 +- .../entrypoints/quick/quick_invoke_entrypoints.cc | 36 +- runtime/entrypoints/quick/quick_jni_entrypoints.cc | 2 +- .../entrypoints/quick/quick_lock_entrypoints.cc | 4 +- .../entrypoints/quick/quick_thread_entrypoints.cc | 2 +- .../entrypoints/quick/quick_throw_entrypoints.cc | 14 +- .../quick/quick_trampoline_entrypoints.cc | 32 +- runtime/exception_test.cc | 4 +- runtime/gc/accounting/mod_union_table.cc | 2 +- runtime/gc/accounting/space_bitmap.cc | 10 +- runtime/gc/collector/mark_sweep-inl.h | 6 +- runtime/gc/collector/mark_sweep.cc | 10 +- runtime/gc/heap.cc | 8 +- runtime/gc/space/image_space.cc | 10 +- runtime/hprof/hprof.cc | 9 +- runtime/instrumentation.cc | 32 +- runtime/instrumentation.h | 52 +-- runtime/interpreter/interpreter.cc | 70 +-- runtime/interpreter/interpreter.h | 6 +- runtime/invoke_arg_array_builder.h | 2 +- runtime/jdwp/jdwp.h | 2 +- runtime/jdwp/object_registry.h | 2 +- runtime/jni_internal.cc | 120 ++++-- runtime/jni_internal.h | 12 +- runtime/jni_internal_test.cc | 110 +++-- runtime/mirror/abstract_method-inl.h | 203 --------- runtime/mirror/abstract_method.cc | 350 --------------- runtime/mirror/abstract_method.h | 471 --------------------- runtime/mirror/art_field-inl.h | 221 ++++++++++ runtime/mirror/art_field.cc | 56 +++ runtime/mirror/art_field.h | 165 ++++++++ runtime/mirror/art_method-inl.h | 203 +++++++++ runtime/mirror/art_method.cc | 342 +++++++++++++++ runtime/mirror/art_method.h | 457 ++++++++++++++++++++ runtime/mirror/class-inl.h | 87 ++-- runtime/mirror/class.cc | 97 +++-- runtime/mirror/class.h | 102 ++--- runtime/mirror/dex_cache-inl.h | 4 +- runtime/mirror/dex_cache.cc | 12 +- runtime/mirror/dex_cache.h | 30 +- runtime/mirror/field-inl.h | 221 ---------- runtime/mirror/field.cc | 56 --- runtime/mirror/field.h | 168 -------- runtime/mirror/iftable.h | 12 +- runtime/mirror/object-inl.h | 40 +- runtime/mirror/object.cc | 14 +- runtime/mirror/object.h | 16 +- runtime/mirror/object_array-inl.h | 2 +- runtime/mirror/object_test.cc | 40 +- runtime/mirror/throwable.cc | 4 +- runtime/monitor.cc | 10 +- runtime/monitor.h | 8 +- runtime/monitor_android.cc | 2 +- runtime/native/dalvik_system_VMStack.cc | 2 +- runtime/native/java_lang_reflect_Constructor.cc | 10 +- runtime/native/java_lang_reflect_Field.cc | 23 +- runtime/native/java_lang_reflect_Method.cc | 23 +- runtime/native/java_lang_reflect_Proxy.cc | 6 +- runtime/nth_caller_visitor.h | 6 +- runtime/oat_file.cc | 6 +- runtime/oat_file.h | 4 +- runtime/oat_test.cc | 4 +- runtime/object_utils.h | 26 +- runtime/reflection.cc | 17 +- runtime/reflection.h | 12 +- runtime/runtime.cc | 29 +- runtime/runtime.h | 22 +- runtime/scoped_thread_state_change.h | 12 +- runtime/stack.cc | 29 +- runtime/stack.h | 38 +- runtime/thread.cc | 54 +-- runtime/thread.h | 6 +- runtime/throw_location.cc | 2 +- runtime/throw_location.h | 8 +- runtime/trace.cc | 34 +- runtime/trace.h | 18 +- runtime/utils.cc | 13 +- runtime/utils.h | 12 +- runtime/utils_test.cc | 4 +- runtime/verifier/method_verifier.cc | 80 ++-- runtime/verifier/method_verifier.h | 43 +- runtime/well_known_classes.cc | 24 +- runtime/well_known_classes.h | 11 +- test/046-reflect/expected.txt | 9 +- test/046-reflect/src/Main.java | 43 +- test/100-reflect2/expected.txt | 2 +- test/ReferenceMap/stack_walk_refmap_jni.cc | 6 +- test/StackWalk/stack_walk_jni.cc | 6 +- 148 files changed, 3300 insertions(+), 3290 deletions(-) delete mode 100644 runtime/mirror/abstract_method-inl.h delete mode 100644 runtime/mirror/abstract_method.cc delete mode 100644 runtime/mirror/abstract_method.h create mode 100644 runtime/mirror/art_field-inl.h create mode 100644 runtime/mirror/art_field.cc create mode 100644 runtime/mirror/art_field.h create mode 100644 runtime/mirror/art_method-inl.h create mode 100644 runtime/mirror/art_method.cc create mode 100644 runtime/mirror/art_method.h delete mode 100644 runtime/mirror/field-inl.h delete mode 100644 runtime/mirror/field.cc delete mode 100644 runtime/mirror/field.h (limited to 'compiler/driver/compiler_driver.cc') diff --git a/compiler/dex/dex_to_dex_compiler.cc b/compiler/dex/dex_to_dex_compiler.cc index 60e638c584..a0e2c1e9aa 100644 --- a/compiler/dex/dex_to_dex_compiler.cc +++ b/compiler/dex/dex_to_dex_compiler.cc @@ -20,10 +20,10 @@ #include "dex_instruction-inl.h" #include "driver/compiler_driver.h" #include "driver/dex_compilation_unit.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_field-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/dex_cache.h" -#include "mirror/field-inl.h" namespace art { namespace optimizer { diff --git a/compiler/dex/quick/gen_common.cc b/compiler/dex/quick/gen_common.cc index 298d3898c8..e5c7fb150e 100644 --- a/compiler/dex/quick/gen_common.cc +++ b/compiler/dex/quick/gen_common.cc @@ -347,7 +347,7 @@ void Mir2Lir::GenSput(uint32_t field_idx, RegLocation rl_src, bool is_long_or_do RegLocation rl_method = LoadCurrMethod(); rBase = AllocTemp(); LoadWordDisp(rl_method.low_reg, - mirror::AbstractMethod::DeclaringClassOffset().Int32Value(), rBase); + mirror::ArtMethod::DeclaringClassOffset().Int32Value(), rBase); if (IsTemp(rl_method.low_reg)) { FreeTemp(rl_method.low_reg); } @@ -365,7 +365,7 @@ void Mir2Lir::GenSput(uint32_t field_idx, RegLocation rl_src, bool is_long_or_do rBase = TargetReg(kArg0); LockTemp(rBase); LoadWordDisp(r_method, - mirror::AbstractMethod::DexCacheInitializedStaticStorageOffset().Int32Value(), + mirror::ArtMethod::DexCacheInitializedStaticStorageOffset().Int32Value(), rBase); LoadWordDisp(rBase, mirror::Array::DataOffset(sizeof(mirror::Object*)).Int32Value() + @@ -433,7 +433,7 @@ void Mir2Lir::GenSget(uint32_t field_idx, RegLocation rl_dest, RegLocation rl_method = LoadCurrMethod(); rBase = AllocTemp(); LoadWordDisp(rl_method.low_reg, - mirror::AbstractMethod::DeclaringClassOffset().Int32Value(), rBase); + mirror::ArtMethod::DeclaringClassOffset().Int32Value(), rBase); } else { // Medium path, static storage base in a different class which requires checks that the other // class is initialized @@ -448,7 +448,7 @@ void Mir2Lir::GenSget(uint32_t field_idx, RegLocation rl_dest, rBase = TargetReg(kArg0); LockTemp(rBase); LoadWordDisp(r_method, - mirror::AbstractMethod::DexCacheInitializedStaticStorageOffset().Int32Value(), + mirror::ArtMethod::DexCacheInitializedStaticStorageOffset().Int32Value(), rBase); LoadWordDisp(rBase, mirror::Array::DataOffset(sizeof(mirror::Object*)).Int32Value() + sizeof(int32_t*) * ssb_index, rBase); @@ -746,7 +746,7 @@ void Mir2Lir::GenConstClass(uint32_t type_idx, RegLocation rl_dest) { } else { // We're don't need access checks, load type from dex cache int32_t dex_cache_offset = - mirror::AbstractMethod::DexCacheResolvedTypesOffset().Int32Value(); + mirror::ArtMethod::DexCacheResolvedTypesOffset().Int32Value(); LoadWordDisp(rl_method.low_reg, dex_cache_offset, res_reg); int32_t offset_of_type = mirror::Array::DataOffset(sizeof(mirror::Class*)).Int32Value() + (sizeof(mirror::Class*) @@ -799,7 +799,7 @@ void Mir2Lir::GenConstString(uint32_t string_idx, RegLocation rl_dest) { LockCallTemps(); // Using explicit registers LoadCurrMethodDirect(TargetReg(kArg2)); LoadWordDisp(TargetReg(kArg2), - mirror::AbstractMethod::DexCacheStringsOffset().Int32Value(), TargetReg(kArg0)); + mirror::ArtMethod::DexCacheStringsOffset().Int32Value(), TargetReg(kArg0)); // Might call out to helper, which will return resolved string in kRet0 int r_tgt = CallHelperSetup(QUICK_ENTRYPOINT_OFFSET(pResolveString)); LoadWordDisp(TargetReg(kArg0), offset_of_string, TargetReg(kRet0)); @@ -835,7 +835,7 @@ void Mir2Lir::GenConstString(uint32_t string_idx, RegLocation rl_dest) { int res_reg = AllocTemp(); RegLocation rl_result = EvalLoc(rl_dest, kCoreReg, true); LoadWordDisp(rl_method.low_reg, - mirror::AbstractMethod::DexCacheStringsOffset().Int32Value(), res_reg); + mirror::ArtMethod::DexCacheStringsOffset().Int32Value(), res_reg); LoadWordDisp(res_reg, offset_of_string, rl_result.low_reg); StoreValue(rl_dest, rl_result); } @@ -884,11 +884,11 @@ void Mir2Lir::GenInstanceofFinal(bool use_declaring_class, uint32_t type_idx, Re LoadCurrMethodDirect(check_class); if (use_declaring_class) { - LoadWordDisp(check_class, mirror::AbstractMethod::DeclaringClassOffset().Int32Value(), + LoadWordDisp(check_class, mirror::ArtMethod::DeclaringClassOffset().Int32Value(), check_class); LoadWordDisp(object.low_reg, mirror::Object::ClassOffset().Int32Value(), object_class); } else { - LoadWordDisp(check_class, mirror::AbstractMethod::DexCacheResolvedTypesOffset().Int32Value(), + LoadWordDisp(check_class, mirror::ArtMethod::DexCacheResolvedTypesOffset().Int32Value(), check_class); LoadWordDisp(object.low_reg, mirror::Object::ClassOffset().Int32Value(), object_class); int32_t offset_of_type = @@ -940,12 +940,12 @@ void Mir2Lir::GenInstanceofCallingHelper(bool needs_access_check, bool type_know } else if (use_declaring_class) { LoadValueDirectFixed(rl_src, TargetReg(kArg0)); // kArg0 <= ref LoadWordDisp(TargetReg(kArg1), - mirror::AbstractMethod::DeclaringClassOffset().Int32Value(), class_reg); + mirror::ArtMethod::DeclaringClassOffset().Int32Value(), class_reg); } else { // Load dex cache entry into class_reg (kArg2) LoadValueDirectFixed(rl_src, TargetReg(kArg0)); // kArg0 <= ref LoadWordDisp(TargetReg(kArg1), - mirror::AbstractMethod::DexCacheResolvedTypesOffset().Int32Value(), class_reg); + mirror::ArtMethod::DexCacheResolvedTypesOffset().Int32Value(), class_reg); int32_t offset_of_type = mirror::Array::DataOffset(sizeof(mirror::Class*)).Int32Value() + (sizeof(mirror::Class*) * type_idx); @@ -1078,11 +1078,11 @@ void Mir2Lir::GenCheckCast(uint32_t insn_idx, uint32_t type_idx, RegLocation rl_ OpRegCopy(class_reg, TargetReg(kRet0)); // Align usage with fast path } else if (use_declaring_class) { LoadWordDisp(TargetReg(kArg1), - mirror::AbstractMethod::DeclaringClassOffset().Int32Value(), class_reg); + mirror::ArtMethod::DeclaringClassOffset().Int32Value(), class_reg); } else { // Load dex cache entry into class_reg (kArg2) LoadWordDisp(TargetReg(kArg1), - mirror::AbstractMethod::DexCacheResolvedTypesOffset().Int32Value(), class_reg); + mirror::ArtMethod::DexCacheResolvedTypesOffset().Int32Value(), class_reg); int32_t offset_of_type = mirror::Array::DataOffset(sizeof(mirror::Class*)).Int32Value() + (sizeof(mirror::Class*) * type_idx); diff --git a/compiler/dex/quick/gen_invoke.cc b/compiler/dex/quick/gen_invoke.cc index 20d683a947..073b550d78 100644 --- a/compiler/dex/quick/gen_invoke.cc +++ b/compiler/dex/quick/gen_invoke.cc @@ -365,7 +365,7 @@ static int NextSDCallInsn(CompilationUnit* cu, CallInfo* info, break; case 1: // Get method->dex_cache_resolved_methods_ cg->LoadWordDisp(cg->TargetReg(kArg0), - mirror::AbstractMethod::DexCacheResolvedMethodsOffset().Int32Value(), cg->TargetReg(kArg0)); + mirror::ArtMethod::DexCacheResolvedMethodsOffset().Int32Value(), cg->TargetReg(kArg0)); // Set up direct code if known. if (direct_code != 0) { if (direct_code != static_cast(-1)) { @@ -395,7 +395,7 @@ static int NextSDCallInsn(CompilationUnit* cu, CallInfo* info, if (cu->instruction_set != kX86) { if (direct_code == 0) { cg->LoadWordDisp(cg->TargetReg(kArg0), - mirror::AbstractMethod::GetEntryPointFromCompiledCodeOffset().Int32Value(), + mirror::ArtMethod::GetEntryPointFromCompiledCodeOffset().Int32Value(), cg->TargetReg(kInvokeTgt)); } break; @@ -448,7 +448,7 @@ static int NextVCallInsn(CompilationUnit* cu, CallInfo* info, case 4: // Get the compiled code address [uses kArg0, sets kInvokeTgt] if (cu->instruction_set != kX86) { cg->LoadWordDisp(cg->TargetReg(kArg0), - mirror::AbstractMethod::GetEntryPointFromCompiledCodeOffset().Int32Value(), + mirror::ArtMethod::GetEntryPointFromCompiledCodeOffset().Int32Value(), cg->TargetReg(kInvokeTgt)); break; } @@ -514,7 +514,7 @@ static int NextInterfaceCallInsn(CompilationUnit* cu, CallInfo* info, int state, break; case 1: // Get method->dex_cache_resolved_methods_ [set/use kArg0] cg->LoadWordDisp(cg->TargetReg(kArg0), - mirror::AbstractMethod::DexCacheResolvedMethodsOffset().Int32Value(), + mirror::ArtMethod::DexCacheResolvedMethodsOffset().Int32Value(), cg->TargetReg(kArg0)); break; case 2: // Grab target method* [set/use kArg0] @@ -1407,7 +1407,7 @@ void Mir2Lir::GenInvoke(CallInfo* info) { } else { if (fast_path && info->type != kInterface) { call_inst = OpMem(kOpBlx, TargetReg(kArg0), - mirror::AbstractMethod::GetEntryPointFromCompiledCodeOffset().Int32Value()); + mirror::ArtMethod::GetEntryPointFromCompiledCodeOffset().Int32Value()); } else { ThreadOffset trampoline(-1); switch (info->type) { diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc index 144271d581..82f51f200a 100644 --- a/compiler/driver/compiler_driver.cc +++ b/compiler/driver/compiler_driver.cc @@ -33,11 +33,11 @@ #include "gc/accounting/card_table-inl.h" #include "gc/accounting/heap_bitmap.h" #include "gc/space/space.h" +#include "mirror/art_field-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class_loader.h" #include "mirror/class-inl.h" #include "mirror/dex_cache-inl.h" -#include "mirror/field-inl.h" -#include "mirror/abstract_method-inl.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" #include "mirror/throwable.h" @@ -515,7 +515,7 @@ static DexToDexCompilationLevel GetDexToDexCompilationlevel(mirror::ClassLoader* } } -void CompilerDriver::CompileOne(const mirror::AbstractMethod* method, base::TimingLogger& timings) { +void CompilerDriver::CompileOne(const mirror::ArtMethod* method, base::TimingLogger& timings) { DCHECK(!Runtime::Current()->IsStarted()); Thread* self = Thread::Current(); jobject jclass_loader; @@ -632,12 +632,12 @@ static bool ResolveCatchBlockExceptionsClassVisitor(mirror::Class* c, void* arg) reinterpret_cast >*>(arg); MethodHelper mh; for (size_t i = 0; i < c->NumVirtualMethods(); ++i) { - mirror::AbstractMethod* m = c->GetVirtualMethod(i); + mirror::ArtMethod* m = c->GetVirtualMethod(i); mh.ChangeMethod(m); ResolveExceptionsForMethod(&mh, *exceptions_to_resolve); } for (size_t i = 0; i < c->NumDirectMethods(); ++i) { - mirror::AbstractMethod* m = c->GetDirectMethod(i); + mirror::ArtMethod* m = c->GetDirectMethod(i); mh.ChangeMethod(m); ResolveExceptionsForMethod(&mh, *exceptions_to_resolve); } @@ -895,7 +895,7 @@ static mirror::Class* ComputeCompilingMethodsClass(ScopedObjectAccess& soa, dex_cache, class_loader); } -static mirror::Field* ComputeFieldReferencedFromCompilingMethod(ScopedObjectAccess& soa, +static mirror::ArtField* ComputeFieldReferencedFromCompilingMethod(ScopedObjectAccess& soa, const DexCompilationUnit* mUnit, uint32_t field_idx) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { @@ -905,7 +905,7 @@ static mirror::Field* ComputeFieldReferencedFromCompilingMethod(ScopedObjectAcce class_loader, false); } -static mirror::AbstractMethod* ComputeMethodReferencedFromCompilingMethod(ScopedObjectAccess& soa, +static mirror::ArtMethod* ComputeMethodReferencedFromCompilingMethod(ScopedObjectAccess& soa, const DexCompilationUnit* mUnit, uint32_t method_idx, InvokeType type) @@ -923,7 +923,7 @@ bool CompilerDriver::ComputeInstanceFieldInfo(uint32_t field_idx, const DexCompi field_offset = -1; is_volatile = true; // Try to resolve field and ignore if an Incompatible Class Change Error (ie is static). - mirror::Field* resolved_field = ComputeFieldReferencedFromCompilingMethod(soa, mUnit, field_idx); + mirror::ArtField* resolved_field = ComputeFieldReferencedFromCompilingMethod(soa, mUnit, field_idx); if (resolved_field != NULL && !resolved_field->IsStatic()) { mirror::Class* referrer_class = ComputeCompilingMethodsClass(soa, resolved_field->GetDeclaringClass()->GetDexCache(), @@ -974,7 +974,7 @@ bool CompilerDriver::ComputeStaticFieldInfo(uint32_t field_idx, const DexCompila is_referrers_class = false; is_volatile = true; // Try to resolve field and ignore if an Incompatible Class Change Error (ie isn't static). - mirror::Field* resolved_field = ComputeFieldReferencedFromCompilingMethod(soa, mUnit, field_idx); + mirror::ArtField* resolved_field = ComputeFieldReferencedFromCompilingMethod(soa, mUnit, field_idx); if (resolved_field != NULL && resolved_field->IsStatic()) { mirror::Class* referrer_class = ComputeCompilingMethodsClass(soa, resolved_field->GetDeclaringClass()->GetDexCache(), @@ -1051,7 +1051,7 @@ bool CompilerDriver::ComputeStaticFieldInfo(uint32_t field_idx, const DexCompila void CompilerDriver::GetCodeAndMethodForDirectCall(InvokeType type, InvokeType sharp_type, mirror::Class* referrer_class, - mirror::AbstractMethod* method, + mirror::ArtMethod* method, uintptr_t& direct_code, uintptr_t& direct_method, bool update_stats) { @@ -1114,7 +1114,7 @@ bool CompilerDriver::ComputeInvokeInfo(const DexCompilationUnit* mUnit, const ui vtable_idx = -1; direct_code = 0; direct_method = 0; - mirror::AbstractMethod* resolved_method = + mirror::ArtMethod* resolved_method = ComputeMethodReferencedFromCompilingMethod(soa, mUnit, target_method.dex_method_index, invoke_type); if (resolved_method != NULL) { @@ -1179,7 +1179,7 @@ bool CompilerDriver::ComputeInvokeInfo(const DexCompilationUnit* mUnit, const ui mUnit->GetClassLinker()->FindDexCache(*devirt_map_target->dex_file); mirror::ClassLoader* class_loader = soa.Decode(mUnit->GetClassLoader()); - mirror::AbstractMethod* called_method = + mirror::ArtMethod* called_method = mUnit->GetClassLinker()->ResolveMethod(*devirt_map_target->dex_file, devirt_map_target->dex_method_index, target_dex_cache, class_loader, NULL, @@ -1471,7 +1471,7 @@ static void ResolveClassFieldsAndMethods(const ParallelCompilationManager* manag mirror::DexCache* dex_cache = class_linker->FindDexCache(dex_file); ClassDataItemIterator it(dex_file, class_data); while (it.HasNextStaticField()) { - mirror::Field* field = class_linker->ResolveField(dex_file, it.GetMemberIndex(), dex_cache, + mirror::ArtField* field = class_linker->ResolveField(dex_file, it.GetMemberIndex(), dex_cache, class_loader, true); if (field == NULL) { CHECK(self->IsExceptionPending()); @@ -1487,7 +1487,7 @@ static void ResolveClassFieldsAndMethods(const ParallelCompilationManager* manag requires_constructor_barrier = true; } - mirror::Field* field = class_linker->ResolveField(dex_file, it.GetMemberIndex(), dex_cache, + mirror::ArtField* field = class_linker->ResolveField(dex_file, it.GetMemberIndex(), dex_cache, class_loader, false); if (field == NULL) { CHECK(self->IsExceptionPending()); @@ -1500,7 +1500,7 @@ static void ResolveClassFieldsAndMethods(const ParallelCompilationManager* manag class_def_index); } while (it.HasNextDirectMethod()) { - mirror::AbstractMethod* method = class_linker->ResolveMethod(dex_file, it.GetMemberIndex(), + mirror::ArtMethod* method = class_linker->ResolveMethod(dex_file, it.GetMemberIndex(), dex_cache, class_loader, NULL, it.GetMethodInvokeType(class_def)); if (method == NULL) { @@ -1510,7 +1510,7 @@ static void ResolveClassFieldsAndMethods(const ParallelCompilationManager* manag it.Next(); } while (it.HasNextVirtualMethod()) { - mirror::AbstractMethod* method = class_linker->ResolveMethod(dex_file, it.GetMemberIndex(), + mirror::ArtMethod* method = class_linker->ResolveMethod(dex_file, it.GetMemberIndex(), dex_cache, class_loader, NULL, it.GetMethodInvokeType(class_def)); if (method == NULL) { @@ -2073,7 +2073,7 @@ static void InitializeClass(const ParallelCompilationManager* manager, size_t cl LOG(INFO) << "Initializing: " << descriptor; if (StringPiece(descriptor) == "Ljava/lang/Void;") { // Hand initialize j.l.Void to avoid Dex file operations in un-started runtime. - mirror::ObjectArray* fields = klass->GetSFields(); + mirror::ObjectArray* fields = klass->GetSFields(); CHECK_EQ(fields->GetLength(), 1); fields->Get(0)->SetObj(klass, manager->GetClassLinker()->FindPrimitiveClass('V')); klass->SetStatus(mirror::Class::kStatusInitialized); diff --git a/compiler/driver/compiler_driver.h b/compiler/driver/compiler_driver.h index b5222c99b8..21a44eaf12 100644 --- a/compiler/driver/compiler_driver.h +++ b/compiler/driver/compiler_driver.h @@ -99,7 +99,7 @@ class CompilerDriver { LOCKS_EXCLUDED(Locks::mutator_lock_); // Compile a single Method - void CompileOne(const mirror::AbstractMethod* method, base::TimingLogger& timings) + void CompileOne(const mirror::ArtMethod* method, base::TimingLogger& timings) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); InstructionSet GetInstructionSet() const { @@ -301,7 +301,7 @@ class CompilerDriver { // Compute constant code and method pointers when possible void GetCodeAndMethodForDirectCall(InvokeType type, InvokeType sharp_type, mirror::Class* referrer_class, - mirror::AbstractMethod* method, + mirror::ArtMethod* method, uintptr_t& direct_code, uintptr_t& direct_method, bool update_stats) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); @@ -425,7 +425,7 @@ class CompilerDriver { CompilerEnableAutoElfLoadingFn compiler_enable_auto_elf_loading_; typedef const void* (*CompilerGetMethodCodeAddrFn) - (const CompilerDriver& driver, const CompiledMethod* cm, const mirror::AbstractMethod* method); + (const CompilerDriver& driver, const CompiledMethod* cm, const mirror::ArtMethod* method); CompilerGetMethodCodeAddrFn compiler_get_method_code_addr_; bool support_boot_image_fixup_; diff --git a/compiler/driver/compiler_driver_test.cc b/compiler/driver/compiler_driver_test.cc index 8ee9cf6442..c6687bb4aa 100644 --- a/compiler/driver/compiler_driver_test.cc +++ b/compiler/driver/compiler_driver_test.cc @@ -24,10 +24,10 @@ #include "common_test.h" #include "dex_file.h" #include "gc/heap.h" +#include "mirror/art_method-inl.h" #include "mirror/class.h" #include "mirror/class-inl.h" #include "mirror/dex_cache-inl.h" -#include "mirror/abstract_method-inl.h" #include "mirror/object_array-inl.h" #include "mirror/object-inl.h" @@ -115,7 +115,7 @@ TEST_F(CompilerDriverTest, DISABLED_LARGE_CompileDexLibCore) { } EXPECT_EQ(dex->NumMethodIds(), dex_cache->NumResolvedMethods()); for (size_t i = 0; i < dex_cache->NumResolvedMethods(); i++) { - mirror::AbstractMethod* method = dex_cache->GetResolvedMethod(i); + mirror::ArtMethod* method = dex_cache->GetResolvedMethod(i); EXPECT_TRUE(method != NULL) << "method_idx=" << i << " " << dex->GetMethodDeclaringClassDescriptor(dex->GetMethodId(i)) << " " << dex->GetMethodName(dex->GetMethodId(i)); @@ -126,7 +126,7 @@ TEST_F(CompilerDriverTest, DISABLED_LARGE_CompileDexLibCore) { } EXPECT_EQ(dex->NumFieldIds(), dex_cache->NumResolvedFields()); for (size_t i = 0; i < dex_cache->NumResolvedFields(); i++) { - mirror::Field* field = dex_cache->GetResolvedField(i); + mirror::ArtField* field = dex_cache->GetResolvedField(i); EXPECT_TRUE(field != NULL) << "field_idx=" << i << " " << dex->GetFieldDeclaringClassDescriptor(dex->GetFieldId(i)) << " " << dex->GetFieldName(dex->GetFieldId(i)); diff --git a/compiler/elf_writer.cc b/compiler/elf_writer.cc index 70d17de102..d3c13dd791 100644 --- a/compiler/elf_writer.cc +++ b/compiler/elf_writer.cc @@ -24,7 +24,7 @@ #include "elf_file.h" #include "invoke_type.h" #include "llvm/utils_llvm.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/object-inl.h" #include "oat.h" #include "scoped_thread_state_change.h" diff --git a/compiler/elf_writer_mclinker.cc b/compiler/elf_writer_mclinker.cc index 2a9bc35559..e496ace27a 100644 --- a/compiler/elf_writer_mclinker.cc +++ b/compiler/elf_writer_mclinker.cc @@ -33,8 +33,8 @@ #include "driver/compiler_driver.h" #include "elf_file.h" #include "globals.h" -#include "mirror/abstract_method.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method.h" +#include "mirror/art_method-inl.h" #include "mirror/object-inl.h" #include "oat_writer.h" #include "scoped_thread_state_change.h" @@ -353,7 +353,7 @@ void ElfWriterMclinker::FixupOatMethodOffsets(const std::vector& const DexFile& dex_file = it.GetDexFile(); uint32_t method_idx = it.GetMemberIndex(); InvokeType invoke_type = it.GetInvokeType(); - mirror::AbstractMethod* method = NULL; + mirror::ArtMethod* method = NULL; if (compiler_driver_->IsImage()) { ClassLinker* linker = Runtime::Current()->GetClassLinker(); mirror::DexCache* dex_cache = linker->FindDexCache(dex_file); diff --git a/compiler/image_writer.cc b/compiler/image_writer.cc index 3432c8cbee..a40e3fc149 100644 --- a/compiler/image_writer.cc +++ b/compiler/image_writer.cc @@ -35,12 +35,12 @@ #include "globals.h" #include "image.h" #include "intern_table.h" +#include "mirror/art_field-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/array-inl.h" #include "mirror/class-inl.h" #include "mirror/class_loader.h" #include "mirror/dex_cache-inl.h" -#include "mirror/field-inl.h" -#include "mirror/abstract_method-inl.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" #include "oat.h" @@ -52,11 +52,11 @@ #include "UniquePtr.h" #include "utils.h" -using ::art::mirror::AbstractMethod; +using ::art::mirror::ArtField; +using ::art::mirror::ArtMethod; using ::art::mirror::Class; using ::art::mirror::DexCache; using ::art::mirror::EntryPointFromInterpreter; -using ::art::mirror::Field; using ::art::mirror::Object; using ::art::mirror::ObjectArray; using ::art::mirror::String; @@ -257,7 +257,7 @@ void ImageWriter::PruneNonImageClasses() { } // Clear references to removed classes from the DexCaches. - AbstractMethod* resolution_method = runtime->GetResolutionMethod(); + ArtMethod* resolution_method = runtime->GetResolutionMethod(); typedef Set::const_iterator CacheIt; // TODO: C++0x auto for (CacheIt it = dex_caches_.begin(), end = dex_caches_.end(); it != end; ++it) { DexCache* dex_cache = *it; @@ -269,13 +269,13 @@ void ImageWriter::PruneNonImageClasses() { } } for (size_t i = 0; i < dex_cache->NumResolvedMethods(); i++) { - AbstractMethod* method = dex_cache->GetResolvedMethod(i); + ArtMethod* method = dex_cache->GetResolvedMethod(i); if (method != NULL && !IsImageClass(method->GetDeclaringClass())) { dex_cache->SetResolvedMethod(i, resolution_method); } } for (size_t i = 0; i < dex_cache->NumResolvedFields(); i++) { - Field* field = dex_cache->GetResolvedField(i); + ArtField* field = dex_cache->GetResolvedField(i); if (field != NULL && !IsImageClass(field->GetDeclaringClass())) { dex_cache->SetResolvedField(i, NULL); } @@ -487,8 +487,8 @@ void ImageWriter::FixupObject(const Object* orig, Object* copy) { FixupClass(orig->AsClass(), down_cast(copy)); } else if (orig->IsObjectArray()) { FixupObjectArray(orig->AsObjectArray(), down_cast*>(copy)); - } else if (orig->IsMethod()) { - FixupMethod(orig->AsMethod(), down_cast(copy)); + } else if (orig->IsArtMethod()) { + FixupMethod(orig->AsArtMethod(), down_cast(copy)); } else { FixupInstanceFields(orig, copy); } @@ -499,7 +499,7 @@ void ImageWriter::FixupClass(const Class* orig, Class* copy) { FixupStaticFields(orig, copy); } -void ImageWriter::FixupMethod(const AbstractMethod* orig, AbstractMethod* copy) { +void ImageWriter::FixupMethod(const ArtMethod* orig, ArtMethod* copy) { FixupInstanceFields(orig, copy); // OatWriter replaces the code_ with an offset value. Here we re-adjust to a pointer relative to @@ -614,9 +614,9 @@ void ImageWriter::FixupFields(const Object* orig, ? klass->NumReferenceStaticFields() : klass->NumReferenceInstanceFields()); for (size_t i = 0; i < num_reference_fields; ++i) { - Field* field = (is_static - ? klass->GetStaticField(i) - : klass->GetInstanceField(i)); + ArtField* field = (is_static + ? klass->GetStaticField(i) + : klass->GetInstanceField(i)); MemberOffset field_offset = field->GetOffset(); const Object* ref = orig->GetFieldObject(field_offset, false); // Use SetFieldPtr to avoid card marking since we are writing to the image. @@ -626,7 +626,7 @@ void ImageWriter::FixupFields(const Object* orig, } if (!is_static && orig->IsReferenceInstance()) { // Fix-up referent, that isn't marked as an object field, for References. - Field* field = orig->GetClass()->FindInstanceField("referent", "Ljava/lang/Object;"); + ArtField* field = orig->GetClass()->FindInstanceField("referent", "Ljava/lang/Object;"); MemberOffset field_offset = field->GetOffset(); const Object* ref = orig->GetFieldObject(field_offset, false); // Use SetFieldPtr to avoid card marking since we are writing to the image. @@ -634,16 +634,16 @@ void ImageWriter::FixupFields(const Object* orig, } } -static AbstractMethod* GetTargetMethod(const CompilerDriver::PatchInformation* patch) +static ArtMethod* GetTargetMethod(const CompilerDriver::PatchInformation* patch) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); DexCache* dex_cache = class_linker->FindDexCache(patch->GetDexFile()); - AbstractMethod* method = class_linker->ResolveMethod(patch->GetDexFile(), - patch->GetTargetMethodIdx(), - dex_cache, - NULL, - NULL, - patch->GetTargetInvokeType()); + ArtMethod* method = class_linker->ResolveMethod(patch->GetDexFile(), + patch->GetTargetMethodIdx(), + dex_cache, + NULL, + NULL, + patch->GetTargetInvokeType()); CHECK(method != NULL) << patch->GetDexFile().GetLocation() << " " << patch->GetTargetMethodIdx(); CHECK(!method->IsRuntimeMethod()) @@ -664,7 +664,7 @@ void ImageWriter::PatchOatCodeAndMethods() { const Patches& code_to_patch = compiler_driver_.GetCodeToPatch(); for (size_t i = 0; i < code_to_patch.size(); i++) { const CompilerDriver::PatchInformation* patch = code_to_patch[i]; - AbstractMethod* target = GetTargetMethod(patch); + ArtMethod* target = GetTargetMethod(patch); uint32_t code = reinterpret_cast(class_linker->GetOatCodeFor(target)); uint32_t code_base = reinterpret_cast(&oat_file_->GetOatHeader()); uint32_t code_offset = code - code_base; @@ -674,7 +674,7 @@ void ImageWriter::PatchOatCodeAndMethods() { const Patches& methods_to_patch = compiler_driver_.GetMethodsToPatch(); for (size_t i = 0; i < methods_to_patch.size(); i++) { const CompilerDriver::PatchInformation* patch = methods_to_patch[i]; - AbstractMethod* target = GetTargetMethod(patch); + ArtMethod* target = GetTargetMethod(patch); SetPatchLocation(patch, reinterpret_cast(GetImageAddress(target))); } diff --git a/compiler/image_writer.h b/compiler/image_writer.h index 545534fff7..750109d1d9 100644 --- a/compiler/image_writer.h +++ b/compiler/image_writer.h @@ -152,7 +152,7 @@ class ImageWriter { SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void FixupClass(const mirror::Class* orig, mirror::Class* copy) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void FixupMethod(const mirror::AbstractMethod* orig, mirror::AbstractMethod* copy) + void FixupMethod(const mirror::ArtMethod* orig, mirror::ArtMethod* copy) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void FixupObject(const mirror::Object* orig, mirror::Object* copy) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); diff --git a/compiler/jni/jni_compiler_test.cc b/compiler/jni/jni_compiler_test.cc index 4b6967faa0..a653ab42a9 100644 --- a/compiler/jni/jni_compiler_test.cc +++ b/compiler/jni/jni_compiler_test.cc @@ -21,9 +21,9 @@ #include "indirect_reference_table.h" #include "jni_internal.h" #include "mem_map.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/class_loader.h" -#include "mirror/abstract_method-inl.h" #include "mirror/object_array-inl.h" #include "mirror/object-inl.h" #include "mirror/stack_trace_element.h" @@ -51,7 +51,7 @@ class JniCompilerTest : public CommonTest { // Compile the native method before starting the runtime mirror::Class* c = class_linker_->FindClass("LMyClassNatives;", soa.Decode(class_loader)); - mirror::AbstractMethod* method; + mirror::ArtMethod* method; if (direct) { method = c->FindDirectMethod(method_name, method_sig); } else { diff --git a/compiler/jni/portable/jni_compiler.cc b/compiler/jni/portable/jni_compiler.cc index e05f291a73..58ee1c1602 100644 --- a/compiler/jni/portable/jni_compiler.cc +++ b/compiler/jni/portable/jni_compiler.cc @@ -27,7 +27,7 @@ #include "llvm/llvm_compilation_unit.h" #include "llvm/runtime_support_llvm_func.h" #include "llvm/utils_llvm.h" -#include "mirror/abstract_method.h" +#include "mirror/art_method.h" #include "runtime.h" #include "stack.h" #include "thread.h" @@ -91,7 +91,7 @@ CompiledMethod* JniCompiler::Compile() { // Load class object this_object_or_class_object = irb_.LoadFromObjectOffset(method_object_addr, - mirror::AbstractMethod::DeclaringClassOffset().Int32Value(), + mirror::ArtMethod::DeclaringClassOffset().Int32Value(), irb_.getJObjectTy(), kTBAAConstJObject); } @@ -135,7 +135,7 @@ CompiledMethod* JniCompiler::Compile() { // Get callee code_addr ::llvm::Value* code_addr = irb_.LoadFromObjectOffset(method_object_addr, - mirror::AbstractMethod::NativeMethodOffset().Int32Value(), + mirror::ArtMethod::NativeMethodOffset().Int32Value(), GetFunctionType(dex_compilation_unit_->GetDexMethodIndex(), is_static, true)->getPointerTo(), kTBAARuntimeInfo); diff --git a/compiler/jni/portable/jni_compiler.h b/compiler/jni/portable/jni_compiler.h index 9bdf35ef10..49cc9f4abf 100644 --- a/compiler/jni/portable/jni_compiler.h +++ b/compiler/jni/portable/jni_compiler.h @@ -28,7 +28,7 @@ namespace art { class DexFile; class DexCompilationUnit; namespace mirror { - class AbstractMethod; + class ArtMethod; class ClassLoader; class DexCache; } // namespace mirror diff --git a/compiler/jni/quick/jni_compiler.cc b/compiler/jni/quick/jni_compiler.cc index 9713fe9da9..069def60f9 100644 --- a/compiler/jni/quick/jni_compiler.cc +++ b/compiler/jni/quick/jni_compiler.cc @@ -119,7 +119,7 @@ CompiledMethod* ArtJniCompileMethodInternal(CompilerDriver& compiler, // Check sirt offset is within frame CHECK_LT(sirt_offset.Uint32Value(), frame_size); __ LoadRef(main_jni_conv->InterproceduralScratchRegister(), - mr_conv->MethodRegister(), mirror::AbstractMethod::DeclaringClassOffset()); + mr_conv->MethodRegister(), mirror::ArtMethod::DeclaringClassOffset()); __ VerifyObject(main_jni_conv->InterproceduralScratchRegister(), false); __ StoreRef(sirt_offset, main_jni_conv->InterproceduralScratchRegister()); main_jni_conv->Next(); // in SIRT so move to next argument @@ -270,7 +270,7 @@ CompiledMethod* ArtJniCompileMethodInternal(CompilerDriver& compiler, } // 9. Plant call to native code associated with method. - __ Call(main_jni_conv->MethodStackOffset(), mirror::AbstractMethod::NativeMethodOffset(), + __ Call(main_jni_conv->MethodStackOffset(), mirror::ArtMethod::NativeMethodOffset(), mr_conv->InterproceduralScratchRegister()); // 10. Fix differences in result widths. diff --git a/compiler/llvm/compiler_llvm.h b/compiler/llvm/compiler_llvm.h index 20934ab209..65bc16bcd8 100644 --- a/compiler/llvm/compiler_llvm.h +++ b/compiler/llvm/compiler_llvm.h @@ -34,7 +34,7 @@ namespace art { class CompilerDriver; class DexCompilationUnit; namespace mirror { - class AbstractMethod; + class ArtMethod; class ClassLoader; } // namespace mirror } // namespace art diff --git a/compiler/llvm/gbc_expander.cc b/compiler/llvm/gbc_expander.cc index a727d06cb2..4f6fa0a2df 100644 --- a/compiler/llvm/gbc_expander.cc +++ b/compiler/llvm/gbc_expander.cc @@ -20,7 +20,7 @@ #include "intrinsic_helper.h" #include "ir_builder.h" #include "method_reference.h" -#include "mirror/abstract_method.h" +#include "mirror/art_method.h" #include "mirror/array.h" #include "mirror/string.h" #include "thread.h" @@ -722,7 +722,7 @@ llvm::Value* GBCExpanderPass::EmitLoadDexCacheAddr(art::MemberOffset offset) { llvm::Value* GBCExpanderPass::EmitLoadDexCacheStaticStorageFieldAddr(uint32_t type_idx) { llvm::Value* static_storage_dex_cache_addr = - EmitLoadDexCacheAddr(art::mirror::AbstractMethod::DexCacheInitializedStaticStorageOffset()); + EmitLoadDexCacheAddr(art::mirror::ArtMethod::DexCacheInitializedStaticStorageOffset()); llvm::Value* type_idx_value = irb_.getPtrEquivInt(type_idx); @@ -732,7 +732,7 @@ GBCExpanderPass::EmitLoadDexCacheStaticStorageFieldAddr(uint32_t type_idx) { llvm::Value* GBCExpanderPass::EmitLoadDexCacheResolvedTypeFieldAddr(uint32_t type_idx) { llvm::Value* resolved_type_dex_cache_addr = - EmitLoadDexCacheAddr(art::mirror::AbstractMethod::DexCacheResolvedTypesOffset()); + EmitLoadDexCacheAddr(art::mirror::ArtMethod::DexCacheResolvedTypesOffset()); llvm::Value* type_idx_value = irb_.getPtrEquivInt(type_idx); @@ -742,7 +742,7 @@ GBCExpanderPass::EmitLoadDexCacheResolvedTypeFieldAddr(uint32_t type_idx) { llvm::Value* GBCExpanderPass:: EmitLoadDexCacheResolvedMethodFieldAddr(uint32_t method_idx) { llvm::Value* resolved_method_dex_cache_addr = - EmitLoadDexCacheAddr(art::mirror::AbstractMethod::DexCacheResolvedMethodsOffset()); + EmitLoadDexCacheAddr(art::mirror::ArtMethod::DexCacheResolvedMethodsOffset()); llvm::Value* method_idx_value = irb_.getPtrEquivInt(method_idx); @@ -752,7 +752,7 @@ EmitLoadDexCacheResolvedMethodFieldAddr(uint32_t method_idx) { llvm::Value* GBCExpanderPass:: EmitLoadDexCacheStringFieldAddr(uint32_t string_idx) { llvm::Value* string_dex_cache_addr = - EmitLoadDexCacheAddr(art::mirror::AbstractMethod::DexCacheStringsOffset()); + EmitLoadDexCacheAddr(art::mirror::ArtMethod::DexCacheStringsOffset()); llvm::Value* string_idx_value = irb_.getPtrEquivInt(string_idx); @@ -911,7 +911,7 @@ llvm::Value* GBCExpanderPass::EmitInvoke(llvm::CallInst& call_inst) { } else { code_addr = irb_.LoadFromObjectOffset(callee_method_object_addr, - art::mirror::AbstractMethod::GetEntryPointFromCompiledCodeOffset().Int32Value(), + art::mirror::ArtMethod::GetEntryPointFromCompiledCodeOffset().Int32Value(), func_type->getPointerTo(), kTBAARuntimeInfo); } @@ -1207,7 +1207,7 @@ void GBCExpanderPass::Expand_SPutFast(llvm::Value* static_storage_addr, llvm::Value* GBCExpanderPass::Expand_LoadDeclaringClassSSB(llvm::Value* method_object_addr) { return irb_.LoadFromObjectOffset(method_object_addr, - art::mirror::AbstractMethod::DeclaringClassOffset().Int32Value(), + art::mirror::ArtMethod::DeclaringClassOffset().Int32Value(), irb_.getJObjectTy(), kTBAAConstJObject); } @@ -1259,7 +1259,7 @@ llvm::Value* GBCExpanderPass::Expand_Invoke(llvm::CallInst& call_inst) { llvm::Value* code_addr = irb_.LoadFromObjectOffset(callee_method_object_addr, - art::mirror::AbstractMethod::GetEntryPointFromCompiledCodeOffset().Int32Value(), + art::mirror::ArtMethod::GetEntryPointFromCompiledCodeOffset().Int32Value(), callee_method_type->getPointerTo(), kTBAARuntimeInfo); @@ -1938,7 +1938,7 @@ llvm::Value* GBCExpanderPass::Expand_HLSget(llvm::CallInst& call_inst, static_storage_addr = irb_.LoadFromObjectOffset(method_object_addr, - art::mirror::AbstractMethod::DeclaringClassOffset().Int32Value(), + art::mirror::ArtMethod::DeclaringClassOffset().Int32Value(), irb_.getJObjectTy(), kTBAAConstJObject); } else { @@ -2023,7 +2023,7 @@ void GBCExpanderPass::Expand_HLSput(llvm::CallInst& call_inst, static_storage_addr = irb_.LoadFromObjectOffset(method_object_addr, - art::mirror::AbstractMethod::DeclaringClassOffset().Int32Value(), + art::mirror::ArtMethod::DeclaringClassOffset().Int32Value(), irb_.getJObjectTy(), kTBAAConstJObject); } else { diff --git a/compiler/oat_writer.cc b/compiler/oat_writer.cc index ce88cf6dd6..f813843bd3 100644 --- a/compiler/oat_writer.cc +++ b/compiler/oat_writer.cc @@ -23,7 +23,7 @@ #include "class_linker.h" #include "dex_file-inl.h" #include "gc/space/space.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/array.h" #include "mirror/class_loader.h" #include "mirror/object-inl.h" @@ -400,7 +400,7 @@ size_t OatWriter::InitOatCodeMethod(size_t offset, size_t oat_class_index, mirror::DexCache* dex_cache = linker->FindDexCache(*dex_file); // Unchecked as we hold mutator_lock_ on entry. ScopedObjectAccessUnchecked soa(Thread::Current()); - mirror::AbstractMethod* method = linker->ResolveMethod(*dex_file, method_idx, dex_cache, + mirror::ArtMethod* method = linker->ResolveMethod(*dex_file, method_idx, dex_cache, NULL, NULL, invoke_type); CHECK(method != NULL); method->SetFrameSizeInBytes(frame_size_in_bytes); diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc index b85378d9ec..c372d000df 100644 --- a/dex2oat/dex2oat.cc +++ b/dex2oat/dex2oat.cc @@ -37,7 +37,7 @@ #include "gc/space/space-inl.h" #include "image_writer.h" #include "leb128.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/class_loader.h" #include "mirror/object-inl.h" @@ -862,7 +862,7 @@ static int dex2oat(int argc, char** argv) { // give it away now and then switch to a more managable ScopedObjectAccess. Thread::Current()->TransitionFromRunnableToSuspended(kNative); // Whilst we're in native take the opportunity to initialize well known classes. - WellKnownClasses::InitClasses(Thread::Current()->GetJniEnv()); + WellKnownClasses::Init(Thread::Current()->GetJniEnv()); ScopedObjectAccess soa(Thread::Current()); // If --image-classes was specified, calculate the full list of classes to include in the image diff --git a/oatdump/oatdump.cc b/oatdump/oatdump.cc index a6f295f46d..67398afd5f 100644 --- a/oatdump/oatdump.cc +++ b/oatdump/oatdump.cc @@ -36,10 +36,10 @@ #include "image.h" #include "indenter.h" #include "mapping_table.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_field-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/array-inl.h" #include "mirror/class-inl.h" -#include "mirror/field-inl.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" #include "oat.h" @@ -169,7 +169,7 @@ class OatDumper { return oat_file_.GetOatHeader().GetInstructionSet(); } - const void* GetOatCode(mirror::AbstractMethod* m) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + const void* GetOatCode(mirror::ArtMethod* m) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { MethodHelper mh(m); for (size_t i = 0; i < oat_dex_files_.size(); i++) { const OatFile::OatDexFile* oat_dex_file = oat_dex_files_[i]; @@ -804,18 +804,18 @@ class ImageDumper { } else if (type->IsClassClass()) { mirror::Class* klass = value->AsClass(); os << StringPrintf("%p Class: %s\n", klass, PrettyDescriptor(klass).c_str()); - } else if (type->IsFieldClass()) { - mirror::Field* field = value->AsField(); + } else if (type->IsArtFieldClass()) { + mirror::ArtField* field = value->AsArtField(); os << StringPrintf("%p Field: %s\n", field, PrettyField(field).c_str()); - } else if (type->IsMethodClass()) { - mirror::AbstractMethod* method = value->AsMethod(); + } else if (type->IsArtMethodClass()) { + mirror::ArtMethod* method = value->AsArtMethod(); os << StringPrintf("%p Method: %s\n", method, PrettyMethod(method).c_str()); } else { os << StringPrintf("%p %s\n", value, PrettyDescriptor(type).c_str()); } } - static void PrintField(std::ostream& os, mirror::Field* field, mirror::Object* obj) + static void PrintField(std::ostream& os, mirror::ArtField* field, mirror::Object* obj) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { FieldHelper fh(field); const char* descriptor = fh.GetTypeDescriptor(); @@ -856,10 +856,10 @@ class ImageDumper { if (super != NULL) { DumpFields(os, obj, super); } - mirror::ObjectArray* fields = klass->GetIFields(); + mirror::ObjectArray* fields = klass->GetIFields(); if (fields != NULL) { for (int32_t i = 0; i < fields->GetLength(); i++) { - mirror::Field* field = fields->Get(i); + mirror::ArtField* field = fields->Get(i); PrintField(os, field, obj); } } @@ -869,7 +869,7 @@ class ImageDumper { return image_space_.Contains(object); } - const void* GetOatCodeBegin(mirror::AbstractMethod* m) + const void* GetOatCodeBegin(mirror::ArtMethod* m) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { const void* code = m->GetEntryPointFromCompiledCode(); if (code == GetResolutionTrampoline(Runtime::Current()->GetClassLinker())) { @@ -881,7 +881,7 @@ class ImageDumper { return code; } - uint32_t GetOatCodeSize(mirror::AbstractMethod* m) + uint32_t GetOatCodeSize(mirror::ArtMethod* m) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { const uint32_t* oat_code_begin = reinterpret_cast(GetOatCodeBegin(m)); if (oat_code_begin == NULL) { @@ -890,7 +890,7 @@ class ImageDumper { return oat_code_begin[-1]; } - const void* GetOatCodeEnd(mirror::AbstractMethod* m) + const void* GetOatCodeEnd(mirror::ArtMethod* m) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { const uint8_t* oat_code_begin = reinterpret_cast(GetOatCodeBegin(m)); if (oat_code_begin == NULL) { @@ -922,12 +922,12 @@ class ImageDumper { mirror::Class* klass = obj->AsClass(); os << StringPrintf("%p: java.lang.Class \"%s\" (", obj, PrettyDescriptor(klass).c_str()) << klass->GetStatus() << ")\n"; - } else if (obj->IsField()) { + } else if (obj->IsArtField()) { os << StringPrintf("%p: java.lang.reflect.Field %s\n", obj, - PrettyField(obj->AsField()).c_str()); - } else if (obj->IsMethod()) { + PrettyField(obj->AsArtField()).c_str()); + } else if (obj->IsArtMethod()) { os << StringPrintf("%p: java.lang.reflect.Method %s\n", obj, - PrettyMethod(obj->AsMethod()).c_str()); + PrettyMethod(obj->AsArtMethod()).c_str()); } else if (obj_class->IsStringClass()) { os << StringPrintf("%p: java.lang.String %s\n", obj, PrintableString(obj->AsString()->ToModifiedUtf8()).c_str()); @@ -960,18 +960,18 @@ class ImageDumper { PrettyObjectValue(indent_os, value_class, value); } } else if (obj->IsClass()) { - mirror::ObjectArray* sfields = obj->AsClass()->GetSFields(); + mirror::ObjectArray* sfields = obj->AsClass()->GetSFields(); if (sfields != NULL) { indent_os << "STATICS:\n"; Indenter indent2_filter(indent_os.rdbuf(), kIndentChar, kIndentBy1Count); std::ostream indent2_os(&indent2_filter); for (int32_t i = 0; i < sfields->GetLength(); i++) { - mirror::Field* field = sfields->Get(i); + mirror::ArtField* field = sfields->Get(i); PrintField(indent2_os, field, field->GetDeclaringClass()); } } - } else if (obj->IsMethod()) { - mirror::AbstractMethod* method = obj->AsMethod(); + } else if (obj->IsArtMethod()) { + mirror::ArtMethod* method = obj->AsArtMethod(); if (method->IsNative()) { DCHECK(method->GetNativeGcMap() == NULL) << PrettyMethod(method); DCHECK(method->GetMappingTable() == NULL) << PrettyMethod(method); @@ -1085,7 +1085,7 @@ class ImageDumper { size_t dex_instruction_bytes; - std::vector method_outlier; + std::vector method_outlier; std::vector method_outlier_size; std::vector method_outlier_expansion; std::vector > oat_dex_file_sizes; @@ -1138,7 +1138,7 @@ class ImageDumper { return (static_cast(size) / static_cast(object_bytes)) * 100; } - void ComputeOutliers(size_t total_size, double expansion, mirror::AbstractMethod* method) { + void ComputeOutliers(size_t total_size, double expansion, mirror::ArtMethod* method) { method_outlier_size.push_back(total_size); method_outlier_expansion.push_back(expansion); method_outlier.push_back(method); diff --git a/runtime/Android.mk b/runtime/Android.mk index 69e13e58f5..b34abe4282 100644 --- a/runtime/Android.mk +++ b/runtime/Android.mk @@ -78,11 +78,11 @@ LIBART_COMMON_SRC_FILES := \ locks.cc \ mem_map.cc \ memory_region.cc \ - mirror/abstract_method.cc \ + mirror/art_field.cc \ + mirror/art_method.cc \ mirror/array.cc \ mirror/class.cc \ mirror/dex_cache.cc \ - mirror/field.cc \ mirror/object.cc \ mirror/stack_trace_element.cc \ mirror/string.cc \ diff --git a/runtime/arch/arm/context_arm.cc b/runtime/arch/arm/context_arm.cc index 6b9538e801..102e1269b5 100644 --- a/runtime/arch/arm/context_arm.cc +++ b/runtime/arch/arm/context_arm.cc @@ -16,7 +16,7 @@ #include "context_arm.h" -#include "mirror/abstract_method.h" +#include "mirror/art_method.h" #include "mirror/object-inl.h" #include "stack.h" #include "thread.h" @@ -41,7 +41,7 @@ void ArmContext::Reset() { } void ArmContext::FillCalleeSaves(const StackVisitor& fr) { - mirror::AbstractMethod* method = fr.GetMethod(); + mirror::ArtMethod* method = fr.GetMethod(); uint32_t core_spills = method->GetCoreSpillMask(); uint32_t fp_core_spills = method->GetFpSpillMask(); size_t spill_count = __builtin_popcount(core_spills); diff --git a/runtime/arch/arm/entrypoints_init_arm.cc b/runtime/arch/arm/entrypoints_init_arm.cc index 810a6832b6..9e6902de3f 100644 --- a/runtime/arch/arm/entrypoints_init_arm.cc +++ b/runtime/arch/arm/entrypoints_init_arm.cc @@ -31,8 +31,8 @@ extern "C" void artInterpreterToCompiledCodeBridge(Thread* self, MethodHelper& m ShadowFrame* shadow_frame, JValue* result); // Portable entrypoints. -extern "C" void art_portable_resolution_trampoline(mirror::AbstractMethod*); -extern "C" void art_portable_to_interpreter_bridge(mirror::AbstractMethod*); +extern "C" void art_portable_resolution_trampoline(mirror::ArtMethod*); +extern "C" void art_portable_to_interpreter_bridge(mirror::ArtMethod*); // Alloc entrypoints. extern "C" void* art_quick_alloc_array(uint32_t, void*, int32_t); @@ -112,8 +112,8 @@ extern "C" int32_t art_quick_indexof(void*, uint32_t, uint32_t, uint32_t); extern "C" int32_t art_quick_string_compareto(void*, void*); // Invoke entrypoints. -extern "C" void art_quick_resolution_trampoline(mirror::AbstractMethod*); -extern "C" void art_quick_to_interpreter_bridge(mirror::AbstractMethod*); +extern "C" void art_quick_resolution_trampoline(mirror::ArtMethod*); +extern "C" void art_quick_to_interpreter_bridge(mirror::ArtMethod*); extern "C" void art_quick_invoke_direct_trampoline_with_access_check(uint32_t, void*); extern "C" void art_quick_invoke_interface_trampoline(uint32_t, void*); extern "C" void art_quick_invoke_interface_trampoline_with_access_check(uint32_t, void*); diff --git a/runtime/arch/mips/context_mips.cc b/runtime/arch/mips/context_mips.cc index a78e5ee80d..b957708769 100644 --- a/runtime/arch/mips/context_mips.cc +++ b/runtime/arch/mips/context_mips.cc @@ -16,7 +16,7 @@ #include "context_mips.h" -#include "mirror/abstract_method.h" +#include "mirror/art_method.h" #include "mirror/object-inl.h" #include "stack.h" @@ -40,7 +40,7 @@ void MipsContext::Reset() { } void MipsContext::FillCalleeSaves(const StackVisitor& fr) { - mirror::AbstractMethod* method = fr.GetMethod(); + mirror::ArtMethod* method = fr.GetMethod(); uint32_t core_spills = method->GetCoreSpillMask(); uint32_t fp_core_spills = method->GetFpSpillMask(); size_t spill_count = __builtin_popcount(core_spills); diff --git a/runtime/arch/mips/entrypoints_init_mips.cc b/runtime/arch/mips/entrypoints_init_mips.cc index a0d3995bce..40d7cd913c 100644 --- a/runtime/arch/mips/entrypoints_init_mips.cc +++ b/runtime/arch/mips/entrypoints_init_mips.cc @@ -30,8 +30,8 @@ extern "C" void artInterpreterToCompiledCodeBridge(Thread* self, MethodHelper& m ShadowFrame* shadow_frame, JValue* result); // Portable entrypoints. -extern "C" void art_portable_resolution_trampoline(mirror::AbstractMethod*); -extern "C" void art_portable_to_interpreter_bridge(mirror::AbstractMethod*); +extern "C" void art_portable_resolution_trampoline(mirror::ArtMethod*); +extern "C" void art_portable_to_interpreter_bridge(mirror::ArtMethod*); // Alloc entrypoints. extern "C" void* art_quick_alloc_array(uint32_t, void*, int32_t); @@ -113,8 +113,8 @@ extern "C" int32_t art_quick_indexof(void*, uint32_t, uint32_t, uint32_t); extern "C" int32_t art_quick_string_compareto(void*, void*); // Invoke entrypoints. -extern "C" void art_quick_resolution_trampoline(mirror::AbstractMethod*); -extern "C" void art_quick_to_interpreter_bridge(mirror::AbstractMethod*); +extern "C" void art_quick_resolution_trampoline(mirror::ArtMethod*); +extern "C" void art_quick_to_interpreter_bridge(mirror::ArtMethod*); extern "C" void art_quick_invoke_direct_trampoline_with_access_check(uint32_t, void*); extern "C" void art_quick_invoke_interface_trampoline(uint32_t, void*); extern "C" void art_quick_invoke_interface_trampoline_with_access_check(uint32_t, void*); diff --git a/runtime/arch/x86/context_x86.cc b/runtime/arch/x86/context_x86.cc index c728ae97ec..66a51f7492 100644 --- a/runtime/arch/x86/context_x86.cc +++ b/runtime/arch/x86/context_x86.cc @@ -16,7 +16,7 @@ #include "context_x86.h" -#include "mirror/abstract_method.h" +#include "mirror/art_method.h" #include "mirror/object-inl.h" #include "stack.h" @@ -36,7 +36,7 @@ void X86Context::Reset() { } void X86Context::FillCalleeSaves(const StackVisitor& fr) { - mirror::AbstractMethod* method = fr.GetMethod(); + mirror::ArtMethod* method = fr.GetMethod(); uint32_t core_spills = method->GetCoreSpillMask(); size_t spill_count = __builtin_popcount(core_spills); DCHECK_EQ(method->GetFpSpillMask(), 0u); diff --git a/runtime/arch/x86/entrypoints_init_x86.cc b/runtime/arch/x86/entrypoints_init_x86.cc index 9b54d55bfc..abc2990cc0 100644 --- a/runtime/arch/x86/entrypoints_init_x86.cc +++ b/runtime/arch/x86/entrypoints_init_x86.cc @@ -29,8 +29,8 @@ extern "C" void artInterpreterToCompiledCodeBridge(Thread* self, MethodHelper& m ShadowFrame* shadow_frame, JValue* result); // Portable entrypoints. -extern "C" void art_portable_resolution_trampoline(mirror::AbstractMethod*); -extern "C" void art_portable_to_interpreter_bridge(mirror::AbstractMethod*); +extern "C" void art_portable_resolution_trampoline(mirror::ArtMethod*); +extern "C" void art_portable_to_interpreter_bridge(mirror::ArtMethod*); // Alloc entrypoints. extern "C" void* art_quick_alloc_array(uint32_t, void*, int32_t); @@ -95,8 +95,8 @@ extern "C" int32_t art_quick_string_compareto(void*, void*); extern "C" void* art_quick_memcpy(void*, const void*, size_t); // Invoke entrypoints. -extern "C" void art_quick_resolution_trampoline(mirror::AbstractMethod*); -extern "C" void art_quick_to_interpreter_bridge(mirror::AbstractMethod*); +extern "C" void art_quick_resolution_trampoline(mirror::ArtMethod*); +extern "C" void art_quick_to_interpreter_bridge(mirror::ArtMethod*); extern "C" void art_quick_invoke_direct_trampoline_with_access_check(uint32_t, void*); extern "C" void art_quick_invoke_interface_trampoline(uint32_t, void*); extern "C" void art_quick_invoke_interface_trampoline_with_access_check(uint32_t, void*); diff --git a/runtime/check_jni.cc b/runtime/check_jni.cc index 073d67b823..6a7ceeed0b 100644 --- a/runtime/check_jni.cc +++ b/runtime/check_jni.cc @@ -24,9 +24,9 @@ #include "class_linker-inl.h" #include "dex_file-inl.h" #include "gc/space/space.h" +#include "mirror/art_field-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" -#include "mirror/field-inl.h" -#include "mirror/abstract_method-inl.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" #include "mirror/throwable.h" @@ -44,7 +44,7 @@ namespace art { static void JniAbort(const char* jni_function_name, const char* msg) { Thread* self = Thread::Current(); ScopedObjectAccess soa(self); - mirror::AbstractMethod* current_method = self->GetCurrentMethod(NULL); + mirror::ArtMethod* current_method = self->GetCurrentMethod(NULL); std::ostringstream os; os << "JNI DETECTED ERROR IN APPLICATION: " << msg; @@ -131,7 +131,7 @@ static const char* gBuiltInPrefixes[] = { NULL }; -static bool ShouldTrace(JavaVMExt* vm, const mirror::AbstractMethod* method) +static bool ShouldTrace(JavaVMExt* vm, const mirror::ArtMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { // If both "-Xcheck:jni" and "-Xjnitrace:" are enabled, we print trace messages // when a native method that matches the -Xjnitrace argument calls a JNI function @@ -204,7 +204,7 @@ class ScopedCheck { */ void CheckFieldType(jobject java_object, jfieldID fid, char prim, bool isStatic) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* f = CheckFieldID(fid); + mirror::ArtField* f = CheckFieldID(fid); if (f == NULL) { return; } @@ -259,7 +259,7 @@ class ScopedCheck { return; } - mirror::Field* f = CheckFieldID(fid); + mirror::ArtField* f = CheckFieldID(fid); if (f == NULL) { return; } @@ -286,7 +286,7 @@ class ScopedCheck { */ void CheckSig(jmethodID mid, const char* expectedType, bool isStatic) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* m = CheckMethodID(mid); + mirror::ArtMethod* m = CheckMethodID(mid); if (m == NULL) { return; } @@ -313,7 +313,7 @@ class ScopedCheck { void CheckStaticFieldID(jclass java_class, jfieldID fid) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { mirror::Class* c = soa_.Decode(java_class); - const mirror::Field* f = CheckFieldID(fid); + const mirror::ArtField* f = CheckFieldID(fid); if (f == NULL) { return; } @@ -334,7 +334,7 @@ class ScopedCheck { */ void CheckStaticMethod(jclass java_class, jmethodID mid) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - const mirror::AbstractMethod* m = CheckMethodID(mid); + const mirror::ArtMethod* m = CheckMethodID(mid); if (m == NULL) { return; } @@ -354,7 +354,7 @@ class ScopedCheck { */ void CheckVirtualMethod(jobject java_object, jmethodID mid) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - const mirror::AbstractMethod* m = CheckMethodID(mid); + const mirror::ArtMethod* m = CheckMethodID(mid); if (m == NULL) { return; } @@ -404,7 +404,7 @@ class ScopedCheck { void Check(bool entry, const char* fmt0, ...) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { va_list ap; - const mirror::AbstractMethod* traceMethod = NULL; + const mirror::ArtMethod* traceMethod = NULL; if (has_method_ && (!soa_.Vm()->trace.empty() || VLOG_IS_ON(third_party_jni))) { // We need to guard some of the invocation interface's calls: a bad caller might // use DetachCurrentThread or GetEnv on a thread that's not yet attached. @@ -477,7 +477,7 @@ class ScopedCheck { } } else if (ch == 'f') { // jfieldID jfieldID fid = va_arg(ap, jfieldID); - mirror::Field* f = reinterpret_cast(fid); + mirror::ArtField* f = reinterpret_cast(fid); msg += PrettyField(f); if (!entry) { StringAppendF(&msg, " (%p)", fid); @@ -490,7 +490,7 @@ class ScopedCheck { StringAppendF(&msg, "%d", i); } else if (ch == 'm') { // jmethodID jmethodID mid = va_arg(ap, jmethodID); - mirror::AbstractMethod* m = reinterpret_cast(mid); + mirror::ArtMethod* m = reinterpret_cast(mid); msg += PrettyMethod(m); if (!entry) { StringAppendF(&msg, " (%p)", mid); @@ -700,13 +700,13 @@ class ScopedCheck { } } - mirror::Field* CheckFieldID(jfieldID fid) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + mirror::ArtField* CheckFieldID(jfieldID fid) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { if (fid == NULL) { JniAbortF(function_name_, "jfieldID was NULL"); return NULL; } - mirror::Field* f = soa_.DecodeField(fid); - if (!Runtime::Current()->GetHeap()->IsHeapAddress(f) || !f->IsField()) { + mirror::ArtField* f = soa_.DecodeField(fid); + if (!Runtime::Current()->GetHeap()->IsHeapAddress(f) || !f->IsArtField()) { Runtime::Current()->GetHeap()->DumpSpaces(); JniAbortF(function_name_, "invalid jfieldID: %p", fid); return NULL; @@ -714,13 +714,13 @@ class ScopedCheck { return f; } - mirror::AbstractMethod* CheckMethodID(jmethodID mid) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + mirror::ArtMethod* CheckMethodID(jmethodID mid) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { if (mid == NULL) { JniAbortF(function_name_, "jmethodID was NULL"); return NULL; } - mirror::AbstractMethod* m = soa_.DecodeMethod(mid); - if (!Runtime::Current()->GetHeap()->IsHeapAddress(m) || !m->IsMethod()) { + mirror::ArtMethod* m = soa_.DecodeMethod(mid); + if (!Runtime::Current()->GetHeap()->IsHeapAddress(m) || !m->IsArtMethod()) { Runtime::Current()->GetHeap()->DumpSpaces(); JniAbortF(function_name_, "invalid jmethodID: %p", mid); return NULL; diff --git a/runtime/class_linker-inl.h b/runtime/class_linker-inl.h index 4d01b66f0a..ad568b1cdb 100644 --- a/runtime/class_linker-inl.h +++ b/runtime/class_linker-inl.h @@ -19,15 +19,15 @@ #include "class_linker.h" +#include "mirror/art_field.h" #include "mirror/dex_cache.h" -#include "mirror/field.h" #include "mirror/iftable.h" #include "mirror/object_array.h" namespace art { inline mirror::String* ClassLinker::ResolveString(uint32_t string_idx, - const mirror::AbstractMethod* referrer) { + const mirror::ArtMethod* referrer) { mirror::String* resolved_string = referrer->GetDexCacheStrings()->Get(string_idx); if (UNLIKELY(resolved_string == NULL)) { mirror::Class* declaring_class = referrer->GetDeclaringClass(); @@ -39,7 +39,7 @@ inline mirror::String* ClassLinker::ResolveString(uint32_t string_idx, } inline mirror::Class* ClassLinker::ResolveType(uint16_t type_idx, - const mirror::AbstractMethod* referrer) { + const mirror::ArtMethod* referrer) { mirror::Class* resolved_type = referrer->GetDexCacheResolvedTypes()->Get(type_idx); if (UNLIKELY(resolved_type == NULL)) { mirror::Class* declaring_class = referrer->GetDeclaringClass(); @@ -51,7 +51,7 @@ inline mirror::Class* ClassLinker::ResolveType(uint16_t type_idx, return resolved_type; } -inline mirror::Class* ClassLinker::ResolveType(uint16_t type_idx, const mirror::Field* referrer) { +inline mirror::Class* ClassLinker::ResolveType(uint16_t type_idx, const mirror::ArtField* referrer) { mirror::Class* declaring_class = referrer->GetDeclaringClass(); mirror::DexCache* dex_cache = declaring_class->GetDexCache(); mirror::Class* resolved_type = dex_cache->GetResolvedType(type_idx); @@ -63,10 +63,10 @@ inline mirror::Class* ClassLinker::ResolveType(uint16_t type_idx, const mirror:: return resolved_type; } -inline mirror::AbstractMethod* ClassLinker::ResolveMethod(uint32_t method_idx, - const mirror::AbstractMethod* referrer, - InvokeType type) { - mirror::AbstractMethod* resolved_method = +inline mirror::ArtMethod* ClassLinker::ResolveMethod(uint32_t method_idx, + const mirror::ArtMethod* referrer, + InvokeType type) { + mirror::ArtMethod* resolved_method = referrer->GetDexCacheResolvedMethods()->Get(method_idx); if (UNLIKELY(resolved_method == NULL || resolved_method->IsRuntimeMethod())) { mirror::Class* declaring_class = referrer->GetDeclaringClass(); @@ -78,10 +78,10 @@ inline mirror::AbstractMethod* ClassLinker::ResolveMethod(uint32_t method_idx, return resolved_method; } -inline mirror::Field* ClassLinker::ResolveField(uint32_t field_idx, - const mirror::AbstractMethod* referrer, - bool is_static) { - mirror::Field* resolved_field = +inline mirror::ArtField* ClassLinker::ResolveField(uint32_t field_idx, + const mirror::ArtMethod* referrer, + bool is_static) { + mirror::ArtField* resolved_field = referrer->GetDeclaringClass()->GetDexCache()->GetResolvedField(field_idx); if (UNLIKELY(resolved_field == NULL)) { mirror::Class* declaring_class = referrer->GetDeclaringClass(); @@ -109,16 +109,10 @@ inline mirror::ObjectArray* ClassLinker::AllocStringArray(Thread length); } -inline mirror::ObjectArray* ClassLinker::AllocAbstractMethodArray(Thread* self, - size_t length) { - return mirror::ObjectArray::Alloc(self, - GetClassRoot(kJavaLangReflectAbstractMethodArrayClass), length); -} - -inline mirror::ObjectArray* ClassLinker::AllocMethodArray(Thread* self, - size_t length) { - return mirror::ObjectArray::Alloc(self, - GetClassRoot(kJavaLangReflectMethodArrayClass), length); +inline mirror::ObjectArray* ClassLinker::AllocArtMethodArray(Thread* self, + size_t length) { + return mirror::ObjectArray::Alloc(self, + GetClassRoot(kJavaLangReflectArtMethodArrayClass), length); } inline mirror::IfTable* ClassLinker::AllocIfTable(Thread* self, size_t ifcount) { @@ -126,11 +120,11 @@ inline mirror::IfTable* ClassLinker::AllocIfTable(Thread* self, size_t ifcount) mirror::IfTable::Alloc(self, GetClassRoot(kObjectArrayClass), ifcount * mirror::IfTable::kMax)); } -inline mirror::ObjectArray* ClassLinker::AllocFieldArray(Thread* self, - size_t length) { - return mirror::ObjectArray::Alloc(self, - GetClassRoot(kJavaLangReflectFieldArrayClass), - length); +inline mirror::ObjectArray* ClassLinker::AllocArtFieldArray(Thread* self, + size_t length) { + return mirror::ObjectArray::Alloc(self, + GetClassRoot(kJavaLangReflectArtFieldArrayClass), + length); } inline mirror::Class* ClassLinker::GetClassRoot(ClassRoot class_root) diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc index c7a8f7e3d4..1e21736d66 100644 --- a/runtime/class_linker.cc +++ b/runtime/class_linker.cc @@ -43,14 +43,13 @@ #include "leb128.h" #include "oat.h" #include "oat_file.h" +#include "mirror/art_field-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class.h" #include "mirror/class-inl.h" #include "mirror/class_loader.h" #include "mirror/dex_cache-inl.h" -#include "mirror/field-inl.h" #include "mirror/iftable-inl.h" -#include "mirror/abstract_method.h" -#include "mirror/abstract_method-inl.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" #include "mirror/proxy.h" @@ -145,15 +144,12 @@ const char* ClassLinker::class_roots_descriptors_[] = { "Ljava/lang/String;", "Ljava/lang/DexCache;", "Ljava/lang/ref/Reference;", - "Ljava/lang/reflect/Constructor;", - "Ljava/lang/reflect/Field;", - "Ljava/lang/reflect/AbstractMethod;", - "Ljava/lang/reflect/Method;", + "Ljava/lang/reflect/ArtField;", + "Ljava/lang/reflect/ArtMethod;", "Ljava/lang/reflect/Proxy;", "[Ljava/lang/String;", - "[Ljava/lang/reflect/AbstractMethod;", - "[Ljava/lang/reflect/Field;", - "[Ljava/lang/reflect/Method;", + "[Ljava/lang/reflect/ArtField;", + "[Ljava/lang/reflect/ArtMethod;", "Ljava/lang/ClassLoader;", "Ljava/lang/Throwable;", "Ljava/lang/ClassNotFoundException;", @@ -292,56 +288,38 @@ void ClassLinker::InitFromCompiler(const std::vector& boot_class java_lang_DexCache->SetStatus(mirror::Class::kStatusResolved); // Constructor, Field, Method, and AbstractMethod are necessary so that FindClass can link members. - SirtRef java_lang_reflect_Field(self, AllocClass(self, java_lang_Class.get(), - sizeof(mirror::FieldClass))); - CHECK(java_lang_reflect_Field.get() != NULL); - java_lang_reflect_Field->SetObjectSize(sizeof(mirror::Field)); - SetClassRoot(kJavaLangReflectField, java_lang_reflect_Field.get()); - java_lang_reflect_Field->SetStatus(mirror::Class::kStatusResolved); - mirror::Field::SetClass(java_lang_reflect_Field.get()); - - SirtRef java_lang_reflect_AbstractMethod(self, AllocClass(self, java_lang_Class.get(), - sizeof(mirror::AbstractMethodClass))); - CHECK(java_lang_reflect_AbstractMethod.get() != NULL); - java_lang_reflect_AbstractMethod->SetObjectSize(sizeof(mirror::AbstractMethod)); - SetClassRoot(kJavaLangReflectAbstractMethod, java_lang_reflect_AbstractMethod.get()); - java_lang_reflect_AbstractMethod->SetStatus(mirror::Class::kStatusResolved); - - SirtRef java_lang_reflect_Constructor(self, AllocClass(self, java_lang_Class.get(), - sizeof(mirror::AbstractMethodClass))); - CHECK(java_lang_reflect_Constructor.get() != NULL); - java_lang_reflect_Constructor->SetObjectSize(sizeof(mirror::Constructor)); - java_lang_reflect_Constructor->SetSuperClass(java_lang_reflect_AbstractMethod.get()); - SetClassRoot(kJavaLangReflectConstructor, java_lang_reflect_Constructor.get()); - java_lang_reflect_Constructor->SetStatus(mirror::Class::kStatusResolved); - - SirtRef java_lang_reflect_Method(self, AllocClass(self, java_lang_Class.get(), - sizeof(mirror::AbstractMethodClass))); - CHECK(java_lang_reflect_Method.get() != NULL); - java_lang_reflect_Method->SetObjectSize(sizeof(mirror::Method)); - java_lang_reflect_Method->SetSuperClass(java_lang_reflect_AbstractMethod.get()); - SetClassRoot(kJavaLangReflectMethod, java_lang_reflect_Method.get()); - java_lang_reflect_Method->SetStatus(mirror::Class::kStatusResolved); - - mirror::AbstractMethod::SetClasses(java_lang_reflect_Constructor.get(), - java_lang_reflect_Method.get()); + SirtRef java_lang_reflect_ArtField(self, AllocClass(self, java_lang_Class.get(), + sizeof(mirror::ArtFieldClass))); + CHECK(java_lang_reflect_ArtField.get() != NULL); + java_lang_reflect_ArtField->SetObjectSize(sizeof(mirror::ArtField)); + SetClassRoot(kJavaLangReflectArtField, java_lang_reflect_ArtField.get()); + java_lang_reflect_ArtField->SetStatus(mirror::Class::kStatusResolved); + mirror::ArtField::SetClass(java_lang_reflect_ArtField.get()); + + SirtRef java_lang_reflect_ArtMethod(self, AllocClass(self, java_lang_Class.get(), + sizeof(mirror::ArtMethodClass))); + CHECK(java_lang_reflect_ArtMethod.get() != NULL); + java_lang_reflect_ArtMethod->SetObjectSize(sizeof(mirror::ArtMethod)); + SetClassRoot(kJavaLangReflectArtMethod, java_lang_reflect_ArtMethod.get()); + java_lang_reflect_ArtMethod->SetStatus(mirror::Class::kStatusResolved); + + mirror::ArtMethod::SetClass(java_lang_reflect_ArtMethod.get()); // Set up array classes for string, field, method - SirtRef object_array_string(self, AllocClass(self, java_lang_Class.get(), sizeof(mirror::Class))); + SirtRef object_array_string(self, AllocClass(self, java_lang_Class.get(), + sizeof(mirror::Class))); object_array_string->SetComponentType(java_lang_String.get()); SetClassRoot(kJavaLangStringArrayClass, object_array_string.get()); - SirtRef object_array_abstract_method(self, AllocClass(self, java_lang_Class.get(), sizeof(mirror::Class))); - object_array_abstract_method->SetComponentType(java_lang_reflect_AbstractMethod.get()); - SetClassRoot(kJavaLangReflectAbstractMethodArrayClass, object_array_abstract_method.get()); + SirtRef object_array_art_method(self, AllocClass(self, java_lang_Class.get(), + sizeof(mirror::Class))); + object_array_art_method->SetComponentType(java_lang_reflect_ArtMethod.get()); + SetClassRoot(kJavaLangReflectArtMethodArrayClass, object_array_art_method.get()); - SirtRef object_array_field(self, AllocClass(self, java_lang_Class.get(), sizeof(mirror::Class))); - object_array_field->SetComponentType(java_lang_reflect_Field.get()); - SetClassRoot(kJavaLangReflectFieldArrayClass, object_array_field.get()); - - SirtRef object_array_method(self, AllocClass(self, java_lang_Class.get(), sizeof(mirror::Class))); - object_array_method->SetComponentType(java_lang_reflect_Method.get()); - SetClassRoot(kJavaLangReflectMethodArrayClass, object_array_method.get()); + SirtRef object_array_art_field(self, AllocClass(self, java_lang_Class.get(), + sizeof(mirror::Class))); + object_array_art_field->SetComponentType(java_lang_reflect_ArtField.get()); + SetClassRoot(kJavaLangReflectArtFieldArrayClass, object_array_art_field.get()); // Setup boot_class_path_ and register class_path now that we can use AllocObjectArray to create // DexCache instances. Needs to be after String, Field, Method arrays since AllocDexCache uses @@ -422,42 +400,29 @@ void ClassLinker::InitFromCompiler(const std::vector& boot_class kh.ChangeClass(object_array_class.get()); CHECK_EQ(java_lang_Cloneable, kh.GetDirectInterface(0)); CHECK_EQ(java_io_Serializable, kh.GetDirectInterface(1)); - // Run Class, Constructor, Field, and Method through FindSystemClass. This initializes their + // Run Class, ArtField, and ArtMethod through FindSystemClass. This initializes their // dex_cache_ fields and register them in classes_. mirror::Class* Class_class = FindSystemClass("Ljava/lang/Class;"); CHECK_EQ(java_lang_Class.get(), Class_class); - java_lang_reflect_AbstractMethod->SetStatus(mirror::Class::kStatusNotReady); - mirror::Class* Abstract_method_class = FindSystemClass("Ljava/lang/reflect/AbstractMethod;"); - CHECK_EQ(java_lang_reflect_AbstractMethod.get(), Abstract_method_class); - - // Method extends AbstractMethod so must reset after. - java_lang_reflect_Method->SetStatus(mirror::Class::kStatusNotReady); - mirror::Class* Method_class = FindSystemClass("Ljava/lang/reflect/Method;"); - CHECK_EQ(java_lang_reflect_Method.get(), Method_class); + java_lang_reflect_ArtMethod->SetStatus(mirror::Class::kStatusNotReady); + mirror::Class* Art_method_class = FindSystemClass("Ljava/lang/reflect/ArtMethod;"); + CHECK_EQ(java_lang_reflect_ArtMethod.get(), Art_method_class); - // Constructor extends AbstractMethod so must reset after. - java_lang_reflect_Constructor->SetStatus(mirror::Class::kStatusNotReady); - mirror::Class* Constructor_class = FindSystemClass("Ljava/lang/reflect/Constructor;"); - CHECK_EQ(java_lang_reflect_Constructor.get(), Constructor_class); - - java_lang_reflect_Field->SetStatus(mirror::Class::kStatusNotReady); - mirror::Class* Field_class = FindSystemClass("Ljava/lang/reflect/Field;"); - CHECK_EQ(java_lang_reflect_Field.get(), Field_class); + java_lang_reflect_ArtField->SetStatus(mirror::Class::kStatusNotReady); + mirror::Class* Art_field_class = FindSystemClass("Ljava/lang/reflect/ArtField;"); + CHECK_EQ(java_lang_reflect_ArtField.get(), Art_field_class); mirror::Class* String_array_class = FindSystemClass(class_roots_descriptors_[kJavaLangStringArrayClass]); CHECK_EQ(object_array_string.get(), String_array_class); - mirror::Class* Abstract_method_array_class = - FindSystemClass(class_roots_descriptors_[kJavaLangReflectAbstractMethodArrayClass]); - CHECK_EQ(object_array_abstract_method.get(), Abstract_method_array_class); - - mirror::Class* Field_array_class = FindSystemClass(class_roots_descriptors_[kJavaLangReflectFieldArrayClass]); - CHECK_EQ(object_array_field.get(), Field_array_class); + mirror::Class* Art_method_array_class = + FindSystemClass(class_roots_descriptors_[kJavaLangReflectArtMethodArrayClass]); + CHECK_EQ(object_array_art_method.get(), Art_method_array_class); - mirror::Class* Method_array_class = - FindSystemClass(class_roots_descriptors_[kJavaLangReflectMethodArrayClass]); - CHECK_EQ(object_array_method.get(), Method_array_class); + mirror::Class* Art_field_array_class = + FindSystemClass(class_roots_descriptors_[kJavaLangReflectArtFieldArrayClass]); + CHECK_EQ(object_array_art_field.get(), Art_field_array_class); // End of special init trickery, subsequent classes may be loaded via FindSystemClass. @@ -516,31 +481,31 @@ void ClassLinker::FinishInit() { const DexFile& java_lang_dex = *java_lang_ref_Reference->GetDexCache()->GetDexFile(); - mirror::Field* pendingNext = java_lang_ref_Reference->GetInstanceField(0); + mirror::ArtField* pendingNext = java_lang_ref_Reference->GetInstanceField(0); FieldHelper fh(pendingNext, this); CHECK_STREQ(fh.GetName(), "pendingNext"); CHECK_EQ(java_lang_dex.GetFieldId(pendingNext->GetDexFieldIndex()).type_idx_, java_lang_ref_Reference->GetDexTypeIndex()); - mirror::Field* queue = java_lang_ref_Reference->GetInstanceField(1); + mirror::ArtField* queue = java_lang_ref_Reference->GetInstanceField(1); fh.ChangeField(queue); CHECK_STREQ(fh.GetName(), "queue"); CHECK_EQ(java_lang_dex.GetFieldId(queue->GetDexFieldIndex()).type_idx_, java_lang_ref_ReferenceQueue->GetDexTypeIndex()); - mirror::Field* queueNext = java_lang_ref_Reference->GetInstanceField(2); + mirror::ArtField* queueNext = java_lang_ref_Reference->GetInstanceField(2); fh.ChangeField(queueNext); CHECK_STREQ(fh.GetName(), "queueNext"); CHECK_EQ(java_lang_dex.GetFieldId(queueNext->GetDexFieldIndex()).type_idx_, java_lang_ref_Reference->GetDexTypeIndex()); - mirror::Field* referent = java_lang_ref_Reference->GetInstanceField(3); + mirror::ArtField* referent = java_lang_ref_Reference->GetInstanceField(3); fh.ChangeField(referent); CHECK_STREQ(fh.GetName(), "referent"); CHECK_EQ(java_lang_dex.GetFieldId(referent->GetDexFieldIndex()).type_idx_, GetClassRoot(kJavaLangObject)->GetDexTypeIndex()); - mirror::Field* zombie = java_lang_ref_FinalizerReference->GetInstanceField(2); + mirror::ArtField* zombie = java_lang_ref_FinalizerReference->GetInstanceField(2); fh.ChangeField(zombie); CHECK_STREQ(fh.GetName(), "zombie"); CHECK_EQ(java_lang_dex.GetFieldId(zombie->GetDexFieldIndex()).type_idx_, @@ -958,8 +923,8 @@ static void InitFromImageCallbackCommon(mirror::Object* obj, ClassLinker* class_ ClassHelper kh(klass, class_linker); mirror::Class* existing = class_linker->InsertClass(kh.GetDescriptor(), klass, true); DCHECK(existing == NULL) << kh.GetDescriptor(); - } else if (interpret_only_mode && obj->IsMethod()) { - mirror::AbstractMethod* method = obj->AsMethod(); + } else if (interpret_only_mode && obj->IsArtMethod()) { + mirror::ArtMethod* method = obj->AsArtMethod(); if (!method->IsNative()) { method->SetEntryPointFromInterpreter(interpreter::artInterpreterToInterpreterBridge); if (method != Runtime::Current()->GetResolutionMethod()) { @@ -1027,8 +992,7 @@ void ClassLinker::InitFromImage() { // Set classes on AbstractMethod early so that IsMethod tests can be performed during the live // bitmap walk. - mirror::AbstractMethod::SetClasses(GetClassRoot(kJavaLangReflectConstructor), - GetClassRoot(kJavaLangReflectMethod)); + mirror::ArtMethod::SetClass(GetClassRoot(kJavaLangReflectArtMethod)); // reinit clases_ table { @@ -1049,7 +1013,7 @@ void ClassLinker::InitFromImage() { array_iftable_ = GetClassRoot(kObjectArrayClass)->GetIfTable(); DCHECK(array_iftable_ == GetClassRoot(kBooleanArrayClass)->GetIfTable()); // String class root was set above - mirror::Field::SetClass(GetClassRoot(kJavaLangReflectField)); + mirror::ArtField::SetClass(GetClassRoot(kJavaLangReflectArtField)); mirror::BooleanArray::SetArrayClass(GetClassRoot(kBooleanArrayClass)); mirror::ByteArray::SetArrayClass(GetClassRoot(kByteArrayClass)); mirror::CharArray::SetArrayClass(GetClassRoot(kCharArrayClass)); @@ -1132,8 +1096,8 @@ void ClassLinker::VisitClassesWithoutClassesLock(ClassVisitor* visitor, void* ar ClassLinker::~ClassLinker() { mirror::Class::ResetClass(); mirror::String::ResetClass(); - mirror::Field::ResetClass(); - mirror::AbstractMethod::ResetClasses(); + mirror::ArtField::ResetClass(); + mirror::ArtMethod::ResetClass(); mirror::BooleanArray::ResetArrayClass(); mirror::ByteArray::ResetArrayClass(); mirror::CharArray::ResetArrayClass(); @@ -1172,13 +1136,13 @@ mirror::DexCache* ClassLinker::AllocDexCache(Thread* self, const DexFile& dex_fi if (types.get() == NULL) { return NULL; } - SirtRef > - methods(self, AllocAbstractMethodArray(self, dex_file.NumMethodIds())); + SirtRef > + methods(self, AllocArtMethodArray(self, dex_file.NumMethodIds())); if (methods.get() == NULL) { return NULL; } - SirtRef > - fields(self, AllocFieldArray(self, dex_file.NumFieldIds())); + SirtRef > + fields(self, AllocArtFieldArray(self, dex_file.NumFieldIds())); if (fields.get() == NULL) { return NULL; } @@ -1214,16 +1178,12 @@ mirror::Class* ClassLinker::AllocClass(Thread* self, size_t class_size) { return AllocClass(self, GetClassRoot(kJavaLangClass), class_size); } -mirror::Field* ClassLinker::AllocField(Thread* self) { - return down_cast(GetClassRoot(kJavaLangReflectField)->AllocObject(self)); +mirror::ArtField* ClassLinker::AllocArtField(Thread* self) { + return down_cast(GetClassRoot(kJavaLangReflectArtField)->AllocObject(self)); } -mirror::Method* ClassLinker::AllocMethod(Thread* self) { - return down_cast(GetClassRoot(kJavaLangReflectMethod)->AllocObject(self)); -} - -mirror::Constructor* ClassLinker::AllocConstructor(Thread* self) { - return down_cast(GetClassRoot(kJavaLangReflectConstructor)->AllocObject(self)); +mirror::ArtMethod* ClassLinker::AllocArtMethod(Thread* self) { + return down_cast(GetClassRoot(kJavaLangReflectArtMethod)->AllocObject(self)); } mirror::ObjectArray* ClassLinker::AllocStackTraceElementArray(Thread* self, @@ -1364,14 +1324,10 @@ mirror::Class* ClassLinker::DefineClass(const StringPiece& descriptor, klass.reset(GetClassRoot(kJavaLangString)); } else if (descriptor == "Ljava/lang/DexCache;") { klass.reset(GetClassRoot(kJavaLangDexCache)); - } else if (descriptor == "Ljava/lang/reflect/Field;") { - klass.reset(GetClassRoot(kJavaLangReflectField)); - } else if (descriptor == "Ljava/lang/reflect/AbstractMethod;") { - klass.reset(GetClassRoot(kJavaLangReflectAbstractMethod)); - } else if (descriptor == "Ljava/lang/reflect/Constructor;") { - klass.reset(GetClassRoot(kJavaLangReflectConstructor)); - } else if (descriptor == "Ljava/lang/reflect/Method;") { - klass.reset(GetClassRoot(kJavaLangReflectMethod)); + } else if (descriptor == "Ljava/lang/reflect/ArtField;") { + klass.reset(GetClassRoot(kJavaLangReflectArtField)); + } else if (descriptor == "Ljava/lang/reflect/ArtMethod;") { + klass.reset(GetClassRoot(kJavaLangReflectArtMethod)); } else { klass.reset(AllocClass(self, SizeOfClass(dex_file, dex_class_def))); } @@ -1519,7 +1475,7 @@ static uint32_t GetOatMethodIndexFromMethodIndex(const DexFile& dex_file, uint32 return 0; } -const OatFile::OatMethod ClassLinker::GetOatMethodFor(const mirror::AbstractMethod* method) { +const OatFile::OatMethod ClassLinker::GetOatMethodFor(const mirror::ArtMethod* method) { // Although we overwrite the trampoline of non-static methods, we may get here via the resolution // method for direct methods (or virtual methods made direct). mirror::Class* declaring_class = method->GetDeclaringClass(); @@ -1553,7 +1509,7 @@ const OatFile::OatMethod ClassLinker::GetOatMethodFor(const mirror::AbstractMeth } // Special case to get oat code without overwriting a trampoline. -const void* ClassLinker::GetOatCodeFor(const mirror::AbstractMethod* method) { +const void* ClassLinker::GetOatCodeFor(const mirror::ArtMethod* method) { CHECK(!method->IsAbstract()) << PrettyMethod(method); if (method->IsProxyMethod()) { #if !defined(ART_USE_PORTABLE_COMPILER) @@ -1580,7 +1536,7 @@ const void* ClassLinker::GetOatCodeFor(const DexFile& dex_file, uint32_t method_ } // Returns true if the method must run with interpreter, false otherwise. -static bool NeedsInterpreter(const mirror::AbstractMethod* method, const void* code) { +static bool NeedsInterpreter(const mirror::ArtMethod* method, const void* code) { if (code == NULL) { // No code: need interpreter. return true; @@ -1617,7 +1573,7 @@ void ClassLinker::FixupStaticTrampolines(mirror::Class* klass) { } // Link the code of methods skipped by LinkCode for (size_t method_index = 0; it.HasNextDirectMethod(); ++method_index, it.Next()) { - mirror::AbstractMethod* method = klass->GetDirectMethod(method_index); + mirror::ArtMethod* method = klass->GetDirectMethod(method_index); if (!method->IsStatic()) { // Only update static methods. continue; @@ -1633,7 +1589,7 @@ void ClassLinker::FixupStaticTrampolines(mirror::Class* klass) { // Ignore virtual methods on the iterator. } -static void LinkCode(SirtRef& method, const OatFile::OatClass* oat_class, +static void LinkCode(SirtRef& method, const OatFile::OatClass* oat_class, uint32_t method_index) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { // Method shouldn't have already been linked. @@ -1707,18 +1663,18 @@ void ClassLinker::LoadClass(const DexFile& dex_file, ClassDataItemIterator it(dex_file, class_data); Thread* self = Thread::Current(); if (it.NumStaticFields() != 0) { - klass->SetSFields(AllocFieldArray(self, it.NumStaticFields())); + klass->SetSFields(AllocArtFieldArray(self, it.NumStaticFields())); } if (it.NumInstanceFields() != 0) { - klass->SetIFields(AllocFieldArray(self, it.NumInstanceFields())); + klass->SetIFields(AllocArtFieldArray(self, it.NumInstanceFields())); } for (size_t i = 0; it.HasNextStaticField(); i++, it.Next()) { - SirtRef sfield(self, AllocField(self)); + SirtRef sfield(self, AllocArtField(self)); klass->SetStaticField(i, sfield.get()); LoadField(dex_file, it, klass, sfield); } for (size_t i = 0; it.HasNextInstanceField(); i++, it.Next()) { - SirtRef ifield(self, AllocField(self)); + SirtRef ifield(self, AllocArtField(self)); klass->SetInstanceField(i, ifield.get()); LoadField(dex_file, it, klass, ifield); } @@ -1731,15 +1687,15 @@ void ClassLinker::LoadClass(const DexFile& dex_file, // Load methods. if (it.NumDirectMethods() != 0) { // TODO: append direct methods to class object - klass->SetDirectMethods(AllocAbstractMethodArray(self, it.NumDirectMethods())); + klass->SetDirectMethods(AllocArtMethodArray(self, it.NumDirectMethods())); } if (it.NumVirtualMethods() != 0) { // TODO: append direct methods to class object - klass->SetVirtualMethods(AllocMethodArray(self, it.NumVirtualMethods())); + klass->SetVirtualMethods(AllocArtMethodArray(self, it.NumVirtualMethods())); } size_t class_def_method_index = 0; for (size_t i = 0; it.HasNextDirectMethod(); i++, it.Next()) { - SirtRef method(self, LoadMethod(self, dex_file, it, klass)); + SirtRef method(self, LoadMethod(self, dex_file, it, klass)); klass->SetDirectMethod(i, method.get()); if (oat_class.get() != NULL) { LinkCode(method, oat_class.get(), class_def_method_index); @@ -1748,7 +1704,7 @@ void ClassLinker::LoadClass(const DexFile& dex_file, class_def_method_index++; } for (size_t i = 0; it.HasNextVirtualMethod(); i++, it.Next()) { - SirtRef method(self, LoadMethod(self, dex_file, it, klass)); + SirtRef method(self, LoadMethod(self, dex_file, it, klass)); klass->SetVirtualMethod(i, method.get()); DCHECK_EQ(class_def_method_index, it.NumDirectMethods() + i); if (oat_class.get() != NULL) { @@ -1760,27 +1716,22 @@ void ClassLinker::LoadClass(const DexFile& dex_file, } void ClassLinker::LoadField(const DexFile& /*dex_file*/, const ClassDataItemIterator& it, - SirtRef& klass, SirtRef& dst) { + SirtRef& klass, SirtRef& dst) { uint32_t field_idx = it.GetMemberIndex(); dst->SetDexFieldIndex(field_idx); dst->SetDeclaringClass(klass.get()); dst->SetAccessFlags(it.GetMemberAccessFlags()); } -mirror::AbstractMethod* ClassLinker::LoadMethod(Thread* self, const DexFile& dex_file, +mirror::ArtMethod* ClassLinker::LoadMethod(Thread* self, const DexFile& dex_file, const ClassDataItemIterator& it, SirtRef& klass) { uint32_t dex_method_idx = it.GetMemberIndex(); const DexFile::MethodId& method_id = dex_file.GetMethodId(dex_method_idx); StringPiece method_name(dex_file.GetMethodName(method_id)); - mirror::AbstractMethod* dst = NULL; - if (method_name == "") { - dst = AllocConstructor(self); - } else { - dst = AllocMethod(self); - } - DCHECK(dst->IsMethod()) << PrettyDescriptor(dst->GetClass()); + mirror::ArtMethod* dst = AllocArtMethod(self); + DCHECK(dst->IsArtMethod()) << PrettyDescriptor(dst->GetClass()); const char* old_cause = self->StartAssertNoThreadSuspension("LoadMethod"); dst->SetDexMethodIndex(dex_method_idx); @@ -1824,7 +1775,7 @@ mirror::AbstractMethod* ClassLinker::LoadMethod(Thread* self, const DexFile& dex dst->SetDexCacheResolvedTypes(klass->GetDexCache()->GetResolvedTypes()); dst->SetDexCacheInitializedStaticStorage(klass->GetDexCache()->GetInitializedStaticStorage()); - CHECK(dst->IsMethod()); + CHECK(dst->IsArtMethod()); self->EndAssertNoThreadSuspension(old_cause); return dst; @@ -1918,7 +1869,7 @@ mirror::DexCache* ClassLinker::FindDexCache(const DexFile& dex_file) const { return NULL; } -void ClassLinker::FixupDexCaches(mirror::AbstractMethod* resolution_method) const { +void ClassLinker::FixupDexCaches(mirror::ArtMethod* resolution_method) const { ReaderMutexLock mu(Thread::Current(), dex_lock_); for (size_t i = 0; i != dex_caches_.size(); ++i) { dex_caches_[i]->Fixup(resolution_method); @@ -2007,12 +1958,10 @@ mirror::Class* ClassLinker::CreateArrayClass(const std::string& descriptor, new_class.reset(GetClassRoot(kObjectArrayClass)); } else if (descriptor == class_roots_descriptors_[kJavaLangStringArrayClass]) { new_class.reset(GetClassRoot(kJavaLangStringArrayClass)); - } else if (descriptor == class_roots_descriptors_[kJavaLangReflectAbstractMethodArrayClass]) { - new_class.reset(GetClassRoot(kJavaLangReflectAbstractMethodArrayClass)); - } else if (descriptor == class_roots_descriptors_[kJavaLangReflectFieldArrayClass]) { - new_class.reset(GetClassRoot(kJavaLangReflectFieldArrayClass)); - } else if (descriptor == class_roots_descriptors_[kJavaLangReflectMethodArrayClass]) { - new_class.reset(GetClassRoot(kJavaLangReflectMethodArrayClass)); + } else if (descriptor == class_roots_descriptors_[kJavaLangReflectArtMethodArrayClass]) { + new_class.reset(GetClassRoot(kJavaLangReflectArtMethodArrayClass)); + } else if (descriptor == class_roots_descriptors_[kJavaLangReflectArtFieldArrayClass]) { + new_class.reset(GetClassRoot(kJavaLangReflectArtFieldArrayClass)); } else if (descriptor == "[C") { new_class.reset(GetClassRoot(kCharArrayClass)); } else if (descriptor == "[I") { @@ -2428,7 +2377,7 @@ void ClassLinker::ResolveClassExceptionHandlerTypes(const DexFile& dex_file, mir } void ClassLinker::ResolveMethodExceptionHandlerTypes(const DexFile& dex_file, - mirror::AbstractMethod* method) { + mirror::ArtMethod* method) { // similar to DexVerifier::ScanTryCatchBlocks and dex2oat's ResolveExceptionsForMethod. const DexFile::CodeItem* code_item = dex_file.GetCodeItem(method->GetCodeItemOffset()); if (code_item == NULL) { @@ -2457,14 +2406,14 @@ void ClassLinker::ResolveMethodExceptionHandlerTypes(const DexFile& dex_file, } } -static void CheckProxyConstructor(mirror::AbstractMethod* constructor); -static void CheckProxyMethod(mirror::AbstractMethod* method, - SirtRef& prototype); +static void CheckProxyConstructor(mirror::ArtMethod* constructor); +static void CheckProxyMethod(mirror::ArtMethod* method, + SirtRef& prototype); mirror::Class* ClassLinker::CreateProxyClass(mirror::String* name, mirror::ObjectArray* interfaces, mirror::ClassLoader* loader, - mirror::ObjectArray* methods, + mirror::ObjectArray* methods, mirror::ObjectArray >* throws) { Thread* self = Thread::Current(); SirtRef klass(self, AllocClass(self, GetClassRoot(kJavaLangClass), @@ -2484,30 +2433,30 @@ mirror::Class* ClassLinker::CreateProxyClass(mirror::String* name, klass->SetDexTypeIndex(DexFile::kDexNoIndex16); // Instance fields are inherited, but we add a couple of static fields... - klass->SetSFields(AllocFieldArray(self, 2)); + klass->SetSFields(AllocArtFieldArray(self, 2)); // 1. Create a static field 'interfaces' that holds the _declared_ interfaces implemented by // our proxy, so Class.getInterfaces doesn't return the flattened set. - SirtRef interfaces_sfield(self, AllocField(self)); + SirtRef interfaces_sfield(self, AllocArtField(self)); klass->SetStaticField(0, interfaces_sfield.get()); interfaces_sfield->SetDexFieldIndex(0); interfaces_sfield->SetDeclaringClass(klass.get()); interfaces_sfield->SetAccessFlags(kAccStatic | kAccPublic | kAccFinal); // 2. Create a static field 'throws' that holds exceptions thrown by our methods. - SirtRef throws_sfield(self, AllocField(self)); + SirtRef throws_sfield(self, AllocArtField(self)); klass->SetStaticField(1, throws_sfield.get()); throws_sfield->SetDexFieldIndex(1); throws_sfield->SetDeclaringClass(klass.get()); throws_sfield->SetAccessFlags(kAccStatic | kAccPublic | kAccFinal); // Proxies have 1 direct method, the constructor - klass->SetDirectMethods(AllocAbstractMethodArray(self, 1)); + klass->SetDirectMethods(AllocArtMethodArray(self, 1)); klass->SetDirectMethod(0, CreateProxyConstructor(self, klass, proxy_class)); // Create virtual method using specified prototypes size_t num_virtual_methods = methods->GetLength(); - klass->SetVirtualMethods(AllocMethodArray(self, num_virtual_methods)); + klass->SetVirtualMethods(AllocArtMethodArray(self, num_virtual_methods)); for (size_t i = 0; i < num_virtual_methods; ++i) { - SirtRef prototype(self, methods->Get(i)); + SirtRef prototype(self, methods->Get(i)); klass->SetVirtualMethod(i, CreateProxyMethod(self, klass, prototype)); } @@ -2532,7 +2481,7 @@ mirror::Class* ClassLinker::CreateProxyClass(mirror::String* name, CHECK(klass->GetIFields() == NULL); CheckProxyConstructor(klass->GetDirectMethod(0)); for (size_t i = 0; i < num_virtual_methods; ++i) { - SirtRef prototype(self, methods->Get(i)); + SirtRef prototype(self, methods->Get(i)); CheckProxyMethod(klass->GetVirtualMethod(i), prototype); } @@ -2559,8 +2508,8 @@ std::string ClassLinker::GetDescriptorForProxy(const mirror::Class* proxy_class) return DotToDescriptor(name->ToModifiedUtf8().c_str()); } -mirror::AbstractMethod* ClassLinker::FindMethodForProxy(const mirror::Class* proxy_class, - const mirror::AbstractMethod* proxy_method) { +mirror::ArtMethod* ClassLinker::FindMethodForProxy(const mirror::Class* proxy_class, + const mirror::ArtMethod* proxy_method) { DCHECK(proxy_class->IsProxyClass()); DCHECK(proxy_method->IsProxyMethod()); // Locate the dex cache of the original interface/Object @@ -2577,31 +2526,31 @@ mirror::AbstractMethod* ClassLinker::FindMethodForProxy(const mirror::Class* pro } CHECK(dex_cache != NULL); uint32_t method_idx = proxy_method->GetDexMethodIndex(); - mirror::AbstractMethod* resolved_method = dex_cache->GetResolvedMethod(method_idx); + mirror::ArtMethod* resolved_method = dex_cache->GetResolvedMethod(method_idx); CHECK(resolved_method != NULL); return resolved_method; } -mirror::AbstractMethod* ClassLinker::CreateProxyConstructor(Thread* self, - SirtRef& klass, - mirror::Class* proxy_class) { +mirror::ArtMethod* ClassLinker::CreateProxyConstructor(Thread* self, + SirtRef& klass, + mirror::Class* proxy_class) { // Create constructor for Proxy that must initialize h - mirror::ObjectArray* proxy_direct_methods = + mirror::ObjectArray* proxy_direct_methods = proxy_class->GetDirectMethods(); - CHECK_EQ(proxy_direct_methods->GetLength(), 15); - mirror::AbstractMethod* proxy_constructor = proxy_direct_methods->Get(2); + CHECK_EQ(proxy_direct_methods->GetLength(), 16); + mirror::ArtMethod* proxy_constructor = proxy_direct_methods->Get(2); // Clone the existing constructor of Proxy (our constructor would just invoke it so steal its // code_ too) - mirror::AbstractMethod* constructor = - down_cast(proxy_constructor->Clone(self)); + mirror::ArtMethod* constructor = + down_cast(proxy_constructor->Clone(self)); // Make this constructor public and fix the class to be our Proxy version constructor->SetAccessFlags((constructor->GetAccessFlags() & ~kAccProtected) | kAccPublic); constructor->SetDeclaringClass(klass.get()); return constructor; } -static void CheckProxyConstructor(mirror::AbstractMethod* constructor) +static void CheckProxyConstructor(mirror::ArtMethod* constructor) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { CHECK(constructor->IsConstructor()); MethodHelper mh(constructor); @@ -2610,15 +2559,15 @@ static void CheckProxyConstructor(mirror::AbstractMethod* constructor) DCHECK(constructor->IsPublic()); } -mirror::AbstractMethod* ClassLinker::CreateProxyMethod(Thread* self, SirtRef& klass, - SirtRef& prototype) { +mirror::ArtMethod* ClassLinker::CreateProxyMethod(Thread* self, SirtRef& klass, + SirtRef& prototype) { // Ensure prototype is in dex cache so that we can use the dex cache to look up the overridden // prototype method prototype->GetDeclaringClass()->GetDexCache()->SetResolvedMethod(prototype->GetDexMethodIndex(), prototype.get()); // We steal everything from the prototype (such as DexCache, invoke stub, etc.) then specialize // as necessary - mirror::AbstractMethod* method = down_cast(prototype->Clone(self)); + mirror::ArtMethod* method = down_cast(prototype->Clone(self)); // Set class to be the concrete proxy class and clear the abstract flag, modify exceptions to // the intersection of throw exceptions as defined in Proxy @@ -2627,7 +2576,7 @@ mirror::AbstractMethod* ClassLinker::CreateProxyMethod(Thread* self, SirtRefGetCalleeSaveMethod(Runtime::kRefsAndArgs); method->SetCoreSpillMask(refs_and_args->GetCoreSpillMask()); method->SetFpSpillMask(refs_and_args->GetFpSpillMask()); @@ -2638,8 +2587,8 @@ mirror::AbstractMethod* ClassLinker::CreateProxyMethod(Thread* self, SirtRef& prototype) +static void CheckProxyMethod(mirror::ArtMethod* method, + SirtRef& prototype) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { // Basic sanity CHECK(!prototype->IsFinal()); @@ -2669,7 +2618,7 @@ bool ClassLinker::InitializeClass(mirror::Class* klass, bool can_run_clinit, boo Thread* self = Thread::Current(); - mirror::AbstractMethod* clinit = NULL; + mirror::ArtMethod* clinit = NULL; { // see JLS 3rd edition, 12.4.2 "Detailed Initialization Procedure" for the locking protocol ObjectLock lock(self, klass); @@ -2842,7 +2791,7 @@ bool ClassLinker::ValidateSuperClassDescriptors(const mirror::Class* klass) { klass->GetClassLoader() != klass->GetSuperClass()->GetClassLoader()) { const mirror::Class* super = klass->GetSuperClass(); for (int i = super->GetVTable()->GetLength() - 1; i >= 0; --i) { - const mirror::AbstractMethod* method = klass->GetVTable()->Get(i); + const mirror::ArtMethod* method = klass->GetVTable()->Get(i); if (method != super->GetVTable()->Get(i) && !IsSameMethodSignatureInDifferentClassContexts(method, super, klass)) { ThrowLinkageError(klass, "Class %s method %s resolves differently in superclass %s", @@ -2857,7 +2806,7 @@ bool ClassLinker::ValidateSuperClassDescriptors(const mirror::Class* klass) { mirror::Class* interface = iftable->GetInterface(i); if (klass->GetClassLoader() != interface->GetClassLoader()) { for (size_t j = 0; j < interface->NumVirtualMethods(); ++j) { - const mirror::AbstractMethod* method = iftable->GetMethodArray(i)->Get(j); + const mirror::ArtMethod* method = iftable->GetMethodArray(i)->Get(j); if (!IsSameMethodSignatureInDifferentClassContexts(method, interface, method->GetDeclaringClass())) { ThrowLinkageError(klass, "Class %s method %s resolves differently in interface %s", @@ -2874,7 +2823,7 @@ bool ClassLinker::ValidateSuperClassDescriptors(const mirror::Class* klass) { // Returns true if classes referenced by the signature of the method are the // same classes in klass1 as they are in klass2. -bool ClassLinker::IsSameMethodSignatureInDifferentClassContexts(const mirror::AbstractMethod* method, +bool ClassLinker::IsSameMethodSignatureInDifferentClassContexts(const mirror::ArtMethod* method, const mirror::Class* klass1, const mirror::Class* klass2) { if (klass1 == klass2) { @@ -2969,7 +2918,7 @@ bool ClassLinker::EnsureInitialized(mirror::Class* c, bool can_run_clinit, bool } void ClassLinker::ConstructFieldMap(const DexFile& dex_file, const DexFile::ClassDef& dex_class_def, - mirror::Class* c, SafeMap& field_map) { + mirror::Class* c, SafeMap& field_map) { mirror::ClassLoader* cl = c->GetClassLoader(); const byte* class_data = dex_file.GetClassData(dex_class_def); ClassDataItemIterator it(dex_file, class_data); @@ -2997,7 +2946,7 @@ bool ClassLinker::InitializeStaticFields(mirror::Class* klass) { if (it.HasNext()) { // We reordered the fields, so we need to be able to map the field indexes to the right fields. - SafeMap field_map; + SafeMap field_map; ConstructFieldMap(dex_file, *dex_class_def, klass, field_map); for (size_t i = 0; it.HasNext(); i++, it.Next()) { it.ReadValueToField(field_map.Get(i)); @@ -3161,17 +3110,17 @@ bool ClassLinker::LinkVirtualMethods(SirtRef& klass) { size_t actual_count = klass->GetSuperClass()->GetVTable()->GetLength(); CHECK_LE(actual_count, max_count); // TODO: do not assign to the vtable field until it is fully constructed. - SirtRef > + SirtRef > vtable(self, klass->GetSuperClass()->GetVTable()->CopyOf(self, max_count)); // See if any of our virtual methods override the superclass. MethodHelper local_mh(NULL, this); MethodHelper super_mh(NULL, this); for (size_t i = 0; i < klass->NumVirtualMethods(); ++i) { - mirror::AbstractMethod* local_method = klass->GetVirtualMethodDuringLinking(i); + mirror::ArtMethod* local_method = klass->GetVirtualMethodDuringLinking(i); local_mh.ChangeMethod(local_method); size_t j = 0; for (; j < actual_count; ++j) { - mirror::AbstractMethod* super_method = vtable->Get(j); + mirror::ArtMethod* super_method = vtable->Get(j); super_mh.ChangeMethod(super_method); if (local_mh.HasSameNameAndSignature(&super_mh)) { if (klass->CanAccessMember(super_method->GetDeclaringClass(), super_method->GetAccessFlags())) { @@ -3215,10 +3164,10 @@ bool ClassLinker::LinkVirtualMethods(SirtRef& klass) { ThrowClassFormatError(klass.get(), "Too many methods: %d", num_virtual_methods); return false; } - SirtRef > - vtable(self, AllocMethodArray(self, num_virtual_methods)); + SirtRef > + vtable(self, AllocArtMethodArray(self, num_virtual_methods)); for (size_t i = 0; i < num_virtual_methods; ++i) { - mirror::AbstractMethod* virtual_method = klass->GetVirtualMethodDuringLinking(i); + mirror::ArtMethod* virtual_method = klass->GetVirtualMethodDuringLinking(i); vtable->Set(i, virtual_method); virtual_method->SetMethodIndex(i & 0xFFFF); } @@ -3328,19 +3277,19 @@ bool ClassLinker::LinkInterfaceMethods(SirtRef& klass, if (klass->IsInterface()) { return true; } - std::vector miranda_list; + std::vector miranda_list; MethodHelper vtable_mh(NULL, this); MethodHelper interface_mh(NULL, this); for (size_t i = 0; i < ifcount; ++i) { mirror::Class* interface = iftable->GetInterface(i); size_t num_methods = interface->NumVirtualMethods(); if (num_methods > 0) { - mirror::ObjectArray* method_array = - AllocMethodArray(self, num_methods); + mirror::ObjectArray* method_array = + AllocArtMethodArray(self, num_methods); iftable->SetMethodArray(i, method_array); - mirror::ObjectArray* vtable = klass->GetVTableDuringLinking(); + mirror::ObjectArray* vtable = klass->GetVTableDuringLinking(); for (size_t j = 0; j < num_methods; ++j) { - mirror::AbstractMethod* interface_method = interface->GetVirtualMethod(j); + mirror::ArtMethod* interface_method = interface->GetVirtualMethod(j); interface_mh.ChangeMethod(interface_method); int32_t k; // For each method listed in the interface's method list, find the @@ -3352,7 +3301,7 @@ bool ClassLinker::LinkInterfaceMethods(SirtRef& klass, // those don't end up in the virtual method table, so it shouldn't // matter which direction we go. We walk it backward anyway.) for (k = vtable->GetLength() - 1; k >= 0; --k) { - mirror::AbstractMethod* vtable_method = vtable->Get(k); + mirror::ArtMethod* vtable_method = vtable->Get(k); vtable_mh.ChangeMethod(vtable_method); if (interface_mh.HasSameNameAndSignature(&vtable_mh)) { if (!vtable_method->IsAbstract() && !vtable_method->IsPublic()) { @@ -3367,9 +3316,9 @@ bool ClassLinker::LinkInterfaceMethods(SirtRef& klass, } } if (k < 0) { - SirtRef miranda_method(self, NULL); + SirtRef miranda_method(self, NULL); for (size_t mir = 0; mir < miranda_list.size(); mir++) { - mirror::AbstractMethod* mir_method = miranda_list[mir]; + mirror::ArtMethod* mir_method = miranda_list[mir]; vtable_mh.ChangeMethod(mir_method); if (interface_mh.HasSameNameAndSignature(&vtable_mh)) { miranda_method.reset(miranda_list[mir]); @@ -3378,7 +3327,7 @@ bool ClassLinker::LinkInterfaceMethods(SirtRef& klass, } if (miranda_method.get() == NULL) { // point the interface table at a phantom slot - miranda_method.reset(down_cast(interface_method->Clone(self))); + miranda_method.reset(down_cast(interface_method->Clone(self))); miranda_list.push_back(miranda_method.get()); } method_array->Set(j, miranda_method.get()); @@ -3390,17 +3339,17 @@ bool ClassLinker::LinkInterfaceMethods(SirtRef& klass, int old_method_count = klass->NumVirtualMethods(); int new_method_count = old_method_count + miranda_list.size(); klass->SetVirtualMethods((old_method_count == 0) - ? AllocMethodArray(self, new_method_count) + ? AllocArtMethodArray(self, new_method_count) : klass->GetVirtualMethods()->CopyOf(self, new_method_count)); - SirtRef > + SirtRef > vtable(self, klass->GetVTableDuringLinking()); CHECK(vtable.get() != NULL); int old_vtable_count = vtable->GetLength(); int new_vtable_count = old_vtable_count + miranda_list.size(); vtable.reset(vtable->CopyOf(self, new_vtable_count)); for (size_t i = 0; i < miranda_list.size(); ++i) { - mirror::AbstractMethod* method = miranda_list[i]; + mirror::ArtMethod* method = miranda_list[i]; // Leave the declaring class alone as type indices are relative to it method->SetAccessFlags(method->GetAccessFlags() | kAccMiranda); method->SetMethodIndex(0xFFFF & (old_vtable_count + i)); @@ -3411,7 +3360,7 @@ bool ClassLinker::LinkInterfaceMethods(SirtRef& klass, klass->SetVTable(vtable.get()); } - mirror::ObjectArray* vtable = klass->GetVTableDuringLinking(); + mirror::ObjectArray* vtable = klass->GetVTableDuringLinking(); for (int i = 0; i < vtable->GetLength(); ++i) { CHECK(vtable->Get(i) != NULL); } @@ -3439,7 +3388,7 @@ struct LinkFieldsComparator { SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) : fh_(fh) {} // No thread safety analysis as will be called from STL. Checked lock held in constructor. - bool operator()(const mirror::Field* field1, const mirror::Field* field2) + bool operator()(const mirror::ArtField* field1, const mirror::ArtField* field2) NO_THREAD_SAFETY_ANALYSIS { // First come reference fields, then 64-bit, and finally 32-bit fh_->ChangeField(field1); @@ -3471,7 +3420,7 @@ bool ClassLinker::LinkFields(SirtRef& klass, bool is_static) { size_t num_fields = is_static ? klass->NumStaticFields() : klass->NumInstanceFields(); - mirror::ObjectArray* fields = + mirror::ObjectArray* fields = is_static ? klass->GetSFields() : klass->GetIFields(); // Initialize size and field_offset @@ -3493,7 +3442,7 @@ bool ClassLinker::LinkFields(SirtRef& klass, bool is_static) { // we want a relatively stable order so that adding new fields // minimizes disruption of C++ version such as Class and Method. - std::deque grouped_and_sorted_fields; + std::deque grouped_and_sorted_fields; for (size_t i = 0; i < num_fields; i++) { grouped_and_sorted_fields.push_back(fields->Get(i)); } @@ -3506,7 +3455,7 @@ bool ClassLinker::LinkFields(SirtRef& klass, bool is_static) { size_t current_field = 0; size_t num_reference_fields = 0; for (; current_field < num_fields; current_field++) { - mirror::Field* field = grouped_and_sorted_fields.front(); + mirror::ArtField* field = grouped_and_sorted_fields.front(); fh.ChangeField(field); Primitive::Type type = fh.GetTypeAsPrimitiveType(); bool isPrimitive = type != Primitive::kPrimNot; @@ -3525,7 +3474,7 @@ bool ClassLinker::LinkFields(SirtRef& klass, bool is_static) { // into place. If we can't find one, we'll have to pad it. if (current_field != num_fields && !IsAligned<8>(field_offset.Uint32Value())) { for (size_t i = 0; i < grouped_and_sorted_fields.size(); i++) { - mirror::Field* field = grouped_and_sorted_fields[i]; + mirror::ArtField* field = grouped_and_sorted_fields[i]; fh.ChangeField(field); Primitive::Type type = fh.GetTypeAsPrimitiveType(); CHECK(type != Primitive::kPrimNot); // should only be working on primitive types @@ -3546,7 +3495,7 @@ bool ClassLinker::LinkFields(SirtRef& klass, bool is_static) { // finish assigning field offsets to all fields. DCHECK(current_field == num_fields || IsAligned<8>(field_offset.Uint32Value())); while (!grouped_and_sorted_fields.empty()) { - mirror::Field* field = grouped_and_sorted_fields.front(); + mirror::ArtField* field = grouped_and_sorted_fields.front(); grouped_and_sorted_fields.pop_front(); fh.ChangeField(field); Primitive::Type type = fh.GetTypeAsPrimitiveType(); @@ -3576,12 +3525,12 @@ bool ClassLinker::LinkFields(SirtRef& klass, bool is_static) { // non-reference fields, and all double-wide fields are aligned. bool seen_non_ref = false; for (size_t i = 0; i < num_fields; i++) { - mirror::Field* field = fields->Get(i); + mirror::ArtField* field = fields->Get(i); if (false) { // enable to debug field layout LOG(INFO) << "LinkFields: " << (is_static ? "static" : "instance") << " class=" << PrettyClass(klass.get()) << " field=" << PrettyField(field) - << " offset=" << field->GetField32(MemberOffset(mirror::Field::OffsetOffset()), + << " offset=" << field->GetField32(MemberOffset(mirror::ArtField::OffsetOffset()), false); } fh.ChangeField(field); @@ -3644,14 +3593,14 @@ void ClassLinker::CreateReferenceOffsets(SirtRef& klass, bool is_ size_t num_reference_fields = is_static ? klass->NumReferenceStaticFieldsDuringLinking() : klass->NumReferenceInstanceFieldsDuringLinking(); - const mirror::ObjectArray* fields = + const mirror::ObjectArray* fields = is_static ? klass->GetSFields() : klass->GetIFields(); // All of the fields that contain object references are guaranteed // to be at the beginning of the fields list. for (size_t i = 0; i < num_reference_fields; ++i) { // Note that byte_offset is the offset from the beginning of // object, not the offset into instance data - const mirror::Field* field = fields->Get(i); + const mirror::ArtField* field = fields->Get(i); MemberOffset byte_offset = field->GetOffsetDuringLinking(); CHECK_EQ(byte_offset.Uint32Value() & (CLASS_OFFSET_ALIGNMENT - 1), 0U); if (CLASS_CAN_ENCODE_OFFSET(byte_offset.Uint32Value())) { @@ -3716,15 +3665,15 @@ mirror::Class* ClassLinker::ResolveType(const DexFile& dex_file, return resolved; } -mirror::AbstractMethod* ClassLinker::ResolveMethod(const DexFile& dex_file, +mirror::ArtMethod* ClassLinker::ResolveMethod(const DexFile& dex_file, uint32_t method_idx, mirror::DexCache* dex_cache, mirror::ClassLoader* class_loader, - const mirror::AbstractMethod* referrer, + const mirror::ArtMethod* referrer, InvokeType type) { DCHECK(dex_cache != NULL); // Check for hit in the dex cache. - mirror::AbstractMethod* resolved = dex_cache->GetResolvedMethod(method_idx); + mirror::ArtMethod* resolved = dex_cache->GetResolvedMethod(method_idx); if (resolved != NULL) { return resolved; } @@ -3863,13 +3812,13 @@ mirror::AbstractMethod* ClassLinker::ResolveMethod(const DexFile& dex_file, } } -mirror::Field* ClassLinker::ResolveField(const DexFile& dex_file, +mirror::ArtField* ClassLinker::ResolveField(const DexFile& dex_file, uint32_t field_idx, mirror::DexCache* dex_cache, mirror::ClassLoader* class_loader, bool is_static) { DCHECK(dex_cache != NULL); - mirror::Field* resolved = dex_cache->GetResolvedField(field_idx); + mirror::ArtField* resolved = dex_cache->GetResolvedField(field_idx); if (resolved != NULL) { return resolved; } @@ -3903,12 +3852,12 @@ mirror::Field* ClassLinker::ResolveField(const DexFile& dex_file, return resolved; } -mirror::Field* ClassLinker::ResolveFieldJLS(const DexFile& dex_file, +mirror::ArtField* ClassLinker::ResolveFieldJLS(const DexFile& dex_file, uint32_t field_idx, mirror::DexCache* dex_cache, mirror::ClassLoader* class_loader) { DCHECK(dex_cache != NULL); - mirror::Field* resolved = dex_cache->GetResolvedField(field_idx); + mirror::ArtField* resolved = dex_cache->GetResolvedField(field_idx); if (resolved != NULL) { return resolved; } @@ -3930,7 +3879,7 @@ mirror::Field* ClassLinker::ResolveFieldJLS(const DexFile& dex_file, return resolved; } -const char* ClassLinker::MethodShorty(uint32_t method_idx, mirror::AbstractMethod* referrer, +const char* ClassLinker::MethodShorty(uint32_t method_idx, mirror::ArtMethod* referrer, uint32_t* length) { mirror::Class* declaring_class = referrer->GetDeclaringClass(); mirror::DexCache* dex_cache = declaring_class->GetDexCache(); diff --git a/runtime/class_linker.h b/runtime/class_linker.h index 67be2ff028..d0cc562ca5 100644 --- a/runtime/class_linker.h +++ b/runtime/class_linker.h @@ -106,7 +106,7 @@ class ClassLinker { // Resolve a String with the given index from the DexFile, storing the // result in the DexCache. The referrer is used to identify the // target DexCache and ClassLoader to use for resolution. - mirror::String* ResolveString(uint32_t string_idx, const mirror::AbstractMethod* referrer) + mirror::String* ResolveString(uint32_t string_idx, const mirror::ArtMethod* referrer) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Resolve a String with the given index from the DexFile, storing the @@ -130,10 +130,10 @@ class ClassLinker { // Resolve a Type with the given index from the DexFile, storing the // result in the DexCache. The referrer is used to identify the // target DexCache and ClassLoader to use for resolution. - mirror::Class* ResolveType(uint16_t type_idx, const mirror::AbstractMethod* referrer) + mirror::Class* ResolveType(uint16_t type_idx, const mirror::ArtMethod* referrer) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::Class* ResolveType(uint16_t type_idx, const mirror::Field* referrer) + mirror::Class* ResolveType(uint16_t type_idx, const mirror::ArtField* referrer) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Resolve a type with the given ID from the DexFile, storing the @@ -151,20 +151,20 @@ class ClassLinker { // in ResolveType. What is unique is the method type argument which // is used to determine if this method is a direct, static, or // virtual method. - mirror::AbstractMethod* ResolveMethod(const DexFile& dex_file, - uint32_t method_idx, - mirror::DexCache* dex_cache, - mirror::ClassLoader* class_loader, - const mirror::AbstractMethod* referrer, - InvokeType type) + mirror::ArtMethod* ResolveMethod(const DexFile& dex_file, + uint32_t method_idx, + mirror::DexCache* dex_cache, + mirror::ClassLoader* class_loader, + const mirror::ArtMethod* referrer, + InvokeType type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::AbstractMethod* ResolveMethod(uint32_t method_idx, const mirror::AbstractMethod* referrer, - InvokeType type) + mirror::ArtMethod* ResolveMethod(uint32_t method_idx, const mirror::ArtMethod* referrer, + InvokeType type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::Field* ResolveField(uint32_t field_idx, const mirror::AbstractMethod* referrer, - bool is_static) + mirror::ArtField* ResolveField(uint32_t field_idx, const mirror::ArtMethod* referrer, + bool is_static) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Resolve a field with a given ID from the DexFile, storing the @@ -172,25 +172,25 @@ class ClassLinker { // in ResolveType. What is unique is the is_static argument which is // used to determine if we are resolving a static or non-static // field. - mirror::Field* ResolveField(const DexFile& dex_file, - uint32_t field_idx, - mirror::DexCache* dex_cache, - mirror::ClassLoader* class_loader, - bool is_static) + mirror::ArtField* ResolveField(const DexFile& dex_file, + uint32_t field_idx, + mirror::DexCache* dex_cache, + mirror::ClassLoader* class_loader, + bool is_static) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Resolve a field with a given ID from the DexFile, storing the // result in DexCache. The ClassLinker and ClassLoader are used as // in ResolveType. No is_static argument is provided so that Java // field resolution semantics are followed. - mirror::Field* ResolveFieldJLS(const DexFile& dex_file, - uint32_t field_idx, - mirror::DexCache* dex_cache, - mirror::ClassLoader* class_loader) + mirror::ArtField* ResolveFieldJLS(const DexFile& dex_file, + uint32_t field_idx, + mirror::DexCache* dex_cache, + mirror::ClassLoader* class_loader) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Get shorty from method index without resolution. Used to do handlerization. - const char* MethodShorty(uint32_t method_idx, mirror::AbstractMethod* referrer, uint32_t* length) + const char* MethodShorty(uint32_t method_idx, mirror::ArtMethod* referrer, uint32_t* length) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Returns true on success, false if there's an exception pending. @@ -232,7 +232,7 @@ class ClassLinker { SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); bool IsDexFileRegistered(const DexFile& dex_file) const LOCKS_EXCLUDED(dex_lock_); - void FixupDexCaches(mirror::AbstractMethod* resolution_method) const + void FixupDexCaches(mirror::ArtMethod* resolution_method) const LOCKS_EXCLUDED(dex_lock_) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); @@ -283,16 +283,13 @@ class ClassLinker { mirror::ObjectArray* AllocStringArray(Thread* self, size_t length) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::ObjectArray* AllocAbstractMethodArray(Thread* self, size_t length) - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - - mirror::ObjectArray* AllocMethodArray(Thread* self, size_t length) + mirror::ObjectArray* AllocArtMethodArray(Thread* self, size_t length) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); mirror::IfTable* AllocIfTable(Thread* self, size_t ifcount) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::ObjectArray* AllocFieldArray(Thread* self, size_t length) + mirror::ObjectArray* AllocArtFieldArray(Thread* self, size_t length) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); mirror::ObjectArray* AllocStackTraceElementArray(Thread* self, @@ -305,23 +302,23 @@ class ClassLinker { SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void ResolveClassExceptionHandlerTypes(const DexFile& dex_file, mirror::Class* klass) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void ResolveMethodExceptionHandlerTypes(const DexFile& dex_file, mirror::AbstractMethod* klass) + void ResolveMethodExceptionHandlerTypes(const DexFile& dex_file, mirror::ArtMethod* klass) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); mirror::Class* CreateProxyClass(mirror::String* name, mirror::ObjectArray* interfaces, mirror::ClassLoader* loader, - mirror::ObjectArray* methods, + mirror::ObjectArray* methods, mirror::ObjectArray >* throws) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); std::string GetDescriptorForProxy(const mirror::Class* proxy_class) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::AbstractMethod* FindMethodForProxy(const mirror::Class* proxy_class, - const mirror::AbstractMethod* proxy_method) + mirror::ArtMethod* FindMethodForProxy(const mirror::Class* proxy_class, + const mirror::ArtMethod* proxy_method) LOCKS_EXCLUDED(dex_lock_) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Get the oat code for a method when its class isn't yet initialized - const void* GetOatCodeFor(const mirror::AbstractMethod* method) + const void* GetOatCodeFor(const mirror::ArtMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Get the oat code for a method from a method index. @@ -361,7 +358,7 @@ class ClassLinker { private: explicit ClassLinker(InternTable*); - const OatFile::OatMethod GetOatMethodFor(const mirror::AbstractMethod* method) + const OatFile::OatMethod GetOatMethodFor(const mirror::ArtMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Initialize class linker by bootstraping from dex files @@ -386,9 +383,8 @@ class ClassLinker { mirror::Class* AllocClass(Thread* self, size_t class_size) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); mirror::DexCache* AllocDexCache(Thread* self, const DexFile& dex_file) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::Field* AllocField(Thread* self) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::Method* AllocMethod(Thread* self) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::Constructor* AllocConstructor(Thread* self) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + mirror::ArtField* AllocArtField(Thread* self) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + mirror::ArtMethod* AllocArtMethod(Thread* self) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); mirror::Class* CreatePrimitiveClass(Thread* self, Primitive::Type type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); @@ -405,7 +401,7 @@ class ClassLinker { SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void ConstructFieldMap(const DexFile& dex_file, const DexFile::ClassDef& dex_class_def, - mirror::Class* c, SafeMap& field_map) + mirror::Class* c, SafeMap& field_map) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); size_t SizeOfClass(const DexFile& dex_file, @@ -418,12 +414,12 @@ class ClassLinker { SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void LoadField(const DexFile& dex_file, const ClassDataItemIterator& it, - SirtRef& klass, SirtRef& dst) + SirtRef& klass, SirtRef& dst) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::AbstractMethod* LoadMethod(Thread* self, const DexFile& dex_file, - const ClassDataItemIterator& dex_method, - SirtRef& klass) + mirror::ArtMethod* LoadMethod(Thread* self, const DexFile& dex_file, + const ClassDataItemIterator& dex_method, + SirtRef& klass) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void FixupStaticTrampolines(mirror::Class* klass) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); @@ -455,7 +451,7 @@ class ClassLinker { const mirror::Class* klass2) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - bool IsSameMethodSignatureInDifferentClassContexts(const mirror::AbstractMethod* method, + bool IsSameMethodSignatureInDifferentClassContexts(const mirror::ArtMethod* method, const mirror::Class* klass1, const mirror::Class* klass2) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); @@ -519,11 +515,11 @@ class ClassLinker { EXCLUSIVE_LOCKS_REQUIRED(dex_lock_) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::AbstractMethod* CreateProxyConstructor(Thread* self, SirtRef& klass, - mirror::Class* proxy_class) + mirror::ArtMethod* CreateProxyConstructor(Thread* self, SirtRef& klass, + mirror::Class* proxy_class) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::AbstractMethod* CreateProxyMethod(Thread* self, SirtRef& klass, - SirtRef& prototype) + mirror::ArtMethod* CreateProxyMethod(Thread* self, SirtRef& klass, + SirtRef& prototype) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); std::vector boot_class_path_; @@ -554,15 +550,12 @@ class ClassLinker { kJavaLangString, kJavaLangDexCache, kJavaLangRefReference, - kJavaLangReflectConstructor, - kJavaLangReflectField, - kJavaLangReflectAbstractMethod, - kJavaLangReflectMethod, + kJavaLangReflectArtField, + kJavaLangReflectArtMethod, kJavaLangReflectProxy, kJavaLangStringArrayClass, - kJavaLangReflectAbstractMethodArrayClass, - kJavaLangReflectFieldArrayClass, - kJavaLangReflectMethodArrayClass, + kJavaLangReflectArtFieldArrayClass, + kJavaLangReflectArtMethodArrayClass, kJavaLangClassLoader, kJavaLangThrowable, kJavaLangClassNotFoundException, diff --git a/runtime/class_linker_test.cc b/runtime/class_linker_test.cc index 4659fd1982..6442f5ad63 100644 --- a/runtime/class_linker_test.cc +++ b/runtime/class_linker_test.cc @@ -24,42 +24,17 @@ #include "dex_file.h" #include "entrypoints/entrypoint_utils.h" #include "gc/heap.h" +#include "mirror/art_field-inl.h" +#include "mirror/art_method.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/dex_cache.h" -#include "mirror/field-inl.h" -#include "mirror/abstract_method.h" -#include "mirror/abstract_method-inl.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" #include "mirror/proxy.h" #include "mirror/stack_trace_element.h" #include "sirt_ref.h" -using ::art::mirror::AbstractMethod; -using ::art::mirror::AbstractMethodClass; -using ::art::mirror::CharArray; -using ::art::mirror::Class; -using ::art::mirror::ClassClass; -using ::art::mirror::ClassLoader; -using ::art::mirror::Constructor; -using ::art::mirror::DexCache; -using ::art::mirror::DoubleArray; -using ::art::mirror::Field; -using ::art::mirror::FieldClass; -using ::art::mirror::IfTable; -using ::art::mirror::IntArray; -using ::art::mirror::LongArray; -using ::art::mirror::Method; -using ::art::mirror::Object; -using ::art::mirror::ObjectArray; -using ::art::mirror::Proxy; -using ::art::mirror::ShortArray; -using ::art::mirror::StackTraceElement; -using ::art::mirror::StaticStorageBase; -using ::art::mirror::String; -using ::art::mirror::StringClass; -using ::art::mirror::Throwable; - namespace art { class ClassLinkerTest : public CommonTest { @@ -69,9 +44,9 @@ class ClassLinkerTest : public CommonTest { EXPECT_TRUE(class_linker_->FindSystemClass(descriptor.c_str()) == NULL); Thread* self = Thread::Current(); EXPECT_TRUE(self->IsExceptionPending()); - Object* exception = self->GetException(NULL); + mirror::Object* exception = self->GetException(NULL); self->ClearException(); - Class* exception_class = class_linker_->FindSystemClass("Ljava/lang/NoClassDefFoundError;"); + mirror::Class* exception_class = class_linker_->FindSystemClass("Ljava/lang/NoClassDefFoundError;"); EXPECT_TRUE(exception->InstanceOf(exception_class)); } @@ -80,7 +55,7 @@ class ClassLinkerTest : public CommonTest { AssertPrimitiveClass(descriptor, class_linker_->FindSystemClass(descriptor.c_str())); } - void AssertPrimitiveClass(const std::string& descriptor, const Class* primitive) + void AssertPrimitiveClass(const std::string& descriptor, const mirror::Class* primitive) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { ClassHelper primitive_ch(primitive); ASSERT_TRUE(primitive != NULL); @@ -91,7 +66,7 @@ class ClassLinkerTest : public CommonTest { EXPECT_TRUE(primitive->GetSuperClass() == NULL); EXPECT_FALSE(primitive->HasSuperClass()); EXPECT_TRUE(primitive->GetClassLoader() == NULL); - EXPECT_EQ(Class::kStatusInitialized, primitive->GetStatus()); + EXPECT_EQ(mirror::Class::kStatusInitialized, primitive->GetStatus()); EXPECT_FALSE(primitive->IsErroneous()); EXPECT_TRUE(primitive->IsLoaded()); EXPECT_TRUE(primitive->IsResolved()); @@ -118,9 +93,9 @@ class ClassLinkerTest : public CommonTest { void AssertArrayClass(const std::string& array_descriptor, const std::string& component_type, - ClassLoader* class_loader) + mirror::ClassLoader* class_loader) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - Class* array = class_linker_->FindClass(array_descriptor.c_str(), class_loader); + mirror::Class* array = class_linker_->FindClass(array_descriptor.c_str(), class_loader); ClassHelper array_component_ch(array->GetComponentType()); EXPECT_STREQ(component_type.c_str(), array_component_ch.GetDescriptor()); EXPECT_EQ(class_loader, array->GetClassLoader()); @@ -128,7 +103,7 @@ class ClassLinkerTest : public CommonTest { AssertArrayClass(array_descriptor, array); } - void AssertArrayClass(const std::string& array_descriptor, Class* array) + void AssertArrayClass(const std::string& array_descriptor, mirror::Class* array) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { ClassHelper kh(array); ASSERT_TRUE(array != NULL); @@ -142,7 +117,7 @@ class ClassLinkerTest : public CommonTest { ASSERT_TRUE(array->GetComponentType() != NULL); kh.ChangeClass(array->GetComponentType()); ASSERT_TRUE(kh.GetDescriptor() != NULL); - EXPECT_EQ(Class::kStatusInitialized, array->GetStatus()); + EXPECT_EQ(mirror::Class::kStatusInitialized, array->GetStatus()); EXPECT_FALSE(array->IsErroneous()); EXPECT_TRUE(array->IsLoaded()); EXPECT_TRUE(array->IsResolved()); @@ -163,7 +138,7 @@ class ClassLinkerTest : public CommonTest { EXPECT_EQ(2U, kh.NumDirectInterfaces()); EXPECT_TRUE(array->GetVTable() != NULL); EXPECT_EQ(2, array->GetIfTableCount()); - IfTable* iftable = array->GetIfTable(); + mirror::IfTable* iftable = array->GetIfTable(); ASSERT_TRUE(iftable != NULL); kh.ChangeClass(kh.GetDirectInterface(0)); EXPECT_STREQ(kh.GetDescriptor(), "Ljava/lang/Cloneable;"); @@ -172,7 +147,7 @@ class ClassLinkerTest : public CommonTest { EXPECT_STREQ(kh.GetDescriptor(), "Ljava/io/Serializable;"); } - void AssertMethod(AbstractMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + void AssertMethod(mirror::ArtMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { MethodHelper mh(method); EXPECT_TRUE(method != NULL); EXPECT_TRUE(method->GetClass() != NULL); @@ -193,7 +168,7 @@ class ClassLinkerTest : public CommonTest { method->GetDexCacheInitializedStaticStorage()); } - void AssertField(Class* klass, Field* field) + void AssertField(mirror::Class* klass, mirror::ArtField* field) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { FieldHelper fh(field); EXPECT_TRUE(field != NULL); @@ -203,7 +178,7 @@ class ClassLinkerTest : public CommonTest { EXPECT_TRUE(fh.GetType() != NULL); } - void AssertClass(const std::string& descriptor, Class* klass) + void AssertClass(const std::string& descriptor, mirror::Class* klass) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { ClassHelper kh(klass); EXPECT_STREQ(descriptor.c_str(), kh.GetDescriptor()); @@ -222,7 +197,7 @@ class ClassLinkerTest : public CommonTest { EXPECT_FALSE(klass->IsArrayClass()); EXPECT_TRUE(klass->GetComponentType() == NULL); EXPECT_TRUE(klass->IsInSamePackage(klass)); - EXPECT_TRUE(Class::IsInSamePackage(kh.GetDescriptor(), kh.GetDescriptor())); + EXPECT_TRUE(mirror::Class::IsInSamePackage(kh.GetDescriptor(), kh.GetDescriptor())); if (klass->IsInterface()) { EXPECT_TRUE(klass->IsAbstract()); if (klass->NumDirectMethods() == 1) { @@ -238,9 +213,9 @@ class ClassLinkerTest : public CommonTest { } } EXPECT_EQ(klass->IsInterface(), klass->GetVTable() == NULL); - const IfTable* iftable = klass->GetIfTable(); + const mirror::IfTable* iftable = klass->GetIfTable(); for (int i = 0; i < klass->GetIfTableCount(); i++) { - Class* interface = iftable->GetInterface(i); + mirror::Class* interface = iftable->GetInterface(i); ASSERT_TRUE(interface != NULL); if (klass->IsInterface()) { EXPECT_EQ(0U, iftable->GetMethodArrayCount(i)); @@ -266,27 +241,27 @@ class ClassLinkerTest : public CommonTest { EXPECT_TRUE(klass->CanAccess(klass)); for (size_t i = 0; i < klass->NumDirectMethods(); i++) { - AbstractMethod* method = klass->GetDirectMethod(i); + mirror::ArtMethod* method = klass->GetDirectMethod(i); AssertMethod(method); EXPECT_TRUE(method->IsDirect()); EXPECT_EQ(klass, method->GetDeclaringClass()); } for (size_t i = 0; i < klass->NumVirtualMethods(); i++) { - AbstractMethod* method = klass->GetVirtualMethod(i); + mirror::ArtMethod* method = klass->GetVirtualMethod(i); AssertMethod(method); EXPECT_FALSE(method->IsDirect()); EXPECT_TRUE(method->GetDeclaringClass()->IsAssignableFrom(klass)); } for (size_t i = 0; i < klass->NumInstanceFields(); i++) { - Field* field = klass->GetInstanceField(i); + mirror::ArtField* field = klass->GetInstanceField(i); AssertField(klass, field); EXPECT_FALSE(field->IsStatic()); } for (size_t i = 0; i < klass->NumStaticFields(); i++) { - Field* field = klass->GetStaticField(i); + mirror::ArtField* field = klass->GetStaticField(i); AssertField(klass, field); EXPECT_TRUE(field->IsStatic()); } @@ -295,17 +270,17 @@ class ClassLinkerTest : public CommonTest { EXPECT_GE(klass->NumInstanceFields(), klass->NumReferenceInstanceFields()); FieldHelper fh; for (size_t i = 0; i < klass->NumReferenceInstanceFields(); i++) { - Field* field = klass->GetInstanceField(i); + mirror::ArtField* field = klass->GetInstanceField(i); fh.ChangeField(field); ASSERT_TRUE(!fh.IsPrimitiveType()); - Class* field_type = fh.GetType(); + mirror::Class* field_type = fh.GetType(); ASSERT_TRUE(field_type != NULL); ASSERT_TRUE(!field_type->IsPrimitive()); } for (size_t i = klass->NumReferenceInstanceFields(); i < klass->NumInstanceFields(); i++) { - Field* field = klass->GetInstanceField(i); + mirror::ArtField* field = klass->GetInstanceField(i); fh.ChangeField(field); - Class* field_type = fh.GetType(); + mirror::Class* field_type = fh.GetType(); ASSERT_TRUE(field_type != NULL); if (!fh.IsPrimitiveType() || !field_type->IsPrimitive()) { // While Reference.referent is not primitive, the ClassLinker @@ -315,7 +290,7 @@ class ClassLinkerTest : public CommonTest { } size_t total_num_reference_instance_fields = 0; - Class* k = klass; + mirror::Class* k = klass; while (k != NULL) { total_num_reference_instance_fields += k->NumReferenceInstanceFields(); k = k->GetSuperClass(); @@ -324,10 +299,10 @@ class ClassLinkerTest : public CommonTest { total_num_reference_instance_fields == 0); } - void AssertDexFileClass(ClassLoader* class_loader, const std::string& descriptor) + void AssertDexFileClass(mirror::ClassLoader* class_loader, const std::string& descriptor) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { ASSERT_TRUE(descriptor != NULL); - Class* klass = class_linker_->FindSystemClass(descriptor.c_str()); + mirror::Class* klass = class_linker_->FindSystemClass(descriptor.c_str()); ASSERT_TRUE(klass != NULL); EXPECT_STREQ(descriptor.c_str(), ClassHelper(klass).GetDescriptor()); EXPECT_EQ(class_loader, klass->GetClassLoader()); @@ -340,7 +315,7 @@ class ClassLinkerTest : public CommonTest { } } - void AssertDexFile(const DexFile* dex, ClassLoader* class_loader) + void AssertDexFile(const DexFile* dex, mirror::ClassLoader* class_loader) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { ASSERT_TRUE(dex != NULL); @@ -358,14 +333,14 @@ class ClassLinkerTest : public CommonTest { } class_linker_->VisitRoots(TestRootVisitor, NULL, false); // Verify the dex cache has resolution methods in all resolved method slots - DexCache* dex_cache = class_linker_->FindDexCache(*dex); - ObjectArray* resolved_methods = dex_cache->GetResolvedMethods(); + mirror::DexCache* dex_cache = class_linker_->FindDexCache(*dex); + mirror::ObjectArray* resolved_methods = dex_cache->GetResolvedMethods(); for (size_t i = 0; i < static_cast(resolved_methods->GetLength()); i++) { EXPECT_TRUE(resolved_methods->Get(i) != NULL); } } - static void TestRootVisitor(const Object* root, void*) { + static void TestRootVisitor(const mirror::Object* root, void*) { EXPECT_TRUE(root != NULL); } }; @@ -385,7 +360,7 @@ struct CheckOffsets { std::vector offsets; bool Check() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - Class* klass = Runtime::Current()->GetClassLinker()->FindSystemClass(class_descriptor.c_str()); + mirror::Class* klass = Runtime::Current()->GetClassLinker()->FindSystemClass(class_descriptor.c_str()); CHECK(klass != NULL) << class_descriptor; bool error = false; @@ -412,7 +387,7 @@ struct CheckOffsets { FieldHelper fh; for (size_t i = 0; i < offsets.size(); i++) { - Field* field = is_static ? klass->GetStaticField(i) : klass->GetInstanceField(i); + mirror::ArtField* field = is_static ? klass->GetStaticField(i) : klass->GetInstanceField(i); fh.ChangeField(field); StringPiece field_name(fh.GetName()); if (field_name != offsets[i].java_name) { @@ -422,7 +397,7 @@ struct CheckOffsets { if (error) { for (size_t i = 0; i < offsets.size(); i++) { CheckOffset& offset = offsets[i]; - Field* field = is_static ? klass->GetStaticField(i) : klass->GetInstanceField(i); + mirror::ArtField* field = is_static ? klass->GetStaticField(i) : klass->GetInstanceField(i); fh.ChangeField(field); StringPiece field_name(fh.GetName()); if (field_name != offsets[i].java_name) { @@ -437,7 +412,7 @@ struct CheckOffsets { for (size_t i = 0; i < offsets.size(); i++) { CheckOffset& offset = offsets[i]; - Field* field = is_static ? klass->GetStaticField(i) : klass->GetInstanceField(i); + mirror::ArtField* field = is_static ? klass->GetStaticField(i) : klass->GetInstanceField(i); if (field->GetOffset().Uint32Value() != offset.cpp_offset) { error = true; } @@ -445,7 +420,7 @@ struct CheckOffsets { if (error) { for (size_t i = 0; i < offsets.size(); i++) { CheckOffset& offset = offsets[i]; - Field* field = is_static ? klass->GetStaticField(i) : klass->GetInstanceField(i); + mirror::ArtField* field = is_static ? klass->GetStaticField(i) : klass->GetInstanceField(i); if (field->GetOffset().Uint32Value() != offset.cpp_offset) { LOG(ERROR) << "OFFSET MISMATCH NEXT LINE:"; } @@ -464,195 +439,179 @@ struct CheckOffsets { // Note that ClassLinkerTest.ValidateFieldOrderOfJavaCppUnionClasses // is first since if it is failing, others are unlikely to succeed. -struct ObjectOffsets : public CheckOffsets { - ObjectOffsets() : CheckOffsets(false, "Ljava/lang/Object;") { +struct ObjectOffsets : public CheckOffsets { + ObjectOffsets() : CheckOffsets(false, "Ljava/lang/Object;") { // alphabetical references - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Object, klass_), "shadow$_klass_")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Object, klass_), "shadow$_klass_")); // alphabetical 32-bit - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Object, monitor_), "shadow$_monitor_")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Object, monitor_), "shadow$_monitor_")); }; }; -struct FieldOffsets : public CheckOffsets { - FieldOffsets() : CheckOffsets(false, "Ljava/lang/reflect/Field;") { +struct ArtFieldOffsets : public CheckOffsets { + ArtFieldOffsets() : CheckOffsets(false, "Ljava/lang/reflect/ArtField;") { // alphabetical references - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Field, declaring_class_), "declaringClass")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtField, declaring_class_), "declaringClass")); // alphabetical 32-bit - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Field, access_flags_), "accessFlags")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Field, field_dex_idx_), "fieldDexIndex")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Field, offset_), "offset")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtField, access_flags_), "accessFlags")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtField, field_dex_idx_), "fieldDexIndex")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtField, offset_), "offset")); }; }; -struct AbstractMethodOffsets : public CheckOffsets { - AbstractMethodOffsets() : CheckOffsets(false, "Ljava/lang/reflect/AbstractMethod;") { +struct ArtMethodOffsets : public CheckOffsets { + ArtMethodOffsets() : CheckOffsets(false, "Ljava/lang/reflect/ArtMethod;") { // alphabetical references - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AbstractMethod, declaring_class_), "declaringClass")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AbstractMethod, dex_cache_initialized_static_storage_), "dexCacheInitializedStaticStorage")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AbstractMethod, dex_cache_resolved_methods_), "dexCacheResolvedMethods")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AbstractMethod, dex_cache_resolved_types_), "dexCacheResolvedTypes")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AbstractMethod, dex_cache_strings_), "dexCacheStrings")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, declaring_class_), "declaringClass")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, dex_cache_initialized_static_storage_), "dexCacheInitializedStaticStorage")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, dex_cache_resolved_methods_), "dexCacheResolvedMethods")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, dex_cache_resolved_types_), "dexCacheResolvedTypes")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, dex_cache_strings_), "dexCacheStrings")); // alphabetical 32-bit - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AbstractMethod, access_flags_), "accessFlags")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AbstractMethod, code_item_offset_), "codeItemOffset")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AbstractMethod, core_spill_mask_), "coreSpillMask")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AbstractMethod, entry_point_from_compiled_code_), "entryPointFromCompiledCode")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AbstractMethod, entry_point_from_interpreter_), "entryPointFromInterpreter")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AbstractMethod, fp_spill_mask_), "fpSpillMask")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AbstractMethod, frame_size_in_bytes_), "frameSizeInBytes")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AbstractMethod, gc_map_), "gcMap")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AbstractMethod, mapping_table_), "mappingTable")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AbstractMethod, method_dex_index_), "methodDexIndex")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AbstractMethod, method_index_), "methodIndex")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AbstractMethod, native_method_), "nativeMethod")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AbstractMethod, vmap_table_), "vmapTable")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, access_flags_), "accessFlags")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, code_item_offset_), "codeItemOffset")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, core_spill_mask_), "coreSpillMask")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, entry_point_from_compiled_code_), "entryPointFromCompiledCode")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, entry_point_from_interpreter_), "entryPointFromInterpreter")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, fp_spill_mask_), "fpSpillMask")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, frame_size_in_bytes_), "frameSizeInBytes")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, gc_map_), "gcMap")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, mapping_table_), "mappingTable")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, method_dex_index_), "methodDexIndex")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, method_index_), "methodIndex")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, native_method_), "nativeMethod")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, vmap_table_), "vmapTable")); }; }; -struct ConstructorOffsets : public CheckOffsets { - // java.lang.reflect.Constructor is a subclass of java.lang.reflect.AbstractMethod - ConstructorOffsets() : CheckOffsets(false, "Ljava/lang/reflect/Constructor;") { - } -}; - -struct MethodOffsets : public CheckOffsets { - // java.lang.reflect.Method is a subclass of java.lang.reflect.AbstractMethod - MethodOffsets() : CheckOffsets(false, "Ljava/lang/reflect/Method;") { - } -}; - -struct ClassOffsets : public CheckOffsets { - ClassOffsets() : CheckOffsets(false, "Ljava/lang/Class;") { +struct ClassOffsets : public CheckOffsets { + ClassOffsets() : CheckOffsets(false, "Ljava/lang/Class;") { // alphabetical references - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, class_loader_), "classLoader")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, component_type_), "componentType")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, dex_cache_), "dexCache")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, direct_methods_), "directMethods")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, ifields_), "iFields")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, iftable_), "ifTable")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, name_), "name")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, sfields_), "sFields")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, super_class_), "superClass")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, verify_error_class_), "verifyErrorClass")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, virtual_methods_), "virtualMethods")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, vtable_), "vtable")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, class_loader_), "classLoader")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, component_type_), "componentType")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, dex_cache_), "dexCache")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, direct_methods_), "directMethods")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, ifields_), "iFields")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, iftable_), "ifTable")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, name_), "name")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, sfields_), "sFields")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, super_class_), "superClass")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, verify_error_class_), "verifyErrorClass")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, virtual_methods_), "virtualMethods")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, vtable_), "vtable")); // alphabetical 32-bit - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, access_flags_), "accessFlags")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, class_size_), "classSize")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, clinit_thread_id_), "clinitThreadId")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, dex_type_idx_), "dexTypeIndex")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, num_reference_instance_fields_), "numReferenceInstanceFields")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, num_reference_static_fields_), "numReferenceStaticFields")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, object_size_), "objectSize")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, primitive_type_), "primitiveType")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, reference_instance_offsets_), "referenceInstanceOffsets")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, reference_static_offsets_), "referenceStaticOffsets")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, status_), "status")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, access_flags_), "accessFlags")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, class_size_), "classSize")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, clinit_thread_id_), "clinitThreadId")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, dex_type_idx_), "dexTypeIndex")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, num_reference_instance_fields_), "numReferenceInstanceFields")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, num_reference_static_fields_), "numReferenceStaticFields")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, object_size_), "objectSize")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, primitive_type_), "primitiveType")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, reference_instance_offsets_), "referenceInstanceOffsets")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, reference_static_offsets_), "referenceStaticOffsets")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, status_), "status")); }; }; -struct StringOffsets : public CheckOffsets { - StringOffsets() : CheckOffsets(false, "Ljava/lang/String;") { +struct StringOffsets : public CheckOffsets { + StringOffsets() : CheckOffsets(false, "Ljava/lang/String;") { // alphabetical references - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(String, array_), "value")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::String, array_), "value")); // alphabetical 32-bit - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(String, count_), "count")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(String, hash_code_), "hashCode")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(String, offset_), "offset")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::String, count_), "count")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::String, hash_code_), "hashCode")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::String, offset_), "offset")); }; }; -struct ThrowableOffsets : public CheckOffsets { - ThrowableOffsets() : CheckOffsets(false, "Ljava/lang/Throwable;") { +struct ThrowableOffsets : public CheckOffsets { + ThrowableOffsets() : CheckOffsets(false, "Ljava/lang/Throwable;") { // alphabetical references - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Throwable, cause_), "cause")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Throwable, detail_message_), "detailMessage")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Throwable, stack_state_), "stackState")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Throwable, stack_trace_), "stackTrace")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Throwable, suppressed_exceptions_), "suppressedExceptions")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Throwable, cause_), "cause")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Throwable, detail_message_), "detailMessage")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Throwable, stack_state_), "stackState")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Throwable, stack_trace_), "stackTrace")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Throwable, suppressed_exceptions_), "suppressedExceptions")); }; }; -struct StackTraceElementOffsets : public CheckOffsets { - StackTraceElementOffsets() : CheckOffsets(false, "Ljava/lang/StackTraceElement;") { +struct StackTraceElementOffsets : public CheckOffsets { + StackTraceElementOffsets() : CheckOffsets(false, "Ljava/lang/StackTraceElement;") { // alphabetical references - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(StackTraceElement, declaring_class_), "declaringClass")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(StackTraceElement, file_name_), "fileName")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(StackTraceElement, method_name_), "methodName")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(StackTraceElement, line_number_), "lineNumber")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::StackTraceElement, declaring_class_), "declaringClass")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::StackTraceElement, file_name_), "fileName")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::StackTraceElement, method_name_), "methodName")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::StackTraceElement, line_number_), "lineNumber")); }; }; -struct ClassLoaderOffsets : public CheckOffsets { - ClassLoaderOffsets() : CheckOffsets(false, "Ljava/lang/ClassLoader;") { +struct ClassLoaderOffsets : public CheckOffsets { + ClassLoaderOffsets() : CheckOffsets(false, "Ljava/lang/ClassLoader;") { // alphabetical references - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(ClassLoader, packages_), "packages")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(ClassLoader, parent_), "parent")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(ClassLoader, proxyCache_), "proxyCache")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ClassLoader, packages_), "packages")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ClassLoader, parent_), "parent")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ClassLoader, proxyCache_), "proxyCache")); }; }; -struct ProxyOffsets : public CheckOffsets { - ProxyOffsets() : CheckOffsets(false, "Ljava/lang/reflect/Proxy;") { +struct ProxyOffsets : public CheckOffsets { + ProxyOffsets() : CheckOffsets(false, "Ljava/lang/reflect/Proxy;") { // alphabetical references - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Proxy, h_), "h")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Proxy, h_), "h")); }; }; -struct ClassClassOffsets : public CheckOffsets { - ClassClassOffsets() : CheckOffsets(true, "Ljava/lang/Class;") { +struct ClassClassOffsets : public CheckOffsets { + ClassClassOffsets() : CheckOffsets(true, "Ljava/lang/Class;") { // padding 32-bit - CHECK_EQ(OFFSETOF_MEMBER(ClassClass, padding_) + 4, - OFFSETOF_MEMBER(ClassClass, serialVersionUID_)); + CHECK_EQ(OFFSETOF_MEMBER(mirror::ClassClass, padding_) + 4, + OFFSETOF_MEMBER(mirror::ClassClass, serialVersionUID_)); // alphabetical 64-bit - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(ClassClass, serialVersionUID_), "serialVersionUID")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ClassClass, serialVersionUID_), "serialVersionUID")); }; }; -struct StringClassOffsets : public CheckOffsets { - StringClassOffsets() : CheckOffsets(true, "Ljava/lang/String;") { +struct StringClassOffsets : public CheckOffsets { + StringClassOffsets() : CheckOffsets(true, "Ljava/lang/String;") { // alphabetical references - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(StringClass, ASCII_), "ASCII")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(StringClass, CASE_INSENSITIVE_ORDER_), "CASE_INSENSITIVE_ORDER")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::StringClass, ASCII_), "ASCII")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::StringClass, CASE_INSENSITIVE_ORDER_), "CASE_INSENSITIVE_ORDER")); // padding 32-bit - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(StringClass, REPLACEMENT_CHAR_), "REPLACEMENT_CHAR")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::StringClass, REPLACEMENT_CHAR_), "REPLACEMENT_CHAR")); // alphabetical 64-bit - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(StringClass, serialVersionUID_), "serialVersionUID")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::StringClass, serialVersionUID_), "serialVersionUID")); }; }; -struct FieldClassOffsets : public CheckOffsets { - FieldClassOffsets() : CheckOffsets(true, "Ljava/lang/reflect/Field;") { - // alphabetical references - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(FieldClass, ORDER_BY_NAME_AND_DECLARING_CLASS_), "ORDER_BY_NAME_AND_DECLARING_CLASS")); +struct ArtFieldClassOffsets : public CheckOffsets { + ArtFieldClassOffsets() : CheckOffsets(true, "Ljava/lang/reflect/ArtField;") { }; }; -struct MethodClassOffsets : public CheckOffsets { - MethodClassOffsets() : CheckOffsets(true, "Ljava/lang/reflect/Method;") { - // alphabetical references - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AbstractMethodClass, ORDER_BY_SIGNATURE_), "ORDER_BY_SIGNATURE")); +struct ArtMethodClassOffsets : public CheckOffsets { + ArtMethodClassOffsets() : CheckOffsets(true, "Ljava/lang/reflect/ArtMethod;") { }; }; -struct DexCacheOffsets : public CheckOffsets { - DexCacheOffsets() : CheckOffsets(false, "Ljava/lang/DexCache;") { +struct DexCacheOffsets : public CheckOffsets { + DexCacheOffsets() : CheckOffsets(false, "Ljava/lang/DexCache;") { // alphabetical references - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(DexCache, initialized_static_storage_), "initializedStaticStorage")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(DexCache, location_), "location")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(DexCache, resolved_fields_), "resolvedFields")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(DexCache, resolved_methods_), "resolvedMethods")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(DexCache, resolved_types_), "resolvedTypes")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(DexCache, strings_), "strings")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(DexCache, dex_file_), "dexFile")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::DexCache, initialized_static_storage_), "initializedStaticStorage")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::DexCache, location_), "location")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::DexCache, resolved_fields_), "resolvedFields")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::DexCache, resolved_methods_), "resolvedMethods")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::DexCache, resolved_types_), "resolvedTypes")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::DexCache, strings_), "strings")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::DexCache, dex_file_), "dexFile")); }; }; @@ -662,10 +621,8 @@ struct DexCacheOffsets : public CheckOffsets { TEST_F(ClassLinkerTest, ValidateFieldOrderOfJavaCppUnionClasses) { ScopedObjectAccess soa(Thread::Current()); EXPECT_TRUE(ObjectOffsets().Check()); - EXPECT_TRUE(ConstructorOffsets().Check()); - EXPECT_TRUE(MethodOffsets().Check()); - EXPECT_TRUE(FieldOffsets().Check()); - EXPECT_TRUE(AbstractMethodOffsets().Check()); + EXPECT_TRUE(ArtFieldOffsets().Check()); + EXPECT_TRUE(ArtMethodOffsets().Check()); EXPECT_TRUE(ClassOffsets().Check()); EXPECT_TRUE(StringOffsets().Check()); EXPECT_TRUE(ThrowableOffsets().Check()); @@ -676,8 +633,8 @@ TEST_F(ClassLinkerTest, ValidateFieldOrderOfJavaCppUnionClasses) { EXPECT_TRUE(ClassClassOffsets().Check()); EXPECT_TRUE(StringClassOffsets().Check()); - EXPECT_TRUE(FieldClassOffsets().Check()); - EXPECT_TRUE(MethodClassOffsets().Check()); + EXPECT_TRUE(ArtFieldClassOffsets().Check()); + EXPECT_TRUE(ArtMethodClassOffsets().Check()); } TEST_F(ClassLinkerTest, FindClassNonexistent) { @@ -688,14 +645,14 @@ TEST_F(ClassLinkerTest, FindClassNonexistent) { TEST_F(ClassLinkerTest, FindClassNested) { ScopedObjectAccess soa(Thread::Current()); - SirtRef class_loader(soa.Self(), soa.Decode(LoadDex("Nested"))); + SirtRef class_loader(soa.Self(), soa.Decode(LoadDex("Nested"))); - Class* outer = class_linker_->FindClass("LNested;", class_loader.get()); + mirror::Class* outer = class_linker_->FindClass("LNested;", class_loader.get()); ASSERT_TRUE(outer != NULL); EXPECT_EQ(0U, outer->NumVirtualMethods()); EXPECT_EQ(1U, outer->NumDirectMethods()); - Class* inner = class_linker_->FindClass("LNested$Inner;", class_loader.get()); + mirror::Class* inner = class_linker_->FindClass("LNested$Inner;", class_loader.get()); ASSERT_TRUE(inner != NULL); EXPECT_EQ(0U, inner->NumVirtualMethods()); EXPECT_EQ(1U, inner->NumDirectMethods()); @@ -717,7 +674,7 @@ TEST_F(ClassLinkerTest, FindClass_Primitives) { TEST_F(ClassLinkerTest, FindClass) { ScopedObjectAccess soa(Thread::Current()); - Class* JavaLangObject = class_linker_->FindSystemClass("Ljava/lang/Object;"); + mirror::Class* JavaLangObject = class_linker_->FindSystemClass("Ljava/lang/Object;"); ClassHelper kh(JavaLangObject); ASSERT_TRUE(JavaLangObject != NULL); ASSERT_TRUE(JavaLangObject->GetClass() != NULL); @@ -727,12 +684,12 @@ TEST_F(ClassLinkerTest, FindClass) { EXPECT_TRUE(JavaLangObject->GetSuperClass() == NULL); EXPECT_FALSE(JavaLangObject->HasSuperClass()); EXPECT_TRUE(JavaLangObject->GetClassLoader() == NULL); - EXPECT_EQ(Class::kStatusResolved, JavaLangObject->GetStatus()); + EXPECT_EQ(mirror::Class::kStatusInitialized, JavaLangObject->GetStatus()); EXPECT_FALSE(JavaLangObject->IsErroneous()); EXPECT_TRUE(JavaLangObject->IsLoaded()); EXPECT_TRUE(JavaLangObject->IsResolved()); - EXPECT_FALSE(JavaLangObject->IsVerified()); - EXPECT_FALSE(JavaLangObject->IsInitialized()); + EXPECT_TRUE(JavaLangObject->IsVerified()); + EXPECT_TRUE(JavaLangObject->IsInitialized()); EXPECT_FALSE(JavaLangObject->IsArrayInstance()); EXPECT_FALSE(JavaLangObject->IsArrayClass()); EXPECT_TRUE(JavaLangObject->GetComponentType() == NULL); @@ -752,9 +709,9 @@ TEST_F(ClassLinkerTest, FindClass) { EXPECT_EQ(0U, JavaLangObject->NumStaticFields()); EXPECT_EQ(0U, kh.NumDirectInterfaces()); - SirtRef class_loader(soa.Self(), soa.Decode(LoadDex("MyClass"))); + SirtRef class_loader(soa.Self(), soa.Decode(LoadDex("MyClass"))); AssertNonExistentClass("LMyClass;"); - Class* MyClass = class_linker_->FindClass("LMyClass;", class_loader.get()); + mirror::Class* MyClass = class_linker_->FindClass("LMyClass;", class_loader.get()); kh.ChangeClass(MyClass); ASSERT_TRUE(MyClass != NULL); ASSERT_TRUE(MyClass->GetClass() != NULL); @@ -764,7 +721,7 @@ TEST_F(ClassLinkerTest, FindClass) { EXPECT_TRUE(MyClass->GetSuperClass() == JavaLangObject); EXPECT_TRUE(MyClass->HasSuperClass()); EXPECT_EQ(class_loader.get(), MyClass->GetClassLoader()); - EXPECT_EQ(Class::kStatusResolved, MyClass->GetStatus()); + EXPECT_EQ(mirror::Class::kStatusResolved, MyClass->GetStatus()); EXPECT_FALSE(MyClass->IsErroneous()); EXPECT_TRUE(MyClass->IsLoaded()); EXPECT_TRUE(MyClass->IsResolved()); @@ -805,12 +762,13 @@ TEST_F(ClassLinkerTest, LibCore) { // start of the object TEST_F(ClassLinkerTest, ValidateObjectArrayElementsOffset) { ScopedObjectAccess soa(Thread::Current()); - Class* array_class = class_linker_->FindSystemClass("[Ljava/lang/String;"); - ObjectArray* array = ObjectArray::Alloc(soa.Self(), array_class, 0); + mirror::Class* array_class = class_linker_->FindSystemClass("[Ljava/lang/String;"); + mirror::ObjectArray* array = + mirror::ObjectArray::Alloc(soa.Self(), array_class, 0); uint32_t array_offset = reinterpret_cast(array); uint32_t data_offset = - array_offset + ObjectArray::DataOffset(sizeof(String*)).Uint32Value(); - if (sizeof(String*) == sizeof(int32_t)) { + array_offset + mirror::ObjectArray::DataOffset(sizeof(mirror::String*)).Uint32Value(); + if (sizeof(mirror::String*) == sizeof(int32_t)) { EXPECT_TRUE(IsAligned<4>(data_offset)); // Check 4 byte alignment. } else { EXPECT_TRUE(IsAligned<8>(data_offset)); // Check 8 byte alignment. @@ -819,27 +777,27 @@ TEST_F(ClassLinkerTest, ValidateObjectArrayElementsOffset) { TEST_F(ClassLinkerTest, ValidatePrimitiveArrayElementsOffset) { ScopedObjectAccess soa(Thread::Current()); - SirtRef long_array(soa.Self(), LongArray::Alloc(soa.Self(), 0)); + SirtRef long_array(soa.Self(), mirror::LongArray::Alloc(soa.Self(), 0)); EXPECT_EQ(class_linker_->FindSystemClass("[J"), long_array->GetClass()); uintptr_t data_offset = reinterpret_cast(long_array->GetData()); EXPECT_TRUE(IsAligned<8>(data_offset)); // Longs require 8 byte alignment - SirtRef double_array(soa.Self(), DoubleArray::Alloc(soa.Self(), 0)); + SirtRef double_array(soa.Self(), mirror::DoubleArray::Alloc(soa.Self(), 0)); EXPECT_EQ(class_linker_->FindSystemClass("[D"), double_array->GetClass()); data_offset = reinterpret_cast(double_array->GetData()); EXPECT_TRUE(IsAligned<8>(data_offset)); // Doubles require 8 byte alignment - SirtRef int_array(soa.Self(), IntArray::Alloc(soa.Self(), 0)); + SirtRef int_array(soa.Self(), mirror::IntArray::Alloc(soa.Self(), 0)); EXPECT_EQ(class_linker_->FindSystemClass("[I"), int_array->GetClass()); data_offset = reinterpret_cast(int_array->GetData()); EXPECT_TRUE(IsAligned<4>(data_offset)); // Ints require 4 byte alignment - SirtRef char_array(soa.Self(), CharArray::Alloc(soa.Self(), 0)); + SirtRef char_array(soa.Self(), mirror::CharArray::Alloc(soa.Self(), 0)); EXPECT_EQ(class_linker_->FindSystemClass("[C"), char_array->GetClass()); data_offset = reinterpret_cast(char_array->GetData()); EXPECT_TRUE(IsAligned<2>(data_offset)); // Chars require 2 byte alignment - SirtRef short_array(soa.Self(), ShortArray::Alloc(soa.Self(), 0)); + SirtRef short_array(soa.Self(), mirror::ShortArray::Alloc(soa.Self(), 0)); EXPECT_EQ(class_linker_->FindSystemClass("[S"), short_array->GetClass()); data_offset = reinterpret_cast(short_array->GetData()); EXPECT_TRUE(IsAligned<2>(data_offset)); // Shorts require 2 byte alignment @@ -851,7 +809,7 @@ TEST_F(ClassLinkerTest, ValidateBoxedTypes) { // Validate that the "value" field is always the 0th field in each of java.lang's box classes. // This lets UnboxPrimitive avoid searching for the field by name at runtime. ScopedObjectAccess soa(Thread::Current()); - Class* c; + mirror::Class* c; c = class_linker_->FindClass("Ljava/lang/Boolean;", NULL); FieldHelper fh(c->GetIFields()->Get(0)); EXPECT_STREQ("value", fh.GetName()); @@ -880,10 +838,10 @@ TEST_F(ClassLinkerTest, ValidateBoxedTypes) { TEST_F(ClassLinkerTest, TwoClassLoadersOneClass) { ScopedObjectAccess soa(Thread::Current()); - SirtRef class_loader_1(soa.Self(), soa.Decode(LoadDex("MyClass"))); - SirtRef class_loader_2(soa.Self(), soa.Decode(LoadDex("MyClass"))); - Class* MyClass_1 = class_linker_->FindClass("LMyClass;", class_loader_1.get()); - Class* MyClass_2 = class_linker_->FindClass("LMyClass;", class_loader_2.get()); + SirtRef class_loader_1(soa.Self(), soa.Decode(LoadDex("MyClass"))); + SirtRef class_loader_2(soa.Self(), soa.Decode(LoadDex("MyClass"))); + mirror::Class* MyClass_1 = class_linker_->FindClass("LMyClass;", class_loader_1.get()); + mirror::Class* MyClass_2 = class_linker_->FindClass("LMyClass;", class_loader_2.get()); EXPECT_TRUE(MyClass_1 != NULL); EXPECT_TRUE(MyClass_2 != NULL); EXPECT_NE(MyClass_1, MyClass_2); @@ -891,72 +849,72 @@ TEST_F(ClassLinkerTest, TwoClassLoadersOneClass) { TEST_F(ClassLinkerTest, StaticFields) { ScopedObjectAccess soa(Thread::Current()); - SirtRef class_loader(soa.Self(), soa.Decode(LoadDex("Statics"))); - Class* statics = class_linker_->FindClass("LStatics;", class_loader.get()); + SirtRef class_loader(soa.Self(), soa.Decode(LoadDex("Statics"))); + mirror::Class* statics = class_linker_->FindClass("LStatics;", class_loader.get()); class_linker_->EnsureInitialized(statics, true, true); // Static final primitives that are initialized by a compile-time constant // expression resolve to a copy of a constant value from the constant pool. // So should be null. - AbstractMethod* clinit = statics->FindDirectMethod("", "()V"); + mirror::ArtMethod* clinit = statics->FindDirectMethod("", "()V"); EXPECT_TRUE(clinit == NULL); EXPECT_EQ(9U, statics->NumStaticFields()); - Field* s0 = statics->FindStaticField("s0", "Z"); + mirror::ArtField* s0 = statics->FindStaticField("s0", "Z"); FieldHelper fh(s0); - EXPECT_STREQ(ClassHelper(s0->GetClass()).GetDescriptor(), "Ljava/lang/reflect/Field;"); + EXPECT_STREQ(ClassHelper(s0->GetClass()).GetDescriptor(), "Ljava/lang/reflect/ArtField;"); EXPECT_TRUE(fh.GetTypeAsPrimitiveType() == Primitive::kPrimBoolean); EXPECT_EQ(true, s0->GetBoolean(statics)); s0->SetBoolean(statics, false); - Field* s1 = statics->FindStaticField("s1", "B"); + mirror::ArtField* s1 = statics->FindStaticField("s1", "B"); fh.ChangeField(s1); EXPECT_TRUE(fh.GetTypeAsPrimitiveType() == Primitive::kPrimByte); EXPECT_EQ(5, s1->GetByte(statics)); s1->SetByte(statics, 6); - Field* s2 = statics->FindStaticField("s2", "C"); + mirror::ArtField* s2 = statics->FindStaticField("s2", "C"); fh.ChangeField(s2); EXPECT_TRUE(fh.GetTypeAsPrimitiveType() == Primitive::kPrimChar); EXPECT_EQ('a', s2->GetChar(statics)); s2->SetChar(statics, 'b'); - Field* s3 = statics->FindStaticField("s3", "S"); + mirror::ArtField* s3 = statics->FindStaticField("s3", "S"); fh.ChangeField(s3); EXPECT_TRUE(fh.GetTypeAsPrimitiveType() == Primitive::kPrimShort); EXPECT_EQ(-536, s3->GetShort(statics)); s3->SetShort(statics, -535); - Field* s4 = statics->FindStaticField("s4", "I"); + mirror::ArtField* s4 = statics->FindStaticField("s4", "I"); fh.ChangeField(s4); EXPECT_TRUE(fh.GetTypeAsPrimitiveType() == Primitive::kPrimInt); EXPECT_EQ(2000000000, s4->GetInt(statics)); s4->SetInt(statics, 2000000001); - Field* s5 = statics->FindStaticField("s5", "J"); + mirror::ArtField* s5 = statics->FindStaticField("s5", "J"); fh.ChangeField(s5); EXPECT_TRUE(fh.GetTypeAsPrimitiveType() == Primitive::kPrimLong); EXPECT_EQ(0x1234567890abcdefLL, s5->GetLong(statics)); s5->SetLong(statics, 0x34567890abcdef12LL); - Field* s6 = statics->FindStaticField("s6", "F"); + mirror::ArtField* s6 = statics->FindStaticField("s6", "F"); fh.ChangeField(s6); EXPECT_TRUE(fh.GetTypeAsPrimitiveType() == Primitive::kPrimFloat); EXPECT_EQ(0.5, s6->GetFloat(statics)); s6->SetFloat(statics, 0.75); - Field* s7 = statics->FindStaticField("s7", "D"); + mirror::ArtField* s7 = statics->FindStaticField("s7", "D"); fh.ChangeField(s7); EXPECT_TRUE(fh.GetTypeAsPrimitiveType() == Primitive::kPrimDouble); EXPECT_EQ(16777217, s7->GetDouble(statics)); s7->SetDouble(statics, 16777219); - Field* s8 = statics->FindStaticField("s8", "Ljava/lang/String;"); + mirror::ArtField* s8 = statics->FindStaticField("s8", "Ljava/lang/String;"); fh.ChangeField(s8); EXPECT_TRUE(fh.GetTypeAsPrimitiveType() == Primitive::kPrimNot); EXPECT_TRUE(s8->GetObject(statics)->AsString()->Equals("android")); - s8->SetObject(s8->GetDeclaringClass(), String::AllocFromModifiedUtf8(soa.Self(), "robot")); + s8->SetObject(s8->GetDeclaringClass(), mirror::String::AllocFromModifiedUtf8(soa.Self(), "robot")); // TODO: Remove EXPECT_FALSE when GCC can handle EXPECT_EQ // http://code.google.com/p/googletest/issues/detail?id=322 @@ -973,27 +931,27 @@ TEST_F(ClassLinkerTest, StaticFields) { TEST_F(ClassLinkerTest, Interfaces) { ScopedObjectAccess soa(Thread::Current()); - SirtRef class_loader(soa.Self(), soa.Decode(LoadDex("Interfaces"))); - Class* I = class_linker_->FindClass("LInterfaces$I;", class_loader.get()); - Class* J = class_linker_->FindClass("LInterfaces$J;", class_loader.get()); - Class* K = class_linker_->FindClass("LInterfaces$K;", class_loader.get()); - Class* A = class_linker_->FindClass("LInterfaces$A;", class_loader.get()); - Class* B = class_linker_->FindClass("LInterfaces$B;", class_loader.get()); + SirtRef class_loader(soa.Self(), soa.Decode(LoadDex("Interfaces"))); + mirror::Class* I = class_linker_->FindClass("LInterfaces$I;", class_loader.get()); + mirror::Class* J = class_linker_->FindClass("LInterfaces$J;", class_loader.get()); + mirror::Class* K = class_linker_->FindClass("LInterfaces$K;", class_loader.get()); + mirror::Class* A = class_linker_->FindClass("LInterfaces$A;", class_loader.get()); + mirror::Class* B = class_linker_->FindClass("LInterfaces$B;", class_loader.get()); EXPECT_TRUE(I->IsAssignableFrom(A)); EXPECT_TRUE(J->IsAssignableFrom(A)); EXPECT_TRUE(J->IsAssignableFrom(K)); EXPECT_TRUE(K->IsAssignableFrom(B)); EXPECT_TRUE(J->IsAssignableFrom(B)); - AbstractMethod* Ii = I->FindVirtualMethod("i", "()V"); - AbstractMethod* Jj1 = J->FindVirtualMethod("j1", "()V"); - AbstractMethod* Jj2 = J->FindVirtualMethod("j2", "()V"); - AbstractMethod* Kj1 = K->FindInterfaceMethod("j1", "()V"); - AbstractMethod* Kj2 = K->FindInterfaceMethod("j2", "()V"); - AbstractMethod* Kk = K->FindInterfaceMethod("k", "()V"); - AbstractMethod* Ai = A->FindVirtualMethod("i", "()V"); - AbstractMethod* Aj1 = A->FindVirtualMethod("j1", "()V"); - AbstractMethod* Aj2 = A->FindVirtualMethod("j2", "()V"); + mirror::ArtMethod* Ii = I->FindVirtualMethod("i", "()V"); + mirror::ArtMethod* Jj1 = J->FindVirtualMethod("j1", "()V"); + mirror::ArtMethod* Jj2 = J->FindVirtualMethod("j2", "()V"); + mirror::ArtMethod* Kj1 = K->FindInterfaceMethod("j1", "()V"); + mirror::ArtMethod* Kj2 = K->FindInterfaceMethod("j2", "()V"); + mirror::ArtMethod* Kk = K->FindInterfaceMethod("k", "()V"); + mirror::ArtMethod* Ai = A->FindVirtualMethod("i", "()V"); + mirror::ArtMethod* Aj1 = A->FindVirtualMethod("j1", "()V"); + mirror::ArtMethod* Aj2 = A->FindVirtualMethod("j2", "()V"); ASSERT_TRUE(Ii != NULL); ASSERT_TRUE(Jj1 != NULL); ASSERT_TRUE(Jj2 != NULL); @@ -1015,10 +973,10 @@ TEST_F(ClassLinkerTest, Interfaces) { EXPECT_EQ(Aj1, A->FindVirtualMethodForVirtualOrInterface(Jj1)); EXPECT_EQ(Aj2, A->FindVirtualMethodForVirtualOrInterface(Jj2)); - Field* Afoo = A->FindStaticField("foo", "Ljava/lang/String;"); - Field* Bfoo = B->FindStaticField("foo", "Ljava/lang/String;"); - Field* Jfoo = J->FindStaticField("foo", "Ljava/lang/String;"); - Field* Kfoo = K->FindStaticField("foo", "Ljava/lang/String;"); + mirror::ArtField* Afoo = A->FindStaticField("foo", "Ljava/lang/String;"); + mirror::ArtField* Bfoo = B->FindStaticField("foo", "Ljava/lang/String;"); + mirror::ArtField* Jfoo = J->FindStaticField("foo", "Ljava/lang/String;"); + mirror::ArtField* Kfoo = K->FindStaticField("foo", "Ljava/lang/String;"); ASSERT_TRUE(Afoo != NULL); EXPECT_EQ(Afoo, Bfoo); EXPECT_EQ(Afoo, Jfoo); @@ -1033,30 +991,30 @@ TEST_F(ClassLinkerTest, ResolveVerifyAndClinit) { ScopedObjectAccess soa(Thread::Current()); jobject jclass_loader = LoadDex("StaticsFromCode"); - SirtRef class_loader(soa.Self(), soa.Decode(jclass_loader)); + SirtRef class_loader(soa.Self(), soa.Decode(jclass_loader)); const DexFile* dex_file = Runtime::Current()->GetCompileTimeClassPath(jclass_loader)[0]; CHECK(dex_file != NULL); - Class* klass = class_linker_->FindClass("LStaticsFromCode;", class_loader.get()); - AbstractMethod* clinit = klass->FindDirectMethod("", "()V"); - AbstractMethod* getS0 = klass->FindDirectMethod("getS0", "()Ljava/lang/Object;"); + mirror::Class* klass = class_linker_->FindClass("LStaticsFromCode;", class_loader.get()); + mirror::ArtMethod* clinit = klass->FindDirectMethod("", "()V"); + mirror::ArtMethod* getS0 = klass->FindDirectMethod("getS0", "()Ljava/lang/Object;"); const DexFile::StringId* string_id = dex_file->FindStringId("LStaticsFromCode;"); ASSERT_TRUE(string_id != NULL); const DexFile::TypeId* type_id = dex_file->FindTypeId(dex_file->GetIndexForStringId(*string_id)); ASSERT_TRUE(type_id != NULL); uint32_t type_idx = dex_file->GetIndexForTypeId(*type_id); EXPECT_TRUE(clinit->GetDexCacheInitializedStaticStorage()->Get(type_idx) == NULL); - StaticStorageBase* uninit = ResolveVerifyAndClinit(type_idx, clinit, Thread::Current(), true, false); + mirror::StaticStorageBase* uninit = ResolveVerifyAndClinit(type_idx, clinit, Thread::Current(), true, false); EXPECT_TRUE(uninit != NULL); EXPECT_TRUE(clinit->GetDexCacheInitializedStaticStorage()->Get(type_idx) == NULL); - StaticStorageBase* init = ResolveVerifyAndClinit(type_idx, getS0, Thread::Current(), true, false); + mirror::StaticStorageBase* init = ResolveVerifyAndClinit(type_idx, getS0, Thread::Current(), true, false); EXPECT_TRUE(init != NULL); EXPECT_EQ(init, clinit->GetDexCacheInitializedStaticStorage()->Get(type_idx)); } TEST_F(ClassLinkerTest, FinalizableBit) { ScopedObjectAccess soa(Thread::Current()); - Class* c; + mirror::Class* c; // Object has a finalize method, but we know it's empty. c = class_linker_->FindSystemClass("Ljava/lang/Object;"); @@ -1092,7 +1050,7 @@ TEST_F(ClassLinkerTest, ClassRootDescriptors) { ScopedObjectAccess soa(Thread::Current()); ClassHelper kh; for (int i = 0; i < ClassLinker::kClassRootsMax; i++) { - Class* klass = class_linker_->GetClassRoot(ClassLinker::ClassRoot(i)); + mirror::Class* klass = class_linker_->GetClassRoot(ClassLinker::ClassRoot(i)); kh.ChangeClass(klass); EXPECT_TRUE(kh.GetDescriptor() != NULL); EXPECT_STREQ(kh.GetDescriptor(), diff --git a/runtime/common_test.h b/runtime/common_test.h index 7110e117f3..ced2af9670 100644 --- a/runtime/common_test.h +++ b/runtime/common_test.h @@ -181,7 +181,7 @@ class CommonTest : public testing::Test { reinterpret_cast(gc_map)); } - void MakeExecutable(mirror::AbstractMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + void MakeExecutable(mirror::ArtMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { CHECK(method != NULL); LOG(INFO) << "MakeExecutable " << PrettyMethod(method); @@ -348,7 +348,7 @@ class CommonTest : public testing::Test { compiler_driver_->SetSupportBootImageFixup(false); // We're back in native, take the opportunity to initialize well known classes. - WellKnownClasses::InitClasses(Thread::Current()->GetJniEnv()); + WellKnownClasses::Init(Thread::Current()->GetJniEnv()); // Create the heap thread pool so that the GC runs in parallel for tests. Normally, the thread // pool is created by the runtime. runtime_->GetHeap()->CreateThreadPool(); @@ -464,7 +464,7 @@ class CommonTest : public testing::Test { } } - void CompileMethod(mirror::AbstractMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + void CompileMethod(mirror::ArtMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { CHECK(method != NULL); base::TimingLogger timings("CommonTest::CompileMethod", false, false); timings.StartSplit("CompileOne"); @@ -480,7 +480,7 @@ class CommonTest : public testing::Test { std::string class_descriptor(DotToDescriptor(class_name)); mirror::Class* klass = class_linker_->FindClass(class_descriptor.c_str(), class_loader); CHECK(klass != NULL) << "Class not found " << class_name; - mirror::AbstractMethod* method = klass->FindDirectMethod(method_name, signature); + mirror::ArtMethod* method = klass->FindDirectMethod(method_name, signature); CHECK(method != NULL) << "Direct method not found: " << class_name << "." << method_name << signature; CompileMethod(method); @@ -494,7 +494,7 @@ class CommonTest : public testing::Test { std::string class_descriptor(DotToDescriptor(class_name)); mirror::Class* klass = class_linker_->FindClass(class_descriptor.c_str(), class_loader); CHECK(klass != NULL) << "Class not found " << class_name; - mirror::AbstractMethod* method = klass->FindVirtualMethod(method_name, signature); + mirror::ArtMethod* method = klass->FindVirtualMethod(method_name, signature); CHECK(method != NULL) << "Virtual method not found: " << class_name << "." << method_name << signature; CompileMethod(method); diff --git a/runtime/common_throws.cc b/runtime/common_throws.cc index 2a55e3138b..26ce5be1ec 100644 --- a/runtime/common_throws.cc +++ b/runtime/common_throws.cc @@ -21,7 +21,7 @@ #include "dex_file-inl.h" #include "dex_instruction-inl.h" #include "invoke_type.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" @@ -68,7 +68,7 @@ static void ThrowException(const ThrowLocation* throw_location, const char* exce // AbstractMethodError -void ThrowAbstractMethodError(const mirror::AbstractMethod* method) { +void ThrowAbstractMethodError(const mirror::ArtMethod* method) { ThrowException(NULL, "Ljava/lang/AbstractMethodError;", NULL, StringPrintf("abstract method \"%s\"", PrettyMethod(method).c_str()).c_str()); @@ -136,8 +136,8 @@ void ThrowIllegalAccessErrorClass(mirror::Class* referrer, mirror::Class* access } void ThrowIllegalAccessErrorClassForMethodDispatch(mirror::Class* referrer, mirror::Class* accessed, - const mirror::AbstractMethod* caller, - const mirror::AbstractMethod* called, + const mirror::ArtMethod* caller, + const mirror::ArtMethod* called, InvokeType type) { std::ostringstream msg; msg << "Illegal class access ('" << PrettyDescriptor(referrer) << "' attempting to access '" @@ -146,26 +146,27 @@ void ThrowIllegalAccessErrorClassForMethodDispatch(mirror::Class* referrer, mirr ThrowException(NULL, "Ljava/lang/IllegalAccessError;", referrer, msg.str().c_str()); } -void ThrowIllegalAccessErrorMethod(mirror::Class* referrer, mirror::AbstractMethod* accessed) { +void ThrowIllegalAccessErrorMethod(mirror::Class* referrer, mirror::ArtMethod* accessed) { std::ostringstream msg; msg << "Method '" << PrettyMethod(accessed) << "' is inaccessible to class '" << PrettyDescriptor(referrer) << "'"; ThrowException(NULL, "Ljava/lang/IllegalAccessError;", referrer, msg.str().c_str()); } -void ThrowIllegalAccessErrorField(mirror::Class* referrer, mirror::Field* accessed) { +void ThrowIllegalAccessErrorField(mirror::Class* referrer, mirror::ArtField* accessed) { std::ostringstream msg; msg << "Field '" << PrettyField(accessed, false) << "' is inaccessible to class '" << PrettyDescriptor(referrer) << "'"; ThrowException(NULL, "Ljava/lang/IllegalAccessError;", referrer, msg.str().c_str()); } -void ThrowIllegalAccessErrorFinalField(const mirror::AbstractMethod* referrer, - mirror::Field* accessed) { +void ThrowIllegalAccessErrorFinalField(const mirror::ArtMethod* referrer, + mirror::ArtField* accessed) { std::ostringstream msg; msg << "Final field '" << PrettyField(accessed, false) << "' cannot be written to by method '" << PrettyMethod(referrer) << "'"; - ThrowException(NULL, "Ljava/lang/IllegalAccessError;", referrer != NULL ? referrer->GetClass() : NULL, + ThrowException(NULL, "Ljava/lang/IllegalAccessError;", + referrer != NULL ? referrer->GetClass() : NULL, msg.str().c_str()); } @@ -186,8 +187,8 @@ void ThrowIllegalArgumentException(const ThrowLocation* throw_location, const ch // IncompatibleClassChangeError void ThrowIncompatibleClassChangeError(InvokeType expected_type, InvokeType found_type, - mirror::AbstractMethod* method, - const mirror::AbstractMethod* referrer) { + mirror::ArtMethod* method, + const mirror::ArtMethod* referrer) { std::ostringstream msg; msg << "The method '" << PrettyMethod(method) << "' was expected to be of type " << expected_type << " but instead was found to be of type " << found_type; @@ -196,9 +197,9 @@ void ThrowIncompatibleClassChangeError(InvokeType expected_type, InvokeType foun msg.str().c_str()); } -void ThrowIncompatibleClassChangeErrorClassForInterfaceDispatch(const mirror::AbstractMethod* interface_method, +void ThrowIncompatibleClassChangeErrorClassForInterfaceDispatch(const mirror::ArtMethod* interface_method, mirror::Object* this_object, - const mirror::AbstractMethod* referrer) { + const mirror::ArtMethod* referrer) { // Referrer is calling interface_method on this_object, however, the interface_method isn't // implemented by this_object. CHECK(this_object != NULL); @@ -212,8 +213,8 @@ void ThrowIncompatibleClassChangeErrorClassForInterfaceDispatch(const mirror::Ab msg.str().c_str()); } -void ThrowIncompatibleClassChangeErrorField(const mirror::Field* resolved_field, bool is_static, - const mirror::AbstractMethod* referrer) { +void ThrowIncompatibleClassChangeErrorField(const mirror::ArtField* resolved_field, bool is_static, + const mirror::ArtMethod* referrer) { std::ostringstream msg; msg << "Expected '" << PrettyField(resolved_field) << "' to be a " << (is_static ? "static" : "instance") << " field" << " rather than a " @@ -241,7 +242,8 @@ void ThrowLinkageError(const mirror::Class* referrer, const char* fmt, ...) { // NegativeArraySizeException void ThrowNegativeArraySizeException(int size) { - ThrowException(NULL, "Ljava/lang/NegativeArraySizeException;", NULL, StringPrintf("%d", size).c_str()); + ThrowException(NULL, "Ljava/lang/NegativeArraySizeException;", NULL, + StringPrintf("%d", size).c_str()); } void ThrowNegativeArraySizeException(const char* msg) { @@ -285,7 +287,7 @@ void ThrowNoSuchMethodError(uint32_t method_idx) { // NullPointerException void ThrowNullPointerExceptionForFieldAccess(const ThrowLocation& throw_location, - mirror::Field* field, bool is_read) { + mirror::ArtField* field, bool is_read) { std::ostringstream msg; msg << "Attempt to " << (is_read ? "read from" : "write to") << " field '" << PrettyField(field, true) << "' on a null object reference"; @@ -303,7 +305,8 @@ static void ThrowNullPointerExceptionForMethodAccessImpl(const ThrowLocation& th ThrowException(&throw_location, "Ljava/lang/NullPointerException;", NULL, msg.str().c_str()); } -void ThrowNullPointerExceptionForMethodAccess(const ThrowLocation& throw_location, uint32_t method_idx, +void ThrowNullPointerExceptionForMethodAccess(const ThrowLocation& throw_location, + uint32_t method_idx, InvokeType type) { mirror::DexCache* dex_cache = throw_location.GetMethod()->GetDeclaringClass()->GetDexCache(); const DexFile& dex_file = *dex_cache->GetDexFile(); @@ -312,7 +315,7 @@ void ThrowNullPointerExceptionForMethodAccess(const ThrowLocation& throw_locatio } void ThrowNullPointerExceptionForMethodAccess(const ThrowLocation& throw_location, - mirror::AbstractMethod* method, + mirror::ArtMethod* method, InvokeType type) { mirror::DexCache* dex_cache = method->GetDeclaringClass()->GetDexCache(); const DexFile& dex_file = *dex_cache->GetDexFile(); @@ -348,7 +351,7 @@ void ThrowNullPointerExceptionFromDexPC(const ThrowLocation& throw_location) { case Instruction::INVOKE_VIRTUAL_RANGE_QUICK: { // Since we replaced the method index, we ask the verifier to tell us which // method is invoked at this location. - mirror::AbstractMethod* method = + mirror::ArtMethod* method = verifier::MethodVerifier::FindInvokedMethodAtDexPc(throw_location.GetMethod(), throw_location.GetDexPc()); if (method != NULL) { @@ -368,7 +371,7 @@ void ThrowNullPointerExceptionFromDexPC(const ThrowLocation& throw_location) { case Instruction::IGET_BYTE: case Instruction::IGET_CHAR: case Instruction::IGET_SHORT: { - mirror::Field* field = + mirror::ArtField* field = Runtime::Current()->GetClassLinker()->ResolveField(instr->VRegC_22c(), throw_location.GetMethod(), false); ThrowNullPointerExceptionForFieldAccess(throw_location, field, true /* read */); @@ -379,7 +382,7 @@ void ThrowNullPointerExceptionFromDexPC(const ThrowLocation& throw_location) { case Instruction::IGET_OBJECT_QUICK: { // Since we replaced the field index, we ask the verifier to tell us which // field is accessed at this location. - mirror::Field* field = + mirror::ArtField* field = verifier::MethodVerifier::FindAccessedFieldAtDexPc(throw_location.GetMethod(), throw_location.GetDexPc()); if (field != NULL) { @@ -399,7 +402,7 @@ void ThrowNullPointerExceptionFromDexPC(const ThrowLocation& throw_location) { case Instruction::IPUT_BYTE: case Instruction::IPUT_CHAR: case Instruction::IPUT_SHORT: { - mirror::Field* field = + mirror::ArtField* field = Runtime::Current()->GetClassLinker()->ResolveField(instr->VRegC_22c(), throw_location.GetMethod(), false); ThrowNullPointerExceptionForFieldAccess(throw_location, field, false /* write */); @@ -410,7 +413,7 @@ void ThrowNullPointerExceptionFromDexPC(const ThrowLocation& throw_location) { case Instruction::IPUT_OBJECT_QUICK: { // Since we replaced the field index, we ask the verifier to tell us which // field is accessed at this location. - mirror::Field* field = + mirror::ArtField* field = verifier::MethodVerifier::FindAccessedFieldAtDexPc(throw_location.GetMethod(), throw_location.GetDexPc()); if (field != NULL) { diff --git a/runtime/common_throws.h b/runtime/common_throws.h index b7f2754df1..99c6343cdd 100644 --- a/runtime/common_throws.h +++ b/runtime/common_throws.h @@ -22,9 +22,9 @@ namespace art { namespace mirror { -class AbstractMethod; +class ArtField; +class ArtMethod; class Class; -class Field; class Object; } // namespace mirror class StringPiece; @@ -32,7 +32,7 @@ class ThrowLocation; // AbstractMethodError -void ThrowAbstractMethodError(const mirror::AbstractMethod* method) +void ThrowAbstractMethodError(const mirror::ArtMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // ArithmeticException @@ -74,19 +74,19 @@ void ThrowIllegalAccessErrorClass(mirror::Class* referrer, mirror::Class* access SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void ThrowIllegalAccessErrorClassForMethodDispatch(mirror::Class* referrer, mirror::Class* accessed, - const mirror::AbstractMethod* caller, - const mirror::AbstractMethod* called, + const mirror::ArtMethod* caller, + const mirror::ArtMethod* called, InvokeType type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); -void ThrowIllegalAccessErrorMethod(mirror::Class* referrer, mirror::AbstractMethod* accessed) +void ThrowIllegalAccessErrorMethod(mirror::Class* referrer, mirror::ArtMethod* accessed) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); -void ThrowIllegalAccessErrorField(mirror::Class* referrer, mirror::Field* accessed) +void ThrowIllegalAccessErrorField(mirror::Class* referrer, mirror::ArtField* accessed) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); -void ThrowIllegalAccessErrorFinalField(const mirror::AbstractMethod* referrer, - mirror::Field* accessed) +void ThrowIllegalAccessErrorFinalField(const mirror::ArtMethod* referrer, + mirror::ArtField* accessed) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void ThrowIllegalAccessError(mirror::Class* referrer, const char* fmt, ...) @@ -101,17 +101,17 @@ void ThrowIllegalArgumentException(const ThrowLocation* throw_location, const ch // IncompatibleClassChangeError void ThrowIncompatibleClassChangeError(InvokeType expected_type, InvokeType found_type, - mirror::AbstractMethod* method, - const mirror::AbstractMethod* referrer) + mirror::ArtMethod* method, + const mirror::ArtMethod* referrer) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); -void ThrowIncompatibleClassChangeErrorClassForInterfaceDispatch(const mirror::AbstractMethod* interface_method, +void ThrowIncompatibleClassChangeErrorClassForInterfaceDispatch(const mirror::ArtMethod* interface_method, mirror::Object* this_object, - const mirror::AbstractMethod* referrer) + const mirror::ArtMethod* referrer) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); -void ThrowIncompatibleClassChangeErrorField(const mirror::Field* resolved_field, bool is_static, - const mirror::AbstractMethod* referrer) +void ThrowIncompatibleClassChangeErrorField(const mirror::ArtField* resolved_field, bool is_static, + const mirror::ArtMethod* referrer) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void ThrowIncompatibleClassChangeError(const mirror::Class* referrer, const char* fmt, ...) @@ -149,7 +149,7 @@ void ThrowNoSuchMethodError(uint32_t method_idx) // NullPointerException void ThrowNullPointerExceptionForFieldAccess(const ThrowLocation& throw_location, - mirror::Field* field, + mirror::ArtField* field, bool is_read) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); @@ -159,7 +159,7 @@ void ThrowNullPointerExceptionForMethodAccess(const ThrowLocation& throw_locatio SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void ThrowNullPointerExceptionForMethodAccess(const ThrowLocation& throw_location, - mirror::AbstractMethod* method, + mirror::ArtMethod* method, InvokeType type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); diff --git a/runtime/debugger.cc b/runtime/debugger.cc index 3591a5097b..569a370b3f 100644 --- a/runtime/debugger.cc +++ b/runtime/debugger.cc @@ -30,11 +30,11 @@ #include "gc/space/space-inl.h" #include "invoke_arg_array_builder.h" #include "jdwp/object_registry.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_field-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class.h" #include "mirror/class-inl.h" #include "mirror/class_loader.h" -#include "mirror/field-inl.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" #include "mirror/throwable.h" @@ -60,7 +60,7 @@ static const size_t kMaxAllocRecordStackDepth = 16; // Max 255. static const size_t kDefaultNumAllocRecords = 64*1024; // Must be a power of 2. struct AllocRecordStackTraceElement { - mirror::AbstractMethod* method; + mirror::ArtMethod* method; uint32_t dex_pc; int32_t LineNumber() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { @@ -84,9 +84,9 @@ struct AllocRecord { }; struct Breakpoint { - mirror::AbstractMethod* method; + mirror::ArtMethod* method; uint32_t dex_pc; - Breakpoint(mirror::AbstractMethod* method, uint32_t dex_pc) : method(method), dex_pc(dex_pc) {} + Breakpoint(mirror::ArtMethod* method, uint32_t dex_pc) : method(method), dex_pc(dex_pc) {} }; static std::ostream& operator<<(std::ostream& os, const Breakpoint& rhs) @@ -103,7 +103,7 @@ struct SingleStepControl { JDWP::JdwpStepSize step_size; JDWP::JdwpStepDepth step_depth; - const mirror::AbstractMethod* method; + const mirror::ArtMethod* method; int32_t line_number; // Or -1 for native methods. std::set dex_pcs; int stack_depth; @@ -115,7 +115,7 @@ class DebugInstrumentationListener : public instrumentation::InstrumentationList virtual ~DebugInstrumentationListener() {} virtual void MethodEntered(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, uint32_t dex_pc) + const mirror::ArtMethod* method, uint32_t dex_pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { if (method->IsNative()) { // TODO: post location events is a suspension point and native method entry stubs aren't. @@ -125,7 +125,7 @@ class DebugInstrumentationListener : public instrumentation::InstrumentationList } virtual void MethodExited(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, + const mirror::ArtMethod* method, uint32_t dex_pc, const JValue& return_value) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { UNUSED(return_value); @@ -136,7 +136,7 @@ class DebugInstrumentationListener : public instrumentation::InstrumentationList Dbg::PostLocationEvent(method, dex_pc, this_object, Dbg::kMethodExit); } - virtual void MethodUnwind(Thread* thread, const mirror::AbstractMethod* method, + virtual void MethodUnwind(Thread* thread, const mirror::ArtMethod* method, uint32_t dex_pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { // We're not recorded to listen to this kind of event, so complain. LOG(ERROR) << "Unexpected method unwind event in debugger " << PrettyMethod(method) @@ -144,13 +144,13 @@ class DebugInstrumentationListener : public instrumentation::InstrumentationList } virtual void DexPcMoved(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, uint32_t new_dex_pc) + const mirror::ArtMethod* method, uint32_t new_dex_pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { Dbg::UpdateDebugger(thread, this_object, method, new_dex_pc); } virtual void ExceptionCaught(Thread* thread, const ThrowLocation& throw_location, - mirror::AbstractMethod* catch_method, uint32_t catch_dex_pc, + mirror::ArtMethod* catch_method, uint32_t catch_dex_pc, mirror::Throwable* exception_object) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { Dbg::PostException(thread, throw_location, catch_method, catch_dex_pc, exception_object); @@ -194,7 +194,7 @@ static size_t gAllocRecordCount GUARDED_BY(gAllocTrackerLock) = 0; static std::vector gBreakpoints GUARDED_BY(Locks::breakpoint_lock_); static SingleStepControl gSingleStepControl GUARDED_BY(Locks::breakpoint_lock_); -static bool IsBreakpoint(const mirror::AbstractMethod* m, uint32_t dex_pc) +static bool IsBreakpoint(const mirror::ArtMethod* m, uint32_t dex_pc) LOCKS_EXCLUDED(Locks::breakpoint_lock_) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { MutexLock mu(Thread::Current(), *Locks::breakpoint_lock_); @@ -1131,7 +1131,7 @@ bool Dbg::MatchType(JDWP::RefTypeId instance_class_id, JDWP::RefTypeId class_id) return c1->IsAssignableFrom(c2); } -static JDWP::FieldId ToFieldId(const mirror::Field* f) +static JDWP::FieldId ToFieldId(const mirror::ArtField* f) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { #ifdef MOVING_GARBAGE_COLLECTOR UNIMPLEMENTED(FATAL); @@ -1140,7 +1140,7 @@ static JDWP::FieldId ToFieldId(const mirror::Field* f) #endif } -static JDWP::MethodId ToMethodId(const mirror::AbstractMethod* m) +static JDWP::MethodId ToMethodId(const mirror::ArtMethod* m) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { #ifdef MOVING_GARBAGE_COLLECTOR UNIMPLEMENTED(FATAL); @@ -1149,25 +1149,25 @@ static JDWP::MethodId ToMethodId(const mirror::AbstractMethod* m) #endif } -static mirror::Field* FromFieldId(JDWP::FieldId fid) +static mirror::ArtField* FromFieldId(JDWP::FieldId fid) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { #ifdef MOVING_GARBAGE_COLLECTOR UNIMPLEMENTED(FATAL); #else - return reinterpret_cast(static_cast(fid)); + return reinterpret_cast(static_cast(fid)); #endif } -static mirror::AbstractMethod* FromMethodId(JDWP::MethodId mid) +static mirror::ArtMethod* FromMethodId(JDWP::MethodId mid) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { #ifdef MOVING_GARBAGE_COLLECTOR UNIMPLEMENTED(FATAL); #else - return reinterpret_cast(static_cast(mid)); + return reinterpret_cast(static_cast(mid)); #endif } -static void SetLocation(JDWP::JdwpLocation& location, mirror::AbstractMethod* m, uint32_t dex_pc) +static void SetLocation(JDWP::JdwpLocation& location, mirror::ArtMethod* m, uint32_t dex_pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { if (m == NULL) { memset(&location, 0, sizeof(location)); @@ -1182,13 +1182,13 @@ static void SetLocation(JDWP::JdwpLocation& location, mirror::AbstractMethod* m, std::string Dbg::GetMethodName(JDWP::MethodId method_id) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* m = FromMethodId(method_id); + mirror::ArtMethod* m = FromMethodId(method_id); return MethodHelper(m).GetName(); } std::string Dbg::GetFieldName(JDWP::FieldId field_id) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* f = FromFieldId(field_id); + mirror::ArtField* f = FromFieldId(field_id); return FieldHelper(f).GetName(); } @@ -1230,7 +1230,7 @@ static uint16_t MangleSlot(uint16_t slot, const char* name) { return newSlot; } -static uint16_t DemangleSlot(uint16_t slot, mirror::AbstractMethod* m) +static uint16_t DemangleSlot(uint16_t slot, mirror::ArtMethod* m) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { if (slot == kEclipseWorkaroundSlot) { return 0; @@ -1255,7 +1255,7 @@ JDWP::JdwpError Dbg::OutputDeclaredFields(JDWP::RefTypeId class_id, bool with_ge expandBufAdd4BE(pReply, instance_field_count + static_field_count); for (size_t i = 0; i < instance_field_count + static_field_count; ++i) { - mirror::Field* f = (i < instance_field_count) ? c->GetInstanceField(i) : c->GetStaticField(i - instance_field_count); + mirror::ArtField* f = (i < instance_field_count) ? c->GetInstanceField(i) : c->GetStaticField(i - instance_field_count); FieldHelper fh(f); expandBufAddFieldId(pReply, ToFieldId(f)); expandBufAddUtf8String(pReply, fh.GetName()); @@ -1283,7 +1283,7 @@ JDWP::JdwpError Dbg::OutputDeclaredMethods(JDWP::RefTypeId class_id, bool with_g expandBufAdd4BE(pReply, direct_method_count + virtual_method_count); for (size_t i = 0; i < direct_method_count + virtual_method_count; ++i) { - mirror::AbstractMethod* m = (i < direct_method_count) ? c->GetDirectMethod(i) : c->GetVirtualMethod(i - direct_method_count); + mirror::ArtMethod* m = (i < direct_method_count) ? c->GetDirectMethod(i) : c->GetVirtualMethod(i - direct_method_count); MethodHelper mh(m); expandBufAddMethodId(pReply, ToMethodId(m)); expandBufAddUtf8String(pReply, mh.GetName()); @@ -1327,7 +1327,7 @@ void Dbg::OutputLineTable(JDWP::RefTypeId, JDWP::MethodId method_id, JDWP::Expan return true; } }; - mirror::AbstractMethod* m = FromMethodId(method_id); + mirror::ArtMethod* m = FromMethodId(method_id); MethodHelper mh(m); uint64_t start, end; if (m->IsNative()) { @@ -1381,14 +1381,14 @@ void Dbg::OutputVariableTable(JDWP::RefTypeId, JDWP::MethodId method_id, bool wi ++pContext->variable_count; } }; - mirror::AbstractMethod* m = FromMethodId(method_id); + mirror::ArtMethod* m = FromMethodId(method_id); MethodHelper mh(m); const DexFile::CodeItem* code_item = mh.GetCodeItem(); // arg_count considers doubles and longs to take 2 units. // variable_count considers everything to take 1 unit. std::string shorty(mh.GetShorty()); - expandBufAdd4BE(pReply, mirror::AbstractMethod::NumArgRegisters(shorty)); + expandBufAdd4BE(pReply, mirror::ArtMethod::NumArgRegisters(shorty)); // We don't know the total number of variables yet, so leave a blank and update it later. size_t variable_count_offset = expandBufGetLength(pReply); @@ -1408,7 +1408,7 @@ void Dbg::OutputVariableTable(JDWP::RefTypeId, JDWP::MethodId method_id, bool wi JDWP::JdwpError Dbg::GetBytecodes(JDWP::RefTypeId, JDWP::MethodId method_id, std::vector& bytecodes) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* m = FromMethodId(method_id); + mirror::ArtMethod* m = FromMethodId(method_id); if (m == NULL) { return JDWP::ERR_INVALID_METHODID; } @@ -1445,7 +1445,7 @@ static JDWP::JdwpError GetFieldValueImpl(JDWP::RefTypeId ref_type_id, JDWP::Obje if ((!is_static && o == NULL) || o == ObjectRegistry::kInvalidObject) { return JDWP::ERR_INVALID_OBJECT; } - mirror::Field* f = FromFieldId(field_id); + mirror::ArtField* f = FromFieldId(field_id); mirror::Class* receiver_class = c; if (receiver_class == NULL && o != NULL) { @@ -1511,7 +1511,7 @@ static JDWP::JdwpError SetFieldValueImpl(JDWP::ObjectId object_id, JDWP::FieldId if ((!is_static && o == NULL) || o == ObjectRegistry::kInvalidObject) { return JDWP::ERR_INVALID_OBJECT; } - mirror::Field* f = FromFieldId(field_id); + mirror::ArtField* f = FromFieldId(field_id); // The RI only enforces the static/non-static mismatch in one direction. // TODO: should we change the tests and check both? @@ -1580,7 +1580,7 @@ JDWP::JdwpError Dbg::GetThreadName(JDWP::ObjectId thread_id, std::string& name) // We still need to report the zombie threads' names, so we can't just call Thread::GetThreadName. mirror::Object* thread_object = gRegistry->Get(thread_id); - mirror::Field* java_lang_Thread_name_field = + mirror::ArtField* java_lang_Thread_name_field = soa.DecodeField(WellKnownClasses::java_lang_Thread_name); mirror::String* s = reinterpret_cast(java_lang_Thread_name_field->GetObject(thread_object)); @@ -1612,7 +1612,7 @@ JDWP::JdwpError Dbg::GetThreadGroup(JDWP::ObjectId thread_id, JDWP::ExpandBuf* p mirror::Class* c = Runtime::Current()->GetClassLinker()->FindSystemClass("Ljava/lang/Thread;"); CHECK(c != NULL); - mirror::Field* f = c->FindInstanceField("group", "Ljava/lang/ThreadGroup;"); + mirror::ArtField* f = c->FindInstanceField("group", "Ljava/lang/ThreadGroup;"); CHECK(f != NULL); mirror::Object* group = f->GetObject(thread_object); CHECK(group != NULL); @@ -1629,7 +1629,7 @@ std::string Dbg::GetThreadGroupName(JDWP::ObjectId thread_group_id) { mirror::Class* c = Runtime::Current()->GetClassLinker()->FindSystemClass("Ljava/lang/ThreadGroup;"); CHECK(c != NULL); - mirror::Field* f = c->FindInstanceField("name", "Ljava/lang/String;"); + mirror::ArtField* f = c->FindInstanceField("name", "Ljava/lang/String;"); CHECK(f != NULL); mirror::String* s = reinterpret_cast(f->GetObject(thread_group)); return s->ToModifiedUtf8(); @@ -1641,7 +1641,7 @@ JDWP::ObjectId Dbg::GetThreadGroupParent(JDWP::ObjectId thread_group_id) { mirror::Class* c = Runtime::Current()->GetClassLinker()->FindSystemClass("Ljava/lang/ThreadGroup;"); CHECK(c != NULL); - mirror::Field* f = c->FindInstanceField("parent", "Ljava/lang/ThreadGroup;"); + mirror::ArtField* f = c->FindInstanceField("parent", "Ljava/lang/ThreadGroup;"); CHECK(f != NULL); mirror::Object* parent = f->GetObject(thread_group); return gRegistry->Add(parent); @@ -1649,14 +1649,14 @@ JDWP::ObjectId Dbg::GetThreadGroupParent(JDWP::ObjectId thread_group_id) { JDWP::ObjectId Dbg::GetSystemThreadGroupId() { ScopedObjectAccessUnchecked soa(Thread::Current()); - mirror::Field* f = soa.DecodeField(WellKnownClasses::java_lang_ThreadGroup_systemThreadGroup); + mirror::ArtField* f = soa.DecodeField(WellKnownClasses::java_lang_ThreadGroup_systemThreadGroup); mirror::Object* group = f->GetObject(f->GetDeclaringClass()); return gRegistry->Add(group); } JDWP::ObjectId Dbg::GetMainThreadGroupId() { ScopedObjectAccess soa(Thread::Current()); - mirror::Field* f = soa.DecodeField(WellKnownClasses::java_lang_ThreadGroup_mainThreadGroup); + mirror::ArtField* f = soa.DecodeField(WellKnownClasses::java_lang_ThreadGroup_mainThreadGroup); mirror::Object* group = f->GetObject(f->GetDeclaringClass()); return gRegistry->Add(group); } @@ -1793,12 +1793,12 @@ void Dbg::GetChildThreadGroups(JDWP::ObjectId thread_group_id, std::vectorGet(thread_group_id); // Get the ArrayList "groups" out of this thread group... - mirror::Field* groups_field = thread_group->GetClass()->FindInstanceField("groups", "Ljava/util/List;"); + mirror::ArtField* groups_field = thread_group->GetClass()->FindInstanceField("groups", "Ljava/util/List;"); mirror::Object* groups_array_list = groups_field->GetObject(thread_group); // Get the array and size out of the ArrayList... - mirror::Field* array_field = groups_array_list->GetClass()->FindInstanceField("array", "[Ljava/lang/Object;"); - mirror::Field* size_field = groups_array_list->GetClass()->FindInstanceField("size", "I"); + mirror::ArtField* array_field = groups_array_list->GetClass()->FindInstanceField("array", "[Ljava/lang/Object;"); + mirror::ArtField* size_field = groups_array_list->GetClass()->FindInstanceField("size", "I"); mirror::ObjectArray* groups_array = array_field->GetObject(groups_array_list)->AsObjectArray(); const int32_t size = size_field->GetInt(groups_array_list); @@ -2017,7 +2017,7 @@ void Dbg::GetLocalValue(JDWP::ObjectId thread_id, JDWP::FrameId frame_id, int sl return true; // Not our frame, carry on. } // TODO: check that the tag is compatible with the actual type of the slot! - mirror::AbstractMethod* m = GetMethod(); + mirror::ArtMethod* m = GetMethod(); uint16_t reg = DemangleSlot(slot_, m); switch (tag_) { @@ -2156,7 +2156,7 @@ void Dbg::SetLocalValue(JDWP::ObjectId thread_id, JDWP::FrameId frame_id, int sl return true; // Not our frame, carry on. } // TODO: check that the tag is compatible with the actual type of the slot! - mirror::AbstractMethod* m = GetMethod(); + mirror::ArtMethod* m = GetMethod(); uint16_t reg = DemangleSlot(slot_, m); switch (tag_) { @@ -2226,7 +2226,7 @@ void Dbg::SetLocalValue(JDWP::ObjectId thread_id, JDWP::FrameId frame_id, int sl visitor.WalkStack(); } -void Dbg::PostLocationEvent(const mirror::AbstractMethod* m, int dex_pc, +void Dbg::PostLocationEvent(const mirror::ArtMethod* m, int dex_pc, mirror::Object* this_object, int event_flags) { mirror::Class* c = m->GetDeclaringClass(); @@ -2246,7 +2246,7 @@ void Dbg::PostLocationEvent(const mirror::AbstractMethod* m, int dex_pc, } void Dbg::PostException(Thread* thread, const ThrowLocation& throw_location, - mirror::AbstractMethod* catch_method, + mirror::ArtMethod* catch_method, uint32_t catch_dex_pc, mirror::Throwable* exception_object) { if (!IsDebuggerActive()) { return; @@ -2280,7 +2280,7 @@ void Dbg::PostClassPrepare(mirror::Class* c) { } void Dbg::UpdateDebugger(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* m, uint32_t dex_pc) { + const mirror::ArtMethod* m, uint32_t dex_pc) { if (!IsDebuggerActive() || dex_pc == static_cast(-2) /* fake method exit */) { return; } @@ -2361,14 +2361,14 @@ void Dbg::UpdateDebugger(Thread* thread, mirror::Object* this_object, void Dbg::WatchLocation(const JDWP::JdwpLocation* location) { MutexLock mu(Thread::Current(), *Locks::breakpoint_lock_); - mirror::AbstractMethod* m = FromMethodId(location->method_id); + mirror::ArtMethod* m = FromMethodId(location->method_id); gBreakpoints.push_back(Breakpoint(m, location->dex_pc)); VLOG(jdwp) << "Set breakpoint #" << (gBreakpoints.size() - 1) << ": " << gBreakpoints[gBreakpoints.size() - 1]; } void Dbg::UnwatchLocation(const JDWP::JdwpLocation* location) { MutexLock mu(Thread::Current(), *Locks::breakpoint_lock_); - mirror::AbstractMethod* m = FromMethodId(location->method_id); + mirror::ArtMethod* m = FromMethodId(location->method_id); for (size_t i = 0; i < gBreakpoints.size(); ++i) { if (gBreakpoints[i].method == m && gBreakpoints[i].dex_pc == location->dex_pc) { VLOG(jdwp) << "Removed breakpoint #" << i << ": " << gBreakpoints[i]; @@ -2468,7 +2468,7 @@ JDWP::JdwpError Dbg::ConfigureStep(JDWP::ObjectId thread_id, JDWP::JdwpStepSize // annotalysis. bool VisitFrame() NO_THREAD_SAFETY_ANALYSIS { Locks::breakpoint_lock_->AssertHeld(Thread::Current()); - const mirror::AbstractMethod* m = GetMethod(); + const mirror::ArtMethod* m = GetMethod(); if (!m->IsRuntimeMethod()) { ++gSingleStepControl.stack_depth; if (gSingleStepControl.method == NULL) { @@ -2538,7 +2538,7 @@ JDWP::JdwpError Dbg::ConfigureStep(JDWP::ObjectId thread_id, JDWP::JdwpStepSize uint32_t last_pc; }; gSingleStepControl.dex_pcs.clear(); - const mirror::AbstractMethod* m = gSingleStepControl.method; + const mirror::ArtMethod* m = gSingleStepControl.method; if (m->IsNative()) { gSingleStepControl.line_number = -1; } else { @@ -2675,7 +2675,7 @@ JDWP::JdwpError Dbg::InvokeMethod(JDWP::ObjectId thread_id, JDWP::ObjectId objec return status; } - mirror::AbstractMethod* m = FromMethodId(method_id); + mirror::ArtMethod* m = FromMethodId(method_id); if (m->IsStatic() != (receiver == NULL)) { return JDWP::ERR_INVALID_METHODID; } @@ -2798,7 +2798,7 @@ void Dbg::ExecuteMethod(DebugInvokeReq* pReq) { // We can be called while an exception is pending. We need // to preserve that across the method invocation. SirtRef old_throw_this_object(soa.Self(), NULL); - SirtRef old_throw_method(soa.Self(), NULL); + SirtRef old_throw_method(soa.Self(), NULL); SirtRef old_exception(soa.Self(), NULL); uint32_t old_throw_dex_pc; { @@ -2812,9 +2812,9 @@ void Dbg::ExecuteMethod(DebugInvokeReq* pReq) { } // Translate the method through the vtable, unless the debugger wants to suppress it. - mirror::AbstractMethod* m = pReq->method_; + mirror::ArtMethod* m = pReq->method_; if ((pReq->options_ & JDWP::INVOKE_NONVIRTUAL) == 0 && pReq->receiver_ != NULL) { - mirror::AbstractMethod* actual_method = pReq->class_->FindVirtualMethodForVirtualOrInterface(pReq->method_); + mirror::ArtMethod* actual_method = pReq->class_->FindVirtualMethodForVirtualOrInterface(pReq->method_); if (actual_method != m) { VLOG(jdwp) << "ExecuteMethod translated " << PrettyMethod(m) << " to " << PrettyMethod(actual_method); m = actual_method; @@ -3491,7 +3491,7 @@ struct AllocRecordStackVisitor : public StackVisitor { if (depth >= kMaxAllocRecordStackDepth) { return false; } - mirror::AbstractMethod* m = GetMethod(); + mirror::ArtMethod* m = GetMethod(); if (!m->IsRuntimeMethod()) { record->stack[depth].method = m; record->stack[depth].dex_pc = GetDexPc(); @@ -3574,7 +3574,7 @@ void Dbg::DumpRecentAllocations() { << PrettyClass(record->type); for (size_t stack_frame = 0; stack_frame < kMaxAllocRecordStackDepth; ++stack_frame) { - const mirror::AbstractMethod* m = record->stack[stack_frame].method; + const mirror::ArtMethod* m = record->stack[stack_frame].method; if (m == NULL) { break; } @@ -3695,7 +3695,7 @@ jbyteArray Dbg::GetRecentAllocations() { MethodHelper mh; for (size_t i = 0; i < kMaxAllocRecordStackDepth; i++) { - mirror::AbstractMethod* m = record->stack[i].method; + mirror::ArtMethod* m = record->stack[i].method; if (m != NULL) { mh.ChangeMethod(m); class_names.Add(mh.GetDeclaringClassDescriptor()); diff --git a/runtime/debugger.h b/runtime/debugger.h index 6b7e2ba6e8..2282305ac2 100644 --- a/runtime/debugger.h +++ b/runtime/debugger.h @@ -32,7 +32,7 @@ namespace art { namespace mirror { -class AbstractMethod; +class ArtMethod; class Class; class Object; class Throwable; @@ -64,7 +64,7 @@ struct DebugInvokeReq { mirror::Object* receiver_; /* not used for ClassType.InvokeMethod */ mirror::Object* thread_; mirror::Class* class_; - mirror::AbstractMethod* method_; + mirror::ArtMethod* method_; uint32_t arg_count_; uint64_t* arg_values_; /* will be NULL if arg_count_ == 0 */ uint32_t options_; @@ -324,11 +324,11 @@ class Dbg { kMethodEntry = 0x04, kMethodExit = 0x08, }; - static void PostLocationEvent(const mirror::AbstractMethod* method, int pcOffset, + static void PostLocationEvent(const mirror::ArtMethod* method, int pcOffset, mirror::Object* thisPtr, int eventFlags) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); static void PostException(Thread* thread, const ThrowLocation& throw_location, - mirror::AbstractMethod* catch_method, + mirror::ArtMethod* catch_method, uint32_t catch_dex_pc, mirror::Throwable* exception) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); static void PostThreadStart(Thread* t) @@ -339,7 +339,7 @@ class Dbg { SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); static void UpdateDebugger(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, uint32_t new_dex_pc) + const mirror::ArtMethod* method, uint32_t new_dex_pc) LOCKS_EXCLUDED(Locks::breakpoint_lock_) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); diff --git a/runtime/dex_file.cc b/runtime/dex_file.cc index aaff0fc6da..45b34270f9 100644 --- a/runtime/dex_file.cc +++ b/runtime/dex_file.cc @@ -31,9 +31,8 @@ #include "dex_file_verifier.h" #include "globals.h" #include "leb128.h" -#include "mirror/abstract_method-inl.h" -#include "mirror/field.h" -#include "mirror/field-inl.h" +#include "mirror/art_field-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/string.h" #include "os.h" #include "safe_map.h" @@ -624,7 +623,7 @@ std::string DexFile::CreateMethodSignature(uint32_t proto_idx, int32_t* unicode_ return descriptor; } -int32_t DexFile::GetLineNumFromPC(const mirror::AbstractMethod* method, uint32_t rel_pc) const { +int32_t DexFile::GetLineNumFromPC(const mirror::ArtMethod* method, uint32_t rel_pc) const { // For native method, lineno should be -2 to indicate it is native. Note that // "line number == -2" is how libcore tells from StackTraceElement. if (method->GetCodeItemOffset() == 0) { @@ -1024,7 +1023,7 @@ void EncodedStaticFieldValueIterator::Next() { ptr_ += width; } -void EncodedStaticFieldValueIterator::ReadValueToField(mirror::Field* field) const { +void EncodedStaticFieldValueIterator::ReadValueToField(mirror::ArtField* field) const { switch (type_) { case kBoolean: field->SetBoolean(field->GetDeclaringClass(), jval_.z); break; case kByte: field->SetByte(field->GetDeclaringClass(), jval_.b); break; diff --git a/runtime/dex_file.h b/runtime/dex_file.h index a60a1398d8..006b692c85 100644 --- a/runtime/dex_file.h +++ b/runtime/dex_file.h @@ -34,10 +34,10 @@ namespace art { namespace mirror { -class AbstractMethod; -class ClassLoader; -class DexCache; -class Field; + class ArtField; + class ArtMethod; + class ClassLoader; + class DexCache; } // namespace mirror class ClassLinker; class ZipArchive; @@ -786,7 +786,7 @@ class DexFile { // Returns -2 for native methods (as expected in exception traces). // // This is used by runtime; therefore use art::Method not art::DexFile::Method. - int32_t GetLineNumFromPC(const mirror::AbstractMethod* method, uint32_t rel_pc) const + int32_t GetLineNumFromPC(const mirror::ArtMethod* method, uint32_t rel_pc) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void DecodeDebugInfo(const CodeItem* code_item, bool is_static, uint32_t method_idx, @@ -1135,7 +1135,7 @@ class EncodedStaticFieldValueIterator { ClassLinker* linker, const DexFile::ClassDef& class_def) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void ReadValueToField(mirror::Field* field) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + void ReadValueToField(mirror::ArtField* field) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); bool HasNext() { return pos_ < array_size_; } diff --git a/runtime/entrypoints/entrypoint_utils.cc b/runtime/entrypoints/entrypoint_utils.cc index c29784151c..6b8c41ed41 100644 --- a/runtime/entrypoints/entrypoint_utils.cc +++ b/runtime/entrypoints/entrypoint_utils.cc @@ -19,9 +19,9 @@ #include "class_linker-inl.h" #include "dex_file-inl.h" #include "gc/accounting/card_table-inl.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_field-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" -#include "mirror/field-inl.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" #include "mirror/proxy.h" @@ -33,7 +33,7 @@ namespace art { // Helper function to allocate array for FILLED_NEW_ARRAY. -mirror::Array* CheckAndAllocArrayFromCode(uint32_t type_idx, mirror::AbstractMethod* referrer, +mirror::Array* CheckAndAllocArrayFromCode(uint32_t type_idx, mirror::ArtMethod* referrer, int32_t component_count, Thread* self, bool access_check) { if (UNLIKELY(component_count < 0)) { @@ -73,7 +73,7 @@ mirror::Array* CheckAndAllocArrayFromCode(uint32_t type_idx, mirror::AbstractMet } } -mirror::Field* FindFieldFromCode(uint32_t field_idx, const mirror::AbstractMethod* referrer, +mirror::ArtField* FindFieldFromCode(uint32_t field_idx, const mirror::ArtMethod* referrer, Thread* self, FindFieldType type, size_t expected_size, bool access_check) { bool is_primitive; @@ -91,7 +91,7 @@ mirror::Field* FindFieldFromCode(uint32_t field_idx, const mirror::AbstractMetho default: is_primitive = true; is_set = true; is_static = true; break; } ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); - mirror::Field* resolved_field = class_linker->ResolveField(field_idx, referrer, is_static); + mirror::ArtField* resolved_field = class_linker->ResolveField(field_idx, referrer, is_static); if (UNLIKELY(resolved_field == NULL)) { DCHECK(self->IsExceptionPending()); // Throw exception and unwind. return NULL; // Failure. @@ -158,12 +158,12 @@ mirror::Field* FindFieldFromCode(uint32_t field_idx, const mirror::AbstractMetho } // Slow path method resolution -mirror::AbstractMethod* FindMethodFromCode(uint32_t method_idx, mirror::Object* this_object, - mirror::AbstractMethod* referrer, +mirror::ArtMethod* FindMethodFromCode(uint32_t method_idx, mirror::Object* this_object, + mirror::ArtMethod* referrer, Thread* self, bool access_check, InvokeType type) { ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); bool is_direct = type == kStatic || type == kDirect; - mirror::AbstractMethod* resolved_method = class_linker->ResolveMethod(method_idx, referrer, type); + mirror::ArtMethod* resolved_method = class_linker->ResolveMethod(method_idx, referrer, type); if (UNLIKELY(resolved_method == NULL)) { DCHECK(self->IsExceptionPending()); // Throw exception and unwind. return NULL; // Failure. @@ -179,7 +179,7 @@ mirror::AbstractMethod* FindMethodFromCode(uint32_t method_idx, mirror::Object* if (is_direct) { return resolved_method; } else if (type == kInterface) { - mirror::AbstractMethod* interface_method = + mirror::ArtMethod* interface_method = this_object->GetClass()->FindVirtualMethodForInterface(resolved_method); if (UNLIKELY(interface_method == NULL)) { ThrowIncompatibleClassChangeErrorClassForInterfaceDispatch(resolved_method, this_object, @@ -189,7 +189,7 @@ mirror::AbstractMethod* FindMethodFromCode(uint32_t method_idx, mirror::Object* return interface_method; } } else { - mirror::ObjectArray* vtable; + mirror::ObjectArray* vtable; uint16_t vtable_index = resolved_method->GetMethodIndex(); if (type == kSuper) { vtable = referrer->GetDeclaringClass()->GetSuperClass()->GetVTable(); @@ -231,7 +231,7 @@ mirror::AbstractMethod* FindMethodFromCode(uint32_t method_idx, mirror::Object* if (is_direct) { return resolved_method; } else if (type == kInterface) { - mirror::AbstractMethod* interface_method = + mirror::ArtMethod* interface_method = this_object->GetClass()->FindVirtualMethodForInterface(resolved_method); if (UNLIKELY(interface_method == NULL)) { ThrowIncompatibleClassChangeErrorClassForInterfaceDispatch(resolved_method, this_object, @@ -241,7 +241,7 @@ mirror::AbstractMethod* FindMethodFromCode(uint32_t method_idx, mirror::Object* return interface_method; } } else { - mirror::ObjectArray* vtable; + mirror::ObjectArray* vtable; uint16_t vtable_index = resolved_method->GetMethodIndex(); if (type == kSuper) { mirror::Class* super_class = referring_class->GetSuperClass(); @@ -326,17 +326,15 @@ JValue InvokeProxyInvocationHandler(ScopedObjectAccessUnchecked& soa, const char } } - // Call InvocationHandler.invoke(Object proxy, Method method, Object[] args). - jobject inv_hand = soa.Env()->GetObjectField(rcvr_jobj, - WellKnownClasses::java_lang_reflect_Proxy_h); + // Call Proxy.invoke(Proxy proxy, ArtMethod method, Object[] args). jvalue invocation_args[3]; invocation_args[0].l = rcvr_jobj; invocation_args[1].l = interface_method_jobj; invocation_args[2].l = args_jobj; jobject result = - soa.Env()->CallObjectMethodA(inv_hand, - WellKnownClasses::java_lang_reflect_InvocationHandler_invoke, - invocation_args); + soa.Env()->CallStaticObjectMethodA(WellKnownClasses::java_lang_reflect_Proxy, + WellKnownClasses::java_lang_reflect_Proxy_invoke, + invocation_args); // Unbox result and handle error conditions. if (LIKELY(!soa.Self()->IsExceptionPending())) { @@ -346,10 +344,10 @@ JValue InvokeProxyInvocationHandler(ScopedObjectAccessUnchecked& soa, const char } else { mirror::Object* result_ref = soa.Decode(result); mirror::Object* rcvr = soa.Decode(rcvr_jobj); - mirror::AbstractMethod* interface_method = - soa.Decode(interface_method_jobj); + mirror::ArtMethod* interface_method = + soa.Decode(interface_method_jobj); mirror::Class* result_type = MethodHelper(interface_method).GetReturnType(); - mirror::AbstractMethod* proxy_method; + mirror::ArtMethod* proxy_method; if (interface_method->GetDeclaringClass()->IsInterface()) { proxy_method = rcvr->GetClass()->FindVirtualMethodForInterface(interface_method); } else { @@ -373,9 +371,9 @@ JValue InvokeProxyInvocationHandler(ScopedObjectAccessUnchecked& soa, const char mirror::Object* rcvr = soa.Decode(rcvr_jobj); mirror::SynthesizedProxyClass* proxy_class = down_cast(rcvr->GetClass()); - mirror::AbstractMethod* interface_method = - soa.Decode(interface_method_jobj); - mirror::AbstractMethod* proxy_method = + mirror::ArtMethod* interface_method = + soa.Decode(interface_method_jobj); + mirror::ArtMethod* proxy_method = rcvr->GetClass()->FindVirtualMethodForInterface(interface_method); int throws_index = -1; size_t num_virt_methods = proxy_class->NumVirtualMethods(); diff --git a/runtime/entrypoints/entrypoint_utils.h b/runtime/entrypoints/entrypoint_utils.h index b6781c02b9..2b73af437e 100644 --- a/runtime/entrypoints/entrypoint_utils.h +++ b/runtime/entrypoints/entrypoint_utils.h @@ -23,7 +23,7 @@ #include "indirect_reference_table.h" #include "invoke_type.h" #include "jni_internal.h" -#include "mirror/abstract_method.h" +#include "mirror/art_method.h" #include "mirror/array.h" #include "mirror/class-inl.h" #include "mirror/throwable.h" @@ -34,7 +34,7 @@ namespace art { namespace mirror { class Class; - class Field; + class ArtField; class Object; } // namespace mirror @@ -42,7 +42,7 @@ namespace mirror { // cannot be resolved, throw an error. If it can, use it to create an instance. // When verification/compiler hasn't been able to verify access, optionally perform an access // check. -static inline mirror::Object* AllocObjectFromCode(uint32_t type_idx, mirror::AbstractMethod* method, +static inline mirror::Object* AllocObjectFromCode(uint32_t type_idx, mirror::ArtMethod* method, Thread* self, bool access_check) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { @@ -80,7 +80,7 @@ static inline mirror::Object* AllocObjectFromCode(uint32_t type_idx, mirror::Abs // it cannot be resolved, throw an error. If it can, use it to create an array. // When verification/compiler hasn't been able to verify access, optionally perform an access // check. -static inline mirror::Array* AllocArrayFromCode(uint32_t type_idx, mirror::AbstractMethod* method, +static inline mirror::Array* AllocArrayFromCode(uint32_t type_idx, mirror::ArtMethod* method, int32_t component_count, Thread* self, bool access_check) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { @@ -107,7 +107,7 @@ static inline mirror::Array* AllocArrayFromCode(uint32_t type_idx, mirror::Abstr return mirror::Array::Alloc(self, klass, component_count); } -extern mirror::Array* CheckAndAllocArrayFromCode(uint32_t type_idx, mirror::AbstractMethod* method, +extern mirror::Array* CheckAndAllocArrayFromCode(uint32_t type_idx, mirror::ArtMethod* method, int32_t component_count, Thread* self, bool access_check) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); @@ -125,17 +125,17 @@ enum FindFieldType { }; // Slow field find that can initialize classes and may throw exceptions. -extern mirror::Field* FindFieldFromCode(uint32_t field_idx, const mirror::AbstractMethod* referrer, - Thread* self, FindFieldType type, size_t expected_size, - bool access_check) +extern mirror::ArtField* FindFieldFromCode(uint32_t field_idx, const mirror::ArtMethod* referrer, + Thread* self, FindFieldType type, size_t expected_size, + bool access_check) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Fast path field resolution that can't initialize classes or throw exceptions. -static inline mirror::Field* FindFieldFast(uint32_t field_idx, - const mirror::AbstractMethod* referrer, - FindFieldType type, size_t expected_size) +static inline mirror::ArtField* FindFieldFast(uint32_t field_idx, + const mirror::ArtMethod* referrer, + FindFieldType type, size_t expected_size) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* resolved_field = + mirror::ArtField* resolved_field = referrer->GetDeclaringClass()->GetDexCache()->GetResolvedField(field_idx); if (UNLIKELY(resolved_field == NULL)) { return NULL; @@ -186,16 +186,16 @@ static inline mirror::Field* FindFieldFast(uint32_t field_idx, } // Fast path method resolution that can't throw exceptions. -static inline mirror::AbstractMethod* FindMethodFast(uint32_t method_idx, - mirror::Object* this_object, - const mirror::AbstractMethod* referrer, - bool access_check, InvokeType type) +static inline mirror::ArtMethod* FindMethodFast(uint32_t method_idx, + mirror::Object* this_object, + const mirror::ArtMethod* referrer, + bool access_check, InvokeType type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { bool is_direct = type == kStatic || type == kDirect; if (UNLIKELY(this_object == NULL && !is_direct)) { return NULL; } - mirror::AbstractMethod* resolved_method = + mirror::ArtMethod* resolved_method = referrer->GetDeclaringClass()->GetDexCache()->GetResolvedMethod(method_idx); if (UNLIKELY(resolved_method == NULL)) { return NULL; @@ -228,13 +228,13 @@ static inline mirror::AbstractMethod* FindMethodFast(uint32_t method_idx, } } -extern mirror::AbstractMethod* FindMethodFromCode(uint32_t method_idx, mirror::Object* this_object, - mirror::AbstractMethod* referrer, - Thread* self, bool access_check, InvokeType type) +extern mirror::ArtMethod* FindMethodFromCode(uint32_t method_idx, mirror::Object* this_object, + mirror::ArtMethod* referrer, + Thread* self, bool access_check, InvokeType type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); static inline mirror::Class* ResolveVerifyAndClinit(uint32_t type_idx, - const mirror::AbstractMethod* referrer, + const mirror::ArtMethod* referrer, Thread* self, bool can_run_clinit, bool verify_access) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { @@ -271,7 +271,7 @@ static inline mirror::Class* ResolveVerifyAndClinit(uint32_t type_idx, extern void ThrowStackOverflowError(Thread* self) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); -static inline mirror::String* ResolveStringFromCode(const mirror::AbstractMethod* referrer, +static inline mirror::String* ResolveStringFromCode(const mirror::ArtMethod* referrer, uint32_t string_idx) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); @@ -307,7 +307,7 @@ static inline void CheckReferenceResult(mirror::Object* o, Thread* self) if (o == NULL) { return; } - mirror::AbstractMethod* m = self->GetCurrentMethod(NULL); + mirror::ArtMethod* m = self->GetCurrentMethod(NULL); if (o == kInvalidIndirectRefObject) { JniAbortF(NULL, "invalid reference returned from %s", PrettyMethod(m).c_str()); } @@ -334,7 +334,7 @@ static inline void CheckSuspend(Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mut } JValue InvokeProxyInvocationHandler(ScopedObjectAccessUnchecked& soa, const char* shorty, - jobject rcvr_jobj, jobject interface_method_jobj, + jobject rcvr_jobj, jobject interface_art_method_jobj, std::vector& args) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); @@ -356,12 +356,12 @@ static inline uintptr_t GetQuickInstrumentationExitPc() { return reinterpret_cast(art_quick_instrumentation_exit); } -extern "C" void art_portable_to_interpreter_bridge(mirror::AbstractMethod*); +extern "C" void art_portable_to_interpreter_bridge(mirror::ArtMethod*); static inline const void* GetPortableToInterpreterBridge() { return reinterpret_cast(art_portable_to_interpreter_bridge); } -extern "C" void art_quick_to_interpreter_bridge(mirror::AbstractMethod*); +extern "C" void art_quick_to_interpreter_bridge(mirror::ArtMethod*); static inline const void* GetQuickToInterpreterBridge() { return reinterpret_cast(art_quick_to_interpreter_bridge); } diff --git a/runtime/entrypoints/interpreter/interpreter_entrypoints.cc b/runtime/entrypoints/interpreter/interpreter_entrypoints.cc index 67f6d98493..f319a0084b 100644 --- a/runtime/entrypoints/interpreter/interpreter_entrypoints.cc +++ b/runtime/entrypoints/interpreter/interpreter_entrypoints.cc @@ -17,7 +17,7 @@ #include "class_linker.h" #include "interpreter/interpreter.h" #include "invoke_arg_array_builder.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/object-inl.h" #include "object_utils.h" #include "runtime.h" @@ -29,7 +29,7 @@ extern "C" void artInterpreterToCompiledCodeBridge(Thread* self, MethodHelper& m const DexFile::CodeItem* code_item, ShadowFrame* shadow_frame, JValue* result) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* method = shadow_frame->GetMethod(); + mirror::ArtMethod* method = shadow_frame->GetMethod(); // Ensure static methods are initialized. if (method->IsStatic()) { Runtime::Current()->GetClassLinker()->EnsureInitialized(method->GetDeclaringClass(), true, true); diff --git a/runtime/entrypoints/jni/jni_entrypoints.cc b/runtime/entrypoints/jni/jni_entrypoints.cc index 88b4936255..83d3a584c5 100644 --- a/runtime/entrypoints/jni/jni_entrypoints.cc +++ b/runtime/entrypoints/jni/jni_entrypoints.cc @@ -16,7 +16,7 @@ #include "base/logging.h" #include "entrypoints/entrypoint_utils.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/object-inl.h" #include "object_utils.h" #include "scoped_thread_state_change.h" @@ -30,7 +30,7 @@ extern "C" void* artFindNativeMethod() { Locks::mutator_lock_->AssertNotHeld(self); // We come here as Native. ScopedObjectAccess soa(self); - mirror::AbstractMethod* method = self->GetCurrentMethod(NULL); + mirror::ArtMethod* method = self->GetCurrentMethod(NULL); DCHECK(method != NULL); // Lookup symbol address for method, on failure we'll return NULL with an exception set, @@ -69,7 +69,7 @@ extern "C" const void* artWorkAroundAppJniBugs(Thread* self, intptr_t* sp) // | unused | // | unused | // | unused | <- sp - mirror::AbstractMethod* jni_method = self->GetCurrentMethod(NULL); + mirror::ArtMethod* jni_method = self->GetCurrentMethod(NULL); DCHECK(jni_method->IsNative()) << PrettyMethod(jni_method); intptr_t* arg_ptr = sp + 4; // pointer to r1 on stack // Fix up this/jclass argument diff --git a/runtime/entrypoints/portable/portable_alloc_entrypoints.cc b/runtime/entrypoints/portable/portable_alloc_entrypoints.cc index 286926909c..91b7353bab 100644 --- a/runtime/entrypoints/portable/portable_alloc_entrypoints.cc +++ b/runtime/entrypoints/portable/portable_alloc_entrypoints.cc @@ -15,27 +15,27 @@ */ #include "entrypoints/entrypoint_utils.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/object-inl.h" namespace art { extern "C" mirror::Object* art_portable_alloc_object_from_code(uint32_t type_idx, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return AllocObjectFromCode(type_idx, referrer, thread, false); } extern "C" mirror::Object* art_portable_alloc_object_from_code_with_access_check(uint32_t type_idx, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return AllocObjectFromCode(type_idx, referrer, thread, true); } extern "C" mirror::Object* art_portable_alloc_array_from_code(uint32_t type_idx, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, uint32_t length, Thread* self) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { @@ -43,7 +43,7 @@ extern "C" mirror::Object* art_portable_alloc_array_from_code(uint32_t type_idx, } extern "C" mirror::Object* art_portable_alloc_array_from_code_with_access_check(uint32_t type_idx, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, uint32_t length, Thread* self) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { @@ -51,7 +51,7 @@ extern "C" mirror::Object* art_portable_alloc_array_from_code_with_access_check( } extern "C" mirror::Object* art_portable_check_and_alloc_array_from_code(uint32_t type_idx, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, uint32_t length, Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { @@ -59,7 +59,7 @@ extern "C" mirror::Object* art_portable_check_and_alloc_array_from_code(uint32_t } extern "C" mirror::Object* art_portable_check_and_alloc_array_from_code_with_access_check(uint32_t type_idx, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, uint32_t length, Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { diff --git a/runtime/entrypoints/portable/portable_dexcache_entrypoints.cc b/runtime/entrypoints/portable/portable_dexcache_entrypoints.cc index bdab587797..b37ebcf785 100644 --- a/runtime/entrypoints/portable/portable_dexcache_entrypoints.cc +++ b/runtime/entrypoints/portable/portable_dexcache_entrypoints.cc @@ -16,27 +16,27 @@ #include "entrypoints/entrypoint_utils.h" #include "gc/accounting/card_table-inl.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/object-inl.h" namespace art { extern "C" mirror::Object* art_portable_initialize_static_storage_from_code(uint32_t type_idx, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return ResolveVerifyAndClinit(type_idx, referrer, thread, true, false); } extern "C" mirror::Object* art_portable_initialize_type_from_code(uint32_t type_idx, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return ResolveVerifyAndClinit(type_idx, referrer, thread, false, false); } extern "C" mirror::Object* art_portable_initialize_type_and_verify_access_from_code(uint32_t type_idx, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { // Called when caller isn't guaranteed to have access to a type and the dex cache may be @@ -44,7 +44,7 @@ extern "C" mirror::Object* art_portable_initialize_type_and_verify_access_from_c return ResolveVerifyAndClinit(type_idx, referrer, thread, false, true); } -extern "C" mirror::Object* art_portable_resolve_string_from_code(mirror::AbstractMethod* referrer, +extern "C" mirror::Object* art_portable_resolve_string_from_code(mirror::ArtMethod* referrer, uint32_t string_idx) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return ResolveStringFromCode(referrer, string_idx); diff --git a/runtime/entrypoints/portable/portable_entrypoints.h b/runtime/entrypoints/portable/portable_entrypoints.h index ec9e4f8a7d..d4564471ac 100644 --- a/runtime/entrypoints/portable/portable_entrypoints.h +++ b/runtime/entrypoints/portable/portable_entrypoints.h @@ -22,7 +22,7 @@ namespace art { namespace mirror { - class AbstractMethod; + class ArtMethod; class Object; } // namespace mirror class Thread; @@ -35,8 +35,8 @@ class Thread; // compiler ABI. struct PACKED(4) PortableEntryPoints { // Invocation - void (*pPortableResolutionTrampoline)(mirror::AbstractMethod*); - void (*pPortableToInterpreterBridge)(mirror::AbstractMethod*); + void (*pPortableResolutionTrampoline)(mirror::ArtMethod*); + void (*pPortableToInterpreterBridge)(mirror::ArtMethod*); }; } // namespace art diff --git a/runtime/entrypoints/portable/portable_field_entrypoints.cc b/runtime/entrypoints/portable/portable_field_entrypoints.cc index aa0f03ce8b..bd6f79584b 100644 --- a/runtime/entrypoints/portable/portable_field_entrypoints.cc +++ b/runtime/entrypoints/portable/portable_field_entrypoints.cc @@ -15,17 +15,17 @@ */ #include "entrypoints/entrypoint_utils.h" -#include "mirror/abstract_method-inl.h" -#include "mirror/field-inl.h" +#include "mirror/art_field-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/object-inl.h" namespace art { extern "C" int32_t art_portable_set32_static_from_code(uint32_t field_idx, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, int32_t new_value) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, + mirror::ArtField* field = FindFieldFast(field_idx, referrer, StaticPrimitiveWrite, sizeof(uint32_t)); @@ -47,10 +47,10 @@ extern "C" int32_t art_portable_set32_static_from_code(uint32_t field_idx, } extern "C" int32_t art_portable_set64_static_from_code(uint32_t field_idx, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, int64_t new_value) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, StaticPrimitiveWrite, sizeof(uint64_t)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, StaticPrimitiveWrite, sizeof(uint64_t)); if (LIKELY(field != NULL)) { field->Set64(field->GetDeclaringClass(), new_value); return 0; @@ -69,11 +69,11 @@ extern "C" int32_t art_portable_set64_static_from_code(uint32_t field_idx, } extern "C" int32_t art_portable_set_obj_static_from_code(uint32_t field_idx, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, mirror::Object* new_value) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, StaticObjectWrite, - sizeof(mirror::Object*)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, StaticObjectWrite, + sizeof(mirror::Object*)); if (LIKELY(field != NULL)) { field->SetObj(field->GetDeclaringClass(), new_value); return 0; @@ -88,9 +88,9 @@ extern "C" int32_t art_portable_set_obj_static_from_code(uint32_t field_idx, } extern "C" int32_t art_portable_get32_static_from_code(uint32_t field_idx, - mirror::AbstractMethod* referrer) + mirror::ArtMethod* referrer) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, StaticPrimitiveRead, sizeof(uint32_t)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, StaticPrimitiveRead, sizeof(uint32_t)); if (LIKELY(field != NULL)) { return field->Get32(field->GetDeclaringClass()); } @@ -103,9 +103,9 @@ extern "C" int32_t art_portable_get32_static_from_code(uint32_t field_idx, } extern "C" int64_t art_portable_get64_static_from_code(uint32_t field_idx, - mirror::AbstractMethod* referrer) + mirror::ArtMethod* referrer) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, StaticPrimitiveRead, sizeof(uint64_t)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, StaticPrimitiveRead, sizeof(uint64_t)); if (LIKELY(field != NULL)) { return field->Get64(field->GetDeclaringClass()); } @@ -118,10 +118,10 @@ extern "C" int64_t art_portable_get64_static_from_code(uint32_t field_idx, } extern "C" mirror::Object* art_portable_get_obj_static_from_code(uint32_t field_idx, - mirror::AbstractMethod* referrer) + mirror::ArtMethod* referrer) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, StaticObjectRead, - sizeof(mirror::Object*)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, StaticObjectRead, + sizeof(mirror::Object*)); if (LIKELY(field != NULL)) { return field->GetObj(field->GetDeclaringClass()); } @@ -134,10 +134,10 @@ extern "C" mirror::Object* art_portable_get_obj_static_from_code(uint32_t field_ } extern "C" int32_t art_portable_set32_instance_from_code(uint32_t field_idx, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, mirror::Object* obj, uint32_t new_value) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, InstancePrimitiveWrite, sizeof(uint32_t)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, InstancePrimitiveWrite, sizeof(uint32_t)); if (LIKELY(field != NULL)) { field->Set32(obj, new_value); return 0; @@ -152,10 +152,10 @@ extern "C" int32_t art_portable_set32_instance_from_code(uint32_t field_idx, } extern "C" int32_t art_portable_set64_instance_from_code(uint32_t field_idx, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, mirror::Object* obj, int64_t new_value) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, InstancePrimitiveWrite, sizeof(uint64_t)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, InstancePrimitiveWrite, sizeof(uint64_t)); if (LIKELY(field != NULL)) { field->Set64(obj, new_value); return 0; @@ -170,12 +170,12 @@ extern "C" int32_t art_portable_set64_instance_from_code(uint32_t field_idx, } extern "C" int32_t art_portable_set_obj_instance_from_code(uint32_t field_idx, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, mirror::Object* obj, mirror::Object* new_value) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, InstanceObjectWrite, - sizeof(mirror::Object*)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, InstanceObjectWrite, + sizeof(mirror::Object*)); if (LIKELY(field != NULL)) { field->SetObj(obj, new_value); return 0; @@ -190,10 +190,10 @@ extern "C" int32_t art_portable_set_obj_instance_from_code(uint32_t field_idx, } extern "C" int32_t art_portable_get32_instance_from_code(uint32_t field_idx, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, mirror::Object* obj) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, InstancePrimitiveRead, sizeof(uint32_t)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, InstancePrimitiveRead, sizeof(uint32_t)); if (LIKELY(field != NULL)) { return field->Get32(obj); } @@ -206,10 +206,10 @@ extern "C" int32_t art_portable_get32_instance_from_code(uint32_t field_idx, } extern "C" int64_t art_portable_get64_instance_from_code(uint32_t field_idx, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, mirror::Object* obj) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, InstancePrimitiveRead, sizeof(uint64_t)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, InstancePrimitiveRead, sizeof(uint64_t)); if (LIKELY(field != NULL)) { return field->Get64(obj); } @@ -222,11 +222,11 @@ extern "C" int64_t art_portable_get64_instance_from_code(uint32_t field_idx, } extern "C" mirror::Object* art_portable_get_obj_instance_from_code(uint32_t field_idx, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, mirror::Object* obj) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, InstanceObjectRead, - sizeof(mirror::Object*)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, InstanceObjectRead, + sizeof(mirror::Object*)); if (LIKELY(field != NULL)) { return field->GetObj(obj); } diff --git a/runtime/entrypoints/portable/portable_fillarray_entrypoints.cc b/runtime/entrypoints/portable/portable_fillarray_entrypoints.cc index 771608b604..8cf4eed88f 100644 --- a/runtime/entrypoints/portable/portable_fillarray_entrypoints.cc +++ b/runtime/entrypoints/portable/portable_fillarray_entrypoints.cc @@ -16,12 +16,12 @@ #include "dex_instruction.h" #include "entrypoints/entrypoint_utils.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/object-inl.h" namespace art { -extern "C" void art_portable_fill_array_data_from_code(mirror::AbstractMethod* method, +extern "C" void art_portable_fill_array_data_from_code(mirror::ArtMethod* method, uint32_t dex_pc, mirror::Array* array, uint32_t payload_offset) diff --git a/runtime/entrypoints/portable/portable_invoke_entrypoints.cc b/runtime/entrypoints/portable/portable_invoke_entrypoints.cc index 5911ba3d8b..14cbd84186 100644 --- a/runtime/entrypoints/portable/portable_invoke_entrypoints.cc +++ b/runtime/entrypoints/portable/portable_invoke_entrypoints.cc @@ -15,20 +15,20 @@ */ #include "entrypoints/entrypoint_utils.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/dex_cache-inl.h" #include "mirror/object-inl.h" namespace art { -static mirror::AbstractMethod* FindMethodHelper(uint32_t method_idx, +static mirror::ArtMethod* FindMethodHelper(uint32_t method_idx, mirror::Object* this_object, - mirror::AbstractMethod* caller_method, + mirror::ArtMethod* caller_method, bool access_check, InvokeType type, Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* method = FindMethodFast(method_idx, + mirror::ArtMethod* method = FindMethodFast(method_idx, this_object, caller_method, access_check, @@ -55,7 +55,7 @@ static mirror::AbstractMethod* FindMethodHelper(uint32_t method_idx, extern "C" mirror::Object* art_portable_find_static_method_from_code_with_access_check(uint32_t method_idx, mirror::Object* this_object, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return FindMethodHelper(method_idx, this_object, referrer, true, kStatic, thread); @@ -63,7 +63,7 @@ extern "C" mirror::Object* art_portable_find_static_method_from_code_with_access extern "C" mirror::Object* art_portable_find_direct_method_from_code_with_access_check(uint32_t method_idx, mirror::Object* this_object, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return FindMethodHelper(method_idx, this_object, referrer, true, kDirect, thread); @@ -71,7 +71,7 @@ extern "C" mirror::Object* art_portable_find_direct_method_from_code_with_access extern "C" mirror::Object* art_portable_find_virtual_method_from_code_with_access_check(uint32_t method_idx, mirror::Object* this_object, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return FindMethodHelper(method_idx, this_object, referrer, true, kVirtual, thread); @@ -79,7 +79,7 @@ extern "C" mirror::Object* art_portable_find_virtual_method_from_code_with_acces extern "C" mirror::Object* art_portable_find_super_method_from_code_with_access_check(uint32_t method_idx, mirror::Object* this_object, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return FindMethodHelper(method_idx, this_object, referrer, true, kSuper, thread); @@ -87,7 +87,7 @@ extern "C" mirror::Object* art_portable_find_super_method_from_code_with_access_ extern "C" mirror::Object* art_portable_find_interface_method_from_code_with_access_check(uint32_t method_idx, mirror::Object* this_object, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return FindMethodHelper(method_idx, this_object, referrer, true, kInterface, thread); @@ -95,7 +95,7 @@ extern "C" mirror::Object* art_portable_find_interface_method_from_code_with_acc extern "C" mirror::Object* art_portable_find_interface_method_from_code(uint32_t method_idx, mirror::Object* this_object, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return FindMethodHelper(method_idx, this_object, referrer, false, kInterface, thread); diff --git a/runtime/entrypoints/portable/portable_jni_entrypoints.cc b/runtime/entrypoints/portable/portable_jni_entrypoints.cc index 8df16ae931..de1e32ef17 100644 --- a/runtime/entrypoints/portable/portable_jni_entrypoints.cc +++ b/runtime/entrypoints/portable/portable_jni_entrypoints.cc @@ -15,7 +15,7 @@ */ #include "entrypoints/entrypoint_utils.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/object-inl.h" #include "thread-inl.h" diff --git a/runtime/entrypoints/portable/portable_thread_entrypoints.cc b/runtime/entrypoints/portable/portable_thread_entrypoints.cc index dac73885a5..8a2c8998aa 100644 --- a/runtime/entrypoints/portable/portable_thread_entrypoints.cc +++ b/runtime/entrypoints/portable/portable_thread_entrypoints.cc @@ -15,7 +15,7 @@ */ #include "entrypoints/entrypoint_utils.h" -#include "mirror/abstract_method.h" +#include "mirror/art_method.h" #include "mirror/object-inl.h" #include "verifier/dex_gc_map.h" #include "stack.h" @@ -31,7 +31,7 @@ class ShadowFrameCopyVisitor : public StackVisitor { if (IsShadowFrame()) { ShadowFrame* cur_frame = GetCurrentShadowFrame(); size_t num_regs = cur_frame->NumberOfVRegs(); - mirror::AbstractMethod* method = cur_frame->GetMethod(); + mirror::ArtMethod* method = cur_frame->GetMethod(); uint32_t dex_pc = cur_frame->GetDexPC(); ShadowFrame* new_frame = ShadowFrame::Create(num_regs, NULL, method, dex_pc); @@ -88,7 +88,7 @@ extern "C" void art_portable_test_suspend_from_code(Thread* self) extern "C" ShadowFrame* art_portable_push_shadow_frame_from_code(Thread* thread, ShadowFrame* new_shadow_frame, - mirror::AbstractMethod* method, + mirror::ArtMethod* method, uint32_t num_vregs) { ShadowFrame* old_frame = thread->PushShadowFrame(new_shadow_frame); new_shadow_frame->SetMethod(method); diff --git a/runtime/entrypoints/portable/portable_throw_entrypoints.cc b/runtime/entrypoints/portable/portable_throw_entrypoints.cc index 64a67ebb4c..2a0df9b896 100644 --- a/runtime/entrypoints/portable/portable_throw_entrypoints.cc +++ b/runtime/entrypoints/portable/portable_throw_entrypoints.cc @@ -16,7 +16,7 @@ #include "dex_instruction.h" #include "entrypoints/entrypoint_utils.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/object-inl.h" namespace art { @@ -68,7 +68,7 @@ extern "C" void* art_portable_get_and_clear_exception(Thread* self) return exception; } -extern "C" int32_t art_portable_find_catch_block_from_code(mirror::AbstractMethod* current_method, +extern "C" int32_t art_portable_find_catch_block_from_code(mirror::ArtMethod* current_method, uint32_t ti_offset) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { Thread* self = Thread::Current(); // TODO: make an argument. diff --git a/runtime/entrypoints/portable/portable_trampoline_entrypoints.cc b/runtime/entrypoints/portable/portable_trampoline_entrypoints.cc index c02ace88c1..e1ce11a825 100644 --- a/runtime/entrypoints/portable/portable_trampoline_entrypoints.cc +++ b/runtime/entrypoints/portable/portable_trampoline_entrypoints.cc @@ -20,7 +20,7 @@ #include "dex_instruction-inl.h" #include "entrypoints/entrypoint_utils.h" #include "interpreter/interpreter.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/object-inl.h" #include "object_utils.h" #include "scoped_thread_state_change.h" @@ -52,7 +52,7 @@ class PortableArgumentVisitor { #define PORTABLE_STACK_ARG_SKIP 0 #endif - PortableArgumentVisitor(MethodHelper& caller_mh, mirror::AbstractMethod** sp) + PortableArgumentVisitor(MethodHelper& caller_mh, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) : caller_mh_(caller_mh), args_in_regs_(ComputeArgsInRegs(caller_mh)), @@ -140,7 +140,7 @@ class PortableArgumentVisitor { // Visits arguments on the stack placing them into the shadow frame. class BuildPortableShadowFrameVisitor : public PortableArgumentVisitor { public: - BuildPortableShadowFrameVisitor(MethodHelper& caller_mh, mirror::AbstractMethod** sp, + BuildPortableShadowFrameVisitor(MethodHelper& caller_mh, mirror::ArtMethod** sp, ShadowFrame& sf, size_t first_arg_reg) : PortableArgumentVisitor(caller_mh, sp), sf_(sf), cur_reg_(first_arg_reg) { } virtual void Visit() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { @@ -176,8 +176,8 @@ class BuildPortableShadowFrameVisitor : public PortableArgumentVisitor { DISALLOW_COPY_AND_ASSIGN(BuildPortableShadowFrameVisitor); }; -extern "C" uint64_t artPortableToInterpreterBridge(mirror::AbstractMethod* method, Thread* self, - mirror::AbstractMethod** sp) +extern "C" uint64_t artPortableToInterpreterBridge(mirror::ArtMethod* method, Thread* self, + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { // Ensure we don't get thread suspension until the object arguments are safely in the shadow // frame. @@ -225,7 +225,7 @@ extern "C" uint64_t artPortableToInterpreterBridge(mirror::AbstractMethod* metho // to jobjects. class BuildPortableArgumentVisitor : public PortableArgumentVisitor { public: - BuildPortableArgumentVisitor(MethodHelper& caller_mh, mirror::AbstractMethod** sp, + BuildPortableArgumentVisitor(MethodHelper& caller_mh, mirror::ArtMethod** sp, ScopedObjectAccessUnchecked& soa, std::vector& args) : PortableArgumentVisitor(caller_mh, sp), soa_(soa), args_(args) {} @@ -269,9 +269,9 @@ class BuildPortableArgumentVisitor : public PortableArgumentVisitor { // which is responsible for recording callee save registers. We explicitly place into jobjects the // incoming reference arguments (so they survive GC). We invoke the invocation handler, which is a // field within the proxy object, which will box the primitive arguments and deal with error cases. -extern "C" uint64_t artPortableProxyInvokeHandler(mirror::AbstractMethod* proxy_method, +extern "C" uint64_t artPortableProxyInvokeHandler(mirror::ArtMethod* proxy_method, mirror::Object* receiver, - Thread* self, mirror::AbstractMethod** sp) + Thread* self, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { // Ensure we don't get thread suspension until the object arguments are safely in jobjects. const char* old_cause = @@ -292,7 +292,7 @@ extern "C" uint64_t artPortableProxyInvokeHandler(mirror::AbstractMethod* proxy_ args.erase(args.begin()); // Convert proxy method into expected interface method. - mirror::AbstractMethod* interface_method = proxy_method->FindOverriddenMethod(); + mirror::ArtMethod* interface_method = proxy_method->FindOverriddenMethod(); DCHECK(interface_method != NULL); DCHECK(!interface_method->IsProxyMethod()) << PrettyMethod(interface_method); jobject interface_method_jobj = soa.AddLocalReference(interface_method); @@ -306,13 +306,13 @@ extern "C" uint64_t artPortableProxyInvokeHandler(mirror::AbstractMethod* proxy_ } // Lazily resolve a method for portable. Called by stub code. -extern "C" const void* artPortableResolutionTrampoline(mirror::AbstractMethod* called, +extern "C" const void* artPortableResolutionTrampoline(mirror::ArtMethod* called, mirror::Object* receiver, Thread* thread, - mirror::AbstractMethod** called_addr) + mirror::ArtMethod** called_addr) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { uint32_t dex_pc; - mirror::AbstractMethod* caller = thread->GetCurrentMethod(&dex_pc); + mirror::ArtMethod* caller = thread->GetCurrentMethod(&dex_pc); ClassLinker* linker = Runtime::Current()->GetClassLinker(); InvokeType invoke_type; diff --git a/runtime/entrypoints/quick/callee_save_frame.h b/runtime/entrypoints/quick/callee_save_frame.h index 0cb578ddd0..8f7004920d 100644 --- a/runtime/entrypoints/quick/callee_save_frame.h +++ b/runtime/entrypoints/quick/callee_save_frame.h @@ -22,11 +22,11 @@ namespace art { namespace mirror { -class AbstractMethod; +class ArtMethod; } // namespace mirror // Place a special frame at the TOS that will save the callee saves for the given type. -static void FinishCalleeSaveFrameSetup(Thread* self, mirror::AbstractMethod** sp, +static void FinishCalleeSaveFrameSetup(Thread* self, mirror::ArtMethod** sp, Runtime::CalleeSaveType type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { // Be aware the store below may well stomp on an incoming argument. diff --git a/runtime/entrypoints/quick/quick_alloc_entrypoints.cc b/runtime/entrypoints/quick/quick_alloc_entrypoints.cc index 9ed802a2bb..420e63a1bb 100644 --- a/runtime/entrypoints/quick/quick_alloc_entrypoints.cc +++ b/runtime/entrypoints/quick/quick_alloc_entrypoints.cc @@ -16,61 +16,61 @@ #include "callee_save_frame.h" #include "entrypoints/entrypoint_utils.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" -#include "mirror/abstract_method-inl.h" #include "mirror/object_array-inl.h" #include "mirror/object-inl.h" namespace art { -extern "C" mirror::Object* artAllocObjectFromCode(uint32_t type_idx, mirror::AbstractMethod* method, - Thread* self, mirror::AbstractMethod** sp) +extern "C" mirror::Object* artAllocObjectFromCode(uint32_t type_idx, mirror::ArtMethod* method, + Thread* self, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly); return AllocObjectFromCode(type_idx, method, self, false); } extern "C" mirror::Object* artAllocObjectFromCodeWithAccessCheck(uint32_t type_idx, - mirror::AbstractMethod* method, + mirror::ArtMethod* method, Thread* self, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly); return AllocObjectFromCode(type_idx, method, self, true); } -extern "C" mirror::Array* artAllocArrayFromCode(uint32_t type_idx, mirror::AbstractMethod* method, +extern "C" mirror::Array* artAllocArrayFromCode(uint32_t type_idx, mirror::ArtMethod* method, int32_t component_count, Thread* self, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly); return AllocArrayFromCode(type_idx, method, component_count, self, false); } extern "C" mirror::Array* artAllocArrayFromCodeWithAccessCheck(uint32_t type_idx, - mirror::AbstractMethod* method, + mirror::ArtMethod* method, int32_t component_count, Thread* self, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly); return AllocArrayFromCode(type_idx, method, component_count, self, true); } extern "C" mirror::Array* artCheckAndAllocArrayFromCode(uint32_t type_idx, - mirror::AbstractMethod* method, + mirror::ArtMethod* method, int32_t component_count, Thread* self, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly); return CheckAndAllocArrayFromCode(type_idx, method, component_count, self, false); } extern "C" mirror::Array* artCheckAndAllocArrayFromCodeWithAccessCheck(uint32_t type_idx, - mirror::AbstractMethod* method, + mirror::ArtMethod* method, int32_t component_count, Thread* self, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly); return CheckAndAllocArrayFromCode(type_idx, method, component_count, self, true); diff --git a/runtime/entrypoints/quick/quick_cast_entrypoints.cc b/runtime/entrypoints/quick/quick_cast_entrypoints.cc index b810bb70a6..9ffa736614 100644 --- a/runtime/entrypoints/quick/quick_cast_entrypoints.cc +++ b/runtime/entrypoints/quick/quick_cast_entrypoints.cc @@ -33,7 +33,7 @@ extern "C" uint32_t artIsAssignableFromCode(const mirror::Class* klass, // Check whether it is safe to cast one class to the other, throw exception and return -1 on failure extern "C" int artCheckCastFromCode(mirror::Class* src_type, mirror::Class* dest_type, - Thread* self, mirror::AbstractMethod** sp) + Thread* self, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { DCHECK(src_type->IsClass()) << PrettyClass(src_type); DCHECK(dest_type->IsClass()) << PrettyClass(dest_type); @@ -50,7 +50,7 @@ extern "C" int artCheckCastFromCode(mirror::Class* src_type, mirror::Class* dest // Returns 0 on success and -1 if an exception is pending. extern "C" int artCanPutArrayElementFromCode(const mirror::Object* element, const mirror::Class* array_class, - Thread* self, mirror::AbstractMethod** sp) + Thread* self, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { DCHECK(array_class != NULL); // element can't be NULL as we catch this is screened in runtime_support diff --git a/runtime/entrypoints/quick/quick_deoptimization_entrypoints.cc b/runtime/entrypoints/quick/quick_deoptimization_entrypoints.cc index 43fc9d2a2d..51c647adf1 100644 --- a/runtime/entrypoints/quick/quick_deoptimization_entrypoints.cc +++ b/runtime/entrypoints/quick/quick_deoptimization_entrypoints.cc @@ -17,7 +17,7 @@ #include "callee_save_frame.h" #include "dex_file-inl.h" #include "interpreter/interpreter.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/object_array-inl.h" #include "mirror/object-inl.h" @@ -28,7 +28,7 @@ namespace art { -extern "C" void artDeoptimize(Thread* self, mirror::AbstractMethod** sp) +extern "C" void artDeoptimize(Thread* self, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { FinishCalleeSaveFrameSetup(self, sp, Runtime::kSaveAll); self->SetException(ThrowLocation(), reinterpret_cast(-1)); diff --git a/runtime/entrypoints/quick/quick_dexcache_entrypoints.cc b/runtime/entrypoints/quick/quick_dexcache_entrypoints.cc index 6400161b3e..003047a5f8 100644 --- a/runtime/entrypoints/quick/quick_dexcache_entrypoints.cc +++ b/runtime/entrypoints/quick/quick_dexcache_entrypoints.cc @@ -19,16 +19,16 @@ #include "class_linker-inl.h" #include "dex_file-inl.h" #include "gc/accounting/card_table-inl.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/object_array-inl.h" #include "mirror/object-inl.h" namespace art { extern "C" mirror::Class* artInitializeStaticStorageFromCode(uint32_t type_idx, - const mirror::AbstractMethod* referrer, + const mirror::ArtMethod* referrer, Thread* self, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { // Called to ensure static storage base is initialized for direct static field reads and writes. // A class may be accessing another class' fields when it doesn't have access, as access has been @@ -38,8 +38,8 @@ extern "C" mirror::Class* artInitializeStaticStorageFromCode(uint32_t type_idx, } extern "C" mirror::Class* artInitializeTypeFromCode(uint32_t type_idx, - const mirror::AbstractMethod* referrer, - Thread* self, mirror::AbstractMethod** sp) + const mirror::ArtMethod* referrer, + Thread* self, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { // Called when method->dex_cache_resolved_types_[] misses. FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly); @@ -47,9 +47,9 @@ extern "C" mirror::Class* artInitializeTypeFromCode(uint32_t type_idx, } extern "C" mirror::Class* artInitializeTypeAndVerifyAccessFromCode(uint32_t type_idx, - const mirror::AbstractMethod* referrer, + const mirror::ArtMethod* referrer, Thread* self, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { // Called when caller isn't guaranteed to have access to a type and the dex cache may be // unpopulated. @@ -57,9 +57,9 @@ extern "C" mirror::Class* artInitializeTypeAndVerifyAccessFromCode(uint32_t type return ResolveVerifyAndClinit(type_idx, referrer, self, false, true); } -extern "C" mirror::String* artResolveStringFromCode(mirror::AbstractMethod* referrer, +extern "C" mirror::String* artResolveStringFromCode(mirror::ArtMethod* referrer, int32_t string_idx, - Thread* self, mirror::AbstractMethod** sp) + Thread* self, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly); return ResolveStringFromCode(referrer, string_idx); diff --git a/runtime/entrypoints/quick/quick_entrypoints.h b/runtime/entrypoints/quick/quick_entrypoints.h index e76679b91f..9d3b8ef27c 100644 --- a/runtime/entrypoints/quick/quick_entrypoints.h +++ b/runtime/entrypoints/quick/quick_entrypoints.h @@ -29,9 +29,9 @@ namespace art { namespace mirror { - class AbstractMethod; - class Class; - class Object; +class ArtMethod; +class Class; +class Object; } // namespace mirror class Thread; @@ -116,8 +116,8 @@ struct PACKED(4) QuickEntryPoints { void* (*pMemcpy)(void*, const void*, size_t); // Invocation - void (*pQuickResolutionTrampoline)(mirror::AbstractMethod*); - void (*pQuickToInterpreterBridge)(mirror::AbstractMethod*); + void (*pQuickResolutionTrampoline)(mirror::ArtMethod*); + void (*pQuickToInterpreterBridge)(mirror::ArtMethod*); void (*pInvokeDirectTrampolineWithAccessCheck)(uint32_t, void*); void (*pInvokeInterfaceTrampoline)(uint32_t, void*); void (*pInvokeInterfaceTrampolineWithAccessCheck)(uint32_t, void*); diff --git a/runtime/entrypoints/quick/quick_field_entrypoints.cc b/runtime/entrypoints/quick/quick_field_entrypoints.cc index a4e9dc9b27..0ec1eb7920 100644 --- a/runtime/entrypoints/quick/quick_field_entrypoints.cc +++ b/runtime/entrypoints/quick/quick_field_entrypoints.cc @@ -17,19 +17,20 @@ #include "callee_save_frame.h" #include "dex_file-inl.h" #include "entrypoints/entrypoint_utils.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_field-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" -#include "mirror/field-inl.h" #include namespace art { extern "C" uint32_t artGet32StaticFromCode(uint32_t field_idx, - const mirror::AbstractMethod* referrer, - Thread* self, mirror::AbstractMethod** sp) + const mirror::ArtMethod* referrer, + Thread* self, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, StaticPrimitiveRead, sizeof(int32_t)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, StaticPrimitiveRead, + sizeof(int32_t)); if (LIKELY(field != NULL)) { return field->Get32(field->GetDeclaringClass()); } @@ -42,10 +43,11 @@ extern "C" uint32_t artGet32StaticFromCode(uint32_t field_idx, } extern "C" uint64_t artGet64StaticFromCode(uint32_t field_idx, - const mirror::AbstractMethod* referrer, - Thread* self, mirror::AbstractMethod** sp) + const mirror::ArtMethod* referrer, + Thread* self, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, StaticPrimitiveRead, sizeof(int64_t)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, StaticPrimitiveRead, + sizeof(int64_t)); if (LIKELY(field != NULL)) { return field->Get64(field->GetDeclaringClass()); } @@ -58,16 +60,17 @@ extern "C" uint64_t artGet64StaticFromCode(uint32_t field_idx, } extern "C" mirror::Object* artGetObjStaticFromCode(uint32_t field_idx, - const mirror::AbstractMethod* referrer, - Thread* self, mirror::AbstractMethod** sp) + const mirror::ArtMethod* referrer, + Thread* self, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, StaticObjectRead, + mirror::ArtField* field = FindFieldFast(field_idx, referrer, StaticObjectRead, sizeof(mirror::Object*)); if (LIKELY(field != NULL)) { return field->GetObj(field->GetDeclaringClass()); } FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly); - field = FindFieldFromCode(field_idx, referrer, self, StaticObjectRead, sizeof(mirror::Object*), true); + field = FindFieldFromCode(field_idx, referrer, self, StaticObjectRead, sizeof(mirror::Object*), + true); if (LIKELY(field != NULL)) { return field->GetObj(field->GetDeclaringClass()); } @@ -75,15 +78,17 @@ extern "C" mirror::Object* artGetObjStaticFromCode(uint32_t field_idx, } extern "C" uint32_t artGet32InstanceFromCode(uint32_t field_idx, mirror::Object* obj, - const mirror::AbstractMethod* referrer, Thread* self, - mirror::AbstractMethod** sp) + const mirror::ArtMethod* referrer, Thread* self, + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, InstancePrimitiveRead, sizeof(int32_t)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, InstancePrimitiveRead, + sizeof(int32_t)); if (LIKELY(field != NULL && obj != NULL)) { return field->Get32(obj); } FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly); - field = FindFieldFromCode(field_idx, referrer, self, InstancePrimitiveRead, sizeof(int32_t), true); + field = FindFieldFromCode(field_idx, referrer, self, InstancePrimitiveRead, sizeof(int32_t), + true); if (LIKELY(field != NULL)) { if (UNLIKELY(obj == NULL)) { ThrowLocation throw_location = self->GetCurrentLocationForThrow(); @@ -96,15 +101,17 @@ extern "C" uint32_t artGet32InstanceFromCode(uint32_t field_idx, mirror::Object* } extern "C" uint64_t artGet64InstanceFromCode(uint32_t field_idx, mirror::Object* obj, - const mirror::AbstractMethod* referrer, Thread* self, - mirror::AbstractMethod** sp) + const mirror::ArtMethod* referrer, Thread* self, + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, InstancePrimitiveRead, sizeof(int64_t)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, InstancePrimitiveRead, + sizeof(int64_t)); if (LIKELY(field != NULL && obj != NULL)) { return field->Get64(obj); } FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly); - field = FindFieldFromCode(field_idx, referrer, self, InstancePrimitiveRead, sizeof(int64_t), true); + field = FindFieldFromCode(field_idx, referrer, self, InstancePrimitiveRead, sizeof(int64_t), + true); if (LIKELY(field != NULL)) { if (UNLIKELY(obj == NULL)) { ThrowLocation throw_location = self->GetCurrentLocationForThrow(); @@ -117,16 +124,18 @@ extern "C" uint64_t artGet64InstanceFromCode(uint32_t field_idx, mirror::Object* } extern "C" mirror::Object* artGetObjInstanceFromCode(uint32_t field_idx, mirror::Object* obj, - const mirror::AbstractMethod* referrer, + const mirror::ArtMethod* referrer, Thread* self, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, InstanceObjectRead, sizeof(mirror::Object*)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, InstanceObjectRead, + sizeof(mirror::Object*)); if (LIKELY(field != NULL && obj != NULL)) { return field->GetObj(obj); } FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly); - field = FindFieldFromCode(field_idx, referrer, self, InstanceObjectRead, sizeof(mirror::Object*), true); + field = FindFieldFromCode(field_idx, referrer, self, InstanceObjectRead, sizeof(mirror::Object*), + true); if (LIKELY(field != NULL)) { if (UNLIKELY(obj == NULL)) { ThrowLocation throw_location = self->GetCurrentLocationForThrow(); @@ -139,10 +148,11 @@ extern "C" mirror::Object* artGetObjInstanceFromCode(uint32_t field_idx, mirror: } extern "C" int artSet32StaticFromCode(uint32_t field_idx, uint32_t new_value, - const mirror::AbstractMethod* referrer, Thread* self, - mirror::AbstractMethod** sp) + const mirror::ArtMethod* referrer, Thread* self, + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, StaticPrimitiveWrite, sizeof(int32_t)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, StaticPrimitiveWrite, + sizeof(int32_t)); if (LIKELY(field != NULL)) { field->Set32(field->GetDeclaringClass(), new_value); return 0; // success @@ -156,10 +166,11 @@ extern "C" int artSet32StaticFromCode(uint32_t field_idx, uint32_t new_value, return -1; // failure } -extern "C" int artSet64StaticFromCode(uint32_t field_idx, const mirror::AbstractMethod* referrer, - uint64_t new_value, Thread* self, mirror::AbstractMethod** sp) +extern "C" int artSet64StaticFromCode(uint32_t field_idx, const mirror::ArtMethod* referrer, + uint64_t new_value, Thread* self, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, StaticPrimitiveWrite, sizeof(int64_t)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, StaticPrimitiveWrite, + sizeof(int64_t)); if (LIKELY(field != NULL)) { field->Set64(field->GetDeclaringClass(), new_value); return 0; // success @@ -174,11 +185,11 @@ extern "C" int artSet64StaticFromCode(uint32_t field_idx, const mirror::Abstract } extern "C" int artSetObjStaticFromCode(uint32_t field_idx, mirror::Object* new_value, - const mirror::AbstractMethod* referrer, Thread* self, - mirror::AbstractMethod** sp) + const mirror::ArtMethod* referrer, Thread* self, + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, StaticObjectWrite, - sizeof(mirror::Object*)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, StaticObjectWrite, + sizeof(mirror::Object*)); if (LIKELY(field != NULL)) { if (LIKELY(!FieldHelper(field).IsPrimitiveType())) { field->SetObj(field->GetDeclaringClass(), new_value); @@ -195,16 +206,18 @@ extern "C" int artSetObjStaticFromCode(uint32_t field_idx, mirror::Object* new_v } extern "C" int artSet32InstanceFromCode(uint32_t field_idx, mirror::Object* obj, uint32_t new_value, - const mirror::AbstractMethod* referrer, Thread* self, - mirror::AbstractMethod** sp) + const mirror::ArtMethod* referrer, Thread* self, + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, InstancePrimitiveWrite, sizeof(int32_t)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, InstancePrimitiveWrite, + sizeof(int32_t)); if (LIKELY(field != NULL && obj != NULL)) { field->Set32(obj, new_value); return 0; // success } FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly); - field = FindFieldFromCode(field_idx, referrer, self, InstancePrimitiveWrite, sizeof(int32_t), true); + field = FindFieldFromCode(field_idx, referrer, self, InstancePrimitiveWrite, sizeof(int32_t), + true); if (LIKELY(field != NULL)) { if (UNLIKELY(obj == NULL)) { ThrowLocation throw_location = self->GetCurrentLocationForThrow(); @@ -218,20 +231,21 @@ extern "C" int artSet32InstanceFromCode(uint32_t field_idx, mirror::Object* obj, } extern "C" int artSet64InstanceFromCode(uint32_t field_idx, mirror::Object* obj, uint64_t new_value, - Thread* self, mirror::AbstractMethod** sp) + Thread* self, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* callee_save = Runtime::Current()->GetCalleeSaveMethod(Runtime::kRefsOnly); - mirror::AbstractMethod* referrer = - sp[callee_save->GetFrameSizeInBytes() / sizeof(mirror::AbstractMethod*)]; - mirror::Field* field = FindFieldFast(field_idx, referrer, InstancePrimitiveWrite, - sizeof(int64_t)); + mirror::ArtMethod* callee_save = Runtime::Current()->GetCalleeSaveMethod(Runtime::kRefsOnly); + mirror::ArtMethod* referrer = + sp[callee_save->GetFrameSizeInBytes() / sizeof(mirror::ArtMethod*)]; + mirror::ArtField* field = FindFieldFast(field_idx, referrer, InstancePrimitiveWrite, + sizeof(int64_t)); if (LIKELY(field != NULL && obj != NULL)) { field->Set64(obj, new_value); return 0; // success } *sp = callee_save; self->SetTopOfStack(sp, 0); - field = FindFieldFromCode(field_idx, referrer, self, InstancePrimitiveWrite, sizeof(int64_t), true); + field = FindFieldFromCode(field_idx, referrer, self, InstancePrimitiveWrite, sizeof(int64_t), + true); if (LIKELY(field != NULL)) { if (UNLIKELY(obj == NULL)) { ThrowLocation throw_location = self->GetCurrentLocationForThrow(); @@ -246,11 +260,11 @@ extern "C" int artSet64InstanceFromCode(uint32_t field_idx, mirror::Object* obj, extern "C" int artSetObjInstanceFromCode(uint32_t field_idx, mirror::Object* obj, mirror::Object* new_value, - const mirror::AbstractMethod* referrer, Thread* self, - mirror::AbstractMethod** sp) + const mirror::ArtMethod* referrer, Thread* self, + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, InstanceObjectWrite, - sizeof(mirror::Object*)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, InstanceObjectWrite, + sizeof(mirror::Object*)); if (LIKELY(field != NULL && obj != NULL)) { field->SetObj(obj, new_value); return 0; // success diff --git a/runtime/entrypoints/quick/quick_fillarray_entrypoints.cc b/runtime/entrypoints/quick/quick_fillarray_entrypoints.cc index b81ad12b7b..ca0c92e6d5 100644 --- a/runtime/entrypoints/quick/quick_fillarray_entrypoints.cc +++ b/runtime/entrypoints/quick/quick_fillarray_entrypoints.cc @@ -39,7 +39,7 @@ namespace art { */ extern "C" int artHandleFillArrayDataFromCode(mirror::Array* array, const Instruction::ArrayDataPayload* payload, - Thread* self, mirror::AbstractMethod** sp) + Thread* self, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly); DCHECK_EQ(payload->ident, static_cast(Instruction::kArrayDataSignature)); diff --git a/runtime/entrypoints/quick/quick_instrumentation_entrypoints.cc b/runtime/entrypoints/quick/quick_instrumentation_entrypoints.cc index 0e61942209..633f580bd6 100644 --- a/runtime/entrypoints/quick/quick_instrumentation_entrypoints.cc +++ b/runtime/entrypoints/quick/quick_instrumentation_entrypoints.cc @@ -16,17 +16,17 @@ #include "callee_save_frame.h" #include "instrumentation.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/object-inl.h" #include "runtime.h" #include "thread-inl.h" namespace art { -extern "C" const void* artInstrumentationMethodEntryFromCode(mirror::AbstractMethod* method, +extern "C" const void* artInstrumentationMethodEntryFromCode(mirror::ArtMethod* method, mirror::Object* this_object, Thread* self, - mirror::AbstractMethod** sp, + mirror::ArtMethod** sp, uintptr_t lr) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsAndArgs); @@ -39,7 +39,7 @@ extern "C" const void* artInstrumentationMethodEntryFromCode(mirror::AbstractMet return result; } -extern "C" uint64_t artInstrumentationMethodExitFromCode(Thread* self, mirror::AbstractMethod** sp, +extern "C" uint64_t artInstrumentationMethodExitFromCode(Thread* self, mirror::ArtMethod** sp, uint64_t gpr_result, uint64_t fpr_result) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { // TODO: use FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly) not the hand inlined below. @@ -47,7 +47,7 @@ extern "C" uint64_t artInstrumentationMethodExitFromCode(Thread* self, mirror::A // stack. // Be aware the store below may well stomp on an incoming argument. Locks::mutator_lock_->AssertSharedHeld(self); - mirror::AbstractMethod* callee_save = Runtime::Current()->GetCalleeSaveMethod(Runtime::kRefsOnly); + mirror::ArtMethod* callee_save = Runtime::Current()->GetCalleeSaveMethod(Runtime::kRefsOnly); *sp = callee_save; uintptr_t* return_pc = reinterpret_cast(reinterpret_cast(sp) + callee_save->GetReturnPcOffsetInBytes()); diff --git a/runtime/entrypoints/quick/quick_invoke_entrypoints.cc b/runtime/entrypoints/quick/quick_invoke_entrypoints.cc index 53b3628e2f..1d8022f803 100644 --- a/runtime/entrypoints/quick/quick_invoke_entrypoints.cc +++ b/runtime/entrypoints/quick/quick_invoke_entrypoints.cc @@ -17,21 +17,21 @@ #include "callee_save_frame.h" #include "dex_instruction-inl.h" #include "entrypoints/entrypoint_utils.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/dex_cache-inl.h" -#include "mirror/abstract_method-inl.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" namespace art { // Determine target of interface dispatch. This object is known non-null. -extern "C" uint64_t artInvokeInterfaceTrampoline(mirror::AbstractMethod* interface_method, +extern "C" uint64_t artInvokeInterfaceTrampoline(mirror::ArtMethod* interface_method, mirror::Object* this_object, - mirror::AbstractMethod* caller_method, - Thread* self, mirror::AbstractMethod** sp) + mirror::ArtMethod* caller_method, + Thread* self, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* method; + mirror::ArtMethod* method; if (LIKELY(interface_method->GetDexMethodIndex() != DexFile::kDexNoIndex16)) { method = this_object->GetClass()->FindVirtualMethodForInterface(interface_method); if (UNLIKELY(method == NULL)) { @@ -144,11 +144,11 @@ extern "C" uint64_t artInvokeInterfaceTrampoline(mirror::AbstractMethod* interfa static uint64_t artInvokeCommon(uint32_t method_idx, mirror::Object* this_object, - mirror::AbstractMethod* caller_method, - Thread* self, mirror::AbstractMethod** sp, bool access_check, + mirror::ArtMethod* caller_method, + Thread* self, mirror::ArtMethod** sp, bool access_check, InvokeType type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* method = FindMethodFast(method_idx, this_object, caller_method, + mirror::ArtMethod* method = FindMethodFast(method_idx, this_object, caller_method, access_check, type); if (UNLIKELY(method == NULL)) { FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsAndArgs); @@ -179,9 +179,9 @@ static uint64_t artInvokeCommon(uint32_t method_idx, mirror::Object* this_object // See comments in runtime_support_asm.S extern "C" uint64_t artInvokeInterfaceTrampolineWithAccessCheck(uint32_t method_idx, mirror::Object* this_object, - mirror::AbstractMethod* caller_method, + mirror::ArtMethod* caller_method, Thread* self, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return artInvokeCommon(method_idx, this_object, caller_method, self, sp, true, kInterface); } @@ -189,36 +189,36 @@ extern "C" uint64_t artInvokeInterfaceTrampolineWithAccessCheck(uint32_t method_ extern "C" uint64_t artInvokeDirectTrampolineWithAccessCheck(uint32_t method_idx, mirror::Object* this_object, - mirror::AbstractMethod* caller_method, + mirror::ArtMethod* caller_method, Thread* self, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return artInvokeCommon(method_idx, this_object, caller_method, self, sp, true, kDirect); } extern "C" uint64_t artInvokeStaticTrampolineWithAccessCheck(uint32_t method_idx, mirror::Object* this_object, - mirror::AbstractMethod* caller_method, + mirror::ArtMethod* caller_method, Thread* self, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return artInvokeCommon(method_idx, this_object, caller_method, self, sp, true, kStatic); } extern "C" uint64_t artInvokeSuperTrampolineWithAccessCheck(uint32_t method_idx, mirror::Object* this_object, - mirror::AbstractMethod* caller_method, + mirror::ArtMethod* caller_method, Thread* self, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return artInvokeCommon(method_idx, this_object, caller_method, self, sp, true, kSuper); } extern "C" uint64_t artInvokeVirtualTrampolineWithAccessCheck(uint32_t method_idx, mirror::Object* this_object, - mirror::AbstractMethod* caller_method, + mirror::ArtMethod* caller_method, Thread* self, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return artInvokeCommon(method_idx, this_object, caller_method, self, sp, true, kVirtual); } diff --git a/runtime/entrypoints/quick/quick_jni_entrypoints.cc b/runtime/entrypoints/quick/quick_jni_entrypoints.cc index 9907c043ee..27ae59b9b0 100644 --- a/runtime/entrypoints/quick/quick_jni_entrypoints.cc +++ b/runtime/entrypoints/quick/quick_jni_entrypoints.cc @@ -16,8 +16,8 @@ #include "dex_file-inl.h" #include "entrypoints/entrypoint_utils.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" -#include "mirror/abstract_method-inl.h" #include "mirror/object.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" diff --git a/runtime/entrypoints/quick/quick_lock_entrypoints.cc b/runtime/entrypoints/quick/quick_lock_entrypoints.cc index 79bb7a69f1..36ca6044a2 100644 --- a/runtime/entrypoints/quick/quick_lock_entrypoints.cc +++ b/runtime/entrypoints/quick/quick_lock_entrypoints.cc @@ -20,7 +20,7 @@ namespace art { extern "C" int artUnlockObjectFromCode(mirror::Object* obj, Thread* self, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) UNLOCK_FUNCTION(monitor_lock_) { FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly); DCHECK(obj != NULL); // Assumed to have been checked before entry @@ -29,7 +29,7 @@ extern "C" int artUnlockObjectFromCode(mirror::Object* obj, Thread* self, } extern "C" void artLockObjectFromCode(mirror::Object* obj, Thread* thread, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) EXCLUSIVE_LOCK_FUNCTION(monitor_lock_) { FinishCalleeSaveFrameSetup(thread, sp, Runtime::kRefsOnly); DCHECK(obj != NULL); // Assumed to have been checked before entry diff --git a/runtime/entrypoints/quick/quick_thread_entrypoints.cc b/runtime/entrypoints/quick/quick_thread_entrypoints.cc index b4d6c0ba8d..53e725edba 100644 --- a/runtime/entrypoints/quick/quick_thread_entrypoints.cc +++ b/runtime/entrypoints/quick/quick_thread_entrypoints.cc @@ -28,7 +28,7 @@ void CheckSuspendFromCode(Thread* thread) CheckSuspend(thread); } -extern "C" void artTestSuspendFromCode(Thread* thread, mirror::AbstractMethod** sp) +extern "C" void artTestSuspendFromCode(Thread* thread, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { // Called when suspend count check value is 0 and thread->suspend_count_ != 0 FinishCalleeSaveFrameSetup(thread, sp, Runtime::kRefsOnly); diff --git a/runtime/entrypoints/quick/quick_throw_entrypoints.cc b/runtime/entrypoints/quick/quick_throw_entrypoints.cc index 3bfa2f2611..f67b2fc4ab 100644 --- a/runtime/entrypoints/quick/quick_throw_entrypoints.cc +++ b/runtime/entrypoints/quick/quick_throw_entrypoints.cc @@ -24,7 +24,7 @@ namespace art { // Deliver an exception that's pending on thread helping set up a callee save frame on the way. -extern "C" void artDeliverPendingExceptionFromCode(Thread* thread, mirror::AbstractMethod** sp) +extern "C" void artDeliverPendingExceptionFromCode(Thread* thread, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { FinishCalleeSaveFrameSetup(thread, sp, Runtime::kSaveAll); thread->QuickDeliverException(); @@ -32,7 +32,7 @@ extern "C" void artDeliverPendingExceptionFromCode(Thread* thread, mirror::Abstr // Called by generated call to throw an exception. extern "C" void artDeliverExceptionFromCode(mirror::Throwable* exception, Thread* self, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { /* * exception may be NULL, in which case this routine should @@ -54,7 +54,7 @@ extern "C" void artDeliverExceptionFromCode(mirror::Throwable* exception, Thread // Called by generated call to throw a NPE exception. extern "C" void artThrowNullPointerExceptionFromCode(Thread* self, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { FinishCalleeSaveFrameSetup(self, sp, Runtime::kSaveAll); ThrowLocation throw_location = self->GetCurrentLocationForThrow(); @@ -64,7 +64,7 @@ extern "C" void artThrowNullPointerExceptionFromCode(Thread* self, // Called by generated call to throw an arithmetic divide by zero exception. extern "C" void artThrowDivZeroFromCode(Thread* self, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { FinishCalleeSaveFrameSetup(self, sp, Runtime::kSaveAll); ThrowArithmeticExceptionDivideByZero(); @@ -73,14 +73,14 @@ extern "C" void artThrowDivZeroFromCode(Thread* self, // Called by generated call to throw an array index out of bounds exception. extern "C" void artThrowArrayBoundsFromCode(int index, int length, Thread* self, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { FinishCalleeSaveFrameSetup(self, sp, Runtime::kSaveAll); ThrowArrayIndexOutOfBoundsException(index, length); self->QuickDeliverException(); } -extern "C" void artThrowStackOverflowFromCode(Thread* self, mirror::AbstractMethod** sp) +extern "C" void artThrowStackOverflowFromCode(Thread* self, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { FinishCalleeSaveFrameSetup(self, sp, Runtime::kSaveAll); ThrowStackOverflowError(self); @@ -88,7 +88,7 @@ extern "C" void artThrowStackOverflowFromCode(Thread* self, mirror::AbstractMeth } extern "C" void artThrowNoSuchMethodFromCode(int32_t method_idx, Thread* self, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { FinishCalleeSaveFrameSetup(self, sp, Runtime::kSaveAll); ThrowNoSuchMethodError(method_idx); diff --git a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc index 9bf02e8c8e..392bcc5257 100644 --- a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc +++ b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc @@ -19,7 +19,7 @@ #include "dex_instruction-inl.h" #include "interpreter/interpreter.h" #include "invoke_arg_array_builder.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" @@ -100,18 +100,18 @@ class QuickArgumentVisitor { #define QUICK_STACK_ARG_SKIP 0 #endif - static mirror::AbstractMethod* GetCallingMethod(mirror::AbstractMethod** sp) { + static mirror::ArtMethod* GetCallingMethod(mirror::ArtMethod** sp) { byte* previous_sp = reinterpret_cast(sp) + QUICK_CALLEE_SAVE_FRAME__REF_AND_ARGS__FRAME_SIZE; - return *reinterpret_cast(previous_sp); + return *reinterpret_cast(previous_sp); } - static uintptr_t GetCallingPc(mirror::AbstractMethod** sp) { + static uintptr_t GetCallingPc(mirror::ArtMethod** sp) { byte* lr = reinterpret_cast(sp) + QUICK_CALLEE_SAVE_FRAME__REF_AND_ARGS__LR_OFFSET; return *reinterpret_cast(lr); } - QuickArgumentVisitor(mirror::AbstractMethod** sp, bool is_static, + QuickArgumentVisitor(mirror::ArtMethod** sp, bool is_static, const char* shorty, uint32_t shorty_len) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) : is_static_(is_static), shorty_(shorty), shorty_len_(shorty_len), @@ -220,7 +220,7 @@ class QuickArgumentVisitor { // Visits arguments on the stack placing them into the shadow frame. class BuildShadowFrameVisitor : public QuickArgumentVisitor { public: - BuildShadowFrameVisitor(mirror::AbstractMethod** sp, bool is_static, const char* shorty, + BuildShadowFrameVisitor(mirror::ArtMethod** sp, bool is_static, const char* shorty, uint32_t shorty_len, ShadowFrame& sf, size_t first_arg_reg) : QuickArgumentVisitor(sp, is_static, shorty, shorty_len), sf_(sf), cur_reg_(first_arg_reg) {} @@ -261,8 +261,8 @@ class BuildShadowFrameVisitor : public QuickArgumentVisitor { DISALLOW_COPY_AND_ASSIGN(BuildShadowFrameVisitor); }; -extern "C" uint64_t artQuickToInterpreterBridge(mirror::AbstractMethod* method, Thread* self, - mirror::AbstractMethod** sp) +extern "C" uint64_t artQuickToInterpreterBridge(mirror::ArtMethod* method, Thread* self, + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { // Ensure we don't get thread suspension until the object arguments are safely in the shadow // frame. @@ -311,7 +311,7 @@ extern "C" uint64_t artQuickToInterpreterBridge(mirror::AbstractMethod* method, // to jobjects. class BuildQuickArgumentVisitor : public QuickArgumentVisitor { public: - BuildQuickArgumentVisitor(mirror::AbstractMethod** sp, bool is_static, const char* shorty, + BuildQuickArgumentVisitor(mirror::ArtMethod** sp, bool is_static, const char* shorty, uint32_t shorty_len, ScopedObjectAccessUnchecked* soa, std::vector* args) : QuickArgumentVisitor(sp, is_static, shorty, shorty_len), soa_(soa), args_(args) {} @@ -360,9 +360,9 @@ class BuildQuickArgumentVisitor : public QuickArgumentVisitor { // which is responsible for recording callee save registers. We explicitly place into jobjects the // incoming reference arguments (so they survive GC). We invoke the invocation handler, which is a // field within the proxy object, which will box the primitive arguments and deal with error cases. -extern "C" uint64_t artQuickProxyInvokeHandler(mirror::AbstractMethod* proxy_method, +extern "C" uint64_t artQuickProxyInvokeHandler(mirror::ArtMethod* proxy_method, mirror::Object* receiver, - Thread* self, mirror::AbstractMethod** sp) + Thread* self, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { // Ensure we don't get thread suspension until the object arguments are safely in jobjects. const char* old_cause = @@ -389,7 +389,7 @@ extern "C" uint64_t artQuickProxyInvokeHandler(mirror::AbstractMethod* proxy_met args.erase(args.begin()); // Convert proxy method into expected interface method. - mirror::AbstractMethod* interface_method = proxy_method->FindOverriddenMethod(); + mirror::ArtMethod* interface_method = proxy_method->FindOverriddenMethod(); DCHECK(interface_method != NULL); DCHECK(!interface_method->IsProxyMethod()) << PrettyMethod(interface_method); jobject interface_method_jobj = soa.AddLocalReference(interface_method); @@ -406,7 +406,7 @@ extern "C" uint64_t artQuickProxyInvokeHandler(mirror::AbstractMethod* proxy_met // so they don't get garbage collected. class RememberFoGcArgumentVisitor : public QuickArgumentVisitor { public: - RememberFoGcArgumentVisitor(mirror::AbstractMethod** sp, bool is_static, const char* shorty, + RememberFoGcArgumentVisitor(mirror::ArtMethod** sp, bool is_static, const char* shorty, uint32_t shorty_len, ScopedObjectAccessUnchecked* soa) : QuickArgumentVisitor(sp, is_static, shorty, shorty_len), soa_(soa) {} @@ -423,9 +423,9 @@ class RememberFoGcArgumentVisitor : public QuickArgumentVisitor { }; // Lazily resolve a method for quick. Called by stub code. -extern "C" const void* artQuickResolutionTrampoline(mirror::AbstractMethod* called, +extern "C" const void* artQuickResolutionTrampoline(mirror::ArtMethod* called, mirror::Object* receiver, - Thread* thread, mirror::AbstractMethod** sp) + Thread* thread, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { FinishCalleeSaveFrameSetup(thread, sp, Runtime::kRefsAndArgs); // Start new JNI local reference state @@ -436,7 +436,7 @@ extern "C" const void* artQuickResolutionTrampoline(mirror::AbstractMethod* call // Compute details about the called method (avoid GCs) ClassLinker* linker = Runtime::Current()->GetClassLinker(); - mirror::AbstractMethod* caller = QuickArgumentVisitor::GetCallingMethod(sp); + mirror::ArtMethod* caller = QuickArgumentVisitor::GetCallingMethod(sp); InvokeType invoke_type; const DexFile* dex_file; uint32_t dex_method_idx; diff --git a/runtime/exception_test.cc b/runtime/exception_test.cc index 933b74ace1..e48208d771 100644 --- a/runtime/exception_test.cc +++ b/runtime/exception_test.cc @@ -95,8 +95,8 @@ class ExceptionTest : public CommonTest { UnsignedLeb128EncodingVector fake_vmap_table_data_; std::vector fake_gc_map_; - mirror::AbstractMethod* method_f_; - mirror::AbstractMethod* method_g_; + mirror::ArtMethod* method_f_; + mirror::ArtMethod* method_g_; private: mirror::Class* my_klass_; diff --git a/runtime/gc/accounting/mod_union_table.cc b/runtime/gc/accounting/mod_union_table.cc index 0363acb477..3bbc3810a0 100644 --- a/runtime/gc/accounting/mod_union_table.cc +++ b/runtime/gc/accounting/mod_union_table.cc @@ -22,9 +22,9 @@ #include "gc/collector/mark_sweep-inl.h" #include "gc/heap.h" #include "gc/space/space.h" +#include "mirror/art_field-inl.h" #include "mirror/object-inl.h" #include "mirror/class-inl.h" -#include "mirror/field-inl.h" #include "mirror/object_array-inl.h" #include "space_bitmap-inl.h" #include "thread.h" diff --git a/runtime/gc/accounting/space_bitmap.cc b/runtime/gc/accounting/space_bitmap.cc index 6edc067cc7..702e162262 100644 --- a/runtime/gc/accounting/space_bitmap.cc +++ b/runtime/gc/accounting/space_bitmap.cc @@ -17,8 +17,8 @@ #include "base/logging.h" #include "dex_file-inl.h" #include "heap_bitmap.h" +#include "mirror/art_field-inl.h" #include "mirror/class-inl.h" -#include "mirror/field-inl.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" #include "object_utils.h" @@ -182,10 +182,10 @@ static void WalkInstanceFields(SpaceBitmap* visited, SpaceBitmap::Callback* call WalkInstanceFields(visited, callback, obj, super, arg); } // Walk instance fields - mirror::ObjectArray* fields = klass->GetIFields(); + mirror::ObjectArray* fields = klass->GetIFields(); if (fields != NULL) { for (int32_t i = 0; i < fields->GetLength(); i++) { - mirror::Field* field = fields->Get(i); + mirror::ArtField* field = fields->Get(i); FieldHelper fh(field); if (!fh.IsPrimitiveType()) { mirror::Object* value = field->GetObj(obj); @@ -212,10 +212,10 @@ static void WalkFieldsInOrder(SpaceBitmap* visited, SpaceBitmap::Callback* callb WalkInstanceFields(visited, callback, obj, klass, arg); // Walk static fields of a Class if (obj->IsClass()) { - mirror::ObjectArray* fields = klass->GetSFields(); + mirror::ObjectArray* fields = klass->GetSFields(); if (fields != NULL) { for (int32_t i = 0; i < fields->GetLength(); i++) { - mirror::Field* field = fields->Get(i); + mirror::ArtField* field = fields->Get(i); FieldHelper fh(field); if (!fh.IsPrimitiveType()) { mirror::Object* value = field->GetObj(NULL); diff --git a/runtime/gc/collector/mark_sweep-inl.h b/runtime/gc/collector/mark_sweep-inl.h index 6b1b617eb4..e158952119 100644 --- a/runtime/gc/collector/mark_sweep-inl.h +++ b/runtime/gc/collector/mark_sweep-inl.h @@ -20,8 +20,8 @@ #include "gc/collector/mark_sweep.h" #include "gc/heap.h" +#include "mirror/art_field.h" #include "mirror/class.h" -#include "mirror/field.h" #include "mirror/object_array.h" namespace art { @@ -136,8 +136,8 @@ inline void MarkSweep::VisitFieldsReferences(const mirror::Object* obj, uint32_t ? klass->NumReferenceStaticFields() : klass->NumReferenceInstanceFields()); for (size_t i = 0; i < num_reference_fields; ++i) { - mirror::Field* field = (is_static ? klass->GetStaticField(i) - : klass->GetInstanceField(i)); + mirror::ArtField* field = (is_static ? klass->GetStaticField(i) + : klass->GetInstanceField(i)); MemberOffset field_offset = field->GetOffset(); const mirror::Object* ref = obj->GetFieldObject(field_offset, false); visitor(obj, ref, field_offset, is_static); diff --git a/runtime/gc/collector/mark_sweep.cc b/runtime/gc/collector/mark_sweep.cc index 7b78720392..61570ae393 100644 --- a/runtime/gc/collector/mark_sweep.cc +++ b/runtime/gc/collector/mark_sweep.cc @@ -37,11 +37,11 @@ #include "jni_internal.h" #include "monitor.h" #include "mark_sweep-inl.h" +#include "mirror/art_field.h" +#include "mirror/art_field-inl.h" #include "mirror/class-inl.h" #include "mirror/class_loader.h" #include "mirror/dex_cache.h" -#include "mirror/field.h" -#include "mirror/field-inl.h" #include "mirror/object-inl.h" #include "mirror/object_array.h" #include "mirror/object_array-inl.h" @@ -50,8 +50,8 @@ #include "thread_list.h" #include "verifier/method_verifier.h" +using ::art::mirror::ArtField; using ::art::mirror::Class; -using ::art::mirror::Field; using ::art::mirror::Object; using ::art::mirror::ObjectArray; @@ -1072,11 +1072,11 @@ void MarkSweep::CheckReference(const Object* obj, const Object* ref, MemberOffse const Class* klass = is_static ? obj->AsClass() : obj->GetClass(); DCHECK(klass != NULL); - const ObjectArray* fields = is_static ? klass->GetSFields() : klass->GetIFields(); + const ObjectArray* fields = is_static ? klass->GetSFields() : klass->GetIFields(); DCHECK(fields != NULL); bool found = false; for (int32_t i = 0; i < fields->GetLength(); ++i) { - const Field* cur = fields->Get(i); + const ArtField* cur = fields->Get(i); if (cur->GetOffset().Int32Value() == offset.Int32Value()) { LOG(WARNING) << "Field referencing the alloc space was " << PrettyField(cur); found = true; diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc index df1f3fe92e..a2453b8405 100644 --- a/runtime/gc/heap.cc +++ b/runtime/gc/heap.cc @@ -41,8 +41,8 @@ #include "gc/space/space-inl.h" #include "image.h" #include "invoke_arg_array_builder.h" +#include "mirror/art_field-inl.h" #include "mirror/class-inl.h" -#include "mirror/field-inl.h" #include "mirror/object.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" @@ -1512,11 +1512,11 @@ class VerifyReferenceCardVisitor { if (!obj->IsObjectArray()) { const mirror::Class* klass = is_static ? obj->AsClass() : obj->GetClass(); CHECK(klass != NULL); - const mirror::ObjectArray* fields = is_static ? klass->GetSFields() - : klass->GetIFields(); + const mirror::ObjectArray* fields = is_static ? klass->GetSFields() + : klass->GetIFields(); CHECK(fields != NULL); for (int32_t i = 0; i < fields->GetLength(); ++i) { - const mirror::Field* cur = fields->Get(i); + const mirror::ArtField* cur = fields->Get(i); if (cur->GetOffset().Int32Value() == offset.Int32Value()) { LOG(ERROR) << (is_static ? "Static " : "") << "field in the live stack is " << PrettyField(cur); diff --git a/runtime/gc/space/image_space.cc b/runtime/gc/space/image_space.cc index 8ff7025c34..22562df512 100644 --- a/runtime/gc/space/image_space.cc +++ b/runtime/gc/space/image_space.cc @@ -22,7 +22,7 @@ #include "base/stl_util.h" #include "base/unix_file/fd_file.h" #include "gc/accounting/space_bitmap-inl.h" -#include "mirror/abstract_method.h" +#include "mirror/art_method.h" #include "mirror/class-inl.h" #include "mirror/object-inl.h" #include "oat_file.h" @@ -187,14 +187,14 @@ ImageSpace* ImageSpace::Init(const std::string& image_file_name, bool validate_o Runtime* runtime = Runtime::Current(); mirror::Object* resolution_method = image_header.GetImageRoot(ImageHeader::kResolutionMethod); - runtime->SetResolutionMethod(down_cast(resolution_method)); + runtime->SetResolutionMethod(down_cast(resolution_method)); mirror::Object* callee_save_method = image_header.GetImageRoot(ImageHeader::kCalleeSaveMethod); - runtime->SetCalleeSaveMethod(down_cast(callee_save_method), Runtime::kSaveAll); + runtime->SetCalleeSaveMethod(down_cast(callee_save_method), Runtime::kSaveAll); callee_save_method = image_header.GetImageRoot(ImageHeader::kRefsOnlySaveMethod); - runtime->SetCalleeSaveMethod(down_cast(callee_save_method), Runtime::kRefsOnly); + runtime->SetCalleeSaveMethod(down_cast(callee_save_method), Runtime::kRefsOnly); callee_save_method = image_header.GetImageRoot(ImageHeader::kRefsAndArgsSaveMethod); - runtime->SetCalleeSaveMethod(down_cast(callee_save_method), Runtime::kRefsAndArgs); + runtime->SetCalleeSaveMethod(down_cast(callee_save_method), Runtime::kRefsAndArgs); UniquePtr space(new ImageSpace(image_file_name, map.release())); diff --git a/runtime/hprof/hprof.cc b/runtime/hprof/hprof.cc index d3bb2e8f5f..0b2e741527 100644 --- a/runtime/hprof/hprof.cc +++ b/runtime/hprof/hprof.cc @@ -48,10 +48,9 @@ #include "gc/heap.h" #include "gc/space/space.h" #include "globals.h" +#include "mirror/art_field-inl.h" #include "mirror/class.h" #include "mirror/class-inl.h" -#include "mirror/field.h" -#include "mirror/field-inl.h" #include "mirror/object-inl.h" #include "object_utils.h" #include "os.h" @@ -922,7 +921,7 @@ int Hprof::DumpHeapObject(mirror::Object* obj) { rec->AddId(CLASS_STATICS_ID(obj)); for (size_t i = 0; i < sFieldCount; ++i) { - mirror::Field* f = thisClass->GetStaticField(i); + mirror::ArtField* f = thisClass->GetStaticField(i); fh.ChangeField(f); size_t size; @@ -947,7 +946,7 @@ int Hprof::DumpHeapObject(mirror::Object* obj) { int iFieldCount = thisClass->IsObjectClass() ? 0 : thisClass->NumInstanceFields(); rec->AddU2((uint16_t)iFieldCount); for (int i = 0; i < iFieldCount; ++i) { - mirror::Field* f = thisClass->GetInstanceField(i); + mirror::ArtField* f = thisClass->GetInstanceField(i); fh.ChangeField(f); HprofBasicType t = SignatureToBasicTypeAndSize(fh.GetTypeDescriptor(), NULL); rec->AddId(LookupStringId(fh.GetName())); @@ -1010,7 +1009,7 @@ int Hprof::DumpHeapObject(mirror::Object* obj) { while (!sclass->IsObjectClass()) { int ifieldCount = sclass->NumInstanceFields(); for (int i = 0; i < ifieldCount; ++i) { - mirror::Field* f = sclass->GetInstanceField(i); + mirror::ArtField* f = sclass->GetInstanceField(i); fh.ChangeField(f); size_t size; SignatureToBasicTypeAndSize(fh.GetTypeDescriptor(), &size); diff --git a/runtime/instrumentation.cc b/runtime/instrumentation.cc index c3b66b3f79..ae3a165a70 100644 --- a/runtime/instrumentation.cc +++ b/runtime/instrumentation.cc @@ -23,9 +23,9 @@ #include "class_linker.h" #include "debugger.h" #include "dex_file-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/dex_cache.h" -#include "mirror/abstract_method-inl.h" #include "mirror/object_array-inl.h" #include "mirror/object-inl.h" #include "nth_caller_visitor.h" @@ -55,7 +55,7 @@ bool Instrumentation::InstallStubsForClass(mirror::Class* klass) { } bool is_initialized = klass->IsInitialized(); for (size_t i = 0; i < klass->NumDirectMethods(); i++) { - mirror::AbstractMethod* method = klass->GetDirectMethod(i); + mirror::ArtMethod* method = klass->GetDirectMethod(i); if (!method->IsAbstract()) { const void* new_code; if (uninstall) { @@ -77,7 +77,7 @@ bool Instrumentation::InstallStubsForClass(mirror::Class* klass) { } } for (size_t i = 0; i < klass->NumVirtualMethods(); i++) { - mirror::AbstractMethod* method = klass->GetVirtualMethod(i); + mirror::ArtMethod* method = klass->GetVirtualMethod(i); if (!method->IsAbstract()) { const void* new_code; if (uninstall) { @@ -109,7 +109,7 @@ static void InstrumentationInstallStack(Thread* thread, void* arg) instrumentation_exit_pc_(instrumentation_exit_pc), last_return_pc_(0) {} virtual bool VisitFrame() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* m = GetMethod(); + mirror::ArtMethod* m = GetMethod(); if (GetCurrentQuickFrame() == NULL) { if (kVerboseInstrumentation) { LOG(INFO) << " Ignoring a shadow frame. Frame " << GetFrameId() @@ -169,7 +169,7 @@ static void InstrumentationInstallStack(Thread* thread, void* arg) for (It it = thread->GetInstrumentationStack()->rbegin(), end = thread->GetInstrumentationStack()->rend(); it != end; ++it) { mirror::Object* this_object = (*it).this_object_; - mirror::AbstractMethod* method = (*it).method_; + mirror::ArtMethod* method = (*it).method_; uint32_t dex_pc = visitor.dex_pcs_.back(); visitor.dex_pcs_.pop_back(); instrumentation->MethodEnterEvent(thread, this_object, method, dex_pc); @@ -193,7 +193,7 @@ static void InstrumentationRestoreStack(Thread* thread, void* arg) if (instrumentation_stack_->size() == 0) { return false; // Stop. } - mirror::AbstractMethod* m = GetMethod(); + mirror::ArtMethod* m = GetMethod(); if (GetCurrentQuickFrame() == NULL) { if (kVerboseInstrumentation) { LOG(INFO) << " Ignoring a shadow frame. Frame " << GetFrameId() << " Method=" << PrettyMethod(m); @@ -379,7 +379,7 @@ void Instrumentation::ConfigureStubs(bool require_entry_exit_stubs, bool require } } -void Instrumentation::UpdateMethodsCode(mirror::AbstractMethod* method, const void* code) const { +void Instrumentation::UpdateMethodsCode(mirror::ArtMethod* method, const void* code) const { if (LIKELY(!instrumentation_stubs_installed_)) { method->SetEntryPointFromCompiledCode(code); } else { @@ -391,7 +391,7 @@ void Instrumentation::UpdateMethodsCode(mirror::AbstractMethod* method, const vo } } -const void* Instrumentation::GetQuickCodeFor(const mirror::AbstractMethod* method) const { +const void* Instrumentation::GetQuickCodeFor(const mirror::ArtMethod* method) const { Runtime* runtime = Runtime::Current(); if (LIKELY(!instrumentation_stubs_installed_)) { const void* code = method->GetEntryPointFromCompiledCode(); @@ -405,7 +405,7 @@ const void* Instrumentation::GetQuickCodeFor(const mirror::AbstractMethod* metho } void Instrumentation::MethodEnterEventImpl(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, + const mirror::ArtMethod* method, uint32_t dex_pc) const { typedef std::list::const_iterator It; // TODO: C++0x auto It it = method_entry_listeners_.begin(); @@ -420,7 +420,7 @@ void Instrumentation::MethodEnterEventImpl(Thread* thread, mirror::Object* this_ } void Instrumentation::MethodExitEventImpl(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, + const mirror::ArtMethod* method, uint32_t dex_pc, const JValue& return_value) const { typedef std::list::const_iterator It; // TODO: C++0x auto It it = method_exit_listeners_.begin(); @@ -435,7 +435,7 @@ void Instrumentation::MethodExitEventImpl(Thread* thread, mirror::Object* this_o } void Instrumentation::MethodUnwindEvent(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, + const mirror::ArtMethod* method, uint32_t dex_pc) const { if (have_method_unwind_listeners_) { typedef std::list::const_iterator It; // TODO: C++0x auto @@ -447,7 +447,7 @@ void Instrumentation::MethodUnwindEvent(Thread* thread, mirror::Object* this_obj } void Instrumentation::DexPcMovedEventImpl(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, + const mirror::ArtMethod* method, uint32_t dex_pc) const { // TODO: STL copy-on-write collection? The copy below is due to the debug listener having an // action where it can remove itself as a listener and break the iterator. The copy only works @@ -461,7 +461,7 @@ void Instrumentation::DexPcMovedEventImpl(Thread* thread, mirror::Object* this_o } void Instrumentation::ExceptionCaughtEvent(Thread* thread, const ThrowLocation& throw_location, - mirror::AbstractMethod* catch_method, + mirror::ArtMethod* catch_method, uint32_t catch_dex_pc, mirror::Throwable* exception_object) { if (have_exception_caught_listeners_) { @@ -489,7 +489,7 @@ static void CheckStackDepth(Thread* self, const InstrumentationStackFrame& instr } void Instrumentation::PushInstrumentationStackFrame(Thread* self, mirror::Object* this_object, - mirror::AbstractMethod* method, + mirror::ArtMethod* method, uintptr_t lr, bool interpreter_entry) { // We have a callee-save frame meaning this value is guaranteed to never be 0. size_t frame_id = StackVisitor::ComputeNumFrames(self); @@ -516,7 +516,7 @@ uint64_t Instrumentation::PopInstrumentationStackFrame(Thread* self, uintptr_t* *return_pc = instrumentation_frame.return_pc_; CheckStackDepth(self, instrumentation_frame, 0); - mirror::AbstractMethod* method = instrumentation_frame.method_; + mirror::ArtMethod* method = instrumentation_frame.method_; char return_shorty = MethodHelper(method).GetShorty()[0]; JValue return_value; if (return_shorty == 'V') { @@ -567,7 +567,7 @@ void Instrumentation::PopMethodForUnwind(Thread* self, bool is_deoptimization) c // TODO: bring back CheckStackDepth(self, instrumentation_frame, 2); stack->pop_front(); - mirror::AbstractMethod* method = instrumentation_frame.method_; + mirror::ArtMethod* method = instrumentation_frame.method_; if (is_deoptimization) { if (kVerboseInstrumentation) { LOG(INFO) << "Popping for deoptimization " << PrettyMethod(method); diff --git a/runtime/instrumentation.h b/runtime/instrumentation.h index 798b7ab56d..6c80b41b64 100644 --- a/runtime/instrumentation.h +++ b/runtime/instrumentation.h @@ -25,10 +25,10 @@ namespace art { namespace mirror { -class AbstractMethod; -class Class; -class Object; -class Throwable; + class ArtMethod; + class Class; + class Object; + class Throwable; } // namespace mirror union JValue; class Thread; @@ -47,30 +47,30 @@ struct InstrumentationListener { // Call-back for when a method is entered. virtual void MethodEntered(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, + const mirror::ArtMethod* method, uint32_t dex_pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) = 0; // Call-back for when a method is exited. // TODO: its likely passing the return value would be useful, however, we may need to get and // parse the shorty to determine what kind of register holds the result. virtual void MethodExited(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, uint32_t dex_pc, + const mirror::ArtMethod* method, uint32_t dex_pc, const JValue& return_value) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) = 0; // Call-back for when a method is popped due to an exception throw. A method will either cause a // MethodExited call-back or a MethodUnwind call-back when its activation is removed. - virtual void MethodUnwind(Thread* thread, const mirror::AbstractMethod* method, + virtual void MethodUnwind(Thread* thread, const mirror::ArtMethod* method, uint32_t dex_pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) = 0; // Call-back for when the dex pc moves in a method. virtual void DexPcMoved(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, uint32_t new_dex_pc) + const mirror::ArtMethod* method, uint32_t new_dex_pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) = 0; // Call-back when an exception is caught. virtual void ExceptionCaught(Thread* thread, const ThrowLocation& throw_location, - mirror::AbstractMethod* catch_method, uint32_t catch_dex_pc, + mirror::ArtMethod* catch_method, uint32_t catch_dex_pc, mirror::Throwable* exception_object) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) = 0; }; @@ -111,12 +111,12 @@ class Instrumentation { LOCKS_EXCLUDED(Locks::thread_list_lock_, Locks::classlinker_classes_lock_); // Update the code of a method respecting any installed stubs. - void UpdateMethodsCode(mirror::AbstractMethod* method, const void* code) const; + void UpdateMethodsCode(mirror::ArtMethod* method, const void* code) const; // Get the quick code for the given method. More efficient than asking the class linker as it // will short-cut to GetCode if instrumentation and static method resolution stubs aren't // installed. - const void* GetQuickCodeFor(const mirror::AbstractMethod* method) const + const void* GetQuickCodeFor(const mirror::ArtMethod* method) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void ForceInterpretOnly() { @@ -124,7 +124,7 @@ class Instrumentation { forced_interpret_only_ = true; } - // Called by AbstractMethod::Invoke to determine dispatch mechanism. + // Called by ArtMethod::Invoke to determine dispatch mechanism. bool InterpretOnly() const { return interpret_only_; } @@ -152,7 +152,7 @@ class Instrumentation { // Inform listeners that a method has been entered. A dex PC is provided as we may install // listeners into executing code and get method enter events for methods already on the stack. void MethodEnterEvent(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, uint32_t dex_pc) const + const mirror::ArtMethod* method, uint32_t dex_pc) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { if (UNLIKELY(HasMethodEntryListeners())) { MethodEnterEventImpl(thread, this_object, method, dex_pc); @@ -161,7 +161,7 @@ class Instrumentation { // Inform listeners that a method has been exited. void MethodExitEvent(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, uint32_t dex_pc, + const mirror::ArtMethod* method, uint32_t dex_pc, const JValue& return_value) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { if (UNLIKELY(HasMethodExitListeners())) { @@ -171,12 +171,12 @@ class Instrumentation { // Inform listeners that a method has been exited due to an exception. void MethodUnwindEvent(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, uint32_t dex_pc) const + const mirror::ArtMethod* method, uint32_t dex_pc) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Inform listeners that the dex pc has moved (only supported by the interpreter). void DexPcMovedEvent(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, uint32_t dex_pc) const + const mirror::ArtMethod* method, uint32_t dex_pc) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { if (UNLIKELY(HasDexPcListeners())) { DexPcMovedEventImpl(thread, this_object, method, dex_pc); @@ -185,14 +185,14 @@ class Instrumentation { // Inform listeners that an exception was caught. void ExceptionCaughtEvent(Thread* thread, const ThrowLocation& throw_location, - mirror::AbstractMethod* catch_method, uint32_t catch_dex_pc, + mirror::ArtMethod* catch_method, uint32_t catch_dex_pc, mirror::Throwable* exception_object) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Called when an instrumented method is entered. The intended link register (lr) is saved so // that returning causes a branch to the method exit stub. Generates method enter events. void PushInstrumentationStackFrame(Thread* self, mirror::Object* this_object, - mirror::AbstractMethod* method, uintptr_t lr, + mirror::ArtMethod* method, uintptr_t lr, bool interpreter_entry) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); @@ -216,23 +216,23 @@ class Instrumentation { LOCKS_EXCLUDED(Locks::thread_list_lock_, Locks::classlinker_classes_lock_); void MethodEnterEventImpl(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, uint32_t dex_pc) const + const mirror::ArtMethod* method, uint32_t dex_pc) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void MethodExitEventImpl(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, + const mirror::ArtMethod* method, uint32_t dex_pc, const JValue& return_value) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void DexPcMovedEventImpl(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, uint32_t dex_pc) const + const mirror::ArtMethod* method, uint32_t dex_pc) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - // Have we hijacked AbstractMethod::code_ so that it calls instrumentation/interpreter code? + // Have we hijacked ArtMethod::code_ so that it calls instrumentation/interpreter code? bool instrumentation_stubs_installed_; - // Have we hijacked AbstractMethod::code_ to reference the enter/exit stubs? + // Have we hijacked ArtMethod::code_ to reference the enter/exit stubs? bool entry_exit_stubs_installed_; - // Have we hijacked AbstractMethod::code_ to reference the enter interpreter stub? + // Have we hijacked ArtMethod::code_ to reference the enter interpreter stub? bool interpreter_stubs_installed_; // Do we need the fidelity of events that we only get from running within the interpreter? @@ -272,7 +272,7 @@ class Instrumentation { // An element in the instrumentation side stack maintained in art::Thread. struct InstrumentationStackFrame { - InstrumentationStackFrame(mirror::Object* this_object, mirror::AbstractMethod* method, + InstrumentationStackFrame(mirror::Object* this_object, mirror::ArtMethod* method, uintptr_t return_pc, size_t frame_id, bool interpreter_entry) : this_object_(this_object), method_(method), return_pc_(return_pc), frame_id_(frame_id), interpreter_entry_(interpreter_entry) { @@ -281,7 +281,7 @@ struct InstrumentationStackFrame { std::string Dump() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); mirror::Object* this_object_; - mirror::AbstractMethod* method_; + mirror::ArtMethod* method_; const uintptr_t return_pc_; const size_t frame_id_; const bool interpreter_entry_; diff --git a/runtime/interpreter/interpreter.cc b/runtime/interpreter/interpreter.cc index 6e35d937fb..59f0ac2e38 100644 --- a/runtime/interpreter/interpreter.cc +++ b/runtime/interpreter/interpreter.cc @@ -28,26 +28,27 @@ #include "gc/accounting/card_table-inl.h" #include "invoke_arg_array_builder.h" #include "nth_caller_visitor.h" +#include "mirror/art_field-inl.h" +#include "mirror/art_method.h" +#include "mirror/art_method-inl.h" #include "mirror/class.h" #include "mirror/class-inl.h" -#include "mirror/field-inl.h" -#include "mirror/abstract_method.h" -#include "mirror/abstract_method-inl.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" #include "object_utils.h" #include "ScopedLocalRef.h" #include "scoped_thread_state_change.h" #include "thread.h" +#include "well_known_classes.h" -using ::art::mirror::AbstractMethod; +using ::art::mirror::ArtField; +using ::art::mirror::ArtMethod; using ::art::mirror::Array; using ::art::mirror::BooleanArray; using ::art::mirror::ByteArray; using ::art::mirror::CharArray; using ::art::mirror::Class; using ::art::mirror::ClassLoader; -using ::art::mirror::Field; using ::art::mirror::IntArray; using ::art::mirror::LongArray; using ::art::mirror::Object; @@ -82,22 +83,22 @@ static void UnstartedRuntimeInvoke(Thread* self, MethodHelper& mh, result->SetL(found); } else if (name == "java.lang.Object java.lang.Class.newInstance()") { Class* klass = shadow_frame->GetVRegReference(arg_offset)->AsClass(); - AbstractMethod* c = klass->FindDeclaredDirectMethod("", "()V"); + ArtMethod* c = klass->FindDeclaredDirectMethod("", "()V"); CHECK(c != NULL); - Object* obj = klass->AllocObject(self); - CHECK(obj != NULL); - EnterInterpreterFromInvoke(self, c, obj, NULL, NULL); - result->SetL(obj); + SirtRef obj(self, klass->AllocObject(self)); + CHECK(obj.get() != NULL); + EnterInterpreterFromInvoke(self, c, obj.get(), NULL, NULL); + result->SetL(obj.get()); } else if (name == "java.lang.reflect.Field java.lang.Class.getDeclaredField(java.lang.String)") { // Special managed code cut-out to allow field lookup in a un-started runtime that'd fail // going the reflective Dex way. Class* klass = shadow_frame->GetVRegReference(arg_offset)->AsClass(); String* name = shadow_frame->GetVRegReference(arg_offset + 1)->AsString(); - Field* found = NULL; + ArtField* found = NULL; FieldHelper fh; - ObjectArray* fields = klass->GetIFields(); + ObjectArray* fields = klass->GetIFields(); for (int32_t i = 0; i < fields->GetLength() && found == NULL; ++i) { - Field* f = fields->Get(i); + ArtField* f = fields->Get(i); fh.ChangeField(f); if (name->Equals(fh.GetName())) { found = f; @@ -106,7 +107,7 @@ static void UnstartedRuntimeInvoke(Thread* self, MethodHelper& mh, if (found == NULL) { fields = klass->GetSFields(); for (int32_t i = 0; i < fields->GetLength() && found == NULL; ++i) { - Field* f = fields->Get(i); + ArtField* f = fields->Get(i); fh.ChangeField(f); if (name->Equals(fh.GetName())) { found = f; @@ -118,7 +119,14 @@ static void UnstartedRuntimeInvoke(Thread* self, MethodHelper& mh, << name->ToModifiedUtf8() << " class=" << PrettyDescriptor(klass); // TODO: getDeclaredField calls GetType once the field is found to ensure a // NoClassDefFoundError is thrown if the field's type cannot be resolved. - result->SetL(found); + Class* jlr_Field = self->DecodeJObject(WellKnownClasses::java_lang_reflect_Field)->AsClass(); + SirtRef field(self, jlr_Field->AllocObject(self)); + CHECK(field.get() != NULL); + ArtMethod* c = jlr_Field->FindDeclaredDirectMethod("", "(Ljava/lang/reflect/ArtField;)V"); + uint32_t args[1]; + args[0] = reinterpret_cast(found); + EnterInterpreterFromInvoke(self, c, field.get(), args, NULL); + result->SetL(field.get()); } else if (name == "void java.lang.System.arraycopy(java.lang.Object, int, java.lang.Object, int, int)") { // Special case array copying without initializing System. Class* ctype = shadow_frame->GetVRegReference(arg_offset)->GetClass()->GetComponentType(); @@ -153,7 +161,7 @@ static void UnstartedRuntimeInvoke(Thread* self, MethodHelper& mh, } // Hand select a number of methods to be run in a not yet started runtime without using JNI. -static void UnstartedRuntimeJni(Thread* self, AbstractMethod* method, +static void UnstartedRuntimeJni(Thread* self, ArtMethod* method, Object* receiver, uint32_t* args, JValue* result) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { std::string name(PrettyMethod(method)); @@ -215,7 +223,7 @@ static void UnstartedRuntimeJni(Thread* self, AbstractMethod* method, } } -static void InterpreterJni(Thread* self, AbstractMethod* method, StringPiece shorty, +static void InterpreterJni(Thread* self, ArtMethod* method, StringPiece shorty, Object* receiver, uint32_t* args, JValue* result) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { // TODO: The following enters JNI code using a typedef-ed function rather than the JNI compiler, @@ -417,8 +425,8 @@ static bool DoInvoke(Thread* self, ShadowFrame& shadow_frame, uint32_t method_idx = (is_range) ? inst->VRegB_3rc() : inst->VRegB_35c(); uint32_t vregC = (is_range) ? inst->VRegC_3rc() : inst->VRegC_35c(); Object* receiver = (type == kStatic) ? NULL : shadow_frame.GetVRegReference(vregC); - AbstractMethod* method = FindMethodFromCode(method_idx, receiver, shadow_frame.GetMethod(), self, - do_access_check, type); + ArtMethod* method = FindMethodFromCode(method_idx, receiver, shadow_frame.GetMethod(), self, + do_access_check, type); if (UNLIKELY(method == NULL)) { CHECK(self->IsExceptionPending()); result->SetJ(0); @@ -438,7 +446,7 @@ static bool DoInvoke(Thread* self, ShadowFrame& shadow_frame, num_ins = code_item->ins_size_; } else { DCHECK(method->IsNative() || method->IsProxyMethod()); - num_regs = num_ins = AbstractMethod::NumArgRegisters(mh.GetShorty()); + num_regs = num_ins = ArtMethod::NumArgRegisters(mh.GetShorty()); if (!method->IsStatic()) { num_regs++; num_ins++; @@ -510,7 +518,7 @@ static bool DoInvokeVirtualQuick(Thread* self, ShadowFrame& shadow_frame, } uint32_t vtable_idx = (is_range) ? inst->VRegB_3rc() : inst->VRegB_35c(); // TODO: use ObjectArray::GetWithoutChecks ? - AbstractMethod* method = receiver->GetClass()->GetVTable()->Get(vtable_idx); + ArtMethod* method = receiver->GetClass()->GetVTable()->Get(vtable_idx); if (UNLIKELY(method == NULL)) { CHECK(self->IsExceptionPending()); result->SetJ(0); @@ -530,7 +538,7 @@ static bool DoInvokeVirtualQuick(Thread* self, ShadowFrame& shadow_frame, num_ins = code_item->ins_size_; } else { DCHECK(method->IsNative() || method->IsProxyMethod()); - num_regs = num_ins = AbstractMethod::NumArgRegisters(mh.GetShorty()); + num_regs = num_ins = ArtMethod::NumArgRegisters(mh.GetShorty()); if (!method->IsStatic()) { num_regs++; num_ins++; @@ -601,9 +609,9 @@ static inline bool DoFieldGet(Thread* self, ShadowFrame& shadow_frame, const Instruction* inst) { bool is_static = (find_type == StaticObjectRead) || (find_type == StaticPrimitiveRead); uint32_t field_idx = is_static ? inst->VRegB_21c() : inst->VRegC_22c(); - Field* f = FindFieldFromCode(field_idx, shadow_frame.GetMethod(), self, - find_type, Primitive::FieldSize(field_type), - do_access_check); + ArtField* f = FindFieldFromCode(field_idx, shadow_frame.GetMethod(), self, + find_type, Primitive::FieldSize(field_type), + do_access_check); if (UNLIKELY(f == NULL)) { CHECK(self->IsExceptionPending()); return false; @@ -695,9 +703,9 @@ static inline bool DoFieldPut(Thread* self, const ShadowFrame& shadow_frame, const Instruction* inst) { bool is_static = (find_type == StaticObjectWrite) || (find_type == StaticPrimitiveWrite); uint32_t field_idx = is_static ? inst->VRegB_21c() : inst->VRegC_22c(); - Field* f = FindFieldFromCode(field_idx, shadow_frame.GetMethod(), self, - find_type, Primitive::FieldSize(field_type), - do_access_check); + ArtField* f = FindFieldFromCode(field_idx, shadow_frame.GetMethod(), self, + find_type, Primitive::FieldSize(field_type), + do_access_check); if (UNLIKELY(f == NULL)) { CHECK(self->IsExceptionPending()); return false; @@ -3052,7 +3060,7 @@ static inline JValue Execute(Thread* self, MethodHelper& mh, const DexFile::Code } } -void EnterInterpreterFromInvoke(Thread* self, AbstractMethod* method, Object* receiver, +void EnterInterpreterFromInvoke(Thread* self, ArtMethod* method, Object* receiver, uint32_t* args, JValue* result) { DCHECK_EQ(self, Thread::Current()); if (UNLIKELY(__builtin_frame_address(0) < self->GetStackEnd())) { @@ -3072,7 +3080,7 @@ void EnterInterpreterFromInvoke(Thread* self, AbstractMethod* method, Object* re return; } else { DCHECK(method->IsNative()); - num_regs = num_ins = AbstractMethod::NumArgRegisters(mh.GetShorty()); + num_regs = num_ins = ArtMethod::NumArgRegisters(mh.GetShorty()); if (!method->IsStatic()) { num_regs++; num_ins++; @@ -3172,7 +3180,7 @@ extern "C" void artInterpreterToInterpreterBridge(Thread* self, MethodHelper& mh return; } - AbstractMethod* method = shadow_frame->GetMethod(); + ArtMethod* method = shadow_frame->GetMethod(); if (method->IsStatic() && !method->GetDeclaringClass()->IsInitializing()) { if (!Runtime::Current()->GetClassLinker()->EnsureInitialized(method->GetDeclaringClass(), true, true)) { diff --git a/runtime/interpreter/interpreter.h b/runtime/interpreter/interpreter.h index af4a1472ee..49e8de08ec 100644 --- a/runtime/interpreter/interpreter.h +++ b/runtime/interpreter/interpreter.h @@ -22,7 +22,7 @@ namespace art { namespace mirror { -class AbstractMethod; +class ArtMethod; class Object; } // namespace mirror @@ -33,8 +33,8 @@ class Thread; namespace interpreter { -// Called by AbstractMethod::Invoke, shadow frames arguments are taken from the args array. -extern void EnterInterpreterFromInvoke(Thread* self, mirror::AbstractMethod* method, +// Called by ArtMethod::Invoke, shadow frames arguments are taken from the args array. +extern void EnterInterpreterFromInvoke(Thread* self, mirror::ArtMethod* method, mirror::Object* receiver, uint32_t* args, JValue* result) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); diff --git a/runtime/invoke_arg_array_builder.h b/runtime/invoke_arg_array_builder.h index 084d005e96..f615e8ebac 100644 --- a/runtime/invoke_arg_array_builder.h +++ b/runtime/invoke_arg_array_builder.h @@ -17,7 +17,7 @@ #ifndef ART_RUNTIME_INVOKE_ARG_ARRAY_BUILDER_H_ #define ART_RUNTIME_INVOKE_ARG_ARRAY_BUILDER_H_ -#include "mirror/abstract_method.h" +#include "mirror/art_method.h" #include "mirror/object.h" #include "scoped_thread_state_change.h" diff --git a/runtime/jdwp/jdwp.h b/runtime/jdwp/jdwp.h index 010a2079b4..a1657d098b 100644 --- a/runtime/jdwp/jdwp.h +++ b/runtime/jdwp/jdwp.h @@ -32,7 +32,7 @@ struct iovec; namespace art { namespace mirror { -class AbstractMethod; + class ArtMethod; } // namespace mirror class Thread; diff --git a/runtime/jdwp/object_registry.h b/runtime/jdwp/object_registry.h index 345f0ad73a..7f162ca80b 100644 --- a/runtime/jdwp/object_registry.h +++ b/runtime/jdwp/object_registry.h @@ -22,9 +22,9 @@ #include #include "jdwp/jdwp.h" +#include "mirror/art_field-inl.h" #include "mirror/class.h" #include "mirror/class-inl.h" -#include "mirror/field-inl.h" #include "mirror/object-inl.h" #include "safe_map.h" diff --git a/runtime/jni_internal.cc b/runtime/jni_internal.cc index d1de6e6f5a..852dd00a77 100644 --- a/runtime/jni_internal.cc +++ b/runtime/jni_internal.cc @@ -32,10 +32,10 @@ #include "interpreter/interpreter.h" #include "invoke_arg_array_builder.h" #include "jni.h" +#include "mirror/art_field-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/class_loader.h" -#include "mirror/field-inl.h" -#include "mirror/abstract_method-inl.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" #include "mirror/throwable.h" @@ -49,7 +49,8 @@ #include "UniquePtr.h" #include "well_known_classes.h" -using ::art::mirror::AbstractMethod; +using ::art::mirror::ArtField; +using ::art::mirror::ArtMethod; using ::art::mirror::Array; using ::art::mirror::BooleanArray; using ::art::mirror::ByteArray; @@ -57,7 +58,6 @@ using ::art::mirror::CharArray; using ::art::mirror::Class; using ::art::mirror::ClassLoader; using ::art::mirror::DoubleArray; -using ::art::mirror::Field; using ::art::mirror::FloatArray; using ::art::mirror::IntArray; using ::art::mirror::LongArray; @@ -101,7 +101,7 @@ static bool IsBadJniVersion(int version) { return version != JNI_VERSION_1_2 && version != JNI_VERSION_1_4 && version != JNI_VERSION_1_6; } -static void CheckMethodArguments(AbstractMethod* m, uint32_t* args) +static void CheckMethodArguments(ArtMethod* m, uint32_t* args) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { MethodHelper mh(m); const DexFile::TypeList* params = mh.GetParameterTypeList(); @@ -144,7 +144,7 @@ static void CheckMethodArguments(AbstractMethod* m, uint32_t* args) } } -void InvokeWithArgArray(const ScopedObjectAccess& soa, AbstractMethod* method, +void InvokeWithArgArray(const ScopedObjectAccess& soa, ArtMethod* method, ArgArray* arg_array, JValue* result, char result_type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { uint32_t* args = arg_array->GetArray(); @@ -157,7 +157,7 @@ void InvokeWithArgArray(const ScopedObjectAccess& soa, AbstractMethod* method, static JValue InvokeWithVarArgs(const ScopedObjectAccess& soa, jobject obj, jmethodID mid, va_list args) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - AbstractMethod* method = soa.DecodeMethod(mid); + ArtMethod* method = soa.DecodeMethod(mid); Object* receiver = method->IsStatic() ? NULL : soa.Decode(obj); MethodHelper mh(method); JValue result; @@ -167,7 +167,7 @@ static JValue InvokeWithVarArgs(const ScopedObjectAccess& soa, jobject obj, return result; } -static AbstractMethod* FindVirtualMethod(Object* receiver, AbstractMethod* method) +static ArtMethod* FindVirtualMethod(Object* receiver, ArtMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return receiver->GetClass()->FindVirtualMethodForVirtualOrInterface(method); } @@ -176,7 +176,7 @@ static JValue InvokeVirtualOrInterfaceWithJValues(const ScopedObjectAccess& soa, jobject obj, jmethodID mid, jvalue* args) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { Object* receiver = soa.Decode(obj); - AbstractMethod* method = FindVirtualMethod(receiver, soa.DecodeMethod(mid)); + ArtMethod* method = FindVirtualMethod(receiver, soa.DecodeMethod(mid)); MethodHelper mh(method); JValue result; ArgArray arg_array(mh.GetShorty(), mh.GetShortyLength()); @@ -189,7 +189,7 @@ static JValue InvokeVirtualOrInterfaceWithVarArgs(const ScopedObjectAccess& soa, jobject obj, jmethodID mid, va_list args) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { Object* receiver = soa.Decode(obj); - AbstractMethod* method = FindVirtualMethod(receiver, soa.DecodeMethod(mid)); + ArtMethod* method = FindVirtualMethod(receiver, soa.DecodeMethod(mid)); MethodHelper mh(method); JValue result; ArgArray arg_array(mh.GetShorty(), mh.GetShortyLength()); @@ -239,7 +239,7 @@ static jmethodID FindMethodID(ScopedObjectAccess& soa, jclass jni_class, return NULL; } - AbstractMethod* method = NULL; + ArtMethod* method = NULL; if (is_static) { method = c->FindDirectMethod(name, sig); } else { @@ -261,7 +261,7 @@ static jmethodID FindMethodID(ScopedObjectAccess& soa, jclass jni_class, static ClassLoader* GetClassLoader(const ScopedObjectAccess& soa) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - AbstractMethod* method = soa.Self()->GetCurrentMethod(NULL); + ArtMethod* method = soa.Self()->GetCurrentMethod(NULL); if (method == NULL || method == soa.DecodeMethod(WellKnownClasses::java_lang_Runtime_nativeLoad)) { return soa.Self()->GetClassLoaderOverride(); @@ -277,7 +277,7 @@ static jfieldID FindFieldID(const ScopedObjectAccess& soa, jclass jni_class, con return NULL; } - Field* field = NULL; + ArtField* field = NULL; Class* field_type; ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); if (sig[1] != '\0') { @@ -290,7 +290,7 @@ static jfieldID FindFieldID(const ScopedObjectAccess& soa, jclass jni_class, con // Failed to find type from the signature of the field. DCHECK(soa.Self()->IsExceptionPending()); ThrowLocation throw_location; - SirtRef cause(soa.Self(), soa.Self()->GetException(&throw_location)); + SirtRef cause(soa.Self(), soa.Self()->GetException(&throw_location)); soa.Self()->ClearException(); soa.Self()->ThrowNewExceptionF(throw_location, "Ljava/lang/NoSuchFieldError;", "no type \"%s\" found and so no field \"%s\" could be found in class " @@ -561,7 +561,7 @@ class Libraries { } // See section 11.3 "Linking Native Methods" of the JNI spec. - void* FindNativeMethod(const AbstractMethod* m, std::string& detail) + void* FindNativeMethod(const ArtMethod* m, std::string& detail) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { std::string jni_short_name(JniShortName(m)); std::string jni_long_name(JniLongName(m)); @@ -598,7 +598,7 @@ class Libraries { JValue InvokeWithJValues(const ScopedObjectAccess& soa, jobject obj, jmethodID mid, jvalue* args) { - AbstractMethod* method = soa.DecodeMethod(mid); + ArtMethod* method = soa.DecodeMethod(mid); Object* receiver = method->IsStatic() ? NULL : soa.Decode(obj); MethodHelper mh(method); JValue result; @@ -620,10 +620,10 @@ class JNI { } static jclass FindClass(JNIEnv* env, const char* name) { - ScopedObjectAccess soa(env); Runtime* runtime = Runtime::Current(); ClassLinker* class_linker = runtime->GetClassLinker(); std::string descriptor(NormalizeJniClassDescriptor(name)); + ScopedObjectAccess soa(env); Class* c = NULL; if (runtime->IsStarted()) { ClassLoader* cl = GetClassLoader(soa); @@ -636,26 +636,50 @@ class JNI { static jmethodID FromReflectedMethod(JNIEnv* env, jobject java_method) { ScopedObjectAccess soa(env); - AbstractMethod* method = soa.Decode(java_method); + jobject art_method = env->GetObjectField(java_method, + WellKnownClasses::java_lang_reflect_AbstractMethod_artMethod); + ArtMethod* method = soa.Decode(art_method); + DCHECK(method != NULL); return soa.EncodeMethod(method); } static jfieldID FromReflectedField(JNIEnv* env, jobject java_field) { ScopedObjectAccess soa(env); - Field* field = soa.Decode(java_field); + jobject art_field = env->GetObjectField(java_field, + WellKnownClasses::java_lang_reflect_Field_artField); + ArtField* field = soa.Decode(art_field); + DCHECK(field != NULL); return soa.EncodeField(field); } static jobject ToReflectedMethod(JNIEnv* env, jclass, jmethodID mid, jboolean) { ScopedObjectAccess soa(env); - AbstractMethod* method = soa.DecodeMethod(mid); - return soa.AddLocalReference(method); + ArtMethod* m = soa.DecodeMethod(mid); + jobject art_method = soa.AddLocalReference(m); + jobject reflect_method = env->AllocObject(WellKnownClasses::java_lang_reflect_Method); + if (env->ExceptionCheck()) { + return NULL; + } + SetObjectField(env, + reflect_method, + WellKnownClasses::java_lang_reflect_AbstractMethod_artMethod, + art_method); + return reflect_method; } static jobject ToReflectedField(JNIEnv* env, jclass, jfieldID fid, jboolean) { ScopedObjectAccess soa(env); - Field* field = soa.DecodeField(fid); - return soa.AddLocalReference(field); + ArtField* f = soa.DecodeField(fid); + jobject art_field = soa.AddLocalReference(f); + jobject reflect_field = env->AllocObject(WellKnownClasses::java_lang_reflect_Field); + if (env->ExceptionCheck()) { + return NULL; + } + SetObjectField(env, + reflect_field, + WellKnownClasses::java_lang_reflect_Field_artField, + art_field); + return reflect_field; } static jclass GetObjectClass(JNIEnv* env, jobject java_object) { @@ -678,7 +702,6 @@ class JNI { } static jboolean IsInstanceOf(JNIEnv* env, jobject jobj, jclass java_class) { - ScopedObjectAccess soa(env); if (java_class == NULL) { JniAbortF("IsInstanceOf", "null class (second argument)"); } @@ -686,6 +709,7 @@ class JNI { // Note: JNI is different from regular Java instanceof in this respect return JNI_TRUE; } else { + ScopedObjectAccess soa(env); Object* obj = soa.Decode(jobj); Class* c = soa.Decode(java_class); return obj->InstanceOf(c) ? JNI_TRUE : JNI_FALSE; @@ -718,13 +742,13 @@ class JNI { static void ExceptionDescribe(JNIEnv* env) { ScopedObjectAccess soa(env); - SirtRef old_throw_this_object(soa.Self(), NULL); - SirtRef old_throw_method(soa.Self(), NULL); - SirtRef old_exception(soa.Self(), NULL); + SirtRef old_throw_this_object(soa.Self(), NULL); + SirtRef old_throw_method(soa.Self(), NULL); + SirtRef old_exception(soa.Self(), NULL); uint32_t old_throw_dex_pc; { ThrowLocation old_throw_location; - mirror::Throwable* old_exception_obj = soa.Self()->GetException(&old_throw_location); + Throwable* old_exception_obj = soa.Self()->GetException(&old_throw_location); old_throw_this_object.reset(old_throw_location.GetThis()); old_throw_method.reset(old_throw_location.GetMethod()); old_exception.reset(old_exception_obj); @@ -855,8 +879,12 @@ class JNI { } static jboolean IsSameObject(JNIEnv* env, jobject obj1, jobject obj2) { - ScopedObjectAccess soa(env); - return (soa.Decode(obj1) == soa.Decode(obj2)) ? JNI_TRUE : JNI_FALSE; + if (obj1 == obj2) { + return JNI_TRUE; + } else { + ScopedObjectAccess soa(env); + return (soa.Decode(obj1) == soa.Decode(obj2)) ? JNI_TRUE : JNI_FALSE; + } } static jobject AllocObject(JNIEnv* env, jclass java_class) { @@ -1316,8 +1344,8 @@ class JNI { va_end(ap); } - static void CallNonvirtualVoidMethodV(JNIEnv* env, - jobject obj, jclass, jmethodID mid, va_list args) { + static void CallNonvirtualVoidMethodV(JNIEnv* env, jobject obj, jclass, jmethodID mid, + va_list args) { ScopedObjectAccess soa(env); InvokeWithVarArgs(soa, obj, mid, args); } @@ -1342,13 +1370,13 @@ class JNI { static jobject GetObjectField(JNIEnv* env, jobject obj, jfieldID fid) { ScopedObjectAccess soa(env); Object* o = soa.Decode(obj); - Field* f = soa.DecodeField(fid); + ArtField* f = soa.DecodeField(fid); return soa.AddLocalReference(f->GetObject(o)); } static jobject GetStaticObjectField(JNIEnv* env, jclass, jfieldID fid) { ScopedObjectAccess soa(env); - Field* f = soa.DecodeField(fid); + ArtField* f = soa.DecodeField(fid); return soa.AddLocalReference(f->GetObject(f->GetDeclaringClass())); } @@ -1356,37 +1384,37 @@ class JNI { ScopedObjectAccess soa(env); Object* o = soa.Decode(java_object); Object* v = soa.Decode(java_value); - Field* f = soa.DecodeField(fid); + ArtField* f = soa.DecodeField(fid); f->SetObject(o, v); } static void SetStaticObjectField(JNIEnv* env, jclass, jfieldID fid, jobject java_value) { ScopedObjectAccess soa(env); Object* v = soa.Decode(java_value); - Field* f = soa.DecodeField(fid); + ArtField* f = soa.DecodeField(fid); f->SetObject(f->GetDeclaringClass(), v); } #define GET_PRIMITIVE_FIELD(fn, instance) \ ScopedObjectAccess soa(env); \ Object* o = soa.Decode(instance); \ - Field* f = soa.DecodeField(fid); \ + ArtField* f = soa.DecodeField(fid); \ return f->fn(o) #define GET_STATIC_PRIMITIVE_FIELD(fn) \ ScopedObjectAccess soa(env); \ - Field* f = soa.DecodeField(fid); \ + ArtField* f = soa.DecodeField(fid); \ return f->fn(f->GetDeclaringClass()) #define SET_PRIMITIVE_FIELD(fn, instance, value) \ ScopedObjectAccess soa(env); \ Object* o = soa.Decode(instance); \ - Field* f = soa.DecodeField(fid); \ + ArtField* f = soa.DecodeField(fid); \ f->fn(o, value) #define SET_STATIC_PRIMITIVE_FIELD(fn, value) \ ScopedObjectAccess soa(env); \ - Field* f = soa.DecodeField(fid); \ + ArtField* f = soa.DecodeField(fid); \ f->fn(f->GetDeclaringClass(), value) static jboolean GetBooleanField(JNIEnv* env, jobject obj, jfieldID fid) { @@ -1806,7 +1834,7 @@ class JNI { static jsize GetArrayLength(JNIEnv* env, jarray java_array) { ScopedObjectAccess soa(env); Object* obj = soa.Decode(java_array); - if (!obj->IsArrayInstance()) { + if (UNLIKELY(!obj->IsArrayInstance())) { JniAbortF("GetArrayLength", "not an array: %s", PrettyTypeOf(obj).c_str()); } Array* array = obj->AsArray(); @@ -1863,12 +1891,12 @@ class JNI { } static jobjectArray NewObjectArray(JNIEnv* env, jsize length, jclass element_jclass, jobject initial_element) { - ScopedObjectAccess soa(env); if (length < 0) { JniAbortF("NewObjectArray", "negative array length: %d", length); } // Compute the array class corresponding to the given element class. + ScopedObjectAccess soa(env); Class* element_class = soa.Decode(element_jclass); std::string descriptor; descriptor += "["; @@ -2080,7 +2108,7 @@ class JNI { ++sig; } - AbstractMethod* m = c->FindDirectMethod(name, sig); + ArtMethod* m = c->FindDirectMethod(name, sig); if (m == NULL) { m = c->FindVirtualMethod(name, sig); } @@ -2111,13 +2139,13 @@ class JNI { VLOG(jni) << "[Unregistering JNI native methods for " << PrettyClass(c) << "]"; for (size_t i = 0; i < c->NumDirectMethods(); ++i) { - AbstractMethod* m = c->GetDirectMethod(i); + ArtMethod* m = c->GetDirectMethod(i); if (m->IsNative()) { m->UnregisterNative(soa.Self()); } } for (size_t i = 0; i < c->NumVirtualMethods(); ++i) { - AbstractMethod* m = c->GetVirtualMethod(i); + ArtMethod* m = c->GetVirtualMethod(i); if (m->IsNative()) { m->UnregisterNative(soa.Self()); } @@ -2899,7 +2927,7 @@ bool JavaVMExt::LoadNativeLibrary(const std::string& path, ClassLoader* class_lo return was_successful; } -void* JavaVMExt::FindCodeForNativeMethod(AbstractMethod* m) { +void* JavaVMExt::FindCodeForNativeMethod(ArtMethod* m) { CHECK(m->IsNative()); Class* c = m->GetDeclaringClass(); diff --git a/runtime/jni_internal.h b/runtime/jni_internal.h index fcac4811c6..e3ffc8421b 100644 --- a/runtime/jni_internal.h +++ b/runtime/jni_internal.h @@ -38,10 +38,10 @@ namespace art { namespace mirror { -class AbstractMethod; -class ClassLoader; -class Field; -} + class ArtField; + class ArtMethod; + class ClassLoader; +} // namespace mirror class ArgArray; union JValue; class Libraries; @@ -55,7 +55,7 @@ void RegisterNativeMethods(JNIEnv* env, const char* jni_class_name, const JNINat JValue InvokeWithJValues(const ScopedObjectAccess&, jobject obj, jmethodID mid, jvalue* args) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); -void InvokeWithArgArray(const ScopedObjectAccess& soa, mirror::AbstractMethod* method, +void InvokeWithArgArray(const ScopedObjectAccess& soa, mirror::ArtMethod* method, ArgArray *arg_array, JValue* result, char result_type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); @@ -79,7 +79,7 @@ struct JavaVMExt : public JavaVM { * Returns a pointer to the code for the native method 'm', found * using dlsym(3) on every native library that's been loaded so far. */ - void* FindCodeForNativeMethod(mirror::AbstractMethod* m) + void* FindCodeForNativeMethod(mirror::ArtMethod* m) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void DumpForSigQuit(std::ostream& os); diff --git a/runtime/jni_internal_test.cc b/runtime/jni_internal_test.cc index c8b9eb95e3..234e40ac46 100644 --- a/runtime/jni_internal_test.cc +++ b/runtime/jni_internal_test.cc @@ -22,7 +22,7 @@ #include "common_test.h" #include "invoke_arg_array_builder.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/object_array-inl.h" #include "mirror/object-inl.h" @@ -43,7 +43,8 @@ class JniInternalTest : public CommonTest { vm_->AttachCurrentThread(&env_, NULL); - ScopedLocalRef aioobe(env_, env_->FindClass("java/lang/ArrayIndexOutOfBoundsException")); + ScopedLocalRef aioobe(env_, + env_->FindClass("java/lang/ArrayIndexOutOfBoundsException")); CHECK(aioobe.get() != NULL); aioobe_ = reinterpret_cast(env_->NewGlobalRef(aioobe.get())); @@ -51,7 +52,8 @@ class JniInternalTest : public CommonTest { CHECK(ase.get() != NULL); ase_ = reinterpret_cast(env_->NewGlobalRef(ase.get())); - ScopedLocalRef sioobe(env_, env_->FindClass("java/lang/StringIndexOutOfBoundsException")); + ScopedLocalRef sioobe(env_, + env_->FindClass("java/lang/StringIndexOutOfBoundsException")); CHECK(sioobe.get() != NULL); sioobe_ = reinterpret_cast(env_->NewGlobalRef(sioobe.get())); } @@ -76,7 +78,7 @@ class JniInternalTest : public CommonTest { CommonTest::TearDown(); } - void DoCompile(mirror::AbstractMethod*& method, + void DoCompile(mirror::ArtMethod*& method, mirror::Object*& receiver, bool is_static, const char* method_name, const char* method_signature) @@ -95,7 +97,8 @@ class JniInternalTest : public CommonTest { CompileVirtualMethod(class_loader.get(), class_name, method_name, method_signature); } - mirror::Class* c = class_linker_->FindClass(DotToDescriptor(class_name).c_str(), class_loader.get()); + mirror::Class* c = class_linker_->FindClass(DotToDescriptor(class_name).c_str(), + class_loader.get()); CHECK(c != NULL); method = is_static ? c->FindDirectMethod(method_name, method_signature) @@ -111,7 +114,7 @@ class JniInternalTest : public CommonTest { } void InvokeNopMethod(bool is_static) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* method; + mirror::ArtMethod* method; mirror::Object* receiver; DoCompile(method, receiver, is_static, "nop", "()V"); @@ -127,7 +130,7 @@ class JniInternalTest : public CommonTest { void InvokeIdentityByteMethod(bool is_static) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* method; + mirror::ArtMethod* method; mirror::Object* receiver; DoCompile(method, receiver, is_static, "identity", "(I)I"); @@ -163,7 +166,7 @@ class JniInternalTest : public CommonTest { void InvokeIdentityIntMethod(bool is_static) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* method; + mirror::ArtMethod* method; mirror::Object* receiver; DoCompile(method, receiver, is_static, "identity", "(I)I"); @@ -199,7 +202,7 @@ class JniInternalTest : public CommonTest { void InvokeIdentityDoubleMethod(bool is_static) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* method; + mirror::ArtMethod* method; mirror::Object* receiver; DoCompile(method, receiver, is_static, "identity", "(D)D"); @@ -243,7 +246,7 @@ class JniInternalTest : public CommonTest { void InvokeSumIntIntMethod(bool is_static) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* method; + mirror::ArtMethod* method; mirror::Object* receiver; DoCompile(method, receiver, is_static, "sum", "(II)I"); @@ -289,7 +292,7 @@ class JniInternalTest : public CommonTest { void InvokeSumIntIntIntMethod(bool is_static) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* method; + mirror::ArtMethod* method; mirror::Object* receiver; DoCompile(method, receiver, is_static, "sum", "(III)I"); @@ -340,7 +343,7 @@ class JniInternalTest : public CommonTest { void InvokeSumIntIntIntIntMethod(bool is_static) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* method; + mirror::ArtMethod* method; mirror::Object* receiver; DoCompile(method, receiver, is_static, "sum", "(IIII)I"); @@ -396,7 +399,7 @@ class JniInternalTest : public CommonTest { void InvokeSumIntIntIntIntIntMethod(bool is_static) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* method; + mirror::ArtMethod* method; mirror::Object* receiver; DoCompile(method, receiver, is_static, "sum", "(IIIII)I"); @@ -457,7 +460,7 @@ class JniInternalTest : public CommonTest { void InvokeSumDoubleDoubleMethod(bool is_static) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* method; + mirror::ArtMethod* method; mirror::Object* receiver; DoCompile(method, receiver, is_static, "sum", "(DD)D"); @@ -523,7 +526,7 @@ class JniInternalTest : public CommonTest { void InvokeSumDoubleDoubleDoubleMethod(bool is_static) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* method; + mirror::ArtMethod* method; mirror::Object* receiver; DoCompile(method, receiver, is_static, "sum", "(DDD)D"); @@ -578,7 +581,7 @@ class JniInternalTest : public CommonTest { void InvokeSumDoubleDoubleDoubleDoubleMethod(bool is_static) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* method; + mirror::ArtMethod* method; mirror::Object* receiver; DoCompile(method, receiver, is_static, "sum", "(DDDD)D"); @@ -642,7 +645,7 @@ class JniInternalTest : public CommonTest { void InvokeSumDoubleDoubleDoubleDoubleDoubleMethod(bool is_static) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* method; + mirror::ArtMethod* method; mirror::Object* receiver; DoCompile(method, receiver, is_static, "sum", "(DDDDD)D"); @@ -891,6 +894,11 @@ TEST_F(JniInternalTest, GetMethodID) { method = env_->GetMethodID(jlstring, "valueOf", "(I)Ljava/lang/String;"); EXPECT_EQ(static_cast(NULL), method); EXPECT_EXCEPTION(jlnsme); + + // Check that GetMethodID for java.lang.NoSuchMethodError.(String) finds the constructor + method = env_->GetMethodID(jlnsme, "", "(Ljava/lang/String;)V"); + EXPECT_NE(static_cast(NULL), method); + EXPECT_FALSE(env_->ExceptionCheck()); } TEST_F(JniInternalTest, GetStaticMethodID) { @@ -933,6 +941,9 @@ TEST_F(JniInternalTest, FromReflectedField_ToReflectedField) { // ...and back again. jfieldID fid2 = env_->FromReflectedField(field); ASSERT_TRUE(fid2 != NULL); + // Make sure we can actually use it. + jstring s = env_->NewStringUTF("poop"); + ASSERT_EQ(4, env_->GetIntField(s, fid2)); } TEST_F(JniInternalTest, FromReflectedMethod_ToReflectedMethod) { @@ -948,6 +959,13 @@ TEST_F(JniInternalTest, FromReflectedMethod_ToReflectedMethod) { // ...and back again. jmethodID mid2 = env_->FromReflectedMethod(method); ASSERT_TRUE(mid2 != NULL); + // Make sure we can actually use it. + jstring s = env_->NewStringUTF("poop"); + // TODO: this should return 4, but the runtime skips the method + // invoke because the runtime isn't started. In the future it would + // be nice to use interpretter for things like this. This still does + // validate that we have a sane jmethodID value. + ASSERT_EQ(0, env_->CallIntMethod(s, mid2)); } void BogusMethod() { @@ -986,7 +1004,13 @@ TEST_F(JniInternalTest, RegisterNatives) { env_->UnregisterNatives(jlobject); } -#define EXPECT_PRIMITIVE_ARRAY(new_fn, get_region_fn, set_region_fn, get_elements_fn, release_elements_fn, scalar_type, expected_class_descriptor) \ +#define EXPECT_PRIMITIVE_ARRAY(new_fn, \ + get_region_fn, \ + set_region_fn, \ + get_elements_fn, \ + release_elements_fn, \ + scalar_type, \ + expected_class_descriptor) \ jsize size = 4; \ /* Allocate an array and check it has the right type and length. */ \ scalar_type ## Array a = env_->new_fn(size); \ @@ -1017,47 +1041,60 @@ TEST_F(JniInternalTest, RegisterNatives) { env_->set_region_fn(a, 0, size, &src_buf[0]); \ /* Copy back only part. */ \ env_->get_region_fn(a, 1, size - 2, &dst_buf[1]); \ - EXPECT_NE(memcmp(&src_buf[0], &dst_buf[0], size * sizeof(scalar_type)), 0) << "short copy equal"; \ + EXPECT_NE(memcmp(&src_buf[0], &dst_buf[0], size * sizeof(scalar_type)), 0) \ + << "short copy equal"; \ /* Copy the missing pieces. */ \ env_->get_region_fn(a, 0, 1, &dst_buf[0]); \ env_->get_region_fn(a, size - 1, 1, &dst_buf[size - 1]); \ - EXPECT_EQ(memcmp(&src_buf[0], &dst_buf[0], size * sizeof(scalar_type)), 0) << "fixed copy not equal"; \ + EXPECT_EQ(memcmp(&src_buf[0], &dst_buf[0], size * sizeof(scalar_type)), 0) \ + << "fixed copy not equal"; \ /* Copy back the whole array. */ \ env_->get_region_fn(a, 0, size, &dst_buf[0]); \ - EXPECT_EQ(memcmp(&src_buf[0], &dst_buf[0], size * sizeof(scalar_type)), 0) << "full copy not equal"; \ + EXPECT_EQ(memcmp(&src_buf[0], &dst_buf[0], size * sizeof(scalar_type)), 0) \ + << "full copy not equal"; \ /* GetPrimitiveArrayCritical */ \ void* v = env_->GetPrimitiveArrayCritical(a, NULL); \ - EXPECT_EQ(memcmp(&src_buf[0], v, size * sizeof(scalar_type)), 0) << "GetPrimitiveArrayCritical not equal"; \ + EXPECT_EQ(memcmp(&src_buf[0], v, size * sizeof(scalar_type)), 0) \ + << "GetPrimitiveArrayCritical not equal"; \ env_->ReleasePrimitiveArrayCritical(a, v, 0); \ /* GetXArrayElements */ \ scalar_type* xs = env_->get_elements_fn(a, NULL); \ - EXPECT_EQ(memcmp(&src_buf[0], xs, size * sizeof(scalar_type)), 0) << # get_elements_fn " not equal"; \ + EXPECT_EQ(memcmp(&src_buf[0], xs, size * sizeof(scalar_type)), 0) \ + << # get_elements_fn " not equal"; \ env_->release_elements_fn(a, xs, 0); \ EXPECT_EQ(reinterpret_cast(v), reinterpret_cast(xs)) TEST_F(JniInternalTest, BooleanArrays) { - EXPECT_PRIMITIVE_ARRAY(NewBooleanArray, GetBooleanArrayRegion, SetBooleanArrayRegion, GetBooleanArrayElements, ReleaseBooleanArrayElements, jboolean, "[Z"); + EXPECT_PRIMITIVE_ARRAY(NewBooleanArray, GetBooleanArrayRegion, SetBooleanArrayRegion, + GetBooleanArrayElements, ReleaseBooleanArrayElements, jboolean, "[Z"); } TEST_F(JniInternalTest, ByteArrays) { - EXPECT_PRIMITIVE_ARRAY(NewByteArray, GetByteArrayRegion, SetByteArrayRegion, GetByteArrayElements, ReleaseByteArrayElements, jbyte, "[B"); + EXPECT_PRIMITIVE_ARRAY(NewByteArray, GetByteArrayRegion, SetByteArrayRegion, + GetByteArrayElements, ReleaseByteArrayElements, jbyte, "[B"); } TEST_F(JniInternalTest, CharArrays) { - EXPECT_PRIMITIVE_ARRAY(NewCharArray, GetCharArrayRegion, SetCharArrayRegion, GetCharArrayElements, ReleaseCharArrayElements, jchar, "[C"); + EXPECT_PRIMITIVE_ARRAY(NewCharArray, GetCharArrayRegion, SetCharArrayRegion, + GetCharArrayElements, ReleaseCharArrayElements, jchar, "[C"); } TEST_F(JniInternalTest, DoubleArrays) { - EXPECT_PRIMITIVE_ARRAY(NewDoubleArray, GetDoubleArrayRegion, SetDoubleArrayRegion, GetDoubleArrayElements, ReleaseDoubleArrayElements, jdouble, "[D"); + EXPECT_PRIMITIVE_ARRAY(NewDoubleArray, GetDoubleArrayRegion, SetDoubleArrayRegion, + GetDoubleArrayElements, ReleaseDoubleArrayElements, jdouble, "[D"); } TEST_F(JniInternalTest, FloatArrays) { - EXPECT_PRIMITIVE_ARRAY(NewFloatArray, GetFloatArrayRegion, SetFloatArrayRegion, GetFloatArrayElements, ReleaseFloatArrayElements, jfloat, "[F"); + EXPECT_PRIMITIVE_ARRAY(NewFloatArray, GetFloatArrayRegion, SetFloatArrayRegion, + GetFloatArrayElements, ReleaseFloatArrayElements, jfloat, "[F"); } TEST_F(JniInternalTest, IntArrays) { - EXPECT_PRIMITIVE_ARRAY(NewIntArray, GetIntArrayRegion, SetIntArrayRegion, GetIntArrayElements, ReleaseIntArrayElements, jint, "[I"); + EXPECT_PRIMITIVE_ARRAY(NewIntArray, GetIntArrayRegion, SetIntArrayRegion, + GetIntArrayElements, ReleaseIntArrayElements, jint, "[I"); } TEST_F(JniInternalTest, LongArrays) { - EXPECT_PRIMITIVE_ARRAY(NewLongArray, GetLongArrayRegion, SetLongArrayRegion, GetLongArrayElements, ReleaseLongArrayElements, jlong, "[J"); + EXPECT_PRIMITIVE_ARRAY(NewLongArray, GetLongArrayRegion, SetLongArrayRegion, + GetLongArrayElements, ReleaseLongArrayElements, jlong, "[J"); } TEST_F(JniInternalTest, ShortArrays) { - EXPECT_PRIMITIVE_ARRAY(NewShortArray, GetShortArrayRegion, SetShortArrayRegion, GetShortArrayElements, ReleaseShortArrayElements, jshort, "[S"); + EXPECT_PRIMITIVE_ARRAY(NewShortArray, GetShortArrayRegion, SetShortArrayRegion, + GetShortArrayElements, ReleaseShortArrayElements, jshort, "[S"); } TEST_F(JniInternalTest, NewObjectArray) { @@ -1437,7 +1474,8 @@ TEST_F(JniInternalTest, DeleteLocalRef) { CheckJniAbortCatcher check_jni_abort_catcher; env_->DeleteLocalRef(s); - std::string expected(StringPrintf("native code passing in reference to invalid local reference: %p", s)); + std::string expected(StringPrintf("native code passing in reference to " + "invalid local reference: %p", s)); check_jni_abort_catcher.Check(expected.c_str()); } @@ -1520,7 +1558,8 @@ TEST_F(JniInternalTest, DeleteGlobalRef) { CheckJniAbortCatcher check_jni_abort_catcher; env_->DeleteGlobalRef(o); - std::string expected(StringPrintf("native code passing in reference to invalid global reference: %p", o)); + std::string expected(StringPrintf("native code passing in reference to " + "invalid global reference: %p", o)); check_jni_abort_catcher.Check(expected.c_str()); } @@ -1564,7 +1603,8 @@ TEST_F(JniInternalTest, DeleteWeakGlobalRef) { CheckJniAbortCatcher check_jni_abort_catcher; env_->DeleteWeakGlobalRef(o); - std::string expected(StringPrintf("native code passing in reference to invalid weak global reference: %p", o)); + std::string expected(StringPrintf("native code passing in reference to " + "invalid weak global reference: %p", o)); check_jni_abort_catcher.Check(expected.c_str()); } @@ -1588,7 +1628,7 @@ TEST_F(JniInternalTest, StaticMainMethod) { mirror::Class* klass = class_linker_->FindClass("LMain;", class_loader.get()); ASSERT_TRUE(klass != NULL); - mirror::AbstractMethod* method = klass->FindDirectMethod("main", "([Ljava/lang/String;)V"); + mirror::ArtMethod* method = klass->FindDirectMethod("main", "([Ljava/lang/String;)V"); ASSERT_TRUE(method != NULL); ArgArray arg_array(NULL, 0); diff --git a/runtime/mirror/abstract_method-inl.h b/runtime/mirror/abstract_method-inl.h deleted file mode 100644 index d47b3ebccc..0000000000 --- a/runtime/mirror/abstract_method-inl.h +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Copyright (C) 2011 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_MIRROR_ABSTRACT_METHOD_INL_H_ -#define ART_RUNTIME_MIRROR_ABSTRACT_METHOD_INL_H_ - -#include "abstract_method.h" - -#include "dex_file.h" -#include "entrypoints/entrypoint_utils.h" -#include "object_array.h" -#include "runtime.h" - -namespace art { -namespace mirror { - -inline Class* AbstractMethod::GetDeclaringClass() const { - Class* result = GetFieldObject(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, declaring_class_), false); - DCHECK(result != NULL) << this; - DCHECK(result->IsIdxLoaded() || result->IsErroneous()) << this; - return result; -} - -inline void AbstractMethod::SetDeclaringClass(Class *new_declaring_class) { - SetFieldObject(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, declaring_class_), new_declaring_class, false); -} - -inline uint32_t AbstractMethod::GetAccessFlags() const { - DCHECK(GetDeclaringClass()->IsIdxLoaded() || GetDeclaringClass()->IsErroneous()); - return GetField32(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, access_flags_), false); -} - -inline uint16_t AbstractMethod::GetMethodIndex() const { - DCHECK(GetDeclaringClass()->IsResolved() || GetDeclaringClass()->IsErroneous()); - return GetField32(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, method_index_), false); -} - -inline uint32_t AbstractMethod::GetDexMethodIndex() const { - DCHECK(GetDeclaringClass()->IsLoaded() || GetDeclaringClass()->IsErroneous()); - return GetField32(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, method_dex_index_), false); -} - -inline ObjectArray* AbstractMethod::GetDexCacheStrings() const { - return GetFieldObject*>( - OFFSET_OF_OBJECT_MEMBER(AbstractMethod, dex_cache_strings_), false); -} - -inline ObjectArray* AbstractMethod::GetDexCacheResolvedMethods() const { - return GetFieldObject*>( - OFFSET_OF_OBJECT_MEMBER(AbstractMethod, dex_cache_resolved_methods_), false); -} - -inline ObjectArray* AbstractMethod::GetDexCacheResolvedTypes() const { - return GetFieldObject*>( - OFFSET_OF_OBJECT_MEMBER(AbstractMethod, dex_cache_resolved_types_), false); -} - -inline ObjectArray* AbstractMethod::GetDexCacheInitializedStaticStorage() const { - return GetFieldObject*>( - OFFSET_OF_OBJECT_MEMBER(AbstractMethod, dex_cache_initialized_static_storage_), - false); -} - -inline uint32_t AbstractMethod::GetCodeSize() const { - DCHECK(!IsRuntimeMethod() && !IsProxyMethod()) << PrettyMethod(this); - uintptr_t code = reinterpret_cast(GetEntryPointFromCompiledCode()); - if (code == 0) { - return 0; - } - // TODO: make this Thumb2 specific - code &= ~0x1; - return reinterpret_cast(code)[-1]; -} - -inline bool AbstractMethod::CheckIncompatibleClassChange(InvokeType type) { - switch (type) { - case kStatic: - return !IsStatic(); - case kDirect: - return !IsDirect() || IsStatic(); - case kVirtual: { - Class* methods_class = GetDeclaringClass(); - return IsDirect() || (methods_class->IsInterface() && !IsMiranda()); - } - case kSuper: - return false; // TODO: appropriate checks for call to super class. - case kInterface: { - Class* methods_class = GetDeclaringClass(); - return IsDirect() || !(methods_class->IsInterface() || methods_class->IsObjectClass()); - } - default: - LOG(FATAL) << "Unreachable - invocation type: " << type; - return true; - } -} - -inline void AbstractMethod::AssertPcIsWithinCode(uintptr_t pc) const { - if (!kIsDebugBuild) { - return; - } - if (IsNative() || IsRuntimeMethod() || IsProxyMethod()) { - return; - } - if (pc == GetQuickInstrumentationExitPc()) { - return; - } - const void* code = GetEntryPointFromCompiledCode(); - if (code == GetCompiledCodeToInterpreterBridge() || code == GetQuickInstrumentationEntryPoint()) { - return; - } - ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); - if (code == GetResolutionTrampoline(class_linker)) { - return; - } - DCHECK(IsWithinCode(pc)) - << PrettyMethod(this) - << " pc=" << std::hex << pc - << " code=" << code - << " size=" << GetCodeSize(); -} - -inline uint32_t AbstractMethod::GetOatCodeOffset() const { - DCHECK(!Runtime::Current()->IsStarted()); - return reinterpret_cast(GetEntryPointFromCompiledCode()); -} - -inline void AbstractMethod::SetOatCodeOffset(uint32_t code_offset) { - DCHECK(!Runtime::Current()->IsStarted()); - SetEntryPointFromCompiledCode(reinterpret_cast(code_offset)); -} - -inline uint32_t AbstractMethod::GetOatMappingTableOffset() const { - DCHECK(!Runtime::Current()->IsStarted()); - return reinterpret_cast(GetMappingTable()); -} - -inline void AbstractMethod::SetOatMappingTableOffset(uint32_t mapping_table_offset) { - DCHECK(!Runtime::Current()->IsStarted()); - SetMappingTable(reinterpret_cast(mapping_table_offset)); -} - -inline uint32_t AbstractMethod::GetOatVmapTableOffset() const { - DCHECK(!Runtime::Current()->IsStarted()); - return reinterpret_cast(GetVmapTable()); -} - -inline void AbstractMethod::SetOatVmapTableOffset(uint32_t vmap_table_offset) { - DCHECK(!Runtime::Current()->IsStarted()); - SetVmapTable(reinterpret_cast(vmap_table_offset)); -} - -inline void AbstractMethod::SetOatNativeGcMapOffset(uint32_t gc_map_offset) { - DCHECK(!Runtime::Current()->IsStarted()); - SetNativeGcMap(reinterpret_cast(gc_map_offset)); -} - -inline uint32_t AbstractMethod::GetOatNativeGcMapOffset() const { - DCHECK(!Runtime::Current()->IsStarted()); - return reinterpret_cast(GetNativeGcMap()); -} - -inline bool AbstractMethod::IsRuntimeMethod() const { - return GetDexMethodIndex() == DexFile::kDexNoIndex16; -} - -inline bool AbstractMethod::IsCalleeSaveMethod() const { - if (!IsRuntimeMethod()) { - return false; - } - Runtime* runtime = Runtime::Current(); - bool result = false; - for (int i = 0; i < Runtime::kLastCalleeSaveType; i++) { - if (this == runtime->GetCalleeSaveMethod(Runtime::CalleeSaveType(i))) { - result = true; - break; - } - } - return result; -} - -inline bool AbstractMethod::IsResolutionMethod() const { - bool result = this == Runtime::Current()->GetResolutionMethod(); - // Check that if we do think it is phony it looks like the resolution method. - DCHECK(!result || IsRuntimeMethod()); - return result; -} -} // namespace mirror -} // namespace art - -#endif // ART_RUNTIME_MIRROR_ABSTRACT_METHOD_INL_H_ diff --git a/runtime/mirror/abstract_method.cc b/runtime/mirror/abstract_method.cc deleted file mode 100644 index b3db5c2721..0000000000 --- a/runtime/mirror/abstract_method.cc +++ /dev/null @@ -1,350 +0,0 @@ -/* - * Copyright (C) 2011 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. - */ - -#include "abstract_method.h" - -#include "abstract_method-inl.h" -#include "base/stringpiece.h" -#include "class-inl.h" -#include "dex_file-inl.h" -#include "dex_instruction.h" -#include "gc/accounting/card_table-inl.h" -#include "interpreter/interpreter.h" -#include "jni_internal.h" -#include "mapping_table.h" -#include "object-inl.h" -#include "object_array.h" -#include "object_array-inl.h" -#include "string.h" -#include "object_utils.h" - -namespace art { -namespace mirror { - -extern "C" void art_portable_invoke_stub(AbstractMethod*, uint32_t*, uint32_t, Thread*, JValue*, char); -extern "C" void art_quick_invoke_stub(AbstractMethod*, uint32_t*, uint32_t, Thread*, JValue*, char); - -// TODO: get global references for these -Class* AbstractMethod::java_lang_reflect_Constructor_ = NULL; -Class* AbstractMethod::java_lang_reflect_Method_ = NULL; - -InvokeType AbstractMethod::GetInvokeType() const { - // TODO: kSuper? - if (GetDeclaringClass()->IsInterface()) { - return kInterface; - } else if (IsStatic()) { - return kStatic; - } else if (IsDirect()) { - return kDirect; - } else { - return kVirtual; - } -} - -void AbstractMethod::SetClasses(Class* java_lang_reflect_Constructor, Class* java_lang_reflect_Method) { - CHECK(java_lang_reflect_Constructor_ == NULL); - CHECK(java_lang_reflect_Constructor != NULL); - java_lang_reflect_Constructor_ = java_lang_reflect_Constructor; - - CHECK(java_lang_reflect_Method_ == NULL); - CHECK(java_lang_reflect_Method != NULL); - java_lang_reflect_Method_ = java_lang_reflect_Method; -} - -void AbstractMethod::ResetClasses() { - CHECK(java_lang_reflect_Constructor_ != NULL); - java_lang_reflect_Constructor_ = NULL; - - CHECK(java_lang_reflect_Method_ != NULL); - java_lang_reflect_Method_ = NULL; -} - -void AbstractMethod::SetDexCacheStrings(ObjectArray* new_dex_cache_strings) { - SetFieldObject(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, dex_cache_strings_), - new_dex_cache_strings, false); -} - -void AbstractMethod::SetDexCacheResolvedMethods(ObjectArray* new_dex_cache_methods) { - SetFieldObject(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, dex_cache_resolved_methods_), - new_dex_cache_methods, false); -} - -void AbstractMethod::SetDexCacheResolvedTypes(ObjectArray* new_dex_cache_classes) { - SetFieldObject(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, dex_cache_resolved_types_), - new_dex_cache_classes, false); -} - -void AbstractMethod::SetDexCacheInitializedStaticStorage(ObjectArray* new_value) { - SetFieldObject(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, dex_cache_initialized_static_storage_), - new_value, false); -} - -size_t AbstractMethod::NumArgRegisters(const StringPiece& shorty) { - CHECK_LE(1, shorty.length()); - uint32_t num_registers = 0; - for (int i = 1; i < shorty.length(); ++i) { - char ch = shorty[i]; - if (ch == 'D' || ch == 'J') { - num_registers += 2; - } else { - num_registers += 1; - } - } - return num_registers; -} - -bool AbstractMethod::IsProxyMethod() const { - return GetDeclaringClass()->IsProxyClass(); -} - -AbstractMethod* AbstractMethod::FindOverriddenMethod() const { - if (IsStatic()) { - return NULL; - } - Class* declaring_class = GetDeclaringClass(); - Class* super_class = declaring_class->GetSuperClass(); - uint16_t method_index = GetMethodIndex(); - ObjectArray* super_class_vtable = super_class->GetVTable(); - AbstractMethod* result = NULL; - // Did this method override a super class method? If so load the result from the super class' - // vtable - if (super_class_vtable != NULL && method_index < super_class_vtable->GetLength()) { - result = super_class_vtable->Get(method_index); - } else { - // Method didn't override superclass method so search interfaces - if (IsProxyMethod()) { - result = GetDexCacheResolvedMethods()->Get(GetDexMethodIndex()); - CHECK_EQ(result, - Runtime::Current()->GetClassLinker()->FindMethodForProxy(GetDeclaringClass(), this)); - } else { - MethodHelper mh(this); - MethodHelper interface_mh; - IfTable* iftable = GetDeclaringClass()->GetIfTable(); - for (size_t i = 0; i < iftable->Count() && result == NULL; i++) { - Class* interface = iftable->GetInterface(i); - for (size_t j = 0; j < interface->NumVirtualMethods(); ++j) { - AbstractMethod* interface_method = interface->GetVirtualMethod(j); - interface_mh.ChangeMethod(interface_method); - if (mh.HasSameNameAndSignature(&interface_mh)) { - result = interface_method; - break; - } - } - } - } - } -#ifndef NDEBUG - MethodHelper result_mh(result); - DCHECK(result == NULL || MethodHelper(this).HasSameNameAndSignature(&result_mh)); -#endif - return result; -} - -uintptr_t AbstractMethod::NativePcOffset(const uintptr_t pc) const { - const void* code = Runtime::Current()->GetInstrumentation()->GetQuickCodeFor(this); - return pc - reinterpret_cast(code); -} - -uint32_t AbstractMethod::ToDexPc(const uintptr_t pc) const { -#if !defined(ART_USE_PORTABLE_COMPILER) - MappingTable table(GetMappingTable()); - if (table.TotalSize() == 0) { - DCHECK(IsNative() || IsCalleeSaveMethod() || IsProxyMethod()) << PrettyMethod(this); - return DexFile::kDexNoIndex; // Special no mapping case - } - const void* code = Runtime::Current()->GetInstrumentation()->GetQuickCodeFor(this); - uint32_t sought_offset = pc - reinterpret_cast(code); - // Assume the caller wants a pc-to-dex mapping so check here first. - typedef MappingTable::PcToDexIterator It; - for (It cur = table.PcToDexBegin(), end = table.PcToDexEnd(); cur != end; ++cur) { - if (cur.NativePcOffset() == sought_offset) { - return cur.DexPc(); - } - } - // Now check dex-to-pc mappings. - typedef MappingTable::DexToPcIterator It2; - for (It2 cur = table.DexToPcBegin(), end = table.DexToPcEnd(); cur != end; ++cur) { - if (cur.NativePcOffset() == sought_offset) { - return cur.DexPc(); - } - } - LOG(FATAL) << "Failed to find Dex offset for PC offset " << reinterpret_cast(sought_offset) - << "(PC " << reinterpret_cast(pc) << ", code=" << code - << ") in " << PrettyMethod(this); - return DexFile::kDexNoIndex; -#else - // Compiler LLVM doesn't use the machine pc, we just use dex pc instead. - return static_cast(pc); -#endif -} - -uintptr_t AbstractMethod::ToNativePc(const uint32_t dex_pc) const { - MappingTable table(GetMappingTable()); - if (table.TotalSize() == 0) { - DCHECK_EQ(dex_pc, 0U); - return 0; // Special no mapping/pc == 0 case - } - // Assume the caller wants a dex-to-pc mapping so check here first. - typedef MappingTable::DexToPcIterator It; - for (It cur = table.DexToPcBegin(), end = table.DexToPcEnd(); cur != end; ++cur) { - if (cur.DexPc() == dex_pc) { - const void* code = Runtime::Current()->GetInstrumentation()->GetQuickCodeFor(this); - return reinterpret_cast(code) + cur.NativePcOffset(); - } - } - // Now check pc-to-dex mappings. - typedef MappingTable::PcToDexIterator It2; - for (It2 cur = table.PcToDexBegin(), end = table.PcToDexEnd(); cur != end; ++cur) { - if (cur.DexPc() == dex_pc) { - const void* code = Runtime::Current()->GetInstrumentation()->GetQuickCodeFor(this); - return reinterpret_cast(code) + cur.NativePcOffset(); - } - } - LOG(FATAL) << "Failed to find native offset for dex pc 0x" << std::hex << dex_pc - << " in " << PrettyMethod(this); - return 0; -} - -uint32_t AbstractMethod::FindCatchBlock(Class* exception_type, uint32_t dex_pc, - bool* has_no_move_exception) const { - MethodHelper mh(this); - const DexFile::CodeItem* code_item = mh.GetCodeItem(); - // Default to handler not found. - uint32_t found_dex_pc = DexFile::kDexNoIndex; - // Iterate over the catch handlers associated with dex_pc. - for (CatchHandlerIterator it(*code_item, dex_pc); it.HasNext(); it.Next()) { - uint16_t iter_type_idx = it.GetHandlerTypeIndex(); - // Catch all case - if (iter_type_idx == DexFile::kDexNoIndex16) { - found_dex_pc = it.GetHandlerAddress(); - break; - } - // Does this catch exception type apply? - Class* iter_exception_type = mh.GetDexCacheResolvedType(iter_type_idx); - if (iter_exception_type == NULL) { - // The verifier should take care of resolving all exception classes early - LOG(WARNING) << "Unresolved exception class when finding catch block: " - << mh.GetTypeDescriptorFromTypeIdx(iter_type_idx); - } else if (iter_exception_type->IsAssignableFrom(exception_type)) { - found_dex_pc = it.GetHandlerAddress(); - break; - } - } - if (found_dex_pc != DexFile::kDexNoIndex) { - const Instruction* first_catch_instr = - Instruction::At(&mh.GetCodeItem()->insns_[found_dex_pc]); - *has_no_move_exception = (first_catch_instr->Opcode() != Instruction::MOVE_EXCEPTION); - } - return found_dex_pc; -} - -void AbstractMethod::Invoke(Thread* self, uint32_t* args, uint32_t args_size, JValue* result, - char result_type) { - if (kIsDebugBuild) { - self->AssertThreadSuspensionIsAllowable(); - CHECK_EQ(kRunnable, self->GetState()); - } - - // Push a transition back into managed code onto the linked list in thread. - ManagedStack fragment; - self->PushManagedStackFragment(&fragment); - - Runtime* runtime = Runtime::Current(); - // Call the invoke stub, passing everything as arguments. - if (UNLIKELY(!runtime->IsStarted())) { - LOG(INFO) << "Not invoking " << PrettyMethod(this) << " for a runtime that isn't started"; - if (result != NULL) { - result->SetJ(0); - } - } else { - const bool kLogInvocationStartAndReturn = false; - if (GetEntryPointFromCompiledCode() != NULL) { - if (kLogInvocationStartAndReturn) { - LOG(INFO) << StringPrintf("Invoking '%s' code=%p", PrettyMethod(this).c_str(), GetEntryPointFromCompiledCode()); - } -#ifdef ART_USE_PORTABLE_COMPILER - (*art_portable_invoke_stub)(this, args, args_size, self, result, result_type); -#else - (*art_quick_invoke_stub)(this, args, args_size, self, result, result_type); -#endif - if (UNLIKELY(reinterpret_cast(self->GetException(NULL)) == -1)) { - // Unusual case where we were running LLVM generated code and an - // exception was thrown to force the activations to be removed from the - // stack. Continue execution in the interpreter. - self->ClearException(); - ShadowFrame* shadow_frame = self->GetAndClearDeoptimizationShadowFrame(result); - self->SetTopOfStack(NULL, 0); - self->SetTopOfShadowStack(shadow_frame); - interpreter::EnterInterpreterFromDeoptimize(self, shadow_frame, result); - } - if (kLogInvocationStartAndReturn) { - LOG(INFO) << StringPrintf("Returned '%s' code=%p", PrettyMethod(this).c_str(), GetEntryPointFromCompiledCode()); - } - } else { - LOG(INFO) << "Not invoking '" << PrettyMethod(this) - << "' code=" << reinterpret_cast(GetEntryPointFromCompiledCode()); - if (result != NULL) { - result->SetJ(0); - } - } - } - - // Pop transition. - self->PopManagedStackFragment(fragment); -} - -bool AbstractMethod::IsRegistered() const { - void* native_method = GetFieldPtr(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, native_method_), false); - CHECK(native_method != NULL); - void* jni_stub = GetJniDlsymLookupStub(); - return native_method != jni_stub; -} - -extern "C" void art_work_around_app_jni_bugs(JNIEnv*, jobject); -void AbstractMethod::RegisterNative(Thread* self, const void* native_method) { - DCHECK(Thread::Current() == self); - CHECK(IsNative()) << PrettyMethod(this); - CHECK(native_method != NULL) << PrettyMethod(this); - if (!self->GetJniEnv()->vm->work_around_app_jni_bugs) { - SetNativeMethod(native_method); - } else { - // We've been asked to associate this method with the given native method but are working - // around JNI bugs, that include not giving Object** SIRT references to native methods. Direct - // the native method to runtime support and store the target somewhere runtime support will - // find it. -#if defined(__i386__) - UNIMPLEMENTED(FATAL); -#else - SetNativeMethod(reinterpret_cast(art_work_around_app_jni_bugs)); -#endif - SetFieldPtr(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, gc_map_), - reinterpret_cast(native_method), false); - } -} - -void AbstractMethod::UnregisterNative(Thread* self) { - CHECK(IsNative()) << PrettyMethod(this); - // restore stub to lookup native pointer via dlsym - RegisterNative(self, GetJniDlsymLookupStub()); -} - -void AbstractMethod::SetNativeMethod(const void* native_method) { - SetFieldPtr(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, native_method_), - native_method, false); -} - -} // namespace mirror -} // namespace art diff --git a/runtime/mirror/abstract_method.h b/runtime/mirror/abstract_method.h deleted file mode 100644 index 5b8c61cd06..0000000000 --- a/runtime/mirror/abstract_method.h +++ /dev/null @@ -1,471 +0,0 @@ -/* - * Copyright (C) 2011 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_MIRROR_ABSTRACT_METHOD_H_ -#define ART_RUNTIME_MIRROR_ABSTRACT_METHOD_H_ - -#include "class.h" -#include "dex_file.h" -#include "invoke_type.h" -#include "locks.h" -#include "modifiers.h" -#include "object.h" - -namespace art { - -struct AbstractMethodOffsets; -struct ConstructorMethodOffsets; -union JValue; -struct MethodClassOffsets; -class MethodHelper; -struct MethodOffsets; -class StringPiece; -class ShadowFrame; - -namespace mirror { - -class StaticStorageBase; - -typedef void (EntryPointFromInterpreter)(Thread* self, MethodHelper& mh, - const DexFile::CodeItem* code_item, ShadowFrame* shadow_frame, JValue* result); - -// C++ mirror of java.lang.reflect.Method and java.lang.reflect.Constructor -class MANAGED AbstractMethod : public Object { - public: - Class* GetDeclaringClass() const; - - void SetDeclaringClass(Class *new_declaring_class) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - - static MemberOffset DeclaringClassOffset() { - return MemberOffset(OFFSETOF_MEMBER(AbstractMethod, declaring_class_)); - } - - static MemberOffset EntryPointFromCompiledCodeOffset() { - return MemberOffset(OFFSETOF_MEMBER(AbstractMethod, entry_point_from_compiled_code_)); - } - - uint32_t GetAccessFlags() const; - - void SetAccessFlags(uint32_t new_access_flags) { - SetField32(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, access_flags_), new_access_flags, false); - } - - // Approximate what kind of method call would be used for this method. - InvokeType GetInvokeType() const; - - // Returns true if the method is declared public. - bool IsPublic() const { - return (GetAccessFlags() & kAccPublic) != 0; - } - - // Returns true if the method is declared private. - bool IsPrivate() const { - return (GetAccessFlags() & kAccPrivate) != 0; - } - - // Returns true if the method is declared static. - bool IsStatic() const { - return (GetAccessFlags() & kAccStatic) != 0; - } - - // Returns true if the method is a constructor. - bool IsConstructor() const { - return (GetAccessFlags() & kAccConstructor) != 0; - } - - // Returns true if the method is static, private, or a constructor. - bool IsDirect() const { - return IsDirect(GetAccessFlags()); - } - - static bool IsDirect(uint32_t access_flags) { - return (access_flags & (kAccStatic | kAccPrivate | kAccConstructor)) != 0; - } - - // Returns true if the method is declared synchronized. - bool IsSynchronized() const { - uint32_t synchonized = kAccSynchronized | kAccDeclaredSynchronized; - return (GetAccessFlags() & synchonized) != 0; - } - - bool IsFinal() const { - return (GetAccessFlags() & kAccFinal) != 0; - } - - bool IsMiranda() const { - return (GetAccessFlags() & kAccMiranda) != 0; - } - - bool IsNative() const { - return (GetAccessFlags() & kAccNative) != 0; - } - - bool IsAbstract() const { - return (GetAccessFlags() & kAccAbstract) != 0; - } - - bool IsSynthetic() const { - return (GetAccessFlags() & kAccSynthetic) != 0; - } - - bool IsProxyMethod() const; - - bool IsPreverified() const { - return (GetAccessFlags() & kAccPreverified) != 0; - } - - void SetPreverified() { - SetAccessFlags(GetAccessFlags() | kAccPreverified); - } - - bool CheckIncompatibleClassChange(InvokeType type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - - uint16_t GetMethodIndex() const; - - size_t GetVtableIndex() const { - return GetMethodIndex(); - } - - void SetMethodIndex(uint16_t new_method_index) { - SetField32(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, method_index_), new_method_index, false); - } - - static MemberOffset MethodIndexOffset() { - return OFFSET_OF_OBJECT_MEMBER(AbstractMethod, method_index_); - } - - uint32_t GetCodeItemOffset() const { - return GetField32(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, code_item_offset_), false); - } - - void SetCodeItemOffset(uint32_t new_code_off) { - SetField32(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, code_item_offset_), new_code_off, false); - } - - // Number of 32bit registers that would be required to hold all the arguments - static size_t NumArgRegisters(const StringPiece& shorty); - - uint32_t GetDexMethodIndex() const; - - void SetDexMethodIndex(uint32_t new_idx) { - SetField32(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, method_dex_index_), new_idx, false); - } - - ObjectArray* GetDexCacheStrings() const; - void SetDexCacheStrings(ObjectArray* new_dex_cache_strings) - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - - static MemberOffset DexCacheStringsOffset() { - return OFFSET_OF_OBJECT_MEMBER(AbstractMethod, dex_cache_strings_); - } - - static MemberOffset DexCacheResolvedMethodsOffset() { - return OFFSET_OF_OBJECT_MEMBER(AbstractMethod, dex_cache_resolved_methods_); - } - - static MemberOffset DexCacheResolvedTypesOffset() { - return OFFSET_OF_OBJECT_MEMBER(AbstractMethod, dex_cache_resolved_types_); - } - - static MemberOffset DexCacheInitializedStaticStorageOffset() { - return OFFSET_OF_OBJECT_MEMBER(AbstractMethod, - dex_cache_initialized_static_storage_); - } - - ObjectArray* GetDexCacheResolvedMethods() const; - void SetDexCacheResolvedMethods(ObjectArray* new_dex_cache_methods) - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - - ObjectArray* GetDexCacheResolvedTypes() const; - void SetDexCacheResolvedTypes(ObjectArray* new_dex_cache_types) - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - - ObjectArray* GetDexCacheInitializedStaticStorage() const; - void SetDexCacheInitializedStaticStorage(ObjectArray* new_value) - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - - // Find the method that this method overrides - AbstractMethod* FindOverriddenMethod() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - - void Invoke(Thread* self, uint32_t* args, uint32_t args_size, JValue* result, char result_type) - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - - EntryPointFromInterpreter* GetEntryPointFromInterpreter() const { - return GetFieldPtr(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, entry_point_from_interpreter_), false); - } - - void SetEntryPointFromInterpreter(EntryPointFromInterpreter* entry_point_from_interpreter) { - SetFieldPtr(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, entry_point_from_interpreter_), entry_point_from_interpreter, false); - } - - const void* GetEntryPointFromCompiledCode() const { - return GetFieldPtr(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, entry_point_from_compiled_code_), false); - } - - void SetEntryPointFromCompiledCode(const void* entry_point_from_compiled_code) { - SetFieldPtr(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, entry_point_from_compiled_code_), entry_point_from_compiled_code, false); - } - - uint32_t GetCodeSize() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - - bool IsWithinCode(uintptr_t pc) const - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - uintptr_t code = reinterpret_cast(GetEntryPointFromCompiledCode()); - if (code == 0) { - return pc == 0; - } - /* - * During a stack walk, a return PC may point to the end of the code + 1 - * (in the case that the last instruction is a call that isn't expected to - * return. Thus, we check <= code + GetCodeSize(). - */ - return (code <= pc && pc <= code + GetCodeSize()); - } - - void AssertPcIsWithinCode(uintptr_t pc) const - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - - uint32_t GetOatCodeOffset() const; - - void SetOatCodeOffset(uint32_t code_offset); - - static MemberOffset GetEntryPointFromCompiledCodeOffset() { - return OFFSET_OF_OBJECT_MEMBER(AbstractMethod, entry_point_from_compiled_code_); - } - - // Callers should wrap the uint8_t* in a MappingTable instance for convenient access. - const uint8_t* GetMappingTable() const { - return GetFieldPtr(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, mapping_table_), false); - } - - void SetMappingTable(const uint8_t* mapping_table) { - SetFieldPtr(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, mapping_table_), - mapping_table, false); - } - - uint32_t GetOatMappingTableOffset() const; - - void SetOatMappingTableOffset(uint32_t mapping_table_offset); - - // Callers should wrap the uint8_t* in a VmapTable instance for convenient access. - const uint8_t* GetVmapTable() const { - return GetFieldPtr(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, vmap_table_), false); - } - - void SetVmapTable(const uint8_t* vmap_table) { - SetFieldPtr(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, vmap_table_), vmap_table, false); - } - - uint32_t GetOatVmapTableOffset() const; - - void SetOatVmapTableOffset(uint32_t vmap_table_offset); - - const uint8_t* GetNativeGcMap() const { - return GetFieldPtr(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, gc_map_), false); - } - void SetNativeGcMap(const uint8_t* data) { - SetFieldPtr(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, gc_map_), data, false); - } - - // When building the oat need a convenient place to stuff the offset of the native GC map. - void SetOatNativeGcMapOffset(uint32_t gc_map_offset); - uint32_t GetOatNativeGcMapOffset() const; - - size_t GetFrameSizeInBytes() const { - DCHECK_EQ(sizeof(size_t), sizeof(uint32_t)); - size_t result = GetField32(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, frame_size_in_bytes_), false); - DCHECK_LE(static_cast(kStackAlignment), result); - return result; - } - - void SetFrameSizeInBytes(size_t new_frame_size_in_bytes) { - DCHECK_EQ(sizeof(size_t), sizeof(uint32_t)); - SetField32(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, frame_size_in_bytes_), - new_frame_size_in_bytes, false); - } - - size_t GetReturnPcOffsetInBytes() const { - return GetFrameSizeInBytes() - kPointerSize; - } - - size_t GetSirtOffsetInBytes() const { - CHECK(IsNative()); - return kPointerSize; - } - - bool IsRegistered() const; - - void RegisterNative(Thread* self, const void* native_method) - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - - void UnregisterNative(Thread* self) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - - static MemberOffset NativeMethodOffset() { - return OFFSET_OF_OBJECT_MEMBER(AbstractMethod, native_method_); - } - - const void* GetNativeMethod() const { - return reinterpret_cast(GetField32(NativeMethodOffset(), false)); - } - - void SetNativeMethod(const void*); - - static MemberOffset GetMethodIndexOffset() { - return OFFSET_OF_OBJECT_MEMBER(AbstractMethod, method_index_); - } - - uint32_t GetCoreSpillMask() const { - return GetField32(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, core_spill_mask_), false); - } - - void SetCoreSpillMask(uint32_t core_spill_mask) { - // Computed during compilation - SetField32(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, core_spill_mask_), core_spill_mask, false); - } - - uint32_t GetFpSpillMask() const { - return GetField32(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, fp_spill_mask_), false); - } - - void SetFpSpillMask(uint32_t fp_spill_mask) { - // Computed during compilation - SetField32(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, fp_spill_mask_), fp_spill_mask, false); - } - - // Is this a CalleSaveMethod or ResolutionMethod and therefore doesn't adhere to normal - // conventions for a method of managed code. Returns false for Proxy methods. - bool IsRuntimeMethod() const; - - // Is this a hand crafted method used for something like describing callee saves? - bool IsCalleeSaveMethod() const; - - bool IsResolutionMethod() const; - - uintptr_t NativePcOffset(const uintptr_t pc) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - - // Converts a native PC to a dex PC. - uint32_t ToDexPc(const uintptr_t pc) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - - // Converts a dex PC to a native PC. - uintptr_t ToNativePc(const uint32_t dex_pc) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - - // Find the catch block for the given exception type and dex_pc. When a catch block is found, - // indicates whether the found catch block is responsible for clearing the exception or whether - // a move-exception instruction is present. - uint32_t FindCatchBlock(Class* exception_type, uint32_t dex_pc, bool* has_no_move_exception) const - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - - static void SetClasses(Class* java_lang_reflect_Constructor, Class* java_lang_reflect_Method); - - static Class* GetConstructorClass() { - return java_lang_reflect_Constructor_; - } - - static Class* GetMethodClass() { - return java_lang_reflect_Method_; - } - - static void ResetClasses(); - - protected: - // Field order required by test "ValidateFieldOrderOfJavaCppUnionClasses". - // The class we are a part of - Class* declaring_class_; - - // short cuts to declaring_class_->dex_cache_ member for fast compiled code access - ObjectArray* dex_cache_initialized_static_storage_; - - // short cuts to declaring_class_->dex_cache_ member for fast compiled code access - ObjectArray* dex_cache_resolved_methods_; - - // short cuts to declaring_class_->dex_cache_ member for fast compiled code access - ObjectArray* dex_cache_resolved_types_; - - // short cuts to declaring_class_->dex_cache_ member for fast compiled code access - ObjectArray* dex_cache_strings_; - - // Access flags; low 16 bits are defined by spec. - uint32_t access_flags_; - - // Offset to the CodeItem. - uint32_t code_item_offset_; - - // Architecture-dependent register spill mask - uint32_t core_spill_mask_; - - // Compiled code associated with this method for callers from managed code. - // May be compiled managed code or a bridge for invoking a native method. - // TODO: Break apart this into portable and quick. - const void* entry_point_from_compiled_code_; - - // Called by the interpreter to execute this method. - EntryPointFromInterpreter* entry_point_from_interpreter_; - - // Architecture-dependent register spill mask - uint32_t fp_spill_mask_; - - // Total size in bytes of the frame - size_t frame_size_in_bytes_; - - // Garbage collection map of native PC offsets (quick) or dex PCs (portable) to reference bitmaps. - const uint8_t* gc_map_; - - // Mapping from native pc to dex pc - const uint32_t* mapping_table_; - - // Index into method_ids of the dex file associated with this method - uint32_t method_dex_index_; - - // For concrete virtual methods, this is the offset of the method in Class::vtable_. - // - // For abstract methods in an interface class, this is the offset of the method in - // "iftable_->Get(n)->GetMethodArray()". - // - // For static and direct methods this is the index in the direct methods table. - uint32_t method_index_; - - // The target native method registered with this method - const void* native_method_; - - // When a register is promoted into a register, the spill mask holds which registers hold dex - // registers. The first promoted register's corresponding dex register is vmap_table_[1], the Nth - // is vmap_table_[N]. vmap_table_[0] holds the length of the table. - const uint16_t* vmap_table_; - - static Class* java_lang_reflect_Constructor_; - static Class* java_lang_reflect_Method_; - - friend struct art::AbstractMethodOffsets; // for verifying offset information - friend struct art::ConstructorMethodOffsets; // for verifying offset information - friend struct art::MethodOffsets; // for verifying offset information - DISALLOW_IMPLICIT_CONSTRUCTORS(AbstractMethod); -}; - -class MANAGED Method : public AbstractMethod {}; - -class MANAGED Constructor : public AbstractMethod {}; - -class MANAGED AbstractMethodClass : public Class { - private: - Object* ORDER_BY_SIGNATURE_; - friend struct art::MethodClassOffsets; // for verifying offset information - DISALLOW_IMPLICIT_CONSTRUCTORS(AbstractMethodClass); -}; - -} // namespace mirror -} // namespace art - -#endif // ART_RUNTIME_MIRROR_ABSTRACT_METHOD_H_ diff --git a/runtime/mirror/art_field-inl.h b/runtime/mirror/art_field-inl.h new file mode 100644 index 0000000000..d8c278c9ac --- /dev/null +++ b/runtime/mirror/art_field-inl.h @@ -0,0 +1,221 @@ +/* + * Copyright (C) 2011 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_MIRROR_ART_FIELD_INL_H_ +#define ART_RUNTIME_MIRROR_ART_FIELD_INL_H_ + +#include "art_field.h" + +#include "base/logging.h" +#include "gc/accounting/card_table-inl.h" +#include "jvalue.h" +#include "object-inl.h" +#include "object_utils.h" +#include "primitive.h" + +namespace art { +namespace mirror { + +inline Class* ArtField::GetDeclaringClass() const { + Class* result = GetFieldObject(OFFSET_OF_OBJECT_MEMBER(ArtField, declaring_class_), false); + DCHECK(result != NULL); + DCHECK(result->IsLoaded() || result->IsErroneous()); + return result; +} + +inline void ArtField::SetDeclaringClass(Class *new_declaring_class) { + SetFieldObject(OFFSET_OF_OBJECT_MEMBER(ArtField, declaring_class_), new_declaring_class, false); +} + +inline uint32_t ArtField::GetAccessFlags() const { + DCHECK(GetDeclaringClass()->IsLoaded() || GetDeclaringClass()->IsErroneous()); + return GetField32(OFFSET_OF_OBJECT_MEMBER(ArtField, access_flags_), false); +} + +inline MemberOffset ArtField::GetOffset() const { + DCHECK(GetDeclaringClass()->IsResolved() || GetDeclaringClass()->IsErroneous()); + return MemberOffset(GetField32(OFFSET_OF_OBJECT_MEMBER(ArtField, offset_), false)); +} + +inline MemberOffset ArtField::GetOffsetDuringLinking() const { + DCHECK(GetDeclaringClass()->IsLoaded() || GetDeclaringClass()->IsErroneous()); + return MemberOffset(GetField32(OFFSET_OF_OBJECT_MEMBER(ArtField, offset_), false)); +} + +inline uint32_t ArtField::Get32(const Object* object) const { + DCHECK(object != NULL) << PrettyField(this); + DCHECK(!IsStatic() || (object == GetDeclaringClass()) || !Runtime::Current()->IsStarted()); + return object->GetField32(GetOffset(), IsVolatile()); +} + +inline void ArtField::Set32(Object* object, uint32_t new_value) const { + DCHECK(object != NULL) << PrettyField(this); + DCHECK(!IsStatic() || (object == GetDeclaringClass()) || !Runtime::Current()->IsStarted()); + object->SetField32(GetOffset(), new_value, IsVolatile()); +} + +inline uint64_t ArtField::Get64(const Object* object) const { + DCHECK(object != NULL) << PrettyField(this); + DCHECK(!IsStatic() || (object == GetDeclaringClass()) || !Runtime::Current()->IsStarted()); + return object->GetField64(GetOffset(), IsVolatile()); +} + +inline void ArtField::Set64(Object* object, uint64_t new_value) const { + DCHECK(object != NULL) << PrettyField(this); + DCHECK(!IsStatic() || (object == GetDeclaringClass()) || !Runtime::Current()->IsStarted()); + object->SetField64(GetOffset(), new_value, IsVolatile()); +} + +inline Object* ArtField::GetObj(const Object* object) const { + DCHECK(object != NULL) << PrettyField(this); + DCHECK(!IsStatic() || (object == GetDeclaringClass()) || !Runtime::Current()->IsStarted()); + return object->GetFieldObject(GetOffset(), IsVolatile()); +} + +inline void ArtField::SetObj(Object* object, const Object* new_value) const { + DCHECK(object != NULL) << PrettyField(this); + DCHECK(!IsStatic() || (object == GetDeclaringClass()) || !Runtime::Current()->IsStarted()); + object->SetFieldObject(GetOffset(), new_value, IsVolatile()); +} + +inline bool ArtField::GetBoolean(const Object* object) const { + DCHECK_EQ(Primitive::kPrimBoolean, FieldHelper(this).GetTypeAsPrimitiveType()) + << PrettyField(this); + return Get32(object); +} + +inline void ArtField::SetBoolean(Object* object, bool z) const { + DCHECK_EQ(Primitive::kPrimBoolean, FieldHelper(this).GetTypeAsPrimitiveType()) + << PrettyField(this); + Set32(object, z); +} + +inline int8_t ArtField::GetByte(const Object* object) const { + DCHECK_EQ(Primitive::kPrimByte, FieldHelper(this).GetTypeAsPrimitiveType()) + << PrettyField(this); + return Get32(object); +} + +inline void ArtField::SetByte(Object* object, int8_t b) const { + DCHECK_EQ(Primitive::kPrimByte, FieldHelper(this).GetTypeAsPrimitiveType()) + << PrettyField(this); + Set32(object, b); +} + +inline uint16_t ArtField::GetChar(const Object* object) const { + DCHECK_EQ(Primitive::kPrimChar, FieldHelper(this).GetTypeAsPrimitiveType()) + << PrettyField(this); + return Get32(object); +} + +inline void ArtField::SetChar(Object* object, uint16_t c) const { + DCHECK_EQ(Primitive::kPrimChar, FieldHelper(this).GetTypeAsPrimitiveType()) + << PrettyField(this); + Set32(object, c); +} + +inline int16_t ArtField::GetShort(const Object* object) const { + DCHECK_EQ(Primitive::kPrimShort, FieldHelper(this).GetTypeAsPrimitiveType()) + << PrettyField(this); + return Get32(object); +} + +inline void ArtField::SetShort(Object* object, int16_t s) const { + DCHECK_EQ(Primitive::kPrimShort, FieldHelper(this).GetTypeAsPrimitiveType()) + << PrettyField(this); + Set32(object, s); +} + +inline int32_t ArtField::GetInt(const Object* object) const { +#ifndef NDEBUG + Primitive::Type type = FieldHelper(this).GetTypeAsPrimitiveType(); + CHECK(type == Primitive::kPrimInt || type == Primitive::kPrimFloat) << PrettyField(this); +#endif + return Get32(object); +} + +inline void ArtField::SetInt(Object* object, int32_t i) const { +#ifndef NDEBUG + Primitive::Type type = FieldHelper(this).GetTypeAsPrimitiveType(); + CHECK(type == Primitive::kPrimInt || type == Primitive::kPrimFloat) << PrettyField(this); +#endif + Set32(object, i); +} + +inline int64_t ArtField::GetLong(const Object* object) const { +#ifndef NDEBUG + Primitive::Type type = FieldHelper(this).GetTypeAsPrimitiveType(); + CHECK(type == Primitive::kPrimLong || type == Primitive::kPrimDouble) << PrettyField(this); +#endif + return Get64(object); +} + +inline void ArtField::SetLong(Object* object, int64_t j) const { +#ifndef NDEBUG + Primitive::Type type = FieldHelper(this).GetTypeAsPrimitiveType(); + CHECK(type == Primitive::kPrimLong || type == Primitive::kPrimDouble) << PrettyField(this); +#endif + Set64(object, j); +} + +inline float ArtField::GetFloat(const Object* object) const { + DCHECK_EQ(Primitive::kPrimFloat, FieldHelper(this).GetTypeAsPrimitiveType()) + << PrettyField(this); + JValue bits; + bits.SetI(Get32(object)); + return bits.GetF(); +} + +inline void ArtField::SetFloat(Object* object, float f) const { + DCHECK_EQ(Primitive::kPrimFloat, FieldHelper(this).GetTypeAsPrimitiveType()) + << PrettyField(this); + JValue bits; + bits.SetF(f); + Set32(object, bits.GetI()); +} + +inline double ArtField::GetDouble(const Object* object) const { + DCHECK_EQ(Primitive::kPrimDouble, FieldHelper(this).GetTypeAsPrimitiveType()) + << PrettyField(this); + JValue bits; + bits.SetJ(Get64(object)); + return bits.GetD(); +} + +inline void ArtField::SetDouble(Object* object, double d) const { + DCHECK_EQ(Primitive::kPrimDouble, FieldHelper(this).GetTypeAsPrimitiveType()) + << PrettyField(this); + JValue bits; + bits.SetD(d); + Set64(object, bits.GetJ()); +} + +inline Object* ArtField::GetObject(const Object* object) const { + DCHECK_EQ(Primitive::kPrimNot, FieldHelper(this).GetTypeAsPrimitiveType()) + << PrettyField(this); + return GetObj(object); +} + +inline void ArtField::SetObject(Object* object, const Object* l) const { + DCHECK_EQ(Primitive::kPrimNot, FieldHelper(this).GetTypeAsPrimitiveType()) + << PrettyField(this); + SetObj(object, l); +} + +} // namespace mirror +} // namespace art + +#endif // ART_RUNTIME_MIRROR_ART_FIELD_INL_H_ diff --git a/runtime/mirror/art_field.cc b/runtime/mirror/art_field.cc new file mode 100644 index 0000000000..a8bbe4bc6a --- /dev/null +++ b/runtime/mirror/art_field.cc @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2011 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. + */ + +#include "art_field.h" + +#include "art_field-inl.h" +#include "gc/accounting/card_table-inl.h" +#include "object-inl.h" +#include "object_utils.h" +#include "runtime.h" +#include "utils.h" + +namespace art { +namespace mirror { + +// TODO: get global references for these +Class* ArtField::java_lang_reflect_ArtField_ = NULL; + +void ArtField::SetClass(Class* java_lang_reflect_ArtField) { + CHECK(java_lang_reflect_ArtField_ == NULL); + CHECK(java_lang_reflect_ArtField != NULL); + java_lang_reflect_ArtField_ = java_lang_reflect_ArtField; +} + +void ArtField::ResetClass() { + CHECK(java_lang_reflect_ArtField_ != NULL); + java_lang_reflect_ArtField_ = NULL; +} + +void ArtField::SetOffset(MemberOffset num_bytes) { + DCHECK(GetDeclaringClass()->IsLoaded() || GetDeclaringClass()->IsErroneous()); +#if 0 // TODO enable later in boot and under !NDEBUG + FieldHelper fh(this); + Primitive::Type type = fh.GetTypeAsPrimitiveType(); + if (type == Primitive::kPrimDouble || type == Primitive::kPrimLong) { + DCHECK_ALIGNED(num_bytes.Uint32Value(), 8); + } +#endif + SetField32(OFFSET_OF_OBJECT_MEMBER(ArtField, offset_), num_bytes.Uint32Value(), false); +} + +} // namespace mirror +} // namespace art diff --git a/runtime/mirror/art_field.h b/runtime/mirror/art_field.h new file mode 100644 index 0000000000..ae34cb1f84 --- /dev/null +++ b/runtime/mirror/art_field.h @@ -0,0 +1,165 @@ +/* + * Copyright (C) 2011 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_MIRROR_ART_FIELD_H_ +#define ART_RUNTIME_MIRROR_ART_FIELD_H_ + +#include "class.h" +#include "modifiers.h" +#include "object.h" + +namespace art { + +struct ArtFieldOffsets; + +namespace mirror { + +// C++ mirror of java.lang.reflect.ArtField +class MANAGED ArtField : public Object { + public: + Class* GetDeclaringClass() const; + + void SetDeclaringClass(Class *new_declaring_class) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + + uint32_t GetAccessFlags() const; + + void SetAccessFlags(uint32_t new_access_flags) { + SetField32(OFFSET_OF_OBJECT_MEMBER(ArtField, access_flags_), new_access_flags, false); + } + + bool IsPublic() const { + return (GetAccessFlags() & kAccPublic) != 0; + } + + bool IsStatic() const { + return (GetAccessFlags() & kAccStatic) != 0; + } + + bool IsFinal() const { + return (GetAccessFlags() & kAccFinal) != 0; + } + + uint32_t GetDexFieldIndex() const { + return GetField32(OFFSET_OF_OBJECT_MEMBER(ArtField, field_dex_idx_), false); + } + + void SetDexFieldIndex(uint32_t new_idx) { + SetField32(OFFSET_OF_OBJECT_MEMBER(ArtField, field_dex_idx_), new_idx, false); + } + + // Offset to field within an Object + MemberOffset GetOffset() const; + + static MemberOffset OffsetOffset() { + return MemberOffset(OFFSETOF_MEMBER(ArtField, offset_)); + } + + MemberOffset GetOffsetDuringLinking() const; + + void SetOffset(MemberOffset num_bytes); + + // field access, null object for static fields + bool GetBoolean(const Object* object) const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + void SetBoolean(Object* object, bool z) const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + int8_t GetByte(const Object* object) const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + void SetByte(Object* object, int8_t b) const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + uint16_t GetChar(const Object* object) const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + void SetChar(Object* object, uint16_t c) const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + int16_t GetShort(const Object* object) const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + void SetShort(Object* object, int16_t s) const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + int32_t GetInt(const Object* object) const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + void SetInt(Object* object, int32_t i) const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + int64_t GetLong(const Object* object) const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + void SetLong(Object* object, int64_t j) const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + float GetFloat(const Object* object) const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + void SetFloat(Object* object, float f) const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + double GetDouble(const Object* object) const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + void SetDouble(Object* object, double d) const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + Object* GetObject(const Object* object) const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + void SetObject(Object* object, const Object* l) const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + + // raw field accesses + uint32_t Get32(const Object* object) const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + void Set32(Object* object, uint32_t new_value) const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + uint64_t Get64(const Object* object) const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + void Set64(Object* object, uint64_t new_value) const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + Object* GetObj(const Object* object) const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + void SetObj(Object* object, const Object* new_value) const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + + static Class* GetJavaLangReflectArtField() { + DCHECK(java_lang_reflect_ArtField_ != NULL); + return java_lang_reflect_ArtField_; + } + + static void SetClass(Class* java_lang_reflect_ArtField); + static void ResetClass(); + + bool IsVolatile() const { + return (GetAccessFlags() & kAccVolatile) != 0; + } + + private: + // Field order required by test "ValidateFieldOrderOfJavaCppUnionClasses". + // The class we are a part of + Class* declaring_class_; + + uint32_t access_flags_; + + // Dex cache index of field id + uint32_t field_dex_idx_; + + // Offset of field within an instance or in the Class' static fields + uint32_t offset_; + + static Class* java_lang_reflect_ArtField_; + + friend struct art::ArtFieldOffsets; // for verifying offset information + DISALLOW_IMPLICIT_CONSTRUCTORS(ArtField); +}; + +class MANAGED ArtFieldClass : public Class { + private: + DISALLOW_IMPLICIT_CONSTRUCTORS(ArtFieldClass); +}; + +} // namespace mirror +} // namespace art + +#endif // ART_RUNTIME_MIRROR_ART_FIELD_H_ diff --git a/runtime/mirror/art_method-inl.h b/runtime/mirror/art_method-inl.h new file mode 100644 index 0000000000..4d8aa6f741 --- /dev/null +++ b/runtime/mirror/art_method-inl.h @@ -0,0 +1,203 @@ +/* + * Copyright (C) 2011 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_MIRROR_ART_METHOD_INL_H_ +#define ART_RUNTIME_MIRROR_ART_METHOD_INL_H_ + +#include "art_method.h" + +#include "dex_file.h" +#include "entrypoints/entrypoint_utils.h" +#include "object_array.h" +#include "runtime.h" + +namespace art { +namespace mirror { + +inline Class* ArtMethod::GetDeclaringClass() const { + Class* result = GetFieldObject(OFFSET_OF_OBJECT_MEMBER(ArtMethod, declaring_class_), false); + DCHECK(result != NULL) << this; + DCHECK(result->IsIdxLoaded() || result->IsErroneous()) << this; + return result; +} + +inline void ArtMethod::SetDeclaringClass(Class *new_declaring_class) { + SetFieldObject(OFFSET_OF_OBJECT_MEMBER(ArtMethod, declaring_class_), new_declaring_class, false); +} + +inline uint32_t ArtMethod::GetAccessFlags() const { + DCHECK(GetDeclaringClass()->IsIdxLoaded() || GetDeclaringClass()->IsErroneous()); + return GetField32(OFFSET_OF_OBJECT_MEMBER(ArtMethod, access_flags_), false); +} + +inline uint16_t ArtMethod::GetMethodIndex() const { + DCHECK(GetDeclaringClass()->IsResolved() || GetDeclaringClass()->IsErroneous()); + return GetField32(OFFSET_OF_OBJECT_MEMBER(ArtMethod, method_index_), false); +} + +inline uint32_t ArtMethod::GetDexMethodIndex() const { + DCHECK(GetDeclaringClass()->IsLoaded() || GetDeclaringClass()->IsErroneous()); + return GetField32(OFFSET_OF_OBJECT_MEMBER(ArtMethod, method_dex_index_), false); +} + +inline ObjectArray* ArtMethod::GetDexCacheStrings() const { + return GetFieldObject*>( + OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_cache_strings_), false); +} + +inline ObjectArray* ArtMethod::GetDexCacheResolvedMethods() const { + return GetFieldObject*>( + OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_cache_resolved_methods_), false); +} + +inline ObjectArray* ArtMethod::GetDexCacheResolvedTypes() const { + return GetFieldObject*>( + OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_cache_resolved_types_), false); +} + +inline ObjectArray* ArtMethod::GetDexCacheInitializedStaticStorage() const { + return GetFieldObject*>( + OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_cache_initialized_static_storage_), + false); +} + +inline uint32_t ArtMethod::GetCodeSize() const { + DCHECK(!IsRuntimeMethod() && !IsProxyMethod()) << PrettyMethod(this); + uintptr_t code = reinterpret_cast(GetEntryPointFromCompiledCode()); + if (code == 0) { + return 0; + } + // TODO: make this Thumb2 specific + code &= ~0x1; + return reinterpret_cast(code)[-1]; +} + +inline bool ArtMethod::CheckIncompatibleClassChange(InvokeType type) { + switch (type) { + case kStatic: + return !IsStatic(); + case kDirect: + return !IsDirect() || IsStatic(); + case kVirtual: { + Class* methods_class = GetDeclaringClass(); + return IsDirect() || (methods_class->IsInterface() && !IsMiranda()); + } + case kSuper: + return false; // TODO: appropriate checks for call to super class. + case kInterface: { + Class* methods_class = GetDeclaringClass(); + return IsDirect() || !(methods_class->IsInterface() || methods_class->IsObjectClass()); + } + default: + LOG(FATAL) << "Unreachable - invocation type: " << type; + return true; + } +} + +inline void ArtMethod::AssertPcIsWithinCode(uintptr_t pc) const { + if (!kIsDebugBuild) { + return; + } + if (IsNative() || IsRuntimeMethod() || IsProxyMethod()) { + return; + } + if (pc == GetQuickInstrumentationExitPc()) { + return; + } + const void* code = GetEntryPointFromCompiledCode(); + if (code == GetCompiledCodeToInterpreterBridge() || code == GetQuickInstrumentationEntryPoint()) { + return; + } + ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); + if (code == GetResolutionTrampoline(class_linker)) { + return; + } + DCHECK(IsWithinCode(pc)) + << PrettyMethod(this) + << " pc=" << std::hex << pc + << " code=" << code + << " size=" << GetCodeSize(); +} + +inline uint32_t ArtMethod::GetOatCodeOffset() const { + DCHECK(!Runtime::Current()->IsStarted()); + return reinterpret_cast(GetEntryPointFromCompiledCode()); +} + +inline void ArtMethod::SetOatCodeOffset(uint32_t code_offset) { + DCHECK(!Runtime::Current()->IsStarted()); + SetEntryPointFromCompiledCode(reinterpret_cast(code_offset)); +} + +inline uint32_t ArtMethod::GetOatMappingTableOffset() const { + DCHECK(!Runtime::Current()->IsStarted()); + return reinterpret_cast(GetMappingTable()); +} + +inline void ArtMethod::SetOatMappingTableOffset(uint32_t mapping_table_offset) { + DCHECK(!Runtime::Current()->IsStarted()); + SetMappingTable(reinterpret_cast(mapping_table_offset)); +} + +inline uint32_t ArtMethod::GetOatVmapTableOffset() const { + DCHECK(!Runtime::Current()->IsStarted()); + return reinterpret_cast(GetVmapTable()); +} + +inline void ArtMethod::SetOatVmapTableOffset(uint32_t vmap_table_offset) { + DCHECK(!Runtime::Current()->IsStarted()); + SetVmapTable(reinterpret_cast(vmap_table_offset)); +} + +inline void ArtMethod::SetOatNativeGcMapOffset(uint32_t gc_map_offset) { + DCHECK(!Runtime::Current()->IsStarted()); + SetNativeGcMap(reinterpret_cast(gc_map_offset)); +} + +inline uint32_t ArtMethod::GetOatNativeGcMapOffset() const { + DCHECK(!Runtime::Current()->IsStarted()); + return reinterpret_cast(GetNativeGcMap()); +} + +inline bool ArtMethod::IsRuntimeMethod() const { + return GetDexMethodIndex() == DexFile::kDexNoIndex16; +} + +inline bool ArtMethod::IsCalleeSaveMethod() const { + if (!IsRuntimeMethod()) { + return false; + } + Runtime* runtime = Runtime::Current(); + bool result = false; + for (int i = 0; i < Runtime::kLastCalleeSaveType; i++) { + if (this == runtime->GetCalleeSaveMethod(Runtime::CalleeSaveType(i))) { + result = true; + break; + } + } + return result; +} + +inline bool ArtMethod::IsResolutionMethod() const { + bool result = this == Runtime::Current()->GetResolutionMethod(); + // Check that if we do think it is phony it looks like the resolution method. + DCHECK(!result || IsRuntimeMethod()); + return result; +} +} // namespace mirror +} // namespace art + +#endif // ART_RUNTIME_MIRROR_ART_METHOD_INL_H_ diff --git a/runtime/mirror/art_method.cc b/runtime/mirror/art_method.cc new file mode 100644 index 0000000000..cd05f41cc2 --- /dev/null +++ b/runtime/mirror/art_method.cc @@ -0,0 +1,342 @@ +/* + * Copyright (C) 2011 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. + */ + +#include "art_method.h" + +#include "art_method-inl.h" +#include "base/stringpiece.h" +#include "class-inl.h" +#include "dex_file-inl.h" +#include "dex_instruction.h" +#include "gc/accounting/card_table-inl.h" +#include "interpreter/interpreter.h" +#include "jni_internal.h" +#include "mapping_table.h" +#include "object-inl.h" +#include "object_array.h" +#include "object_array-inl.h" +#include "string.h" +#include "object_utils.h" + +namespace art { +namespace mirror { + +extern "C" void art_portable_invoke_stub(ArtMethod*, uint32_t*, uint32_t, Thread*, JValue*, char); +extern "C" void art_quick_invoke_stub(ArtMethod*, uint32_t*, uint32_t, Thread*, JValue*, char); + +// TODO: get global references for these +Class* ArtMethod::java_lang_reflect_ArtMethod_ = NULL; + +InvokeType ArtMethod::GetInvokeType() const { + // TODO: kSuper? + if (GetDeclaringClass()->IsInterface()) { + return kInterface; + } else if (IsStatic()) { + return kStatic; + } else if (IsDirect()) { + return kDirect; + } else { + return kVirtual; + } +} + +void ArtMethod::SetClass(Class* java_lang_reflect_ArtMethod) { + CHECK(java_lang_reflect_ArtMethod_ == NULL); + CHECK(java_lang_reflect_ArtMethod != NULL); + java_lang_reflect_ArtMethod_ = java_lang_reflect_ArtMethod; +} + +void ArtMethod::ResetClass() { + CHECK(java_lang_reflect_ArtMethod_ != NULL); + java_lang_reflect_ArtMethod_ = NULL; +} + +void ArtMethod::SetDexCacheStrings(ObjectArray* new_dex_cache_strings) { + SetFieldObject(OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_cache_strings_), + new_dex_cache_strings, false); +} + +void ArtMethod::SetDexCacheResolvedMethods(ObjectArray* new_dex_cache_methods) { + SetFieldObject(OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_cache_resolved_methods_), + new_dex_cache_methods, false); +} + +void ArtMethod::SetDexCacheResolvedTypes(ObjectArray* new_dex_cache_classes) { + SetFieldObject(OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_cache_resolved_types_), + new_dex_cache_classes, false); +} + +void ArtMethod::SetDexCacheInitializedStaticStorage(ObjectArray* new_value) { + SetFieldObject(OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_cache_initialized_static_storage_), + new_value, false); +} + +size_t ArtMethod::NumArgRegisters(const StringPiece& shorty) { + CHECK_LE(1, shorty.length()); + uint32_t num_registers = 0; + for (int i = 1; i < shorty.length(); ++i) { + char ch = shorty[i]; + if (ch == 'D' || ch == 'J') { + num_registers += 2; + } else { + num_registers += 1; + } + } + return num_registers; +} + +bool ArtMethod::IsProxyMethod() const { + return GetDeclaringClass()->IsProxyClass(); +} + +ArtMethod* ArtMethod::FindOverriddenMethod() const { + if (IsStatic()) { + return NULL; + } + Class* declaring_class = GetDeclaringClass(); + Class* super_class = declaring_class->GetSuperClass(); + uint16_t method_index = GetMethodIndex(); + ObjectArray* super_class_vtable = super_class->GetVTable(); + ArtMethod* result = NULL; + // Did this method override a super class method? If so load the result from the super class' + // vtable + if (super_class_vtable != NULL && method_index < super_class_vtable->GetLength()) { + result = super_class_vtable->Get(method_index); + } else { + // Method didn't override superclass method so search interfaces + if (IsProxyMethod()) { + result = GetDexCacheResolvedMethods()->Get(GetDexMethodIndex()); + CHECK_EQ(result, + Runtime::Current()->GetClassLinker()->FindMethodForProxy(GetDeclaringClass(), this)); + } else { + MethodHelper mh(this); + MethodHelper interface_mh; + IfTable* iftable = GetDeclaringClass()->GetIfTable(); + for (size_t i = 0; i < iftable->Count() && result == NULL; i++) { + Class* interface = iftable->GetInterface(i); + for (size_t j = 0; j < interface->NumVirtualMethods(); ++j) { + ArtMethod* interface_method = interface->GetVirtualMethod(j); + interface_mh.ChangeMethod(interface_method); + if (mh.HasSameNameAndSignature(&interface_mh)) { + result = interface_method; + break; + } + } + } + } + } +#ifndef NDEBUG + MethodHelper result_mh(result); + DCHECK(result == NULL || MethodHelper(this).HasSameNameAndSignature(&result_mh)); +#endif + return result; +} + +uintptr_t ArtMethod::NativePcOffset(const uintptr_t pc) const { + const void* code = Runtime::Current()->GetInstrumentation()->GetQuickCodeFor(this); + return pc - reinterpret_cast(code); +} + +uint32_t ArtMethod::ToDexPc(const uintptr_t pc) const { +#if !defined(ART_USE_PORTABLE_COMPILER) + MappingTable table(GetMappingTable()); + if (table.TotalSize() == 0) { + DCHECK(IsNative() || IsCalleeSaveMethod() || IsProxyMethod()) << PrettyMethod(this); + return DexFile::kDexNoIndex; // Special no mapping case + } + const void* code = Runtime::Current()->GetInstrumentation()->GetQuickCodeFor(this); + uint32_t sought_offset = pc - reinterpret_cast(code); + // Assume the caller wants a pc-to-dex mapping so check here first. + typedef MappingTable::PcToDexIterator It; + for (It cur = table.PcToDexBegin(), end = table.PcToDexEnd(); cur != end; ++cur) { + if (cur.NativePcOffset() == sought_offset) { + return cur.DexPc(); + } + } + // Now check dex-to-pc mappings. + typedef MappingTable::DexToPcIterator It2; + for (It2 cur = table.DexToPcBegin(), end = table.DexToPcEnd(); cur != end; ++cur) { + if (cur.NativePcOffset() == sought_offset) { + return cur.DexPc(); + } + } + LOG(FATAL) << "Failed to find Dex offset for PC offset " << reinterpret_cast(sought_offset) + << "(PC " << reinterpret_cast(pc) << ", code=" << code + << ") in " << PrettyMethod(this); + return DexFile::kDexNoIndex; +#else + // Compiler LLVM doesn't use the machine pc, we just use dex pc instead. + return static_cast(pc); +#endif +} + +uintptr_t ArtMethod::ToNativePc(const uint32_t dex_pc) const { + MappingTable table(GetMappingTable()); + if (table.TotalSize() == 0) { + DCHECK_EQ(dex_pc, 0U); + return 0; // Special no mapping/pc == 0 case + } + // Assume the caller wants a dex-to-pc mapping so check here first. + typedef MappingTable::DexToPcIterator It; + for (It cur = table.DexToPcBegin(), end = table.DexToPcEnd(); cur != end; ++cur) { + if (cur.DexPc() == dex_pc) { + const void* code = Runtime::Current()->GetInstrumentation()->GetQuickCodeFor(this); + return reinterpret_cast(code) + cur.NativePcOffset(); + } + } + // Now check pc-to-dex mappings. + typedef MappingTable::PcToDexIterator It2; + for (It2 cur = table.PcToDexBegin(), end = table.PcToDexEnd(); cur != end; ++cur) { + if (cur.DexPc() == dex_pc) { + const void* code = Runtime::Current()->GetInstrumentation()->GetQuickCodeFor(this); + return reinterpret_cast(code) + cur.NativePcOffset(); + } + } + LOG(FATAL) << "Failed to find native offset for dex pc 0x" << std::hex << dex_pc + << " in " << PrettyMethod(this); + return 0; +} + +uint32_t ArtMethod::FindCatchBlock(Class* exception_type, uint32_t dex_pc, + bool* has_no_move_exception) const { + MethodHelper mh(this); + const DexFile::CodeItem* code_item = mh.GetCodeItem(); + // Default to handler not found. + uint32_t found_dex_pc = DexFile::kDexNoIndex; + // Iterate over the catch handlers associated with dex_pc. + for (CatchHandlerIterator it(*code_item, dex_pc); it.HasNext(); it.Next()) { + uint16_t iter_type_idx = it.GetHandlerTypeIndex(); + // Catch all case + if (iter_type_idx == DexFile::kDexNoIndex16) { + found_dex_pc = it.GetHandlerAddress(); + break; + } + // Does this catch exception type apply? + Class* iter_exception_type = mh.GetDexCacheResolvedType(iter_type_idx); + if (iter_exception_type == NULL) { + // The verifier should take care of resolving all exception classes early + LOG(WARNING) << "Unresolved exception class when finding catch block: " + << mh.GetTypeDescriptorFromTypeIdx(iter_type_idx); + } else if (iter_exception_type->IsAssignableFrom(exception_type)) { + found_dex_pc = it.GetHandlerAddress(); + break; + } + } + if (found_dex_pc != DexFile::kDexNoIndex) { + const Instruction* first_catch_instr = + Instruction::At(&mh.GetCodeItem()->insns_[found_dex_pc]); + *has_no_move_exception = (first_catch_instr->Opcode() != Instruction::MOVE_EXCEPTION); + } + return found_dex_pc; +} + +void ArtMethod::Invoke(Thread* self, uint32_t* args, uint32_t args_size, JValue* result, + char result_type) { + if (kIsDebugBuild) { + self->AssertThreadSuspensionIsAllowable(); + CHECK_EQ(kRunnable, self->GetState()); + } + + // Push a transition back into managed code onto the linked list in thread. + ManagedStack fragment; + self->PushManagedStackFragment(&fragment); + + Runtime* runtime = Runtime::Current(); + // Call the invoke stub, passing everything as arguments. + if (UNLIKELY(!runtime->IsStarted())) { + LOG(INFO) << "Not invoking " << PrettyMethod(this) << " for a runtime that isn't started"; + if (result != NULL) { + result->SetJ(0); + } + } else { + const bool kLogInvocationStartAndReturn = false; + if (GetEntryPointFromCompiledCode() != NULL) { + if (kLogInvocationStartAndReturn) { + LOG(INFO) << StringPrintf("Invoking '%s' code=%p", PrettyMethod(this).c_str(), GetEntryPointFromCompiledCode()); + } +#ifdef ART_USE_PORTABLE_COMPILER + (*art_portable_invoke_stub)(this, args, args_size, self, result, result_type); +#else + (*art_quick_invoke_stub)(this, args, args_size, self, result, result_type); +#endif + if (UNLIKELY(reinterpret_cast(self->GetException(NULL)) == -1)) { + // Unusual case where we were running LLVM generated code and an + // exception was thrown to force the activations to be removed from the + // stack. Continue execution in the interpreter. + self->ClearException(); + ShadowFrame* shadow_frame = self->GetAndClearDeoptimizationShadowFrame(result); + self->SetTopOfStack(NULL, 0); + self->SetTopOfShadowStack(shadow_frame); + interpreter::EnterInterpreterFromDeoptimize(self, shadow_frame, result); + } + if (kLogInvocationStartAndReturn) { + LOG(INFO) << StringPrintf("Returned '%s' code=%p", PrettyMethod(this).c_str(), GetEntryPointFromCompiledCode()); + } + } else { + LOG(INFO) << "Not invoking '" << PrettyMethod(this) + << "' code=" << reinterpret_cast(GetEntryPointFromCompiledCode()); + if (result != NULL) { + result->SetJ(0); + } + } + } + + // Pop transition. + self->PopManagedStackFragment(fragment); +} + +bool ArtMethod::IsRegistered() const { + void* native_method = GetFieldPtr(OFFSET_OF_OBJECT_MEMBER(ArtMethod, native_method_), false); + CHECK(native_method != NULL); + void* jni_stub = GetJniDlsymLookupStub(); + return native_method != jni_stub; +} + +extern "C" void art_work_around_app_jni_bugs(JNIEnv*, jobject); +void ArtMethod::RegisterNative(Thread* self, const void* native_method) { + DCHECK(Thread::Current() == self); + CHECK(IsNative()) << PrettyMethod(this); + CHECK(native_method != NULL) << PrettyMethod(this); + if (!self->GetJniEnv()->vm->work_around_app_jni_bugs) { + SetNativeMethod(native_method); + } else { + // We've been asked to associate this method with the given native method but are working + // around JNI bugs, that include not giving Object** SIRT references to native methods. Direct + // the native method to runtime support and store the target somewhere runtime support will + // find it. +#if defined(__i386__) + UNIMPLEMENTED(FATAL); +#else + SetNativeMethod(reinterpret_cast(art_work_around_app_jni_bugs)); +#endif + SetFieldPtr(OFFSET_OF_OBJECT_MEMBER(ArtMethod, gc_map_), + reinterpret_cast(native_method), false); + } +} + +void ArtMethod::UnregisterNative(Thread* self) { + CHECK(IsNative()) << PrettyMethod(this); + // restore stub to lookup native pointer via dlsym + RegisterNative(self, GetJniDlsymLookupStub()); +} + +void ArtMethod::SetNativeMethod(const void* native_method) { + SetFieldPtr(OFFSET_OF_OBJECT_MEMBER(ArtMethod, native_method_), + native_method, false); +} + +} // namespace mirror +} // namespace art diff --git a/runtime/mirror/art_method.h b/runtime/mirror/art_method.h new file mode 100644 index 0000000000..7301f23747 --- /dev/null +++ b/runtime/mirror/art_method.h @@ -0,0 +1,457 @@ +/* + * Copyright (C) 2011 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_MIRROR_ART_METHOD_H_ +#define ART_RUNTIME_MIRROR_ART_METHOD_H_ + +#include "class.h" +#include "dex_file.h" +#include "invoke_type.h" +#include "locks.h" +#include "modifiers.h" +#include "object.h" + +namespace art { + +struct ArtMethodOffsets; +struct ConstructorMethodOffsets; +union JValue; +struct MethodClassOffsets; +class MethodHelper; +class StringPiece; +class ShadowFrame; + +namespace mirror { + +class StaticStorageBase; + +typedef void (EntryPointFromInterpreter)(Thread* self, MethodHelper& mh, + const DexFile::CodeItem* code_item, ShadowFrame* shadow_frame, JValue* result); + +// C++ mirror of java.lang.reflect.Method and java.lang.reflect.Constructor +class MANAGED ArtMethod : public Object { + public: + Class* GetDeclaringClass() const; + + void SetDeclaringClass(Class *new_declaring_class) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + + static MemberOffset DeclaringClassOffset() { + return MemberOffset(OFFSETOF_MEMBER(ArtMethod, declaring_class_)); + } + + static MemberOffset EntryPointFromCompiledCodeOffset() { + return MemberOffset(OFFSETOF_MEMBER(ArtMethod, entry_point_from_compiled_code_)); + } + + uint32_t GetAccessFlags() const; + + void SetAccessFlags(uint32_t new_access_flags) { + SetField32(OFFSET_OF_OBJECT_MEMBER(ArtMethod, access_flags_), new_access_flags, false); + } + + // Approximate what kind of method call would be used for this method. + InvokeType GetInvokeType() const; + + // Returns true if the method is declared public. + bool IsPublic() const { + return (GetAccessFlags() & kAccPublic) != 0; + } + + // Returns true if the method is declared private. + bool IsPrivate() const { + return (GetAccessFlags() & kAccPrivate) != 0; + } + + // Returns true if the method is declared static. + bool IsStatic() const { + return (GetAccessFlags() & kAccStatic) != 0; + } + + // Returns true if the method is a constructor. + bool IsConstructor() const { + return (GetAccessFlags() & kAccConstructor) != 0; + } + + // Returns true if the method is static, private, or a constructor. + bool IsDirect() const { + return IsDirect(GetAccessFlags()); + } + + static bool IsDirect(uint32_t access_flags) { + return (access_flags & (kAccStatic | kAccPrivate | kAccConstructor)) != 0; + } + + // Returns true if the method is declared synchronized. + bool IsSynchronized() const { + uint32_t synchonized = kAccSynchronized | kAccDeclaredSynchronized; + return (GetAccessFlags() & synchonized) != 0; + } + + bool IsFinal() const { + return (GetAccessFlags() & kAccFinal) != 0; + } + + bool IsMiranda() const { + return (GetAccessFlags() & kAccMiranda) != 0; + } + + bool IsNative() const { + return (GetAccessFlags() & kAccNative) != 0; + } + + bool IsAbstract() const { + return (GetAccessFlags() & kAccAbstract) != 0; + } + + bool IsSynthetic() const { + return (GetAccessFlags() & kAccSynthetic) != 0; + } + + bool IsProxyMethod() const; + + bool IsPreverified() const { + return (GetAccessFlags() & kAccPreverified) != 0; + } + + void SetPreverified() { + SetAccessFlags(GetAccessFlags() | kAccPreverified); + } + + bool CheckIncompatibleClassChange(InvokeType type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + + uint16_t GetMethodIndex() const; + + size_t GetVtableIndex() const { + return GetMethodIndex(); + } + + void SetMethodIndex(uint16_t new_method_index) { + SetField32(OFFSET_OF_OBJECT_MEMBER(ArtMethod, method_index_), new_method_index, false); + } + + static MemberOffset MethodIndexOffset() { + return OFFSET_OF_OBJECT_MEMBER(ArtMethod, method_index_); + } + + uint32_t GetCodeItemOffset() const { + return GetField32(OFFSET_OF_OBJECT_MEMBER(ArtMethod, code_item_offset_), false); + } + + void SetCodeItemOffset(uint32_t new_code_off) { + SetField32(OFFSET_OF_OBJECT_MEMBER(ArtMethod, code_item_offset_), new_code_off, false); + } + + // Number of 32bit registers that would be required to hold all the arguments + static size_t NumArgRegisters(const StringPiece& shorty); + + uint32_t GetDexMethodIndex() const; + + void SetDexMethodIndex(uint32_t new_idx) { + SetField32(OFFSET_OF_OBJECT_MEMBER(ArtMethod, method_dex_index_), new_idx, false); + } + + ObjectArray* GetDexCacheStrings() const; + void SetDexCacheStrings(ObjectArray* new_dex_cache_strings) + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + + static MemberOffset DexCacheStringsOffset() { + return OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_cache_strings_); + } + + static MemberOffset DexCacheResolvedMethodsOffset() { + return OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_cache_resolved_methods_); + } + + static MemberOffset DexCacheResolvedTypesOffset() { + return OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_cache_resolved_types_); + } + + static MemberOffset DexCacheInitializedStaticStorageOffset() { + return OFFSET_OF_OBJECT_MEMBER(ArtMethod, + dex_cache_initialized_static_storage_); + } + + ObjectArray* GetDexCacheResolvedMethods() const; + void SetDexCacheResolvedMethods(ObjectArray* new_dex_cache_methods) + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + + ObjectArray* GetDexCacheResolvedTypes() const; + void SetDexCacheResolvedTypes(ObjectArray* new_dex_cache_types) + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + + ObjectArray* GetDexCacheInitializedStaticStorage() const; + void SetDexCacheInitializedStaticStorage(ObjectArray* new_value) + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + + // Find the method that this method overrides + ArtMethod* FindOverriddenMethod() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + + void Invoke(Thread* self, uint32_t* args, uint32_t args_size, JValue* result, char result_type) + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + + EntryPointFromInterpreter* GetEntryPointFromInterpreter() const { + return GetFieldPtr(OFFSET_OF_OBJECT_MEMBER(ArtMethod, entry_point_from_interpreter_), false); + } + + void SetEntryPointFromInterpreter(EntryPointFromInterpreter* entry_point_from_interpreter) { + SetFieldPtr(OFFSET_OF_OBJECT_MEMBER(ArtMethod, entry_point_from_interpreter_), entry_point_from_interpreter, false); + } + + const void* GetEntryPointFromCompiledCode() const { + return GetFieldPtr(OFFSET_OF_OBJECT_MEMBER(ArtMethod, entry_point_from_compiled_code_), false); + } + + void SetEntryPointFromCompiledCode(const void* entry_point_from_compiled_code) { + SetFieldPtr(OFFSET_OF_OBJECT_MEMBER(ArtMethod, entry_point_from_compiled_code_), entry_point_from_compiled_code, false); + } + + uint32_t GetCodeSize() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + + bool IsWithinCode(uintptr_t pc) const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + uintptr_t code = reinterpret_cast(GetEntryPointFromCompiledCode()); + if (code == 0) { + return pc == 0; + } + /* + * During a stack walk, a return PC may point to the end of the code + 1 + * (in the case that the last instruction is a call that isn't expected to + * return. Thus, we check <= code + GetCodeSize(). + */ + return (code <= pc && pc <= code + GetCodeSize()); + } + + void AssertPcIsWithinCode(uintptr_t pc) const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + + uint32_t GetOatCodeOffset() const; + + void SetOatCodeOffset(uint32_t code_offset); + + static MemberOffset GetEntryPointFromCompiledCodeOffset() { + return OFFSET_OF_OBJECT_MEMBER(ArtMethod, entry_point_from_compiled_code_); + } + + // Callers should wrap the uint8_t* in a MappingTable instance for convenient access. + const uint8_t* GetMappingTable() const { + return GetFieldPtr(OFFSET_OF_OBJECT_MEMBER(ArtMethod, mapping_table_), false); + } + + void SetMappingTable(const uint8_t* mapping_table) { + SetFieldPtr(OFFSET_OF_OBJECT_MEMBER(ArtMethod, mapping_table_), + mapping_table, false); + } + + uint32_t GetOatMappingTableOffset() const; + + void SetOatMappingTableOffset(uint32_t mapping_table_offset); + + // Callers should wrap the uint8_t* in a VmapTable instance for convenient access. + const uint8_t* GetVmapTable() const { + return GetFieldPtr(OFFSET_OF_OBJECT_MEMBER(ArtMethod, vmap_table_), false); + } + + void SetVmapTable(const uint8_t* vmap_table) { + SetFieldPtr(OFFSET_OF_OBJECT_MEMBER(ArtMethod, vmap_table_), vmap_table, false); + } + + uint32_t GetOatVmapTableOffset() const; + + void SetOatVmapTableOffset(uint32_t vmap_table_offset); + + const uint8_t* GetNativeGcMap() const { + return GetFieldPtr(OFFSET_OF_OBJECT_MEMBER(ArtMethod, gc_map_), false); + } + void SetNativeGcMap(const uint8_t* data) { + SetFieldPtr(OFFSET_OF_OBJECT_MEMBER(ArtMethod, gc_map_), data, false); + } + + // When building the oat need a convenient place to stuff the offset of the native GC map. + void SetOatNativeGcMapOffset(uint32_t gc_map_offset); + uint32_t GetOatNativeGcMapOffset() const; + + size_t GetFrameSizeInBytes() const { + DCHECK_EQ(sizeof(size_t), sizeof(uint32_t)); + size_t result = GetField32(OFFSET_OF_OBJECT_MEMBER(ArtMethod, frame_size_in_bytes_), false); + DCHECK_LE(static_cast(kStackAlignment), result); + return result; + } + + void SetFrameSizeInBytes(size_t new_frame_size_in_bytes) { + DCHECK_EQ(sizeof(size_t), sizeof(uint32_t)); + SetField32(OFFSET_OF_OBJECT_MEMBER(ArtMethod, frame_size_in_bytes_), + new_frame_size_in_bytes, false); + } + + size_t GetReturnPcOffsetInBytes() const { + return GetFrameSizeInBytes() - kPointerSize; + } + + size_t GetSirtOffsetInBytes() const { + CHECK(IsNative()); + return kPointerSize; + } + + bool IsRegistered() const; + + void RegisterNative(Thread* self, const void* native_method) + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + + void UnregisterNative(Thread* self) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + + static MemberOffset NativeMethodOffset() { + return OFFSET_OF_OBJECT_MEMBER(ArtMethod, native_method_); + } + + const void* GetNativeMethod() const { + return reinterpret_cast(GetField32(NativeMethodOffset(), false)); + } + + void SetNativeMethod(const void*); + + static MemberOffset GetMethodIndexOffset() { + return OFFSET_OF_OBJECT_MEMBER(ArtMethod, method_index_); + } + + uint32_t GetCoreSpillMask() const { + return GetField32(OFFSET_OF_OBJECT_MEMBER(ArtMethod, core_spill_mask_), false); + } + + void SetCoreSpillMask(uint32_t core_spill_mask) { + // Computed during compilation + SetField32(OFFSET_OF_OBJECT_MEMBER(ArtMethod, core_spill_mask_), core_spill_mask, false); + } + + uint32_t GetFpSpillMask() const { + return GetField32(OFFSET_OF_OBJECT_MEMBER(ArtMethod, fp_spill_mask_), false); + } + + void SetFpSpillMask(uint32_t fp_spill_mask) { + // Computed during compilation + SetField32(OFFSET_OF_OBJECT_MEMBER(ArtMethod, fp_spill_mask_), fp_spill_mask, false); + } + + // Is this a CalleSaveMethod or ResolutionMethod and therefore doesn't adhere to normal + // conventions for a method of managed code. Returns false for Proxy methods. + bool IsRuntimeMethod() const; + + // Is this a hand crafted method used for something like describing callee saves? + bool IsCalleeSaveMethod() const; + + bool IsResolutionMethod() const; + + uintptr_t NativePcOffset(const uintptr_t pc) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + + // Converts a native PC to a dex PC. + uint32_t ToDexPc(const uintptr_t pc) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + + // Converts a dex PC to a native PC. + uintptr_t ToNativePc(const uint32_t dex_pc) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + + // Find the catch block for the given exception type and dex_pc. When a catch block is found, + // indicates whether the found catch block is responsible for clearing the exception or whether + // a move-exception instruction is present. + uint32_t FindCatchBlock(Class* exception_type, uint32_t dex_pc, bool* has_no_move_exception) const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + + static void SetClass(Class* java_lang_reflect_ArtMethod); + + static Class* GetJavaLangReflectArtMethod() { + return java_lang_reflect_ArtMethod_; + } + + static void ResetClass(); + + protected: + // Field order required by test "ValidateFieldOrderOfJavaCppUnionClasses". + // The class we are a part of + Class* declaring_class_; + + // short cuts to declaring_class_->dex_cache_ member for fast compiled code access + ObjectArray* dex_cache_initialized_static_storage_; + + // short cuts to declaring_class_->dex_cache_ member for fast compiled code access + ObjectArray* dex_cache_resolved_methods_; + + // short cuts to declaring_class_->dex_cache_ member for fast compiled code access + ObjectArray* dex_cache_resolved_types_; + + // short cuts to declaring_class_->dex_cache_ member for fast compiled code access + ObjectArray* dex_cache_strings_; + + // Access flags; low 16 bits are defined by spec. + uint32_t access_flags_; + + // Offset to the CodeItem. + uint32_t code_item_offset_; + + // Architecture-dependent register spill mask + uint32_t core_spill_mask_; + + // Compiled code associated with this method for callers from managed code. + // May be compiled managed code or a bridge for invoking a native method. + // TODO: Break apart this into portable and quick. + const void* entry_point_from_compiled_code_; + + // Called by the interpreter to execute this method. + EntryPointFromInterpreter* entry_point_from_interpreter_; + + // Architecture-dependent register spill mask + uint32_t fp_spill_mask_; + + // Total size in bytes of the frame + size_t frame_size_in_bytes_; + + // Garbage collection map of native PC offsets (quick) or dex PCs (portable) to reference bitmaps. + const uint8_t* gc_map_; + + // Mapping from native pc to dex pc + const uint32_t* mapping_table_; + + // Index into method_ids of the dex file associated with this method + uint32_t method_dex_index_; + + // For concrete virtual methods, this is the offset of the method in Class::vtable_. + // + // For abstract methods in an interface class, this is the offset of the method in + // "iftable_->Get(n)->GetMethodArray()". + // + // For static and direct methods this is the index in the direct methods table. + uint32_t method_index_; + + // The target native method registered with this method + const void* native_method_; + + // When a register is promoted into a register, the spill mask holds which registers hold dex + // registers. The first promoted register's corresponding dex register is vmap_table_[1], the Nth + // is vmap_table_[N]. vmap_table_[0] holds the length of the table. + const uint16_t* vmap_table_; + + static Class* java_lang_reflect_ArtMethod_; + + friend struct art::ArtMethodOffsets; // for verifying offset information + DISALLOW_IMPLICIT_CONSTRUCTORS(ArtMethod); +}; + +class MANAGED ArtMethodClass : public Class { + private: + DISALLOW_IMPLICIT_CONSTRUCTORS(ArtMethodClass); +}; + +} // namespace mirror +} // namespace art + +#endif // ART_RUNTIME_MIRROR_ART_METHOD_H_ diff --git a/runtime/mirror/class-inl.h b/runtime/mirror/class-inl.h index 52906a2650..1e1138745d 100644 --- a/runtime/mirror/class-inl.h +++ b/runtime/mirror/class-inl.h @@ -19,10 +19,10 @@ #include "class.h" -#include "abstract_method.h" +#include "art_field.h" +#include "art_method.h" #include "class_loader.h" #include "dex_cache.h" -#include "field.h" #include "iftable.h" #include "object_array-inl.h" #include "runtime.h" @@ -54,30 +54,30 @@ inline DexCache* Class::GetDexCache() const { return GetFieldObject(OFFSET_OF_OBJECT_MEMBER(Class, dex_cache_), false); } -inline ObjectArray* Class::GetDirectMethods() const { +inline ObjectArray* Class::GetDirectMethods() const { DCHECK(IsLoaded() || IsErroneous()); - return GetFieldObject*>( + return GetFieldObject*>( OFFSET_OF_OBJECT_MEMBER(Class, direct_methods_), false); } -inline void Class::SetDirectMethods(ObjectArray* new_direct_methods) +inline void Class::SetDirectMethods(ObjectArray* new_direct_methods) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - DCHECK(NULL == GetFieldObject*>( + DCHECK(NULL == GetFieldObject*>( OFFSET_OF_OBJECT_MEMBER(Class, direct_methods_), false)); DCHECK_NE(0, new_direct_methods->GetLength()); SetFieldObject(OFFSET_OF_OBJECT_MEMBER(Class, direct_methods_), new_direct_methods, false); } -inline AbstractMethod* Class::GetDirectMethod(int32_t i) const +inline ArtMethod* Class::GetDirectMethod(int32_t i) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return GetDirectMethods()->Get(i); } -inline void Class::SetDirectMethod(uint32_t i, AbstractMethod* f) // TODO: uint16_t +inline void Class::SetDirectMethod(uint32_t i, ArtMethod* f) // TODO: uint16_t SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - ObjectArray* direct_methods = - GetFieldObject*>( + ObjectArray* direct_methods = + GetFieldObject*>( OFFSET_OF_OBJECT_MEMBER(Class, direct_methods_), false); direct_methods->Set(i, f); } @@ -87,13 +87,13 @@ inline size_t Class::NumDirectMethods() const { return (GetDirectMethods() != NULL) ? GetDirectMethods()->GetLength() : 0; } -inline ObjectArray* Class::GetVirtualMethods() const { +inline ObjectArray* Class::GetVirtualMethods() const { DCHECK(IsLoaded() || IsErroneous()); - return GetFieldObject*>( + return GetFieldObject*>( OFFSET_OF_OBJECT_MEMBER(Class, virtual_methods_), false); } -inline void Class::SetVirtualMethods(ObjectArray* new_virtual_methods) { +inline void Class::SetVirtualMethods(ObjectArray* new_virtual_methods) { // TODO: we reassign virtual methods to grow the table for miranda // methods.. they should really just be assigned once DCHECK_NE(0, new_virtual_methods->GetLength()); @@ -105,37 +105,37 @@ inline size_t Class::NumVirtualMethods() const { return (GetVirtualMethods() != NULL) ? GetVirtualMethods()->GetLength() : 0; } -inline AbstractMethod* Class::GetVirtualMethod(uint32_t i) const +inline ArtMethod* Class::GetVirtualMethod(uint32_t i) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { DCHECK(IsResolved() || IsErroneous()); return GetVirtualMethods()->Get(i); } -inline AbstractMethod* Class::GetVirtualMethodDuringLinking(uint32_t i) const +inline ArtMethod* Class::GetVirtualMethodDuringLinking(uint32_t i) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { DCHECK(IsLoaded() || IsErroneous()); return GetVirtualMethods()->Get(i); } -inline void Class::SetVirtualMethod(uint32_t i, AbstractMethod* f) // TODO: uint16_t +inline void Class::SetVirtualMethod(uint32_t i, ArtMethod* f) // TODO: uint16_t SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - ObjectArray* virtual_methods = - GetFieldObject*>( + ObjectArray* virtual_methods = + GetFieldObject*>( OFFSET_OF_OBJECT_MEMBER(Class, virtual_methods_), false); virtual_methods->Set(i, f); } -inline ObjectArray* Class::GetVTable() const { +inline ObjectArray* Class::GetVTable() const { DCHECK(IsResolved() || IsErroneous()); - return GetFieldObject*>(OFFSET_OF_OBJECT_MEMBER(Class, vtable_), false); + return GetFieldObject*>(OFFSET_OF_OBJECT_MEMBER(Class, vtable_), false); } -inline ObjectArray* Class::GetVTableDuringLinking() const { +inline ObjectArray* Class::GetVTableDuringLinking() const { DCHECK(IsLoaded() || IsErroneous()); - return GetFieldObject*>(OFFSET_OF_OBJECT_MEMBER(Class, vtable_), false); + return GetFieldObject*>(OFFSET_OF_OBJECT_MEMBER(Class, vtable_), false); } -inline void Class::SetVTable(ObjectArray* new_vtable) +inline void Class::SetVTable(ObjectArray* new_vtable) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { SetFieldObject(OFFSET_OF_OBJECT_MEMBER(Class, vtable_), new_vtable, false); } @@ -208,7 +208,7 @@ inline bool Class::IsSubClass(const Class* klass) const { return false; } -inline AbstractMethod* Class::FindVirtualMethodForInterface(AbstractMethod* method) const { +inline ArtMethod* Class::FindVirtualMethodForInterface(ArtMethod* method) const { Class* declaring_class = method->GetDeclaringClass(); DCHECK(declaring_class != NULL) << PrettyClass(this); DCHECK(declaring_class->IsInterface()) << PrettyMethod(method); @@ -223,7 +223,7 @@ inline AbstractMethod* Class::FindVirtualMethodForInterface(AbstractMethod* meth return NULL; } -inline AbstractMethod* Class::FindVirtualMethodForVirtual(AbstractMethod* method) const +inline ArtMethod* Class::FindVirtualMethodForVirtual(ArtMethod* method) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { DCHECK(!method->GetDeclaringClass()->IsInterface() || method->IsMiranda()); // The argument method may from a super class. @@ -231,13 +231,13 @@ inline AbstractMethod* Class::FindVirtualMethodForVirtual(AbstractMethod* method return GetVTable()->Get(method->GetMethodIndex()); } -inline AbstractMethod* Class::FindVirtualMethodForSuper(AbstractMethod* method) const +inline ArtMethod* Class::FindVirtualMethodForSuper(ArtMethod* method) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { DCHECK(!method->GetDeclaringClass()->IsInterface()); return GetSuperClass()->GetVTable()->Get(method->GetMethodIndex()); } -inline AbstractMethod* Class::FindVirtualMethodForVirtualOrInterface(AbstractMethod* method) const { +inline ArtMethod* Class::FindVirtualMethodForVirtualOrInterface(ArtMethod* method) const { if (method->IsDirect()) { return method; } @@ -263,26 +263,26 @@ inline void Class::SetIfTable(IfTable* new_iftable) { SetFieldObject(OFFSET_OF_OBJECT_MEMBER(Class, iftable_), new_iftable, false); } -inline ObjectArray* Class::GetIFields() const { +inline ObjectArray* Class::GetIFields() const { DCHECK(IsLoaded() || IsErroneous()); - return GetFieldObject*>(OFFSET_OF_OBJECT_MEMBER(Class, ifields_), false); + return GetFieldObject*>(OFFSET_OF_OBJECT_MEMBER(Class, ifields_), false); } -inline void Class::SetIFields(ObjectArray* new_ifields) +inline void Class::SetIFields(ObjectArray* new_ifields) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - DCHECK(NULL == GetFieldObject*>( + DCHECK(NULL == GetFieldObject*>( OFFSET_OF_OBJECT_MEMBER(Class, ifields_), false)); SetFieldObject(OFFSET_OF_OBJECT_MEMBER(Class, ifields_), new_ifields, false); } -inline ObjectArray* Class::GetSFields() const { +inline ObjectArray* Class::GetSFields() const { DCHECK(IsLoaded() || IsErroneous()); - return GetFieldObject*>(OFFSET_OF_OBJECT_MEMBER(Class, sfields_), false); + return GetFieldObject*>(OFFSET_OF_OBJECT_MEMBER(Class, sfields_), false); } -inline void Class::SetSFields(ObjectArray* new_sfields) +inline void Class::SetSFields(ObjectArray* new_sfields) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - DCHECK(NULL == GetFieldObject*>( + DCHECK(NULL == GetFieldObject*>( OFFSET_OF_OBJECT_MEMBER(Class, sfields_), false)); SetFieldObject(OFFSET_OF_OBJECT_MEMBER(Class, sfields_), new_sfields, false); } @@ -291,14 +291,14 @@ inline size_t Class::NumStaticFields() const { return (GetSFields() != NULL) ? GetSFields()->GetLength() : 0; } -inline Field* Class::GetStaticField(uint32_t i) const // TODO: uint16_t +inline ArtField* Class::GetStaticField(uint32_t i) const // TODO: uint16_t SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return GetSFields()->Get(i); } -inline void Class::SetStaticField(uint32_t i, Field* f) // TODO: uint16_t +inline void Class::SetStaticField(uint32_t i, ArtField* f) // TODO: uint16_t SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - ObjectArray* sfields= GetFieldObject*>( + ObjectArray* sfields= GetFieldObject*>( OFFSET_OF_OBJECT_MEMBER(Class, sfields_), false); sfields->Set(i, f); } @@ -307,15 +307,15 @@ inline size_t Class::NumInstanceFields() const { return (GetIFields() != NULL) ? GetIFields()->GetLength() : 0; } -inline Field* Class::GetInstanceField(uint32_t i) const // TODO: uint16_t +inline ArtField* Class::GetInstanceField(uint32_t i) const // TODO: uint16_t SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { DCHECK_NE(NumInstanceFields(), 0U); return GetIFields()->Get(i); } -inline void Class::SetInstanceField(uint32_t i, Field* f) // TODO: uint16_t +inline void Class::SetInstanceField(uint32_t i, ArtField* f) // TODO: uint16_t SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - ObjectArray* ifields= GetFieldObject*>( + ObjectArray* ifields= GetFieldObject*>( OFFSET_OF_OBJECT_MEMBER(Class, ifields_), false); ifields->Set(i, f); } @@ -330,9 +330,8 @@ inline uint32_t Class::GetAccessFlags() const { // circularity issue during loading the names of its members DCHECK(IsLoaded() || IsErroneous() || this == String::GetJavaLangString() || - this == Field::GetJavaLangReflectField() || - this == AbstractMethod::GetConstructorClass() || - this == AbstractMethod::GetMethodClass()); + this == ArtField::GetJavaLangReflectArtField() || + this == ArtMethod::GetJavaLangReflectArtMethod()); return GetField32(OFFSET_OF_OBJECT_MEMBER(Class, access_flags_), false); } diff --git a/runtime/mirror/class.cc b/runtime/mirror/class.cc index e490d97f80..29025f26c8 100644 --- a/runtime/mirror/class.cc +++ b/runtime/mirror/class.cc @@ -16,13 +16,13 @@ #include "class.h" -#include "abstract_method-inl.h" +#include "art_field-inl.h" +#include "art_method-inl.h" #include "class-inl.h" #include "class_linker.h" #include "class_loader.h" #include "dex_cache.h" #include "dex_file-inl.h" -#include "field-inl.h" #include "gc/accounting/card_table-inl.h" #include "object-inl.h" #include "object_array-inl.h" @@ -63,7 +63,7 @@ void Class::SetStatus(Status new_status) { // Stash current exception. Thread* self = Thread::Current(); SirtRef old_throw_this_object(self, NULL); - SirtRef old_throw_method(self, NULL); + SirtRef old_throw_method(self, NULL); SirtRef old_exception(self, NULL); uint32_t old_throw_dex_pc; { @@ -316,24 +316,23 @@ bool Class::IsThrowableClass() const { return WellKnownClasses::ToClass(WellKnownClasses::java_lang_Throwable)->IsAssignableFrom(this); } -bool Class::IsFieldClass() const { +bool Class::IsArtFieldClass() const { Class* java_lang_Class = GetClass(); - Class* java_lang_reflect_Field = java_lang_Class->GetInstanceField(0)->GetClass(); - return this == java_lang_reflect_Field; + Class* java_lang_reflect_ArtField = java_lang_Class->GetInstanceField(0)->GetClass(); + return this == java_lang_reflect_ArtField; } -bool Class::IsMethodClass() const { - return (this == AbstractMethod::GetMethodClass()) || - (this == AbstractMethod::GetConstructorClass()); +bool Class::IsArtMethodClass() const { + return this == ArtMethod::GetJavaLangReflectArtMethod(); } void Class::SetClassLoader(ClassLoader* new_class_loader) { SetFieldObject(OFFSET_OF_OBJECT_MEMBER(Class, class_loader_), new_class_loader, false); } -AbstractMethod* Class::FindInterfaceMethod(const StringPiece& name, const StringPiece& signature) const { +ArtMethod* Class::FindInterfaceMethod(const StringPiece& name, const StringPiece& signature) const { // Check the current class before checking the interfaces. - AbstractMethod* method = FindDeclaredVirtualMethod(name, signature); + ArtMethod* method = FindDeclaredVirtualMethod(name, signature); if (method != NULL) { return method; } @@ -349,9 +348,9 @@ AbstractMethod* Class::FindInterfaceMethod(const StringPiece& name, const String return NULL; } -AbstractMethod* Class::FindInterfaceMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const { +ArtMethod* Class::FindInterfaceMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const { // Check the current class before checking the interfaces. - AbstractMethod* method = FindDeclaredVirtualMethod(dex_cache, dex_method_idx); + ArtMethod* method = FindDeclaredVirtualMethod(dex_cache, dex_method_idx); if (method != NULL) { return method; } @@ -368,10 +367,10 @@ AbstractMethod* Class::FindInterfaceMethod(const DexCache* dex_cache, uint32_t d } -AbstractMethod* Class::FindDeclaredDirectMethod(const StringPiece& name, const StringPiece& signature) const { +ArtMethod* Class::FindDeclaredDirectMethod(const StringPiece& name, const StringPiece& signature) const { MethodHelper mh; for (size_t i = 0; i < NumDirectMethods(); ++i) { - AbstractMethod* method = GetDirectMethod(i); + ArtMethod* method = GetDirectMethod(i); mh.ChangeMethod(method); if (name == mh.GetName() && signature == mh.GetSignature()) { return method; @@ -380,10 +379,10 @@ AbstractMethod* Class::FindDeclaredDirectMethod(const StringPiece& name, const S return NULL; } -AbstractMethod* Class::FindDeclaredDirectMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const { +ArtMethod* Class::FindDeclaredDirectMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const { if (GetDexCache() == dex_cache) { for (size_t i = 0; i < NumDirectMethods(); ++i) { - AbstractMethod* method = GetDirectMethod(i); + ArtMethod* method = GetDirectMethod(i); if (method->GetDexMethodIndex() == dex_method_idx) { return method; } @@ -392,9 +391,9 @@ AbstractMethod* Class::FindDeclaredDirectMethod(const DexCache* dex_cache, uint3 return NULL; } -AbstractMethod* Class::FindDirectMethod(const StringPiece& name, const StringPiece& signature) const { +ArtMethod* Class::FindDirectMethod(const StringPiece& name, const StringPiece& signature) const { for (const Class* klass = this; klass != NULL; klass = klass->GetSuperClass()) { - AbstractMethod* method = klass->FindDeclaredDirectMethod(name, signature); + ArtMethod* method = klass->FindDeclaredDirectMethod(name, signature); if (method != NULL) { return method; } @@ -402,9 +401,9 @@ AbstractMethod* Class::FindDirectMethod(const StringPiece& name, const StringPie return NULL; } -AbstractMethod* Class::FindDirectMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const { +ArtMethod* Class::FindDirectMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const { for (const Class* klass = this; klass != NULL; klass = klass->GetSuperClass()) { - AbstractMethod* method = klass->FindDeclaredDirectMethod(dex_cache, dex_method_idx); + ArtMethod* method = klass->FindDeclaredDirectMethod(dex_cache, dex_method_idx); if (method != NULL) { return method; } @@ -412,11 +411,11 @@ AbstractMethod* Class::FindDirectMethod(const DexCache* dex_cache, uint32_t dex_ return NULL; } -AbstractMethod* Class::FindDeclaredVirtualMethod(const StringPiece& name, +ArtMethod* Class::FindDeclaredVirtualMethod(const StringPiece& name, const StringPiece& signature) const { MethodHelper mh; for (size_t i = 0; i < NumVirtualMethods(); ++i) { - AbstractMethod* method = GetVirtualMethod(i); + ArtMethod* method = GetVirtualMethod(i); mh.ChangeMethod(method); if (name == mh.GetName() && signature == mh.GetSignature()) { return method; @@ -425,10 +424,10 @@ AbstractMethod* Class::FindDeclaredVirtualMethod(const StringPiece& name, return NULL; } -AbstractMethod* Class::FindDeclaredVirtualMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const { +ArtMethod* Class::FindDeclaredVirtualMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const { if (GetDexCache() == dex_cache) { for (size_t i = 0; i < NumVirtualMethods(); ++i) { - AbstractMethod* method = GetVirtualMethod(i); + ArtMethod* method = GetVirtualMethod(i); if (method->GetDexMethodIndex() == dex_method_idx) { return method; } @@ -437,9 +436,9 @@ AbstractMethod* Class::FindDeclaredVirtualMethod(const DexCache* dex_cache, uint return NULL; } -AbstractMethod* Class::FindVirtualMethod(const StringPiece& name, const StringPiece& signature) const { +ArtMethod* Class::FindVirtualMethod(const StringPiece& name, const StringPiece& signature) const { for (const Class* klass = this; klass != NULL; klass = klass->GetSuperClass()) { - AbstractMethod* method = klass->FindDeclaredVirtualMethod(name, signature); + ArtMethod* method = klass->FindDeclaredVirtualMethod(name, signature); if (method != NULL) { return method; } @@ -447,9 +446,9 @@ AbstractMethod* Class::FindVirtualMethod(const StringPiece& name, const StringPi return NULL; } -AbstractMethod* Class::FindVirtualMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const { +ArtMethod* Class::FindVirtualMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const { for (const Class* klass = this; klass != NULL; klass = klass->GetSuperClass()) { - AbstractMethod* method = klass->FindDeclaredVirtualMethod(dex_cache, dex_method_idx); + ArtMethod* method = klass->FindDeclaredVirtualMethod(dex_cache, dex_method_idx); if (method != NULL) { return method; } @@ -457,12 +456,12 @@ AbstractMethod* Class::FindVirtualMethod(const DexCache* dex_cache, uint32_t dex return NULL; } -Field* Class::FindDeclaredInstanceField(const StringPiece& name, const StringPiece& type) { +ArtField* Class::FindDeclaredInstanceField(const StringPiece& name, const StringPiece& type) { // Is the field in this class? // Interfaces are not relevant because they can't contain instance fields. FieldHelper fh; for (size_t i = 0; i < NumInstanceFields(); ++i) { - Field* f = GetInstanceField(i); + ArtField* f = GetInstanceField(i); fh.ChangeField(f); if (name == fh.GetName() && type == fh.GetTypeDescriptor()) { return f; @@ -471,10 +470,10 @@ Field* Class::FindDeclaredInstanceField(const StringPiece& name, const StringPie return NULL; } -Field* Class::FindDeclaredInstanceField(const DexCache* dex_cache, uint32_t dex_field_idx) { +ArtField* Class::FindDeclaredInstanceField(const DexCache* dex_cache, uint32_t dex_field_idx) { if (GetDexCache() == dex_cache) { for (size_t i = 0; i < NumInstanceFields(); ++i) { - Field* f = GetInstanceField(i); + ArtField* f = GetInstanceField(i); if (f->GetDexFieldIndex() == dex_field_idx) { return f; } @@ -483,11 +482,11 @@ Field* Class::FindDeclaredInstanceField(const DexCache* dex_cache, uint32_t dex_ return NULL; } -Field* Class::FindInstanceField(const StringPiece& name, const StringPiece& type) { +ArtField* Class::FindInstanceField(const StringPiece& name, const StringPiece& type) { // Is the field in this class, or any of its superclasses? // Interfaces are not relevant because they can't contain instance fields. for (Class* c = this; c != NULL; c = c->GetSuperClass()) { - Field* f = c->FindDeclaredInstanceField(name, type); + ArtField* f = c->FindDeclaredInstanceField(name, type); if (f != NULL) { return f; } @@ -495,11 +494,11 @@ Field* Class::FindInstanceField(const StringPiece& name, const StringPiece& type return NULL; } -Field* Class::FindInstanceField(const DexCache* dex_cache, uint32_t dex_field_idx) { +ArtField* Class::FindInstanceField(const DexCache* dex_cache, uint32_t dex_field_idx) { // Is the field in this class, or any of its superclasses? // Interfaces are not relevant because they can't contain instance fields. for (Class* c = this; c != NULL; c = c->GetSuperClass()) { - Field* f = c->FindDeclaredInstanceField(dex_cache, dex_field_idx); + ArtField* f = c->FindDeclaredInstanceField(dex_cache, dex_field_idx); if (f != NULL) { return f; } @@ -507,11 +506,11 @@ Field* Class::FindInstanceField(const DexCache* dex_cache, uint32_t dex_field_id return NULL; } -Field* Class::FindDeclaredStaticField(const StringPiece& name, const StringPiece& type) { +ArtField* Class::FindDeclaredStaticField(const StringPiece& name, const StringPiece& type) { DCHECK(type != NULL); FieldHelper fh; for (size_t i = 0; i < NumStaticFields(); ++i) { - Field* f = GetStaticField(i); + ArtField* f = GetStaticField(i); fh.ChangeField(f); if (name == fh.GetName() && type == fh.GetTypeDescriptor()) { return f; @@ -520,10 +519,10 @@ Field* Class::FindDeclaredStaticField(const StringPiece& name, const StringPiece return NULL; } -Field* Class::FindDeclaredStaticField(const DexCache* dex_cache, uint32_t dex_field_idx) { +ArtField* Class::FindDeclaredStaticField(const DexCache* dex_cache, uint32_t dex_field_idx) { if (dex_cache == GetDexCache()) { for (size_t i = 0; i < NumStaticFields(); ++i) { - Field* f = GetStaticField(i); + ArtField* f = GetStaticField(i); if (f->GetDexFieldIndex() == dex_field_idx) { return f; } @@ -532,13 +531,13 @@ Field* Class::FindDeclaredStaticField(const DexCache* dex_cache, uint32_t dex_fi return NULL; } -Field* Class::FindStaticField(const StringPiece& name, const StringPiece& type) { +ArtField* Class::FindStaticField(const StringPiece& name, const StringPiece& type) { // Is the field in this class (or its interfaces), or any of its // superclasses (or their interfaces)? ClassHelper kh; for (Class* k = this; k != NULL; k = k->GetSuperClass()) { // Is the field in this class? - Field* f = k->FindDeclaredStaticField(name, type); + ArtField* f = k->FindDeclaredStaticField(name, type); if (f != NULL) { return f; } @@ -555,11 +554,11 @@ Field* Class::FindStaticField(const StringPiece& name, const StringPiece& type) return NULL; } -Field* Class::FindStaticField(const DexCache* dex_cache, uint32_t dex_field_idx) { +ArtField* Class::FindStaticField(const DexCache* dex_cache, uint32_t dex_field_idx) { ClassHelper kh; for (Class* k = this; k != NULL; k = k->GetSuperClass()) { // Is the field in this class? - Field* f = k->FindDeclaredStaticField(dex_cache, dex_field_idx); + ArtField* f = k->FindDeclaredStaticField(dex_cache, dex_field_idx); if (f != NULL) { return f; } @@ -576,12 +575,12 @@ Field* Class::FindStaticField(const DexCache* dex_cache, uint32_t dex_field_idx) return NULL; } -Field* Class::FindField(const StringPiece& name, const StringPiece& type) { +ArtField* Class::FindField(const StringPiece& name, const StringPiece& type) { // Find a field using the JLS field resolution order ClassHelper kh; for (Class* k = this; k != NULL; k = k->GetSuperClass()) { // Is the field in this class? - Field* f = k->FindDeclaredInstanceField(name, type); + ArtField* f = k->FindDeclaredInstanceField(name, type); if (f != NULL) { return f; } @@ -602,11 +601,11 @@ Field* Class::FindField(const StringPiece& name, const StringPiece& type) { return NULL; } -static void SetPreverifiedFlagOnMethods(mirror::ObjectArray* methods) +static void SetPreverifiedFlagOnMethods(mirror::ObjectArray* methods) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { if (methods != NULL) { for (int32_t index = 0, end = methods->GetLength(); index < end; ++index) { - mirror::AbstractMethod* method = methods->GetWithoutChecks(index); + mirror::ArtMethod* method = methods->GetWithoutChecks(index); DCHECK(method != NULL); method->SetPreverified(); } diff --git a/runtime/mirror/class.h b/runtime/mirror/class.h index 1dd02c0256..638b67f485 100644 --- a/runtime/mirror/class.h +++ b/runtime/mirror/class.h @@ -63,9 +63,9 @@ class StringPiece; namespace mirror { +class ArtField; class ClassLoader; class DexCache; -class Field; class IfTable; // Type for the InitializedStaticStorage table. Currently the Class @@ -341,9 +341,9 @@ class MANAGED Class : public StaticStorageBase { bool IsThrowableClass() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - bool IsFieldClass() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + bool IsArtFieldClass() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - bool IsMethodClass() const; + bool IsArtMethodClass() const; Class* GetComponentType() const { return GetFieldObject(OFFSET_OF_OBJECT_MEMBER(Class, component_type_), false); @@ -502,42 +502,42 @@ class MANAGED Class : public StaticStorageBase { void SetDexCache(DexCache* new_dex_cache) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - ObjectArray* GetDirectMethods() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + ObjectArray* GetDirectMethods() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void SetDirectMethods(ObjectArray* new_direct_methods) + void SetDirectMethods(ObjectArray* new_direct_methods) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - AbstractMethod* GetDirectMethod(int32_t i) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + ArtMethod* GetDirectMethod(int32_t i) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void SetDirectMethod(uint32_t i, AbstractMethod* f) // TODO: uint16_t + void SetDirectMethod(uint32_t i, ArtMethod* f) // TODO: uint16_t SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Returns the number of static, private, and constructor methods. size_t NumDirectMethods() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - ObjectArray* GetVirtualMethods() const + ObjectArray* GetVirtualMethods() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void SetVirtualMethods(ObjectArray* new_virtual_methods) + void SetVirtualMethods(ObjectArray* new_virtual_methods) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Returns the number of non-inherited virtual methods. size_t NumVirtualMethods() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - AbstractMethod* GetVirtualMethod(uint32_t i) const + ArtMethod* GetVirtualMethod(uint32_t i) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - AbstractMethod* GetVirtualMethodDuringLinking(uint32_t i) const + ArtMethod* GetVirtualMethodDuringLinking(uint32_t i) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void SetVirtualMethod(uint32_t i, AbstractMethod* f) // TODO: uint16_t + void SetVirtualMethod(uint32_t i, ArtMethod* f) // TODO: uint16_t SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - ObjectArray* GetVTable() const; + ObjectArray* GetVTable() const; - ObjectArray* GetVTableDuringLinking() const; + ObjectArray* GetVTableDuringLinking() const; - void SetVTable(ObjectArray* new_vtable) + void SetVTable(ObjectArray* new_vtable) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); static MemberOffset VTableOffset() { @@ -546,51 +546,51 @@ class MANAGED Class : public StaticStorageBase { // Given a method implemented by this class but potentially from a super class, return the // specific implementation method for this class. - AbstractMethod* FindVirtualMethodForVirtual(AbstractMethod* method) const + ArtMethod* FindVirtualMethodForVirtual(ArtMethod* method) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Given a method implemented by this class' super class, return the specific implementation // method for this class. - AbstractMethod* FindVirtualMethodForSuper(AbstractMethod* method) const + ArtMethod* FindVirtualMethodForSuper(ArtMethod* method) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Given a method implemented by this class, but potentially from a // super class or interface, return the specific implementation // method for this class. - AbstractMethod* FindVirtualMethodForInterface(AbstractMethod* method) const + ArtMethod* FindVirtualMethodForInterface(ArtMethod* method) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) ALWAYS_INLINE; - AbstractMethod* FindInterfaceMethod(const StringPiece& name, const StringPiece& descriptor) const + ArtMethod* FindInterfaceMethod(const StringPiece& name, const StringPiece& descriptor) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - AbstractMethod* FindInterfaceMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const + ArtMethod* FindInterfaceMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - AbstractMethod* FindVirtualMethodForVirtualOrInterface(AbstractMethod* method) const + ArtMethod* FindVirtualMethodForVirtualOrInterface(ArtMethod* method) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - AbstractMethod* FindDeclaredVirtualMethod(const StringPiece& name, const StringPiece& signature) const + ArtMethod* FindDeclaredVirtualMethod(const StringPiece& name, const StringPiece& signature) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - AbstractMethod* FindDeclaredVirtualMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const + ArtMethod* FindDeclaredVirtualMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - AbstractMethod* FindVirtualMethod(const StringPiece& name, const StringPiece& descriptor) const + ArtMethod* FindVirtualMethod(const StringPiece& name, const StringPiece& descriptor) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - AbstractMethod* FindVirtualMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const + ArtMethod* FindVirtualMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - AbstractMethod* FindDeclaredDirectMethod(const StringPiece& name, const StringPiece& signature) const + ArtMethod* FindDeclaredDirectMethod(const StringPiece& name, const StringPiece& signature) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - AbstractMethod* FindDeclaredDirectMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const + ArtMethod* FindDeclaredDirectMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - AbstractMethod* FindDirectMethod(const StringPiece& name, const StringPiece& signature) const + ArtMethod* FindDirectMethod(const StringPiece& name, const StringPiece& signature) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - AbstractMethod* FindDirectMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const + ArtMethod* FindDirectMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); int32_t GetIfTableCount() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); @@ -600,16 +600,16 @@ class MANAGED Class : public StaticStorageBase { void SetIfTable(IfTable* new_iftable) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Get instance fields of the class (See also GetSFields). - ObjectArray* GetIFields() const; + ObjectArray* GetIFields() const; - void SetIFields(ObjectArray* new_ifields) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + void SetIFields(ObjectArray* new_ifields) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); size_t NumInstanceFields() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - Field* GetInstanceField(uint32_t i) const // TODO: uint16_t + ArtField* GetInstanceField(uint32_t i) const // TODO: uint16_t SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void SetInstanceField(uint32_t i, Field* f) // TODO: uint16_t + void SetInstanceField(uint32_t i, ArtField* f) // TODO: uint16_t SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Returns the number of instance fields containing reference types. @@ -662,15 +662,15 @@ class MANAGED Class : public StaticStorageBase { } // Gets the static fields of the class. - ObjectArray* GetSFields() const; + ObjectArray* GetSFields() const; - void SetSFields(ObjectArray* new_sfields) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + void SetSFields(ObjectArray* new_sfields) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); size_t NumStaticFields() const; - Field* GetStaticField(uint32_t i) const; // TODO: uint16_t + ArtField* GetStaticField(uint32_t i) const; // TODO: uint16_t - void SetStaticField(uint32_t i, Field* f); // TODO: uint16_t + void SetStaticField(uint32_t i, ArtField* f); // TODO: uint16_t uint32_t GetReferenceStaticOffsets() const { return GetField32(OFFSET_OF_OBJECT_MEMBER(Class, reference_static_offsets_), false); @@ -679,37 +679,37 @@ class MANAGED Class : public StaticStorageBase { void SetReferenceStaticOffsets(uint32_t new_reference_offsets); // Find a static or instance field using the JLS resolution order - Field* FindField(const StringPiece& name, const StringPiece& type) + ArtField* FindField(const StringPiece& name, const StringPiece& type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Finds the given instance field in this class or a superclass. - Field* FindInstanceField(const StringPiece& name, const StringPiece& type) + ArtField* FindInstanceField(const StringPiece& name, const StringPiece& type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Finds the given instance field in this class or a superclass, only searches classes that // have the same dex cache. - Field* FindInstanceField(const DexCache* dex_cache, uint32_t dex_field_idx) + ArtField* FindInstanceField(const DexCache* dex_cache, uint32_t dex_field_idx) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - Field* FindDeclaredInstanceField(const StringPiece& name, const StringPiece& type) + ArtField* FindDeclaredInstanceField(const StringPiece& name, const StringPiece& type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - Field* FindDeclaredInstanceField(const DexCache* dex_cache, uint32_t dex_field_idx) + ArtField* FindDeclaredInstanceField(const DexCache* dex_cache, uint32_t dex_field_idx) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Finds the given static field in this class or a superclass. - Field* FindStaticField(const StringPiece& name, const StringPiece& type) + ArtField* FindStaticField(const StringPiece& name, const StringPiece& type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Finds the given static field in this class or superclass, only searches classes that // have the same dex cache. - Field* FindStaticField(const DexCache* dex_cache, uint32_t dex_field_idx) + ArtField* FindStaticField(const DexCache* dex_cache, uint32_t dex_field_idx) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - Field* FindDeclaredStaticField(const StringPiece& name, const StringPiece& type) + ArtField* FindDeclaredStaticField(const StringPiece& name, const StringPiece& type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - Field* FindDeclaredStaticField(const DexCache* dex_cache, uint32_t dex_field_idx) + ArtField* FindDeclaredStaticField(const DexCache* dex_cache, uint32_t dex_field_idx) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); pid_t GetClinitThreadId() const { @@ -768,7 +768,7 @@ class MANAGED Class : public StaticStorageBase { DexCache* dex_cache_; // static, private, and methods - ObjectArray* direct_methods_; + ObjectArray* direct_methods_; // instance fields // @@ -780,7 +780,7 @@ class MANAGED Class : public StaticStorageBase { // All instance fields that refer to objects are guaranteed to be at // the beginning of the field list. num_reference_instance_fields_ // specifies the number of reference fields. - ObjectArray* ifields_; + ObjectArray* ifields_; // The interface table (iftable_) contains pairs of a interface class and an array of the // interface methods. There is one pair per interface supported by this class. That means one @@ -799,7 +799,7 @@ class MANAGED Class : public StaticStorageBase { String* name_; // Static fields - ObjectArray* sfields_; + ObjectArray* sfields_; // The superclass, or NULL if this is java.lang.Object, an interface or primitive type. Class* super_class_; @@ -808,13 +808,13 @@ class MANAGED Class : public StaticStorageBase { Class* verify_error_class_; // virtual methods defined in this class; invoked through vtable - ObjectArray* virtual_methods_; + ObjectArray* virtual_methods_; // Virtual method table (vtable), for use by "invoke-virtual". The vtable from the superclass is // copied in, and virtual methods from our class either replace those from the super or are // appended. For abstract classes, methods may be created in the vtable that aren't in // virtual_ methods_ for miranda methods. - ObjectArray* vtable_; + ObjectArray* vtable_; // access flags; low 16 bits are defined by VM spec uint32_t access_flags_; diff --git a/runtime/mirror/dex_cache-inl.h b/runtime/mirror/dex_cache-inl.h index 369dc49ed0..da26be59b9 100644 --- a/runtime/mirror/dex_cache-inl.h +++ b/runtime/mirror/dex_cache-inl.h @@ -22,9 +22,9 @@ namespace art { namespace mirror { -inline AbstractMethod* DexCache::GetResolvedMethod(uint32_t method_idx) const +inline ArtMethod* DexCache::GetResolvedMethod(uint32_t method_idx) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - AbstractMethod* method = GetResolvedMethods()->Get(method_idx); + ArtMethod* method = GetResolvedMethods()->Get(method_idx); // Hide resolution trampoline methods from the caller if (method != NULL && method->IsRuntimeMethod()) { DCHECK(method == Runtime::Current()->GetResolutionMethod()); diff --git a/runtime/mirror/dex_cache.cc b/runtime/mirror/dex_cache.cc index 239dc5e0c3..00531e3076 100644 --- a/runtime/mirror/dex_cache.cc +++ b/runtime/mirror/dex_cache.cc @@ -16,7 +16,7 @@ #include "dex_cache.h" -#include "abstract_method-inl.h" +#include "art_method-inl.h" #include "base/logging.h" #include "class_linker.h" #include "gc/accounting/card_table-inl.h" @@ -35,8 +35,8 @@ void DexCache::Init(const DexFile* dex_file, String* location, ObjectArray* strings, ObjectArray* resolved_types, - ObjectArray* resolved_methods, - ObjectArray* resolved_fields, + ObjectArray* resolved_methods, + ObjectArray* resolved_fields, ObjectArray* initialized_static_storage) { CHECK(dex_file != NULL); CHECK(location != NULL); @@ -58,7 +58,7 @@ void DexCache::Init(const DexFile* dex_file, Runtime* runtime = Runtime::Current(); if (runtime->HasResolutionMethod()) { // Initialize the resolve methods array to contain trampolines for resolution. - AbstractMethod* trampoline = runtime->GetResolutionMethod(); + ArtMethod* trampoline = runtime->GetResolutionMethod(); size_t length = resolved_methods->GetLength(); for (size_t i = 0; i < length; i++) { resolved_methods->SetWithoutChecks(i, trampoline); @@ -66,10 +66,10 @@ void DexCache::Init(const DexFile* dex_file, } } -void DexCache::Fixup(AbstractMethod* trampoline) { +void DexCache::Fixup(ArtMethod* trampoline) { // Fixup the resolve methods array to contain trampoline for resolution. CHECK(trampoline != NULL); - ObjectArray* resolved_methods = GetResolvedMethods(); + ObjectArray* resolved_methods = GetResolvedMethods(); size_t length = resolved_methods->GetLength(); for (size_t i = 0; i < length; i++) { if (resolved_methods->GetWithoutChecks(i) == NULL) { diff --git a/runtime/mirror/dex_cache.h b/runtime/mirror/dex_cache.h index 9c0f09ba21..6cfab9e425 100644 --- a/runtime/mirror/dex_cache.h +++ b/runtime/mirror/dex_cache.h @@ -17,7 +17,7 @@ #ifndef ART_RUNTIME_MIRROR_DEX_CACHE_H_ #define ART_RUNTIME_MIRROR_DEX_CACHE_H_ -#include "abstract_method.h" +#include "art_method.h" #include "class.h" #include "object.h" #include "object_array.h" @@ -32,8 +32,8 @@ union JValue; namespace mirror { +class ArtField; class Class; -class Field; class MANAGED DexCacheClass : public Class { private: @@ -46,12 +46,12 @@ class MANAGED DexCache : public Object { String* location, ObjectArray* strings, ObjectArray* types, - ObjectArray* methods, - ObjectArray* fields, + ObjectArray* methods, + ObjectArray* fields, ObjectArray* initialized_static_storage) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void Fixup(AbstractMethod* trampoline) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + void Fixup(ArtMethod* trampoline) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); String* GetLocation() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return GetFieldObject(OFFSET_OF_OBJECT_MEMBER(DexCache, location_), false); @@ -110,20 +110,20 @@ class MANAGED DexCache : public Object { GetResolvedTypes()->Set(type_idx, resolved); } - AbstractMethod* GetResolvedMethod(uint32_t method_idx) const + ArtMethod* GetResolvedMethod(uint32_t method_idx) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void SetResolvedMethod(uint32_t method_idx, AbstractMethod* resolved) + void SetResolvedMethod(uint32_t method_idx, ArtMethod* resolved) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { GetResolvedMethods()->Set(method_idx, resolved); } - Field* GetResolvedField(uint32_t field_idx) const + ArtField* GetResolvedField(uint32_t field_idx) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return GetResolvedFields()->Get(field_idx); } - void SetResolvedField(uint32_t field_idx, Field* resolved) + void SetResolvedField(uint32_t field_idx, ArtField* resolved) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { GetResolvedFields()->Set(field_idx, resolved); } @@ -139,14 +139,14 @@ class MANAGED DexCache : public Object { OFFSET_OF_OBJECT_MEMBER(DexCache, resolved_types_), false); } - ObjectArray* GetResolvedMethods() const + ObjectArray* GetResolvedMethods() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - return GetFieldObject< ObjectArray* >(ResolvedMethodsOffset(), false); + return GetFieldObject< ObjectArray* >(ResolvedMethodsOffset(), false); } - ObjectArray* GetResolvedFields() const + ObjectArray* GetResolvedFields() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - return GetFieldObject< ObjectArray* >(ResolvedFieldsOffset(), false); + return GetFieldObject< ObjectArray* >(ResolvedFieldsOffset(), false); } ObjectArray* GetInitializedStaticStorage() const @@ -166,8 +166,8 @@ class MANAGED DexCache : public Object { private: ObjectArray* initialized_static_storage_; String* location_; - ObjectArray* resolved_fields_; - ObjectArray* resolved_methods_; + ObjectArray* resolved_fields_; + ObjectArray* resolved_methods_; ObjectArray* resolved_types_; ObjectArray* strings_; uint32_t dex_file_; diff --git a/runtime/mirror/field-inl.h b/runtime/mirror/field-inl.h deleted file mode 100644 index 3e3d6db4a6..0000000000 --- a/runtime/mirror/field-inl.h +++ /dev/null @@ -1,221 +0,0 @@ -/* - * Copyright (C) 2011 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_MIRROR_FIELD_INL_H_ -#define ART_RUNTIME_MIRROR_FIELD_INL_H_ - -#include "field.h" - -#include "base/logging.h" -#include "gc/accounting/card_table-inl.h" -#include "jvalue.h" -#include "object-inl.h" -#include "object_utils.h" -#include "primitive.h" - -namespace art { -namespace mirror { - -inline Class* Field::GetDeclaringClass() const { - Class* result = GetFieldObject(OFFSET_OF_OBJECT_MEMBER(Field, declaring_class_), false); - DCHECK(result != NULL); - DCHECK(result->IsLoaded() || result->IsErroneous()); - return result; -} - -inline void Field::SetDeclaringClass(Class *new_declaring_class) { - SetFieldObject(OFFSET_OF_OBJECT_MEMBER(Field, declaring_class_), new_declaring_class, false); -} - -inline uint32_t Field::GetAccessFlags() const { - DCHECK(GetDeclaringClass()->IsLoaded() || GetDeclaringClass()->IsErroneous()); - return GetField32(OFFSET_OF_OBJECT_MEMBER(Field, access_flags_), false); -} - -inline MemberOffset Field::GetOffset() const { - DCHECK(GetDeclaringClass()->IsResolved() || GetDeclaringClass()->IsErroneous()); - return MemberOffset(GetField32(OFFSET_OF_OBJECT_MEMBER(Field, offset_), false)); -} - -inline MemberOffset Field::GetOffsetDuringLinking() const { - DCHECK(GetDeclaringClass()->IsLoaded() || GetDeclaringClass()->IsErroneous()); - return MemberOffset(GetField32(OFFSET_OF_OBJECT_MEMBER(Field, offset_), false)); -} - -inline uint32_t Field::Get32(const Object* object) const { - DCHECK(object != NULL) << PrettyField(this); - DCHECK(!IsStatic() || (object == GetDeclaringClass()) || !Runtime::Current()->IsStarted()); - return object->GetField32(GetOffset(), IsVolatile()); -} - -inline void Field::Set32(Object* object, uint32_t new_value) const { - DCHECK(object != NULL) << PrettyField(this); - DCHECK(!IsStatic() || (object == GetDeclaringClass()) || !Runtime::Current()->IsStarted()); - object->SetField32(GetOffset(), new_value, IsVolatile()); -} - -inline uint64_t Field::Get64(const Object* object) const { - DCHECK(object != NULL) << PrettyField(this); - DCHECK(!IsStatic() || (object == GetDeclaringClass()) || !Runtime::Current()->IsStarted()); - return object->GetField64(GetOffset(), IsVolatile()); -} - -inline void Field::Set64(Object* object, uint64_t new_value) const { - DCHECK(object != NULL) << PrettyField(this); - DCHECK(!IsStatic() || (object == GetDeclaringClass()) || !Runtime::Current()->IsStarted()); - object->SetField64(GetOffset(), new_value, IsVolatile()); -} - -inline Object* Field::GetObj(const Object* object) const { - DCHECK(object != NULL) << PrettyField(this); - DCHECK(!IsStatic() || (object == GetDeclaringClass()) || !Runtime::Current()->IsStarted()); - return object->GetFieldObject(GetOffset(), IsVolatile()); -} - -inline void Field::SetObj(Object* object, const Object* new_value) const { - DCHECK(object != NULL) << PrettyField(this); - DCHECK(!IsStatic() || (object == GetDeclaringClass()) || !Runtime::Current()->IsStarted()); - object->SetFieldObject(GetOffset(), new_value, IsVolatile()); -} - -inline bool Field::GetBoolean(const Object* object) const { - DCHECK_EQ(Primitive::kPrimBoolean, FieldHelper(this).GetTypeAsPrimitiveType()) - << PrettyField(this); - return Get32(object); -} - -inline void Field::SetBoolean(Object* object, bool z) const { - DCHECK_EQ(Primitive::kPrimBoolean, FieldHelper(this).GetTypeAsPrimitiveType()) - << PrettyField(this); - Set32(object, z); -} - -inline int8_t Field::GetByte(const Object* object) const { - DCHECK_EQ(Primitive::kPrimByte, FieldHelper(this).GetTypeAsPrimitiveType()) - << PrettyField(this); - return Get32(object); -} - -inline void Field::SetByte(Object* object, int8_t b) const { - DCHECK_EQ(Primitive::kPrimByte, FieldHelper(this).GetTypeAsPrimitiveType()) - << PrettyField(this); - Set32(object, b); -} - -inline uint16_t Field::GetChar(const Object* object) const { - DCHECK_EQ(Primitive::kPrimChar, FieldHelper(this).GetTypeAsPrimitiveType()) - << PrettyField(this); - return Get32(object); -} - -inline void Field::SetChar(Object* object, uint16_t c) const { - DCHECK_EQ(Primitive::kPrimChar, FieldHelper(this).GetTypeAsPrimitiveType()) - << PrettyField(this); - Set32(object, c); -} - -inline int16_t Field::GetShort(const Object* object) const { - DCHECK_EQ(Primitive::kPrimShort, FieldHelper(this).GetTypeAsPrimitiveType()) - << PrettyField(this); - return Get32(object); -} - -inline void Field::SetShort(Object* object, int16_t s) const { - DCHECK_EQ(Primitive::kPrimShort, FieldHelper(this).GetTypeAsPrimitiveType()) - << PrettyField(this); - Set32(object, s); -} - -inline int32_t Field::GetInt(const Object* object) const { -#ifndef NDEBUG - Primitive::Type type = FieldHelper(this).GetTypeAsPrimitiveType(); - CHECK(type == Primitive::kPrimInt || type == Primitive::kPrimFloat) << PrettyField(this); -#endif - return Get32(object); -} - -inline void Field::SetInt(Object* object, int32_t i) const { -#ifndef NDEBUG - Primitive::Type type = FieldHelper(this).GetTypeAsPrimitiveType(); - CHECK(type == Primitive::kPrimInt || type == Primitive::kPrimFloat) << PrettyField(this); -#endif - Set32(object, i); -} - -inline int64_t Field::GetLong(const Object* object) const { -#ifndef NDEBUG - Primitive::Type type = FieldHelper(this).GetTypeAsPrimitiveType(); - CHECK(type == Primitive::kPrimLong || type == Primitive::kPrimDouble) << PrettyField(this); -#endif - return Get64(object); -} - -inline void Field::SetLong(Object* object, int64_t j) const { -#ifndef NDEBUG - Primitive::Type type = FieldHelper(this).GetTypeAsPrimitiveType(); - CHECK(type == Primitive::kPrimLong || type == Primitive::kPrimDouble) << PrettyField(this); -#endif - Set64(object, j); -} - -inline float Field::GetFloat(const Object* object) const { - DCHECK_EQ(Primitive::kPrimFloat, FieldHelper(this).GetTypeAsPrimitiveType()) - << PrettyField(this); - JValue bits; - bits.SetI(Get32(object)); - return bits.GetF(); -} - -inline void Field::SetFloat(Object* object, float f) const { - DCHECK_EQ(Primitive::kPrimFloat, FieldHelper(this).GetTypeAsPrimitiveType()) - << PrettyField(this); - JValue bits; - bits.SetF(f); - Set32(object, bits.GetI()); -} - -inline double Field::GetDouble(const Object* object) const { - DCHECK_EQ(Primitive::kPrimDouble, FieldHelper(this).GetTypeAsPrimitiveType()) - << PrettyField(this); - JValue bits; - bits.SetJ(Get64(object)); - return bits.GetD(); -} - -inline void Field::SetDouble(Object* object, double d) const { - DCHECK_EQ(Primitive::kPrimDouble, FieldHelper(this).GetTypeAsPrimitiveType()) - << PrettyField(this); - JValue bits; - bits.SetD(d); - Set64(object, bits.GetJ()); -} - -inline Object* Field::GetObject(const Object* object) const { - DCHECK_EQ(Primitive::kPrimNot, FieldHelper(this).GetTypeAsPrimitiveType()) - << PrettyField(this); - return GetObj(object); -} - -inline void Field::SetObject(Object* object, const Object* l) const { - DCHECK_EQ(Primitive::kPrimNot, FieldHelper(this).GetTypeAsPrimitiveType()) - << PrettyField(this); - SetObj(object, l); -} - -} // namespace mirror -} // namespace art - -#endif // ART_RUNTIME_MIRROR_FIELD_INL_H_ diff --git a/runtime/mirror/field.cc b/runtime/mirror/field.cc deleted file mode 100644 index 12f395f6b6..0000000000 --- a/runtime/mirror/field.cc +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2011 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. - */ - -#include "field.h" - -#include "field-inl.h" -#include "gc/accounting/card_table-inl.h" -#include "object-inl.h" -#include "object_utils.h" -#include "runtime.h" -#include "utils.h" - -namespace art { -namespace mirror { - -// TODO: get global references for these -Class* Field::java_lang_reflect_Field_ = NULL; - -void Field::SetClass(Class* java_lang_reflect_Field) { - CHECK(java_lang_reflect_Field_ == NULL); - CHECK(java_lang_reflect_Field != NULL); - java_lang_reflect_Field_ = java_lang_reflect_Field; -} - -void Field::ResetClass() { - CHECK(java_lang_reflect_Field_ != NULL); - java_lang_reflect_Field_ = NULL; -} - -void Field::SetOffset(MemberOffset num_bytes) { - DCHECK(GetDeclaringClass()->IsLoaded() || GetDeclaringClass()->IsErroneous()); -#if 0 // TODO enable later in boot and under !NDEBUG - FieldHelper fh(this); - Primitive::Type type = fh.GetTypeAsPrimitiveType(); - if (type == Primitive::kPrimDouble || type == Primitive::kPrimLong) { - DCHECK_ALIGNED(num_bytes.Uint32Value(), 8); - } -#endif - SetField32(OFFSET_OF_OBJECT_MEMBER(Field, offset_), num_bytes.Uint32Value(), false); -} - -} // namespace mirror -} // namespace art diff --git a/runtime/mirror/field.h b/runtime/mirror/field.h deleted file mode 100644 index 6e508a362f..0000000000 --- a/runtime/mirror/field.h +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright (C) 2011 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_MIRROR_FIELD_H_ -#define ART_RUNTIME_MIRROR_FIELD_H_ - -#include "class.h" -#include "modifiers.h" -#include "object.h" - -namespace art { - -struct FieldClassOffsets; -struct FieldOffsets; - -namespace mirror { - -// C++ mirror of java.lang.reflect.Field -class MANAGED Field : public Object { - public: - Class* GetDeclaringClass() const; - - void SetDeclaringClass(Class *new_declaring_class) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - - uint32_t GetAccessFlags() const; - - void SetAccessFlags(uint32_t new_access_flags) { - SetField32(OFFSET_OF_OBJECT_MEMBER(Field, access_flags_), new_access_flags, false); - } - - bool IsPublic() const { - return (GetAccessFlags() & kAccPublic) != 0; - } - - bool IsStatic() const { - return (GetAccessFlags() & kAccStatic) != 0; - } - - bool IsFinal() const { - return (GetAccessFlags() & kAccFinal) != 0; - } - - uint32_t GetDexFieldIndex() const { - return GetField32(OFFSET_OF_OBJECT_MEMBER(Field, field_dex_idx_), false); - } - - void SetDexFieldIndex(uint32_t new_idx) { - SetField32(OFFSET_OF_OBJECT_MEMBER(Field, field_dex_idx_), new_idx, false); - } - - // Offset to field within an Object - MemberOffset GetOffset() const; - - static MemberOffset OffsetOffset() { - return MemberOffset(OFFSETOF_MEMBER(Field, offset_)); - } - - MemberOffset GetOffsetDuringLinking() const; - - void SetOffset(MemberOffset num_bytes); - - // field access, null object for static fields - bool GetBoolean(const Object* object) const - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void SetBoolean(Object* object, bool z) const - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - int8_t GetByte(const Object* object) const - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void SetByte(Object* object, int8_t b) const - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - uint16_t GetChar(const Object* object) const - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void SetChar(Object* object, uint16_t c) const - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - int16_t GetShort(const Object* object) const - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void SetShort(Object* object, int16_t s) const - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - int32_t GetInt(const Object* object) const - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void SetInt(Object* object, int32_t i) const - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - int64_t GetLong(const Object* object) const - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void SetLong(Object* object, int64_t j) const - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - float GetFloat(const Object* object) const - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void SetFloat(Object* object, float f) const - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - double GetDouble(const Object* object) const - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void SetDouble(Object* object, double d) const - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - Object* GetObject(const Object* object) const - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void SetObject(Object* object, const Object* l) const - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - - // raw field accesses - uint32_t Get32(const Object* object) const - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void Set32(Object* object, uint32_t new_value) const - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - uint64_t Get64(const Object* object) const - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void Set64(Object* object, uint64_t new_value) const - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - Object* GetObj(const Object* object) const - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void SetObj(Object* object, const Object* new_value) const - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - - static Class* GetJavaLangReflectField() { - DCHECK(java_lang_reflect_Field_ != NULL); - return java_lang_reflect_Field_; - } - - static void SetClass(Class* java_lang_reflect_Field); - static void ResetClass(); - - bool IsVolatile() const { - return (GetAccessFlags() & kAccVolatile) != 0; - } - - private: - // Field order required by test "ValidateFieldOrderOfJavaCppUnionClasses". - // The class we are a part of - Class* declaring_class_; - - uint32_t access_flags_; - - // Dex cache index of field id - uint32_t field_dex_idx_; - - // Offset of field within an instance or in the Class' static fields - uint32_t offset_; - - static Class* java_lang_reflect_Field_; - - friend struct art::FieldOffsets; // for verifying offset information - DISALLOW_IMPLICIT_CONSTRUCTORS(Field); -}; - -class MANAGED FieldClass : public Class { - private: - Object* ORDER_BY_NAME_AND_DECLARING_CLASS_; - friend struct art::FieldClassOffsets; // for verifying offset information - DISALLOW_IMPLICIT_CONSTRUCTORS(FieldClass); -}; - -} // namespace mirror -} // namespace art - -#endif // ART_RUNTIME_MIRROR_FIELD_H_ diff --git a/runtime/mirror/iftable.h b/runtime/mirror/iftable.h index aea8fddafe..421893d3db 100644 --- a/runtime/mirror/iftable.h +++ b/runtime/mirror/iftable.h @@ -32,24 +32,24 @@ class MANAGED IfTable : public ObjectArray { void SetInterface(int32_t i, Class* interface) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - ObjectArray* GetMethodArray(int32_t i) const + ObjectArray* GetMethodArray(int32_t i) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - ObjectArray* method_array = - down_cast*>(Get((i * kMax) + kMethodArray)); + ObjectArray* method_array = + down_cast*>(Get((i * kMax) + kMethodArray)); DCHECK(method_array != NULL); return method_array; } size_t GetMethodArrayCount(int32_t i) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - ObjectArray* method_array = - down_cast*>(Get((i * kMax) + kMethodArray)); + ObjectArray* method_array = + down_cast*>(Get((i * kMax) + kMethodArray)); if (method_array == NULL) { return 0; } return method_array->GetLength(); } - void SetMethodArray(int32_t i, ObjectArray* new_ma) + void SetMethodArray(int32_t i, ObjectArray* new_ma) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { DCHECK(new_ma != NULL); DCHECK(Get((i * kMax) + kMethodArray) == NULL); diff --git a/runtime/mirror/object-inl.h b/runtime/mirror/object-inl.h index 5818a800bf..63396d2f59 100644 --- a/runtime/mirror/object-inl.h +++ b/runtime/mirror/object-inl.h @@ -19,10 +19,10 @@ #include "object.h" -#include "abstract_method.h" +#include "art_field.h" +#include "art_method.h" #include "atomic.h" #include "array-inl.h" -#include "field.h" #include "class.h" #include "monitor.h" #include "runtime.h" @@ -112,32 +112,32 @@ inline bool Object::IsArrayInstance() const { return GetClass()->IsArrayClass(); } -inline bool Object::IsField() const { - return GetClass()->IsFieldClass(); +inline bool Object::IsArtField() const { + return GetClass()->IsArtFieldClass(); } -inline Field* Object::AsField() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - DCHECK(IsField()); - return down_cast(this); +inline ArtField* Object::AsArtField() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + DCHECK(IsArtField()); + return down_cast(this); } -inline const Field* Object::AsField() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - DCHECK(IsField()); - return down_cast(this); +inline const ArtField* Object::AsArtField() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + DCHECK(IsArtField()); + return down_cast(this); } -inline bool Object::IsMethod() const { - return GetClass()->IsMethodClass(); +inline bool Object::IsArtMethod() const { + return GetClass()->IsArtMethodClass(); } -inline AbstractMethod* Object::AsMethod() { - DCHECK(IsMethod()); - return down_cast(this); +inline ArtMethod* Object::AsArtMethod() { + DCHECK(IsArtMethod()); + return down_cast(this); } -inline const AbstractMethod* Object::AsMethod() const { - DCHECK(IsMethod()); - return down_cast(this); +inline const ArtMethod* Object::AsArtMethod() const { + DCHECK(IsArtMethod()); + return down_cast(this); } inline bool Object::IsReferenceInstance() const { @@ -227,8 +227,8 @@ inline size_t Object::SizeOf() const { } else { result = GetClass()->GetObjectSize(); } - DCHECK(!IsField() || result == sizeof(Field)); - DCHECK(!IsMethod() || result == sizeof(AbstractMethod)); + DCHECK(!IsArtField() || result == sizeof(ArtField)); + DCHECK(!IsArtMethod() || result == sizeof(ArtMethod)); return result; } diff --git a/runtime/mirror/object.cc b/runtime/mirror/object.cc index b2d6e71478..92c05b26ca 100644 --- a/runtime/mirror/object.cc +++ b/runtime/mirror/object.cc @@ -16,12 +16,12 @@ #include "object.h" +#include "art_field.h" +#include "art_field-inl.h" #include "array-inl.h" #include "class.h" #include "class-inl.h" #include "class_linker-inl.h" -#include "field.h" -#include "field-inl.h" #include "gc/accounting/card_table-inl.h" #include "gc/heap.h" #include "iftable-inl.h" @@ -67,7 +67,7 @@ Object* Object::Clone(Thread* self) { for (const Class* klass = c; klass != NULL; klass = klass->GetSuperClass()) { size_t num_reference_fields = klass->NumReferenceInstanceFields(); for (size_t i = 0; i < num_reference_fields; ++i) { - Field* field = klass->GetInstanceField(i); + ArtField* field = klass->GetInstanceField(i); MemberOffset field_offset = field->GetOffset(); const Object* ref = copy->GetFieldObject(field_offset, false); heap->WriteBarrierField(copy.get(), field_offset, ref); @@ -90,11 +90,11 @@ void Object::CheckFieldAssignmentImpl(MemberOffset field_offset, const Object* n return; } for (const Class* cur = c; cur != NULL; cur = cur->GetSuperClass()) { - ObjectArray* fields = cur->GetIFields(); + ObjectArray* fields = cur->GetIFields(); if (fields != NULL) { size_t num_ref_ifields = cur->NumReferenceInstanceFields(); for (size_t i = 0; i < num_ref_ifields; ++i) { - Field* field = fields->Get(i); + ArtField* field = fields->Get(i); if (field->GetOffset().Int32Value() == field_offset.Int32Value()) { FieldHelper fh(field); CHECK(fh.GetType()->IsAssignableFrom(new_value->GetClass())); @@ -108,11 +108,11 @@ void Object::CheckFieldAssignmentImpl(MemberOffset field_offset, const Object* n return; } if (IsClass()) { - ObjectArray* fields = AsClass()->GetSFields(); + ObjectArray* fields = AsClass()->GetSFields(); if (fields != NULL) { size_t num_ref_sfields = AsClass()->NumReferenceStaticFields(); for (size_t i = 0; i < num_ref_sfields; ++i) { - Field* field = fields->Get(i); + ArtField* field = fields->Get(i); if (field->GetOffset().Int32Value() == field_offset.Int32Value()) { FieldHelper fh(field); CHECK(fh.GetType()->IsAssignableFrom(new_value->GetClass())); diff --git a/runtime/mirror/object.h b/runtime/mirror/object.h index a40c906eb0..28a91dd8e5 100644 --- a/runtime/mirror/object.h +++ b/runtime/mirror/object.h @@ -31,10 +31,10 @@ class Thread; namespace mirror { -class AbstractMethod; +class ArtField; +class ArtMethod; class Array; class Class; -class Field; template class ObjectArray; template class PrimitiveArray; typedef PrimitiveArray BooleanArray; @@ -144,17 +144,17 @@ class MANAGED Object { Throwable* AsThrowable() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - bool IsMethod() const; + bool IsArtMethod() const; - AbstractMethod* AsMethod(); + ArtMethod* AsArtMethod(); - const AbstractMethod* AsMethod() const; + const ArtMethod* AsArtMethod() const; - bool IsField() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + bool IsArtField() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - Field* AsField() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + ArtField* AsArtField() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - const Field* AsField() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + const ArtField* AsArtField() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); bool IsReferenceInstance() const; diff --git a/runtime/mirror/object_array-inl.h b/runtime/mirror/object_array-inl.h index 8675c31b37..6f22618340 100644 --- a/runtime/mirror/object_array-inl.h +++ b/runtime/mirror/object_array-inl.h @@ -20,8 +20,8 @@ #include "object_array.h" #include "gc/heap.h" +#include "mirror/art_field.h" #include "mirror/class.h" -#include "mirror/field.h" #include "runtime.h" #include "thread.h" diff --git a/runtime/mirror/object_test.cc b/runtime/mirror/object_test.cc index 540ff9f68e..814305c3af 100644 --- a/runtime/mirror/object_test.cc +++ b/runtime/mirror/object_test.cc @@ -20,6 +20,7 @@ #include #include "array-inl.h" +#include "art_field-inl.h" #include "asm_support.h" #include "class-inl.h" #include "class_linker.h" @@ -27,11 +28,10 @@ #include "common_test.h" #include "dex_file.h" #include "entrypoints/entrypoint_utils.h" -#include "field-inl.h" #include "gc/accounting/card_table-inl.h" #include "gc/heap.h" #include "iftable-inl.h" -#include "abstract_method-inl.h" +#include "art_method-inl.h" #include "object-inl.h" #include "object_array-inl.h" #include "sirt_ref.h" @@ -75,7 +75,7 @@ TEST_F(ObjectTest, AsmConstants) { ASSERT_EQ(STRING_OFFSET_OFFSET, String::OffsetOffset().Int32Value()); ASSERT_EQ(STRING_DATA_OFFSET, Array::DataOffset(sizeof(uint16_t)).Int32Value()); - ASSERT_EQ(METHOD_CODE_OFFSET, AbstractMethod::EntryPointFromCompiledCodeOffset().Int32Value()); + ASSERT_EQ(METHOD_CODE_OFFSET, ArtMethod::EntryPointFromCompiledCodeOffset().Int32Value()); } TEST_F(ObjectTest, IsInSamePackage) { @@ -204,7 +204,7 @@ TEST_F(ObjectTest, CheckAndAllocArrayFromCode) { // pretend we are trying to call 'new char[3]' from String.toCharArray ScopedObjectAccess soa(Thread::Current()); Class* java_util_Arrays = class_linker_->FindSystemClass("Ljava/util/Arrays;"); - AbstractMethod* sort = java_util_Arrays->FindDirectMethod("sort", "([I)V"); + ArtMethod* sort = java_util_Arrays->FindDirectMethod("sort", "([I)V"); const DexFile::StringId* string_id = java_lang_dex_file_->FindStringId("[I"); ASSERT_TRUE(string_id != NULL); const DexFile::TypeId* type_id = java_lang_dex_file_->FindTypeId( @@ -261,7 +261,7 @@ TEST_F(ObjectTest, StaticFieldFromCode) { Class* klass = class_linker_->FindClass("LStaticsFromCode;", soa.Decode(class_loader)); - AbstractMethod* clinit = klass->FindDirectMethod("", "()V"); + ArtMethod* clinit = klass->FindDirectMethod("", "()V"); const DexFile::StringId* klass_string_id = dex_file->FindStringId("LStaticsFromCode;"); ASSERT_TRUE(klass_string_id != NULL); const DexFile::TypeId* klass_type_id = dex_file->FindTypeId( @@ -282,8 +282,8 @@ TEST_F(ObjectTest, StaticFieldFromCode) { ASSERT_TRUE(field_id != NULL); uint32_t field_idx = dex_file->GetIndexForFieldId(*field_id); - Field* field = FindFieldFromCode(field_idx, clinit, Thread::Current(), StaticObjectRead, - sizeof(Object*), true); + ArtField* field = FindFieldFromCode(field_idx, clinit, Thread::Current(), StaticObjectRead, + sizeof(Object*), true); Object* s0 = field->GetObj(klass); EXPECT_TRUE(s0 != NULL); @@ -294,7 +294,7 @@ TEST_F(ObjectTest, StaticFieldFromCode) { field->SetObj(field->GetDeclaringClass(), NULL); EXPECT_EQ(NULL, field->GetObj(klass)); - // TODO: more exhaustive tests of all 6 cases of Field::*FromCode + // TODO: more exhaustive tests of all 6 cases of ArtField::*FromCode } TEST_F(ObjectTest, String) { @@ -395,29 +395,29 @@ TEST_F(ObjectTest, DescriptorCompare) { Class* klass2 = linker->FindClass("LProtoCompare2;", class_loader_2.get()); ASSERT_TRUE(klass2 != NULL); - AbstractMethod* m1_1 = klass1->GetVirtualMethod(0); + ArtMethod* m1_1 = klass1->GetVirtualMethod(0); MethodHelper mh(m1_1); EXPECT_STREQ(mh.GetName(), "m1"); - AbstractMethod* m2_1 = klass1->GetVirtualMethod(1); + ArtMethod* m2_1 = klass1->GetVirtualMethod(1); mh.ChangeMethod(m2_1); EXPECT_STREQ(mh.GetName(), "m2"); - AbstractMethod* m3_1 = klass1->GetVirtualMethod(2); + ArtMethod* m3_1 = klass1->GetVirtualMethod(2); mh.ChangeMethod(m3_1); EXPECT_STREQ(mh.GetName(), "m3"); - AbstractMethod* m4_1 = klass1->GetVirtualMethod(3); + ArtMethod* m4_1 = klass1->GetVirtualMethod(3); mh.ChangeMethod(m4_1); EXPECT_STREQ(mh.GetName(), "m4"); - AbstractMethod* m1_2 = klass2->GetVirtualMethod(0); + ArtMethod* m1_2 = klass2->GetVirtualMethod(0); mh.ChangeMethod(m1_2); EXPECT_STREQ(mh.GetName(), "m1"); - AbstractMethod* m2_2 = klass2->GetVirtualMethod(1); + ArtMethod* m2_2 = klass2->GetVirtualMethod(1); mh.ChangeMethod(m2_2); EXPECT_STREQ(mh.GetName(), "m2"); - AbstractMethod* m3_2 = klass2->GetVirtualMethod(2); + ArtMethod* m3_2 = klass2->GetVirtualMethod(2); mh.ChangeMethod(m3_2); EXPECT_STREQ(mh.GetName(), "m3"); - AbstractMethod* m4_2 = klass2->GetVirtualMethod(3); + ArtMethod* m4_2 = klass2->GetVirtualMethod(3); mh.ChangeMethod(m4_2); EXPECT_STREQ(mh.GetName(), "m4"); @@ -593,8 +593,8 @@ TEST_F(ObjectTest, FindInstanceField) { EXPECT_TRUE(c->FindInstanceField("Count", "I") == NULL); // Right name and type. - Field* f1 = c->FindDeclaredInstanceField("count", "I"); - Field* f2 = c->FindInstanceField("count", "I"); + ArtField* f1 = c->FindDeclaredInstanceField("count", "I"); + ArtField* f2 = c->FindInstanceField("count", "I"); EXPECT_TRUE(f1 != NULL); EXPECT_TRUE(f2 != NULL); EXPECT_EQ(f1, f2); @@ -626,8 +626,8 @@ TEST_F(ObjectTest, FindStaticField) { EXPECT_TRUE(c->FindStaticField("cASE_INSENSITIVE_ORDER", "Ljava/util/Comparator;") == NULL); // Right name and type. - Field* f1 = c->FindDeclaredStaticField("CASE_INSENSITIVE_ORDER", "Ljava/util/Comparator;"); - Field* f2 = c->FindStaticField("CASE_INSENSITIVE_ORDER", "Ljava/util/Comparator;"); + ArtField* f1 = c->FindDeclaredStaticField("CASE_INSENSITIVE_ORDER", "Ljava/util/Comparator;"); + ArtField* f2 = c->FindStaticField("CASE_INSENSITIVE_ORDER", "Ljava/util/Comparator;"); EXPECT_TRUE(f1 != NULL); EXPECT_TRUE(f2 != NULL); EXPECT_EQ(f1, f2); diff --git a/runtime/mirror/throwable.cc b/runtime/mirror/throwable.cc index 78b76dc6ef..961f6deed3 100644 --- a/runtime/mirror/throwable.cc +++ b/runtime/mirror/throwable.cc @@ -16,7 +16,7 @@ #include "throwable.h" -#include "abstract_method-inl.h" +#include "art_method-inl.h" #include "class-inl.h" #include "dex_file-inl.h" #include "gc/accounting/card_table-inl.h" @@ -65,7 +65,7 @@ std::string Throwable::Dump() const { IntArray* pc_trace = down_cast(method_trace->Get(depth)); MethodHelper mh; for (int32_t i = 0; i < depth; ++i) { - AbstractMethod* method = down_cast(method_trace->Get(i)); + ArtMethod* method = down_cast(method_trace->Get(i)); mh.ChangeMethod(method); uint32_t dex_pc = pc_trace->Get(i); int32_t line_number = mh.GetLineNumFromDexPC(dex_pc); diff --git a/runtime/monitor.cc b/runtime/monitor.cc index 09a952b3cf..48c05692b4 100644 --- a/runtime/monitor.cc +++ b/runtime/monitor.cc @@ -23,7 +23,7 @@ #include "class_linker.h" #include "dex_file-inl.h" #include "dex_instruction.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" @@ -204,7 +204,7 @@ void Monitor::Lock(Thread* self) { uint64_t waitStart = 0; uint64_t waitEnd = 0; uint32_t wait_threshold = lock_profiling_threshold_; - const mirror::AbstractMethod* current_locking_method = NULL; + const mirror::ArtMethod* current_locking_method = NULL; uint32_t current_locking_dex_pc = 0; { ScopedThreadStateChange tsc(self, kBlocked); @@ -433,7 +433,7 @@ void Monitor::WaitWithLock(Thread* self, int64_t ms, int32_t ns, int prev_lock_count = lock_count_; lock_count_ = 0; owner_ = NULL; - const mirror::AbstractMethod* saved_method = locking_method_; + const mirror::ArtMethod* saved_method = locking_method_; locking_method_ = NULL; uintptr_t saved_dex_pc = locking_dex_pc_; locking_dex_pc_ = 0; @@ -888,7 +888,7 @@ mirror::Object* Monitor::GetContendedMonitor(Thread* thread) { void Monitor::VisitLocks(StackVisitor* stack_visitor, void (*callback)(mirror::Object*, void*), void* callback_context) { - mirror::AbstractMethod* m = stack_visitor->GetMethod(); + mirror::ArtMethod* m = stack_visitor->GetMethod(); CHECK(m != NULL); // Native methods are an easy special case. @@ -948,7 +948,7 @@ void Monitor::VisitLocks(StackVisitor* stack_visitor, void (*callback)(mirror::O } } -void Monitor::TranslateLocation(const mirror::AbstractMethod* method, uint32_t dex_pc, +void Monitor::TranslateLocation(const mirror::ArtMethod* method, uint32_t dex_pc, const char*& source_file, uint32_t& line_number) const { // If method is null, location is unknown if (method == NULL) { diff --git a/runtime/monitor.h b/runtime/monitor.h index 3b06217374..02c10a7a10 100644 --- a/runtime/monitor.h +++ b/runtime/monitor.h @@ -56,8 +56,8 @@ namespace art { #define LW_LOCK_OWNER(x) (((x) >> LW_LOCK_OWNER_SHIFT) & LW_LOCK_OWNER_MASK) namespace mirror { -class AbstractMethod; -class Object; + class ArtMethod; + class Object; } // namespace mirror class Thread; class StackVisitor; @@ -141,7 +141,7 @@ class Monitor { SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Translates the provided method and pc into its declaring class' source file and line number. - void TranslateLocation(const mirror::AbstractMethod* method, uint32_t pc, + void TranslateLocation(const mirror::ArtMethod* method, uint32_t pc, const char*& source_file, uint32_t& line_number) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); @@ -165,7 +165,7 @@ class Monitor { // Method and dex pc where the lock owner acquired the lock, used when lock // sampling is enabled. locking_method_ may be null if the lock is currently // unlocked, or if the lock is acquired by the system when the stack is empty. - const mirror::AbstractMethod* locking_method_ GUARDED_BY(monitor_lock_); + const mirror::ArtMethod* locking_method_ GUARDED_BY(monitor_lock_); uint32_t locking_dex_pc_ GUARDED_BY(monitor_lock_); friend class MonitorInfo; diff --git a/runtime/monitor_android.cc b/runtime/monitor_android.cc index 9265cd649d..8efa0721e8 100644 --- a/runtime/monitor_android.cc +++ b/runtime/monitor_android.cc @@ -78,7 +78,7 @@ void Monitor::LogContentionEvent(Thread* self, uint32_t wait_ms, uint32_t sample // Emit the source code file name, <= 37 bytes. uint32_t pc; - mirror::AbstractMethod* m = self->GetCurrentMethod(&pc); + mirror::ArtMethod* m = self->GetCurrentMethod(&pc); const char* filename; uint32_t line_number; TranslateLocation(m, pc, filename, line_number); diff --git a/runtime/native/dalvik_system_VMStack.cc b/runtime/native/dalvik_system_VMStack.cc index 1a80d6286b..eaf67b8f02 100644 --- a/runtime/native/dalvik_system_VMStack.cc +++ b/runtime/native/dalvik_system_VMStack.cc @@ -16,7 +16,7 @@ #include "jni_internal.h" #include "nth_caller_visitor.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/class_loader.h" #include "mirror/object-inl.h" diff --git a/runtime/native/java_lang_reflect_Constructor.cc b/runtime/native/java_lang_reflect_Constructor.cc index 918021748b..85556ac16e 100644 --- a/runtime/native/java_lang_reflect_Constructor.cc +++ b/runtime/native/java_lang_reflect_Constructor.cc @@ -16,13 +16,14 @@ #include "class_linker.h" #include "jni_internal.h" +#include "mirror/art_method.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" -#include "mirror/abstract_method.h" -#include "mirror/abstract_method-inl.h" #include "mirror/object-inl.h" #include "object_utils.h" #include "reflection.h" #include "scoped_thread_state_change.h" +#include "well_known_classes.h" namespace art { @@ -35,7 +36,10 @@ namespace art { */ static jobject Constructor_newInstance(JNIEnv* env, jobject javaMethod, jobjectArray javaArgs) { ScopedObjectAccess soa(env); - mirror::AbstractMethod* m = soa.Decode(javaMethod)->AsMethod(); + jobject art_method = soa.Env()->GetObjectField( + javaMethod, WellKnownClasses::java_lang_reflect_AbstractMethod_artMethod); + + mirror::ArtMethod* m = soa.Decode(art_method)->AsArtMethod(); mirror::Class* c = m->GetDeclaringClass(); if (UNLIKELY(c->IsAbstract())) { ThrowLocation throw_location = soa.Self()->GetCurrentLocationForThrow(); diff --git a/runtime/native/java_lang_reflect_Field.cc b/runtime/native/java_lang_reflect_Field.cc index b0daa916c6..00f89b65ea 100644 --- a/runtime/native/java_lang_reflect_Field.cc +++ b/runtime/native/java_lang_reflect_Field.cc @@ -19,16 +19,15 @@ #include "common_throws.h" #include "dex_file-inl.h" #include "jni_internal.h" +#include "mirror/art_field-inl.h" #include "mirror/class-inl.h" -#include "mirror/field.h" -#include "mirror/field-inl.h" #include "object_utils.h" #include "reflection.h" #include "scoped_thread_state_change.h" namespace art { -static bool GetFieldValue(const ScopedObjectAccess& soa, mirror::Object* o, mirror::Field* f, +static bool GetFieldValue(const ScopedObjectAccess& soa, mirror::Object* o, mirror::ArtField* f, JValue& value, bool allow_references) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { DCHECK_EQ(value.GetJ(), 0LL); @@ -78,7 +77,7 @@ static bool GetFieldValue(const ScopedObjectAccess& soa, mirror::Object* o, mirr return false; } -static bool CheckReceiver(const ScopedObjectAccess& soa, jobject j_rcvr, mirror::Field* f, +static bool CheckReceiver(const ScopedObjectAccess& soa, jobject j_rcvr, mirror::ArtField* f, mirror::Object*& class_or_rcvr) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { if (f->IsStatic()) { @@ -96,7 +95,7 @@ static bool CheckReceiver(const ScopedObjectAccess& soa, jobject j_rcvr, mirror: static jobject Field_get(JNIEnv* env, jobject javaField, jobject javaObj) { ScopedObjectAccess soa(env); - mirror::Field* f = soa.DecodeField(env->FromReflectedField(javaField)); + mirror::ArtField* f = soa.DecodeField(env->FromReflectedField(javaField)); mirror::Object* o = NULL; if (!CheckReceiver(soa, javaObj, f, o)) { return NULL; @@ -111,9 +110,10 @@ static jobject Field_get(JNIEnv* env, jobject javaField, jobject javaObj) { soa.AddLocalReference(BoxPrimitive(FieldHelper(f).GetTypeAsPrimitiveType(), value)); } -static JValue GetPrimitiveField(JNIEnv* env, jobject javaField, jobject javaObj, char dst_descriptor) { +static JValue GetPrimitiveField(JNIEnv* env, jobject javaField, jobject javaObj, + char dst_descriptor) { ScopedObjectAccess soa(env); - mirror::Field* f = soa.DecodeField(env->FromReflectedField(javaField)); + mirror::ArtField* f = soa.DecodeField(env->FromReflectedField(javaField)); mirror::Object* o = NULL; if (!CheckReceiver(soa, javaObj, f, o)) { return JValue(); @@ -127,7 +127,8 @@ static JValue GetPrimitiveField(JNIEnv* env, jobject javaField, jobject javaObj, // Widen it if necessary (and possible). JValue wide_value; - mirror::Class* dst_type = Runtime::Current()->GetClassLinker()->FindPrimitiveClass(dst_descriptor); + mirror::Class* dst_type = + Runtime::Current()->GetClassLinker()->FindPrimitiveClass(dst_descriptor); if (!ConvertPrimitiveValue(NULL, false, FieldHelper(f).GetTypeAsPrimitiveType(), dst_type->GetPrimitiveType(), field_value, wide_value)) { return JValue(); @@ -167,7 +168,7 @@ static jshort Field_getShort(JNIEnv* env, jobject javaField, jobject javaObj) { return GetPrimitiveField(env, javaField, javaObj, 'S').GetS(); } -static void SetFieldValue(mirror::Object* o, mirror::Field* f, const JValue& new_value, +static void SetFieldValue(mirror::Object* o, mirror::ArtField* f, const JValue& new_value, bool allow_references) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { if (!Runtime::Current()->GetClassLinker()->EnsureInitialized(f->GetDeclaringClass(), @@ -221,7 +222,7 @@ static void SetFieldValue(mirror::Object* o, mirror::Field* f, const JValue& new static void Field_set(JNIEnv* env, jobject javaField, jobject javaObj, jobject javaValue) { ScopedObjectAccess soa(env); - mirror::Field* f = soa.DecodeField(env->FromReflectedField(javaField)); + mirror::ArtField* f = soa.DecodeField(env->FromReflectedField(javaField)); // Unbox the value, if necessary. mirror::Object* boxed_value = soa.Decode(javaValue); @@ -242,7 +243,7 @@ static void Field_set(JNIEnv* env, jobject javaField, jobject javaObj, jobject j static void SetPrimitiveField(JNIEnv* env, jobject javaField, jobject javaObj, char src_descriptor, const JValue& new_value) { ScopedObjectAccess soa(env); - mirror::Field* f = soa.DecodeField(env->FromReflectedField(javaField)); + mirror::ArtField* f = soa.DecodeField(env->FromReflectedField(javaField)); mirror::Object* o = NULL; if (!CheckReceiver(soa, javaObj, f, o)) { return; diff --git a/runtime/native/java_lang_reflect_Method.cc b/runtime/native/java_lang_reflect_Method.cc index 14dc6a44ee..d29de3debe 100644 --- a/runtime/native/java_lang_reflect_Method.cc +++ b/runtime/native/java_lang_reflect_Method.cc @@ -16,26 +16,31 @@ #include "class_linker.h" #include "jni_internal.h" +#include "mirror/art_method.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" -#include "mirror/abstract_method.h" -#include "mirror/abstract_method-inl.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" #include "mirror/proxy.h" #include "object_utils.h" #include "reflection.h" #include "scoped_thread_state_change.h" +#include "well_known_classes.h" namespace art { -static jobject Method_invoke(JNIEnv* env, jobject javaMethod, jobject javaReceiver, jobject javaArgs) { +static jobject Method_invoke(JNIEnv* env, + jobject javaMethod, jobject javaReceiver, jobject javaArgs) { ScopedObjectAccess soa(env); return InvokeMethod(soa, javaMethod, javaReceiver, javaArgs); } static jobject Method_getExceptionTypesNative(JNIEnv* env, jobject javaMethod) { ScopedObjectAccess soa(env); - mirror::AbstractMethod* proxy_method = soa.Decode(javaMethod)->AsMethod(); + jobject art_method = soa.Env()->GetObjectField( + javaMethod, WellKnownClasses::java_lang_reflect_AbstractMethod_artMethod); + + mirror::ArtMethod* proxy_method = soa.Decode(art_method)->AsArtMethod(); CHECK(proxy_method->GetDeclaringClass()->IsProxyClass()); mirror::SynthesizedProxyClass* proxy_class = down_cast(proxy_method->GetDeclaringClass()); @@ -48,20 +53,14 @@ static jobject Method_getExceptionTypesNative(JNIEnv* env, jobject javaMethod) { } } CHECK_NE(throws_index, -1); - mirror::ObjectArray* declared_exceptions = proxy_class->GetThrows()->Get(throws_index); + mirror::ObjectArray* declared_exceptions = + proxy_class->GetThrows()->Get(throws_index); return soa.AddLocalReference(declared_exceptions->Clone(soa.Self())); } -static jobject Method_findOverriddenMethodNative(JNIEnv* env, jobject javaMethod) { - ScopedObjectAccess soa(env); - mirror::AbstractMethod* method = soa.Decode(javaMethod)->AsMethod(); - return soa.AddLocalReference(method->FindOverriddenMethod()); -} - static JNINativeMethod gMethods[] = { NATIVE_METHOD(Method, invoke, "(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;"), NATIVE_METHOD(Method, getExceptionTypesNative, "()[Ljava/lang/Class;"), - NATIVE_METHOD(Method, findOverriddenMethodNative, "()Ljava/lang/reflect/Method;"), }; void register_java_lang_reflect_Method(JNIEnv* env) { diff --git a/runtime/native/java_lang_reflect_Proxy.cc b/runtime/native/java_lang_reflect_Proxy.cc index 547ce7b38d..a92823a85d 100644 --- a/runtime/native/java_lang_reflect_Proxy.cc +++ b/runtime/native/java_lang_reflect_Proxy.cc @@ -31,8 +31,8 @@ static jclass Proxy_generateProxy(JNIEnv* env, jclass, jstring javaName, mirror::ObjectArray* interfaces = soa.Decode*>(javaInterfaces); mirror::ClassLoader* loader = soa.Decode(javaLoader); - mirror::ObjectArray* methods = - soa.Decode*>(javaMethods); + mirror::ObjectArray* methods = + soa.Decode*>(javaMethods); mirror::ObjectArray >* throws = soa.Decode >*>(javaThrows); ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); @@ -41,7 +41,7 @@ static jclass Proxy_generateProxy(JNIEnv* env, jclass, jstring javaName, } static JNINativeMethod gMethods[] = { - NATIVE_METHOD(Proxy, generateProxy, "(Ljava/lang/String;[Ljava/lang/Class;Ljava/lang/ClassLoader;[Ljava/lang/reflect/Method;[[Ljava/lang/Class;)Ljava/lang/Class;"), + NATIVE_METHOD(Proxy, generateProxy, "(Ljava/lang/String;[Ljava/lang/Class;Ljava/lang/ClassLoader;[Ljava/lang/reflect/ArtMethod;[[Ljava/lang/Class;)Ljava/lang/Class;"), }; void register_java_lang_reflect_Proxy(JNIEnv* env) { diff --git a/runtime/nth_caller_visitor.h b/runtime/nth_caller_visitor.h index e3593d805d..794878a08e 100644 --- a/runtime/nth_caller_visitor.h +++ b/runtime/nth_caller_visitor.h @@ -17,7 +17,7 @@ #ifndef ART_RUNTIME_NTH_CALLER_VISITOR_H_ #define ART_RUNTIME_NTH_CALLER_VISITOR_H_ -#include "mirror/abstract_method.h" +#include "mirror/art_method.h" #include "locks.h" #include "stack.h" @@ -31,7 +31,7 @@ struct NthCallerVisitor : public StackVisitor { count(0), caller(NULL) {} bool VisitFrame() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* m = GetMethod(); + mirror::ArtMethod* m = GetMethod(); bool do_count = false; if (m == NULL || m->IsRuntimeMethod()) { // Upcall. @@ -53,7 +53,7 @@ struct NthCallerVisitor : public StackVisitor { const size_t n; const bool include_runtime_and_upcalls_; size_t count; - mirror::AbstractMethod* caller; + mirror::ArtMethod* caller; }; } // namespace art diff --git a/runtime/oat_file.cc b/runtime/oat_file.cc index 93e98ad894..1f34317d26 100644 --- a/runtime/oat_file.cc +++ b/runtime/oat_file.cc @@ -22,9 +22,9 @@ #include "base/unix_file/fd_file.h" #include "elf_file.h" #include "oat.h" +#include "mirror/art_method.h" +#include "mirror/art_method-inl.h" #include "mirror/class.h" -#include "mirror/abstract_method.h" -#include "mirror/abstract_method-inl.h" #include "mirror/object-inl.h" #include "os.h" #include "utils.h" @@ -453,7 +453,7 @@ uint32_t OatFile::OatMethod::GetCodeSize() const { #endif } -void OatFile::OatMethod::LinkMethod(mirror::AbstractMethod* method) const { +void OatFile::OatMethod::LinkMethod(mirror::ArtMethod* method) const { CHECK(method != NULL); method->SetEntryPointFromCompiledCode(GetCode()); method->SetFrameSizeInBytes(frame_size_in_bytes_); diff --git a/runtime/oat_file.h b/runtime/oat_file.h index 650301465b..325ebb2914 100644 --- a/runtime/oat_file.h +++ b/runtime/oat_file.h @@ -23,7 +23,7 @@ #include "dex_file.h" #include "invoke_type.h" #include "mem_map.h" -#include "mirror/abstract_method.h" +#include "mirror/art_method.h" #include "oat.h" #include "os.h" @@ -70,7 +70,7 @@ class OatFile { class OatMethod { public: - void LinkMethod(mirror::AbstractMethod* method) const; + void LinkMethod(mirror::ArtMethod* method) const; uint32_t GetCodeOffset() const { return code_offset_; diff --git a/runtime/oat_test.cc b/runtime/oat_test.cc index 68595c896d..74b5da9eff 100644 --- a/runtime/oat_test.cc +++ b/runtime/oat_test.cc @@ -15,7 +15,7 @@ */ #include "compiler/oat_writer.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/object_array-inl.h" #include "mirror/object-inl.h" @@ -28,7 +28,7 @@ namespace art { class OatTest : public CommonTest { protected: - void CheckMethod(mirror::AbstractMethod* method, + void CheckMethod(mirror::ArtMethod* method, const OatFile::OatMethod& oat_method, const DexFile* dex_file) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { diff --git a/runtime/object_utils.h b/runtime/object_utils.h index 3639a80e77..29102437a2 100644 --- a/runtime/object_utils.h +++ b/runtime/object_utils.h @@ -20,10 +20,10 @@ #include "class_linker-inl.h" #include "dex_file.h" #include "monitor.h" -#include "mirror/abstract_method.h" +#include "mirror/art_field.h" +#include "mirror/art_method.h" #include "mirror/class.h" #include "mirror/dex_cache.h" -#include "mirror/field.h" #include "mirror/iftable.h" #include "mirror/string.h" @@ -256,11 +256,11 @@ class ClassHelper { class FieldHelper { public: FieldHelper() : class_linker_(NULL), dex_cache_(NULL), dex_file_(NULL), field_(NULL) {} - explicit FieldHelper(const mirror::Field* f) : class_linker_(NULL), dex_cache_(NULL), dex_file_(NULL), field_(f) {} - FieldHelper(const mirror::Field* f, ClassLinker* l) + explicit FieldHelper(const mirror::ArtField* f) : class_linker_(NULL), dex_cache_(NULL), dex_file_(NULL), field_(f) {} + FieldHelper(const mirror::ArtField* f, ClassLinker* l) : class_linker_(l), dex_cache_(NULL), dex_file_(NULL), field_(f) {} - void ChangeField(const mirror::Field* new_f) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + void ChangeField(const mirror::ArtField* new_f) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { DCHECK(new_f != NULL); if (dex_cache_ != NULL) { mirror::DexCache* new_f_dex_cache = new_f->GetDeclaringClass()->GetDexCache(); @@ -366,7 +366,7 @@ class FieldHelper { ClassLinker* class_linker_; mirror::DexCache* dex_cache_; const DexFile* dex_file_; - const mirror::Field* field_; + const mirror::ArtField* field_; std::string declaring_class_descriptor_; DISALLOW_COPY_AND_ASSIGN(FieldHelper); @@ -378,21 +378,21 @@ class MethodHelper { : class_linker_(NULL), dex_cache_(NULL), dex_file_(NULL), method_(NULL), shorty_(NULL), shorty_len_(0) {} - explicit MethodHelper(const mirror::AbstractMethod* m) + explicit MethodHelper(const mirror::ArtMethod* m) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) : class_linker_(NULL), dex_cache_(NULL), dex_file_(NULL), method_(NULL), shorty_(NULL), shorty_len_(0) { SetMethod(m); } - MethodHelper(const mirror::AbstractMethod* m, ClassLinker* l) + MethodHelper(const mirror::ArtMethod* m, ClassLinker* l) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) : class_linker_(l), dex_cache_(NULL), dex_file_(NULL), method_(NULL), shorty_(NULL), shorty_len_(0) { SetMethod(m); } - void ChangeMethod(mirror::AbstractMethod* new_m) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + void ChangeMethod(mirror::ArtMethod* new_m) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { DCHECK(new_m != NULL); if (dex_cache_ != NULL) { mirror::Class* klass = new_m->GetDeclaringClass(); @@ -411,7 +411,7 @@ class MethodHelper { shorty_ = NULL; } - const mirror::AbstractMethod* GetMethod() const { + const mirror::ArtMethod* GetMethod() const { return method_; } @@ -653,11 +653,11 @@ class MethodHelper { private: // Set the method_ field, for proxy methods looking up the interface method via the resolved // methods table. - void SetMethod(const mirror::AbstractMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + void SetMethod(const mirror::ArtMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { if (method != NULL) { mirror::Class* klass = method->GetDeclaringClass(); if (UNLIKELY(klass->IsProxyClass())) { - mirror::AbstractMethod* interface_method = + mirror::ArtMethod* interface_method = method->GetDexCacheResolvedMethods()->Get(method->GetDexMethodIndex()); DCHECK(interface_method != NULL); DCHECK(interface_method == GetClassLinker()->FindMethodForProxy(klass, method)); @@ -679,7 +679,7 @@ class MethodHelper { ClassLinker* class_linker_; mirror::DexCache* dex_cache_; const DexFile* dex_file_; - const mirror::AbstractMethod* method_; + const mirror::ArtMethod* method_; const char* shorty_; uint32_t shorty_len_; diff --git a/runtime/reflection.cc b/runtime/reflection.cc index 8e478ff969..3e58b4bd94 100644 --- a/runtime/reflection.cc +++ b/runtime/reflection.cc @@ -21,11 +21,10 @@ #include "dex_file-inl.h" #include "invoke_arg_array_builder.h" #include "jni_internal.h" -#include "mirror/abstract_method.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_field-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class.h" #include "mirror/class-inl.h" -#include "mirror/field-inl.h" #include "mirror/object_array.h" #include "mirror/object_array-inl.h" #include "object_utils.h" @@ -37,7 +36,7 @@ namespace art { jobject InvokeMethod(const ScopedObjectAccess& soa, jobject javaMethod, jobject javaReceiver, jobject javaArgs) { jmethodID mid = soa.Env()->FromReflectedMethod(javaMethod); - mirror::AbstractMethod* m = soa.DecodeMethod(mid); + mirror::ArtMethod* m = soa.DecodeMethod(mid); mirror::Class* declaring_class = m->GetDeclaringClass(); if (!Runtime::Current()->GetClassLinker()->EnsureInitialized(declaring_class, true, true)) { @@ -267,7 +266,7 @@ mirror::Object* BoxPrimitive(Primitive::Type src_class, const JValue& value) { return result.GetL(); } -static std::string UnboxingFailureKind(mirror::AbstractMethod* m, int index, mirror::Field* f) +static std::string UnboxingFailureKind(mirror::ArtMethod* m, int index, mirror::ArtField* f) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { if (m != NULL && index != -1) { ++index; // Humans count from 1. @@ -281,7 +280,7 @@ static std::string UnboxingFailureKind(mirror::AbstractMethod* m, int index, mir static bool UnboxPrimitive(const ThrowLocation* throw_location, mirror::Object* o, mirror::Class* dst_class, JValue& unboxed_value, - mirror::AbstractMethod* m, int index, mirror::Field* f) + mirror::ArtMethod* m, int index, mirror::ArtField* f) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { bool unbox_for_result = (f == NULL) && (index == -1); if (!dst_class->IsPrimitive()) { @@ -327,7 +326,7 @@ static bool UnboxPrimitive(const ThrowLocation* throw_location, mirror::Object* std::string src_descriptor(ClassHelper(o->GetClass()).GetDescriptor()); mirror::Class* src_class = NULL; ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); - mirror::Field* primitive_field = o->GetClass()->GetIFields()->Get(0); + mirror::ArtField* primitive_field = o->GetClass()->GetIFields()->Get(0); if (src_descriptor == "Ljava/lang/Boolean;") { src_class = class_linker->FindPrimitiveClass('Z'); boxed_value.SetZ(primitive_field->GetBoolean(o)); @@ -367,13 +366,13 @@ static bool UnboxPrimitive(const ThrowLocation* throw_location, mirror::Object* } bool UnboxPrimitiveForArgument(mirror::Object* o, mirror::Class* dst_class, JValue& unboxed_value, - mirror::AbstractMethod* m, size_t index) { + mirror::ArtMethod* m, size_t index) { CHECK(m != NULL); return UnboxPrimitive(NULL, o, dst_class, unboxed_value, m, index, NULL); } bool UnboxPrimitiveForField(mirror::Object* o, mirror::Class* dst_class, JValue& unboxed_value, - mirror::Field* f) { + mirror::ArtField* f) { CHECK(f != NULL); return UnboxPrimitive(NULL, o, dst_class, unboxed_value, NULL, -1, f); } diff --git a/runtime/reflection.h b/runtime/reflection.h index 56ab4712db..13c90af895 100644 --- a/runtime/reflection.h +++ b/runtime/reflection.h @@ -22,10 +22,10 @@ namespace art { namespace mirror { -class AbstractMethod; -class Class; -class Field; -class Object; + class ArtField; + class ArtMethod; + class Class; + class Object; } // namespace mirror union JValue; class ScopedObjectAccess; @@ -34,10 +34,10 @@ class ThrowLocation; mirror::Object* BoxPrimitive(Primitive::Type src_class, const JValue& value) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); bool UnboxPrimitiveForArgument(mirror::Object* o, mirror::Class* dst_class, JValue& unboxed_value, - mirror::AbstractMethod* m, size_t index) + mirror::ArtMethod* m, size_t index) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); bool UnboxPrimitiveForField(mirror::Object* o, mirror::Class* dst_class, JValue& unboxed_value, - mirror::Field* f) + mirror::ArtField* f) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); bool UnboxPrimitiveForResult(const ThrowLocation& throw_location, mirror::Object* o, mirror::Class* dst_class, JValue& unboxed_value) diff --git a/runtime/runtime.cc b/runtime/runtime.cc index 70d8816401..7b12870872 100644 --- a/runtime/runtime.cc +++ b/runtime/runtime.cc @@ -42,12 +42,11 @@ #include "intern_table.h" #include "invoke_arg_array_builder.h" #include "jni_internal.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_field-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/array.h" #include "mirror/class-inl.h" #include "mirror/class_loader.h" -#include "mirror/field.h" -#include "mirror/field-inl.h" #include "mirror/throwable.h" #include "monitor.h" #include "oat_file.h" @@ -654,7 +653,7 @@ static void CreateSystemClassLoader() { soa.Decode(WellKnownClasses::java_lang_ClassLoader); CHECK(Runtime::Current()->GetClassLinker()->EnsureInitialized(class_loader_class, true, true)); - mirror::AbstractMethod* getSystemClassLoader = + mirror::ArtMethod* getSystemClassLoader = class_loader_class->FindDirectMethod("getSystemClassLoader", "()Ljava/lang/ClassLoader;"); CHECK(getSystemClassLoader != NULL); @@ -669,8 +668,8 @@ static void CreateSystemClassLoader() { mirror::Class* thread_class = soa.Decode(WellKnownClasses::java_lang_Thread); CHECK(Runtime::Current()->GetClassLinker()->EnsureInitialized(thread_class, true, true)); - mirror::Field* contextClassLoader = thread_class->FindDeclaredInstanceField("contextClassLoader", - "Ljava/lang/ClassLoader;"); + mirror::ArtField* contextClassLoader = thread_class->FindDeclaredInstanceField("contextClassLoader", + "Ljava/lang/ClassLoader;"); CHECK(contextClassLoader != NULL); contextClassLoader->SetObject(soa.Self()->GetPeer(), class_loader); @@ -1125,11 +1124,11 @@ void Runtime::VisitRoots(RootVisitor* visitor, void* arg, bool only_dirty, bool VisitNonConcurrentRoots(visitor, arg); } -mirror::AbstractMethod* Runtime::CreateResolutionMethod() { - mirror::Class* method_class = mirror::AbstractMethod::GetMethodClass(); +mirror::ArtMethod* Runtime::CreateResolutionMethod() { + mirror::Class* method_class = mirror::ArtMethod::GetJavaLangReflectArtMethod(); Thread* self = Thread::Current(); - SirtRef - method(self, down_cast(method_class->AllocObject(self))); + SirtRef + method(self, down_cast(method_class->AllocObject(self))); method->SetDeclaringClass(method_class); // TODO: use a special method for resolution method saves method->SetDexMethodIndex(DexFile::kDexNoIndex16); @@ -1140,12 +1139,12 @@ mirror::AbstractMethod* Runtime::CreateResolutionMethod() { return method.get(); } -mirror::AbstractMethod* Runtime::CreateCalleeSaveMethod(InstructionSet instruction_set, +mirror::ArtMethod* Runtime::CreateCalleeSaveMethod(InstructionSet instruction_set, CalleeSaveType type) { - mirror::Class* method_class = mirror::AbstractMethod::GetMethodClass(); + mirror::Class* method_class = mirror::ArtMethod::GetJavaLangReflectArtMethod(); Thread* self = Thread::Current(); - SirtRef - method(self, down_cast(method_class->AllocObject(self))); + SirtRef + method(self, down_cast(method_class->AllocObject(self))); method->SetDeclaringClass(method_class); // TODO: use a special method for callee saves method->SetDexMethodIndex(DexFile::kDexNoIndex16); @@ -1205,7 +1204,7 @@ mirror::AbstractMethod* Runtime::CreateCalleeSaveMethod(InstructionSet instructi return method.get(); } -void Runtime::SetCalleeSaveMethod(mirror::AbstractMethod* method, CalleeSaveType type) { +void Runtime::SetCalleeSaveMethod(mirror::ArtMethod* method, CalleeSaveType type) { DCHECK_LT(static_cast(type), static_cast(kLastCalleeSaveType)); callee_save_methods_[type] = method; } diff --git a/runtime/runtime.h b/runtime/runtime.h index d67265a42d..b93ae9daeb 100644 --- a/runtime/runtime.h +++ b/runtime/runtime.h @@ -43,7 +43,7 @@ namespace gc { class Heap; } namespace mirror { - class AbstractMethod; + class ArtMethod; class ClassLoader; template class PrimitiveArray; typedef PrimitiveArray ByteArray; @@ -310,7 +310,7 @@ class Runtime { SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Returns a special method that calls into a trampoline for runtime method resolution - mirror::AbstractMethod* GetResolutionMethod() const { + mirror::ArtMethod* GetResolutionMethod() const { CHECK(HasResolutionMethod()); return resolution_method_; } @@ -319,11 +319,11 @@ class Runtime { return resolution_method_ != NULL; } - void SetResolutionMethod(mirror::AbstractMethod* method) { + void SetResolutionMethod(mirror::ArtMethod* method) { resolution_method_ = method; } - mirror::AbstractMethod* CreateResolutionMethod() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + mirror::ArtMethod* CreateResolutionMethod() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Returns a special method that describes all callee saves being spilled to the stack. enum CalleeSaveType { @@ -337,21 +337,21 @@ class Runtime { return callee_save_methods_[type] != NULL; } - mirror::AbstractMethod* GetCalleeSaveMethod(CalleeSaveType type) const { + mirror::ArtMethod* GetCalleeSaveMethod(CalleeSaveType type) const { DCHECK(HasCalleeSaveMethod(type)); return callee_save_methods_[type]; } - void SetCalleeSaveMethod(mirror::AbstractMethod* method, CalleeSaveType type); + void SetCalleeSaveMethod(mirror::ArtMethod* method, CalleeSaveType type); - mirror::AbstractMethod* CreateCalleeSaveMethod(InstructionSet instruction_set, + mirror::ArtMethod* CreateCalleeSaveMethod(InstructionSet instruction_set, CalleeSaveType type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::AbstractMethod* CreateRefOnlyCalleeSaveMethod(InstructionSet instruction_set) + mirror::ArtMethod* CreateRefOnlyCalleeSaveMethod(InstructionSet instruction_set) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::AbstractMethod* CreateRefAndArgsCalleeSaveMethod(InstructionSet instruction_set) + mirror::ArtMethod* CreateRefAndArgsCalleeSaveMethod(InstructionSet instruction_set) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); int32_t GetStat(int kind); @@ -451,9 +451,9 @@ class Runtime { mirror::Throwable* pre_allocated_OutOfMemoryError_; - mirror::AbstractMethod* callee_save_methods_[kLastCalleeSaveType]; + mirror::ArtMethod* callee_save_methods_[kLastCalleeSaveType]; - mirror::AbstractMethod* resolution_method_; + mirror::ArtMethod* resolution_method_; // As returned by ClassLoader.getSystemClassLoader() mirror::ClassLoader* system_class_loader_; diff --git a/runtime/scoped_thread_state_change.h b/runtime/scoped_thread_state_change.h index 965e6b85ac..5f649b117b 100644 --- a/runtime/scoped_thread_state_change.h +++ b/runtime/scoped_thread_state_change.h @@ -204,7 +204,7 @@ class ScopedObjectAccessUnchecked : public ScopedThreadStateChange { return down_cast(Self()->DecodeJObject(obj)); } - mirror::Field* DecodeField(jfieldID fid) const + mirror::ArtField* DecodeField(jfieldID fid) const LOCKS_EXCLUDED(JavaVMExt::globals_lock, JavaVMExt::weak_globals_lock) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { @@ -214,10 +214,10 @@ class ScopedObjectAccessUnchecked : public ScopedThreadStateChange { // TODO: we should make these unique weak globals if Field instances can ever move. UNIMPLEMENTED(WARNING); #endif - return reinterpret_cast(fid); + return reinterpret_cast(fid); } - jfieldID EncodeField(mirror::Field* field) const + jfieldID EncodeField(mirror::ArtField* field) const LOCKS_EXCLUDED(JavaVMExt::globals_lock, JavaVMExt::weak_globals_lock) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { @@ -229,7 +229,7 @@ class ScopedObjectAccessUnchecked : public ScopedThreadStateChange { return reinterpret_cast(field); } - mirror::AbstractMethod* DecodeMethod(jmethodID mid) const + mirror::ArtMethod* DecodeMethod(jmethodID mid) const LOCKS_EXCLUDED(JavaVMExt::globals_lock, JavaVMExt::weak_globals_lock) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { @@ -239,10 +239,10 @@ class ScopedObjectAccessUnchecked : public ScopedThreadStateChange { // TODO: we should make these unique weak globals if Method instances can ever move. UNIMPLEMENTED(WARNING); #endif - return reinterpret_cast(mid); + return reinterpret_cast(mid); } - jmethodID EncodeMethod(mirror::AbstractMethod* method) const + jmethodID EncodeMethod(mirror::ArtMethod* method) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { Locks::mutator_lock_->AssertSharedHeld(Self()); DCHECK_EQ(thread_state_, kRunnable); // Don't work with raw objects in non-runnable states. diff --git a/runtime/stack.cc b/runtime/stack.cc index e1a752adb9..206bff3425 100644 --- a/runtime/stack.cc +++ b/runtime/stack.cc @@ -16,7 +16,7 @@ #include "stack.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/object.h" #include "mirror/object-inl.h" @@ -29,7 +29,7 @@ namespace art { mirror::Object* ShadowFrame::GetThisObject() const { - mirror::AbstractMethod* m = GetMethod(); + mirror::ArtMethod* m = GetMethod(); if (m->IsStatic()) { return NULL; } else if (m->IsNative()) { @@ -43,7 +43,7 @@ mirror::Object* ShadowFrame::GetThisObject() const { } mirror::Object* ShadowFrame::GetThisObject(uint16_t num_ins) const { - mirror::AbstractMethod* m = GetMethod(); + mirror::ArtMethod* m = GetMethod(); if (m->IsStatic()) { return NULL; } else { @@ -101,7 +101,7 @@ uint32_t StackVisitor::GetDexPc() const { } mirror::Object* StackVisitor::GetThisObject() const { - mirror::AbstractMethod* m = GetMethod(); + mirror::ArtMethod* m = GetMethod(); if (m->IsStatic()) { return NULL; } else if (m->IsNative()) { @@ -132,7 +132,7 @@ size_t StackVisitor::GetNativePcOffset() const { return GetMethod()->NativePcOffset(cur_quick_frame_pc_); } -uint32_t StackVisitor::GetVReg(mirror::AbstractMethod* m, uint16_t vreg, VRegKind kind) const { +uint32_t StackVisitor::GetVReg(mirror::ArtMethod* m, uint16_t vreg, VRegKind kind) const { if (cur_quick_frame_ != NULL) { DCHECK(context_ != NULL); // You can't reliably read registers without a context. DCHECK(m == GetMethod()); @@ -156,7 +156,7 @@ uint32_t StackVisitor::GetVReg(mirror::AbstractMethod* m, uint16_t vreg, VRegKin } } -void StackVisitor::SetVReg(mirror::AbstractMethod* m, uint16_t vreg, uint32_t new_value, +void StackVisitor::SetVReg(mirror::ArtMethod* m, uint16_t vreg, uint32_t new_value, VRegKind kind) { if (cur_quick_frame_ != NULL) { DCHECK(context_ != NULL); // You can't reliably write registers without a context. @@ -195,14 +195,14 @@ void StackVisitor::SetGPR(uint32_t reg, uintptr_t value) { } uintptr_t StackVisitor::GetReturnPc() const { - mirror::AbstractMethod** sp = GetCurrentQuickFrame(); + mirror::ArtMethod** sp = GetCurrentQuickFrame(); DCHECK(sp != NULL); byte* pc_addr = reinterpret_cast(sp) + GetMethod()->GetReturnPcOffsetInBytes(); return *reinterpret_cast(pc_addr); } void StackVisitor::SetReturnPc(uintptr_t new_ret_pc) { - mirror::AbstractMethod** sp = GetCurrentQuickFrame(); + mirror::ArtMethod** sp = GetCurrentQuickFrame(); CHECK(sp != NULL); byte* pc_addr = reinterpret_cast(sp) + GetMethod()->GetReturnPcOffsetInBytes(); *reinterpret_cast(pc_addr) = new_ret_pc; @@ -241,7 +241,7 @@ void StackVisitor::DescribeStack(Thread* thread) { std::string StackVisitor::DescribeLocation() const { std::string result("Visiting method '"); - mirror::AbstractMethod* m = GetMethod(); + mirror::ArtMethod* m = GetMethod(); if (m == NULL) { return "upcall"; } @@ -259,9 +259,8 @@ instrumentation::InstrumentationStackFrame StackVisitor::GetInstrumentationStack void StackVisitor::SanityCheckFrame() const { #ifndef NDEBUG - mirror::AbstractMethod* method = GetMethod(); - CHECK(method->GetClass() == mirror::AbstractMethod::GetMethodClass() || - method->GetClass() == mirror::AbstractMethod::GetConstructorClass()); + mirror::ArtMethod* method = GetMethod(); + CHECK(method->GetClass() == mirror::ArtMethod::GetJavaLangReflectArtMethod()); if (cur_quick_frame_ != NULL) { method->AssertPcIsWithinCode(cur_quick_frame_pc_); // Frame sanity. @@ -291,7 +290,7 @@ void StackVisitor::WalkStack(bool include_transitions) { if (cur_quick_frame_ != NULL) { // Handle quick stack frames. // Can't be both a shadow and a quick fragment. DCHECK(current_fragment->GetTopShadowFrame() == NULL); - mirror::AbstractMethod* method = *cur_quick_frame_; + mirror::ArtMethod* method = *cur_quick_frame_; while (method != NULL) { SanityCheckFrame(); bool should_continue = VisitFrame(); @@ -316,7 +315,7 @@ void StackVisitor::WalkStack(bool include_transitions) { if (GetMethod() == Runtime::Current()->GetCalleeSaveMethod(Runtime::kSaveAll)) { // Skip runtime save all callee frames which are used to deliver exceptions. } else if (instrumentation_frame.interpreter_entry_) { - mirror::AbstractMethod* callee = Runtime::Current()->GetCalleeSaveMethod(Runtime::kRefsAndArgs); + mirror::ArtMethod* callee = Runtime::Current()->GetCalleeSaveMethod(Runtime::kRefsAndArgs); CHECK_EQ(GetMethod(), callee) << "Expected: " << PrettyMethod(callee) << " Found: " << PrettyMethod(GetMethod()); } else if (instrumentation_frame.method_ != GetMethod()) { @@ -335,7 +334,7 @@ void StackVisitor::WalkStack(bool include_transitions) { } cur_quick_frame_pc_ = return_pc; byte* next_frame = reinterpret_cast(cur_quick_frame_) + frame_size; - cur_quick_frame_ = reinterpret_cast(next_frame); + cur_quick_frame_ = reinterpret_cast(next_frame); cur_depth_++; method = *cur_quick_frame_; } diff --git a/runtime/stack.h b/runtime/stack.h index 388e4014c1..8ecf8f0571 100644 --- a/runtime/stack.h +++ b/runtime/stack.h @@ -28,8 +28,8 @@ namespace art { namespace mirror { -class AbstractMethod; -class Object; + class ArtMethod; + class Object; } // namespace mirror class Context; @@ -66,7 +66,7 @@ class ShadowFrame { // Create ShadowFrame in heap for deoptimization. static ShadowFrame* Create(uint32_t num_vregs, ShadowFrame* link, - mirror::AbstractMethod* method, uint32_t dex_pc) { + mirror::ArtMethod* method, uint32_t dex_pc) { uint8_t* memory = new uint8_t[ComputeSize(num_vregs)]; ShadowFrame* sf = new (memory) ShadowFrame(num_vregs, link, method, dex_pc, true); return sf; @@ -74,7 +74,7 @@ class ShadowFrame { // Create ShadowFrame for interpreter using provided memory. static ShadowFrame* Create(uint32_t num_vregs, ShadowFrame* link, - mirror::AbstractMethod* method, uint32_t dex_pc, void* memory) { + mirror::ArtMethod* method, uint32_t dex_pc, void* memory) { ShadowFrame* sf = new (memory) ShadowFrame(num_vregs, link, method, dex_pc, true); return sf; } @@ -195,7 +195,7 @@ class ShadowFrame { } } - mirror::AbstractMethod* GetMethod() const { + mirror::ArtMethod* GetMethod() const { DCHECK_NE(method_, static_cast(NULL)); return method_; } @@ -206,7 +206,7 @@ class ShadowFrame { ThrowLocation GetCurrentLocationForThrow() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void SetMethod(mirror::AbstractMethod* method) { + void SetMethod(mirror::ArtMethod* method) { #if defined(ART_USE_PORTABLE_COMPILER) DCHECK_NE(method, static_cast(NULL)); method_ = method; @@ -248,7 +248,7 @@ class ShadowFrame { } private: - ShadowFrame(uint32_t num_vregs, ShadowFrame* link, mirror::AbstractMethod* method, + ShadowFrame(uint32_t num_vregs, ShadowFrame* link, mirror::ArtMethod* method, uint32_t dex_pc, bool has_reference_array) : number_of_vregs_(num_vregs), link_(link), method_(method), dex_pc_(dex_pc) { if (has_reference_array) { @@ -285,9 +285,9 @@ class ShadowFrame { ShadowFrame* link_; #if defined(ART_USE_PORTABLE_COMPILER) // TODO: make const in the portable case. - mirror::AbstractMethod* method_; + mirror::ArtMethod* method_; #else - mirror::AbstractMethod* const method_; + mirror::ArtMethod* const method_; #endif uint32_t dex_pc_; uint32_t vregs_[0]; @@ -323,11 +323,11 @@ class PACKED(4) ManagedStack { return link_; } - mirror::AbstractMethod** GetTopQuickFrame() const { + mirror::ArtMethod** GetTopQuickFrame() const { return top_quick_frame_; } - void SetTopQuickFrame(mirror::AbstractMethod** top) { + void SetTopQuickFrame(mirror::ArtMethod** top) { DCHECK(top_shadow_frame_ == NULL); top_quick_frame_ = top; } @@ -385,7 +385,7 @@ class PACKED(4) ManagedStack { private: ManagedStack* link_; ShadowFrame* top_shadow_frame_; - mirror::AbstractMethod** top_quick_frame_; + mirror::ArtMethod** top_quick_frame_; uintptr_t top_quick_frame_pc_; }; @@ -402,7 +402,7 @@ class StackVisitor { void WalkStack(bool include_transitions = false) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::AbstractMethod* GetMethod() const { + mirror::ArtMethod* GetMethod() const { if (cur_shadow_frame_ != NULL) { return cur_shadow_frame_->GetMethod(); } else if (cur_quick_frame_ != NULL) { @@ -450,16 +450,16 @@ class StackVisitor { return num_frames_; } - uint32_t GetVReg(mirror::AbstractMethod* m, uint16_t vreg, VRegKind kind) const + uint32_t GetVReg(mirror::ArtMethod* m, uint16_t vreg, VRegKind kind) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void SetVReg(mirror::AbstractMethod* m, uint16_t vreg, uint32_t new_value, VRegKind kind) + void SetVReg(mirror::ArtMethod* m, uint16_t vreg, uint32_t new_value, VRegKind kind) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); uintptr_t GetGPR(uint32_t reg) const; void SetGPR(uint32_t reg, uintptr_t value); - uint32_t GetVReg(mirror::AbstractMethod** cur_quick_frame, const DexFile::CodeItem* code_item, + uint32_t GetVReg(mirror::ArtMethod** cur_quick_frame, const DexFile::CodeItem* code_item, uint32_t core_spills, uint32_t fp_spills, size_t frame_size, uint16_t vreg) const { int offset = GetVRegOffset(code_item, core_spills, fp_spills, frame_size, vreg); @@ -533,7 +533,7 @@ class StackVisitor { return cur_quick_frame_pc_; } - mirror::AbstractMethod** GetCurrentQuickFrame() const { + mirror::ArtMethod** GetCurrentQuickFrame() const { return cur_quick_frame_; } @@ -542,7 +542,7 @@ class StackVisitor { } StackIndirectReferenceTable* GetCurrentSirt() const { - mirror::AbstractMethod** sp = GetCurrentQuickFrame(); + mirror::ArtMethod** sp = GetCurrentQuickFrame(); ++sp; // Skip Method*; SIRT comes next; return reinterpret_cast(sp); } @@ -560,7 +560,7 @@ class StackVisitor { Thread* const thread_; ShadowFrame* cur_shadow_frame_; - mirror::AbstractMethod** cur_quick_frame_; + mirror::ArtMethod** cur_quick_frame_; uintptr_t cur_quick_frame_pc_; // Lazily computed, number of frames in the stack. size_t num_frames_; diff --git a/runtime/thread.cc b/runtime/thread.cc index 07a003d330..7e3afb59a5 100644 --- a/runtime/thread.cc +++ b/runtime/thread.cc @@ -45,10 +45,10 @@ #include "gc/space/space.h" #include "invoke_arg_array_builder.h" #include "jni_internal.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_field-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/class_loader.h" -#include "mirror/field-inl.h" #include "mirror/object_array-inl.h" #include "mirror/stack_trace_element.h" #include "monitor.h" @@ -168,7 +168,7 @@ void* Thread::CreateCallback(void* arg) { // Invoke the 'run' method of our java.lang.Thread. mirror::Object* receiver = self->opeer_; jmethodID mid = WellKnownClasses::java_lang_Thread_run; - mirror::AbstractMethod* m = + mirror::ArtMethod* m = receiver->GetClass()->FindVirtualMethodForVirtualOrInterface(soa.DecodeMethod(mid)); JValue result; ArgArray arg_array(NULL, 0); @@ -183,7 +183,7 @@ void* Thread::CreateCallback(void* arg) { Thread* Thread::FromManagedThread(const ScopedObjectAccessUnchecked& soa, mirror::Object* thread_peer) { - mirror::Field* f = soa.DecodeField(WellKnownClasses::java_lang_Thread_nativePeer); + mirror::ArtField* f = soa.DecodeField(WellKnownClasses::java_lang_Thread_nativePeer); Thread* result = reinterpret_cast(static_cast(f->GetInt(thread_peer))); // Sanity check that if we have a result it is either suspended or we hold the thread_list_lock_ // to stop it from going away. @@ -488,7 +488,7 @@ void Thread::Dump(std::ostream& os) const { } mirror::String* Thread::GetThreadName(const ScopedObjectAccessUnchecked& soa) const { - mirror::Field* f = soa.DecodeField(WellKnownClasses::java_lang_Thread_name); + mirror::ArtField* f = soa.DecodeField(WellKnownClasses::java_lang_Thread_name); return (opeer_ != NULL) ? reinterpret_cast(f->GetObject(opeer_)) : NULL; } @@ -678,7 +678,7 @@ void Thread::DumpState(std::ostream& os, const Thread* thread, pid_t tid) { soa.DecodeField(WellKnownClasses::java_lang_Thread_group)->GetObject(thread->opeer_); if (thread_group != NULL) { - mirror::Field* group_name_field = + mirror::ArtField* group_name_field = soa.DecodeField(WellKnownClasses::java_lang_ThreadGroup_name); mirror::String* group_name_string = reinterpret_cast(group_name_field->GetObject(thread_group)); @@ -776,7 +776,7 @@ struct StackDumpVisitor : public StackVisitor { } bool VisitFrame() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* m = GetMethod(); + mirror::ArtMethod* m = GetMethod(); if (m->IsRuntimeMethod()) { return true; } @@ -831,7 +831,7 @@ struct StackDumpVisitor : public StackVisitor { const Thread* thread; const bool can_allocate; MethodHelper mh; - mirror::AbstractMethod* last_method; + mirror::ArtMethod* last_method; int last_line_number; int repetition_count; int frame_count; @@ -855,7 +855,7 @@ static bool ShouldShowNativeStack(const Thread* thread) // We don't just check kNative because native methods will be in state kSuspended if they're // calling back into the VM, or kBlocked if they're blocked on a monitor, or one of the // thread-startup states if it's early enough in their life cycle (http://b/7432159). - mirror::AbstractMethod* current_method = thread->GetCurrentMethod(NULL); + mirror::ArtMethod* current_method = thread->GetCurrentMethod(NULL); return current_method != NULL && current_method->IsNative(); } @@ -1238,7 +1238,7 @@ class CountStackDepthVisitor : public StackVisitor { // We want to skip frames up to and including the exception's constructor. // Note we also skip the frame if it doesn't have a method (namely the callee // save frame) - mirror::AbstractMethod* m = GetMethod(); + mirror::ArtMethod* m = GetMethod(); if (skipping_ && !m->IsRuntimeMethod() && !mirror::Throwable::GetJavaLangThrowable()->IsAssignableFrom(m->GetDeclaringClass())) { skipping_ = false; @@ -1313,7 +1313,7 @@ class BuildInternalStackTraceVisitor : public StackVisitor { skip_depth_--; return true; } - mirror::AbstractMethod* m = GetMethod(); + mirror::ArtMethod* m = GetMethod(); if (m->IsRuntimeMethod()) { return true; // Ignore runtime frames (in particular callee save). } @@ -1398,7 +1398,7 @@ jobjectArray Thread::InternalStackTraceToStackTraceElementArray(JNIEnv* env, job MethodHelper mh; for (int32_t i = 0; i < depth; ++i) { // Prepare parameters for StackTraceElement(String cls, String method, String file, int line) - mirror::AbstractMethod* method = down_cast(method_trace->Get(i)); + mirror::ArtMethod* method = down_cast(method_trace->Get(i)); mh.ChangeMethod(method); uint32_t dex_pc = pc_trace->Get(i); int32_t line_number = mh.GetLineNumFromDexPC(dex_pc); @@ -1472,7 +1472,7 @@ void Thread::ThrowNewWrappedException(const ThrowLocation& throw_location, DCHECK_EQ(this, Thread::Current()); // Ensure we don't forget arguments over object allocation. SirtRef saved_throw_this(this, throw_location.GetThis()); - SirtRef saved_throw_method(this, throw_location.GetMethod()); + SirtRef saved_throw_method(this, throw_location.GetMethod()); // Ignore the cause throw location. TODO: should we report this as a re-throw? SirtRef cause(this, GetException(NULL)); ClearException(); @@ -1520,7 +1520,7 @@ void Thread::ThrowNewWrappedException(const ThrowLocation& throw_location, signature = "(Ljava/lang/Throwable;)V"; } } - mirror::AbstractMethod* exception_init_method = + mirror::ArtMethod* exception_init_method = exception_class->FindDeclaredDirectMethod("", signature); CHECK(exception_init_method != NULL) << "No " << signature << " in " @@ -1740,7 +1740,7 @@ class CatchBlockStackVisitor : public StackVisitor { } bool VisitFrame() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* method = GetMethod(); + mirror::ArtMethod* method = GetMethod(); if (method == NULL) { // This is the upcall, we remember the frame and last pc so that we may long jump to them. handler_quick_frame_pc_ = GetCurrentQuickFramePc(); @@ -1764,7 +1764,7 @@ class CatchBlockStackVisitor : public StackVisitor { } } - bool HandleTryItems(mirror::AbstractMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + bool HandleTryItems(mirror::ArtMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { uint32_t dex_pc = DexFile::kDexNoIndex; if (method->IsNative()) { native_method_count_++; @@ -1783,7 +1783,7 @@ class CatchBlockStackVisitor : public StackVisitor { return true; // Continue stack walk. } - bool HandleDeoptimization(mirror::AbstractMethod* m) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + bool HandleDeoptimization(mirror::ArtMethod* m) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { MethodHelper mh(m); const DexFile::CodeItem* code_item = mh.GetCodeItem(); CHECK(code_item != NULL); @@ -1825,7 +1825,7 @@ class CatchBlockStackVisitor : public StackVisitor { } void DoLongJump() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* catch_method = *handler_quick_frame_; + mirror::ArtMethod* catch_method = *handler_quick_frame_; if (catch_method == NULL) { if (kDebugExceptionDelivery) { LOG(INFO) << "Handler is upcall"; @@ -1880,7 +1880,7 @@ class CatchBlockStackVisitor : public StackVisitor { // Location of the throw. const ThrowLocation& throw_location_; // Quick frame with found handler or last frame if no handler found. - mirror::AbstractMethod** handler_quick_frame_; + mirror::ArtMethod** handler_quick_frame_; // PC to branch to for the handler. uintptr_t handler_quick_frame_pc_; // Associated dex PC. @@ -1940,7 +1940,7 @@ struct CurrentMethodVisitor : public StackVisitor { SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) : StackVisitor(thread, context), this_object_(NULL), method_(NULL), dex_pc_(0) {} virtual bool VisitFrame() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* m = GetMethod(); + mirror::ArtMethod* m = GetMethod(); if (m->IsRuntimeMethod()) { // Continue if this is a runtime method. return true; @@ -1953,11 +1953,11 @@ struct CurrentMethodVisitor : public StackVisitor { return false; } mirror::Object* this_object_; - mirror::AbstractMethod* method_; + mirror::ArtMethod* method_; uint32_t dex_pc_; }; -mirror::AbstractMethod* Thread::GetCurrentMethod(uint32_t* dex_pc) const { +mirror::ArtMethod* Thread::GetCurrentMethod(uint32_t* dex_pc) const { CurrentMethodVisitor visitor(const_cast(this), NULL); visitor.WalkStack(false); if (dex_pc != NULL) { @@ -1996,7 +1996,7 @@ class ReferenceMapVisitor : public StackVisitor { } ShadowFrame* shadow_frame = GetCurrentShadowFrame(); if (shadow_frame != NULL) { - mirror::AbstractMethod* m = shadow_frame->GetMethod(); + mirror::ArtMethod* m = shadow_frame->GetMethod(); size_t num_regs = shadow_frame->NumberOfVRegs(); if (m->IsNative() || shadow_frame->HasReferenceArray()) { // SIRT for JNI or References for interpreter. @@ -2030,7 +2030,7 @@ class ReferenceMapVisitor : public StackVisitor { } } } else { - mirror::AbstractMethod* m = GetMethod(); + mirror::ArtMethod* m = GetMethod(); // Process register map (which native and runtime methods don't have) if (!m->IsNative() && !m->IsRuntimeMethod() && !m->IsProxyMethod()) { const uint8_t* native_gc_map = m->GetNativeGcMap(); @@ -2049,7 +2049,7 @@ class ReferenceMapVisitor : public StackVisitor { uint32_t fp_spills = m->GetFpSpillMask(); size_t frame_size = m->GetFrameSizeInBytes(); // For all dex registers in the bitmap - mirror::AbstractMethod** cur_quick_frame = GetCurrentQuickFrame(); + mirror::ArtMethod** cur_quick_frame = GetCurrentQuickFrame(); DCHECK(cur_quick_frame != NULL); for (size_t reg = 0; reg < num_regs; ++reg) { // Does this register hold a reference? @@ -2164,7 +2164,7 @@ void Thread::VerifyRoots(VerifyRootVisitor* visitor, void* arg) { if (this_object != NULL) { VerifyRootWrapperCallback(this_object, &wrapperArg); } - mirror::AbstractMethod* method = (*it).method_; + mirror::ArtMethod* method = (*it).method_; VerifyRootWrapperCallback(method, &wrapperArg); } } @@ -2199,7 +2199,7 @@ void Thread::VisitRoots(RootVisitor* visitor, void* arg) { if (this_object != NULL) { visitor(this_object, arg); } - mirror::AbstractMethod* method = (*it).method_; + mirror::ArtMethod* method = (*it).method_; visitor(method, arg); } } diff --git a/runtime/thread.h b/runtime/thread.h index 8b6771e60c..b9b93dd8f1 100644 --- a/runtime/thread.h +++ b/runtime/thread.h @@ -45,7 +45,7 @@ namespace art { namespace mirror { - class AbstractMethod; + class ArtMethod; class Array; class Class; class ClassLoader; @@ -318,13 +318,13 @@ class PACKED(4) Thread { long_jump_context_ = context; } - mirror::AbstractMethod* GetCurrentMethod(uint32_t* dex_pc) const + mirror::ArtMethod* GetCurrentMethod(uint32_t* dex_pc) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); ThrowLocation GetCurrentLocationForThrow() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void SetTopOfStack(void* stack, uintptr_t pc) { - mirror::AbstractMethod** top_method = reinterpret_cast(stack); + mirror::ArtMethod** top_method = reinterpret_cast(stack); managed_stack_.SetTopQuickFrame(top_method); managed_stack_.SetTopQuickFramePc(pc); } diff --git a/runtime/throw_location.cc b/runtime/throw_location.cc index 84d2c9b446..6d1ca1b4f0 100644 --- a/runtime/throw_location.cc +++ b/runtime/throw_location.cc @@ -16,7 +16,7 @@ #include "throw_location.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/object-inl.h" #include "object_utils.h" diff --git a/runtime/throw_location.h b/runtime/throw_location.h index b2cd4d5803..5da446e9c5 100644 --- a/runtime/throw_location.h +++ b/runtime/throw_location.h @@ -26,7 +26,7 @@ namespace art { namespace mirror { -class AbstractMethod; +class ArtMethod; class Object; } // mirror @@ -36,7 +36,7 @@ class PACKED(4) ThrowLocation { Clear(); } - ThrowLocation(mirror::Object* throw_this_object, mirror::AbstractMethod* throw_method, + ThrowLocation(mirror::Object* throw_this_object, mirror::ArtMethod* throw_method, uint32_t throw_dex_pc) : this_object_(throw_this_object), method_(throw_method), @@ -46,7 +46,7 @@ class PACKED(4) ThrowLocation { return this_object_; } - mirror::AbstractMethod* GetMethod() const { + mirror::ArtMethod* GetMethod() const { return method_; } @@ -68,7 +68,7 @@ class PACKED(4) ThrowLocation { // The 'this' reference of the throwing method. mirror::Object* this_object_; // The throwing method. - mirror::AbstractMethod* method_; + mirror::ArtMethod* method_; // The instruction within the throwing method. uint32_t dex_pc_; }; diff --git a/runtime/trace.cc b/runtime/trace.cc index 2bce70f7c1..84df6a9e8b 100644 --- a/runtime/trace.cc +++ b/runtime/trace.cc @@ -24,7 +24,7 @@ #include "debugger.h" #include "dex_file-inl.h" #include "instrumentation.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/dex_cache.h" #include "mirror/object_array-inl.h" @@ -98,15 +98,15 @@ ProfilerClockSource Trace::default_clock_source_ = kProfilerClockSourceWall; Trace* Trace::the_trace_ = NULL; -static mirror::AbstractMethod* DecodeTraceMethodId(uint32_t tmid) { - return reinterpret_cast(tmid & ~kTraceMethodActionMask); +static mirror::ArtMethod* DecodeTraceMethodId(uint32_t tmid) { + return reinterpret_cast(tmid & ~kTraceMethodActionMask); } static TraceAction DecodeTraceAction(uint32_t tmid) { return static_cast(tmid & kTraceMethodActionMask); } -static uint32_t EncodeTraceMethodAndAction(const mirror::AbstractMethod* method, +static uint32_t EncodeTraceMethodAndAction(const mirror::ArtMethod* method, TraceAction action) { uint32_t tmid = reinterpret_cast(method) | action; DCHECK_EQ(method, DecodeTraceMethodId(tmid)); @@ -311,7 +311,7 @@ static void DumpBuf(uint8_t* buf, size_t buf_size, ProfilerClockSource clock_sou while (ptr < end) { uint32_t tmid = ptr[2] | (ptr[3] << 8) | (ptr[4] << 16) | (ptr[5] << 24); - mirror::AbstractMethod* method = DecodeTraceMethodId(tmid); + mirror::ArtMethod* method = DecodeTraceMethodId(tmid); TraceAction action = DecodeTraceAction(tmid); LOG(INFO) << PrettyMethod(method) << " " << static_cast(action); ptr += GetRecordSize(clock_source); @@ -329,7 +329,7 @@ void Trace::FinishTracing() { Runtime::Current()->SetStatsEnabled(false); } - std::set visited_methods; + std::set visited_methods; GetVisitedMethods(final_offset, &visited_methods); std::ostringstream os; @@ -386,35 +386,35 @@ void Trace::FinishTracing() { } void Trace::DexPcMoved(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, uint32_t new_dex_pc) { + const mirror::ArtMethod* method, uint32_t new_dex_pc) { // We're not recorded to listen to this kind of event, so complain. LOG(ERROR) << "Unexpected dex PC event in tracing " << PrettyMethod(method) << " " << new_dex_pc; }; void Trace::MethodEntered(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, uint32_t dex_pc) { + const mirror::ArtMethod* method, uint32_t dex_pc) { LogMethodTraceEvent(thread, method, instrumentation::Instrumentation::kMethodEntered); } void Trace::MethodExited(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, uint32_t dex_pc, + const mirror::ArtMethod* method, uint32_t dex_pc, const JValue& return_value) { UNUSED(return_value); LogMethodTraceEvent(thread, method, instrumentation::Instrumentation::kMethodExited); } -void Trace::MethodUnwind(Thread* thread, const mirror::AbstractMethod* method, uint32_t dex_pc) { +void Trace::MethodUnwind(Thread* thread, const mirror::ArtMethod* method, uint32_t dex_pc) { LogMethodTraceEvent(thread, method, instrumentation::Instrumentation::kMethodUnwind); } void Trace::ExceptionCaught(Thread* thread, const ThrowLocation& throw_location, - mirror::AbstractMethod* catch_method, uint32_t catch_dex_pc, + mirror::ArtMethod* catch_method, uint32_t catch_dex_pc, mirror::Throwable* exception_object) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { LOG(ERROR) << "Unexpected exception caught event in tracing"; } -void Trace::LogMethodTraceEvent(Thread* thread, const mirror::AbstractMethod* method, +void Trace::LogMethodTraceEvent(Thread* thread, const mirror::ArtMethod* method, instrumentation::Instrumentation::InstrumentationEvent event) { // Advance cur_offset_ atomically. int32_t new_offset; @@ -473,24 +473,24 @@ void Trace::LogMethodTraceEvent(Thread* thread, const mirror::AbstractMethod* me } void Trace::GetVisitedMethods(size_t buf_size, - std::set* visited_methods) { + std::set* visited_methods) { uint8_t* ptr = buf_.get() + kTraceHeaderLength; uint8_t* end = buf_.get() + buf_size; while (ptr < end) { uint32_t tmid = ptr[2] | (ptr[3] << 8) | (ptr[4] << 16) | (ptr[5] << 24); - mirror::AbstractMethod* method = DecodeTraceMethodId(tmid); + mirror::ArtMethod* method = DecodeTraceMethodId(tmid); visited_methods->insert(method); ptr += GetRecordSize(clock_source_); } } void Trace::DumpMethodList(std::ostream& os, - const std::set& visited_methods) { - typedef std::set::const_iterator It; // TODO: C++0x auto + const std::set& visited_methods) { + typedef std::set::const_iterator It; // TODO: C++0x auto MethodHelper mh; for (It it = visited_methods.begin(); it != visited_methods.end(); ++it) { - mirror::AbstractMethod* method = *it; + mirror::ArtMethod* method = *it; mh.ChangeMethod(method); os << StringPrintf("%p\t%s\t%s\t%s\t%s\n", method, PrettyDescriptor(mh.GetDeclaringClassDescriptor()).c_str(), mh.GetName(), diff --git a/runtime/trace.h b/runtime/trace.h index bd9c140d26..ae583cae2d 100644 --- a/runtime/trace.h +++ b/runtime/trace.h @@ -31,7 +31,7 @@ namespace art { namespace mirror { -class AbstractMethod; + class ArtMethod; } // namespace mirror class Thread; @@ -63,19 +63,19 @@ class Trace : public instrumentation::InstrumentationListener { bool UseThreadCpuClock(); virtual void MethodEntered(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, uint32_t dex_pc) + const mirror::ArtMethod* method, uint32_t dex_pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); virtual void MethodExited(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, uint32_t dex_pc, + const mirror::ArtMethod* method, uint32_t dex_pc, const JValue& return_value) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - virtual void MethodUnwind(Thread* thread, const mirror::AbstractMethod* method, uint32_t dex_pc) + virtual void MethodUnwind(Thread* thread, const mirror::ArtMethod* method, uint32_t dex_pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); virtual void DexPcMoved(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, uint32_t new_dex_pc) + const mirror::ArtMethod* method, uint32_t new_dex_pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); virtual void ExceptionCaught(Thread* thread, const ThrowLocation& throw_location, - mirror::AbstractMethod* catch_method, uint32_t catch_dex_pc, + mirror::ArtMethod* catch_method, uint32_t catch_dex_pc, mirror::Throwable* exception_object) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); @@ -84,12 +84,12 @@ class Trace : public instrumentation::InstrumentationListener { void FinishTracing() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void LogMethodTraceEvent(Thread* thread, const mirror::AbstractMethod* method, + void LogMethodTraceEvent(Thread* thread, const mirror::ArtMethod* method, instrumentation::Instrumentation::InstrumentationEvent event); // Methods to output traced methods and threads. - void GetVisitedMethods(size_t end_offset, std::set* visited_methods); - void DumpMethodList(std::ostream& os, const std::set& visited_methods) + void GetVisitedMethods(size_t end_offset, std::set* visited_methods); + void DumpMethodList(std::ostream& os, const std::set& visited_methods) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void DumpThreadList(std::ostream& os) LOCKS_EXCLUDED(Locks::thread_list_lock_); diff --git a/runtime/utils.cc b/runtime/utils.cc index 71e502df29..87cd21c478 100644 --- a/runtime/utils.cc +++ b/runtime/utils.cc @@ -25,11 +25,10 @@ #include "UniquePtr.h" #include "base/unix_file/fd_file.h" #include "dex_file-inl.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_field-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/class_loader.h" -#include "mirror/field.h" -#include "mirror/field-inl.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" #include "mirror/string.h" @@ -295,7 +294,7 @@ std::string PrettyDescriptor(Primitive::Type type) { return PrettyDescriptor(descriptor_string); } -std::string PrettyField(const mirror::Field* f, bool with_type) { +std::string PrettyField(const mirror::ArtField* f, bool with_type) { if (f == NULL) { return "null"; } @@ -370,7 +369,7 @@ std::string PrettyReturnType(const char* signature) { return PrettyDescriptor(return_type); } -std::string PrettyMethod(const mirror::AbstractMethod* m, bool with_signature) { +std::string PrettyMethod(const mirror::ArtMethod* m, bool with_signature) { if (m == NULL) { return "null"; } @@ -629,7 +628,7 @@ std::string DescriptorToName(const char* descriptor) { return descriptor; } -std::string JniShortName(const mirror::AbstractMethod* m) { +std::string JniShortName(const mirror::ArtMethod* m) { MethodHelper mh(m); std::string class_name(mh.GetDeclaringClassDescriptor()); // Remove the leading 'L' and trailing ';'... @@ -648,7 +647,7 @@ std::string JniShortName(const mirror::AbstractMethod* m) { return short_name; } -std::string JniLongName(const mirror::AbstractMethod* m) { +std::string JniLongName(const mirror::ArtMethod* m) { std::string long_name; long_name += JniShortName(m); long_name += "__"; diff --git a/runtime/utils.h b/runtime/utils.h index 1c45048c13..9e724d0ac4 100644 --- a/runtime/utils.h +++ b/runtime/utils.h @@ -33,9 +33,9 @@ namespace art { class DexFile; namespace mirror { +class ArtField; +class ArtMethod; class Class; -class Field; -class AbstractMethod; class Object; class String; } // namespace mirror @@ -195,13 +195,13 @@ std::string PrettyDescriptor(const mirror::Class* klass) // Returns a human-readable signature for 'f'. Something like "a.b.C.f" or // "int a.b.C.f" (depending on the value of 'with_type'). -std::string PrettyField(const mirror::Field* f, bool with_type = true) +std::string PrettyField(const mirror::ArtField* f, bool with_type = true) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); std::string PrettyField(uint32_t field_idx, const DexFile& dex_file, bool with_type = true); // Returns a human-readable signature for 'm'. Something like "a.b.C.m" or // "a.b.C.m(II)V" (depending on the value of 'with_signature'). -std::string PrettyMethod(const mirror::AbstractMethod* m, bool with_signature = true) +std::string PrettyMethod(const mirror::ArtMethod* m, bool with_signature = true) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); std::string PrettyMethod(uint32_t method_idx, const DexFile& dex_file, bool with_signature = true); @@ -265,10 +265,10 @@ bool IsValidDescriptor(const char* s); // "Ljava/lang/String;" bool IsValidMemberName(const char* s); // Returns the JNI native function name for the non-overloaded method 'm'. -std::string JniShortName(const mirror::AbstractMethod* m) +std::string JniShortName(const mirror::ArtMethod* m) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Returns the JNI native function name for the overloaded method 'm'. -std::string JniLongName(const mirror::AbstractMethod* m) +std::string JniLongName(const mirror::ArtMethod* m) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); bool ReadFileToString(const std::string& file_name, std::string* result); diff --git a/runtime/utils_test.cc b/runtime/utils_test.cc index 0966e717ca..2633964b57 100644 --- a/runtime/utils_test.cc +++ b/runtime/utils_test.cc @@ -130,7 +130,7 @@ TEST_F(UtilsTest, PrettyField) { mirror::Class* java_lang_String = class_linker_->FindSystemClass("Ljava/lang/String;"); - mirror::Field* f; + mirror::ArtField* f; f = java_lang_String->FindDeclaredInstanceField("count", "I"); EXPECT_EQ("int java.lang.String.count", PrettyField(f)); EXPECT_EQ("java.lang.String.count", PrettyField(f, false)); @@ -199,7 +199,7 @@ TEST_F(UtilsTest, JniShortName_JniLongName) { ScopedObjectAccess soa(Thread::Current()); mirror::Class* c = class_linker_->FindSystemClass("Ljava/lang/String;"); ASSERT_TRUE(c != NULL); - mirror::AbstractMethod* m; + mirror::ArtMethod* m; m = c->FindVirtualMethod("charAt", "(I)C"); ASSERT_TRUE(m != NULL); diff --git a/runtime/verifier/method_verifier.cc b/runtime/verifier/method_verifier.cc index fc595d90d9..02168446b1 100644 --- a/runtime/verifier/method_verifier.cc +++ b/runtime/verifier/method_verifier.cc @@ -29,11 +29,11 @@ #include "indenter.h" #include "intern_table.h" #include "leb128.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_field-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class.h" #include "mirror/class-inl.h" #include "mirror/dex_cache-inl.h" -#include "mirror/field-inl.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" #include "object_utils.h" @@ -139,7 +139,7 @@ MethodVerifier::FailureKind MethodVerifier::VerifyClass(const DexFile* dex_file, } previous_direct_method_idx = method_idx; InvokeType type = it.GetMethodInvokeType(class_def); - mirror::AbstractMethod* method = + mirror::ArtMethod* method = linker->ResolveMethod(*dex_file, method_idx, dex_cache, class_loader, NULL, type); if (method == NULL) { DCHECK(Thread::Current()->IsExceptionPending()); @@ -181,7 +181,7 @@ MethodVerifier::FailureKind MethodVerifier::VerifyClass(const DexFile* dex_file, } previous_virtual_method_idx = method_idx; InvokeType type = it.GetMethodInvokeType(class_def); - mirror::AbstractMethod* method = + mirror::ArtMethod* method = linker->ResolveMethod(*dex_file, method_idx, dex_cache, class_loader, NULL, type); if (method == NULL) { DCHECK(Thread::Current()->IsExceptionPending()); @@ -225,7 +225,7 @@ MethodVerifier::FailureKind MethodVerifier::VerifyMethod(uint32_t method_idx, mirror::ClassLoader* class_loader, uint32_t class_def_idx, const DexFile::CodeItem* code_item, - mirror::AbstractMethod* method, + mirror::ArtMethod* method, uint32_t method_access_flags, bool allow_soft_failures) { MethodVerifier::FailureKind result = kNoFailure; @@ -266,7 +266,7 @@ void MethodVerifier::VerifyMethodAndDump(std::ostream& os, uint32_t dex_method_i const DexFile* dex_file, mirror::DexCache* dex_cache, mirror::ClassLoader* class_loader, uint32_t class_def_idx, const DexFile::CodeItem* code_item, - mirror::AbstractMethod* method, + mirror::ArtMethod* method, uint32_t method_access_flags) { MethodVerifier verifier(dex_file, dex_cache, class_loader, class_def_idx, code_item, dex_method_idx, method, method_access_flags, true, true); @@ -279,7 +279,7 @@ void MethodVerifier::VerifyMethodAndDump(std::ostream& os, uint32_t dex_method_i MethodVerifier::MethodVerifier(const DexFile* dex_file, mirror::DexCache* dex_cache, mirror::ClassLoader* class_loader, uint32_t class_def_idx, const DexFile::CodeItem* code_item, - uint32_t dex_method_idx, mirror::AbstractMethod* method, + uint32_t dex_method_idx, mirror::ArtMethod* method, uint32_t method_access_flags, bool can_load_classes, bool allow_soft_failures) : reg_types_(can_load_classes), @@ -305,7 +305,7 @@ MethodVerifier::MethodVerifier(const DexFile* dex_file, mirror::DexCache* dex_ca has_virtual_or_interface_invokes_(false) { } -void MethodVerifier::FindLocksAtDexPc(mirror::AbstractMethod* m, uint32_t dex_pc, +void MethodVerifier::FindLocksAtDexPc(mirror::ArtMethod* m, uint32_t dex_pc, std::vector& monitor_enter_dex_pcs) { MethodHelper mh(m); MethodVerifier verifier(&mh.GetDexFile(), mh.GetDexCache(), mh.GetClassLoader(), @@ -327,7 +327,7 @@ void MethodVerifier::FindLocksAtDexPc() { Verify(); } -mirror::Field* MethodVerifier::FindAccessedFieldAtDexPc(mirror::AbstractMethod* m, +mirror::ArtField* MethodVerifier::FindAccessedFieldAtDexPc(mirror::ArtMethod* m, uint32_t dex_pc) { MethodHelper mh(m); MethodVerifier verifier(&mh.GetDexFile(), mh.GetDexCache(), mh.GetClassLoader(), @@ -336,7 +336,7 @@ mirror::Field* MethodVerifier::FindAccessedFieldAtDexPc(mirror::AbstractMethod* return verifier.FindAccessedFieldAtDexPc(dex_pc); } -mirror::Field* MethodVerifier::FindAccessedFieldAtDexPc(uint32_t dex_pc) { +mirror::ArtField* MethodVerifier::FindAccessedFieldAtDexPc(uint32_t dex_pc) { CHECK(code_item_ != NULL); // This only makes sense for methods with code. // Strictly speaking, we ought to be able to get away with doing a subset of the full method @@ -355,7 +355,7 @@ mirror::Field* MethodVerifier::FindAccessedFieldAtDexPc(uint32_t dex_pc) { return GetQuickFieldAccess(inst, register_line); } -mirror::AbstractMethod* MethodVerifier::FindInvokedMethodAtDexPc(mirror::AbstractMethod* m, +mirror::ArtMethod* MethodVerifier::FindInvokedMethodAtDexPc(mirror::ArtMethod* m, uint32_t dex_pc) { MethodHelper mh(m); MethodVerifier verifier(&mh.GetDexFile(), mh.GetDexCache(), mh.GetClassLoader(), @@ -364,7 +364,7 @@ mirror::AbstractMethod* MethodVerifier::FindInvokedMethodAtDexPc(mirror::Abstrac return verifier.FindInvokedMethodAtDexPc(dex_pc); } -mirror::AbstractMethod* MethodVerifier::FindInvokedMethodAtDexPc(uint32_t dex_pc) { +mirror::ArtMethod* MethodVerifier::FindInvokedMethodAtDexPc(uint32_t dex_pc) { CHECK(code_item_ != NULL); // This only makes sense for methods with code. // Strictly speaking, we ought to be able to get away with doing a subset of the full method @@ -2113,7 +2113,7 @@ bool MethodVerifier::CodeFlowVerifyInstruction(uint32_t* start_guess) { inst->Opcode() == Instruction::INVOKE_SUPER_RANGE); bool is_super = (inst->Opcode() == Instruction::INVOKE_SUPER || inst->Opcode() == Instruction::INVOKE_SUPER_RANGE); - mirror::AbstractMethod* called_method = VerifyInvocationArgs(inst, METHOD_VIRTUAL, + mirror::ArtMethod* called_method = VerifyInvocationArgs(inst, METHOD_VIRTUAL, is_range, is_super); const char* descriptor; if (called_method == NULL) { @@ -2136,7 +2136,7 @@ bool MethodVerifier::CodeFlowVerifyInstruction(uint32_t* start_guess) { case Instruction::INVOKE_DIRECT: case Instruction::INVOKE_DIRECT_RANGE: { bool is_range = (inst->Opcode() == Instruction::INVOKE_DIRECT_RANGE); - mirror::AbstractMethod* called_method = VerifyInvocationArgs(inst, METHOD_DIRECT, + mirror::ArtMethod* called_method = VerifyInvocationArgs(inst, METHOD_DIRECT, is_range, false); const char* return_type_descriptor; bool is_constructor; @@ -2203,7 +2203,7 @@ bool MethodVerifier::CodeFlowVerifyInstruction(uint32_t* start_guess) { case Instruction::INVOKE_STATIC: case Instruction::INVOKE_STATIC_RANGE: { bool is_range = (inst->Opcode() == Instruction::INVOKE_STATIC_RANGE); - mirror::AbstractMethod* called_method = VerifyInvocationArgs(inst, + mirror::ArtMethod* called_method = VerifyInvocationArgs(inst, METHOD_STATIC, is_range, false); @@ -2228,7 +2228,7 @@ bool MethodVerifier::CodeFlowVerifyInstruction(uint32_t* start_guess) { case Instruction::INVOKE_INTERFACE: case Instruction::INVOKE_INTERFACE_RANGE: { bool is_range = (inst->Opcode() == Instruction::INVOKE_INTERFACE_RANGE); - mirror::AbstractMethod* abs_method = VerifyInvocationArgs(inst, + mirror::ArtMethod* abs_method = VerifyInvocationArgs(inst, METHOD_INTERFACE, is_range, false); @@ -2536,7 +2536,7 @@ bool MethodVerifier::CodeFlowVerifyInstruction(uint32_t* start_guess) { case Instruction::INVOKE_VIRTUAL_QUICK: case Instruction::INVOKE_VIRTUAL_RANGE_QUICK: { bool is_range = (inst->Opcode() == Instruction::INVOKE_VIRTUAL_RANGE_QUICK); - mirror::AbstractMethod* called_method = VerifyInvokeVirtualQuickArgs(inst, is_range); + mirror::ArtMethod* called_method = VerifyInvokeVirtualQuickArgs(inst, is_range); if (called_method != NULL) { const char* descriptor = MethodHelper(called_method).GetReturnTypeDescriptor(); const RegType& return_type = reg_types_.FromDescriptor(class_loader_, descriptor, false); @@ -2871,7 +2871,7 @@ const RegType& MethodVerifier::GetCaughtExceptionType() { return *common_super; } -mirror::AbstractMethod* MethodVerifier::ResolveMethodAndCheckAccess(uint32_t dex_method_idx, +mirror::ArtMethod* MethodVerifier::ResolveMethodAndCheckAccess(uint32_t dex_method_idx, MethodType method_type) { const DexFile::MethodId& method_id = dex_file_->GetMethodId(dex_method_idx); const RegType& klass_type = ResolveClassAndCheckAccess(method_id.class_idx_); @@ -2886,7 +2886,7 @@ mirror::AbstractMethod* MethodVerifier::ResolveMethodAndCheckAccess(uint32_t dex } mirror::Class* klass = klass_type.GetClass(); const RegType& referrer = GetDeclaringClass(); - mirror::AbstractMethod* res_method = dex_cache_->GetResolvedMethod(dex_method_idx); + mirror::ArtMethod* res_method = dex_cache_->GetResolvedMethod(dex_method_idx); if (res_method == NULL) { const char* name = dex_file_->GetMethodName(method_id); std::string signature(dex_file_->CreateMethodSignature(method_id.proto_idx_, NULL)); @@ -2963,14 +2963,14 @@ mirror::AbstractMethod* MethodVerifier::ResolveMethodAndCheckAccess(uint32_t dex return res_method; } -mirror::AbstractMethod* MethodVerifier::VerifyInvocationArgs(const Instruction* inst, +mirror::ArtMethod* MethodVerifier::VerifyInvocationArgs(const Instruction* inst, MethodType method_type, bool is_range, bool is_super) { // Resolve the method. This could be an abstract or concrete method depending on what sort of call // we're making. const uint32_t method_idx = (is_range) ? inst->VRegB_3rc() : inst->VRegB_35c(); - mirror::AbstractMethod* res_method = ResolveMethodAndCheckAccess(method_idx, method_type); + mirror::ArtMethod* res_method = ResolveMethodAndCheckAccess(method_idx, method_type); if (res_method == NULL) { // error or class is unresolved return NULL; } @@ -3078,7 +3078,7 @@ mirror::AbstractMethod* MethodVerifier::VerifyInvocationArgs(const Instruction* } } -mirror::AbstractMethod* MethodVerifier::GetQuickInvokedMethod(const Instruction* inst, +mirror::ArtMethod* MethodVerifier::GetQuickInvokedMethod(const Instruction* inst, RegisterLine* reg_line, bool is_range) { DCHECK(inst->Opcode() == Instruction::INVOKE_VIRTUAL_QUICK || @@ -3103,19 +3103,19 @@ mirror::AbstractMethod* MethodVerifier::GetQuickInvokedMethod(const Instruction* if (this_class == NULL) { return NULL; } - mirror::ObjectArray* vtable = this_class->GetVTable(); + mirror::ObjectArray* vtable = this_class->GetVTable(); CHECK(vtable != NULL); uint16_t vtable_index = is_range ? inst->VRegB_3rc() : inst->VRegB_35c(); CHECK(vtable_index < vtable->GetLength()); - mirror::AbstractMethod* res_method = vtable->Get(vtable_index); + mirror::ArtMethod* res_method = vtable->Get(vtable_index); CHECK(!Thread::Current()->IsExceptionPending()); return res_method; } -mirror::AbstractMethod* MethodVerifier::VerifyInvokeVirtualQuickArgs(const Instruction* inst, +mirror::ArtMethod* MethodVerifier::VerifyInvokeVirtualQuickArgs(const Instruction* inst, bool is_range) { DCHECK(Runtime::Current()->IsStarted()); - mirror::AbstractMethod* res_method = GetQuickInvokedMethod(inst, work_line_.get(), + mirror::ArtMethod* res_method = GetQuickInvokedMethod(inst, work_line_.get(), is_range); if (res_method == NULL) { Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "Cannot infer method from " << inst->Name(); @@ -3368,7 +3368,7 @@ void MethodVerifier::VerifyAPut(const Instruction* inst, } } -mirror::Field* MethodVerifier::GetStaticField(int field_idx) { +mirror::ArtField* MethodVerifier::GetStaticField(int field_idx) { const DexFile::FieldId& field_id = dex_file_->GetFieldId(field_idx); // Check access to class const RegType& klass_type = ResolveClassAndCheckAccess(field_id.class_idx_); @@ -3381,7 +3381,7 @@ mirror::Field* MethodVerifier::GetStaticField(int field_idx) { if (klass_type.IsUnresolvedTypes()) { return NULL; // Can't resolve Class so no more to do here, will do checking at runtime. } - mirror::Field* field = Runtime::Current()->GetClassLinker()->ResolveFieldJLS(*dex_file_, + mirror::ArtField* field = Runtime::Current()->GetClassLinker()->ResolveFieldJLS(*dex_file_, field_idx, dex_cache_, class_loader_); @@ -3405,7 +3405,7 @@ mirror::Field* MethodVerifier::GetStaticField(int field_idx) { } } -mirror::Field* MethodVerifier::GetInstanceField(const RegType& obj_type, int field_idx) { +mirror::ArtField* MethodVerifier::GetInstanceField(const RegType& obj_type, int field_idx) { const DexFile::FieldId& field_id = dex_file_->GetFieldId(field_idx); // Check access to class const RegType& klass_type = ResolveClassAndCheckAccess(field_id.class_idx_); @@ -3418,7 +3418,7 @@ mirror::Field* MethodVerifier::GetInstanceField(const RegType& obj_type, int fie if (klass_type.IsUnresolvedTypes()) { return NULL; // Can't resolve Class so no more to do here } - mirror::Field* field = Runtime::Current()->GetClassLinker()->ResolveFieldJLS(*dex_file_, + mirror::ArtField* field = Runtime::Current()->GetClassLinker()->ResolveFieldJLS(*dex_file_, field_idx, dex_cache_, class_loader_); @@ -3471,7 +3471,7 @@ mirror::Field* MethodVerifier::GetInstanceField(const RegType& obj_type, int fie void MethodVerifier::VerifyISGet(const Instruction* inst, const RegType& insn_type, bool is_primitive, bool is_static) { uint32_t field_idx = is_static ? inst->VRegB_21c() : inst->VRegC_22c(); - mirror::Field* field; + mirror::ArtField* field; if (is_static) { field = GetStaticField(field_idx); } else { @@ -3525,7 +3525,7 @@ void MethodVerifier::VerifyISGet(const Instruction* inst, const RegType& insn_ty void MethodVerifier::VerifyISPut(const Instruction* inst, const RegType& insn_type, bool is_primitive, bool is_static) { uint32_t field_idx = is_static ? inst->VRegB_21c() : inst->VRegC_22c(); - mirror::Field* field; + mirror::ArtField* field; if (is_static) { field = GetStaticField(field_idx); } else { @@ -3567,13 +3567,13 @@ void MethodVerifier::VerifyISPut(const Instruction* inst, const RegType& insn_ty // Look for an instance field with this offset. // TODO: we may speed up the search if offsets are sorted by doing a quick search. -static mirror::Field* FindInstanceFieldWithOffset(const mirror::Class* klass, +static mirror::ArtField* FindInstanceFieldWithOffset(const mirror::Class* klass, uint32_t field_offset) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - const mirror::ObjectArray* instance_fields = klass->GetIFields(); + const mirror::ObjectArray* instance_fields = klass->GetIFields(); if (instance_fields != NULL) { for (int32_t i = 0, e = instance_fields->GetLength(); i < e; ++i) { - mirror::Field* field = instance_fields->Get(i); + mirror::ArtField* field = instance_fields->Get(i); if (field->GetOffset().Uint32Value() == field_offset) { return field; } @@ -3589,7 +3589,7 @@ static mirror::Field* FindInstanceFieldWithOffset(const mirror::Class* klass, // Returns the access field of a quick field access (iget/iput-quick) or NULL // if it cannot be found. -mirror::Field* MethodVerifier::GetQuickFieldAccess(const Instruction* inst, +mirror::ArtField* MethodVerifier::GetQuickFieldAccess(const Instruction* inst, RegisterLine* reg_line) { DCHECK(inst->Opcode() == Instruction::IGET_QUICK || inst->Opcode() == Instruction::IGET_WIDE_QUICK || @@ -3624,7 +3624,7 @@ mirror::Field* MethodVerifier::GetQuickFieldAccess(const Instruction* inst, void MethodVerifier::VerifyIGetQuick(const Instruction* inst, const RegType& insn_type, bool is_primitive) { DCHECK(Runtime::Current()->IsStarted()); - mirror::Field* field = GetQuickFieldAccess(inst, work_line_.get()); + mirror::ArtField* field = GetQuickFieldAccess(inst, work_line_.get()); if (field == NULL) { Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "Cannot infer field from " << inst->Name(); return; @@ -3668,7 +3668,7 @@ void MethodVerifier::VerifyIGetQuick(const Instruction* inst, const RegType& ins void MethodVerifier::VerifyIPutQuick(const Instruction* inst, const RegType& insn_type, bool is_primitive) { DCHECK(Runtime::Current()->IsStarted()); - mirror::Field* field = GetQuickFieldAccess(inst, work_line_.get()); + mirror::ArtField* field = GetQuickFieldAccess(inst, work_line_.get()); if (field == NULL) { Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "Cannot infer field from " << inst->Name(); return; @@ -3922,7 +3922,7 @@ MethodVerifier::PcToConcreteMethodMap* MethodVerifier::GenerateDevirtMap() { // We can't devirtualize abstract classes except on arrays of abstract classes. continue; } - mirror::AbstractMethod* abstract_method = + mirror::ArtMethod* abstract_method = dex_cache_->GetResolvedMethod(is_range ? inst->VRegB_3rc() : inst->VRegB_35c()); if (abstract_method == NULL) { // If the method is not found in the cache this means that it was never found @@ -3930,7 +3930,7 @@ MethodVerifier::PcToConcreteMethodMap* MethodVerifier::GenerateDevirtMap() { continue; } // Find the concrete method. - mirror::AbstractMethod* concrete_method = NULL; + mirror::ArtMethod* concrete_method = NULL; if (is_interface) { concrete_method = reg_type.GetClass()->FindVirtualMethodForInterface(abstract_method); } diff --git a/runtime/verifier/method_verifier.h b/runtime/verifier/method_verifier.h index e01f2c08c1..6171943a6c 100644 --- a/runtime/verifier/method_verifier.h +++ b/runtime/verifier/method_verifier.h @@ -156,7 +156,7 @@ class MethodVerifier { static void VerifyMethodAndDump(std::ostream& os, uint32_t method_idx, const DexFile* dex_file, mirror::DexCache* dex_cache, mirror::ClassLoader* class_loader, uint32_t class_def_idx, const DexFile::CodeItem* code_item, - mirror::AbstractMethod* method, uint32_t method_access_flags) + mirror::ArtMethod* method, uint32_t method_access_flags) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); uint8_t EncodePcToReferenceMapData() const; @@ -197,20 +197,18 @@ class MethodVerifier { // Fills 'monitor_enter_dex_pcs' with the dex pcs of the monitor-enter instructions corresponding // to the locks held at 'dex_pc' in method 'm'. - static void FindLocksAtDexPc(mirror::AbstractMethod* m, uint32_t dex_pc, + static void FindLocksAtDexPc(mirror::ArtMethod* m, uint32_t dex_pc, std::vector& monitor_enter_dex_pcs) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Returns the accessed field corresponding to the quick instruction's field // offset at 'dex_pc' in method 'm'. - static mirror::Field* FindAccessedFieldAtDexPc(mirror::AbstractMethod* m, - uint32_t dex_pc) + static mirror::ArtField* FindAccessedFieldAtDexPc(mirror::ArtMethod* m, uint32_t dex_pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Returns the invoked method corresponding to the quick instruction's vtable // index at 'dex_pc' in method 'm'. - static mirror::AbstractMethod* FindInvokedMethodAtDexPc(mirror::AbstractMethod* m, - uint32_t dex_pc) + static mirror::ArtMethod* FindInvokedMethodAtDexPc(mirror::ArtMethod* m, uint32_t dex_pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); static void Init() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); @@ -226,7 +224,7 @@ class MethodVerifier { MethodVerifier(const DexFile* dex_file, mirror::DexCache* dex_cache, mirror::ClassLoader* class_loader, uint32_t class_def_idx, const DexFile::CodeItem* code_item, - uint32_t method_idx, mirror::AbstractMethod* method, + uint32_t method_idx, mirror::ArtMethod* method, uint32_t access_flags, bool can_load_classes, bool allow_soft_failures) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); @@ -266,16 +264,16 @@ class MethodVerifier { mirror::DexCache* dex_cache, mirror::ClassLoader* class_loader, uint32_t class_def_idx, const DexFile::CodeItem* code_item, - mirror::AbstractMethod* method, uint32_t method_access_flags, + mirror::ArtMethod* method, uint32_t method_access_flags, bool allow_soft_failures) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void FindLocksAtDexPc() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::Field* FindAccessedFieldAtDexPc(uint32_t dex_pc) + mirror::ArtField* FindAccessedFieldAtDexPc(uint32_t dex_pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::AbstractMethod* FindInvokedMethodAtDexPc(uint32_t dex_pc) + mirror::ArtMethod* FindInvokedMethodAtDexPc(uint32_t dex_pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); /* @@ -496,11 +494,11 @@ class MethodVerifier { bool is_primitive) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Lookup instance field and fail for resolution violations - mirror::Field* GetInstanceField(const RegType& obj_type, int field_idx) + mirror::ArtField* GetInstanceField(const RegType& obj_type, int field_idx) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Lookup static field and fail for resolution violations - mirror::Field* GetStaticField(int field_idx) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + mirror::ArtField* GetStaticField(int field_idx) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Perform verification of an iget or sget instruction. void VerifyISGet(const Instruction* inst, const RegType& insn_type, @@ -514,7 +512,7 @@ class MethodVerifier { // Returns the access field of a quick field access (iget/iput-quick) or NULL // if it cannot be found. - mirror::Field* GetQuickFieldAccess(const Instruction* inst, RegisterLine* reg_line) + mirror::ArtField* GetQuickFieldAccess(const Instruction* inst, RegisterLine* reg_line) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Perform verification of an iget-quick instruction. @@ -545,7 +543,7 @@ class MethodVerifier { * the referrer can access the resolved method. * Does not throw exceptions. */ - mirror::AbstractMethod* ResolveMethodAndCheckAccess(uint32_t method_idx, MethodType method_type) + mirror::ArtMethod* ResolveMethodAndCheckAccess(uint32_t method_idx, MethodType method_type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); /* @@ -570,18 +568,17 @@ class MethodVerifier { * Returns the resolved method on success, NULL on failure (with *failure * set appropriately). */ - mirror::AbstractMethod* VerifyInvocationArgs(const Instruction* inst, - MethodType method_type, - bool is_range, bool is_super) + mirror::ArtMethod* VerifyInvocationArgs(const Instruction* inst, + MethodType method_type, + bool is_range, bool is_super) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::AbstractMethod* GetQuickInvokedMethod(const Instruction* inst, - RegisterLine* reg_line, - bool is_range) + mirror::ArtMethod* GetQuickInvokedMethod(const Instruction* inst, + RegisterLine* reg_line, + bool is_range) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::AbstractMethod* VerifyInvokeVirtualQuickArgs(const Instruction* inst, - bool is_range) + mirror::ArtMethod* VerifyInvokeVirtualQuickArgs(const Instruction* inst, bool is_range) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); /* @@ -686,7 +683,7 @@ class MethodVerifier { const uint32_t dex_method_idx_; // The method we're working on. // Its object representation if known. - mirror::AbstractMethod* mirror_method_ GUARDED_BY(Locks::mutator_lock_); + mirror::ArtMethod* mirror_method_ GUARDED_BY(Locks::mutator_lock_); const uint32_t method_access_flags_; // Method's access flags. const DexFile* const dex_file_; // The dex file containing the method. // The dex_cache for the declaring class of the method. diff --git a/runtime/well_known_classes.cc b/runtime/well_known_classes.cc index 434fcf00f5..8de020a975 100644 --- a/runtime/well_known_classes.cc +++ b/runtime/well_known_classes.cc @@ -32,8 +32,11 @@ jclass WellKnownClasses::java_lang_ClassNotFoundException; jclass WellKnownClasses::java_lang_Daemons; jclass WellKnownClasses::java_lang_Error; jclass WellKnownClasses::java_lang_Object; -jclass WellKnownClasses::java_lang_reflect_InvocationHandler; jclass WellKnownClasses::java_lang_reflect_AbstractMethod; +jclass WellKnownClasses::java_lang_reflect_ArtMethod; +jclass WellKnownClasses::java_lang_reflect_Constructor; +jclass WellKnownClasses::java_lang_reflect_Field; +jclass WellKnownClasses::java_lang_reflect_Method; jclass WellKnownClasses::java_lang_reflect_Proxy; jclass WellKnownClasses::java_lang_RuntimeException; jclass WellKnownClasses::java_lang_StackOverflowError; @@ -61,7 +64,7 @@ jmethodID WellKnownClasses::java_lang_Integer_valueOf; jmethodID WellKnownClasses::java_lang_Long_valueOf; jmethodID WellKnownClasses::java_lang_ref_FinalizerReference_add; jmethodID WellKnownClasses::java_lang_ref_ReferenceQueue_add; -jmethodID WellKnownClasses::java_lang_reflect_InvocationHandler_invoke; +jmethodID WellKnownClasses::java_lang_reflect_Proxy_invoke; jmethodID WellKnownClasses::java_lang_Runtime_nativeLoad; jmethodID WellKnownClasses::java_lang_Short_valueOf; jmethodID WellKnownClasses::java_lang_System_runFinalization = NULL; @@ -83,6 +86,8 @@ jfieldID WellKnownClasses::java_lang_Thread_nativePeer; jfieldID WellKnownClasses::java_lang_ThreadGroup_mainThreadGroup; jfieldID WellKnownClasses::java_lang_ThreadGroup_name; jfieldID WellKnownClasses::java_lang_ThreadGroup_systemThreadGroup; +jfieldID WellKnownClasses::java_lang_reflect_AbstractMethod_artMethod; +jfieldID WellKnownClasses::java_lang_reflect_Field_artField; jfieldID WellKnownClasses::java_lang_reflect_Proxy_h; jfieldID WellKnownClasses::java_nio_DirectByteBuffer_capacity; jfieldID WellKnownClasses::java_nio_DirectByteBuffer_effectiveDirectAddress; @@ -121,7 +126,7 @@ static jmethodID CachePrimitiveBoxingMethod(JNIEnv* env, char prim_name, const c StringPrintf("(%c)L%s;", prim_name, boxed_name).c_str()); } -void WellKnownClasses::InitClasses(JNIEnv* env) { +void WellKnownClasses::Init(JNIEnv* env) { com_android_dex_Dex = CacheClass(env, "com/android/dex/Dex"); dalvik_system_PathClassLoader = CacheClass(env, "dalvik/system/PathClassLoader"); java_lang_ClassLoader = CacheClass(env, "java/lang/ClassLoader"); @@ -129,8 +134,11 @@ void WellKnownClasses::InitClasses(JNIEnv* env) { java_lang_Daemons = CacheClass(env, "java/lang/Daemons"); java_lang_Object = CacheClass(env, "java/lang/Object"); java_lang_Error = CacheClass(env, "java/lang/Error"); - java_lang_reflect_InvocationHandler = CacheClass(env, "java/lang/reflect/InvocationHandler"); java_lang_reflect_AbstractMethod = CacheClass(env, "java/lang/reflect/AbstractMethod"); + java_lang_reflect_ArtMethod = CacheClass(env, "java/lang/reflect/ArtMethod"); + java_lang_reflect_Constructor = CacheClass(env, "java/lang/reflect/Constructor"); + java_lang_reflect_Field = CacheClass(env, "java/lang/reflect/Field"); + java_lang_reflect_Method = CacheClass(env, "java/lang/reflect/Method"); java_lang_reflect_Proxy = CacheClass(env, "java/lang/reflect/Proxy"); java_lang_RuntimeException = CacheClass(env, "java/lang/RuntimeException"); java_lang_StackOverflowError = CacheClass(env, "java/lang/StackOverflowError"); @@ -142,10 +150,6 @@ void WellKnownClasses::InitClasses(JNIEnv* env) { java_nio_DirectByteBuffer = CacheClass(env, "java/nio/DirectByteBuffer"); org_apache_harmony_dalvik_ddmc_Chunk = CacheClass(env, "org/apache/harmony/dalvik/ddmc/Chunk"); org_apache_harmony_dalvik_ddmc_DdmServer = CacheClass(env, "org/apache/harmony/dalvik/ddmc/DdmServer"); -} - -void WellKnownClasses::Init(JNIEnv* env) { - InitClasses(env); com_android_dex_Dex_create = CacheMethod(env, com_android_dex_Dex, true, "create", "(Ljava/nio/ByteBuffer;)Lcom/android/dex/Dex;"); java_lang_ClassNotFoundException_init = CacheMethod(env, java_lang_ClassNotFoundException, false, "", "(Ljava/lang/String;Ljava/lang/Throwable;)V"); @@ -160,7 +164,7 @@ void WellKnownClasses::Init(JNIEnv* env) { ScopedLocalRef java_lang_ref_ReferenceQueue(env, env->FindClass("java/lang/ref/ReferenceQueue")); java_lang_ref_ReferenceQueue_add = CacheMethod(env, java_lang_ref_ReferenceQueue.get(), true, "add", "(Ljava/lang/ref/Reference;)V"); - java_lang_reflect_InvocationHandler_invoke = CacheMethod(env, java_lang_reflect_InvocationHandler, false, "invoke", "(Ljava/lang/Object;Ljava/lang/reflect/Method;[Ljava/lang/Object;)Ljava/lang/Object;"); + java_lang_reflect_Proxy_invoke = CacheMethod(env, java_lang_reflect_Proxy, true, "invoke", "(Ljava/lang/reflect/Proxy;Ljava/lang/reflect/ArtMethod;[Ljava/lang/Object;)Ljava/lang/Object;"); java_lang_Thread_init = CacheMethod(env, java_lang_Thread, false, "", "(Ljava/lang/ThreadGroup;Ljava/lang/String;IZ)V"); java_lang_Thread_run = CacheMethod(env, java_lang_Thread, false, "run", "()V"); java_lang_Thread$UncaughtExceptionHandler_uncaughtException = CacheMethod(env, java_lang_Thread$UncaughtExceptionHandler, false, "uncaughtException", "(Ljava/lang/Thread;Ljava/lang/Throwable;)V"); @@ -179,6 +183,8 @@ void WellKnownClasses::Init(JNIEnv* env) { java_lang_ThreadGroup_mainThreadGroup = CacheField(env, java_lang_ThreadGroup, true, "mainThreadGroup", "Ljava/lang/ThreadGroup;"); java_lang_ThreadGroup_name = CacheField(env, java_lang_ThreadGroup, false, "name", "Ljava/lang/String;"); java_lang_ThreadGroup_systemThreadGroup = CacheField(env, java_lang_ThreadGroup, true, "systemThreadGroup", "Ljava/lang/ThreadGroup;"); + java_lang_reflect_AbstractMethod_artMethod = CacheField(env, java_lang_reflect_AbstractMethod, false, "artMethod", "Ljava/lang/reflect/ArtMethod;"); + java_lang_reflect_Field_artField = CacheField(env, java_lang_reflect_Field, false, "artField", "Ljava/lang/reflect/ArtField;"); java_lang_reflect_Proxy_h = CacheField(env, java_lang_reflect_Proxy, false, "h", "Ljava/lang/reflect/InvocationHandler;"); java_nio_DirectByteBuffer_capacity = CacheField(env, java_nio_DirectByteBuffer, false, "capacity", "I"); java_nio_DirectByteBuffer_effectiveDirectAddress = CacheField(env, java_nio_DirectByteBuffer, false, "effectiveDirectAddress", "J"); diff --git a/runtime/well_known_classes.h b/runtime/well_known_classes.h index fc2bffb485..bc928d0dbe 100644 --- a/runtime/well_known_classes.h +++ b/runtime/well_known_classes.h @@ -32,7 +32,7 @@ class Class; jmethodID CacheMethod(JNIEnv* env, jclass c, bool is_static, const char* name, const char* signature); struct WellKnownClasses { - static void InitClasses(JNIEnv* env); + public: static void Init(JNIEnv* env); // Run before native methods are registered. static void LateInit(JNIEnv* env); // Run after native methods are registered. @@ -46,8 +46,11 @@ struct WellKnownClasses { static jclass java_lang_Daemons; static jclass java_lang_Error; static jclass java_lang_Object; - static jclass java_lang_reflect_InvocationHandler; static jclass java_lang_reflect_AbstractMethod; + static jclass java_lang_reflect_ArtMethod; + static jclass java_lang_reflect_Constructor; + static jclass java_lang_reflect_Field; + static jclass java_lang_reflect_Method; static jclass java_lang_reflect_Proxy; static jclass java_lang_RuntimeException; static jclass java_lang_StackOverflowError; @@ -75,7 +78,7 @@ struct WellKnownClasses { static jmethodID java_lang_Long_valueOf; static jmethodID java_lang_ref_FinalizerReference_add; static jmethodID java_lang_ref_ReferenceQueue_add; - static jmethodID java_lang_reflect_InvocationHandler_invoke; + static jmethodID java_lang_reflect_Proxy_invoke; static jmethodID java_lang_Runtime_nativeLoad; static jmethodID java_lang_Short_valueOf; static jmethodID java_lang_System_runFinalization; @@ -87,6 +90,8 @@ struct WellKnownClasses { static jmethodID org_apache_harmony_dalvik_ddmc_DdmServer_broadcast; static jmethodID org_apache_harmony_dalvik_ddmc_DdmServer_dispatch; + static jfieldID java_lang_reflect_AbstractMethod_artMethod; + static jfieldID java_lang_reflect_Field_artField; static jfieldID java_lang_reflect_Proxy_h; static jfieldID java_lang_Thread_daemon; static jfieldID java_lang_Thread_group; diff --git a/test/046-reflect/expected.txt b/test/046-reflect/expected.txt index 8de373caa6..fcfaf2ff3f 100644 --- a/test/046-reflect/expected.txt +++ b/test/046-reflect/expected.txt @@ -81,8 +81,9 @@ Field name is cantTouchThis Field type is int Access flags are 0x11 cantTouchThis is 77 - setAccessible is always true cantTouchThis is now 99 + public final int Target.cantTouchThis accessible=false + public final int Target.cantTouchThis accessible=true cantTouchThis is now 87 cantTouchThis is now 88 cons modifiers=1 @@ -92,6 +93,8 @@ myMethod (I)I arg=17 anInt=7 ReflectTest done! public method +static java.lang.Object java.util.Collections.checkType(java.lang.Object,java.lang.Class) accessible=false +static java.lang.Object java.util.Collections.checkType(java.lang.Object,java.lang.Class) accessible=true checkType invoking null checkType got expected exception calling const-class FieldNoisyInitUser.class @@ -113,3 +116,7 @@ MethodNoisyInit is initializing generic field: java.util.List generic method fancyMethod params='[1] java.util.ArrayList' ret='java.util.Map' generic ctor Main params='[1] java.util.ArrayList' +fields are unique +fields are .equals +methods are unique +methods are .equals diff --git a/test/046-reflect/src/Main.java b/test/046-reflect/src/Main.java index 9d4cacf499..dfb0d8fe9b 100644 --- a/test/046-reflect/src/Main.java +++ b/test/046-reflect/src/Main.java @@ -335,14 +335,15 @@ public class Main { System.out.println(" cantTouchThis is " + intVal); try { field.setInt(instance, 99); - System.out.println(" setAccessible is always true"); } catch (IllegalAccessException iae) { System.out.println("ERROR: set-final failed"); } intVal = field.getInt(instance); System.out.println(" cantTouchThis is now " + intVal); + System.out.println(" " + field + " accessible=" + field.isAccessible()); field.setAccessible(true); + System.out.println(" " + field + " accessible=" + field.isAccessible()); field.setInt(instance, 87); // exercise int version intVal = field.getInt(instance); System.out.println(" cantTouchThis is now " + intVal); @@ -378,8 +379,9 @@ public class Main { nsme.printStackTrace(); return; } - + System.out.println(m + " accessible=" + m.isAccessible()); m.setAccessible(true); + System.out.println(m + " accessible=" + m.isAccessible()); try { m.invoke(null, new Object(), Object.class); } catch (IllegalAccessException iae) { @@ -518,6 +520,42 @@ public class Main { return stb.toString(); } + public static void checkUnique() { + Field field1, field2; + try { + field1 = Main.class.getField("dummy"); + field2 = Main.class.getField("dummy"); + } catch (NoSuchFieldException nsfe) { + throw new RuntimeException(nsfe); + } + if (field1 == field2) { + System.out.println("ERROR: fields shouldn't have reference equality"); + } else { + System.out.println("fields are unique"); + } + if (field1.hashCode() == field2.hashCode() && field1.equals(field2)) { + System.out.println("fields are .equals"); + } else { + System.out.println("ERROR: fields fail equality"); + } + Method method1, method2; + try { + method1 = Main.class.getMethod("fancyMethod", new Class[] { ArrayList.class }); + method2 = Main.class.getMethod("fancyMethod", new Class[] { ArrayList.class }); + } catch (NoSuchMethodException nsme) { + throw new RuntimeException(nsme); + } + if (method1 == method2) { + System.out.println("ERROR: methods shouldn't have reference equality"); + } else { + System.out.println("methods are unique"); + } + if (method1.hashCode() == method2.hashCode() && method1.equals(method2)) { + System.out.println("methods are .equals"); + } else { + System.out.println("ERROR: methods fail equality"); + } + } public static void main(String[] args) throws Exception { Main test = new Main(); @@ -528,6 +566,7 @@ public class Main { checkClinitForFields(); checkClinitForMethods(); checkGeneric(); + checkUnique(); } } diff --git a/test/100-reflect2/expected.txt b/test/100-reflect2/expected.txt index f56fd98947..3d87ebc559 100644 --- a/test/100-reflect2/expected.txt +++ b/test/100-reflect2/expected.txt @@ -36,7 +36,7 @@ z (class java.lang.Character) 14 (class java.lang.Short) [public java.lang.String(), java.lang.String(int,int,char[]), public java.lang.String(java.lang.String), public java.lang.String(java.lang.StringBuffer), public java.lang.String(java.lang.StringBuilder), public java.lang.String(byte[]), public java.lang.String(byte[],int), public java.lang.String(byte[],int,int), public java.lang.String(byte[],int,int,int), public java.lang.String(byte[],int,int,java.lang.String) throws java.io.UnsupportedEncodingException, public java.lang.String(byte[],int,int,java.nio.charset.Charset), public java.lang.String(byte[],java.lang.String) throws java.io.UnsupportedEncodingException, public java.lang.String(byte[],java.nio.charset.Charset), public java.lang.String(char[]), public java.lang.String(char[],int,int), public java.lang.String(int[],int,int)] [private final char[] java.lang.String.value, private final int java.lang.String.count, private int java.lang.String.hashCode, private final int java.lang.String.offset, private static final char[] java.lang.String.ASCII, public static final java.util.Comparator java.lang.String.CASE_INSENSITIVE_ORDER, private static final char java.lang.String.REPLACEMENT_CHAR, private static final long java.lang.String.serialVersionUID] -[void java.lang.String._getChars(int,int,char[],int), public char java.lang.String.charAt(int), public int java.lang.String.codePointAt(int), public int java.lang.String.codePointBefore(int), public int java.lang.String.codePointCount(int,int), public volatile int java.lang.String.compareTo(java.lang.Object), public native int java.lang.String.compareTo(java.lang.String), public int java.lang.String.compareToIgnoreCase(java.lang.String), public java.lang.String java.lang.String.concat(java.lang.String), public boolean java.lang.String.contains(java.lang.CharSequence), public boolean java.lang.String.contentEquals(java.lang.CharSequence), public boolean java.lang.String.contentEquals(java.lang.StringBuffer), public boolean java.lang.String.endsWith(java.lang.String), public boolean java.lang.String.equals(java.lang.Object), public boolean java.lang.String.equalsIgnoreCase(java.lang.String), public void java.lang.String.getBytes(int,int,byte[],int), public [B java.lang.String.getBytes(), public [B java.lang.String.getBytes(java.lang.String) throws java.io.UnsupportedEncodingException, public [B java.lang.String.getBytes(java.nio.charset.Charset), public void java.lang.String.getChars(int,int,char[],int), public int java.lang.String.hashCode(), public int java.lang.String.indexOf(int), public int java.lang.String.indexOf(int,int), public int java.lang.String.indexOf(java.lang.String), public int java.lang.String.indexOf(java.lang.String,int), public native java.lang.String java.lang.String.intern(), public boolean java.lang.String.isEmpty(), public int java.lang.String.lastIndexOf(int), public int java.lang.String.lastIndexOf(int,int), public int java.lang.String.lastIndexOf(java.lang.String), public int java.lang.String.lastIndexOf(java.lang.String,int), public int java.lang.String.length(), public boolean java.lang.String.matches(java.lang.String), public int java.lang.String.offsetByCodePoints(int,int), public boolean java.lang.String.regionMatches(int,java.lang.String,int,int), public boolean java.lang.String.regionMatches(boolean,int,java.lang.String,int,int), public java.lang.String java.lang.String.replace(char,char), public java.lang.String java.lang.String.replace(java.lang.CharSequence,java.lang.CharSequence), public java.lang.String java.lang.String.replaceAll(java.lang.String,java.lang.String), public java.lang.String java.lang.String.replaceFirst(java.lang.String,java.lang.String), public [Ljava.lang.String; java.lang.String.split(java.lang.String), public [Ljava.lang.String; java.lang.String.split(java.lang.String,int), public boolean java.lang.String.startsWith(java.lang.String), public boolean java.lang.String.startsWith(java.lang.String,int), public java.lang.CharSequence java.lang.String.subSequence(int,int), public java.lang.String java.lang.String.substring(int), public java.lang.String java.lang.String.substring(int,int), public [C java.lang.String.toCharArray(), public java.lang.String java.lang.String.toLowerCase(), public java.lang.String java.lang.String.toLowerCase(java.util.Locale), public java.lang.String java.lang.String.toString(), public java.lang.String java.lang.String.toUpperCase(), public java.lang.String java.lang.String.toUpperCase(java.util.Locale), public java.lang.String java.lang.String.trim(), static void java.lang.String.(), public static java.lang.String java.lang.String.copyValueOf(char[]), public static java.lang.String java.lang.String.copyValueOf(char[],int,int), private java.lang.StringIndexOutOfBoundsException java.lang.String.failedBoundsCheck(int,int,int), private native int java.lang.String.fastIndexOf(int,int), private char java.lang.String.foldCase(char), public static transient java.lang.String java.lang.String.format(java.lang.String,java.lang.Object[]), public static transient java.lang.String java.lang.String.format(java.util.Locale,java.lang.String,java.lang.Object[]), private java.lang.StringIndexOutOfBoundsException java.lang.String.indexAndLength(int), private static int java.lang.String.indexOf(java.lang.String,java.lang.String,int,int,char), private int java.lang.String.indexOfSupplementary(int,int), private int java.lang.String.lastIndexOfSupplementary(int,int), private java.lang.StringIndexOutOfBoundsException java.lang.String.startEndAndLength(int,int), public static java.lang.String java.lang.String.valueOf(char), public static java.lang.String java.lang.String.valueOf(double), public static java.lang.String java.lang.String.valueOf(float), public static java.lang.String java.lang.String.valueOf(int), public static java.lang.String java.lang.String.valueOf(long), public static java.lang.String java.lang.String.valueOf(java.lang.Object), public static java.lang.String java.lang.String.valueOf(boolean), public static java.lang.String java.lang.String.valueOf(char[]), public static java.lang.String java.lang.String.valueOf(char[],int,int)] +[void java.lang.String._getChars(int,int,char[],int), public char java.lang.String.charAt(int), public int java.lang.String.codePointAt(int), public int java.lang.String.codePointBefore(int), public int java.lang.String.codePointCount(int,int), public volatile int java.lang.String.compareTo(java.lang.Object), public native int java.lang.String.compareTo(java.lang.String), public int java.lang.String.compareToIgnoreCase(java.lang.String), public java.lang.String java.lang.String.concat(java.lang.String), public boolean java.lang.String.contains(java.lang.CharSequence), public boolean java.lang.String.contentEquals(java.lang.CharSequence), public boolean java.lang.String.contentEquals(java.lang.StringBuffer), public boolean java.lang.String.endsWith(java.lang.String), public boolean java.lang.String.equals(java.lang.Object), public boolean java.lang.String.equalsIgnoreCase(java.lang.String), public void java.lang.String.getBytes(int,int,byte[],int), public [B java.lang.String.getBytes(), public [B java.lang.String.getBytes(java.lang.String) throws java.io.UnsupportedEncodingException, public [B java.lang.String.getBytes(java.nio.charset.Charset), public void java.lang.String.getChars(int,int,char[],int), public int java.lang.String.hashCode(), public int java.lang.String.indexOf(int), public int java.lang.String.indexOf(int,int), public int java.lang.String.indexOf(java.lang.String), public int java.lang.String.indexOf(java.lang.String,int), public native java.lang.String java.lang.String.intern(), public boolean java.lang.String.isEmpty(), public int java.lang.String.lastIndexOf(int), public int java.lang.String.lastIndexOf(int,int), public int java.lang.String.lastIndexOf(java.lang.String), public int java.lang.String.lastIndexOf(java.lang.String,int), public int java.lang.String.length(), public boolean java.lang.String.matches(java.lang.String), public int java.lang.String.offsetByCodePoints(int,int), public boolean java.lang.String.regionMatches(int,java.lang.String,int,int), public boolean java.lang.String.regionMatches(boolean,int,java.lang.String,int,int), public java.lang.String java.lang.String.replace(char,char), public java.lang.String java.lang.String.replace(java.lang.CharSequence,java.lang.CharSequence), public java.lang.String java.lang.String.replaceAll(java.lang.String,java.lang.String), public java.lang.String java.lang.String.replaceFirst(java.lang.String,java.lang.String), public [Ljava.lang.String; java.lang.String.split(java.lang.String), public [Ljava.lang.String; java.lang.String.split(java.lang.String,int), public boolean java.lang.String.startsWith(java.lang.String), public boolean java.lang.String.startsWith(java.lang.String,int), public java.lang.CharSequence java.lang.String.subSequence(int,int), public java.lang.String java.lang.String.substring(int), public java.lang.String java.lang.String.substring(int,int), public [C java.lang.String.toCharArray(), public java.lang.String java.lang.String.toLowerCase(), public java.lang.String java.lang.String.toLowerCase(java.util.Locale), public java.lang.String java.lang.String.toString(), public java.lang.String java.lang.String.toUpperCase(), public java.lang.String java.lang.String.toUpperCase(java.util.Locale), public java.lang.String java.lang.String.trim(), public static java.lang.String java.lang.String.copyValueOf(char[]), public static java.lang.String java.lang.String.copyValueOf(char[],int,int), private java.lang.StringIndexOutOfBoundsException java.lang.String.failedBoundsCheck(int,int,int), private native int java.lang.String.fastIndexOf(int,int), private char java.lang.String.foldCase(char), public static transient java.lang.String java.lang.String.format(java.lang.String,java.lang.Object[]), public static transient java.lang.String java.lang.String.format(java.util.Locale,java.lang.String,java.lang.Object[]), private java.lang.StringIndexOutOfBoundsException java.lang.String.indexAndLength(int), private static int java.lang.String.indexOf(java.lang.String,java.lang.String,int,int,char), private int java.lang.String.indexOfSupplementary(int,int), private int java.lang.String.lastIndexOfSupplementary(int,int), private java.lang.StringIndexOutOfBoundsException java.lang.String.startEndAndLength(int,int), public static java.lang.String java.lang.String.valueOf(char), public static java.lang.String java.lang.String.valueOf(double), public static java.lang.String java.lang.String.valueOf(float), public static java.lang.String java.lang.String.valueOf(int), public static java.lang.String java.lang.String.valueOf(long), public static java.lang.String java.lang.String.valueOf(java.lang.Object), public static java.lang.String java.lang.String.valueOf(boolean), public static java.lang.String java.lang.String.valueOf(char[]), public static java.lang.String java.lang.String.valueOf(char[],int,int)] [] [interface java.io.Serializable, interface java.lang.Comparable, interface java.lang.CharSequence] 0 diff --git a/test/ReferenceMap/stack_walk_refmap_jni.cc b/test/ReferenceMap/stack_walk_refmap_jni.cc index 84f5f2ea29..1f6e307f26 100644 --- a/test/ReferenceMap/stack_walk_refmap_jni.cc +++ b/test/ReferenceMap/stack_walk_refmap_jni.cc @@ -20,8 +20,8 @@ #include "class_linker.h" #include "dex_file-inl.h" #include "gc_map.h" -#include "mirror/abstract_method.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/object_array-inl.h" #include "object_utils.h" @@ -52,7 +52,7 @@ struct ReferenceMap2Visitor : public StackVisitor { } bool VisitFrame() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* m = GetMethod(); + mirror::ArtMethod* m = GetMethod(); if (!m || m->IsNative() || m->IsRuntimeMethod() || IsShadowFrame()) { return true; } diff --git a/test/StackWalk/stack_walk_jni.cc b/test/StackWalk/stack_walk_jni.cc index 8f4aae61fd..528586ed7b 100644 --- a/test/StackWalk/stack_walk_jni.cc +++ b/test/StackWalk/stack_walk_jni.cc @@ -19,8 +19,8 @@ #include "UniquePtr.h" #include "class_linker.h" #include "gc_map.h" -#include "mirror/abstract_method.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/object_array-inl.h" #include "mirror/object-inl.h" @@ -50,7 +50,7 @@ struct TestReferenceMapVisitor : public StackVisitor { } bool VisitFrame() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* m = GetMethod(); + mirror::ArtMethod* m = GetMethod(); CHECK(m != NULL); LOG(INFO) << "At " << PrettyMethod(m, false); -- cgit v1.2.3-59-g8ed1b From 75a43f10f55e2aa550de51e969cc1e60d583b632 Mon Sep 17 00:00:00 2001 From: Anwar Ghuloum Date: Tue, 13 Aug 2013 17:22:14 -0700 Subject: Clean up logcat spam from compiler and verifier Moved to VLOG(...), adding verifer tag for VLOG. Change-Id: Ia9ac8aeaf5aa1f4881e384003e82a66e560c5692 --- compiler/driver/compiler_driver.cc | 6 +++--- compiler/oat_writer.cc | 4 ++-- dex2oat/dex2oat.cc | 12 ++++++------ runtime/base/logging.h | 2 ++ runtime/runtime.cc | 3 +++ runtime/verifier/method_verifier.cc | 37 +++++++++++++++++++++---------------- 6 files changed, 37 insertions(+), 27 deletions(-) (limited to 'compiler/driver/compiler_driver.cc') diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc index 144271d581..47ef222bf8 100644 --- a/compiler/driver/compiler_driver.cc +++ b/compiler/driver/compiler_driver.cc @@ -64,7 +64,7 @@ static void DumpStat(size_t x, size_t y, const char* str) { if (x == 0 && y == 0) { return; } - LOG(INFO) << Percentage(x, y) << "% of " << str << " for " << (x + y) << " cases"; + VLOG(compiler) << Percentage(x, y) << "% of " << str << " for " << (x + y) << " cases"; } class AOTCompilationStats { @@ -724,7 +724,7 @@ static void MaybeAddToImageClasses(mirror::Class* klass, CompilerDriver::Descrip std::pair result = image_classes->insert(descriptor); if (result.second) { - LOG(INFO) << "Adding " << descriptor << " to image classes"; + VLOG(compiler) << "Adding " << descriptor << " to image classes"; } else { return; } @@ -2070,7 +2070,7 @@ static void InitializeClass(const ParallelCompilationManager* manager, size_t cl } } if (!is_black_listed) { - LOG(INFO) << "Initializing: " << descriptor; + VLOG(compiler) << "Initializing: " << descriptor; if (StringPiece(descriptor) == "Ljava/lang/Void;") { // Hand initialize j.l.Void to avoid Dex file operations in un-started runtime. mirror::ObjectArray* fields = klass->GetSFields(); diff --git a/compiler/oat_writer.cc b/compiler/oat_writer.cc index ce88cf6dd6..b129026a24 100644 --- a/compiler/oat_writer.cc +++ b/compiler/oat_writer.cc @@ -464,7 +464,7 @@ bool OatWriter::Write(OutputStream& out) { if (kIsDebugBuild) { uint32_t size_total = 0; #define DO_STAT(x) \ - LOG(INFO) << #x "=" << PrettySize(x) << " (" << x << "B)"; \ + VLOG(compiler) << #x "=" << PrettySize(x) << " (" << x << "B)"; \ size_total += x; DO_STAT(size_dex_file_alignment_); @@ -495,7 +495,7 @@ bool OatWriter::Write(OutputStream& out) { DO_STAT(size_oat_class_method_offsets_); #undef DO_STAT - LOG(INFO) << "size_total=" << PrettySize(size_total) << " (" << size_total << "B)"; \ + VLOG(compiler) << "size_total=" << PrettySize(size_total) << " (" << size_total << "B)"; \ CHECK_EQ(file_offset + size_total, static_cast(out.Seek(0, kSeekCurrent))); CHECK_EQ(size_, size_total); } diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc index b85378d9ec..0f146a9baf 100644 --- a/dex2oat/dex2oat.cc +++ b/dex2oat/dex2oat.cc @@ -164,7 +164,7 @@ class Dex2Oat { ~Dex2Oat() { delete runtime_; - LOG(INFO) << "dex2oat took " << PrettyDuration(NanoTime() - start_ns_) + VLOG(compiler) << "dex2oat took " << PrettyDuration(NanoTime() - start_ns_) << " (threads: " << thread_count_ << ")"; } @@ -923,7 +923,7 @@ static int dex2oat(int argc, char** argv) { } if (num_methods <= Runtime::Current()->GetNumDexMethodsThreshold()) { Runtime::Current()->SetCompilerFilter(Runtime::kSpeed); - LOG(INFO) << "Below method threshold, compiling anyways"; + VLOG(compiler) << "Below method threshold, compiling anyways"; } } @@ -945,7 +945,7 @@ static int dex2oat(int argc, char** argv) { return EXIT_FAILURE; } - LOG(INFO) << "Oat file written successfully (unstripped): " << oat_location; + VLOG(compiler) << "Oat file written successfully (unstripped): " << oat_location; // Notes on the interleaving of creating the image and oat file to // ensure the references between the two are correct. @@ -1009,7 +1009,7 @@ static int dex2oat(int argc, char** argv) { if (!image_creation_success) { return EXIT_FAILURE; } - LOG(INFO) << "Image written successfully: " << image_filename; + VLOG(compiler) << "Image written successfully: " << image_filename; } if (is_host) { @@ -1037,7 +1037,7 @@ static int dex2oat(int argc, char** argv) { CHECK(write_ok); } oat_file.reset(out.release()); - LOG(INFO) << "Oat file copied successfully (stripped): " << oat_stripped; + VLOG(compiler) << "Oat file copied successfully (stripped): " << oat_stripped; } #if ART_USE_PORTABLE_COMPILER // We currently only generate symbols on Portable @@ -1049,7 +1049,7 @@ static int dex2oat(int argc, char** argv) { // We wrote the oat file successfully, and want to keep it. - LOG(INFO) << "Oat file written successfully (stripped): " << oat_location; + VLOG(compiler) << "Oat file written successfully (stripped): " << oat_location; #endif // ART_USE_PORTABLE_COMPILER timings.EndSplit(); diff --git a/runtime/base/logging.h b/runtime/base/logging.h index ade8d34ed6..8e40da0112 100644 --- a/runtime/base/logging.h +++ b/runtime/base/logging.h @@ -125,6 +125,7 @@ #define VLOG_IS_ON(module) UNLIKELY(::art::gLogVerbosity.module) #define VLOG(module) if (VLOG_IS_ON(module)) ::art::LogMessage(__FILE__, __LINE__, INFO, -1).stream() +#define VLOG_STREAM(module) ::art::LogMessage(__FILE__, __LINE__, INFO, -1).stream() // // Implementation details beyond this point. @@ -306,6 +307,7 @@ class ToStr { // and the "-verbose:" command line argument. struct LogVerbosity { bool class_linker; // Enabled with "-verbose:class". + bool verifier; bool compiler; bool heap; bool gc; diff --git a/runtime/runtime.cc b/runtime/runtime.cc index 70d8816401..7c354b5b66 100644 --- a/runtime/runtime.cc +++ b/runtime/runtime.cc @@ -365,6 +365,7 @@ Runtime::ParsedOptions* Runtime::ParsedOptions::Create(const Options& options, b parsed->sea_ir_mode_ = false; // gLogVerbosity.class_linker = true; // TODO: don't check this in! // gLogVerbosity.compiler = true; // TODO: don't check this in! +// gLogVerbosity.verifier = true; // TODO: don't check this in! // gLogVerbosity.heap = true; // TODO: don't check this in! // gLogVerbosity.gc = true; // TODO: don't check this in! // gLogVerbosity.jdwp = true; // TODO: don't check this in! @@ -522,6 +523,8 @@ Runtime::ParsedOptions* Runtime::ParsedOptions::Create(const Options& options, b for (size_t i = 0; i < verbose_options.size(); ++i) { if (verbose_options[i] == "class") { gLogVerbosity.class_linker = true; + } else if (verbose_options[i] == "verifier") { + gLogVerbosity.verifier = true; } else if (verbose_options[i] == "compiler") { gLogVerbosity.compiler = true; } else if (verbose_options[i] == "heap") { diff --git a/runtime/verifier/method_verifier.cc b/runtime/verifier/method_verifier.cc index fc595d90d9..6f3bae595b 100644 --- a/runtime/verifier/method_verifier.cc +++ b/runtime/verifier/method_verifier.cc @@ -45,6 +45,7 @@ namespace art { namespace verifier { static const bool gDebugVerify = false; +// TODO: Add a constant to method_verifier to turn on verbose logging? void PcToRegisterLineTable::Init(RegisterTrackingMode mode, InstructionFlags* flags, uint32_t insns_size, uint16_t registers_size, @@ -231,26 +232,28 @@ MethodVerifier::FailureKind MethodVerifier::VerifyMethod(uint32_t method_idx, MethodVerifier::FailureKind result = kNoFailure; uint64_t start_ns = NanoTime(); - MethodVerifier verifier(dex_file, dex_cache, class_loader, class_def_idx, code_item, method_idx, - method, method_access_flags, true, allow_soft_failures); - if (verifier.Verify()) { + MethodVerifier verifier_(dex_file, dex_cache, class_loader, class_def_idx, code_item, method_idx, + method, method_access_flags, true, allow_soft_failures); + if (verifier_.Verify()) { // Verification completed, however failures may be pending that didn't cause the verification // to hard fail. - CHECK(!verifier.have_pending_hard_failure_); - if (verifier.failures_.size() != 0) { - verifier.DumpFailures(LOG(INFO) << "Soft verification failures in " - << PrettyMethod(method_idx, *dex_file) << "\n"); + CHECK(!verifier_.have_pending_hard_failure_); + if (verifier_.failures_.size() != 0) { + if (VLOG_IS_ON(verifier)) { + verifier_.DumpFailures(VLOG_STREAM(verifier) << "Soft verification failures in " + << PrettyMethod(method_idx, *dex_file) << "\n"); + } result = kSoftFailure; } } else { // Bad method data. - CHECK_NE(verifier.failures_.size(), 0U); - CHECK(verifier.have_pending_hard_failure_); - verifier.DumpFailures(LOG(INFO) << "Verification error in " + CHECK_NE(verifier_.failures_.size(), 0U); + CHECK(verifier_.have_pending_hard_failure_); + verifier_.DumpFailures(LOG(INFO) << "Verification error in " << PrettyMethod(method_idx, *dex_file) << "\n"); if (gDebugVerify) { - std::cout << "\n" << verifier.info_messages_.str(); - verifier.Dump(std::cout); + std::cout << "\n" << verifier_.info_messages_.str(); + verifier_.Dump(std::cout); } result = kHardFailure; } @@ -1079,8 +1082,10 @@ bool MethodVerifier::VerifyCodeFlow() { std::ostream& MethodVerifier::DumpFailures(std::ostream& os) { DCHECK_EQ(failures_.size(), failure_messages_.size()); - for (size_t i = 0; i < failures_.size(); ++i) { - os << failure_messages_[i]->str() << "\n"; + if (VLOG_IS_ON(verifier)) { + for (size_t i = 0; i < failures_.size(); ++i) { + os << failure_messages_[i]->str() << "\n"; + } } return os; } @@ -3386,7 +3391,7 @@ mirror::Field* MethodVerifier::GetStaticField(int field_idx) { dex_cache_, class_loader_); if (field == NULL) { - LOG(INFO) << "Unable to resolve static field " << field_idx << " (" + VLOG(verifier) << "Unable to resolve static field " << field_idx << " (" << dex_file_->GetFieldName(field_id) << ") in " << dex_file_->GetFieldDeclaringClassDescriptor(field_id); DCHECK(Thread::Current()->IsExceptionPending()); @@ -3423,7 +3428,7 @@ mirror::Field* MethodVerifier::GetInstanceField(const RegType& obj_type, int fie dex_cache_, class_loader_); if (field == NULL) { - LOG(INFO) << "Unable to resolve instance field " << field_idx << " (" + VLOG(verifier) << "Unable to resolve instance field " << field_idx << " (" << dex_file_->GetFieldName(field_id) << ") in " << dex_file_->GetFieldDeclaringClassDescriptor(field_id); DCHECK(Thread::Current()->IsExceptionPending()); -- cgit v1.2.3-59-g8ed1b