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

Unified Diff: src/elements.cc

Issue 2164573003: [turbofan] Introduce a TransitionElementsKind simplified operator. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix the runtime fallback. Created 4 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 | « src/elements.h ('k') | src/runtime/runtime-array.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/elements.cc
diff --git a/src/elements.cc b/src/elements.cc
index 3cf8378162844a1fc00525e3ccacdb6f47406ac5..031d5169290bab0c24da0d8b4537fae95b7b11b5 100644
--- a/src/elements.cc
+++ b/src/elements.cc
@@ -783,6 +783,45 @@ class ElementsAccessorBase : public ElementsAccessor {
return new_elements;
}
+ static void TransitionElementsKindImpl(Handle<JSObject> object,
+ Handle<Map> to_map) {
+ Handle<Map> from_map = handle(object->map());
+ ElementsKind from_kind = from_map->elements_kind();
+ ElementsKind to_kind = to_map->elements_kind();
+ if (IsFastHoleyElementsKind(from_kind)) {
+ to_kind = GetHoleyElementsKind(to_kind);
+ }
+ if (from_kind != to_kind) {
+ // This method should never be called for any other case.
+ DCHECK(IsFastElementsKind(from_kind));
+ DCHECK(IsFastElementsKind(to_kind));
+ DCHECK_NE(TERMINAL_FAST_ELEMENTS_KIND, from_kind);
+
+ Handle<FixedArrayBase> from_elements(object->elements());
+ if (object->elements() == object->GetHeap()->empty_fixed_array() ||
+ IsFastDoubleElementsKind(from_kind) ==
+ IsFastDoubleElementsKind(to_kind)) {
+ // No change is needed to the elements() buffer, the transition
+ // only requires a map change.
+ JSObject::MigrateToMap(object, to_map);
+ } else {
+ DCHECK((IsFastSmiElementsKind(from_kind) &&
+ IsFastDoubleElementsKind(to_kind)) ||
+ (IsFastDoubleElementsKind(from_kind) &&
+ IsFastObjectElementsKind(to_kind)));
+ uint32_t capacity = static_cast<uint32_t>(object->elements()->length());
+ Handle<FixedArrayBase> elements = ConvertElementsWithCapacity(
+ object, from_elements, from_kind, capacity);
+ JSObject::SetMapAndElements(object, to_map, elements);
+ }
+ if (FLAG_trace_elements_transitions) {
+ JSObject::PrintElementsTransition(stdout, object, from_kind,
+ from_elements, to_kind,
+ handle(object->elements()));
+ }
+ }
+ }
+
static void GrowCapacityAndConvertImpl(Handle<JSObject> object,
uint32_t capacity) {
ElementsKind from_kind = object->GetElementsKind();
@@ -822,6 +861,10 @@ class ElementsAccessorBase : public ElementsAccessor {
}
}
+ void TransitionElementsKind(Handle<JSObject> object, Handle<Map> map) final {
+ Subclass::TransitionElementsKindImpl(object, map);
+ }
+
void GrowCapacityAndConvert(Handle<JSObject> object,
uint32_t capacity) final {
Subclass::GrowCapacityAndConvertImpl(object, capacity);
@@ -2255,6 +2298,11 @@ class SloppyArgumentsElementsAccessor
}
}
+ static void TransitionElementsKindImpl(Handle<JSObject> object,
+ Handle<Map> map) {
+ UNREACHABLE();
+ }
+
static void GrowCapacityAndConvertImpl(Handle<JSObject> object,
uint32_t capacity) {
UNREACHABLE();
« no previous file with comments | « src/elements.h ('k') | src/runtime/runtime-array.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698