Reviewers: Jakob,
Message:
PTAL
Description:
Promote double arrays to FAST_ELEMENT that use generic KeyedLoadIC
BUG=none
TEST=none
Please review this at http://codereview.chromium.org/9111036/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/ic.cc
M src/runtime.cc
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");
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index
9da09fa85284929e2db5a750717bf29de3e92aaf..f2f430b9042c27e4cd4a7ea5e8c45539879b4d90
100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -4186,14 +4186,24 @@ RUNTIME_FUNCTION(MaybeObject*,
Runtime_KeyedGetProperty) {
// If value is the hole do the general lookup.
}
}
- } else if (FLAG_smi_only_arrays && args.at<Object>(1)->IsSmi()) {
+ } else if (args.at<Object>(1)->IsSmi()) {
+ // Getting properties from FAST_DOUBLE_ELEMENTS arrays causes
boxing. To
+ // proactively avoid excessive boxing, proactively transition
+ // FAST_DOUBLE_ELEMENTS arrays to FAST_ELEMENTS if they are accessed
via
+ // this function, which is called by the KeyedLoadIC::GenericStub.
+ Handle<JSObject> js_object(args.at<JSObject>(0));
+ if (js_object->HasFastDoubleElements()) {
+ MaybeObject* maybe_object =
+ js_object->TransitionElementsKind(FAST_ELEMENTS);
+ if (maybe_object->IsFailure()) return maybe_object;
+ }
+
// JSObject without a string key. If the key is a Smi, check for a
// definite out-of-bounds access to elements, which is a strong
indicator
// that subsequent accesses will also call the runtime. Proactively
// transition elements to FAST_ELEMENTS to avoid excessive boxing of
// doubles for those future calls in the case that the elements would
// become FAST_DOUBLE_ELEMENTS.
- Handle<JSObject> js_object(args.at<JSObject>(0));
ElementsKind elements_kind = js_object->GetElementsKind();
if (elements_kind == FAST_SMI_ONLY_ELEMENTS ||
elements_kind == FAST_DOUBLE_ELEMENTS) {
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev