summaryrefslogtreecommitdiff
path: root/runtime/stack.cc
diff options
context:
space:
mode:
author David Brazdil <dbrazdil@google.com> 2015-05-29 16:29:43 +0100
committer David Brazdil <dbrazdil@google.com> 2015-06-04 17:25:02 +0100
commitf677ebfd832c9c614fea5e6735725fec2f7a3f2a (patch)
tree051b3ba6343bdbca4929d728dd5c0341e4383a08 /runtime/stack.cc
parentc47908e8c32fd58bc4dc75998a80f706954db1dc (diff)
Cache stack map encoding
Operations on CodeInfo and StackMap objects repeatedly read encoding information from the MemoryRegion. Since these are 3-bit-loads of values that never change, caching them can measurably reduce compile times. According to benchmarks, this patch saves 1-3% on armv7, 2-4% on x86, and 0-1% on x64. Change-Id: I46b197513601325d8bab562cc80100c00ec28a3b
Diffstat (limited to 'runtime/stack.cc')
-rw-r--r--runtime/stack.cc41
1 files changed, 26 insertions, 15 deletions
diff --git a/runtime/stack.cc b/runtime/stack.cc
index 411088794a..5aeca98a88 100644
--- a/runtime/stack.cc
+++ b/runtime/stack.cc
@@ -113,9 +113,10 @@ InlineInfo StackVisitor::GetCurrentInlineInfo() const {
ArtMethod* outer_method = *GetCurrentQuickFrame();
uint32_t native_pc_offset = outer_method->NativeQuickPcOffset(cur_quick_frame_pc_);
CodeInfo code_info = outer_method->GetOptimizedCodeInfo();
- StackMap stack_map = code_info.GetStackMapForNativePcOffset(native_pc_offset);
+ StackMapEncoding encoding = code_info.ExtractEncoding();
+ StackMap stack_map = code_info.GetStackMapForNativePcOffset(native_pc_offset, encoding);
DCHECK(stack_map.IsValid());
- return code_info.GetInlineInfoOf(stack_map);
+ return code_info.GetInlineInfoOf(stack_map, encoding);
}
ArtMethod* StackVisitor::GetMethod() const {
@@ -274,34 +275,40 @@ bool StackVisitor::GetVRegFromOptimizedCode(ArtMethod* m, uint16_t vreg, VRegKin
const void* code_pointer = outer_method->GetQuickOatCodePointer(sizeof(void*));
DCHECK(code_pointer != nullptr);
CodeInfo code_info = outer_method->GetOptimizedCodeInfo();
+ StackMapEncoding encoding = code_info.ExtractEncoding();
uint32_t native_pc_offset = outer_method->NativeQuickPcOffset(cur_quick_frame_pc_);
- StackMap stack_map = code_info.GetStackMapForNativePcOffset(native_pc_offset);
+ StackMap stack_map = code_info.GetStackMapForNativePcOffset(native_pc_offset, encoding);
DCHECK(stack_map.IsValid());
size_t depth_in_stack_map = current_inlining_depth_ - 1;
DexRegisterMap dex_register_map = IsInInlinedFrame()
- ? code_info.GetDexRegisterMapAtDepth(
- depth_in_stack_map, code_info.GetInlineInfoOf(stack_map), number_of_dex_registers)
- : code_info.GetDexRegisterMapOf(stack_map, number_of_dex_registers);
+ ? code_info.GetDexRegisterMapAtDepth(depth_in_stack_map,
+ code_info.GetInlineInfoOf(stack_map, encoding),
+ encoding,
+ number_of_dex_registers)
+ : code_info.GetDexRegisterMapOf(stack_map, encoding, number_of_dex_registers);
DexRegisterLocation::Kind location_kind =
- dex_register_map.GetLocationKind(vreg, number_of_dex_registers, code_info);
+ dex_register_map.GetLocationKind(vreg, number_of_dex_registers, code_info, encoding);
switch (location_kind) {
case DexRegisterLocation::Kind::kInStack: {
- const int32_t offset =
- dex_register_map.GetStackOffsetInBytes(vreg, number_of_dex_registers, code_info);
+ const int32_t offset = dex_register_map.GetStackOffsetInBytes(vreg,
+ number_of_dex_registers,
+ code_info,
+ encoding);
const uint8_t* addr = reinterpret_cast<const uint8_t*>(cur_quick_frame_) + offset;
*val = *reinterpret_cast<const uint32_t*>(addr);
return true;
}
case DexRegisterLocation::Kind::kInRegister:
case DexRegisterLocation::Kind::kInFpuRegister: {
- uint32_t reg = dex_register_map.GetMachineRegister(vreg, number_of_dex_registers, code_info);
+ uint32_t reg =
+ dex_register_map.GetMachineRegister(vreg, number_of_dex_registers, code_info, encoding);
return GetRegisterIfAccessible(reg, kind, val);
}
case DexRegisterLocation::Kind::kConstant:
- *val = dex_register_map.GetConstant(vreg, number_of_dex_registers, code_info);
+ *val = dex_register_map.GetConstant(vreg, number_of_dex_registers, code_info, encoding);
return true;
case DexRegisterLocation::Kind::kNone:
return false;
@@ -309,7 +316,10 @@ bool StackVisitor::GetVRegFromOptimizedCode(ArtMethod* m, uint16_t vreg, VRegKin
LOG(FATAL)
<< "Unexpected location kind"
<< DexRegisterLocation::PrettyDescriptor(
- dex_register_map.GetLocationInternalKind(vreg, number_of_dex_registers, code_info));
+ dex_register_map.GetLocationInternalKind(vreg,
+ number_of_dex_registers,
+ code_info,
+ encoding));
UNREACHABLE();
}
}
@@ -782,10 +792,11 @@ void StackVisitor::WalkStack(bool include_transitions) {
if ((walk_kind_ == StackWalkKind::kIncludeInlinedFrames)
&& method->IsOptimized(sizeof(void*))) {
CodeInfo code_info = method->GetOptimizedCodeInfo();
+ StackMapEncoding encoding = code_info.ExtractEncoding();
uint32_t native_pc_offset = method->NativeQuickPcOffset(cur_quick_frame_pc_);
- StackMap stack_map = code_info.GetStackMapForNativePcOffset(native_pc_offset);
- if (stack_map.IsValid() && stack_map.HasInlineInfo(code_info)) {
- InlineInfo inline_info = code_info.GetInlineInfoOf(stack_map);
+ StackMap stack_map = code_info.GetStackMapForNativePcOffset(native_pc_offset, encoding);
+ if (stack_map.IsValid() && stack_map.HasInlineInfo(encoding)) {
+ InlineInfo inline_info = code_info.GetInlineInfoOf(stack_map, encoding);
DCHECK_EQ(current_inlining_depth_, 0u);
for (current_inlining_depth_ = inline_info.GetDepth();
current_inlining_depth_ != 0;