Reviewers: Kevin Millikin,
Description:
Fix GVN for polymorphic loads.
They must not be hoisted above the compare-map-and-branch.
Please review this at http://codereview.chromium.org/5971003/
SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/
Affected files:
M src/hydrogen-instructions.h
M src/hydrogen.h
M src/hydrogen.cc
Index: src/hydrogen-instructions.h
===================================================================
--- src/hydrogen-instructions.h (revision 6079)
+++ src/hydrogen-instructions.h (working copy)
@@ -2552,7 +2552,8 @@
HLoadNamedField(HValue* object, bool is_in_object, int offset)
: HUnaryOperation(object),
is_in_object_(is_in_object),
- offset_(offset) {
+ offset_(offset),
+ is_polymorphic_(false) {
set_representation(Representation::Tagged());
SetFlag(kUseGVN);
if (is_in_object) {
@@ -2566,6 +2567,9 @@
bool is_in_object() const { return is_in_object_; }
int offset() const { return offset_; }
+ bool is_polymorphic() const { return is_polymorphic_; }
+ void set_is_polymorphic(bool b) { is_polymorphic_ = b; }
+
virtual Representation RequiredInputRepresentation(int index) const {
return Representation::Tagged();
}
@@ -2582,6 +2586,7 @@
private:
bool is_in_object_;
int offset_;
+ bool is_polymorphic_;
};
Index: src/hydrogen.cc
===================================================================
--- src/hydrogen.cc (revision 6079)
+++ src/hydrogen.cc (working copy)
@@ -1455,6 +1455,13 @@
HBasicBlock* loop_header) {
if (!instr->IsChange() &&
FLAG_aggressive_loop_invariant_motion) return true;
+
+ // Don't hoist named loads that are part of polymorphic loads.
+ if (instr->IsLoadNamedField() &&
+ HLoadNamedField::cast(instr)->is_polymorphic()) {
+ return false;
+ }
+
HBasicBlock* block = instr->block();
bool result = true;
if (block != loop_header) {
@@ -3532,9 +3539,10 @@
maps.Add(map);
HSubgraph* subgraph = CreateBranchSubgraph(environment());
SubgraphScope scope(this, subgraph);
- HInstruction* instr =
+ HLoadNamedField* instr =
BuildLoadNamedField(object, expr, map, &lookup, false);
instr->set_position(expr->position());
+ instr->set_is_polymorphic(true);
PushAndAdd(instr);
subgraphs.Add(subgraph);
} else {
@@ -3573,11 +3581,11 @@
}
-HInstruction* HGraphBuilder::BuildLoadNamedField(HValue* object,
- Property* expr,
- Handle<Map> type,
- LookupResult* lookup,
- bool smi_and_map_check) {
+HLoadNamedField* HGraphBuilder::BuildLoadNamedField(HValue* object,
+ Property* expr,
+ Handle<Map> type,
+ LookupResult* lookup,
+ bool
smi_and_map_check) {
if (smi_and_map_check) {
AddInstruction(new HCheckNonSmi(object));
AddInstruction(new HCheckMap(object, type));
Index: src/hydrogen.h
===================================================================
--- src/hydrogen.h (revision 6079)
+++ src/hydrogen.h (working copy)
@@ -786,11 +786,11 @@
HValue* left,
HValue* right);
HInstruction* BuildIncrement(HValue* value, bool increment);
- HInstruction* BuildLoadNamedField(HValue* object,
- Property* expr,
- Handle<Map> type,
- LookupResult* result,
- bool smi_and_map_check);
+ HLoadNamedField* BuildLoadNamedField(HValue* object,
+ Property* expr,
+ Handle<Map> type,
+ LookupResult* result,
+ bool smi_and_map_check);
HInstruction* BuildLoadNamedGeneric(HValue* object, Property* expr);
HInstruction* BuildLoadKeyedFastElement(HValue* object,
HValue* key,
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev