ART: Change ArtMethod::NumArgRegisters() signature.
Take "const char*" instead of StringPiece. Avoid calling
strlen() in all callers, rely on explicit checking for
the end of the string.
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Bug: 123750182
Change-Id: I189841e4ae7dcc5950616d5e5a590987618146cb
diff --git a/runtime/art_method.cc b/runtime/art_method.cc
index 44b80df..c7e41be 100644
--- a/runtime/art_method.cc
+++ b/runtime/art_method.cc
@@ -22,7 +22,6 @@
#include "arch/context.h"
#include "art_method-inl.h"
-#include "base/stringpiece.h"
#include "class_linker-inl.h"
#include "class_root.h"
#include "debugger.h"
@@ -166,12 +165,11 @@
}
}
-size_t ArtMethod::NumArgRegisters(const StringPiece& shorty) {
- CHECK_LE(1U, shorty.length());
+size_t ArtMethod::NumArgRegisters(const char* shorty) {
+ CHECK_NE(shorty[0], '\0');
uint32_t num_registers = 0;
- for (size_t i = 1; i < shorty.length(); ++i) {
- char ch = shorty[i];
- if (ch == 'D' || ch == 'J') {
+ for (const char* s = shorty + 1; *s != '\0'; ++s) {
+ if (*s == 'D' || *s == 'J') {
num_registers += 2;
} else {
num_registers += 1;
diff --git a/runtime/art_method.h b/runtime/art_method.h
index aabd093..feff91a 100644
--- a/runtime/art_method.h
+++ b/runtime/art_method.h
@@ -49,7 +49,6 @@
class OatQuickMethodHeader;
class ProfilingInfo;
class ScopedObjectAccessAlreadyRunnable;
-class StringPiece;
class ShadowFrame;
namespace mirror {
@@ -386,7 +385,7 @@
}
// Number of 32bit registers that would be required to hold all the arguments
- static size_t NumArgRegisters(const StringPiece& shorty);
+ static size_t NumArgRegisters(const char* shorty);
ALWAYS_INLINE uint32_t GetDexMethodIndex() {
return dex_method_index_;