Reviewers: titzer,
Message:
Easy solution for one of my problems I mentioned today. :)
Description:
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.
[email protected]
Please review this at https://codereview.chromium.org/19493005/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/hydrogen-instructions.h
M src/hydrogen-instructions.cc
M src/hydrogen.h
M src/hydrogen.cc
Index: src/hydrogen-instructions.cc
diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc
index
16476a9c5a95c2b9a1bcca90e388255d7d25438b..1400a2c8c655d932c4f1c81c59588ca53eb24776
100644
--- a/src/hydrogen-instructions.cc
+++ b/src/hydrogen-instructions.cc
@@ -3187,11 +3187,6 @@ HType HStringCharFromCode::CalculateInferredType() {
}
-HType HAllocate::CalculateInferredType() {
- return type_;
-}
-
-
void HAllocate::HandleSideEffectDominator(GVNFlag side_effect,
HValue* dominator) {
ASSERT(side_effect == kChangesNewSpacePromotion);
Index: src/hydrogen-instructions.h
diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h
index
763b6369e3583a0a1c9b1a41bd3af7e93e8fe34e..64befa4ab5fc82ad3cafb13b7db9a0509db98053
100644
--- a/src/hydrogen-instructions.h
+++ b/src/hydrogen-instructions.h
@@ -4969,10 +4969,10 @@ class HAllocate: public HTemplateInstruction<2> {
};
HAllocate(HValue* context, HValue* size, HType type, Flags flags)
- : type_(type),
- flags_(flags) {
+ : flags_(flags) {
SetOperandAt(0, context);
SetOperandAt(1, size);
+ set_type(type);
set_representation(Representation::Tagged());
SetFlag(kTrackSideEffectDominators);
SetGVNFlag(kChangesNewSpacePromotion);
@@ -4997,7 +4997,6 @@ class HAllocate: public HTemplateInstruction<2> {
HValue* context() { return OperandAt(0); }
HValue* size() { return OperandAt(1); }
- HType type() { return type_; }
virtual Representation RequiredInputRepresentation(int index) {
if (index == 0) {
@@ -5015,8 +5014,6 @@ class HAllocate: public HTemplateInstruction<2> {
known_initial_map_ = known_initial_map;
}
- virtual HType CalculateInferredType();
-
bool CanAllocateInNewSpace() const {
return (flags_ & CAN_ALLOCATE_IN_NEW_SPACE) != 0;
}
@@ -5062,7 +5059,6 @@ class HAllocate: public HTemplateInstruction<2> {
DECLARE_CONCRETE_INSTRUCTION(Allocate)
private:
- HType type_;
Flags flags_;
Handle<Map> known_initial_map_;
};
@@ -5071,10 +5067,10 @@ class HAllocate: public HTemplateInstruction<2> {
class HInnerAllocatedObject: public HTemplateInstruction<1> {
public:
HInnerAllocatedObject(HValue* value, int offset, HType type =
HType::Tagged())
- : offset_(offset),
- type_(type) {
+ : offset_(offset) {
ASSERT(value->IsAllocate());
SetOperandAt(0, value);
+ set_type(type);
set_representation(Representation::Tagged());
}
@@ -5085,15 +5081,12 @@ class HInnerAllocatedObject: public
HTemplateInstruction<1> {
return Representation::Tagged();
}
- virtual HType CalculateInferredType() { return type_; }
-
virtual void PrintDataTo(StringStream* stream);
DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject)
private:
int offset_;
- HType type_;
};
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index
57220e0de1e5cf77641235343b45aba12249cb8a..db0b5ea331b8867c4ce4c53719bd7baa4a912db9
100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -1043,14 +1043,19 @@ HValue* HGraphBuilder::BuildCheckHeapObject(HValue*
obj) {
}
-HValue* HGraphBuilder::BuildCheckMap(HValue* obj,
- Handle<Map> map) {
+HValue* HGraphBuilder::BuildCheckMap(HValue* obj, Handle<Map> map) {
HCheckMaps* check = HCheckMaps::New(obj, map, zone());
AddInstruction(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* elements,
ElementsKind kind,
@@ -6881,7 +6886,7 @@ bool HOptimizedGraphBuilder::TryCallApply(Call* expr)
{
if (function_state()->outer() == NULL) {
HInstruction* elements = Add<HArgumentsElements>(false);
HInstruction* length = Add<HArgumentsLength>(elements);
- HValue* wrapped_receiver = Add<HWrapReceiver>(receiver, function);
+ HValue* wrapped_receiver = BuildWrapReceiver(receiver, function);
HInstruction* result =
new(zone()) HApplyArguments(function,
wrapped_receiver,
@@ -6898,7 +6903,7 @@ bool HOptimizedGraphBuilder::TryCallApply(Call* expr)
{
HArgumentsObject* args = function_state()->entry()->arguments_object();
const ZoneList<HValue*>* arguments_values = args->arguments_values();
int arguments_count = arguments_values->length();
- PushAndAdd(new(zone()) HWrapReceiver(receiver, function));
+ Push(BuildWrapReceiver(receiver, function));
for (int i = 1; i < arguments_count; i++) {
Push(arguments_values->at(i));
}
Index: src/hydrogen.h
diff --git a/src/hydrogen.h b/src/hydrogen.h
index
797b444078d5e838157c77e207a956a4b3d056db..2318165888265c9e95ef881afff86e4a99c408f0
100644
--- a/src/hydrogen.h
+++ b/src/hydrogen.h
@@ -1044,6 +1044,7 @@ class HGraphBuilder {
HValue* BuildCheckHeapObject(HValue* object);
HValue* BuildCheckMap(HValue* obj, Handle<Map> map);
+ HValue* BuildWrapReceiver(HValue* object, HValue* function);
// Building common constructs
HValue* BuildCheckForCapacityGrow(HValue* object,
--
--
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.