Commit 9da828a5 authored by verwaest@chromium.org's avatar verwaest@chromium.org

Move CopyReplaceDescriptors to private

BUG=
R=ishell@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20793 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 10714e29
......@@ -5756,16 +5756,7 @@ MaybeHandle<Object> JSObject::Freeze(Handle<JSObject> object) {
JSObject::MigrateToMap(object, transition_map);
} else if (object->HasFastProperties() && old_map->CanHaveMoreTransitions()) {
// Create a new descriptor array with fully-frozen properties
int num_descriptors = old_map->NumberOfOwnDescriptors();
Handle<DescriptorArray> new_descriptors =
DescriptorArray::CopyUpToAddAttributes(
handle(old_map->instance_descriptors()), num_descriptors, FROZEN);
Handle<Map> new_map = Map::CopyReplaceDescriptors(
old_map, new_descriptors, INSERT_TRANSITION,
isolate->factory()->frozen_symbol());
new_map->freeze();
new_map->set_is_extensible(false);
new_map->set_elements_kind(DICTIONARY_ELEMENTS);
Handle<Map> new_map = Map::CopyForFreeze(old_map);
JSObject::MigrateToMap(object, new_map);
} else {
// Slow path: need to normalize properties for safety
......@@ -6967,16 +6958,7 @@ Handle<Map> Map::ShareDescriptor(Handle<Map> map,
Handle<Map> Map::CopyReplaceDescriptors(Handle<Map> map,
Handle<DescriptorArray> descriptors,
TransitionFlag flag,
SimpleTransitionFlag simple_flag) {
return CopyReplaceDescriptors(
map, descriptors, flag, Handle<Name>::null(), simple_flag);
}
Handle<Map> Map::CopyReplaceDescriptors(Handle<Map> map,
Handle<DescriptorArray> descriptors,
TransitionFlag flag,
Handle<Name> name,
MaybeHandle<Name> maybe_name,
SimpleTransitionFlag simple_flag) {
ASSERT(descriptors->IsSortedNoDuplicates());
......@@ -6984,6 +6966,8 @@ Handle<Map> Map::CopyReplaceDescriptors(Handle<Map> map,
result->InitializeDescriptors(*descriptors);
if (flag == INSERT_TRANSITION && map->CanHaveMoreTransitions()) {
Handle<Name> name;
CHECK(maybe_name.ToHandle(&name));
Handle<TransitionArray> transitions = TransitionArray::CopyInsert(
map, name, result, simple_flag);
map->set_transitions(*transitions);
......@@ -7120,7 +7104,8 @@ Handle<Map> Map::Copy(Handle<Map> map) {
int number_of_own_descriptors = map->NumberOfOwnDescriptors();
Handle<DescriptorArray> new_descriptors =
DescriptorArray::CopyUpTo(descriptors, number_of_own_descriptors);
return CopyReplaceDescriptors(map, new_descriptors, OMIT_TRANSITION);
return CopyReplaceDescriptors(
map, new_descriptors, OMIT_TRANSITION, MaybeHandle<Name>());
}
......@@ -7153,6 +7138,20 @@ Handle<Map> Map::Create(Handle<JSFunction> constructor,
}
Handle<Map> Map::CopyForFreeze(Handle<Map> map) {
int num_descriptors = map->NumberOfOwnDescriptors();
Isolate* isolate = map->GetIsolate();
Handle<DescriptorArray> new_desc = DescriptorArray::CopyUpToAddAttributes(
handle(map->instance_descriptors(), isolate), num_descriptors, FROZEN);
Handle<Map> new_map = Map::CopyReplaceDescriptors(
map, new_desc, INSERT_TRANSITION, isolate->factory()->frozen_symbol());
new_map->freeze();
new_map->set_is_extensible(false);
new_map->set_elements_kind(DICTIONARY_ELEMENTS);
return new_map;
}
Handle<Map> Map::CopyAddDescriptor(Handle<Map> map,
Descriptor* descriptor,
TransitionFlag flag) {
......
......@@ -6398,17 +6398,6 @@ class Map: public HeapObject {
static Handle<Map> CurrentMapForDeprecatedInternal(Handle<Map> map);
static Handle<Map> CopyDropDescriptors(Handle<Map> map);
static Handle<Map> CopyReplaceDescriptors(
Handle<Map> map,
Handle<DescriptorArray> descriptors,
TransitionFlag flag,
Handle<Name> name,
SimpleTransitionFlag simple_flag = FULL_TRANSITION);
static Handle<Map> CopyReplaceDescriptors(
Handle<Map> map,
Handle<DescriptorArray> descriptors,
TransitionFlag flag,
SimpleTransitionFlag simple_flag = FULL_TRANSITION);
static Handle<Map> CopyInsertDescriptor(Handle<Map> map,
Descriptor* descriptor,
TransitionFlag flag);
......@@ -6441,6 +6430,8 @@ class Map: public HeapObject {
static Handle<Map> CopyForObserved(Handle<Map> map);
static Handle<Map> CopyForFreeze(Handle<Map> map);
static Handle<Map> CopyNormalized(Handle<Map> map,
PropertyNormalizationMode mode,
NormalizedMapSharingMode sharing);
......@@ -6686,6 +6677,12 @@ class Map: public HeapObject {
static Handle<Map> CopyAddDescriptor(Handle<Map> map,
Descriptor* descriptor,
TransitionFlag flag);
static Handle<Map> CopyReplaceDescriptors(
Handle<Map> map,
Handle<DescriptorArray> descriptors,
TransitionFlag flag,
MaybeHandle<Name> maybe_name,
SimpleTransitionFlag simple_flag = FULL_TRANSITION);
// Zaps the contents of backing data structures. Note that the
// heap verifier (i.e. VerifyMarkingVisitor) relies on zapping of objects
......
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