summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libdexfile/dex/dex_file-inl.h18
-rw-r--r--libdexfile/dex/dex_file.h2
-rw-r--r--openjdkjvmti/ti_method.cc2
-rw-r--r--runtime/art_method-inl.h6
-rw-r--r--runtime/art_method.cc8
-rw-r--r--runtime/art_method.h4
-rw-r--r--runtime/entrypoints/quick/quick_trampoline_entrypoints.cc153
-rw-r--r--runtime/interpreter/interpreter.cc2
8 files changed, 104 insertions, 91 deletions
diff --git a/libdexfile/dex/dex_file-inl.h b/libdexfile/dex/dex_file-inl.h
index d9c5211cc8..d549d31805 100644
--- a/libdexfile/dex/dex_file-inl.h
+++ b/libdexfile/dex/dex_file-inl.h
@@ -180,6 +180,10 @@ inline const char* DexFile::GetMethodShorty(const dex::MethodId& method_id, uint
return StringDataAndUtf16LengthByIdx(GetProtoId(method_id.proto_idx_).shorty_idx_, length);
}
+inline std::string_view DexFile::GetMethodShortyView(const dex::MethodId& method_id) const {
+ return GetShortyView(method_id.proto_idx_);
+}
+
inline const char* DexFile::GetClassDescriptor(const dex::ClassDef& class_def) const {
return StringByTypeIdx(class_def.class_idx_);
}
@@ -194,12 +198,16 @@ inline const char* DexFile::GetShorty(dex::ProtoIndex proto_idx) const {
}
ALWAYS_INLINE
+inline std::string_view DexFile::GetShortyView(dex::ProtoIndex proto_idx) const {
+ return GetShortyView(GetProtoId(proto_idx));
+}
+
+ALWAYS_INLINE
inline std::string_view DexFile::GetShortyView(const dex::ProtoId& proto_id) const {
- uint32_t lhs_shorty_len;
- const char* lhs_shorty_data =
- StringDataAndUtf16LengthByIdx(proto_id.shorty_idx_, &lhs_shorty_len);
- DCHECK_EQ(lhs_shorty_data[lhs_shorty_len], '\0'); // For a shorty utf16 length == mutf8 length.
- return std::string_view(lhs_shorty_data, lhs_shorty_len);
+ uint32_t shorty_len;
+ const char* shorty_data = StringDataAndUtf16LengthByIdx(proto_id.shorty_idx_, &shorty_len);
+ DCHECK_EQ(shorty_data[shorty_len], '\0'); // For a shorty utf16 length == mutf8 length.
+ return std::string_view(shorty_data, shorty_len);
}
inline const dex::TryItem* DexFile::GetTryItems(const DexInstructionIterator& code_item_end,
diff --git a/libdexfile/dex/dex_file.h b/libdexfile/dex/dex_file.h
index dcf1a5d935..1b652c3e94 100644
--- a/libdexfile/dex/dex_file.h
+++ b/libdexfile/dex/dex_file.h
@@ -464,6 +464,7 @@ class DexFile {
// Returns the shorty of a method id.
const char* GetMethodShorty(const dex::MethodId& method_id) const;
const char* GetMethodShorty(const dex::MethodId& method_id, uint32_t* length) const;
+ std::string_view GetMethodShortyView(const dex::MethodId& method_id) const;
// Returns the number of class definitions in the .dex file.
uint32_t NumClassDefs() const {
@@ -558,6 +559,7 @@ class DexFile {
// Returns the short form method descriptor for the given prototype.
const char* GetShorty(dex::ProtoIndex proto_idx) const;
+ std::string_view GetShortyView(dex::ProtoIndex proto_idx) const;
std::string_view GetShortyView(const dex::ProtoId& proto_id) const;
const dex::TypeList* GetProtoParameters(const dex::ProtoId& proto_id) const {
diff --git a/openjdkjvmti/ti_method.cc b/openjdkjvmti/ti_method.cc
index 16efc2e358..b400513208 100644
--- a/openjdkjvmti/ti_method.cc
+++ b/openjdkjvmti/ti_method.cc
@@ -182,7 +182,7 @@ jvmtiError MethodUtil::GetArgumentsSize([[maybe_unused]] jvmtiEnv* env,
if (art_method->IsProxyMethod() || art_method->IsAbstract()) {
// Use the shorty.
art::ArtMethod* base_method = art_method->GetInterfaceMethodIfProxy(art::kRuntimePointerSize);
- size_t arg_count = art::ArtMethod::NumArgRegisters(base_method->GetShorty());
+ size_t arg_count = art::ArtMethod::NumArgRegisters(base_method->GetShortyView());
if (!base_method->IsStatic()) {
arg_count++;
}
diff --git a/runtime/art_method-inl.h b/runtime/art_method-inl.h
index e79e5a4aa8..46c78d2b21 100644
--- a/runtime/art_method-inl.h
+++ b/runtime/art_method-inl.h
@@ -404,6 +404,12 @@ inline const char* ArtMethod::GetShorty(uint32_t* out_length) {
return dex_file->GetMethodShorty(dex_file->GetMethodId(GetDexMethodIndex()), out_length);
}
+inline std::string_view ArtMethod::GetShortyView() {
+ DCHECK(!IsProxyMethod());
+ const DexFile* dex_file = GetDexFile();
+ return dex_file->GetMethodShortyView(dex_file->GetMethodId(GetDexMethodIndex()));
+}
+
inline const Signature ArtMethod::GetSignature() {
uint32_t dex_method_idx = GetDexMethodIndex();
if (dex_method_idx != dex::kDexNoIndex) {
diff --git a/runtime/art_method.cc b/runtime/art_method.cc
index c7be2dc0ca..973dabe4f0 100644
--- a/runtime/art_method.cc
+++ b/runtime/art_method.cc
@@ -226,11 +226,11 @@ InvokeType ArtMethod::GetInvokeType() {
}
}
-size_t ArtMethod::NumArgRegisters(const char* shorty) {
- CHECK_NE(shorty[0], '\0');
+size_t ArtMethod::NumArgRegisters(std::string_view shorty) {
+ CHECK(!shorty.empty());
uint32_t num_registers = 0;
- for (const char* s = shorty + 1; *s != '\0'; ++s) {
- if (*s == 'D' || *s == 'J') {
+ for (char c : shorty.substr(1u)) {
+ if (c == 'D' || c == 'J') {
num_registers += 2;
} else {
num_registers += 1;
diff --git a/runtime/art_method.h b/runtime/art_method.h
index b5d6ee7365..d3108da1e5 100644
--- a/runtime/art_method.h
+++ b/runtime/art_method.h
@@ -631,7 +631,7 @@ class ArtMethod final {
}
// Number of 32bit registers that would be required to hold all the arguments
- static size_t NumArgRegisters(const char* shorty);
+ static size_t NumArgRegisters(std::string_view shorty);
ALWAYS_INLINE uint32_t GetDexMethodIndex() const {
return dex_method_index_;
@@ -903,6 +903,8 @@ class ArtMethod final {
const char* GetShorty(uint32_t* out_length) REQUIRES_SHARED(Locks::mutator_lock_);
+ std::string_view GetShortyView() REQUIRES_SHARED(Locks::mutator_lock_);
+
const Signature GetSignature() REQUIRES_SHARED(Locks::mutator_lock_);
ALWAYS_INLINE const char* GetName() REQUIRES_SHARED(Locks::mutator_lock_);
diff --git a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
index 85e03f35ef..6ae475f849 100644
--- a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
+++ b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
@@ -309,15 +309,20 @@ class QuickArgumentVisitor {
return *reinterpret_cast<uintptr_t*>(GetCallingPcAddr(sp));
}
- QuickArgumentVisitor(ArtMethod** sp, bool is_static, const char* shorty,
- uint32_t shorty_len) REQUIRES_SHARED(Locks::mutator_lock_) :
- is_static_(is_static), shorty_(shorty), shorty_len_(shorty_len),
- gpr_args_(reinterpret_cast<uint8_t*>(sp) + kQuickCalleeSaveFrame_RefAndArgs_Gpr1Offset),
- fpr_args_(reinterpret_cast<uint8_t*>(sp) + kQuickCalleeSaveFrame_RefAndArgs_Fpr1Offset),
- stack_args_(reinterpret_cast<uint8_t*>(sp) + kQuickCalleeSaveFrame_RefAndArgs_FrameSize
- + sizeof(ArtMethod*)), // Skip ArtMethod*.
- gpr_index_(0), fpr_index_(0), fpr_double_index_(0), stack_index_(0),
- cur_type_(Primitive::kPrimVoid), is_split_long_or_double_(false) {
+ QuickArgumentVisitor(ArtMethod** sp, bool is_static, std::string_view shorty)
+ REQUIRES_SHARED(Locks::mutator_lock_)
+ : is_static_(is_static),
+ shorty_(shorty),
+ gpr_args_(reinterpret_cast<uint8_t*>(sp) + kQuickCalleeSaveFrame_RefAndArgs_Gpr1Offset),
+ fpr_args_(reinterpret_cast<uint8_t*>(sp) + kQuickCalleeSaveFrame_RefAndArgs_Fpr1Offset),
+ stack_args_(reinterpret_cast<uint8_t*>(sp) + kQuickCalleeSaveFrame_RefAndArgs_FrameSize +
+ sizeof(ArtMethod*)), // Skip ArtMethod*.
+ gpr_index_(0),
+ fpr_index_(0),
+ fpr_double_index_(0),
+ stack_index_(0),
+ cur_type_(Primitive::kPrimVoid),
+ is_split_long_or_double_(false) {
static_assert(kQuickSoftFloatAbi == (kNumQuickFprArgs == 0),
"Number of Quick FPR arguments unexpected");
static_assert(!(kQuickSoftFloatAbi && kQuickDoubleRegAlignedFloatBackFilled),
@@ -414,8 +419,8 @@ class QuickArgumentVisitor {
IncGprIndex();
}
}
- for (uint32_t shorty_index = 1; shorty_index < shorty_len_; ++shorty_index) {
- cur_type_ = Primitive::GetType(shorty_[shorty_index]);
+ for (char c : shorty_.substr(1u)) {
+ cur_type_ = Primitive::GetType(c);
switch (cur_type_) {
case Primitive::kPrimNot:
case Primitive::kPrimBoolean:
@@ -523,8 +528,7 @@ class QuickArgumentVisitor {
protected:
const bool is_static_;
- const char* const shorty_;
- const uint32_t shorty_len_;
+ const std::string_view shorty_;
private:
uint8_t* const gpr_args_; // Address of GPR arguments in callee save frame.
@@ -557,9 +561,12 @@ extern "C" mirror::Object* artQuickGetProxyThisObject(ArtMethod** sp)
// Visits arguments on the stack placing them into the shadow frame.
class BuildQuickShadowFrameVisitor final : public QuickArgumentVisitor {
public:
- BuildQuickShadowFrameVisitor(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) {}
+ BuildQuickShadowFrameVisitor(ArtMethod** sp,
+ bool is_static,
+ std::string_view shorty,
+ ShadowFrame* sf,
+ size_t first_arg_reg)
+ : QuickArgumentVisitor(sp, is_static, shorty), sf_(sf), cur_reg_(first_arg_reg) {}
void Visit() REQUIRES_SHARED(Locks::mutator_lock_) override;
@@ -690,8 +697,7 @@ extern "C" uint64_t artQuickToInterpreterBridge(ArtMethod* method, Thread* self,
ArtMethod* non_proxy_method = method->GetInterfaceMethodIfProxy(kRuntimePointerSize);
DCHECK(non_proxy_method->GetCodeItem() != nullptr) << method->PrettyMethod();
- uint32_t shorty_len = 0;
- const char* shorty = non_proxy_method->GetShorty(&shorty_len);
+ std::string_view shorty = non_proxy_method->GetShortyView();
ManagedStack fragment;
ShadowFrame* deopt_frame = self->MaybePopDeoptimizedStackedShadowFrame();
@@ -707,8 +713,8 @@ extern "C" uint64_t artQuickToInterpreterBridge(ArtMethod* method, Thread* self,
CREATE_SHADOW_FRAME(num_regs, method, /* dex_pc= */ 0);
ShadowFrame* shadow_frame = shadow_frame_unique_ptr.get();
size_t first_arg_reg = accessor.RegistersSize() - accessor.InsSize();
- BuildQuickShadowFrameVisitor shadow_frame_builder(sp, method->IsStatic(), shorty, shorty_len,
- shadow_frame, first_arg_reg);
+ BuildQuickShadowFrameVisitor shadow_frame_builder(
+ sp, method->IsStatic(), shorty, shadow_frame, first_arg_reg);
shadow_frame_builder.VisitArguments();
self->EndAssertNoThreadSuspension(old_cause);
@@ -739,7 +745,7 @@ extern "C" uint64_t artQuickToInterpreterBridge(ArtMethod* method, Thread* self,
// Push the context of the deoptimization stack so we can restore the return value and the
// exception before executing the deoptimized frames.
self->PushDeoptimizationContext(result,
- shorty[0] == 'L' || shorty[0] == '[', /* class or array */
+ shorty[0] == 'L' || shorty[0] == '[', // class or array
self->GetException(),
/* from_code= */ false,
DeoptimizationMethodType::kDefault);
@@ -756,9 +762,12 @@ extern "C" uint64_t artQuickToInterpreterBridge(ArtMethod* method, Thread* self,
// to jobjects.
class BuildQuickArgumentVisitor final : public QuickArgumentVisitor {
public:
- BuildQuickArgumentVisitor(ArtMethod** sp, bool is_static, const char* shorty, uint32_t shorty_len,
- ScopedObjectAccessUnchecked* soa, std::vector<jvalue>* args) :
- QuickArgumentVisitor(sp, is_static, shorty, shorty_len), soa_(soa), args_(args) {}
+ BuildQuickArgumentVisitor(ArtMethod** sp,
+ bool is_static,
+ std::string_view shorty,
+ ScopedObjectAccessUnchecked* soa,
+ std::vector<jvalue>* args)
+ : QuickArgumentVisitor(sp, is_static, shorty), soa_(soa), args_(args) {}
void Visit() REQUIRES_SHARED(Locks::mutator_lock_) override;
@@ -830,9 +839,9 @@ extern "C" uint64_t artQuickProxyInvokeHandler(
<< non_proxy_method->PrettyMethod();
std::vector<jvalue> args;
uint32_t shorty_len = 0;
- const char* shorty = non_proxy_method->GetShorty(&shorty_len);
- BuildQuickArgumentVisitor local_ref_visitor(
- sp, /* is_static= */ false, shorty, shorty_len, &soa, &args);
+ const char* raw_shorty = non_proxy_method->GetShorty(&shorty_len);
+ std::string_view shorty(raw_shorty, shorty_len);
+ BuildQuickArgumentVisitor local_ref_visitor(sp, /* is_static= */ false, shorty, &soa, &args);
local_ref_visitor.VisitArguments();
DCHECK_GT(args.size(), 0U) << proxy_method->PrettyMethod();
@@ -865,7 +874,8 @@ extern "C" uint64_t artQuickProxyInvokeHandler(
return 0;
}
}
- JValue result = InvokeProxyInvocationHandler(soa, shorty, rcvr_jobj, interface_method_jobj, args);
+ JValue result =
+ InvokeProxyInvocationHandler(soa, raw_shorty, rcvr_jobj, interface_method_jobj, args);
if (soa.Self()->IsExceptionPending()) {
if (instr->HasMethodUnwindListeners()) {
instr->MethodUnwindEvent(self,
@@ -885,16 +895,13 @@ extern "C" uint64_t artQuickProxyInvokeHandler(
// NOTE: Only used for testing purposes.
class GetQuickReferenceArgumentAtVisitor final : public QuickArgumentVisitor {
public:
- GetQuickReferenceArgumentAtVisitor(ArtMethod** sp,
- const char* shorty,
- uint32_t shorty_len,
- size_t arg_pos)
- : QuickArgumentVisitor(sp, /* is_static= */ false, shorty, shorty_len),
+ GetQuickReferenceArgumentAtVisitor(ArtMethod** sp, std::string_view shorty, size_t arg_pos)
+ : QuickArgumentVisitor(sp, /* is_static= */ false, shorty),
cur_pos_(0u),
arg_pos_(arg_pos),
ref_arg_(nullptr) {
- CHECK_LT(arg_pos, shorty_len) << "Argument position greater than the number arguments";
- }
+ CHECK_LT(arg_pos, shorty.length()) << "Argument position greater than the number arguments";
+ }
void Visit() REQUIRES_SHARED(Locks::mutator_lock_) override {
if (cur_pos_ == arg_pos_) {
@@ -929,9 +936,8 @@ extern "C" StackReference<mirror::Object>* artQuickGetProxyReferenceArgumentAt(s
ArtMethod* non_proxy_method = proxy_method->GetInterfaceMethodIfProxy(kRuntimePointerSize);
CHECK(!non_proxy_method->IsStatic())
<< proxy_method->PrettyMethod() << " " << non_proxy_method->PrettyMethod();
- uint32_t shorty_len = 0;
- const char* shorty = non_proxy_method->GetShorty(&shorty_len);
- GetQuickReferenceArgumentAtVisitor ref_arg_visitor(sp, shorty, shorty_len, arg_pos);
+ std::string_view shorty = non_proxy_method->GetShortyView();
+ GetQuickReferenceArgumentAtVisitor ref_arg_visitor(sp, shorty, arg_pos);
ref_arg_visitor.VisitArguments();
StackReference<mirror::Object>* ref_arg = ref_arg_visitor.GetReferenceArgument();
return ref_arg;
@@ -940,11 +946,8 @@ extern "C" StackReference<mirror::Object>* artQuickGetProxyReferenceArgumentAt(s
// Visitor returning all the reference arguments in a Quick stack frame.
class GetQuickReferenceArgumentsVisitor final : public QuickArgumentVisitor {
public:
- GetQuickReferenceArgumentsVisitor(ArtMethod** sp,
- bool is_static,
- const char* shorty,
- uint32_t shorty_len)
- : QuickArgumentVisitor(sp, is_static, shorty, shorty_len) {}
+ GetQuickReferenceArgumentsVisitor(ArtMethod** sp, bool is_static, std::string_view shorty)
+ : QuickArgumentVisitor(sp, is_static, shorty) {}
void Visit() REQUIRES_SHARED(Locks::mutator_lock_) override {
Primitive::Type type = GetParamPrimitiveType();
@@ -973,9 +976,8 @@ std::vector<StackReference<mirror::Object>*> GetProxyReferenceArguments(ArtMetho
ArtMethod* non_proxy_method = proxy_method->GetInterfaceMethodIfProxy(kRuntimePointerSize);
CHECK(!non_proxy_method->IsStatic())
<< proxy_method->PrettyMethod() << " " << non_proxy_method->PrettyMethod();
- uint32_t shorty_len = 0;
- const char* shorty = non_proxy_method->GetShorty(&shorty_len);
- GetQuickReferenceArgumentsVisitor ref_args_visitor(sp, /*is_static=*/ false, shorty, shorty_len);
+ std::string_view shorty = non_proxy_method->GetShortyView();
+ GetQuickReferenceArgumentsVisitor ref_args_visitor(sp, /*is_static=*/ false, shorty);
ref_args_visitor.VisitArguments();
std::vector<StackReference<mirror::Object>*> ref_args = ref_args_visitor.GetReferenceArguments();
return ref_args;
@@ -985,9 +987,11 @@ std::vector<StackReference<mirror::Object>*> GetProxyReferenceArguments(ArtMetho
// so they don't get garbage collected.
class RememberForGcArgumentVisitor final : public QuickArgumentVisitor {
public:
- RememberForGcArgumentVisitor(ArtMethod** sp, bool is_static, const char* shorty,
- uint32_t shorty_len, ScopedObjectAccessUnchecked* soa) :
- QuickArgumentVisitor(sp, is_static, shorty, shorty_len), soa_(soa) {}
+ RememberForGcArgumentVisitor(ArtMethod** sp,
+ bool is_static,
+ std::string_view shorty,
+ ScopedObjectAccessUnchecked* soa)
+ : QuickArgumentVisitor(sp, is_static, shorty), soa_(soa) {}
void Visit() REQUIRES_SHARED(Locks::mutator_lock_) override;
@@ -1200,10 +1204,9 @@ extern "C" const void* artQuickResolutionTrampoline(
called_method.dex_file = called->GetDexFile();
called_method.index = called->GetDexMethodIndex();
}
- uint32_t shorty_len;
- const char* shorty =
- called_method.dex_file->GetMethodShorty(called_method.GetMethodId(), &shorty_len);
- RememberForGcArgumentVisitor visitor(sp, invoke_type == kStatic, shorty, shorty_len, &soa);
+ std::string_view shorty =
+ called_method.dex_file->GetMethodShortyView(called_method.GetMethodId());
+ RememberForGcArgumentVisitor visitor(sp, invoke_type == kStatic, shorty, &soa);
visitor.VisitArguments();
self->EndAssertNoThreadSuspension(old_cause);
const bool virtual_or_interface = invoke_type == kVirtual || invoke_type == kInterface;
@@ -1644,13 +1647,13 @@ class ComputeNativeCallFrameSize {
[[maybe_unused]] BuildNativeCallFrameStateMachine<ComputeNativeCallFrameSize>* sm)
REQUIRES_SHARED(Locks::mutator_lock_) {}
- void Walk(const char* shorty, uint32_t shorty_len) REQUIRES_SHARED(Locks::mutator_lock_) {
+ void Walk(std::string_view shorty) REQUIRES_SHARED(Locks::mutator_lock_) {
BuildNativeCallFrameStateMachine<ComputeNativeCallFrameSize> sm(this);
WalkHeader(&sm);
- for (uint32_t i = 1; i < shorty_len; ++i) {
- Primitive::Type cur_type_ = Primitive::GetType(shorty[i]);
+ for (char c : shorty.substr(1u)) {
+ Primitive::Type cur_type_ = Primitive::GetType(c);
switch (cur_type_) {
case Primitive::kPrimNot:
sm.AdvancePointer(nullptr);
@@ -1705,11 +1708,11 @@ class ComputeGenericJniFrameSize final : public ComputeNativeCallFrameSize {
explicit ComputeGenericJniFrameSize(bool critical_native)
: critical_native_(critical_native) {}
- uintptr_t* ComputeLayout(ArtMethod** managed_sp, const char* shorty, uint32_t shorty_len)
+ uintptr_t* ComputeLayout(ArtMethod** managed_sp, std::string_view shorty)
REQUIRES_SHARED(Locks::mutator_lock_) {
DCHECK_EQ(Runtime::Current()->GetClassLinker()->GetImagePointerSize(), kRuntimePointerSize);
- Walk(shorty, shorty_len);
+ Walk(shorty);
// Add space for cookie.
DCHECK_ALIGNED(managed_sp, sizeof(uintptr_t));
@@ -1817,11 +1820,10 @@ class BuildGenericJniFrameVisitor final : public QuickArgumentVisitor {
BuildGenericJniFrameVisitor(Thread* self,
bool is_static,
bool critical_native,
- const char* shorty,
- uint32_t shorty_len,
+ std::string_view shorty,
ArtMethod** managed_sp,
uintptr_t* reserved_area)
- : QuickArgumentVisitor(managed_sp, is_static, shorty, shorty_len),
+ : QuickArgumentVisitor(managed_sp, is_static, shorty),
jni_call_(nullptr, nullptr, nullptr),
sm_(&jni_call_),
current_vreg_(nullptr) {
@@ -1829,7 +1831,7 @@ class BuildGenericJniFrameVisitor final : public QuickArgumentVisitor {
DCHECK_ALIGNED(reserved_area, sizeof(uintptr_t));
ComputeGenericJniFrameSize fsc(critical_native);
- uintptr_t* out_args_sp = fsc.ComputeLayout(managed_sp, shorty, shorty_len);
+ uintptr_t* out_args_sp = fsc.ComputeLayout(managed_sp, shorty);
// Store hidden argument for @CriticalNative.
uintptr_t* hidden_arg_slot = fsc.GetHiddenArgSlot(reserved_area);
@@ -1964,8 +1966,7 @@ extern "C" const void* artQuickGenericJniTrampoline(Thread* self,
ArtMethod* called = *managed_sp;
DCHECK(called->IsNative()) << called->PrettyMethod(true);
Runtime* runtime = Runtime::Current();
- uint32_t shorty_len = 0;
- const char* shorty = called->GetShorty(&shorty_len);
+ std::string_view shorty = called->GetShortyView();
bool critical_native = called->IsCriticalNative();
bool fast_native = called->IsFastNative();
bool normal_native = !critical_native && !fast_native;
@@ -1975,7 +1976,6 @@ extern "C" const void* artQuickGenericJniTrampoline(Thread* self,
called->IsStatic(),
critical_native,
shorty,
- shorty_len,
managed_sp,
reserved_area);
{
@@ -2118,12 +2118,12 @@ static TwoWordReturn artInvokeCommon(uint32_t method_idx,
return GetTwoWordFailureValue(); // Failure.
}
const DexFile* dex_file = caller_method->GetDexFile();
- uint32_t shorty_len;
- const char* shorty = dex_file->GetMethodShorty(dex_file->GetMethodId(method_idx), &shorty_len);
+ std::string_view shorty =
+ dex_file->GetMethodShortyView(dex_file->GetMethodId(method_idx));
{
// Remember the args in case a GC happens in FindMethodToCall.
ScopedObjectAccessUnchecked soa(self->GetJniEnv());
- RememberForGcArgumentVisitor visitor(sp, type == kStatic, shorty, shorty_len, &soa);
+ RememberForGcArgumentVisitor visitor(sp, type == kStatic, shorty, &soa);
visitor.VisitArguments();
method = FindMethodToCall<type>(self,
@@ -2231,13 +2231,12 @@ extern "C" TwoWordReturn artInvokeInterfaceTrampoline(ArtMethod* interface_metho
}
const DexFile& dex_file = *caller_method->GetDexFile();
- uint32_t shorty_len;
- const char* shorty = dex_file.GetMethodShorty(dex_file.GetMethodId(dex_method_idx),
- &shorty_len);
+ std::string_view shorty =
+ dex_file.GetMethodShortyView(dex_file.GetMethodId(dex_method_idx));
{
// Remember the args in case a GC happens in ClassLinker::ResolveMethod().
ScopedObjectAccessUnchecked soa(self->GetJniEnv());
- RememberForGcArgumentVisitor visitor(sp, false, shorty, shorty_len, &soa);
+ RememberForGcArgumentVisitor visitor(sp, false, shorty, &soa);
visitor.VisitArguments();
ClassLinker* class_linker = runtime->GetClassLinker();
interface_method = class_linker->ResolveMethod<ClassLinker::ResolveMode::kNoChecks>(
@@ -2342,10 +2341,9 @@ extern "C" uint64_t artInvokePolymorphic(mirror::Object* raw_receiver, Thread* s
DCHECK(inst.Opcode() == Instruction::INVOKE_POLYMORPHIC ||
inst.Opcode() == Instruction::INVOKE_POLYMORPHIC_RANGE);
const dex::ProtoIndex proto_idx(inst.VRegH());
- const char* shorty = caller_method->GetDexFile()->GetShorty(proto_idx);
- const size_t shorty_length = strlen(shorty);
+ std::string_view shorty = caller_method->GetDexFile()->GetShortyView(proto_idx);
static const bool kMethodIsStatic = false; // invoke() and invokeExact() are not static.
- RememberForGcArgumentVisitor gc_visitor(sp, kMethodIsStatic, shorty, shorty_length, &soa);
+ RememberForGcArgumentVisitor gc_visitor(sp, kMethodIsStatic, shorty, &soa);
gc_visitor.VisitArguments();
// Wrap raw_receiver in a Handle for safety.
@@ -2384,7 +2382,6 @@ extern "C" uint64_t artInvokePolymorphic(mirror::Object* raw_receiver, Thread* s
BuildQuickShadowFrameVisitor shadow_frame_builder(sp,
kMethodIsStatic,
shorty,
- strlen(shorty),
shadow_frame,
first_arg);
shadow_frame_builder.VisitArguments();
@@ -2467,8 +2464,7 @@ extern "C" uint64_t artInvokeCustom(uint32_t call_site_idx, Thread* self, ArtMet
ArtMethod* caller_method = QuickArgumentVisitor::GetCallingMethodAndDexPc(sp, &dex_pc);
const DexFile* dex_file = caller_method->GetDexFile();
const dex::ProtoIndex proto_idx(dex_file->GetProtoIndexForCallSite(call_site_idx));
- const char* shorty = caller_method->GetDexFile()->GetShorty(proto_idx);
- const uint32_t shorty_len = strlen(shorty);
+ std::string_view shorty = caller_method->GetDexFile()->GetShortyView(proto_idx);
// Construct the shadow frame placing arguments consecutively from |first_arg|.
const size_t first_arg = 0;
@@ -2480,7 +2476,6 @@ extern "C" uint64_t artInvokeCustom(uint32_t call_site_idx, Thread* self, ArtMet
BuildQuickShadowFrameVisitor shadow_frame_builder(sp,
kMethodIsStatic,
shorty,
- shorty_len,
shadow_frame,
first_arg);
shadow_frame_builder.VisitArguments();
diff --git a/runtime/interpreter/interpreter.cc b/runtime/interpreter/interpreter.cc
index 3ca531f89b..dcbf9ebf52 100644
--- a/runtime/interpreter/interpreter.cc
+++ b/runtime/interpreter/interpreter.cc
@@ -377,7 +377,7 @@ void EnterInterpreterFromInvoke(Thread* self,
return;
} else {
DCHECK(method->IsNative()) << method->PrettyMethod();
- num_regs = num_ins = ArtMethod::NumArgRegisters(method->GetShorty());
+ num_regs = num_ins = ArtMethod::NumArgRegisters(method->GetShortyView());
if (!method->IsStatic()) {
num_regs++;
num_ins++;