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

Unified Diff: src/objects.cc

Issue 234573005: Clean up the public interface of Map. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 8 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/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index aaa03203ae444987ec954edb1d4e19012e0791c5..070779df209cb5df432527a689bb9ec40c597ff4 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -2635,7 +2635,7 @@ Handle<Map> Map::GeneralizeRepresentation(Handle<Map> old_map,
// Add missing transitions.
Handle<Map> new_map = split_map;
for (; descriptor < descriptors; descriptor++) {
- new_map = Map::CopyInstallDescriptors(new_map, descriptor, new_descriptors);
+ new_map = CopyInstallDescriptors(new_map, descriptor, new_descriptors);
}
new_map->set_owns_descriptors(true);
@@ -6794,7 +6794,7 @@ Handle<Map> Map::CopyNormalized(Handle<Map> map,
new_instance_size -= map->inobject_properties() * kPointerSize;
}
- Handle<Map> result = Map::RawCopy(map, new_instance_size);
+ Handle<Map> result = RawCopy(map, new_instance_size);
if (mode != CLEAR_INOBJECT_PROPERTIES) {
result->set_inobject_properties(map->inobject_properties());
@@ -6839,7 +6839,7 @@ Handle<Map> Map::ShareDescriptor(Handle<Map> map,
ASSERT(map->NumberOfOwnDescriptors() ==
map->instance_descriptors()->number_of_descriptors());
- Handle<Map> result = Map::CopyDropDescriptors(map);
+ Handle<Map> result = CopyDropDescriptors(map);
Handle<Name> name = descriptor->GetKey();
Handle<TransitionArray> transitions =
TransitionArray::CopyInsert(map, name, result, SIMPLE_TRANSITION);
@@ -6850,7 +6850,7 @@ Handle<Map> Map::ShareDescriptor(Handle<Map> map,
if (old_size == 0) {
descriptors = DescriptorArray::Allocate(map->GetIsolate(), 0, 1);
} else {
- Map::EnsureDescriptorSlack(map, old_size < 4 ? 1 : old_size / 2);
+ EnsureDescriptorSlack(map, old_size < 4 ? 1 : old_size / 2);
descriptors = handle(map->instance_descriptors());
}
}
@@ -6875,7 +6875,7 @@ Handle<Map> Map::CopyReplaceDescriptors(Handle<Map> map,
Handle<DescriptorArray> descriptors,
TransitionFlag flag,
SimpleTransitionFlag simple_flag) {
- return Map::CopyReplaceDescriptors(
+ return CopyReplaceDescriptors(
map, descriptors, flag, Handle<Name>::null(), simple_flag);
}
@@ -6910,7 +6910,7 @@ Handle<Map> Map::CopyInstallDescriptors(Handle<Map> map,
Handle<DescriptorArray> descriptors) {
ASSERT(descriptors->IsSortedNoDuplicates());
- Handle<Map> result = Map::CopyDropDescriptors(map);
+ Handle<Map> result = CopyDropDescriptors(map);
result->InitializeDescriptors(*descriptors);
result->SetNumberOfOwnDescriptors(new_descriptor + 1);
@@ -6958,7 +6958,7 @@ Handle<Map> Map::CopyAsElementsKind(Handle<Map> map, ElementsKind kind,
if (insert_transition && map->owns_descriptors()) {
// In case the map owned its own descriptors, share the descriptors and
// transfer ownership to the new map.
- Handle<Map> new_map = Map::CopyDropDescriptors(map);
+ Handle<Map> new_map = CopyDropDescriptors(map);
SetElementsTransitionMap(map, new_map);
@@ -6972,7 +6972,7 @@ Handle<Map> Map::CopyAsElementsKind(Handle<Map> map, ElementsKind kind,
// In case the map did not own its own descriptors, a split is forced by
// copying the map; creating a new descriptor array cell.
// Create a new free-floating map only if we are not allowed to store it.
- Handle<Map> new_map = Map::Copy(map);
+ Handle<Map> new_map = Copy(map);
new_map->set_elements_kind(kind);
@@ -6994,9 +6994,9 @@ Handle<Map> Map::CopyForObserved(Handle<Map> map) {
// transfer ownership to the new map.
Handle<Map> new_map;
if (map->owns_descriptors()) {
- new_map = Map::CopyDropDescriptors(map);
+ new_map = CopyDropDescriptors(map);
} else {
- new_map = Map::Copy(map);
+ new_map = Copy(map);
}
Handle<TransitionArray> transitions = TransitionArray::CopyInsert(
@@ -7021,7 +7021,7 @@ 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 Map::CopyReplaceDescriptors(map, new_descriptors, OMIT_TRANSITION);
+ return CopyReplaceDescriptors(map, new_descriptors, OMIT_TRANSITION);
}
@@ -7065,14 +7065,14 @@ Handle<Map> Map::CopyAddDescriptor(Handle<Map> map,
if (flag == INSERT_TRANSITION &&
map->owns_descriptors() &&
map->CanHaveMoreTransitions()) {
- return Map::ShareDescriptor(map, descriptors, descriptor);
+ return ShareDescriptor(map, descriptors, descriptor);
}
Handle<DescriptorArray> new_descriptors = DescriptorArray::CopyUpTo(
descriptors, map->NumberOfOwnDescriptors(), 1);
new_descriptors->Append(descriptor);
- return Map::CopyReplaceDescriptors(
+ return CopyReplaceDescriptors(
map, new_descriptors, flag, descriptor->GetKey(), SIMPLE_TRANSITION);
}
@@ -7088,10 +7088,9 @@ Handle<Map> Map::CopyInsertDescriptor(Handle<Map> map,
// We replace the key if it is already present.
int index = old_descriptors->SearchWithCache(*descriptor->GetKey(), *map);
if (index != DescriptorArray::kNotFound) {
- return Map::CopyReplaceDescriptor(
- map, old_descriptors, descriptor, index, flag);
+ return CopyReplaceDescriptor(map, old_descriptors, descriptor, index, flag);
}
- return Map::CopyAddDescriptor(map, descriptor, flag);
+ return CopyAddDescriptor(map, descriptor, flag);
}
@@ -7167,8 +7166,7 @@ Handle<Map> Map::CopyReplaceDescriptor(Handle<Map> map,
(insertion_index == descriptors->number_of_descriptors() - 1)
? SIMPLE_TRANSITION
: FULL_TRANSITION;
- return Map::CopyReplaceDescriptors(
- map, new_descriptors, flag, key, simple_flag);
+ return CopyReplaceDescriptors(map, new_descriptors, flag, key, simple_flag);
}
@@ -11533,7 +11531,7 @@ Handle<Map> Map::PutPrototypeTransition(Handle<Map> map,
Factory* factory = map->GetIsolate()->factory();
cache = factory->CopySizeFixedArray(cache, transitions * 2 * step + header);
- Map::SetPrototypeTransitions(map, cache);
+ SetPrototypeTransitions(map, cache);
}
// Reload number of transitions as GC might shrink them.
@@ -11813,6 +11811,18 @@ void DependentCode::AddToDependentICList(Handle<Code> stub) {
}
+Handle<Map> Map::TransitionToPrototype(Handle<Map> map,
+ Handle<Object> prototype) {
+ Handle<Map> new_map = GetPrototypeTransition(map, prototype);
+ if (new_map.is_null()) {
+ new_map = Copy(map);
+ PutPrototypeTransition(map, prototype, new_map);
+ new_map->set_prototype(*prototype);
+ }
+ return new_map;
+}
+
+
Handle<Object> JSObject::SetPrototype(Handle<JSObject> object,
Handle<Object> value,
bool skip_hidden_prototypes) {
@@ -11883,12 +11893,7 @@ Handle<Object> JSObject::SetPrototype(Handle<JSObject> object,
JSObject::OptimizeAsPrototype(Handle<JSObject>::cast(value));
}
- Handle<Map> new_map = Map::GetPrototypeTransition(map, value);
- if (new_map.is_null()) {
- new_map = Map::Copy(map);
- Map::PutPrototypeTransition(map, value, new_map);
- new_map->set_prototype(*value);
- }
+ Handle<Map> new_map = Map::TransitionToPrototype(map, value);
ASSERT(new_map->prototype() == *value);
JSObject::MigrateToMap(real_receiver, new_map);
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698