Revision: 14874
Author: [email protected]
Date: Wed May 29 03:47:55 2013
Log: Don't explicitly pass requested representations to constants;
implement ConstantS
[email protected]
Review URL: https://chromiumcodereview.appspot.com/15932011
http://code.google.com/p/v8/source/detail?r=14874
Modified:
/branches/bleeding_edge/src/arm/lithium-arm.cc
/branches/bleeding_edge/src/arm/lithium-arm.h
/branches/bleeding_edge/src/arm/lithium-codegen-arm.cc
/branches/bleeding_edge/src/code-stubs-hydrogen.cc
/branches/bleeding_edge/src/hydrogen-instructions.cc
/branches/bleeding_edge/src/hydrogen-instructions.h
/branches/bleeding_edge/src/hydrogen.cc
/branches/bleeding_edge/src/hydrogen.h
/branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc
/branches/bleeding_edge/src/ia32/lithium-ia32.cc
/branches/bleeding_edge/src/ia32/lithium-ia32.h
/branches/bleeding_edge/src/x64/lithium-codegen-x64.cc
/branches/bleeding_edge/src/x64/lithium-x64.cc
/branches/bleeding_edge/src/x64/lithium-x64.h
=======================================
--- /branches/bleeding_edge/src/arm/lithium-arm.cc Tue May 28 02:24:39 2013
+++ /branches/bleeding_edge/src/arm/lithium-arm.cc Wed May 29 03:47:55 2013
@@ -2053,11 +2053,13 @@
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();
=======================================
--- /branches/bleeding_edge/src/arm/lithium-arm.h Mon May 27 02:58:46 2013
+++ /branches/bleeding_edge/src/arm/lithium-arm.h Wed May 29 03:47:55 2013
@@ -87,6 +87,7 @@
V(CmpT) \
V(ConstantD) \
V(ConstantI) \
+ V(ConstantS) \
V(ConstantT) \
V(Context) \
V(DebugBreak) \
@@ -1206,6 +1207,15 @@
};
+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")
=======================================
--- /branches/bleeding_edge/src/arm/lithium-codegen-arm.cc Tue May 28
05:37:29 2013
+++ /branches/bleeding_edge/src/arm/lithium-codegen-arm.cc Wed May 29
03:47:55 2013
@@ -1900,7 +1900,11 @@
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()));
}
=======================================
--- /branches/bleeding_edge/src/code-stubs-hydrogen.cc Tue May 28 03:44:21
2013
+++ /branches/bleeding_edge/src/code-stubs-hydrogen.cc Wed May 29 03:47:55
2013
@@ -564,16 +564,13 @@
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();
=======================================
--- /branches/bleeding_edge/src/hydrogen-instructions.cc Tue May 28
06:28:59 2013
+++ /branches/bleeding_edge/src/hydrogen-instructions.cc Wed May 29
03:47:55 2013
@@ -1142,17 +1142,16 @@
void HBoundsCheck::InferRepresentation(HInferRepresentation* h_infer) {
ASSERT(CheckFlag(kFlexibleRepresentation));
Representation r;
+ HValue* actual_index = index()->ActualValue();
HValue* actual_length = length()->ActualValue();
- HValue* actual_index = index()->ActualValue();
- if (key_mode_ == DONT_ALLOW_SMI_KEY ||
- !actual_length->representation().IsSmiOrTagged()) {
+ 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 @@
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);
=======================================
--- /branches/bleeding_edge/src/hydrogen-instructions.h Mon May 27 23:31:05
2013
+++ /branches/bleeding_edge/src/hydrogen-instructions.h Wed May 29 03:47:55
2013
@@ -3124,11 +3124,11 @@
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 @@
};
-enum BoundsCheckKeyMode {
- DONT_ALLOW_SMI_KEY,
- ALLOW_SMI_KEY
-};
-
-
class HBoundsCheckBaseIndexInformation;
@@ -3542,10 +3536,8 @@
// 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 @@
virtual bool DataEquals(HValue* other) { return true; }
virtual void TryGuaranteeRangeChanging(RangeEvaluationContext* context);
- BoundsCheckKeyMode key_mode_;
bool skip_check_;
HValue* base_;
int offset_;
=======================================
--- /branches/bleeding_edge/src/hydrogen.cc Wed May 29 02:55:50 2013
+++ /branches/bleeding_edge/src/hydrogen.cc Wed May 29 03:47:55 2013
@@ -593,11 +593,10 @@
#endif
-HConstant* HGraph::GetConstantInt32(SetOncePointer<HConstant>* pointer,
- int32_t value) {
+HConstant* HGraph::GetConstant(SetOncePointer<HConstant>* pointer,
+ int32_t value) {
if (!pointer->is_set()) {
- HConstant* constant =
- new(zone()) HConstant(value, Representation::Integer32());
+ HConstant* constant = new(zone()) HConstant(value);
constant->InsertAfter(GetConstantUndefined());
pointer->set(constant);
}
@@ -606,17 +605,17 @@
HConstant* HGraph::GetConstant0() {
- return GetConstantInt32(&constant_0_, 0);
+ return GetConstant(&constant_0_, 0);
}
HConstant* HGraph::GetConstant1() {
- return GetConstantInt32(&constant_1_, 1);
+ return GetConstant(&constant_1_, 1);
}
HConstant* HGraph::GetConstantMinus1() {
- return GetConstantInt32(&constant_minus1_, -1);
+ return GetConstant(&constant_minus1_, -1);
}
@@ -648,7 +647,7 @@
HConstant* HGraph::GetInvalidContext() {
- return GetConstantInt32(&constant_invalid_context_, 0xFFFFC0C7);
+ return GetConstant(&constant_invalid_context_, 0xFFFFC0C7);
}
@@ -979,11 +978,8 @@
}
-HBoundsCheck* HGraphBuilder::AddBoundsCheck(HValue* index,
- HValue* length,
- BoundsCheckKeyMode key_mode) {
- HBoundsCheck* result = new(graph()->zone()) HBoundsCheck(
- index, length, key_mode);
+HBoundsCheck* HGraphBuilder::AddBoundsCheck(HValue* index, HValue* length)
{
+ HBoundsCheck* result = new(graph()->zone()) HBoundsCheck(index, length);
AddInstruction(result);
return result;
}
@@ -1169,7 +1165,7 @@
length_checker.Else();
- AddBoundsCheck(key, length, ALLOW_SMI_KEY);
+ AddBoundsCheck(key, length);
environment()->Push(elements);
length_checker.End();
@@ -1274,7 +1270,7 @@
return result;
} else {
ASSERT(store_mode == STANDARD_STORE);
- checked_key = AddBoundsCheck(key, length, ALLOW_SMI_KEY);
+ checked_key = AddBoundsCheck(key, length);
HLoadExternalArrayPointer* external_elements =
new(zone) HLoadExternalArrayPointer(elements);
AddInstruction(external_elements);
@@ -1302,7 +1298,7 @@
length, key, is_js_array);
checked_key = key;
} else {
- checked_key = AddBoundsCheck(key, length, ALLOW_SMI_KEY);
+ checked_key = AddBoundsCheck(key, length);
if (is_store && (fast_elements || fast_smi_only_elements)) {
if (store_mode == STORE_NO_TRANSITION_HANDLE_COW) {
@@ -1470,13 +1466,11 @@
: kPointerSize;
int max_size = heap->MaxRegularSpaceAllocationSize() / element_size;
max_size -= JSArray::kSize / element_size;
- HConstant* max_size_constant =
- new(zone) HConstant(max_size, Representation::Integer32());
+ HConstant* max_size_constant = new(zone) HConstant(max_size);
AddInstruction(max_size_constant);
// Since we're forcing Integer32 representation for this HBoundsCheck,
// there's no need to Smi-check the index.
- AddInstruction(new(zone) HBoundsCheck(
- length, max_size_constant, DONT_ALLOW_SMI_KEY));
+ AddInstruction(new(zone) HBoundsCheck(length, max_size_constant));
}
@@ -1544,8 +1538,7 @@
if (unfold_loop) {
for (int i = 0; i < initial_capacity; i++) {
- HInstruction* key = AddInstruction(new(zone)
- HConstant(i, Representation::Integer32()));
+ HInstruction* key = AddInstruction(new(zone) HConstant(i));
AddInstruction(new(zone) HStoreKeyed(elements, key, hole,
elements_kind));
}
} else {
@@ -1668,8 +1661,7 @@
// copying loops with constant length up to a given boundary and use
this
// helper here instead.
for (int i = 0; i < length; i++) {
- HValue* key_constant =
- AddInstruction(new(zone) HConstant(i,
Representation::Integer32()));
+ HValue* key_constant = AddInstruction(new(zone) HConstant(i));
HInstruction* value =
AddInstruction(new(zone) HLoadKeyed(boilerplate_elements,
key_constant,
@@ -5347,8 +5339,7 @@
HInstruction* enum_length = AddInstruction(new(zone())
HMapEnumLength(map));
- HInstruction* start_index = AddInstruction(new(zone()) HConstant(
- Handle<Object>(Smi::FromInt(0), isolate()),
Representation::Integer32()));
+ HInstruction* start_index = AddInstruction(new(zone()) HConstant(0));
Push(map);
Push(array);
@@ -6085,9 +6076,7 @@
elements = AddLoadElements(literal);
- HValue* key = AddInstruction(
- new(zone()) HConstant(Handle<Object>(Smi::FromInt(i), isolate()),
- Representation::Integer32()));
+ HValue* key = AddInstruction(new(zone()) HConstant(i));
switch (boilerplate_elements_kind) {
case FAST_SMI_ELEMENTS:
@@ -7282,7 +7271,7 @@
typecheck, Representation::Smi());
length->set_type(HType::Smi());
- checked_key = AddBoundsCheck(key, length, ALLOW_SMI_KEY);
+ checked_key = AddBoundsCheck(key, length);
access = AddInstruction(BuildFastElementAccess(
elements, checked_key, val, elements_kind_branch,
elements_kind, is_store, NEVER_RETURN_HOLE, STANDARD_STORE));
@@ -7300,7 +7289,7 @@
set_current_block(if_fastobject);
length = AddInstruction(new(zone())
HFixedArrayBaseLength(elements));
- checked_key = AddBoundsCheck(key, length, ALLOW_SMI_KEY);
+ checked_key = AddBoundsCheck(key, length);
access = AddInstruction(BuildFastElementAccess(
elements, checked_key, val, elements_kind_branch,
elements_kind, is_store, NEVER_RETURN_HOLE, STANDARD_STORE));
@@ -7438,9 +7427,7 @@
// Number of arguments without receiver.
int argument_count = environment()->
arguments_environment()->parameter_count() - 1;
- result = new(zone()) HConstant(
- Handle<Object>(Smi::FromInt(argument_count), isolate()),
- Representation::Integer32());
+ result = new(zone()) HConstant(argument_count);
}
} else {
Push(graph()->GetArgumentsObject());
@@ -7463,8 +7450,7 @@
int argument_count = environment()->
arguments_environment()->parameter_count() - 1;
HInstruction* length = AddInstruction(new(zone()) HConstant(
- Handle<Object>(Smi::FromInt(argument_count), isolate()),
- Representation::Integer32()));
+ argument_count));
HInstruction* checked_key = AddBoundsCheck(key, length);
result = new(zone()) HAccessArgumentsAt(elements, length,
checked_key);
}
@@ -8334,10 +8320,8 @@
result =
HUnaryMathOperation::New(zone(), context, left,
kMathPowHalf);
} else if (exponent == -0.5) {
- HConstant* double_one =
- new(zone()) HConstant(Handle<Object>(Smi::FromInt(1),
- isolate()),
- Representation::Double());
+ HConstant* double_one = new(zone()) HConstant(
+ 1, Representation::Double());
AddInstruction(double_one);
HInstruction* sqrt =
HUnaryMathOperation::New(zone(), context, left,
kMathPowHalf);
@@ -9291,7 +9275,7 @@
if (i < 0 || i >= s->length()) {
return new(zone()) HConstant(OS::nan_value(),
Representation::Double());
}
- return new(zone()) HConstant(s->Get(i), Representation::Integer32());
+ return new(zone()) HConstant(s->Get(i));
}
}
BuildCheckNonSmi(string);
@@ -10093,8 +10077,7 @@
int elements_length = elements->length();
HValue* object_elements_length =
- AddInstruction(new(zone) HConstant(
- elements_length, Representation::Integer32()));
+ AddInstruction(new(zone) HConstant(elements_length));
BuildInitializeElementsHeader(object_elements, kind,
object_elements_length);
@@ -10119,8 +10102,7 @@
elements, Representation::Tagged()));
int elements_length = elements->length();
for (int i = 0; i < elements_length; i++) {
- HValue* key_constant =
- AddInstruction(new(zone) HConstant(i,
Representation::Integer32()));
+ HValue* key_constant = AddInstruction(new(zone) HConstant(i));
HInstruction* value_instruction =
AddInstruction(new(zone) HLoadKeyed(
boilerplate_elements, key_constant, NULL, kind,
ALLOW_RETURN_HOLE));
@@ -10147,8 +10129,7 @@
Handle<FixedArray>::cast(original_elements);
for (int i = 0; i < elements_length; i++) {
Handle<Object> value(fast_elements->get(i), isolate());
- HValue* key_constant =
- AddInstruction(new(zone) HConstant(i,
Representation::Integer32()));
+ HValue* key_constant = AddInstruction(new(zone) HConstant(i));
if (value->IsJSObject()) {
Handle<JSObject> value_object = Handle<JSObject>::cast(value);
Handle<JSObject> original_value_object = Handle<JSObject>::cast(
=======================================
--- /branches/bleeding_edge/src/hydrogen.h Tue May 28 03:44:21 2013
+++ /branches/bleeding_edge/src/hydrogen.h Wed May 29 03:47:55 2013
@@ -400,8 +400,8 @@
}
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 @@
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);
=======================================
--- /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc Tue May 28
02:38:28 2013
+++ /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc Wed May 29
03:47:55 2013
@@ -1751,7 +1751,11 @@
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()));
}
=======================================
--- /branches/bleeding_edge/src/ia32/lithium-ia32.cc Tue May 28 02:24:39
2013
+++ /branches/bleeding_edge/src/ia32/lithium-ia32.cc Wed May 29 03:47:55
2013
@@ -2108,7 +2108,9 @@
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 @@
} else {
return DefineX87TOS(new(zone()) LConstantD(NULL));
}
- } else if (r.IsSmiOrTagged()) {
+ } else if (r.IsTagged()) {
return DefineAsRegister(new(zone()) LConstantT);
} else {
UNREACHABLE();
=======================================
--- /branches/bleeding_edge/src/ia32/lithium-ia32.h Mon May 27 02:58:46 2013
+++ /branches/bleeding_edge/src/ia32/lithium-ia32.h Wed May 29 03:47:55 2013
@@ -82,6 +82,7 @@
V(CmpConstantEqAndBranch) \
V(ConstantD) \
V(ConstantI) \
+ V(ConstantS) \
V(ConstantT) \
V(Context) \
V(DebugBreak) \
@@ -1152,6 +1153,15 @@
};
+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) {
=======================================
--- /branches/bleeding_edge/src/x64/lithium-codegen-x64.cc Tue May 28
05:37:29 2013
+++ /branches/bleeding_edge/src/x64/lithium-codegen-x64.cc Wed May 29
03:47:55 2013
@@ -1560,9 +1560,13 @@
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) {
=======================================
--- /branches/bleeding_edge/src/x64/lithium-x64.cc Tue May 28 02:24:39 2013
+++ /branches/bleeding_edge/src/x64/lithium-x64.cc Wed May 29 03:47:55 2013
@@ -1969,12 +1969,14 @@
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();
=======================================
--- /branches/bleeding_edge/src/x64/lithium-x64.h Mon May 27 02:58:46 2013
+++ /branches/bleeding_edge/src/x64/lithium-x64.h Wed May 29 03:47:55 2013
@@ -87,6 +87,7 @@
V(CmpT) \
V(ConstantD) \
V(ConstantI) \
+ V(ConstantS) \
V(ConstantT) \
V(Context) \
V(DebugBreak) \
@@ -1136,6 +1137,15 @@
};
+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) {
--
--
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.