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 1073 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1084 } else { | 1084 } else { |
1085 return; | 1085 return; |
1086 } | 1086 } |
1087 | 1087 |
1088 ReplaceAllUsesWith(index()); | 1088 ReplaceAllUsesWith(index()); |
1089 | 1089 |
1090 HValue* current_index = decomposition.base(); | 1090 HValue* current_index = decomposition.base(); |
1091 int actual_offset = decomposition.offset() + offset(); | 1091 int actual_offset = decomposition.offset() + offset(); |
1092 int actual_scale = decomposition.scale() + scale(); | 1092 int actual_scale = decomposition.scale() + scale(); |
1093 | 1093 |
1094 Zone* zone = block()->graph()->zone(); | |
1095 HValue* context = block()->graph()->GetInvalidContext(); | |
1094 if (actual_offset != 0) { | 1096 if (actual_offset != 0) { |
1095 HConstant* add_offset = new(block()->graph()->zone()) HConstant( | 1097 HConstant* add_offset = HConstant::New(zone, context, actual_offset); |
1096 actual_offset, index()->representation()); | |
1097 add_offset->InsertBefore(this); | 1098 add_offset->InsertBefore(this); |
1098 HInstruction* add = HAdd::New(block()->graph()->zone(), | 1099 HInstruction* add = HAdd::New(zone, context, |
1099 block()->graph()->GetInvalidContext(), current_index, add_offset); | 1100 current_index, add_offset); |
1100 add->InsertBefore(this); | 1101 add->InsertBefore(this); |
1101 add->AssumeRepresentation(index()->representation()); | 1102 add->AssumeRepresentation(index()->representation()); |
1102 add->ClearFlag(kCanOverflow); | 1103 add->ClearFlag(kCanOverflow); |
1103 current_index = add; | 1104 current_index = add; |
1104 } | 1105 } |
1105 | 1106 |
1106 if (actual_scale != 0) { | 1107 if (actual_scale != 0) { |
1107 HConstant* sar_scale = new(block()->graph()->zone()) HConstant( | 1108 HConstant* sar_scale = HConstant::New(zone, context, actual_scale); |
1108 actual_scale, index()->representation()); | |
1109 sar_scale->InsertBefore(this); | 1109 sar_scale->InsertBefore(this); |
1110 HInstruction* sar = HSar::New(block()->graph()->zone(), | 1110 HInstruction* sar = HSar::New(zone, context, |
1111 block()->graph()->GetInvalidContext(), current_index, sar_scale); | 1111 current_index, sar_scale); |
1112 sar->InsertBefore(this); | 1112 sar->InsertBefore(this); |
1113 sar->AssumeRepresentation(index()->representation()); | 1113 sar->AssumeRepresentation(index()->representation()); |
1114 current_index = sar; | 1114 current_index = sar; |
1115 } | 1115 } |
1116 | 1116 |
1117 SetOperandAt(0, current_index); | 1117 SetOperandAt(0, current_index); |
1118 | 1118 |
1119 base_ = NULL; | 1119 base_ = NULL; |
1120 offset_ = 0; | 1120 offset_ = 0; |
1121 scale_ = 0; | 1121 scale_ = 0; |
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1605 | 1605 |
1606 // Insert the new values in the graph. | 1606 // Insert the new values in the graph. |
1607 if (new_left->IsInstruction() && | 1607 if (new_left->IsInstruction() && |
1608 !HInstruction::cast(new_left)->IsLinked()) { | 1608 !HInstruction::cast(new_left)->IsLinked()) { |
1609 HInstruction::cast(new_left)->InsertBefore(this); | 1609 HInstruction::cast(new_left)->InsertBefore(this); |
1610 } | 1610 } |
1611 if (new_right->IsInstruction() && | 1611 if (new_right->IsInstruction() && |
1612 !HInstruction::cast(new_right)->IsLinked()) { | 1612 !HInstruction::cast(new_right)->IsLinked()) { |
1613 HInstruction::cast(new_right)->InsertBefore(this); | 1613 HInstruction::cast(new_right)->InsertBefore(this); |
1614 } | 1614 } |
1615 HMathFloorOfDiv* instr = new(block()->zone()) | 1615 HMathFloorOfDiv* instr = |
1616 HMathFloorOfDiv(context(), new_left, new_right); | 1616 HMathFloorOfDiv::New(block()->zone(), context(), new_left, new_right); |
1617 // Replace this HMathFloor instruction by the new HMathFloorOfDiv. | 1617 // Replace this HMathFloor instruction by the new HMathFloorOfDiv. |
1618 instr->InsertBefore(this); | 1618 instr->InsertBefore(this); |
1619 ReplaceAllUsesWith(instr); | 1619 ReplaceAllUsesWith(instr); |
1620 Kill(); | 1620 Kill(); |
1621 // We know the division had no other uses than this HMathFloor. Delete it. | 1621 // We know the division had no other uses than this HMathFloor. Delete it. |
1622 // Dead code elimination will deal with |left| and |right| if | 1622 // Dead code elimination will deal with |left| and |right| if |
1623 // appropriate. | 1623 // appropriate. |
1624 hdiv->DeleteAndReplaceWith(NULL); | 1624 hdiv->DeleteAndReplaceWith(NULL); |
1625 | 1625 |
1626 // Return NULL to remove this instruction from the graph. | 1626 // Return NULL to remove this instruction from the graph. |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2122 | 2122 |
2123 void InductionVariableData::ChecksRelatedToLength::UseNewIndexInCurrentBlock( | 2123 void InductionVariableData::ChecksRelatedToLength::UseNewIndexInCurrentBlock( |
2124 Token::Value token, | 2124 Token::Value token, |
2125 int32_t mask, | 2125 int32_t mask, |
2126 HValue* index_base, | 2126 HValue* index_base, |
2127 HValue* context) { | 2127 HValue* context) { |
2128 ASSERT(first_check_in_block() != NULL); | 2128 ASSERT(first_check_in_block() != NULL); |
2129 HValue* previous_index = first_check_in_block()->index(); | 2129 HValue* previous_index = first_check_in_block()->index(); |
2130 ASSERT(context != NULL); | 2130 ASSERT(context != NULL); |
2131 | 2131 |
2132 set_added_constant(new(index_base->block()->graph()->zone()) HConstant( | 2132 Zone* zone = index_base->block()->graph()->zone(); |
2133 mask, index_base->representation())); | 2133 set_added_constant(HConstant::New(zone, context, mask)); |
2134 if (added_index() != NULL) { | 2134 if (added_index() != NULL) { |
2135 added_constant()->InsertBefore(added_index()); | 2135 added_constant()->InsertBefore(added_index()); |
2136 } else { | 2136 } else { |
2137 added_constant()->InsertBefore(first_check_in_block()); | 2137 added_constant()->InsertBefore(first_check_in_block()); |
2138 } | 2138 } |
2139 | 2139 |
2140 if (added_index() == NULL) { | 2140 if (added_index() == NULL) { |
2141 first_check_in_block()->ReplaceAllUsesWith(first_check_in_block()->index()); | 2141 first_check_in_block()->ReplaceAllUsesWith(first_check_in_block()->index()); |
2142 HInstruction* new_index = HBitwise::New( | 2142 HInstruction* new_index = HBitwise::New(zone, context, token, index_base, |
2143 index_base->block()->graph()->zone(), | 2143 added_constant()); |
2144 token, context, index_base, added_constant()); | |
2145 ASSERT(new_index->IsBitwise()); | 2144 ASSERT(new_index->IsBitwise()); |
2146 new_index->ClearAllSideEffects(); | 2145 new_index->ClearAllSideEffects(); |
2147 new_index->AssumeRepresentation(Representation::Integer32()); | 2146 new_index->AssumeRepresentation(Representation::Integer32()); |
2148 set_added_index(HBitwise::cast(new_index)); | 2147 set_added_index(HBitwise::cast(new_index)); |
2149 added_index()->InsertBefore(first_check_in_block()); | 2148 added_index()->InsertBefore(first_check_in_block()); |
2150 } | 2149 } |
2151 ASSERT(added_index()->op() == token); | 2150 ASSERT(added_index()->op() == token); |
2152 | 2151 |
2153 added_index()->SetOperandAt(1, index_base); | 2152 added_index()->SetOperandAt(1, index_base); |
2154 added_index()->SetOperandAt(2, added_constant()); | 2153 added_index()->SetOperandAt(2, added_constant()); |
(...skipping 1341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3496 if (key()->IsLoadKeyed()) { | 3495 if (key()->IsLoadKeyed()) { |
3497 HLoadKeyed* key_load = HLoadKeyed::cast(key()); | 3496 HLoadKeyed* key_load = HLoadKeyed::cast(key()); |
3498 if (key_load->elements()->IsForInCacheArray()) { | 3497 if (key_load->elements()->IsForInCacheArray()) { |
3499 HForInCacheArray* names_cache = | 3498 HForInCacheArray* names_cache = |
3500 HForInCacheArray::cast(key_load->elements()); | 3499 HForInCacheArray::cast(key_load->elements()); |
3501 | 3500 |
3502 if (names_cache->enumerable() == object()) { | 3501 if (names_cache->enumerable() == object()) { |
3503 HForInCacheArray* index_cache = | 3502 HForInCacheArray* index_cache = |
3504 names_cache->index_cache(); | 3503 names_cache->index_cache(); |
3505 HCheckMapValue* map_check = | 3504 HCheckMapValue* map_check = |
3506 new(block()->zone()) HCheckMapValue(object(), names_cache->map()); | 3505 HCheckMapValue::New(block()->graph()->zone(), |
3507 HInstruction* index = new(block()->zone()) HLoadKeyed( | 3506 block()->graph()->GetInvalidContext(), |
3507 object(), | |
3508 names_cache->map()); | |
3509 HInstruction* index = HLoadKeyed::New( | |
3510 block()->graph()->zone(), | |
3511 block()->graph()->GetInvalidContext(), | |
3508 index_cache, | 3512 index_cache, |
3509 key_load->key(), | 3513 key_load->key(), |
3510 key_load->key(), | 3514 key_load->key(), |
3511 key_load->elements_kind()); | 3515 key_load->elements_kind()); |
3512 map_check->InsertBefore(this); | 3516 map_check->InsertBefore(this); |
3513 index->InsertBefore(this); | 3517 index->InsertBefore(this); |
3514 HLoadFieldByIndex* load = new(block()->zone()) HLoadFieldByIndex( | 3518 HLoadFieldByIndex* load = new(block()->zone()) HLoadFieldByIndex( |
3515 object(), index); | 3519 object(), index); |
3516 load->InsertBefore(this); | 3520 load->InsertBefore(this); |
3517 return load; | 3521 return load; |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3796 if (new_dominator_size > Page::kMaxNonCodeHeapObjectSize) { | 3800 if (new_dominator_size > Page::kMaxNonCodeHeapObjectSize) { |
3797 if (FLAG_trace_allocation_folding) { | 3801 if (FLAG_trace_allocation_folding) { |
3798 PrintF("#%d (%s) cannot fold into #%d (%s) due to size: %d\n", | 3802 PrintF("#%d (%s) cannot fold into #%d (%s) due to size: %d\n", |
3799 id(), Mnemonic(), dominator->id(), dominator->Mnemonic(), | 3803 id(), Mnemonic(), dominator->id(), dominator->Mnemonic(), |
3800 new_dominator_size); | 3804 new_dominator_size); |
3801 } | 3805 } |
3802 return; | 3806 return; |
3803 } | 3807 } |
3804 HBasicBlock* block = dominator->block(); | 3808 HBasicBlock* block = dominator->block(); |
3805 Zone* zone = block->zone(); | 3809 Zone* zone = block->zone(); |
3806 HInstruction* new_dominator_size_constant = new(zone) HConstant( | 3810 HInstruction* new_dominator_size_constant = |
3807 new_dominator_size); | 3811 HConstant::New(zone, context(), new_dominator_size); |
3808 new_dominator_size_constant->InsertBefore(dominator_allocate_instr); | 3812 new_dominator_size_constant->InsertBefore(dominator_allocate_instr); |
3809 dominator_allocate_instr->UpdateSize(new_dominator_size_constant); | 3813 dominator_allocate_instr->UpdateSize(new_dominator_size_constant); |
3810 | 3814 |
3811 #ifdef VERIFY_HEAP | 3815 #ifdef VERIFY_HEAP |
3812 if (FLAG_verify_heap) { | 3816 if (FLAG_verify_heap) { |
3813 dominator_allocate_instr->SetFlags(HAllocate::PREFILL_WITH_FILLER); | 3817 dominator_allocate_instr->SetFlags(HAllocate::PREFILL_WITH_FILLER); |
3814 } | 3818 } |
3815 #endif | 3819 #endif |
3816 | 3820 |
3817 // After that replace the dominated allocate instruction. | 3821 // After that replace the dominated allocate instruction. |
3818 HInstruction* dominated_allocate_instr = | 3822 HInstruction* dominated_allocate_instr = |
3819 new(zone) HInnerAllocatedObject(dominator_allocate_instr, | 3823 HInnerAllocatedObject::New(zone, |
3820 dominator_size_constant, | 3824 context(), |
3821 type()); | 3825 dominator_allocate_instr, |
3826 dominator_size_constant, | |
3827 type()); | |
3822 dominated_allocate_instr->InsertBefore(this); | 3828 dominated_allocate_instr->InsertBefore(this); |
3823 DeleteAndReplaceWith(dominated_allocate_instr); | 3829 DeleteAndReplaceWith(dominated_allocate_instr); |
3824 if (FLAG_trace_allocation_folding) { | 3830 if (FLAG_trace_allocation_folding) { |
3825 PrintF("#%d (%s) folded into #%d (%s)\n", | 3831 PrintF("#%d (%s) folded into #%d (%s)\n", |
3826 id(), Mnemonic(), dominator->id(), dominator->Mnemonic()); | 3832 id(), Mnemonic(), dominator->id(), dominator->Mnemonic()); |
3827 } | 3833 } |
3828 } | 3834 } |
3829 | 3835 |
3830 | 3836 |
3831 void HAllocate::PrintDataTo(StringStream* stream) { | 3837 void HAllocate::PrintDataTo(StringStream* stream) { |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3959 return false; | 3965 return false; |
3960 } | 3966 } |
3961 if (HChange::cast(value())->value()->type().IsSmi()) { | 3967 if (HChange::cast(value())->value()->type().IsSmi()) { |
3962 return false; | 3968 return false; |
3963 } | 3969 } |
3964 } | 3970 } |
3965 return true; | 3971 return true; |
3966 } | 3972 } |
3967 | 3973 |
3968 | 3974 |
3969 #define H_CONSTANT_INT(val) \ | 3975 #define H_CONSTANT_INT(val) \ |
3970 new(zone) HConstant(static_cast<int32_t>(val)) | 3976 HConstant::New(zone, context, static_cast<int32_t>(val)) |
3971 #define H_CONSTANT_DOUBLE(val) \ | 3977 #define H_CONSTANT_DOUBLE(val) \ |
3972 new(zone) HConstant(static_cast<double>(val), Representation::Double()) | 3978 HConstant::New(zone, context, static_cast<double>(val)) |
3973 | 3979 |
3974 #define DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR(HInstr, op) \ | 3980 #define DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR(HInstr, op) \ |
3975 HInstruction* HInstr::New( \ | 3981 HInstruction* HInstr::New( \ |
3976 Zone* zone, HValue* context, HValue* left, HValue* right) { \ | 3982 Zone* zone, HValue* context, HValue* left, HValue* right) { \ |
3977 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) { \ | 3983 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) { \ |
3978 HConstant* c_left = HConstant::cast(left); \ | 3984 HConstant* c_left = HConstant::cast(left); \ |
3979 HConstant* c_right = HConstant::cast(right); \ | 3985 HConstant* c_right = HConstant::cast(right); \ |
3980 if ((c_left->HasNumberValue() && c_right->HasNumberValue())) { \ | 3986 if ((c_left->HasNumberValue() && c_right->HasNumberValue())) { \ |
3981 double double_res = c_left->DoubleValue() op c_right->DoubleValue(); \ | 3987 double double_res = c_left->DoubleValue() op c_right->DoubleValue(); \ |
3982 if (TypeInfo::IsInt32Double(double_res)) { \ | 3988 if (TypeInfo::IsInt32Double(double_res)) { \ |
3983 return H_CONSTANT_INT(double_res); \ | 3989 return H_CONSTANT_INT(double_res); \ |
3984 } \ | 3990 } \ |
3985 return H_CONSTANT_DOUBLE(double_res); \ | 3991 return H_CONSTANT_DOUBLE(double_res); \ |
3986 } \ | 3992 } \ |
3987 } \ | 3993 } \ |
3988 return new(zone) HInstr(context, left, right); \ | 3994 return new(zone) HInstr(context, left, right); \ |
3989 } | 3995 } |
3990 | 3996 |
3991 | 3997 |
3992 DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR(HAdd, +) | 3998 DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR(HAdd, +) |
3993 DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR(HMul, *) | 3999 DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR(HMul, *) |
3994 DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR(HSub, -) | 4000 DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR(HSub, -) |
3995 | 4001 |
3996 #undef DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR | 4002 #undef DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR |
3997 | 4003 |
3998 | 4004 |
3999 HInstruction* HStringAdd::New(Zone* zone, | 4005 HInstruction* HStringAdd::New(Zone* zone, |
4000 HValue* context, | 4006 HValue* context, |
4001 HValue* left, | 4007 HValue* left, |
4002 HValue* right, | 4008 HValue* right, |
4003 StringAddFlags flags) { | 4009 StringAddFlags flags) { |
4004 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) { | 4010 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) { |
4005 HConstant* c_right = HConstant::cast(right); | 4011 HConstant* c_right = HConstant::cast(right); |
4006 HConstant* c_left = HConstant::cast(left); | 4012 HConstant* c_left = HConstant::cast(left); |
4007 if (c_left->HasStringValue() && c_right->HasStringValue()) { | 4013 if (c_left->HasStringValue() && c_right->HasStringValue()) { |
4008 Handle<String> concat = zone->isolate()->factory()->NewFlatConcatString( | 4014 Handle<String> concat = zone->isolate()->factory()->NewFlatConcatString( |
4009 c_left->StringValue(), c_right->StringValue()); | 4015 c_left->StringValue(), c_right->StringValue()); |
4010 return new(zone) HConstant(concat, Representation::Tagged()); | 4016 return HConstant::New(zone, context, concat); |
4011 } | 4017 } |
4012 } | 4018 } |
4013 return new(zone) HStringAdd(context, left, right, flags); | 4019 return new(zone) HStringAdd(context, left, right, flags); |
4014 } | 4020 } |
4015 | 4021 |
4016 | 4022 |
4017 HInstruction* HStringCharFromCode::New( | 4023 HInstruction* HStringCharFromCode::New( |
4018 Zone* zone, HValue* context, HValue* char_code) { | 4024 Zone* zone, HValue* context, HValue* char_code) { |
4019 if (FLAG_fold_constants && char_code->IsConstant()) { | 4025 if (FLAG_fold_constants && char_code->IsConstant()) { |
4020 HConstant* c_code = HConstant::cast(char_code); | 4026 HConstant* c_code = HConstant::cast(char_code); |
4021 Isolate* isolate = Isolate::Current(); | 4027 Isolate* isolate = Isolate::Current(); |
4022 if (c_code->HasNumberValue()) { | 4028 if (c_code->HasNumberValue()) { |
4023 if (std::isfinite(c_code->DoubleValue())) { | 4029 if (std::isfinite(c_code->DoubleValue())) { |
4024 uint32_t code = c_code->NumberValueAsInteger32() & 0xffff; | 4030 uint32_t code = c_code->NumberValueAsInteger32() & 0xffff; |
4025 return new(zone) HConstant(LookupSingleCharacterStringFromCode(isolate, | 4031 return HConstant::New(zone, context, |
4026 code), | 4032 LookupSingleCharacterStringFromCode(isolate, code)); |
4027 Representation::Tagged()); | |
4028 } | 4033 } |
4029 return new(zone) HConstant(isolate->factory()->empty_string(), | 4034 return HConstant::New(zone, context, isolate->factory()->empty_string()); |
4030 Representation::Tagged()); | |
4031 } | 4035 } |
4032 } | 4036 } |
4033 return new(zone) HStringCharFromCode(context, char_code); | 4037 return new(zone) HStringCharFromCode(context, char_code); |
4034 } | 4038 } |
4035 | 4039 |
4036 | 4040 |
4037 HInstruction* HStringLength::New(Zone* zone, HValue* string) { | 4041 HInstruction* HStringLength::New(Zone* zone, HValue* context, HValue* string) { |
4038 if (FLAG_fold_constants && string->IsConstant()) { | 4042 if (FLAG_fold_constants && string->IsConstant()) { |
4039 HConstant* c_string = HConstant::cast(string); | 4043 HConstant* c_string = HConstant::cast(string); |
4040 if (c_string->HasStringValue()) { | 4044 if (c_string->HasStringValue()) { |
4041 return new(zone) HConstant(c_string->StringValue()->length()); | 4045 return HConstant::New(zone, context, c_string->StringValue()->length()); |
4042 } | 4046 } |
4043 } | 4047 } |
4044 return new(zone) HStringLength(string); | 4048 return new(zone) HStringLength(string); |
4045 } | 4049 } |
4046 | 4050 |
4047 | 4051 |
4048 HInstruction* HUnaryMathOperation::New( | 4052 HInstruction* HUnaryMathOperation::New( |
4049 Zone* zone, HValue* context, HValue* value, BuiltinFunctionId op) { | 4053 Zone* zone, HValue* context, HValue* value, BuiltinFunctionId op) { |
4050 do { | 4054 do { |
4051 if (!FLAG_fold_constants) break; | 4055 if (!FLAG_fold_constants) break; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4106 return H_CONSTANT_DOUBLE(floor(d)); | 4110 return H_CONSTANT_DOUBLE(floor(d)); |
4107 default: | 4111 default: |
4108 UNREACHABLE(); | 4112 UNREACHABLE(); |
4109 break; | 4113 break; |
4110 } | 4114 } |
4111 } while (false); | 4115 } while (false); |
4112 return new(zone) HUnaryMathOperation(context, value, op); | 4116 return new(zone) HUnaryMathOperation(context, value, op); |
4113 } | 4117 } |
4114 | 4118 |
4115 | 4119 |
4116 HInstruction* HPower::New(Zone* zone, HValue* left, HValue* right) { | 4120 HInstruction* HPower::New(Zone* zone, |
4121 HValue* context, | |
4122 HValue* left, | |
4123 HValue* right) { | |
4117 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) { | 4124 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) { |
4118 HConstant* c_left = HConstant::cast(left); | 4125 HConstant* c_left = HConstant::cast(left); |
4119 HConstant* c_right = HConstant::cast(right); | 4126 HConstant* c_right = HConstant::cast(right); |
4120 if (c_left->HasNumberValue() && c_right->HasNumberValue()) { | 4127 if (c_left->HasNumberValue() && c_right->HasNumberValue()) { |
4121 double result = power_helper(c_left->DoubleValue(), | 4128 double result = power_helper(c_left->DoubleValue(), |
4122 c_right->DoubleValue()); | 4129 c_right->DoubleValue()); |
4123 return H_CONSTANT_DOUBLE(std::isnan(result) ? OS::nan_value() : result); | 4130 return H_CONSTANT_DOUBLE(std::isnan(result) ? OS::nan_value() : result); |
4124 } | 4131 } |
4125 } | 4132 } |
4126 return new(zone) HPower(left, right); | 4133 return new(zone) HPower(left, right); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4205 Double(c_right->DoubleValue()).Sign(); // Right could be -0. | 4212 Double(c_right->DoubleValue()).Sign(); // Right could be -0. |
4206 return H_CONSTANT_DOUBLE(sign * V8_INFINITY); | 4213 return H_CONSTANT_DOUBLE(sign * V8_INFINITY); |
4207 } | 4214 } |
4208 } | 4215 } |
4209 } | 4216 } |
4210 return new(zone) HDiv(context, left, right); | 4217 return new(zone) HDiv(context, left, right); |
4211 } | 4218 } |
4212 | 4219 |
4213 | 4220 |
4214 HInstruction* HBitwise::New( | 4221 HInstruction* HBitwise::New( |
4215 Zone* zone, Token::Value op, HValue* context, HValue* left, HValue* right) { | 4222 Zone* zone, HValue* context, Token::Value op, HValue* left, HValue* right) { |
4216 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) { | 4223 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) { |
4217 HConstant* c_left = HConstant::cast(left); | 4224 HConstant* c_left = HConstant::cast(left); |
4218 HConstant* c_right = HConstant::cast(right); | 4225 HConstant* c_right = HConstant::cast(right); |
4219 if ((c_left->HasNumberValue() && c_right->HasNumberValue())) { | 4226 if ((c_left->HasNumberValue() && c_right->HasNumberValue())) { |
4220 int32_t result; | 4227 int32_t result; |
4221 int32_t v_left = c_left->NumberValueAsInteger32(); | 4228 int32_t v_left = c_left->NumberValueAsInteger32(); |
4222 int32_t v_right = c_right->NumberValueAsInteger32(); | 4229 int32_t v_right = c_right->NumberValueAsInteger32(); |
4223 switch (op) { | 4230 switch (op) { |
4224 case Token::BIT_XOR: | 4231 case Token::BIT_XOR: |
4225 result = v_left ^ v_right; | 4232 result = v_left ^ v_right; |
4226 break; | 4233 break; |
4227 case Token::BIT_AND: | 4234 case Token::BIT_AND: |
4228 result = v_left & v_right; | 4235 result = v_left & v_right; |
4229 break; | 4236 break; |
4230 case Token::BIT_OR: | 4237 case Token::BIT_OR: |
4231 result = v_left | v_right; | 4238 result = v_left | v_right; |
4232 break; | 4239 break; |
4233 default: | 4240 default: |
4234 result = 0; // Please the compiler. | 4241 result = 0; // Please the compiler. |
4235 UNREACHABLE(); | 4242 UNREACHABLE(); |
4236 } | 4243 } |
4237 return H_CONSTANT_INT(result); | 4244 return H_CONSTANT_INT(result); |
4238 } | 4245 } |
4239 } | 4246 } |
4240 return new(zone) HBitwise(op, context, left, right); | 4247 return new(zone) HBitwise(context, op, left, right); |
4241 } | 4248 } |
4242 | 4249 |
4243 | 4250 |
4244 #define DEFINE_NEW_H_BITWISE_INSTR(HInstr, result) \ | 4251 #define DEFINE_NEW_H_BITWISE_INSTR(HInstr, result) \ |
4245 HInstruction* HInstr::New( \ | 4252 HInstruction* HInstr::New( \ |
4246 Zone* zone, HValue* context, HValue* left, HValue* right) { \ | 4253 Zone* zone, HValue* context, HValue* left, HValue* right) { \ |
4247 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) { \ | 4254 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) { \ |
4248 HConstant* c_left = HConstant::cast(left); \ | 4255 HConstant* c_left = HConstant::cast(left); \ |
4249 HConstant* c_right = HConstant::cast(right); \ | 4256 HConstant* c_right = HConstant::cast(right); \ |
4250 if ((c_left->HasNumberValue() && c_right->HasNumberValue())) { \ | 4257 if ((c_left->HasNumberValue() && c_right->HasNumberValue())) { \ |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4299 for (int i = 0; i < OperandCount(); ++i) { | 4306 for (int i = 0; i < OperandCount(); ++i) { |
4300 if (!OperandAt(i)->IsConstant()) return; | 4307 if (!OperandAt(i)->IsConstant()) return; |
4301 } | 4308 } |
4302 HGraph* graph = block()->graph(); | 4309 HGraph* graph = block()->graph(); |
4303 for (int i = 0; i < OperandCount(); ++i) { | 4310 for (int i = 0; i < OperandCount(); ++i) { |
4304 HConstant* operand = HConstant::cast(OperandAt(i)); | 4311 HConstant* operand = HConstant::cast(OperandAt(i)); |
4305 if (operand->HasInteger32Value()) { | 4312 if (operand->HasInteger32Value()) { |
4306 continue; | 4313 continue; |
4307 } else if (operand->HasDoubleValue()) { | 4314 } else if (operand->HasDoubleValue()) { |
4308 HConstant* integer_input = | 4315 HConstant* integer_input = |
4309 new(graph->zone()) HConstant(DoubleToInt32(operand->DoubleValue())); | 4316 HConstant::New(graph->zone(), NULL, |
Toon Verwaest
2013/07/31 12:56:37
graph->GetInvalidContext()
danno
2013/07/31 14:10:09
Done.
| |
4317 DoubleToInt32(operand->DoubleValue())); | |
4310 integer_input->InsertAfter(operand); | 4318 integer_input->InsertAfter(operand); |
4311 SetOperandAt(i, integer_input); | 4319 SetOperandAt(i, integer_input); |
4312 } else if (operand == graph->GetConstantTrue()) { | 4320 } else if (operand == graph->GetConstantTrue()) { |
4313 SetOperandAt(i, graph->GetConstant1()); | 4321 SetOperandAt(i, graph->GetConstant1()); |
4314 } else { | 4322 } else { |
4315 // This catches |false|, |undefined|, strings and objects. | 4323 // This catches |false|, |undefined|, strings and objects. |
4316 SetOperandAt(i, graph->GetConstant0()); | 4324 SetOperandAt(i, graph->GetConstant0()); |
4317 } | 4325 } |
4318 } | 4326 } |
4319 // Overwrite observed input representations because they are likely Tagged. | 4327 // Overwrite observed input representations because they are likely Tagged. |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4570 break; | 4578 break; |
4571 case kExternalMemory: | 4579 case kExternalMemory: |
4572 stream->Add("[external-memory]"); | 4580 stream->Add("[external-memory]"); |
4573 break; | 4581 break; |
4574 } | 4582 } |
4575 | 4583 |
4576 stream->Add("@%d", offset()); | 4584 stream->Add("@%d", offset()); |
4577 } | 4585 } |
4578 | 4586 |
4579 } } // namespace v8::internal | 4587 } } // namespace v8::internal |
OLD | NEW |