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

Unified Diff: src/lookup.cc

Issue 1237953002: Simplify PrepareForDataProperty in the IsElement case (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Only used to modify an existing value, so don't make holey Created 5 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/lookup.cc
diff --git a/src/lookup.cc b/src/lookup.cc
index 3acc6e2a00ed76825174a5e4e5f9e3ed46b2274d..3738c2ed4a0bfae90455482f75445b81956ba00d 100644
--- a/src/lookup.cc
+++ b/src/lookup.cc
@@ -132,29 +132,15 @@ void LookupIterator::PrepareForDataProperty(Handle<Object> value) {
Handle<JSObject> holder = GetHolder<JSObject>();
if (IsElement()) {
- ElementsKind old_kind = holder_map_->elements_kind();
- holder_map_ = Map::PrepareForDataElement(holder_map_, value);
- ElementsKind new_kind = holder_map_->elements_kind();
- if (new_kind != old_kind) {
- // TODO(verwaest): Handle element migration in MigrateToMap.
- JSObject::UpdateAllocationSite(holder, new_kind);
- if (IsFastDoubleElementsKind(old_kind) !=
- IsFastDoubleElementsKind(new_kind)) {
- uint32_t capacity = holder->elements()->length();
- ElementsAccessor* accessor = ElementsAccessor::ForKind(new_kind);
- accessor->GrowCapacityAndConvert(holder, capacity);
- // GrowCapacityAndConvert migrated the object. No reloading of property
- // infomation is necessary for elements.
- return;
- } else if (FLAG_trace_elements_transitions) {
- Handle<FixedArrayBase> elements(holder->elements());
- JSObject::PrintElementsTransition(stdout, holder, old_kind, elements,
- new_kind, elements);
- }
- }
+ ElementsKind kind = holder_map_->elements_kind();
+ ElementsKind to = value->OptimalElementsKind();
+ if (IsHoleyElementsKind(kind)) to = GetHoleyElementsKind(to);
+ to = IsMoreGeneralElementsKindTransition(kind, to) ? to : kind;
+ JSObject::TransitionElementsKind(holder, to);
+ holder_map_ = handle(holder->map(), isolate_);
// Copy the backing store if it is copy-on-write.
- if (IsFastSmiOrObjectElementsKind(new_kind)) {
+ if (IsFastSmiOrObjectElementsKind(to)) {
JSObject::EnsureWritableFastElements(holder);
}
« 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