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

Unified Diff: src/ia32/lithium-ia32.cc

Issue 11299328: Implement basic array prefetching hints in Hydrogen. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 8 years 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 | « src/ia32/lithium-ia32.h ('k') | src/lithium-allocator-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ia32/lithium-ia32.cc
===================================================================
--- src/ia32/lithium-ia32.cc (revision 13123)
+++ src/ia32/lithium-ia32.cc (working copy)
@@ -422,6 +422,10 @@
} else {
stream->Add("]");
}
+ if (prefetch_distance() != NULL) {
+ stream->Add(" ");
+ prefetch_distance()->PrintTo(stream);
+ }
}
@@ -1958,6 +1962,23 @@
}
+static bool ShouldPrefetch(HValue* distance, ElementsKind elements_kind) {
+ bool should_prefetch = true;
+
+ if (distance->IsConstant()) {
+ HConstant* prefetch_distance = HConstant::cast(distance);
+ ASSERT(prefetch_distance->HasInteger32Value());
+ int32_t distance_value = prefetch_distance->Integer32Value();
+ if (distance_value < 0) distance_value = -distance_value;
+ // Omit the nearby accesses which are supposed to hit the cache.
+ should_prefetch =
+ (distance_value >= (64 >> ElementsKindToShiftSize(elements_kind)));
+ }
+
+ return should_prefetch;
+}
+
+
LInstruction* LChunkBuilder::DoLoadKeyed(HLoadKeyed* instr) {
ASSERT(instr->key()->representation().IsInteger32() ||
instr->key()->representation().IsTagged());
@@ -1969,9 +1990,17 @@
: UseRegisterOrConstantAtStart(instr->key());
LLoadKeyed* result = NULL;
+ LOperand* prefetch = NULL;
+ LOperand* temp = NULL;
+ if (instr->prefetch_distance() != graph()->GetConstantUndefined() &&
+ ShouldPrefetch(instr->prefetch_distance(), elements_kind)) {
+ prefetch = UseRegisterOrConstant(instr->prefetch_distance());
+ temp = TempRegister();
+ }
+
if (!instr->is_external()) {
LOperand* obj = UseRegisterAtStart(instr->elements());
- result = new(zone()) LLoadKeyed(obj, key);
+ result = new(zone()) LLoadKeyed(obj, key, prefetch, temp);
} else {
ASSERT(
(instr->representation().IsInteger32() &&
@@ -1981,7 +2010,7 @@
((elements_kind == EXTERNAL_FLOAT_ELEMENTS) ||
(elements_kind == EXTERNAL_DOUBLE_ELEMENTS))));
LOperand* external_pointer = UseRegister(instr->elements());
- result = new(zone()) LLoadKeyed(external_pointer, key);
+ result = new(zone()) LLoadKeyed(external_pointer, key, prefetch, temp);
}
DefineAsRegister(result);
« no previous file with comments | « src/ia32/lithium-ia32.h ('k') | src/lithium-allocator-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698