}
-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) {
DescriptorArray* descriptors = instance_descriptors();
int number_of_own_descriptors = NumberOfOwnDescriptors();
}
-void Map::SetTransition(int transition_index, Map* target) {
- transitions()->SetTarget(transition_index, target);
-}
-
-
Map* Map::GetTransition(int transition_index) {
return transitions()->GetTarget(transition_index);
}
// 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);
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());
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);
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());
}
}
Handle<DescriptorArray> descriptors,
TransitionFlag flag,
SimpleTransitionFlag simple_flag) {
- return Map::CopyReplaceDescriptors(
+ return CopyReplaceDescriptors(
map, descriptors, flag, Handle<Name>::null(), simple_flag);
}
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);
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);
// 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);
// 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(
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);
}
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);
}
// 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);
}
(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);
}
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.
}
+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) {
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);
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);
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();
// 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;
// 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,
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);
// 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
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);
// 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;
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);
};
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());
}