| 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 1119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3274 // We don't have an easy way to handle both a call (to the generic stub) and | 3273 // We don't have an easy way to handle both a call (to the generic stub) and |
| 3275 // a deopt in the same hydrogen instruction, so in this case we don't add | 3274 // a deopt in the same hydrogen instruction, so in this case we don't add |
| 3276 // the negative lookups which can deopt - just let the generic stub handle | 3275 // the negative lookups which can deopt - just let the generic stub handle |
| 3277 // them. | 3276 // them. |
| 3278 SetAllSideEffects(); | 3277 SetAllSideEffects(); |
| 3279 need_generic_ = true; | 3278 need_generic_ = true; |
| 3280 } | 3279 } |
| 3281 } | 3280 } |
| 3282 | 3281 |
| 3283 | 3282 |
| 3284 HCheckMaps* HCheckMaps::New(HValue* value, | 3283 HCheckMaps* HCheckMaps::New(Zone* zone, |
| 3284 HValue* context, |
| 3285 HValue* value, |
| 3285 Handle<Map> map, | 3286 Handle<Map> map, |
| 3286 Zone* zone, | |
| 3287 CompilationInfo* info, | 3287 CompilationInfo* info, |
| 3288 HValue* typecheck) { | 3288 HValue* typecheck) { |
| 3289 HCheckMaps* check_map = new(zone) HCheckMaps(value, zone, typecheck); | 3289 HCheckMaps* check_map = new(zone) HCheckMaps(value, zone, typecheck); |
| 3290 check_map->map_set_.Add(map, zone); | 3290 check_map->map_set_.Add(map, zone); |
| 3291 if (map->CanOmitMapChecks() && | 3291 if (map->CanOmitMapChecks() && |
| 3292 value->IsConstant() && | 3292 value->IsConstant() && |
| 3293 HConstant::cast(value)->InstanceOf(map)) { | 3293 HConstant::cast(value)->InstanceOf(map)) { |
| 3294 check_map->omit(info); | 3294 check_map->omit(info); |
| 3295 } | 3295 } |
| 3296 return check_map; | 3296 return check_map; |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3462 if (key()->IsLoadKeyed()) { | 3462 if (key()->IsLoadKeyed()) { |
| 3463 HLoadKeyed* key_load = HLoadKeyed::cast(key()); | 3463 HLoadKeyed* key_load = HLoadKeyed::cast(key()); |
| 3464 if (key_load->elements()->IsForInCacheArray()) { | 3464 if (key_load->elements()->IsForInCacheArray()) { |
| 3465 HForInCacheArray* names_cache = | 3465 HForInCacheArray* names_cache = |
| 3466 HForInCacheArray::cast(key_load->elements()); | 3466 HForInCacheArray::cast(key_load->elements()); |
| 3467 | 3467 |
| 3468 if (names_cache->enumerable() == object()) { | 3468 if (names_cache->enumerable() == object()) { |
| 3469 HForInCacheArray* index_cache = | 3469 HForInCacheArray* index_cache = |
| 3470 names_cache->index_cache(); | 3470 names_cache->index_cache(); |
| 3471 HCheckMapValue* map_check = | 3471 HCheckMapValue* map_check = |
| 3472 new(block()->zone()) HCheckMapValue(object(), names_cache->map()); | 3472 HCheckMapValue::New(block()->graph()->zone(), |
| 3473 HInstruction* index = new(block()->zone()) HLoadKeyed( | 3473 block()->graph()->GetInvalidContext(), |
| 3474 object(), |
| 3475 names_cache->map()); |
| 3476 HInstruction* index = HLoadKeyed::New( |
| 3477 block()->graph()->zone(), |
| 3478 block()->graph()->GetInvalidContext(), |
| 3474 index_cache, | 3479 index_cache, |
| 3475 key_load->key(), | 3480 key_load->key(), |
| 3476 key_load->key(), | 3481 key_load->key(), |
| 3477 key_load->elements_kind()); | 3482 key_load->elements_kind()); |
| 3478 map_check->InsertBefore(this); | 3483 map_check->InsertBefore(this); |
| 3479 index->InsertBefore(this); | 3484 index->InsertBefore(this); |
| 3480 HLoadFieldByIndex* load = new(block()->zone()) HLoadFieldByIndex( | 3485 HLoadFieldByIndex* load = new(block()->zone()) HLoadFieldByIndex( |
| 3481 object(), index); | 3486 object(), index); |
| 3482 load->InsertBefore(this); | 3487 load->InsertBefore(this); |
| 3483 return load; | 3488 return load; |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3696 if (new_dominator_size > Page::kMaxNonCodeHeapObjectSize) { | 3701 if (new_dominator_size > Page::kMaxNonCodeHeapObjectSize) { |
| 3697 if (FLAG_trace_allocation_folding) { | 3702 if (FLAG_trace_allocation_folding) { |
| 3698 PrintF("#%d (%s) cannot fold into #%d (%s) due to size: %d\n", | 3703 PrintF("#%d (%s) cannot fold into #%d (%s) due to size: %d\n", |
| 3699 id(), Mnemonic(), dominator->id(), dominator->Mnemonic(), | 3704 id(), Mnemonic(), dominator->id(), dominator->Mnemonic(), |
| 3700 new_dominator_size); | 3705 new_dominator_size); |
| 3701 } | 3706 } |
| 3702 return; | 3707 return; |
| 3703 } | 3708 } |
| 3704 HBasicBlock* block = dominator->block(); | 3709 HBasicBlock* block = dominator->block(); |
| 3705 Zone* zone = block->zone(); | 3710 Zone* zone = block->zone(); |
| 3706 HInstruction* new_dominator_size_constant = new(zone) HConstant( | 3711 HInstruction* new_dominator_size_constant = |
| 3707 new_dominator_size); | 3712 HConstant::New(zone, context(), new_dominator_size); |
| 3708 new_dominator_size_constant->InsertBefore(dominator_allocate_instr); | 3713 new_dominator_size_constant->InsertBefore(dominator_allocate_instr); |
| 3709 dominator_allocate_instr->UpdateSize(new_dominator_size_constant); | 3714 dominator_allocate_instr->UpdateSize(new_dominator_size_constant); |
| 3710 | 3715 |
| 3711 #ifdef VERIFY_HEAP | 3716 #ifdef VERIFY_HEAP |
| 3712 if (FLAG_verify_heap) { | 3717 if (FLAG_verify_heap) { |
| 3713 dominator_allocate_instr->MakePrefillWithFiller(); | 3718 dominator_allocate_instr->MakePrefillWithFiller(); |
| 3714 } | 3719 } |
| 3715 #endif | 3720 #endif |
| 3716 | 3721 |
| 3717 // After that replace the dominated allocate instruction. | 3722 // After that replace the dominated allocate instruction. |
| 3718 HInstruction* dominated_allocate_instr = | 3723 HInstruction* dominated_allocate_instr = |
| 3719 new(zone) HInnerAllocatedObject(dominator_allocate_instr, | 3724 HInnerAllocatedObject::New(zone, |
| 3720 dominator_size_constant, | 3725 context(), |
| 3721 type()); | 3726 dominator_allocate_instr, |
| 3727 dominator_size_constant, |
| 3728 type()); |
| 3722 dominated_allocate_instr->InsertBefore(this); | 3729 dominated_allocate_instr->InsertBefore(this); |
| 3723 DeleteAndReplaceWith(dominated_allocate_instr); | 3730 DeleteAndReplaceWith(dominated_allocate_instr); |
| 3724 if (FLAG_trace_allocation_folding) { | 3731 if (FLAG_trace_allocation_folding) { |
| 3725 PrintF("#%d (%s) folded into #%d (%s)\n", | 3732 PrintF("#%d (%s) folded into #%d (%s)\n", |
| 3726 id(), Mnemonic(), dominator->id(), dominator->Mnemonic()); | 3733 id(), Mnemonic(), dominator->id(), dominator->Mnemonic()); |
| 3727 } | 3734 } |
| 3728 } | 3735 } |
| 3729 | 3736 |
| 3730 | 3737 |
| 3731 void HAllocate::PrintDataTo(StringStream* stream) { | 3738 void HAllocate::PrintDataTo(StringStream* stream) { |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3849 return false; | 3856 return false; |
| 3850 } | 3857 } |
| 3851 if (HChange::cast(value())->value()->type().IsSmi()) { | 3858 if (HChange::cast(value())->value()->type().IsSmi()) { |
| 3852 return false; | 3859 return false; |
| 3853 } | 3860 } |
| 3854 } | 3861 } |
| 3855 return true; | 3862 return true; |
| 3856 } | 3863 } |
| 3857 | 3864 |
| 3858 | 3865 |
| 3859 #define H_CONSTANT_INT(val) \ | 3866 #define H_CONSTANT_INT(val) \ |
| 3860 new(zone) HConstant(static_cast<int32_t>(val)) | 3867 HConstant::New(zone, context, static_cast<int32_t>(val)) |
| 3861 #define H_CONSTANT_DOUBLE(val) \ | 3868 #define H_CONSTANT_DOUBLE(val) \ |
| 3862 new(zone) HConstant(static_cast<double>(val), Representation::Double()) | 3869 HConstant::New(zone, context, static_cast<double>(val)) |
| 3863 | 3870 |
| 3864 #define DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR(HInstr, op) \ | 3871 #define DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR(HInstr, op) \ |
| 3865 HInstruction* HInstr::New( \ | 3872 HInstruction* HInstr::New( \ |
| 3866 Zone* zone, HValue* context, HValue* left, HValue* right) { \ | 3873 Zone* zone, HValue* context, HValue* left, HValue* right) { \ |
| 3867 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) { \ | 3874 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) { \ |
| 3868 HConstant* c_left = HConstant::cast(left); \ | 3875 HConstant* c_left = HConstant::cast(left); \ |
| 3869 HConstant* c_right = HConstant::cast(right); \ | 3876 HConstant* c_right = HConstant::cast(right); \ |
| 3870 if ((c_left->HasNumberValue() && c_right->HasNumberValue())) { \ | 3877 if ((c_left->HasNumberValue() && c_right->HasNumberValue())) { \ |
| 3871 double double_res = c_left->DoubleValue() op c_right->DoubleValue(); \ | 3878 double double_res = c_left->DoubleValue() op c_right->DoubleValue(); \ |
| 3872 if (TypeInfo::IsInt32Double(double_res)) { \ | 3879 if (TypeInfo::IsInt32Double(double_res)) { \ |
| 3873 return H_CONSTANT_INT(double_res); \ | 3880 return H_CONSTANT_INT(double_res); \ |
| 3874 } \ | 3881 } \ |
| 3875 return H_CONSTANT_DOUBLE(double_res); \ | 3882 return H_CONSTANT_DOUBLE(double_res); \ |
| 3876 } \ | 3883 } \ |
| 3877 } \ | 3884 } \ |
| 3878 return new(zone) HInstr(context, left, right); \ | 3885 return new(zone) HInstr(context, left, right); \ |
| 3879 } | 3886 } |
| 3880 | 3887 |
| 3881 | 3888 |
| 3882 DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR(HAdd, +) | 3889 DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR(HAdd, +) |
| 3883 DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR(HMul, *) | 3890 DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR(HMul, *) |
| 3884 DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR(HSub, -) | 3891 DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR(HSub, -) |
| 3885 | 3892 |
| 3886 #undef DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR | 3893 #undef DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR |
| 3887 | 3894 |
| 3888 | 3895 |
| 3889 HInstruction* HStringAdd::New(Zone* zone, | 3896 HInstruction* HStringAdd::New(Zone* zone, |
| 3890 HValue* context, | 3897 HValue* context, |
| 3891 HValue* left, | 3898 HValue* left, |
| 3892 HValue* right, | 3899 HValue* right, |
| 3893 StringAddFlags flags) { | 3900 StringAddFlags flags) { |
| 3894 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) { | 3901 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) { |
| 3895 HConstant* c_right = HConstant::cast(right); | 3902 HConstant* c_right = HConstant::cast(right); |
| 3896 HConstant* c_left = HConstant::cast(left); | 3903 HConstant* c_left = HConstant::cast(left); |
| 3897 if (c_left->HasStringValue() && c_right->HasStringValue()) { | 3904 if (c_left->HasStringValue() && c_right->HasStringValue()) { |
| 3898 Handle<String> concat = zone->isolate()->factory()->NewFlatConcatString( | 3905 Handle<String> concat = zone->isolate()->factory()->NewFlatConcatString( |
| 3899 c_left->StringValue(), c_right->StringValue()); | 3906 c_left->StringValue(), c_right->StringValue()); |
| 3900 return new(zone) HConstant(concat, Representation::Tagged()); | 3907 return HConstant::New(zone, context, concat); |
| 3901 } | 3908 } |
| 3902 } | 3909 } |
| 3903 return new(zone) HStringAdd(context, left, right, flags); | 3910 return new(zone) HStringAdd(context, left, right, flags); |
| 3904 } | 3911 } |
| 3905 | 3912 |
| 3906 | 3913 |
| 3907 HInstruction* HStringCharFromCode::New( | 3914 HInstruction* HStringCharFromCode::New( |
| 3908 Zone* zone, HValue* context, HValue* char_code) { | 3915 Zone* zone, HValue* context, HValue* char_code) { |
| 3909 if (FLAG_fold_constants && char_code->IsConstant()) { | 3916 if (FLAG_fold_constants && char_code->IsConstant()) { |
| 3910 HConstant* c_code = HConstant::cast(char_code); | 3917 HConstant* c_code = HConstant::cast(char_code); |
| 3911 Isolate* isolate = Isolate::Current(); | 3918 Isolate* isolate = Isolate::Current(); |
| 3912 if (c_code->HasNumberValue()) { | 3919 if (c_code->HasNumberValue()) { |
| 3913 if (std::isfinite(c_code->DoubleValue())) { | 3920 if (std::isfinite(c_code->DoubleValue())) { |
| 3914 uint32_t code = c_code->NumberValueAsInteger32() & 0xffff; | 3921 uint32_t code = c_code->NumberValueAsInteger32() & 0xffff; |
| 3915 return new(zone) HConstant(LookupSingleCharacterStringFromCode(isolate, | 3922 return HConstant::New(zone, context, |
| 3916 code), | 3923 LookupSingleCharacterStringFromCode(isolate, code)); |
| 3917 Representation::Tagged()); | |
| 3918 } | 3924 } |
| 3919 return new(zone) HConstant(isolate->factory()->empty_string(), | 3925 return HConstant::New(zone, context, isolate->factory()->empty_string()); |
| 3920 Representation::Tagged()); | |
| 3921 } | 3926 } |
| 3922 } | 3927 } |
| 3923 return new(zone) HStringCharFromCode(context, char_code); | 3928 return new(zone) HStringCharFromCode(context, char_code); |
| 3924 } | 3929 } |
| 3925 | 3930 |
| 3926 | 3931 |
| 3927 HInstruction* HStringLength::New(Zone* zone, HValue* string) { | 3932 HInstruction* HStringLength::New(Zone* zone, HValue* context, HValue* string) { |
| 3928 if (FLAG_fold_constants && string->IsConstant()) { | 3933 if (FLAG_fold_constants && string->IsConstant()) { |
| 3929 HConstant* c_string = HConstant::cast(string); | 3934 HConstant* c_string = HConstant::cast(string); |
| 3930 if (c_string->HasStringValue()) { | 3935 if (c_string->HasStringValue()) { |
| 3931 return new(zone) HConstant(c_string->StringValue()->length()); | 3936 return HConstant::New(zone, context, c_string->StringValue()->length()); |
| 3932 } | 3937 } |
| 3933 } | 3938 } |
| 3934 return new(zone) HStringLength(string); | 3939 return new(zone) HStringLength(string); |
| 3935 } | 3940 } |
| 3936 | 3941 |
| 3937 | 3942 |
| 3938 HInstruction* HUnaryMathOperation::New( | 3943 HInstruction* HUnaryMathOperation::New( |
| 3939 Zone* zone, HValue* context, HValue* value, BuiltinFunctionId op) { | 3944 Zone* zone, HValue* context, HValue* value, BuiltinFunctionId op) { |
| 3940 do { | 3945 do { |
| 3941 if (!FLAG_fold_constants) break; | 3946 if (!FLAG_fold_constants) break; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3996 return H_CONSTANT_DOUBLE(floor(d)); | 4001 return H_CONSTANT_DOUBLE(floor(d)); |
| 3997 default: | 4002 default: |
| 3998 UNREACHABLE(); | 4003 UNREACHABLE(); |
| 3999 break; | 4004 break; |
| 4000 } | 4005 } |
| 4001 } while (false); | 4006 } while (false); |
| 4002 return new(zone) HUnaryMathOperation(context, value, op); | 4007 return new(zone) HUnaryMathOperation(context, value, op); |
| 4003 } | 4008 } |
| 4004 | 4009 |
| 4005 | 4010 |
| 4006 HInstruction* HPower::New(Zone* zone, HValue* left, HValue* right) { | 4011 HInstruction* HPower::New(Zone* zone, |
| 4012 HValue* context, |
| 4013 HValue* left, |
| 4014 HValue* right) { |
| 4007 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) { | 4015 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) { |
| 4008 HConstant* c_left = HConstant::cast(left); | 4016 HConstant* c_left = HConstant::cast(left); |
| 4009 HConstant* c_right = HConstant::cast(right); | 4017 HConstant* c_right = HConstant::cast(right); |
| 4010 if (c_left->HasNumberValue() && c_right->HasNumberValue()) { | 4018 if (c_left->HasNumberValue() && c_right->HasNumberValue()) { |
| 4011 double result = power_helper(c_left->DoubleValue(), | 4019 double result = power_helper(c_left->DoubleValue(), |
| 4012 c_right->DoubleValue()); | 4020 c_right->DoubleValue()); |
| 4013 return H_CONSTANT_DOUBLE(std::isnan(result) ? OS::nan_value() : result); | 4021 return H_CONSTANT_DOUBLE(std::isnan(result) ? OS::nan_value() : result); |
| 4014 } | 4022 } |
| 4015 } | 4023 } |
| 4016 return new(zone) HPower(left, right); | 4024 return new(zone) HPower(left, right); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4095 Double(c_right->DoubleValue()).Sign(); // Right could be -0. | 4103 Double(c_right->DoubleValue()).Sign(); // Right could be -0. |
| 4096 return H_CONSTANT_DOUBLE(sign * V8_INFINITY); | 4104 return H_CONSTANT_DOUBLE(sign * V8_INFINITY); |
| 4097 } | 4105 } |
| 4098 } | 4106 } |
| 4099 } | 4107 } |
| 4100 return new(zone) HDiv(context, left, right); | 4108 return new(zone) HDiv(context, left, right); |
| 4101 } | 4109 } |
| 4102 | 4110 |
| 4103 | 4111 |
| 4104 HInstruction* HBitwise::New( | 4112 HInstruction* HBitwise::New( |
| 4105 Zone* zone, Token::Value op, HValue* context, HValue* left, HValue* right) { | 4113 Zone* zone, HValue* context, Token::Value op, HValue* left, HValue* right) { |
| 4106 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) { | 4114 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) { |
| 4107 HConstant* c_left = HConstant::cast(left); | 4115 HConstant* c_left = HConstant::cast(left); |
| 4108 HConstant* c_right = HConstant::cast(right); | 4116 HConstant* c_right = HConstant::cast(right); |
| 4109 if ((c_left->HasNumberValue() && c_right->HasNumberValue())) { | 4117 if ((c_left->HasNumberValue() && c_right->HasNumberValue())) { |
| 4110 int32_t result; | 4118 int32_t result; |
| 4111 int32_t v_left = c_left->NumberValueAsInteger32(); | 4119 int32_t v_left = c_left->NumberValueAsInteger32(); |
| 4112 int32_t v_right = c_right->NumberValueAsInteger32(); | 4120 int32_t v_right = c_right->NumberValueAsInteger32(); |
| 4113 switch (op) { | 4121 switch (op) { |
| 4114 case Token::BIT_XOR: | 4122 case Token::BIT_XOR: |
| 4115 result = v_left ^ v_right; | 4123 result = v_left ^ v_right; |
| 4116 break; | 4124 break; |
| 4117 case Token::BIT_AND: | 4125 case Token::BIT_AND: |
| 4118 result = v_left & v_right; | 4126 result = v_left & v_right; |
| 4119 break; | 4127 break; |
| 4120 case Token::BIT_OR: | 4128 case Token::BIT_OR: |
| 4121 result = v_left | v_right; | 4129 result = v_left | v_right; |
| 4122 break; | 4130 break; |
| 4123 default: | 4131 default: |
| 4124 result = 0; // Please the compiler. | 4132 result = 0; // Please the compiler. |
| 4125 UNREACHABLE(); | 4133 UNREACHABLE(); |
| 4126 } | 4134 } |
| 4127 return H_CONSTANT_INT(result); | 4135 return H_CONSTANT_INT(result); |
| 4128 } | 4136 } |
| 4129 } | 4137 } |
| 4130 return new(zone) HBitwise(op, context, left, right); | 4138 return new(zone) HBitwise(context, op, left, right); |
| 4131 } | 4139 } |
| 4132 | 4140 |
| 4133 | 4141 |
| 4134 #define DEFINE_NEW_H_BITWISE_INSTR(HInstr, result) \ | 4142 #define DEFINE_NEW_H_BITWISE_INSTR(HInstr, result) \ |
| 4135 HInstruction* HInstr::New( \ | 4143 HInstruction* HInstr::New( \ |
| 4136 Zone* zone, HValue* context, HValue* left, HValue* right) { \ | 4144 Zone* zone, HValue* context, HValue* left, HValue* right) { \ |
| 4137 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) { \ | 4145 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) { \ |
| 4138 HConstant* c_left = HConstant::cast(left); \ | 4146 HConstant* c_left = HConstant::cast(left); \ |
| 4139 HConstant* c_right = HConstant::cast(right); \ | 4147 HConstant* c_right = HConstant::cast(right); \ |
| 4140 if ((c_left->HasNumberValue() && c_right->HasNumberValue())) { \ | 4148 if ((c_left->HasNumberValue() && c_right->HasNumberValue())) { \ |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4189 for (int i = 0; i < OperandCount(); ++i) { | 4197 for (int i = 0; i < OperandCount(); ++i) { |
| 4190 if (!OperandAt(i)->IsConstant()) return; | 4198 if (!OperandAt(i)->IsConstant()) return; |
| 4191 } | 4199 } |
| 4192 HGraph* graph = block()->graph(); | 4200 HGraph* graph = block()->graph(); |
| 4193 for (int i = 0; i < OperandCount(); ++i) { | 4201 for (int i = 0; i < OperandCount(); ++i) { |
| 4194 HConstant* operand = HConstant::cast(OperandAt(i)); | 4202 HConstant* operand = HConstant::cast(OperandAt(i)); |
| 4195 if (operand->HasInteger32Value()) { | 4203 if (operand->HasInteger32Value()) { |
| 4196 continue; | 4204 continue; |
| 4197 } else if (operand->HasDoubleValue()) { | 4205 } else if (operand->HasDoubleValue()) { |
| 4198 HConstant* integer_input = | 4206 HConstant* integer_input = |
| 4199 new(graph->zone()) HConstant(DoubleToInt32(operand->DoubleValue())); | 4207 HConstant::New(graph->zone(), graph->GetInvalidContext(), |
| 4208 DoubleToInt32(operand->DoubleValue())); |
| 4200 integer_input->InsertAfter(operand); | 4209 integer_input->InsertAfter(operand); |
| 4201 SetOperandAt(i, integer_input); | 4210 SetOperandAt(i, integer_input); |
| 4202 } else if (operand == graph->GetConstantTrue()) { | 4211 } else if (operand == graph->GetConstantTrue()) { |
| 4203 SetOperandAt(i, graph->GetConstant1()); | 4212 SetOperandAt(i, graph->GetConstant1()); |
| 4204 } else { | 4213 } else { |
| 4205 // This catches |false|, |undefined|, strings and objects. | 4214 // This catches |false|, |undefined|, strings and objects. |
| 4206 SetOperandAt(i, graph->GetConstant0()); | 4215 SetOperandAt(i, graph->GetConstant0()); |
| 4207 } | 4216 } |
| 4208 } | 4217 } |
| 4209 // Overwrite observed input representations because they are likely Tagged. | 4218 // Overwrite observed input representations because they are likely Tagged. |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4460 break; | 4469 break; |
| 4461 case kExternalMemory: | 4470 case kExternalMemory: |
| 4462 stream->Add("[external-memory]"); | 4471 stream->Add("[external-memory]"); |
| 4463 break; | 4472 break; |
| 4464 } | 4473 } |
| 4465 | 4474 |
| 4466 stream->Add("@%d", offset()); | 4475 stream->Add("@%d", offset()); |
| 4467 } | 4476 } |
| 4468 | 4477 |
| 4469 } } // namespace v8::internal | 4478 } } // namespace v8::internal |
| OLD | NEW |