Index: src/ic.cc |
diff --git a/src/ic.cc b/src/ic.cc |
index 9024605da54a6f111f54d180732906a083166807..b68fd38dced16b27eb7702e07df31ce5956c8915 100644 |
--- a/src/ic.cc |
+++ b/src/ic.cc |
@@ -1,4 +1,4 @@ |
-// Copyright 2011 the V8 project authors. All rights reserved. |
+// Copyright 2012 the V8 project authors. All rights reserved. |
// Redistribution and use in source and binary forms, with or without |
// modification, are permitted provided that the following conditions are |
// met: |
@@ -1120,6 +1120,17 @@ MaybeObject* KeyedLoadIC::Load(State state, |
} else if (key->IsSmi() && (target() != *non_strict_arguments_stub())) { |
stub = ComputeStub(receiver, LOAD, kNonStrictMode, stub); |
} |
+ // If the IC is being replaced by the generic stub, loads from |
+ // FAST_DOUBLE_ELEMENTS arrays will cause unboxing in Crankshafted |
+ // code. To prevent these expensive allocations, proactively promote |
+ // arrays to FAST_ELEMENTS ElementKinds. |
+ if (*stub == *generic_stub()) { |
+ if (receiver->HasFastDoubleElements()) { |
+ MaybeObject* maybe_object = |
+ receiver->TransitionElementsKind(FAST_ELEMENTS); |
+ if (maybe_object->IsFailure()) return maybe_object; |
+ } |
+ } |
} |
} else { |
TRACE_GENERIC_IC("KeyedLoadIC", "force generic"); |