diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h index 63ee683d74..9b7a95b2f0 100644 --- a/src/hydrogen-instructions.h +++ b/src/hydrogen-instructions.h @@ -1898,10 +1898,14 @@ class HLoadExternalArrayPointer: public HUnaryOperation { }; -class HCheckMap: public HUnaryOperation { +class HCheckMap: public HTemplateInstruction<2> { public: - HCheckMap(HValue* value, Handle map) - : HUnaryOperation(value), map_(map) { + HCheckMap(HValue* value, Handle map, HValue* typecheck = NULL) + : map_(map) { + SetOperandAt(0, value); + // If callers don't depend on a typecheck, they can pass in NULL. In that + // case we use a copy of the |value| argument as a dummy value. + SetOperandAt(1, typecheck != NULL ? typecheck : value); set_representation(Representation::Tagged()); SetFlag(kUseGVN); SetFlag(kDependsOnMaps); @@ -1913,6 +1917,7 @@ class HCheckMap: public HUnaryOperation { virtual void PrintDataTo(StringStream* stream); virtual HType CalculateInferredType(); + HValue* value() { return OperandAt(0); } Handle map() const { return map_; } DECLARE_CONCRETE_INSTRUCTION(CheckMap) diff --git a/src/hydrogen.cc b/src/hydrogen.cc index 69a060df56..d03aa5d2f6 100644 --- a/src/hydrogen.cc +++ b/src/hydrogen.cc @@ -3911,7 +3911,7 @@ HInstruction* HGraphBuilder::BuildMonomorphicElementAccess(HValue* object, HInstruction* mapcheck = AddInstruction(new(zone()) HCheckMap(object, map)); HInstruction* elements = AddInstruction(new(zone()) HLoadElements(object)); bool fast_double_elements = map->has_fast_double_elements(); - if (is_store && !fast_double_elements) { + if (is_store && map->has_fast_elements()) { AddInstruction(new(zone()) HCheckMap( elements, isolate()->factory()->fixed_array_map())); } @@ -4022,9 +4022,10 @@ HValue* HGraphBuilder::HandlePolymorphicElementAccess(HValue* object, elements_kind == JSObject::FAST_DOUBLE_ELEMENTS) { bool fast_double_elements = elements_kind == JSObject::FAST_DOUBLE_ELEMENTS; - if (is_store && !fast_double_elements) { + if (is_store && elements_kind == JSObject::FAST_ELEMENTS) { AddInstruction(new(zone()) HCheckMap( - elements, isolate()->factory()->fixed_array_map())); + elements, isolate()->factory()->fixed_array_map(), + elements_kind_branch)); } HBasicBlock* if_jsarray = graph()->CreateBasicBlock(); HBasicBlock* if_fastobject = graph()->CreateBasicBlock();