diff options
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/dex/quick/dex_file_method_inliner.cc | 40 | ||||
| -rw-r--r-- | compiler/dex/quick/dex_file_method_inliner.h | 11 | ||||
| -rw-r--r-- | compiler/driver/compiler_driver.cc | 12 | ||||
| -rw-r--r-- | compiler/driver/compiler_driver.h | 3 | ||||
| -rw-r--r-- | compiler/optimizing/code_generator_arm.cc | 7 | ||||
| -rw-r--r-- | compiler/optimizing/code_generator_arm64.cc | 7 | ||||
| -rw-r--r-- | compiler/optimizing/code_generator_mips.cc | 7 | ||||
| -rw-r--r-- | compiler/optimizing/code_generator_mips64.cc | 7 | ||||
| -rw-r--r-- | compiler/optimizing/code_generator_x86.cc | 7 | ||||
| -rw-r--r-- | compiler/optimizing/code_generator_x86_64.cc | 8 | ||||
| -rw-r--r-- | compiler/optimizing/instruction_builder.cc | 55 | ||||
| -rw-r--r-- | compiler/optimizing/nodes.h | 4 |
12 files changed, 60 insertions, 108 deletions
diff --git a/compiler/dex/quick/dex_file_method_inliner.cc b/compiler/dex/quick/dex_file_method_inliner.cc index 8d53dbfe39..67505541c2 100644 --- a/compiler/dex/quick/dex_file_method_inliner.cc +++ b/compiler/dex/quick/dex_file_method_inliner.cc @@ -640,28 +640,6 @@ const DexFileMethodInliner::IntrinsicDef DexFileMethodInliner::kIntrinsicMethods INTRINSIC(JavaLangLong, RotateLeft, JI_J, kIntrinsicRotateLeft, k64), #undef INTRINSIC - -#define SPECIAL(c, n, p, o, d) \ - { { kClassCache ## c, kNameCache ## n, kProtoCache ## p }, { o, kInlineSpecial, { d } } } - - SPECIAL(JavaLangString, Init, _V, kInlineStringInit, 0), - SPECIAL(JavaLangString, Init, ByteArray_V, kInlineStringInit, 1), - SPECIAL(JavaLangString, Init, ByteArrayI_V, kInlineStringInit, 2), - SPECIAL(JavaLangString, Init, ByteArrayII_V, kInlineStringInit, 3), - SPECIAL(JavaLangString, Init, ByteArrayIII_V, kInlineStringInit, 4), - SPECIAL(JavaLangString, Init, ByteArrayIIString_V, kInlineStringInit, 5), - SPECIAL(JavaLangString, Init, ByteArrayString_V, kInlineStringInit, 6), - SPECIAL(JavaLangString, Init, ByteArrayIICharset_V, kInlineStringInit, 7), - SPECIAL(JavaLangString, Init, ByteArrayCharset_V, kInlineStringInit, 8), - SPECIAL(JavaLangString, Init, CharArray_V, kInlineStringInit, 9), - SPECIAL(JavaLangString, Init, CharArrayII_V, kInlineStringInit, 10), - SPECIAL(JavaLangString, Init, IICharArray_V, kInlineStringInit, 11), - SPECIAL(JavaLangString, Init, IntArrayII_V, kInlineStringInit, 12), - SPECIAL(JavaLangString, Init, String_V, kInlineStringInit, 13), - SPECIAL(JavaLangString, Init, StringBuffer_V, kInlineStringInit, 14), - SPECIAL(JavaLangString, Init, StringBuilder_V, kInlineStringInit, 15), - -#undef SPECIAL }; DexFileMethodInliner::DexFileMethodInliner() @@ -843,22 +821,4 @@ bool DexFileMethodInliner::AddInlineMethod(int32_t method_idx, const InlineMetho } } -uint32_t DexFileMethodInliner::GetOffsetForStringInit(uint32_t method_index, - PointerSize pointer_size) { - ReaderMutexLock mu(Thread::Current(), lock_); - auto it = inline_methods_.find(method_index); - if (it != inline_methods_.end() && (it->second.opcode == kInlineStringInit)) { - uint32_t string_init_base_offset = Thread::QuickEntryPointOffsetWithSize( - OFFSETOF_MEMBER(QuickEntryPoints, pNewEmptyString), pointer_size); - return string_init_base_offset + it->second.d.data * static_cast<size_t>(pointer_size); - } - return 0; -} - -bool DexFileMethodInliner::IsStringInitMethodIndex(uint32_t method_index) { - ReaderMutexLock mu(Thread::Current(), lock_); - auto it = inline_methods_.find(method_index); - return (it != inline_methods_.end()) && (it->second.opcode == kInlineStringInit); -} - } // namespace art diff --git a/compiler/dex/quick/dex_file_method_inliner.h b/compiler/dex/quick/dex_file_method_inliner.h index 43fc687957..f4ae5a548e 100644 --- a/compiler/dex/quick/dex_file_method_inliner.h +++ b/compiler/dex/quick/dex_file_method_inliner.h @@ -82,17 +82,6 @@ class DexFileMethodInliner { bool IsSpecial(uint32_t method_index) REQUIRES(!lock_); /** - * Gets the thread pointer entrypoint offset for a string init method index and pointer size. - */ - uint32_t GetOffsetForStringInit(uint32_t method_index, PointerSize pointer_size) - REQUIRES(!lock_); - - /** - * Check whether a particular method index is a string init. - */ - bool IsStringInitMethodIndex(uint32_t method_index) REQUIRES(!lock_); - - /** * To avoid multiple lookups of a class by its descriptor, we cache its * type index in the IndexCache. These are the indexes into the IndexCache * class_indexes array. diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc index adbf9fd0a7..79828d8c1f 100644 --- a/compiler/driver/compiler_driver.cc +++ b/compiler/driver/compiler_driver.cc @@ -2789,18 +2789,6 @@ std::string CompilerDriver::GetMemoryUsageString(bool extended) const { return oss.str(); } -bool CompilerDriver::IsStringTypeIndex(uint16_t type_index, const DexFile* dex_file) { - const char* type = dex_file->GetTypeDescriptor(dex_file->GetTypeId(type_index)); - return strcmp(type, "Ljava/lang/String;") == 0; -} - -bool CompilerDriver::IsStringInit(uint32_t method_index, const DexFile* dex_file, int32_t* offset) { - DexFileMethodInliner* inliner = GetMethodInlinerMap()->GetMethodInliner(dex_file); - const PointerSize pointer_size = InstructionSetPointerSize(GetInstructionSet()); - *offset = inliner->GetOffsetForStringInit(method_index, pointer_size); - return inliner->IsStringInitMethodIndex(method_index); -} - bool CompilerDriver::MayInlineInternal(const DexFile* inlined_from, const DexFile* inlined_into) const { // We're not allowed to inline across dex files if we're the no-inline-from dex file. diff --git a/compiler/driver/compiler_driver.h b/compiler/driver/compiler_driver.h index 1f4c3aca34..41f0d36c79 100644 --- a/compiler/driver/compiler_driver.h +++ b/compiler/driver/compiler_driver.h @@ -432,9 +432,6 @@ class CompilerDriver { // Get memory usage during compilation. std::string GetMemoryUsageString(bool extended) const; - bool IsStringTypeIndex(uint16_t type_index, const DexFile* dex_file); - bool IsStringInit(uint32_t method_index, const DexFile* dex_file, int32_t* offset); - void SetHadHardVerifierFailure() { had_hard_verifier_failure_ = true; } diff --git a/compiler/optimizing/code_generator_arm.cc b/compiler/optimizing/code_generator_arm.cc index 6be458ce26..55e122150e 100644 --- a/compiler/optimizing/code_generator_arm.cc +++ b/compiler/optimizing/code_generator_arm.cc @@ -6748,10 +6748,13 @@ void CodeGeneratorARM::GenerateStaticOrDirectCall(HInvokeStaticOrDirect* invoke, Location callee_method = temp; // For all kinds except kRecursive, callee will be in temp. switch (invoke->GetMethodLoadKind()) { - case HInvokeStaticOrDirect::MethodLoadKind::kStringInit: + case HInvokeStaticOrDirect::MethodLoadKind::kStringInit: { + uint32_t offset = + GetThreadOffset<kArmPointerSize>(invoke->GetStringInitEntryPoint()).Int32Value(); // temp = thread->string_init_entrypoint - __ LoadFromOffset(kLoadWord, temp.AsRegister<Register>(), TR, invoke->GetStringInitOffset()); + __ LoadFromOffset(kLoadWord, temp.AsRegister<Register>(), TR, offset); break; + } case HInvokeStaticOrDirect::MethodLoadKind::kRecursive: callee_method = invoke->GetLocations()->InAt(invoke->GetSpecialInputIndex()); break; diff --git a/compiler/optimizing/code_generator_arm64.cc b/compiler/optimizing/code_generator_arm64.cc index 7160607687..a2a2e426b6 100644 --- a/compiler/optimizing/code_generator_arm64.cc +++ b/compiler/optimizing/code_generator_arm64.cc @@ -3570,10 +3570,13 @@ void CodeGeneratorARM64::GenerateStaticOrDirectCall(HInvokeStaticOrDirect* invok // Make sure that ArtMethod* is passed in kArtMethodRegister as per the calling convention. Location callee_method = temp; // For all kinds except kRecursive, callee will be in temp. switch (invoke->GetMethodLoadKind()) { - case HInvokeStaticOrDirect::MethodLoadKind::kStringInit: + case HInvokeStaticOrDirect::MethodLoadKind::kStringInit: { + uint32_t offset = + GetThreadOffset<kArm64PointerSize>(invoke->GetStringInitEntryPoint()).Int32Value(); // temp = thread->string_init_entrypoint - __ Ldr(XRegisterFrom(temp), MemOperand(tr, invoke->GetStringInitOffset())); + __ Ldr(XRegisterFrom(temp), MemOperand(tr, offset)); break; + } case HInvokeStaticOrDirect::MethodLoadKind::kRecursive: callee_method = invoke->GetLocations()->InAt(invoke->GetSpecialInputIndex()); break; diff --git a/compiler/optimizing/code_generator_mips.cc b/compiler/optimizing/code_generator_mips.cc index f560207d3e..5c0ca85c78 100644 --- a/compiler/optimizing/code_generator_mips.cc +++ b/compiler/optimizing/code_generator_mips.cc @@ -4396,13 +4396,16 @@ void CodeGeneratorMIPS::GenerateStaticOrDirectCall(HInvokeStaticOrDirect* invoke } switch (method_load_kind) { - case HInvokeStaticOrDirect::MethodLoadKind::kStringInit: + case HInvokeStaticOrDirect::MethodLoadKind::kStringInit: { // temp = thread->string_init_entrypoint + uint32_t offset = + GetThreadOffset<kMipsPointerSize>(invoke->GetStringInitEntryPoint()).Int32Value(); __ LoadFromOffset(kLoadWord, temp.AsRegister<Register>(), TR, - invoke->GetStringInitOffset()); + offset); break; + } case HInvokeStaticOrDirect::MethodLoadKind::kRecursive: callee_method = invoke->GetLocations()->InAt(invoke->GetSpecialInputIndex()); break; diff --git a/compiler/optimizing/code_generator_mips64.cc b/compiler/optimizing/code_generator_mips64.cc index a5e23511a4..02576bda67 100644 --- a/compiler/optimizing/code_generator_mips64.cc +++ b/compiler/optimizing/code_generator_mips64.cc @@ -3006,13 +3006,16 @@ void CodeGeneratorMIPS64::GenerateStaticOrDirectCall(HInvokeStaticOrDirect* invo Location callee_method = temp; // For all kinds except kRecursive, callee will be in temp. switch (invoke->GetMethodLoadKind()) { - case HInvokeStaticOrDirect::MethodLoadKind::kStringInit: + case HInvokeStaticOrDirect::MethodLoadKind::kStringInit: { // temp = thread->string_init_entrypoint + uint32_t offset = + GetThreadOffset<kMips64PointerSize>(invoke->GetStringInitEntryPoint()).Int32Value(); __ LoadFromOffset(kLoadDoubleword, temp.AsRegister<GpuRegister>(), TR, - invoke->GetStringInitOffset()); + offset); break; + } case HInvokeStaticOrDirect::MethodLoadKind::kRecursive: callee_method = invoke->GetLocations()->InAt(invoke->GetSpecialInputIndex()); break; diff --git a/compiler/optimizing/code_generator_x86.cc b/compiler/optimizing/code_generator_x86.cc index 47dfb2e921..c3000805d1 100644 --- a/compiler/optimizing/code_generator_x86.cc +++ b/compiler/optimizing/code_generator_x86.cc @@ -4276,10 +4276,13 @@ Location CodeGeneratorX86::GenerateCalleeMethodStaticOrDirectCall(HInvokeStaticO Location temp) { Location callee_method = temp; // For all kinds except kRecursive, callee will be in temp. switch (invoke->GetMethodLoadKind()) { - case HInvokeStaticOrDirect::MethodLoadKind::kStringInit: + case HInvokeStaticOrDirect::MethodLoadKind::kStringInit: { // temp = thread->string_init_entrypoint - __ fs()->movl(temp.AsRegister<Register>(), Address::Absolute(invoke->GetStringInitOffset())); + uint32_t offset = + GetThreadOffset<kX86PointerSize>(invoke->GetStringInitEntryPoint()).Int32Value(); + __ fs()->movl(temp.AsRegister<Register>(), Address::Absolute(offset)); break; + } case HInvokeStaticOrDirect::MethodLoadKind::kRecursive: callee_method = invoke->GetLocations()->InAt(invoke->GetSpecialInputIndex()); break; diff --git a/compiler/optimizing/code_generator_x86_64.cc b/compiler/optimizing/code_generator_x86_64.cc index 59c0ca47f8..f9a3e429d7 100644 --- a/compiler/optimizing/code_generator_x86_64.cc +++ b/compiler/optimizing/code_generator_x86_64.cc @@ -754,11 +754,13 @@ Location CodeGeneratorX86_64::GenerateCalleeMethodStaticOrDirectCall(HInvokeStat // All registers are assumed to be correctly set up. Location callee_method = temp; // For all kinds except kRecursive, callee will be in temp. switch (invoke->GetMethodLoadKind()) { - case HInvokeStaticOrDirect::MethodLoadKind::kStringInit: + case HInvokeStaticOrDirect::MethodLoadKind::kStringInit: { // temp = thread->string_init_entrypoint - __ gs()->movq(temp.AsRegister<CpuRegister>(), - Address::Absolute(invoke->GetStringInitOffset(), /* no_rip */ true)); + uint32_t offset = + GetThreadOffset<kX86_64PointerSize>(invoke->GetStringInitEntryPoint()).Int32Value(); + __ gs()->movq(temp.AsRegister<CpuRegister>(), Address::Absolute(offset, /* no_rip */ true)); break; + } case HInvokeStaticOrDirect::MethodLoadKind::kRecursive: callee_method = invoke->GetLocations()->InAt(invoke->GetSpecialInputIndex()); break; diff --git a/compiler/optimizing/instruction_builder.cc b/compiler/optimizing/instruction_builder.cc index 5a6a212cc9..62c6051596 100644 --- a/compiler/optimizing/instruction_builder.cc +++ b/compiler/optimizing/instruction_builder.cc @@ -767,6 +767,11 @@ ArtMethod* HInstructionBuilder::ResolveMethod(uint16_t method_idx, InvokeType in return resolved_method; } +static bool IsStringConstructor(ArtMethod* method) { + ScopedObjectAccess soa(Thread::Current()); + return method->GetDeclaringClass()->IsStringClass() && method->IsConstructor(); +} + bool HInstructionBuilder::BuildInvoke(const Instruction& instruction, uint32_t dex_pc, uint32_t method_idx, @@ -785,17 +790,33 @@ bool HInstructionBuilder::BuildInvoke(const Instruction& instruction, number_of_arguments++; } - // Special handling for string init. - int32_t string_init_offset = 0; - bool is_string_init = compiler_driver_->IsStringInit(method_idx, - dex_file_, - &string_init_offset); + ArtMethod* resolved_method = ResolveMethod(method_idx, invoke_type); + + if (UNLIKELY(resolved_method == nullptr)) { + MaybeRecordStat(MethodCompilationStat::kUnresolvedMethod); + HInvoke* invoke = new (arena_) HInvokeUnresolved(arena_, + number_of_arguments, + return_type, + dex_pc, + method_idx, + invoke_type); + return HandleInvoke(invoke, + number_of_vreg_arguments, + args, + register_index, + is_range, + descriptor, + nullptr, /* clinit_check */ + true /* is_unresolved */); + } + // Replace calls to String.<init> with StringFactory. - if (is_string_init) { + if (IsStringConstructor(resolved_method)) { + uint32_t string_init_entry_point = WellKnownClasses::StringInitToEntryPoint(resolved_method); HInvokeStaticOrDirect::DispatchInfo dispatch_info = { HInvokeStaticOrDirect::MethodLoadKind::kStringInit, HInvokeStaticOrDirect::CodePtrLocation::kCallArtMethod, - dchecked_integral_cast<uint64_t>(string_init_offset), + dchecked_integral_cast<uint64_t>(string_init_entry_point), 0U }; MethodReference target_method(dex_file_, method_idx); @@ -818,26 +839,6 @@ bool HInstructionBuilder::BuildInvoke(const Instruction& instruction, descriptor); } - ArtMethod* resolved_method = ResolveMethod(method_idx, invoke_type); - - if (UNLIKELY(resolved_method == nullptr)) { - MaybeRecordStat(MethodCompilationStat::kUnresolvedMethod); - HInvoke* invoke = new (arena_) HInvokeUnresolved(arena_, - number_of_arguments, - return_type, - dex_pc, - method_idx, - invoke_type); - return HandleInvoke(invoke, - number_of_vreg_arguments, - args, - register_index, - is_range, - descriptor, - nullptr, /* clinit_check */ - true /* is_unresolved */); - } - // Potential class initialization check, in the case of a static method call. HClinitCheck* clinit_check = nullptr; HInvoke* invoke = nullptr; diff --git a/compiler/optimizing/nodes.h b/compiler/optimizing/nodes.h index 57ae555caa..4dc4c20003 100644 --- a/compiler/optimizing/nodes.h +++ b/compiler/optimizing/nodes.h @@ -4044,9 +4044,9 @@ class HInvokeStaticOrDirect FINAL : public HInvoke { } bool HasDirectCodePtr() const { return GetCodePtrLocation() == CodePtrLocation::kCallDirect; } - int32_t GetStringInitOffset() const { + QuickEntrypointEnum GetStringInitEntryPoint() const { DCHECK(IsStringInit()); - return dispatch_info_.method_load_data; + return static_cast<QuickEntrypointEnum>(dispatch_info_.method_load_data); } uint64_t GetMethodAddress() const { |