From: bmeurer@chromium.org Date: Tue, 10 Jun 2014 12:24:54 +0000 (+0000) Subject: Fix invalid attributes when generalizing because of incompatible map change. X-Git-Tag: upstream/4.7.83~8756 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0fcd89161bb3615c8a2f6b95a1bcbe875f3117e6;p=platform%2Fupstream%2Fv8.git Fix invalid attributes when generalizing because of incompatible map change. BUG=382143 LOG=y TEST=mjsunit/regress/regress-382143 R=verwaest@chromium.org Review URL: https://codereview.chromium.org/324933003 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@21743 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/objects.cc b/src/objects.cc index 3f9a9ca..6fa9054 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -2416,6 +2416,18 @@ Handle Map::CopyGeneralizeAllRepresentations(Handle map, } +// static +Handle Map::CopyGeneralizeAllRepresentations(Handle map, + int modify_index, + StoreMode store_mode, + const char* reason) { + PropertyDetails details = + map->instance_descriptors()->GetDetails(modify_index); + return CopyGeneralizeAllRepresentations(map, modify_index, store_mode, + details.attributes(), reason); +} + + void Map::DeprecateTransitionTree() { if (is_deprecated()) return; if (HasTransitionArray()) { @@ -2661,8 +2673,8 @@ Handle Map::GeneralizeRepresentation(Handle old_map, // Check the state of the root map. Handle root_map(old_map->FindRootMap(), isolate); if (!old_map->EquivalentToForTransition(*root_map)) { - return CopyGeneralizeAllRepresentations(old_map, modify_index, store_mode, - old_details.attributes(), "not equivalent"); + return CopyGeneralizeAllRepresentations( + old_map, modify_index, store_mode, "not equivalent"); } int root_nof = root_map->NumberOfOwnDescriptors(); if (modify_index < root_nof) { @@ -2671,8 +2683,8 @@ Handle Map::GeneralizeRepresentation(Handle old_map, (old_details.type() == FIELD && (!new_field_type->NowIs(old_descriptors->GetFieldType(modify_index)) || !new_representation.fits_into(old_details.representation())))) { - return CopyGeneralizeAllRepresentations(old_map, modify_index, store_mode, - old_details.attributes(), "root modification"); + return CopyGeneralizeAllRepresentations( + old_map, modify_index, store_mode, "root modification"); } } @@ -2694,8 +2706,7 @@ Handle Map::GeneralizeRepresentation(Handle old_map, (tmp_type != old_type || tmp_descriptors->GetValue(i) != old_descriptors->GetValue(i)))) { return CopyGeneralizeAllRepresentations( - old_map, modify_index, store_mode, - old_details.attributes(), "incompatible"); + old_map, modify_index, store_mode, "incompatible"); } Representation old_representation = old_details.representation(); Representation tmp_representation = tmp_details.representation(); @@ -2759,8 +2770,7 @@ Handle Map::GeneralizeRepresentation(Handle old_map, (tmp_details.type() != old_details.type() || tmp_descriptors->GetValue(i) != old_descriptors->GetValue(i)))) { return CopyGeneralizeAllRepresentations( - old_map, modify_index, store_mode, - old_details.attributes(), "incompatible"); + old_map, modify_index, store_mode, "incompatible"); } target_map = tmp_map; } @@ -2803,6 +2813,7 @@ Handle Map::GeneralizeRepresentation(Handle old_map, target_details = target_details.CopyWithRepresentation( new_representation.generalize(target_details.representation())); } + ASSERT_EQ(old_details.attributes(), target_details.attributes()); if (old_details.type() == FIELD || target_details.type() == FIELD || (modify_index == i && store_mode == FORCE_FIELD) || diff --git a/src/objects.h b/src/objects.h index 0ba12ba..1bce728 100644 --- a/src/objects.h +++ b/src/objects.h @@ -6367,6 +6367,11 @@ class Map: public HeapObject { StoreMode store_mode, PropertyAttributes attributes, const char* reason); + static Handle CopyGeneralizeAllRepresentations( + Handle map, + int modify_index, + StoreMode store_mode, + const char* reason); static Handle Normalize(Handle map, PropertyNormalizationMode mode); diff --git a/test/mjsunit/regress/regress-crbug-382143.js b/test/mjsunit/regress/regress-crbug-382143.js new file mode 100644 index 0000000..9f37b2e --- /dev/null +++ b/test/mjsunit/regress/regress-crbug-382143.js @@ -0,0 +1,16 @@ +// Copyright 2013 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +function A() { + Object.defineProperty(this, "x", { set: function () {}, get: function () {}}); + this.a = function () { return 1; } +} + +function B() { + A.apply( this ); + this.a = function () { return 2; } +} + +var b = new B(); +assertTrue(Object.getOwnPropertyDescriptor(b, "a").enumerable);