Avoid adding HWrapReceiver during graph building.

This adds an early check to the graph builder which prevents adding an
HWrapReceiver instruction if the receiver type is already known at graph
building time. Also HAllocate no longer unnecessarily postpones setting
it's type until type inference but sets it right away. These changes are
in preparation for escape analysis.

R=titzer@chromium.org

Review URL: https://codereview.chromium.org/19493005

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15843 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent b7369c38
...@@ -3244,11 +3244,6 @@ HType HStringCharFromCode::CalculateInferredType() { ...@@ -3244,11 +3244,6 @@ HType HStringCharFromCode::CalculateInferredType() {
} }
HType HAllocate::CalculateInferredType() {
return type_;
}
void HAllocate::HandleSideEffectDominator(GVNFlag side_effect, void HAllocate::HandleSideEffectDominator(GVNFlag side_effect,
HValue* dominator) { HValue* dominator) {
ASSERT(side_effect == kChangesNewSpacePromotion); ASSERT(side_effect == kChangesNewSpacePromotion);
......
...@@ -4919,10 +4919,10 @@ class HAllocate: public HTemplateInstruction<2> { ...@@ -4919,10 +4919,10 @@ class HAllocate: public HTemplateInstruction<2> {
}; };
HAllocate(HValue* context, HValue* size, HType type, Flags flags) HAllocate(HValue* context, HValue* size, HType type, Flags flags)
: type_(type), : flags_(flags) {
flags_(flags) {
SetOperandAt(0, context); SetOperandAt(0, context);
SetOperandAt(1, size); SetOperandAt(1, size);
set_type(type);
set_representation(Representation::Tagged()); set_representation(Representation::Tagged());
SetFlag(kTrackSideEffectDominators); SetFlag(kTrackSideEffectDominators);
SetGVNFlag(kChangesNewSpacePromotion); SetGVNFlag(kChangesNewSpacePromotion);
...@@ -4947,7 +4947,6 @@ class HAllocate: public HTemplateInstruction<2> { ...@@ -4947,7 +4947,6 @@ class HAllocate: public HTemplateInstruction<2> {
HValue* context() { return OperandAt(0); } HValue* context() { return OperandAt(0); }
HValue* size() { return OperandAt(1); } HValue* size() { return OperandAt(1); }
HType type() { return type_; }
virtual Representation RequiredInputRepresentation(int index) { virtual Representation RequiredInputRepresentation(int index) {
if (index == 0) { if (index == 0) {
...@@ -4965,8 +4964,6 @@ class HAllocate: public HTemplateInstruction<2> { ...@@ -4965,8 +4964,6 @@ class HAllocate: public HTemplateInstruction<2> {
known_initial_map_ = known_initial_map; known_initial_map_ = known_initial_map;
} }
virtual HType CalculateInferredType();
bool CanAllocateInNewSpace() const { bool CanAllocateInNewSpace() const {
return (flags_ & CAN_ALLOCATE_IN_NEW_SPACE) != 0; return (flags_ & CAN_ALLOCATE_IN_NEW_SPACE) != 0;
} }
...@@ -5012,7 +5009,6 @@ class HAllocate: public HTemplateInstruction<2> { ...@@ -5012,7 +5009,6 @@ class HAllocate: public HTemplateInstruction<2> {
DECLARE_CONCRETE_INSTRUCTION(Allocate) DECLARE_CONCRETE_INSTRUCTION(Allocate)
private: private:
HType type_;
Flags flags_; Flags flags_;
Handle<Map> known_initial_map_; Handle<Map> known_initial_map_;
}; };
...@@ -5021,10 +5017,10 @@ class HAllocate: public HTemplateInstruction<2> { ...@@ -5021,10 +5017,10 @@ class HAllocate: public HTemplateInstruction<2> {
class HInnerAllocatedObject: public HTemplateInstruction<1> { class HInnerAllocatedObject: public HTemplateInstruction<1> {
public: public:
HInnerAllocatedObject(HValue* value, int offset, HType type = HType::Tagged()) HInnerAllocatedObject(HValue* value, int offset, HType type = HType::Tagged())
: offset_(offset), : offset_(offset) {
type_(type) {
ASSERT(value->IsAllocate()); ASSERT(value->IsAllocate());
SetOperandAt(0, value); SetOperandAt(0, value);
set_type(type);
set_representation(Representation::Tagged()); set_representation(Representation::Tagged());
} }
...@@ -5035,15 +5031,12 @@ class HInnerAllocatedObject: public HTemplateInstruction<1> { ...@@ -5035,15 +5031,12 @@ class HInnerAllocatedObject: public HTemplateInstruction<1> {
return Representation::Tagged(); return Representation::Tagged();
} }
virtual HType CalculateInferredType() { return type_; }
virtual void PrintDataTo(StringStream* stream); virtual void PrintDataTo(StringStream* stream);
DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject) DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject)
private: private:
int offset_; int offset_;
HType type_;
}; };
......
...@@ -1040,14 +1040,19 @@ void HGraphBuilder::PadEnvironmentForContinuation( ...@@ -1040,14 +1040,19 @@ void HGraphBuilder::PadEnvironmentForContinuation(
} }
HValue* HGraphBuilder::BuildCheckMap(HValue* obj, HValue* HGraphBuilder::BuildCheckMap(HValue* obj, Handle<Map> map) {
Handle<Map> map) {
HCheckMaps* check = HCheckMaps::New(obj, map, zone(), top_info()); HCheckMaps* check = HCheckMaps::New(obj, map, zone(), top_info());
AddInstruction(check); AddInstruction(check);
return check; return check;
} }
HValue* HGraphBuilder::BuildWrapReceiver(HValue* object, HValue* function) {
if (object->type().IsJSObject()) return object;
return Add<HWrapReceiver>(object, function);
}
HValue* HGraphBuilder::BuildCheckForCapacityGrow(HValue* object, HValue* HGraphBuilder::BuildCheckForCapacityGrow(HValue* object,
HValue* elements, HValue* elements,
ElementsKind kind, ElementsKind kind,
...@@ -6886,7 +6891,7 @@ bool HOptimizedGraphBuilder::TryCallApply(Call* expr) { ...@@ -6886,7 +6891,7 @@ bool HOptimizedGraphBuilder::TryCallApply(Call* expr) {
if (function_state()->outer() == NULL) { if (function_state()->outer() == NULL) {
HInstruction* elements = Add<HArgumentsElements>(false); HInstruction* elements = Add<HArgumentsElements>(false);
HInstruction* length = Add<HArgumentsLength>(elements); HInstruction* length = Add<HArgumentsLength>(elements);
HValue* wrapped_receiver = Add<HWrapReceiver>(receiver, function); HValue* wrapped_receiver = BuildWrapReceiver(receiver, function);
HInstruction* result = HInstruction* result =
new(zone()) HApplyArguments(function, new(zone()) HApplyArguments(function,
wrapped_receiver, wrapped_receiver,
...@@ -6903,7 +6908,7 @@ bool HOptimizedGraphBuilder::TryCallApply(Call* expr) { ...@@ -6903,7 +6908,7 @@ bool HOptimizedGraphBuilder::TryCallApply(Call* expr) {
HArgumentsObject* args = function_state()->entry()->arguments_object(); HArgumentsObject* args = function_state()->entry()->arguments_object();
const ZoneList<HValue*>* arguments_values = args->arguments_values(); const ZoneList<HValue*>* arguments_values = args->arguments_values();
int arguments_count = arguments_values->length(); int arguments_count = arguments_values->length();
PushAndAdd(new(zone()) HWrapReceiver(receiver, function)); Push(BuildWrapReceiver(receiver, function));
for (int i = 1; i < arguments_count; i++) { for (int i = 1; i < arguments_count; i++) {
Push(arguments_values->at(i)); Push(arguments_values->at(i));
} }
......
...@@ -1038,6 +1038,7 @@ class HGraphBuilder { ...@@ -1038,6 +1038,7 @@ class HGraphBuilder {
HValue* BuildCheckHeapObject(HValue* object); HValue* BuildCheckHeapObject(HValue* object);
HValue* BuildCheckMap(HValue* obj, Handle<Map> map); HValue* BuildCheckMap(HValue* obj, Handle<Map> map);
HValue* BuildWrapReceiver(HValue* object, HValue* function);
// Building common constructs // Building common constructs
HValue* BuildCheckForCapacityGrow(HValue* object, HValue* BuildCheckForCapacityGrow(HValue* object,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment