Commit f08d2690 authored by verwaest@chromium.org's avatar verwaest@chromium.org

Fix Object.freeze with field type tracking.

Keep the descriptor properly intact while update the field type.

BUG=v8:3458
LOG=y
R=jkummerow@chromium.org

Review URL: https://codereview.chromium.org/424093002

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22671 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 947740a6
......@@ -2443,15 +2443,23 @@ Map* Map::FindFieldOwner(int descriptor) {
}
void Map::UpdateDescriptor(int descriptor_number, Descriptor* desc) {
void Map::UpdateFieldType(int descriptor, Handle<Name> name,
Handle<HeapType> new_type) {
DisallowHeapAllocation no_allocation;
PropertyDetails details = instance_descriptors()->GetDetails(descriptor);
if (!details.type() == FIELD) return;
if (HasTransitionArray()) {
TransitionArray* transitions = this->transitions();
for (int i = 0; i < transitions->number_of_transitions(); ++i) {
transitions->GetTarget(i)->UpdateDescriptor(descriptor_number, desc);
transitions->GetTarget(i)->UpdateFieldType(descriptor, name, new_type);
}
}
instance_descriptors()->Replace(descriptor_number, desc);;
// Skip if already updated the shared descriptor.
if (instance_descriptors()->GetFieldType(descriptor) == *new_type) return;
FieldDescriptor d(name, instance_descriptors()->GetFieldIndex(descriptor),
new_type, details.attributes(), details.representation());
instance_descriptors()->Replace(descriptor, &d);
;
}
......@@ -2502,12 +2510,8 @@ void Map::GeneralizeFieldType(Handle<Map> map,
old_field_type, new_field_type, isolate);
PropertyDetails details = descriptors->GetDetails(modify_index);
FieldDescriptor d(handle(descriptors->GetKey(modify_index), isolate),
descriptors->GetFieldIndex(modify_index),
new_field_type,
details.attributes(),
details.representation());
field_owner->UpdateDescriptor(modify_index, &d);
Handle<Name> name(descriptors->GetKey(modify_index));
field_owner->UpdateFieldType(modify_index, name, new_field_type);
field_owner->dependent_code()->DeoptimizeDependentCodeGroup(
isolate, DependentCode::kFieldTypeGroup);
......
......@@ -6773,7 +6773,8 @@ class Map: public HeapObject {
Map* FindLastMatchMap(int verbatim, int length, DescriptorArray* descriptors);
void UpdateDescriptor(int descriptor_number, Descriptor* desc);
void UpdateFieldType(int descriptor_number, Handle<Name> name,
Handle<HeapType> new_type);
void PrintGeneralization(FILE* file,
const char* reason,
......
// Copyright 2014 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 test(){
function InnerClass(){}
var container = {field: new InnerClass()};
return Object.freeze(container);
};
assertTrue(Object.isFrozen(test()));
assertTrue(Object.isFrozen(test()));
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment