Revision: 20716
Author: [email protected]
Date: Mon Apr 14 11:19:37 2014 UTC
Log: Clean up the public interface of Map.
BUG=
[email protected]
Review URL: https://codereview.chromium.org/234573005
http://code.google.com/p/v8/source/detail?r=20716
Modified:
/branches/bleeding_edge/src/objects-inl.h
/branches/bleeding_edge/src/objects.cc
/branches/bleeding_edge/src/objects.h
/branches/bleeding_edge/test/cctest/test-heap.cc
=======================================
--- /branches/bleeding_edge/src/objects-inl.h Mon Apr 14 09:19:09 2014 UTC
+++ /branches/bleeding_edge/src/objects-inl.h Mon Apr 14 11:19:37 2014 UTC
@@ -5024,19 +5024,6 @@
Object* value = READ_FIELD(this, kBitField3Offset);
return Smi::cast(value)->value();
}
-
-
-void Map::ClearTransitions(Heap* heap, WriteBarrierMode mode) {
- Object* back_pointer = GetBackPointer();
-
- if (Heap::ShouldZapGarbage() && HasTransitionArray()) {
- ZapTransitions();
- }
-
- WRITE_FIELD(this, kTransitionsOrBackPointerOffset, back_pointer);
- CONDITIONAL_WRITE_BARRIER(
- heap, this, kTransitionsOrBackPointerOffset, back_pointer, mode);
-}
void Map::AppendDescriptor(Descriptor* desc) {
@@ -5082,11 +5069,6 @@
TransitionArray::kTransitionSize)
<= Page::kMaxRegularHeapObjectSize;
}
-
-
-void Map::SetTransition(int transition_index, Map* target) {
- transitions()->SetTarget(transition_index, target);
-}
Map* Map::GetTransition(int transition_index) {
=======================================
--- /branches/bleeding_edge/src/objects.cc Mon Apr 14 09:19:09 2014 UTC
+++ /branches/bleeding_edge/src/objects.cc Mon Apr 14 11:19:37 2014 UTC
@@ -2607,7 +2607,7 @@
// 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);
@@ -6766,7 +6766,7 @@
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());
@@ -6811,7 +6811,7 @@
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);
@@ -6822,7 +6822,7 @@
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());
}
}
@@ -6847,7 +6847,7 @@
Handle<DescriptorArray>
descriptors,
TransitionFlag flag,
SimpleTransitionFlag simple_flag) {
- return Map::CopyReplaceDescriptors(
+ return CopyReplaceDescriptors(
map, descriptors, flag, Handle<Name>::null(), simple_flag);
}
@@ -6882,7 +6882,7 @@
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);
@@ -6930,7 +6930,7 @@
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);
@@ -6944,7 +6944,7 @@
// 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);
@@ -6966,9 +6966,9 @@
// 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(
@@ -6993,7 +6993,7 @@
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);
}
@@ -7037,14 +7037,14 @@
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);
}
@@ -7060,10 +7060,9 @@
// 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);
}
@@ -7139,8 +7138,7 @@
(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);
}
@@ -11510,7 +11508,7 @@
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.
@@ -11788,6 +11786,18 @@
stub->set_next_code_link(object_at(i));
set_object_at(i, *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,
@@ -11860,12 +11870,7 @@
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);
=======================================
--- /branches/bleeding_edge/src/objects.h Mon Apr 14 09:19:09 2014 UTC
+++ /branches/bleeding_edge/src/objects.h Mon Apr 14 11:19:37 2014 UTC
@@ -6209,21 +6209,13 @@
inline Map* elements_transition_map();
static Handle<TransitionArray> SetElementsTransitionMap(
Handle<Map> map, Handle<Map> transitioned_map);
- inline void SetTransition(int transition_index, Map* target);
inline Map* GetTransition(int transition_index);
inline int SearchTransition(Name* name);
inline FixedArrayBase* GetInitialElements();
DECL_ACCESSORS(transitions, TransitionArray)
- inline void ClearTransitions(Heap* heap,
- WriteBarrierMode mode =
UPDATE_WRITE_BARRIER);
-
- void DeprecateTransitionTree();
- void DeprecateTarget(Name* key, DescriptorArray* new_descriptors);
Map* FindRootMap();
- Map* FindUpdatedMap(int verbatim, int length, DescriptorArray*
descriptors);
- Map* FindLastMatchMap(int verbatim, int length, DescriptorArray*
descriptors);
inline int GetInObjectPropertyOffset(int index);
@@ -6248,15 +6240,6 @@
PropertyAttributes attributes,
const char* reason);
- void PrintGeneralization(FILE* file,
- const char* reason,
- int modify_index,
- int split,
- int descriptors,
- bool constant_to_field,
- Representation old_representation,
- Representation new_representation);
-
// Returns the constructor name (the name (possibly, inferred name) of
the
// function that was used to instantiate the object).
String* constructor_name();
@@ -6322,8 +6305,6 @@
// 2 + 2 * i: prototype
// 3 + 2 * i: target map
inline FixedArray* GetPrototypeTransitions();
- static inline void SetPrototypeTransitions(
- Handle<Map> map, Handle<FixedArray> prototype_transitions);
inline bool HasPrototypeTransitions();
static const int kProtoTransitionHeaderSize = 1;
@@ -6415,7 +6396,6 @@
// Same as above, but does not touch the prototype chain.
static Handle<Map> CurrentMapForDeprecatedInternal(Handle<Map> map);
- static Handle<Map> RawCopy(Handle<Map> map, int instance_size);
static Handle<Map> CopyDropDescriptors(Handle<Map> map);
static Handle<Map> CopyReplaceDescriptors(
Handle<Map> map,
@@ -6428,25 +6408,17 @@
Handle<DescriptorArray> descriptors,
TransitionFlag flag,
SimpleTransitionFlag simple_flag = FULL_TRANSITION);
- static Handle<Map> CopyInstallDescriptors(
- Handle<Map> map,
- int new_descriptor,
- Handle<DescriptorArray> descriptors);
- static Handle<Map> ShareDescriptor(Handle<Map> map,
- Handle<DescriptorArray> descriptors,
- Descriptor* descriptor);
static Handle<Map> CopyAddDescriptor(Handle<Map> map,
Descriptor* descriptor,
TransitionFlag flag);
static Handle<Map> CopyInsertDescriptor(Handle<Map> map,
Descriptor* descriptor,
TransitionFlag flag);
- static Handle<Map> CopyReplaceDescriptor(
- Handle<Map> map,
- Handle<DescriptorArray> descriptors,
- Descriptor* descriptor,
- int index,
- TransitionFlag flag);
+ static Handle<Map> CopyReplaceDescriptor(Handle<Map> map,
+ Handle<DescriptorArray>
descriptors,
+ Descriptor* descriptor,
+ int index,
+ TransitionFlag flag);
static Handle<Map> AsElementsKind(Handle<Map> map, ElementsKind kind);
@@ -6522,14 +6494,6 @@
// Computes a hash value for this map, to be used in HashTables and such.
int Hash();
- bool EquivalentToForTransition(Map* other);
-
- // Compares this map to another to see if they describe equivalent
objects.
- // If |mode| is set to CLEAR_INOBJECT_PROPERTIES, |other| is treated as
if
- // it had exactly zero inobject properties.
- // The "shared" flags of both this map and |other| are ignored.
- bool EquivalentToForNormalization(Map* other, PropertyNormalizationMode
mode);
-
// Returns the map that this map transitions to if its elements_kind
// is changed to |elements_kind|, or NULL if no such map is cached yet.
// |safe_to_add_transitions| is set to false if adding transitions is not
@@ -6542,15 +6506,6 @@
Handle<Map> FindTransitionedMap(MapHandleList* candidates);
Map* FindTransitionedMap(MapList* candidates);
- // Zaps the contents of backing data structures. Note that the
- // heap verifier (i.e. VerifyMarkingVisitor) relies on zapping of objects
- // holding weak references when incremental marking is used, because it
also
- // iterates over objects that are otherwise unreachable.
- // In general we only want to call these functions in release mode when
- // heap verification is turned on.
- void ZapPrototypeTransitions();
- void ZapTransitions();
-
bool CanTransition() {
// Only JSObject and subtypes have map transitions and back pointers.
STATIC_ASSERT(LAST_TYPE == LAST_JS_OBJECT_TYPE);
@@ -6611,11 +6566,8 @@
// transitions are in the form of a map where the keys are prototype
objects
// and the values are the maps the are transitioned to.
static const int kMaxCachedPrototypeTransitions = 256;
- static Handle<Map> GetPrototypeTransition(Handle<Map> map,
- Handle<Object> prototype);
- static Handle<Map> PutPrototypeTransition(Handle<Map> map,
- Handle<Object> prototype,
- Handle<Map> target_map);
+ static Handle<Map> TransitionToPrototype(Handle<Map> map,
+ Handle<Object> prototype);
static const int kMaxPreAllocatedPropertyFields = 255;
@@ -6699,7 +6651,57 @@
kPointerFieldsEndOffset,
kSize> BodyDescriptor;
+ // Compares this map to another to see if they describe equivalent
objects.
+ // If |mode| is set to CLEAR_INOBJECT_PROPERTIES, |other| is treated as
if
+ // it had exactly zero inobject properties.
+ // The "shared" flags of both this map and |other| are ignored.
+ bool EquivalentToForNormalization(Map* other, PropertyNormalizationMode
mode);
+
private:
+ bool EquivalentToForTransition(Map* other);
+ static Handle<Map> RawCopy(Handle<Map> map, int instance_size);
+ static Handle<Map> ShareDescriptor(Handle<Map> map,
+ Handle<DescriptorArray> descriptors,
+ Descriptor* descriptor);
+ static Handle<Map> CopyInstallDescriptors(
+ Handle<Map> map,
+ int new_descriptor,
+ Handle<DescriptorArray> descriptors);
+
+ // Zaps the contents of backing data structures. Note that the
+ // heap verifier (i.e. VerifyMarkingVisitor) relies on zapping of objects
+ // holding weak references when incremental marking is used, because it
also
+ // iterates over objects that are otherwise unreachable.
+ // In general we only want to call these functions in release mode when
+ // heap verification is turned on.
+ void ZapPrototypeTransitions();
+ void ZapTransitions();
+
+ void DeprecateTransitionTree();
+ void DeprecateTarget(Name* key, DescriptorArray* new_descriptors);
+
+ Map* FindUpdatedMap(int verbatim, int length, DescriptorArray*
descriptors);
+ Map* FindLastMatchMap(int verbatim, int length, DescriptorArray*
descriptors);
+
+ void PrintGeneralization(FILE* file,
+ const char* reason,
+ int modify_index,
+ int split,
+ int descriptors,
+ bool constant_to_field,
+ Representation old_representation,
+ Representation new_representation);
+
+ static inline void SetPrototypeTransitions(
+ Handle<Map> map,
+ Handle<FixedArray> prototype_transitions);
+
+ static Handle<Map> GetPrototypeTransition(Handle<Map> map,
+ Handle<Object> prototype);
+ static Handle<Map> PutPrototypeTransition(Handle<Map> map,
+ Handle<Object> prototype,
+ Handle<Map> target_map);
+
DISALLOW_IMPLICIT_CONSTRUCTORS(Map);
};
=======================================
--- /branches/bleeding_edge/test/cctest/test-heap.cc Mon Apr 14 08:58:00
2014 UTC
+++ /branches/bleeding_edge/test/cctest/test-heap.cc Mon Apr 14 11:19:37
2014 UTC
@@ -2072,10 +2072,6 @@
CHECK(!space->LastPage()->Contains(
map->GetPrototypeTransitions()->address()));
CHECK(space->LastPage()->Contains(prototype->address()));
- JSObject::SetPrototype(baseObject, prototype, false);
- CHECK(Map::GetPrototypeTransition(map, prototype)->IsMap());
- CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
- CHECK(Map::GetPrototypeTransition(map, prototype)->IsMap());
}
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.