diff options
author | Ian Rogers <irogers@google.com> | 2013-05-06 13:25:44 -0700 |
---|---|---|
committer | Ian Rogers <irogers@google.com> | 2013-05-06 16:04:04 -0700 |
commit | 8a01a3a8caee37d4c4cf1a8c673f897c74aaf785 (patch) | |
tree | 2abfaf7d42e5aaabdc1faaeeda01f5a904fd64ed /src | |
parent | bf47e5f28b1aa39748dce8ac5abbabca1baee093 (diff) | |
download | art-8a01a3a8caee37d4c4cf1a8c673f897c74aaf785.tar.gz art-8a01a3a8caee37d4c4cf1a8c673f897c74aaf785.tar.bz2 art-8a01a3a8caee37d4c4cf1a8c673f897c74aaf785.zip |
Make ShadowFrame fields const when not in portable.
ShadowFrames in quick don't need the HasReferenceArray test as they always have
a reference array. Make the method_ and number_of_vregs_ fields const to aid
G++'s optimization of the interpreter.
Modify the OFFSETOF_MEMBER macro to handle const fields.
Change-Id: I696480789190f7c5190449b9c278d37853903a5e
Diffstat (limited to 'src')
-rw-r--r-- | src/base/macros.h | 2 | ||||
-rw-r--r-- | src/stack.h | 33 |
2 files changed, 32 insertions, 3 deletions
diff --git a/src/base/macros.h b/src/base/macros.h index 3a24c084c..8579872d5 100644 --- a/src/base/macros.h +++ b/src/base/macros.h @@ -120,7 +120,7 @@ char (&ArraySizeHelper(T (&array)[N]))[N]; #define SIZEOF_MEMBER(t, f) sizeof((reinterpret_cast<t*>(4096))->f) #define OFFSETOF_MEMBER(t, f) \ - (reinterpret_cast<char*>(&reinterpret_cast<t*>(16)->f) - reinterpret_cast<char*>(16)) // NOLINT + (reinterpret_cast<const char*>(&reinterpret_cast<t*>(16)->f) - reinterpret_cast<const char*>(16)) // NOLINT #define OFFSETOF_VOLATILE_MEMBER(t, f) \ (reinterpret_cast<volatile char*>(&reinterpret_cast<t*>(16)->f) - reinterpret_cast<volatile char*>(16)) // NOLINT diff --git a/src/stack.h b/src/stack.h index eb187b2b8..e2148a34d 100644 --- a/src/stack.h +++ b/src/stack.h @@ -71,15 +71,28 @@ class ShadowFrame { ~ShadowFrame() {} bool HasReferenceArray() const { +#if defined(ART_USE_PORTABLE_COMPILER) return (number_of_vregs_ & kHasReferenceArray) != 0; +#else + return true; +#endif } uint32_t NumberOfVRegs() const { +#if defined(ART_USE_PORTABLE_COMPILER) return number_of_vregs_ & ~kHasReferenceArray; +#else + return number_of_vregs_; +#endif } void SetNumberOfVRegs(uint32_t number_of_vregs) { +#if defined(ART_USE_PORTABLE_COMPILER) number_of_vregs_ = number_of_vregs | (number_of_vregs_ & kHasReferenceArray); +#else + UNUSED(number_of_vregs); + UNIMPLEMENTED(FATAL) << "Should only be called when portable is enabled"; +#endif } uint32_t GetDexPC() const { @@ -173,8 +186,13 @@ class ShadowFrame { ThrowLocation GetCurrentLocationForThrow() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void SetMethod(mirror::AbstractMethod* method) { +#if defined(ART_USE_PORTABLE_COMPILER) DCHECK_NE(method, static_cast<void*>(NULL)); method_ = method; +#else + UNUSED(method); + UNIMPLEMENTED(FATAL) << "Should only be called when portable is enabled"; +#endif } bool Contains(mirror::Object** shadow_frame_entry_obj) const { @@ -212,9 +230,11 @@ class ShadowFrame { ShadowFrame(uint32_t num_vregs, ShadowFrame* link, mirror::AbstractMethod* method, uint32_t dex_pc, bool has_reference_array) : number_of_vregs_(num_vregs), link_(link), method_(method), dex_pc_(dex_pc) { - CHECK_LT(num_vregs, static_cast<uint32_t>(kHasReferenceArray)); if (has_reference_array) { +#if defined(ART_USE_PORTABLE_COMPILER) + CHECK_LT(num_vregs, static_cast<uint32_t>(kHasReferenceArray)); number_of_vregs_ |= kHasReferenceArray; +#endif for (size_t i = 0; i < num_vregs; ++i) { SetVRegReference(i, NULL); } @@ -235,14 +255,23 @@ class ShadowFrame { return const_cast<mirror::Object**>(const_cast<const ShadowFrame*>(this)->References()); } +#if defined(ART_USE_PORTABLE_COMPILER) enum ShadowFrameFlag { kHasReferenceArray = 1ul << 31 }; - // TODO: make the majority of these fields const. + // TODO: make const in the portable case. uint32_t number_of_vregs_; +#else + const uint32_t number_of_vregs_; +#endif // Link to previous shadow frame or NULL. ShadowFrame* link_; +#if defined(ART_USE_PORTABLE_COMPILER) + // TODO: make const in the portable case. mirror::AbstractMethod* method_; +#else + mirror::AbstractMethod* const method_; +#endif uint32_t dex_pc_; uint32_t vregs_[0]; |