Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Unified Diff: src/arm/assembler-arm.cc

Issue 376973002: [Arm]: Optimize ConstantPoolBuilder::Populate code by minimizing calls to OffsetOfElementAt (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/objects.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/arm/assembler-arm.cc
diff --git a/src/arm/assembler-arm.cc b/src/arm/assembler-arm.cc
index a441bc3bcc0498194872c4eb7ceb3ab515aa40e7..dc57cf4744a673a7846bd80f029001192e1dd905 100644
--- a/src/arm/assembler-arm.cc
+++ b/src/arm/assembler-arm.cc
@@ -3586,7 +3586,6 @@ ConstantPoolArray::LayoutSection ConstantPoolBuilder::AddEntry(
rmode != RelocInfo::STATEMENT_POSITION &&
rmode != RelocInfo::CONST_POOL);
-
// Try to merge entries which won't be patched.
int merged_index = -1;
ConstantPoolArray::LayoutSection entry_section = current_section_;
@@ -3656,8 +3655,22 @@ void ConstantPoolBuilder::Populate(Assembler* assm,
constant_pool, ConstantPoolArray::EXTENDED_SECTION)));
}
- ConstantPoolArray::NumberOfEntries small_idx;
- ConstantPoolArray::NumberOfEntries extended_idx;
+ // Set up initial offsets.
+ int offsets[ConstantPoolArray::NUMBER_OF_LAYOUT_SECTIONS]
+ [ConstantPoolArray::NUMBER_OF_TYPES];
+ for (int section = 0; section <= constant_pool->final_section(); section++) {
+ int section_start = (section == ConstantPoolArray::EXTENDED_SECTION)
+ ? small_entries()->total_count()
+ : 0;
+ for (int i = 0; i < ConstantPoolArray::NUMBER_OF_TYPES; i++) {
+ ConstantPoolArray::Type type = static_cast<ConstantPoolArray::Type>(i);
+ if (number_of_entries_[section].count_of(type) != 0) {
+ offsets[section][type] = constant_pool->OffsetOfElementAt(
+ number_of_entries_[section].base_of(type) + section_start);
+ }
+ }
+ }
+
for (std::vector<ConstantPoolEntry>::iterator entry = entries_.begin();
entry != entries_.end(); entry++) {
RelocInfo rinfo = entry->rinfo_;
@@ -3667,27 +3680,21 @@ void ConstantPoolBuilder::Populate(Assembler* assm,
// Update constant pool if necessary and get the entry's offset.
int offset;
if (entry->merged_index_ == -1) {
- int index;
- if (entry->section_ == ConstantPoolArray::EXTENDED_SECTION) {
- index = small_entries()->total_count() +
- extended_entries()->base_of(type) + extended_idx.count_of(type);
- extended_idx.increment(type);
- } else {
- ASSERT(entry->section_ == ConstantPoolArray::SMALL_SECTION);
- index = small_entries()->base_of(type) + small_idx.count_of(type);
- small_idx.increment(type);
- }
+ offset = offsets[entry->section_][type];
+ offsets[entry->section_][type] += ConstantPoolArray::entry_size(type);
if (type == ConstantPoolArray::INT64) {
- constant_pool->set(index, rinfo.data64());
+ constant_pool->set_at_offset(offset, rinfo.data64());
} else if (type == ConstantPoolArray::INT32) {
- constant_pool->set(index, static_cast<int32_t>(rinfo.data()));
+ constant_pool->set_at_offset(offset, rinfo.data());
} else if (type == ConstantPoolArray::CODE_PTR) {
- constant_pool->set(index, reinterpret_cast<Address>(rinfo.data()));
+ constant_pool->set_at_offset(offset,
+ reinterpret_cast<Address>(rinfo.data()));
} else {
ASSERT(type == ConstantPoolArray::HEAP_PTR);
- constant_pool->set(index, reinterpret_cast<Object*>(rinfo.data()));
+ constant_pool->set_at_offset(offset,
+ reinterpret_cast<Object*>(rinfo.data()));
}
- offset = constant_pool->OffsetOfElementAt(index) - kHeapObjectTag;
+ offset -= kHeapObjectTag;
entry->merged_index_ = offset; // Stash offset for merged entries.
} else {
ASSERT(entry->merged_index_ < (entry - entries_.begin()));
@@ -3724,9 +3731,6 @@ void ConstantPoolBuilder::Populate(Assembler* assm,
rinfo.pc(), Assembler::SetLdrRegisterImmediateOffset(instr, offset));
}
}
-
- ASSERT(small_idx.equals(*small_entries()));
- ASSERT(extended_idx.equals(*extended_entries()));
}
« no previous file with comments | « no previous file | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698