Index: src/arm/lithium-codegen-arm.cc |
diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc |
index 4564d2684ec06f1699911c6d29a3158fc145657a..353f8f2d669a33058eb009421f549609675bbb06 100644 |
--- a/src/arm/lithium-codegen-arm.cc |
+++ b/src/arm/lithium-codegen-arm.cc |
@@ -83,6 +83,9 @@ void LCodeGen::FinishCode(Handle<Code> code) { |
ASSERT(is_done()); |
code->set_stack_slots(GetStackSlotCount()); |
code->set_safepoint_table_offset(safepoints_.GetCodeOffset()); |
+ if (FLAG_weak_embedded_maps_in_optimized_code) { |
+ RegisterDependentCodeForEmbeddedMaps(code); |
+ } |
PopulateDeoptimizationData(code); |
} |
@@ -864,6 +867,31 @@ void LCodeGen::DeoptimizeIf(Condition cc, LEnvironment* environment) { |
} |
+void LCodeGen::RegisterDependentCodeForEmbeddedMaps(Handle<Code> code) { |
+ ZoneList<Handle<Map> > maps(1, zone()); |
+ int mode_mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT); |
+ for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) { |
+ RelocInfo::Mode mode = it.rinfo()->rmode(); |
+ if (mode == RelocInfo::EMBEDDED_OBJECT && |
+ it.rinfo()->target_object()->IsMap()) { |
+ Handle<Map> map(Map::cast(it.rinfo()->target_object())); |
+ if (map->CanTransition()) { |
+ maps.Add(map, zone()); |
+ } |
+ } |
+ } |
+#ifdef VERIFY_HEAP |
+ // This disables verification of weak embedded maps after full GC. |
+ // AddDependentCode can cause a GC, which would observe the state where |
+ // this code is not yet in the depended code lists of the embedded maps. |
+ NoWeakEmbeddedMapsVerificationScope disable_verification_of_embedded_maps; |
+#endif |
+ for (int i = 0; i < maps.length(); i++) { |
+ maps.at(i)->AddDependentCode(code); |
+ } |
+} |
+ |
+ |
void LCodeGen::PopulateDeoptimizationData(Handle<Code> code) { |
int length = deoptimizations_.length(); |
if (length == 0) return; |