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 1237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1248 } | 1248 } |
1249 // Optimize double negation, a common pattern used for ToInt32(x). | 1249 // Optimize double negation, a common pattern used for ToInt32(x). |
1250 HValue* arg; | 1250 HValue* arg; |
1251 if (MatchDoubleNegation(this, &arg) && !arg->CheckFlag(kUint32)) { | 1251 if (MatchDoubleNegation(this, &arg) && !arg->CheckFlag(kUint32)) { |
1252 return arg; | 1252 return arg; |
1253 } | 1253 } |
1254 return this; | 1254 return this; |
1255 } | 1255 } |
1256 | 1256 |
1257 | 1257 |
| 1258 Representation HAdd::RepresentationFromInputs() { |
| 1259 Representation left_rep = left()->representation(); |
| 1260 if (left_rep.IsExternal()) { |
| 1261 return Representation::External(); |
| 1262 } |
| 1263 return HArithmeticBinaryOperation::RepresentationFromInputs(); |
| 1264 } |
| 1265 |
| 1266 |
| 1267 Representation HAdd::RequiredInputRepresentation(int index) { |
| 1268 if (index == 2) { |
| 1269 Representation left_rep = left()->representation(); |
| 1270 if (left_rep.IsExternal()) { |
| 1271 return Representation::Integer32(); |
| 1272 } |
| 1273 } |
| 1274 return HArithmeticBinaryOperation::RequiredInputRepresentation(index); |
| 1275 } |
| 1276 |
| 1277 |
1258 static bool IsIdentityOperation(HValue* arg1, HValue* arg2, int32_t identity) { | 1278 static bool IsIdentityOperation(HValue* arg1, HValue* arg2, int32_t identity) { |
1259 return arg1->representation().IsSpecialization() && | 1279 return arg1->representation().IsSpecialization() && |
1260 arg2->EqualsInteger32Constant(identity); | 1280 arg2->EqualsInteger32Constant(identity); |
1261 } | 1281 } |
1262 | 1282 |
1263 | 1283 |
1264 HValue* HAdd::Canonicalize() { | 1284 HValue* HAdd::Canonicalize() { |
1265 // Adding 0 is an identity operation except in case of -0: -0 + 0 = +0 | 1285 // Adding 0 is an identity operation except in case of -0: -0 + 0 = +0 |
1266 if (IsIdentityOperation(left(), right(), 0) && | 1286 if (IsIdentityOperation(left(), right(), 0) && |
1267 !left()->representation().IsDouble()) { // Left could be -0. | 1287 !left()->representation().IsDouble()) { // Left could be -0. |
(...skipping 2474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3742 } | 3762 } |
3743 | 3763 |
3744 | 3764 |
3745 DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR(HAdd, +) | 3765 DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR(HAdd, +) |
3746 DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR(HMul, *) | 3766 DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR(HMul, *) |
3747 DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR(HSub, -) | 3767 DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR(HSub, -) |
3748 | 3768 |
3749 #undef DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR | 3769 #undef DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR |
3750 | 3770 |
3751 | 3771 |
| 3772 HAdd* HAdd::NewExternalPointerOffset(Zone* zone, |
| 3773 HValue* context, |
| 3774 HValue* base_pointer, |
| 3775 HValue* offset) { |
| 3776 HAdd* result = new(zone) HAdd(context, base_pointer, offset); |
| 3777 |
| 3778 result->set_observed_input_representation(1, Representation::External()); |
| 3779 result->initialize_output_representation(Representation::External()); |
| 3780 return result; |
| 3781 } |
| 3782 |
| 3783 |
3752 HInstruction* HStringAdd::New(Zone* zone, | 3784 HInstruction* HStringAdd::New(Zone* zone, |
3753 HValue* context, | 3785 HValue* context, |
3754 HValue* left, | 3786 HValue* left, |
3755 HValue* right, | 3787 HValue* right, |
3756 StringAddFlags flags) { | 3788 StringAddFlags flags) { |
3757 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) { | 3789 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) { |
3758 HConstant* c_right = HConstant::cast(right); | 3790 HConstant* c_right = HConstant::cast(right); |
3759 HConstant* c_left = HConstant::cast(left); | 3791 HConstant* c_left = HConstant::cast(left); |
3760 if (c_left->HasStringValue() && c_right->HasStringValue()) { | 3792 if (c_left->HasStringValue() && c_right->HasStringValue()) { |
3761 Handle<String> concat = zone->isolate()->factory()->NewFlatConcatString( | 3793 Handle<String> concat = zone->isolate()->factory()->NewFlatConcatString( |
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4351 break; | 4383 break; |
4352 case kExternalMemory: | 4384 case kExternalMemory: |
4353 stream->Add("[external-memory]"); | 4385 stream->Add("[external-memory]"); |
4354 break; | 4386 break; |
4355 } | 4387 } |
4356 | 4388 |
4357 stream->Add("@%d", offset()); | 4389 stream->Add("@%d", offset()); |
4358 } | 4390 } |
4359 | 4391 |
4360 } } // namespace v8::internal | 4392 } } // namespace v8::internal |
OLD | NEW |