| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 | 123 |
| 124 return Representation::None(); | 124 return Representation::None(); |
| 125 } | 125 } |
| 126 | 126 |
| 127 | 127 |
| 128 void HValue::UpdateRepresentation(Representation new_rep, | 128 void HValue::UpdateRepresentation(Representation new_rep, |
| 129 HInferRepresentation* h_infer, | 129 HInferRepresentation* h_infer, |
| 130 const char* reason) { | 130 const char* reason) { |
| 131 Representation r = representation(); | 131 Representation r = representation(); |
| 132 if (new_rep.is_more_general_than(r)) { | 132 if (new_rep.is_more_general_than(r)) { |
| 133 if (CheckFlag(kCannotBeTagged) && new_rep.IsTagged()) return; |
| 133 if (FLAG_trace_representation) { | 134 if (FLAG_trace_representation) { |
| 134 PrintF("Changing #%d %s representation %s -> %s based on %s\n", | 135 PrintF("Changing #%d %s representation %s -> %s based on %s\n", |
| 135 id(), Mnemonic(), r.Mnemonic(), new_rep.Mnemonic(), reason); | 136 id(), Mnemonic(), r.Mnemonic(), new_rep.Mnemonic(), reason); |
| 136 } | 137 } |
| 137 ChangeRepresentation(new_rep); | 138 ChangeRepresentation(new_rep); |
| 138 AddDependantsToWorklist(h_infer); | 139 AddDependantsToWorklist(h_infer); |
| 139 } | 140 } |
| 140 } | 141 } |
| 141 | 142 |
| 142 | 143 |
| (...skipping 1007 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1150 } | 1151 } |
| 1151 } | 1152 } |
| 1152 | 1153 |
| 1153 | 1154 |
| 1154 void HBoundsCheck::InferRepresentation(HInferRepresentation* h_infer) { | 1155 void HBoundsCheck::InferRepresentation(HInferRepresentation* h_infer) { |
| 1155 ASSERT(CheckFlag(kFlexibleRepresentation)); | 1156 ASSERT(CheckFlag(kFlexibleRepresentation)); |
| 1156 HValue* actual_index = index()->ActualValue(); | 1157 HValue* actual_index = index()->ActualValue(); |
| 1157 HValue* actual_length = length()->ActualValue(); | 1158 HValue* actual_length = length()->ActualValue(); |
| 1158 Representation index_rep = actual_index->representation(); | 1159 Representation index_rep = actual_index->representation(); |
| 1159 Representation length_rep = actual_length->representation(); | 1160 Representation length_rep = actual_length->representation(); |
| 1160 if (index_rep.IsTagged()) index_rep = Representation::Smi(); | 1161 if (index_rep.IsTagged() && actual_index->type().IsSmi()) { |
| 1161 if (length_rep.IsTagged()) length_rep = Representation::Smi(); | 1162 index_rep = Representation::Smi(); |
| 1163 } |
| 1164 if (length_rep.IsTagged() && actual_length->type().IsSmi()) { |
| 1165 length_rep = Representation::Smi(); |
| 1166 } |
| 1162 Representation r = index_rep.generalize(length_rep); | 1167 Representation r = index_rep.generalize(length_rep); |
| 1163 if (r.is_more_general_than(Representation::Integer32())) { | 1168 if (r.is_more_general_than(Representation::Integer32())) { |
| 1164 r = Representation::Integer32(); | 1169 r = Representation::Integer32(); |
| 1165 } | 1170 } |
| 1166 UpdateRepresentation(r, h_infer, "boundscheck"); | 1171 UpdateRepresentation(r, h_infer, "boundscheck"); |
| 1167 } | 1172 } |
| 1168 | 1173 |
| 1169 | 1174 |
| 1170 bool HBoundsCheckBaseIndexInformation::IsRelationTrueInternal( | 1175 bool HBoundsCheckBaseIndexInformation::IsRelationTrueInternal( |
| 1171 NumericRelation relation, | 1176 NumericRelation relation, |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1271 void HReturn::PrintDataTo(StringStream* stream) { | 1276 void HReturn::PrintDataTo(StringStream* stream) { |
| 1272 value()->PrintNameTo(stream); | 1277 value()->PrintNameTo(stream); |
| 1273 stream->Add(" (pop "); | 1278 stream->Add(" (pop "); |
| 1274 parameter_count()->PrintNameTo(stream); | 1279 parameter_count()->PrintNameTo(stream); |
| 1275 stream->Add(" values)"); | 1280 stream->Add(" values)"); |
| 1276 } | 1281 } |
| 1277 | 1282 |
| 1278 | 1283 |
| 1279 Representation HBranch::observed_input_representation(int index) { | 1284 Representation HBranch::observed_input_representation(int index) { |
| 1280 static const ToBooleanStub::Types tagged_types( | 1285 static const ToBooleanStub::Types tagged_types( |
| 1281 ToBooleanStub::UNDEFINED | | |
| 1282 ToBooleanStub::NULL_TYPE | | 1286 ToBooleanStub::NULL_TYPE | |
| 1283 ToBooleanStub::SPEC_OBJECT | | 1287 ToBooleanStub::SPEC_OBJECT | |
| 1284 ToBooleanStub::STRING | | 1288 ToBooleanStub::STRING | |
| 1285 ToBooleanStub::SYMBOL); | 1289 ToBooleanStub::SYMBOL); |
| 1286 if (expected_input_types_.ContainsAnyOf(tagged_types)) { | 1290 if (expected_input_types_.ContainsAnyOf(tagged_types)) { |
| 1287 return Representation::Tagged(); | 1291 return Representation::Tagged(); |
| 1288 } else if (expected_input_types_.Contains(ToBooleanStub::HEAP_NUMBER)) { | 1292 } |
| 1293 if (expected_input_types_.Contains(ToBooleanStub::UNDEFINED)) { |
| 1294 if (expected_input_types_.Contains(ToBooleanStub::HEAP_NUMBER)) { |
| 1295 return Representation::Double(); |
| 1296 } |
| 1297 return Representation::Tagged(); |
| 1298 } |
| 1299 if (expected_input_types_.Contains(ToBooleanStub::HEAP_NUMBER)) { |
| 1289 return Representation::Double(); | 1300 return Representation::Double(); |
| 1290 } else if (expected_input_types_.Contains(ToBooleanStub::SMI)) { | 1301 } |
| 1302 if (expected_input_types_.Contains(ToBooleanStub::SMI)) { |
| 1291 return Representation::Smi(); | 1303 return Representation::Smi(); |
| 1292 } else { | |
| 1293 return Representation::None(); | |
| 1294 } | 1304 } |
| 1305 return Representation::None(); |
| 1295 } | 1306 } |
| 1296 | 1307 |
| 1297 | 1308 |
| 1298 void HCompareMap::PrintDataTo(StringStream* stream) { | 1309 void HCompareMap::PrintDataTo(StringStream* stream) { |
| 1299 value()->PrintNameTo(stream); | 1310 value()->PrintNameTo(stream); |
| 1300 stream->Add(" (%p)", *map()); | 1311 stream->Add(" (%p)", *map()); |
| 1301 HControlInstruction::PrintDataTo(stream); | 1312 HControlInstruction::PrintDataTo(stream); |
| 1302 } | 1313 } |
| 1303 | 1314 |
| 1304 | 1315 |
| (...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1753 if (has_int32_value_) { | 1764 if (has_int32_value_) { |
| 1754 Range* result = new(zone) Range(int32_value_, int32_value_); | 1765 Range* result = new(zone) Range(int32_value_, int32_value_); |
| 1755 result->set_can_be_minus_zero(false); | 1766 result->set_can_be_minus_zero(false); |
| 1756 return result; | 1767 return result; |
| 1757 } | 1768 } |
| 1758 return HValue::InferRange(zone); | 1769 return HValue::InferRange(zone); |
| 1759 } | 1770 } |
| 1760 | 1771 |
| 1761 | 1772 |
| 1762 Range* HPhi::InferRange(Zone* zone) { | 1773 Range* HPhi::InferRange(Zone* zone) { |
| 1763 if (representation().IsInteger32()) { | 1774 Representation r = representation(); |
| 1775 if (r.IsSmiOrInteger32()) { |
| 1764 if (block()->IsLoopHeader()) { | 1776 if (block()->IsLoopHeader()) { |
| 1765 Range* range = new(zone) Range(kMinInt, kMaxInt); | 1777 Range* range = r.IsSmi() |
| 1778 ? new(zone) Range(Smi::kMinValue, Smi::kMaxValue) |
| 1779 : new(zone) Range(kMinInt, kMaxInt); |
| 1766 return range; | 1780 return range; |
| 1767 } else { | 1781 } else { |
| 1768 Range* range = OperandAt(0)->range()->Copy(zone); | 1782 Range* range = OperandAt(0)->range()->Copy(zone); |
| 1769 for (int i = 1; i < OperandCount(); ++i) { | 1783 for (int i = 1; i < OperandCount(); ++i) { |
| 1770 range->Union(OperandAt(i)->range()); | 1784 range->Union(OperandAt(i)->range()); |
| 1771 } | 1785 } |
| 1772 return range; | 1786 return range; |
| 1773 } | 1787 } |
| 1774 } else { | 1788 } else { |
| 1775 return HValue::InferRange(zone); | 1789 return HValue::InferRange(zone); |
| (...skipping 1274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3050 HType HCheckMaps::CalculateInferredType() { | 3064 HType HCheckMaps::CalculateInferredType() { |
| 3051 return value()->type(); | 3065 return value()->type(); |
| 3052 } | 3066 } |
| 3053 | 3067 |
| 3054 | 3068 |
| 3055 HType HCheckFunction::CalculateInferredType() { | 3069 HType HCheckFunction::CalculateInferredType() { |
| 3056 return value()->type(); | 3070 return value()->type(); |
| 3057 } | 3071 } |
| 3058 | 3072 |
| 3059 | 3073 |
| 3060 HType HCheckNonSmi::CalculateInferredType() { | 3074 HType HCheckHeapObject::CalculateInferredType() { |
| 3061 // TODO(kasperl): Is there any way to signal that this isn't a smi? | 3075 return HType::NonPrimitive(); |
| 3062 return HType::Tagged(); | |
| 3063 } | 3076 } |
| 3064 | 3077 |
| 3065 | 3078 |
| 3066 HType HPhi::CalculateInferredType() { | 3079 HType HPhi::CalculateInferredType() { |
| 3067 HType result = HType::Uninitialized(); | 3080 HType result = HType::Uninitialized(); |
| 3068 for (int i = 0; i < OperandCount(); ++i) { | 3081 for (int i = 0; i < OperandCount(); ++i) { |
| 3069 HType current = OperandAt(i)->type(); | 3082 HType current = OperandAt(i)->type(); |
| 3070 result = result.Combine(current); | 3083 result = result.Combine(current); |
| 3071 } | 3084 } |
| 3072 return result; | 3085 return result; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3142 if (!input_rep.IsTagged()) rep = rep.generalize(input_rep); | 3155 if (!input_rep.IsTagged()) rep = rep.generalize(input_rep); |
| 3143 return rep; | 3156 return rep; |
| 3144 } | 3157 } |
| 3145 | 3158 |
| 3146 | 3159 |
| 3147 HType HStringCharFromCode::CalculateInferredType() { | 3160 HType HStringCharFromCode::CalculateInferredType() { |
| 3148 return HType::String(); | 3161 return HType::String(); |
| 3149 } | 3162 } |
| 3150 | 3163 |
| 3151 | 3164 |
| 3165 HType HAllocateObject::CalculateInferredType() { |
| 3166 return HType::JSObject(); |
| 3167 } |
| 3168 |
| 3169 |
| 3152 HType HAllocate::CalculateInferredType() { | 3170 HType HAllocate::CalculateInferredType() { |
| 3153 return type_; | 3171 return type_; |
| 3154 } | 3172 } |
| 3155 | 3173 |
| 3156 | 3174 |
| 3157 void HAllocate::PrintDataTo(StringStream* stream) { | 3175 void HAllocate::PrintDataTo(StringStream* stream) { |
| 3158 size()->PrintNameTo(stream); | 3176 size()->PrintNameTo(stream); |
| 3159 if (!GuaranteedInNewSpace()) stream->Add(" (pretenure)"); | 3177 if (!GuaranteedInNewSpace()) stream->Add(" (pretenure)"); |
| 3160 } | 3178 } |
| 3161 | 3179 |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3322 | 3340 |
| 3323 #undef DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR | 3341 #undef DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR |
| 3324 | 3342 |
| 3325 | 3343 |
| 3326 HInstruction* HStringAdd::New( | 3344 HInstruction* HStringAdd::New( |
| 3327 Zone* zone, HValue* context, HValue* left, HValue* right) { | 3345 Zone* zone, HValue* context, HValue* left, HValue* right) { |
| 3328 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) { | 3346 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) { |
| 3329 HConstant* c_right = HConstant::cast(right); | 3347 HConstant* c_right = HConstant::cast(right); |
| 3330 HConstant* c_left = HConstant::cast(left); | 3348 HConstant* c_left = HConstant::cast(left); |
| 3331 if (c_left->HasStringValue() && c_right->HasStringValue()) { | 3349 if (c_left->HasStringValue() && c_right->HasStringValue()) { |
| 3332 Factory* factory = Isolate::Current()->factory(); | 3350 Handle<String> concat = zone->isolate()->factory()->NewFlatConcatString( |
| 3333 return new(zone) HConstant(factory->NewConsString(c_left->StringValue(), | 3351 c_left->StringValue(), c_right->StringValue()); |
| 3334 c_right->StringValue()), | 3352 return new(zone) HConstant(concat, Representation::Tagged()); |
| 3335 Representation::Tagged()); | |
| 3336 } | 3353 } |
| 3337 } | 3354 } |
| 3338 return new(zone) HStringAdd(context, left, right); | 3355 return new(zone) HStringAdd(context, left, right); |
| 3339 } | 3356 } |
| 3340 | 3357 |
| 3341 | 3358 |
| 3342 HInstruction* HStringCharFromCode::New( | 3359 HInstruction* HStringCharFromCode::New( |
| 3343 Zone* zone, HValue* context, HValue* char_code) { | 3360 Zone* zone, HValue* context, HValue* char_code) { |
| 3344 if (FLAG_fold_constants && char_code->IsConstant()) { | 3361 if (FLAG_fold_constants && char_code->IsConstant()) { |
| 3345 HConstant* c_code = HConstant::cast(char_code); | 3362 HConstant* c_code = HConstant::cast(char_code); |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3482 } | 3499 } |
| 3483 } | 3500 } |
| 3484 return new(zone) HMathMinMax(context, left, right, op); | 3501 return new(zone) HMathMinMax(context, left, right, op); |
| 3485 } | 3502 } |
| 3486 | 3503 |
| 3487 | 3504 |
| 3488 HInstruction* HMod::New(Zone* zone, | 3505 HInstruction* HMod::New(Zone* zone, |
| 3489 HValue* context, | 3506 HValue* context, |
| 3490 HValue* left, | 3507 HValue* left, |
| 3491 HValue* right, | 3508 HValue* right, |
| 3492 bool has_fixed_right_arg, | 3509 Maybe<int> fixed_right_arg) { |
| 3493 int fixed_right_arg_value) { | |
| 3494 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) { | 3510 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) { |
| 3495 HConstant* c_left = HConstant::cast(left); | 3511 HConstant* c_left = HConstant::cast(left); |
| 3496 HConstant* c_right = HConstant::cast(right); | 3512 HConstant* c_right = HConstant::cast(right); |
| 3497 if (c_left->HasInteger32Value() && c_right->HasInteger32Value()) { | 3513 if (c_left->HasInteger32Value() && c_right->HasInteger32Value()) { |
| 3498 int32_t dividend = c_left->Integer32Value(); | 3514 int32_t dividend = c_left->Integer32Value(); |
| 3499 int32_t divisor = c_right->Integer32Value(); | 3515 int32_t divisor = c_right->Integer32Value(); |
| 3500 if (dividend == kMinInt && divisor == -1) { | 3516 if (dividend == kMinInt && divisor == -1) { |
| 3501 return H_CONSTANT_DOUBLE(-0.0); | 3517 return H_CONSTANT_DOUBLE(-0.0); |
| 3502 } | 3518 } |
| 3503 if (divisor != 0) { | 3519 if (divisor != 0) { |
| 3504 int32_t res = dividend % divisor; | 3520 int32_t res = dividend % divisor; |
| 3505 if ((res == 0) && (dividend < 0)) { | 3521 if ((res == 0) && (dividend < 0)) { |
| 3506 return H_CONSTANT_DOUBLE(-0.0); | 3522 return H_CONSTANT_DOUBLE(-0.0); |
| 3507 } | 3523 } |
| 3508 return H_CONSTANT_INT32(res); | 3524 return H_CONSTANT_INT32(res); |
| 3509 } | 3525 } |
| 3510 } | 3526 } |
| 3511 } | 3527 } |
| 3512 return new(zone) HMod(context, | 3528 return new(zone) HMod(context, left, right, fixed_right_arg); |
| 3513 left, | |
| 3514 right, | |
| 3515 has_fixed_right_arg, | |
| 3516 fixed_right_arg_value); | |
| 3517 } | 3529 } |
| 3518 | 3530 |
| 3519 | 3531 |
| 3520 HInstruction* HDiv::New( | 3532 HInstruction* HDiv::New( |
| 3521 Zone* zone, HValue* context, HValue* left, HValue* right) { | 3533 Zone* zone, HValue* context, HValue* left, HValue* right) { |
| 3522 // If left and right are constant values, try to return a constant value. | 3534 // If left and right are constant values, try to return a constant value. |
| 3523 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) { | 3535 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) { |
| 3524 HConstant* c_left = HConstant::cast(left); | 3536 HConstant* c_left = HConstant::cast(left); |
| 3525 HConstant* c_right = HConstant::cast(right); | 3537 HConstant* c_right = HConstant::cast(right); |
| 3526 if ((c_left->HasNumberValue() && c_right->HasNumberValue())) { | 3538 if ((c_left->HasNumberValue() && c_right->HasNumberValue())) { |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3722 } | 3734 } |
| 3723 } | 3735 } |
| 3724 | 3736 |
| 3725 | 3737 |
| 3726 void HSimulate::Verify() { | 3738 void HSimulate::Verify() { |
| 3727 HInstruction::Verify(); | 3739 HInstruction::Verify(); |
| 3728 ASSERT(HasAstId()); | 3740 ASSERT(HasAstId()); |
| 3729 } | 3741 } |
| 3730 | 3742 |
| 3731 | 3743 |
| 3732 void HCheckNonSmi::Verify() { | 3744 void HCheckHeapObject::Verify() { |
| 3733 HInstruction::Verify(); | 3745 HInstruction::Verify(); |
| 3734 ASSERT(HasNoUses()); | 3746 ASSERT(HasNoUses()); |
| 3735 } | 3747 } |
| 3736 | 3748 |
| 3737 | 3749 |
| 3738 void HCheckFunction::Verify() { | 3750 void HCheckFunction::Verify() { |
| 3739 HInstruction::Verify(); | 3751 HInstruction::Verify(); |
| 3740 ASSERT(HasNoUses()); | 3752 ASSERT(HasNoUses()); |
| 3741 } | 3753 } |
| 3742 | 3754 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3872 case kBackingStore: | 3884 case kBackingStore: |
| 3873 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString()); | 3885 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString()); |
| 3874 stream->Add("[backing-store]"); | 3886 stream->Add("[backing-store]"); |
| 3875 break; | 3887 break; |
| 3876 } | 3888 } |
| 3877 | 3889 |
| 3878 stream->Add("@%d", offset()); | 3890 stream->Add("@%d", offset()); |
| 3879 } | 3891 } |
| 3880 | 3892 |
| 3881 } } // namespace v8::internal | 3893 } } // namespace v8::internal |
| OLD | NEW |