Reviewers: danno,
Message:
PTAL
Description:
Update deprecated maps before generating optimized code.
Please review this at https://chromiumcodereview.appspot.com/14847008/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/objects-inl.h
M src/objects.h
M src/stub-cache.h
M src/stub-cache.cc
M src/type-info.cc
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index
29474b99fd5901cd4e8e9e27fb21a95e84edfd6a..68c99a236456ba941e4d824c3a9cfa7b924ed0f1
100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -3610,6 +3610,12 @@ bool Map::CanBeDeprecated() {
}
+Handle<Map> Map::Update(Handle<Map> map) {
+ if (!map->is_deprecated()) return map;
+ return GeneralizeRepresentation(map, 0, Representation::Smi());
+}
+
+
void Map::NotifyLeafMapLayoutChange() {
dependent_code()->DeoptimizeDependentCodeGroup(
GetIsolate(),
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index
4b5b51d9d90e2363c3542c877a5489f8ddb7203d..9bfcfb73d783fe747bd559cf1f68c3d3abeead29
100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -5344,6 +5344,7 @@ class Map: public HeapObject {
inline void deprecate();
inline bool is_deprecated();
inline bool CanBeDeprecated();
+ static inline Handle<Map> Update(Handle<Map> map);
MUST_USE_RESULT MaybeObject* RawCopy(int instance_size);
MUST_USE_RESULT MaybeObject* CopyWithPreallocatedFieldDescriptors();
Index: src/stub-cache.cc
diff --git a/src/stub-cache.cc b/src/stub-cache.cc
index
63748779b11c59a75f08aa77eb778ecc3f367277..9e6f01515f87d76909b4ecc144d90d564dcf7e09
100644
--- a/src/stub-cache.cc
+++ b/src/stub-cache.cc
@@ -1058,46 +1058,51 @@ void StubCache::Clear() {
}
+static void AddMapIfMissing(Handle<Map> map, SmallMapList* list,
+ Zone* zone) {
+ map = Map::Update(map);
+ for (int i = 0; i < list->length(); ++i) {
+ if (list->at(i).is_identical_to(map)) return;
+ }
+ list->Add(map, zone);
+}
+
+
void StubCache::CollectMatchingMaps(SmallMapList* types,
- Name* name,
+ Handle<Name> name,
Code::Flags flags,
Handle<Context> native_context,
Zone* zone) {
for (int i = 0; i < kPrimaryTableSize; i++) {
- if (primary_[i].key == name) {
+ if (primary_[i].key == *name) {
Map* map = primary_[i].map;
// Map can be NULL, if the stub is constant function call
// with a primitive receiver.
if (map == NULL) continue;
- int offset = PrimaryOffset(name, flags, map);
+ int offset = PrimaryOffset(*name, flags, map);
if (entry(primary_, offset) == &primary_[i] &&
!TypeFeedbackOracle::CanRetainOtherContext(map,
*native_context)) {
- types->Add(Handle<Map>(map), zone);
+ AddMapIfMissing(Handle<Map>(map), types, zone);
}
}
}
for (int i = 0; i < kSecondaryTableSize; i++) {
- if (secondary_[i].key == name) {
+ if (secondary_[i].key == *name) {
Map* map = secondary_[i].map;
// Map can be NULL, if the stub is constant function call
// with a primitive receiver.
if (map == NULL) continue;
// Lookup in primary table and skip duplicates.
- int primary_offset = PrimaryOffset(name, flags, map);
- Entry* primary_entry = entry(primary_, primary_offset);
- if (primary_entry->key == name) {
- Map* primary_map = primary_entry->map;
- if (map == primary_map) continue;
- }
+ int primary_offset = PrimaryOffset(*name, flags, map);
// Lookup in secondary table and add matches.
- int offset = SecondaryOffset(name, flags, primary_offset);
+ int offset = SecondaryOffset(*name, flags, primary_offset);
if (entry(secondary_, offset) == &secondary_[i] &&
!TypeFeedbackOracle::CanRetainOtherContext(map,
*native_context)) {
- types->Add(Handle<Map>(map), zone);
+ AddMapIfMissing(Handle<Map>(map), types, zone);
}
}
}
Index: src/stub-cache.h
diff --git a/src/stub-cache.h b/src/stub-cache.h
index
6a08d956946de185fa52d19e32855940c6aa21df..84f7f932b46a824235ab2ded8882f7f23dfe4ff5
100644
--- a/src/stub-cache.h
+++ b/src/stub-cache.h
@@ -311,7 +311,7 @@ class StubCache {
// Collect all maps that match the name and flags.
void CollectMatchingMaps(SmallMapList* types,
- Name* name,
+ Handle<Name> name,
Code::Flags flags,
Handle<Context> native_context,
Zone* zone);
Index: src/type-info.cc
diff --git a/src/type-info.cc b/src/type-info.cc
index
3bc509a6189a93068ee2f50b6f0a90d9aeffef67..6cda351dd8a7c5152f4cbbccd9644a2dc9782757
100644
--- a/src/type-info.cc
+++ b/src/type-info.cc
@@ -541,6 +541,7 @@ TypeInfo
TypeFeedbackOracle::IncrementType(CountOperation* expr) {
static void AddMapIfMissing(Handle<Map> map, SmallMapList* list,
Zone* zone) {
+ map = Map::Update(map);
for (int i = 0; i < list->length(); ++i) {
if (list->at(i).is_identical_to(map)) return;
}
@@ -574,7 +575,7 @@ void
TypeFeedbackOracle::CollectReceiverTypes(TypeFeedbackId ast_id,
// we need a generic store (or load) here.
ASSERT(Handle<Code>::cast(object)->ic_state() == GENERIC);
} else if (object->IsMap()) {
- types->Add(Handle<Map>::cast(object), zone());
+ AddMapIfMissing(Handle<Map>::cast(object), types, zone());
} else if (Handle<Code>::cast(object)->ic_state() == POLYMORPHIC) {
CollectPolymorphicMaps(Handle<Code>::cast(object), types);
} else if (FLAG_collect_megamorphic_maps_from_stub_cache &&
@@ -582,7 +583,7 @@ void
TypeFeedbackOracle::CollectReceiverTypes(TypeFeedbackId ast_id,
types->Reserve(4, zone());
ASSERT(object->IsCode());
isolate_->stub_cache()->CollectMatchingMaps(types,
- *name,
+ name,
flags,
native_context_,
zone());
--
--
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/groups/opt_out.