Commit 7d32e745 authored by verwaest@chromium.org's avatar verwaest@chromium.org

Don't explicitly pass requested representations to constants; implement ConstantS

R=jkummerow@chromium.org

Review URL: https://chromiumcodereview.appspot.com/15932011

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14874 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 9b6aa956
......@@ -2053,11 +2053,13 @@ LInstruction* LChunkBuilder::DoReturn(HReturn* instr) {
LInstruction* LChunkBuilder::DoConstant(HConstant* instr) {
Representation r = instr->representation();
if (r.IsInteger32()) {
if (r.IsSmi()) {
return DefineAsRegister(new(zone()) LConstantS);
} else if (r.IsInteger32()) {
return DefineAsRegister(new(zone()) LConstantI);
} else if (r.IsDouble()) {
return DefineAsRegister(new(zone()) LConstantD);
} else if (r.IsSmiOrTagged()) {
} else if (r.IsTagged()) {
return DefineAsRegister(new(zone()) LConstantT);
} else {
UNREACHABLE();
......
......@@ -87,6 +87,7 @@ class LCodeGen;
V(CmpT) \
V(ConstantD) \
V(ConstantI) \
V(ConstantS) \
V(ConstantT) \
V(Context) \
V(DebugBreak) \
......@@ -1206,6 +1207,15 @@ class LConstantI: public LTemplateInstruction<1, 0, 0> {
};
class LConstantS: public LTemplateInstruction<1, 0, 0> {
public:
DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
DECLARE_HYDROGEN_ACCESSOR(Constant)
Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
};
class LConstantD: public LTemplateInstruction<1, 0, 0> {
public:
DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
......
......@@ -1900,7 +1900,11 @@ void LCodeGen::DoRSubI(LRSubI* instr) {
void LCodeGen::DoConstantI(LConstantI* instr) {
ASSERT(instr->result()->IsRegister());
__ mov(ToRegister(instr->result()), Operand(instr->value()));
}
void LCodeGen::DoConstantS(LConstantS* instr) {
__ mov(ToRegister(instr->result()), Operand(instr->value()));
}
......
......@@ -564,16 +564,13 @@ HValue* CodeStubGraphBuilder<ArraySingleArgumentConstructorStub>::
new(zone()) HAccessArgumentsAt(elements, constant_one, constant_zero));
HConstant* max_alloc_length =
new(zone()) HConstant(JSObject::kInitialMaxFastElementArray,
Representation::Tagged());
new(zone()) HConstant(JSObject::kInitialMaxFastElementArray);
AddInstruction(max_alloc_length);
const int initial_capacity = JSArray::kPreallocatedArrayElements;
HConstant* initial_capacity_node =
new(zone()) HConstant(initial_capacity, Representation::Tagged());
HConstant* initial_capacity_node = new(zone()) HConstant(initial_capacity);
AddInstruction(initial_capacity_node);
HBoundsCheck* checked_arg = AddBoundsCheck(
argument, max_alloc_length, ALLOW_SMI_KEY);
HBoundsCheck* checked_arg = AddBoundsCheck(argument, max_alloc_length);
IfBuilder if_builder(this);
if_builder.IfCompare(checked_arg, constant_zero, Token::EQ);
if_builder.Then();
......
......@@ -1142,17 +1142,16 @@ void HBoundsCheck::PrintDataTo(StringStream* stream) {
void HBoundsCheck::InferRepresentation(HInferRepresentation* h_infer) {
ASSERT(CheckFlag(kFlexibleRepresentation));
Representation r;
HValue* actual_length = length()->ActualValue();
HValue* actual_index = index()->ActualValue();
if (key_mode_ == DONT_ALLOW_SMI_KEY ||
!actual_length->representation().IsSmiOrTagged()) {
HValue* actual_length = length()->ActualValue();
Representation index_rep = actual_index->representation();
if (!actual_length->representation().IsSmiOrTagged()) {
r = Representation::Integer32();
} else if (actual_index->representation().IsSmiOrTagged() ||
(actual_index->IsConstant() &&
HConstant::cast(actual_index)->HasSmiValue())) {
// If the index is smi, or a constant that holds a Smi, allow the length to
// be smi, since it is usually already smi from loading it out of the length
// field of a JSArray. This allows for direct comparison without untagging.
} else if ((index_rep.IsTagged() && actual_index->type().IsSmi()) ||
index_rep.IsSmi()) {
// If the index is smi, allow the length to be smi, since it is usually
// already smi from loading it out of the length field of a JSArray. This
// allows for direct comparison without untagging.
r = Representation::Smi();
} else {
r = Representation::Integer32();
......@@ -3250,7 +3249,7 @@ HInstruction* HStringLength::New(Zone* zone, HValue* string) {
if (FLAG_fold_constants && string->IsConstant()) {
HConstant* c_string = HConstant::cast(string);
if (c_string->HasStringValue()) {
return H_CONSTANT_INT32(c_string->StringValue()->length());
return new(zone) HConstant(c_string->StringValue()->length());
}
}
return new(zone) HStringLength(string);
......
......@@ -3124,11 +3124,11 @@ class HConstant: public HTemplateInstruction<0> {
public:
HConstant(Handle<Object> handle, Representation r);
HConstant(int32_t value,
Representation r,
Representation r = Representation::None(),
bool is_not_in_new_space = true,
Handle<Object> optional_handle = Handle<Object>::null());
HConstant(double value,
Representation r,
Representation r = Representation::None(),
bool is_not_in_new_space = true,
Handle<Object> optional_handle = Handle<Object>::null());
HConstant(Handle<Object> handle,
......@@ -3527,12 +3527,6 @@ class HAccessArgumentsAt: public HTemplateInstruction<3> {
};
enum BoundsCheckKeyMode {
DONT_ALLOW_SMI_KEY,
ALLOW_SMI_KEY
};
class HBoundsCheckBaseIndexInformation;
......@@ -3542,10 +3536,8 @@ class HBoundsCheck: public HTemplateInstruction<2> {
// HGraphBuilder::AddBoundsCheck() helper.
// However when building stubs, where we know that the arguments are Int32,
// it makes sense to invoke this constructor directly.
HBoundsCheck(HValue* index,
HValue* length,
BoundsCheckKeyMode key_mode = DONT_ALLOW_SMI_KEY)
: key_mode_(key_mode), skip_check_(false),
HBoundsCheck(HValue* index, HValue* length)
: skip_check_(false),
base_(NULL), offset_(0), scale_(0),
responsibility_direction_(DIRECTION_NONE) {
SetOperandAt(0, index);
......@@ -3618,7 +3610,6 @@ class HBoundsCheck: public HTemplateInstruction<2> {
virtual bool DataEquals(HValue* other) { return true; }
virtual void TryGuaranteeRangeChanging(RangeEvaluationContext* context);
BoundsCheckKeyMode key_mode_;
bool skip_check_;
HValue* base_;
int offset_;
......
This diff is collapsed.
......@@ -400,8 +400,8 @@ class HGraph: public ZoneObject {
}
private:
HConstant* GetConstantInt32(SetOncePointer<HConstant>* pointer,
int32_t integer_value);
HConstant* GetConstant(SetOncePointer<HConstant>* pointer,
int32_t integer_value);
void MarkLive(HValue* ref, HValue* instr, ZoneList<HValue*>* worklist);
void MarkLiveInstructions();
......@@ -952,10 +952,7 @@ class HGraphBuilder {
HInstruction* AddInstruction(HInstruction* instr);
void AddSimulate(BailoutId id,
RemovableSimulate removable = FIXED_SIMULATE);
HBoundsCheck* AddBoundsCheck(
HValue* index,
HValue* length,
BoundsCheckKeyMode key_mode = DONT_ALLOW_SMI_KEY);
HBoundsCheck* AddBoundsCheck(HValue* index, HValue* length);
HReturn* AddReturn(HValue* value);
......
......@@ -1751,7 +1751,11 @@ void LCodeGen::DoSubI(LSubI* instr) {
void LCodeGen::DoConstantI(LConstantI* instr) {
ASSERT(instr->result()->IsRegister());
__ Set(ToRegister(instr->result()), Immediate(instr->value()));
}
void LCodeGen::DoConstantS(LConstantS* instr) {
__ Set(ToRegister(instr->result()), Immediate(instr->value()));
}
......
......@@ -2108,7 +2108,9 @@ LInstruction* LChunkBuilder::DoReturn(HReturn* instr) {
LInstruction* LChunkBuilder::DoConstant(HConstant* instr) {
Representation r = instr->representation();
if (r.IsInteger32()) {
if (r.IsSmi()) {
return DefineAsRegister(new(zone()) LConstantS);
} else if (r.IsInteger32()) {
return DefineAsRegister(new(zone()) LConstantI);
} else if (r.IsDouble()) {
double value = instr->DoubleValue();
......@@ -2119,7 +2121,7 @@ LInstruction* LChunkBuilder::DoConstant(HConstant* instr) {
} else {
return DefineX87TOS(new(zone()) LConstantD(NULL));
}
} else if (r.IsSmiOrTagged()) {
} else if (r.IsTagged()) {
return DefineAsRegister(new(zone()) LConstantT);
} else {
UNREACHABLE();
......
......@@ -82,6 +82,7 @@ class LCodeGen;
V(CmpConstantEqAndBranch) \
V(ConstantD) \
V(ConstantI) \
V(ConstantS) \
V(ConstantT) \
V(Context) \
V(DebugBreak) \
......@@ -1152,6 +1153,15 @@ class LConstantI: public LTemplateInstruction<1, 0, 0> {
};
class LConstantS: public LTemplateInstruction<1, 0, 0> {
public:
DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
DECLARE_HYDROGEN_ACCESSOR(Constant)
Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
};
class LConstantD: public LTemplateInstruction<1, 0, 1> {
public:
explicit LConstantD(LOperand* temp) {
......
......@@ -1560,11 +1560,15 @@ void LCodeGen::DoSubI(LSubI* instr) {
void LCodeGen::DoConstantI(LConstantI* instr) {
ASSERT(instr->result()->IsRegister());
__ Set(ToRegister(instr->result()), instr->value());
}
void LCodeGen::DoConstantS(LConstantS* instr) {
__ Move(ToRegister(instr->result()), instr->value());
}
void LCodeGen::DoConstantD(LConstantD* instr) {
ASSERT(instr->result()->IsDoubleRegister());
XMMRegister res = ToDoubleRegister(instr->result());
......
......@@ -1969,12 +1969,14 @@ LInstruction* LChunkBuilder::DoReturn(HReturn* instr) {
LInstruction* LChunkBuilder::DoConstant(HConstant* instr) {
Representation r = instr->representation();
if (r.IsInteger32()) {
if (r.IsSmi()) {
return DefineAsRegister(new(zone()) LConstantS);
} else if (r.IsInteger32()) {
return DefineAsRegister(new(zone()) LConstantI);
} else if (r.IsDouble()) {
LOperand* temp = TempRegister();
return DefineAsRegister(new(zone()) LConstantD(temp));
} else if (r.IsSmiOrTagged()) {
} else if (r.IsTagged()) {
return DefineAsRegister(new(zone()) LConstantT);
} else {
UNREACHABLE();
......
......@@ -87,6 +87,7 @@ class LCodeGen;
V(CmpT) \
V(ConstantD) \
V(ConstantI) \
V(ConstantS) \
V(ConstantT) \
V(Context) \
V(DebugBreak) \
......@@ -1136,6 +1137,15 @@ class LConstantI: public LTemplateInstruction<1, 0, 0> {
};
class LConstantS: public LTemplateInstruction<1, 0, 0> {
public:
DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
DECLARE_HYDROGEN_ACCESSOR(Constant)
Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
};
class LConstantD: public LTemplateInstruction<1, 0, 1> {
public:
explicit LConstantD(LOperand* temp) {
......
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