| 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 1633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1644 | 1644 |
| 1645 | 1645 |
| 1646 void HCheckInstanceType::GetCheckMaskAndTag(uint8_t* mask, uint8_t* tag) { | 1646 void HCheckInstanceType::GetCheckMaskAndTag(uint8_t* mask, uint8_t* tag) { |
| 1647 ASSERT(!is_interval_check()); | 1647 ASSERT(!is_interval_check()); |
| 1648 switch (check_) { | 1648 switch (check_) { |
| 1649 case IS_STRING: | 1649 case IS_STRING: |
| 1650 *mask = kIsNotStringMask; | 1650 *mask = kIsNotStringMask; |
| 1651 *tag = kStringTag; | 1651 *tag = kStringTag; |
| 1652 return; | 1652 return; |
| 1653 case IS_INTERNALIZED_STRING: | 1653 case IS_INTERNALIZED_STRING: |
| 1654 *mask = kIsInternalizedMask; | 1654 *mask = kIsNotInternalizedMask; |
| 1655 *tag = kInternalizedTag; | 1655 *tag = kInternalizedTag; |
| 1656 return; | 1656 return; |
| 1657 default: | 1657 default: |
| 1658 UNREACHABLE(); | 1658 UNREACHABLE(); |
| 1659 } | 1659 } |
| 1660 } | 1660 } |
| 1661 | 1661 |
| 1662 | 1662 |
| 1663 void HCheckMaps::HandleSideEffectDominator(GVNFlag side_effect, | 1663 void HCheckMaps::HandleSideEffectDominator(GVNFlag side_effect, |
| 1664 HValue* dominator) { | 1664 HValue* dominator) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1689 stream->Add("]"); | 1689 stream->Add("]"); |
| 1690 } | 1690 } |
| 1691 | 1691 |
| 1692 | 1692 |
| 1693 void HCheckFunction::PrintDataTo(StringStream* stream) { | 1693 void HCheckFunction::PrintDataTo(StringStream* stream) { |
| 1694 value()->PrintNameTo(stream); | 1694 value()->PrintNameTo(stream); |
| 1695 stream->Add(" %p", *target()); | 1695 stream->Add(" %p", *target()); |
| 1696 } | 1696 } |
| 1697 | 1697 |
| 1698 | 1698 |
| 1699 HValue* HCheckFunction::Canonicalize() { |
| 1700 return (value()->IsConstant() && |
| 1701 HConstant::cast(value())->UniqueValueIdsMatch(target_unique_id_)) |
| 1702 ? NULL |
| 1703 : this; |
| 1704 } |
| 1705 |
| 1706 |
| 1699 const char* HCheckInstanceType::GetCheckName() { | 1707 const char* HCheckInstanceType::GetCheckName() { |
| 1700 switch (check_) { | 1708 switch (check_) { |
| 1701 case IS_SPEC_OBJECT: return "object"; | 1709 case IS_SPEC_OBJECT: return "object"; |
| 1702 case IS_JS_ARRAY: return "array"; | 1710 case IS_JS_ARRAY: return "array"; |
| 1703 case IS_STRING: return "string"; | 1711 case IS_STRING: return "string"; |
| 1704 case IS_INTERNALIZED_STRING: return "internalized_string"; | 1712 case IS_INTERNALIZED_STRING: return "internalized_string"; |
| 1705 } | 1713 } |
| 1706 UNREACHABLE(); | 1714 UNREACHABLE(); |
| 1707 return ""; | 1715 return ""; |
| 1708 } | 1716 } |
| (...skipping 1341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3050 if (details_.IsReadOnly()) stream->Add(" (read-only)"); | 3058 if (details_.IsReadOnly()) stream->Add(" (read-only)"); |
| 3051 } | 3059 } |
| 3052 | 3060 |
| 3053 | 3061 |
| 3054 void HStoreGlobalGeneric::PrintDataTo(StringStream* stream) { | 3062 void HStoreGlobalGeneric::PrintDataTo(StringStream* stream) { |
| 3055 stream->Add("%o = ", *name()); | 3063 stream->Add("%o = ", *name()); |
| 3056 value()->PrintNameTo(stream); | 3064 value()->PrintNameTo(stream); |
| 3057 } | 3065 } |
| 3058 | 3066 |
| 3059 | 3067 |
| 3068 void HLinkObjectInList::PrintDataTo(StringStream* stream) { |
| 3069 value()->PrintNameTo(stream); |
| 3070 stream->Add(" offset %d", store_field_.offset()); |
| 3071 } |
| 3072 |
| 3073 |
| 3060 void HLoadContextSlot::PrintDataTo(StringStream* stream) { | 3074 void HLoadContextSlot::PrintDataTo(StringStream* stream) { |
| 3061 value()->PrintNameTo(stream); | 3075 value()->PrintNameTo(stream); |
| 3062 stream->Add("[%d]", slot_index()); | 3076 stream->Add("[%d]", slot_index()); |
| 3063 } | 3077 } |
| 3064 | 3078 |
| 3065 | 3079 |
| 3066 void HStoreContextSlot::PrintDataTo(StringStream* stream) { | 3080 void HStoreContextSlot::PrintDataTo(StringStream* stream) { |
| 3067 context()->PrintNameTo(stream); | 3081 context()->PrintNameTo(stream); |
| 3068 stream->Add("[%d] = ", slot_index()); | 3082 stream->Add("[%d] = ", slot_index()); |
| 3069 value()->PrintNameTo(stream); | 3083 value()->PrintNameTo(stream); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3214 id(), Mnemonic(), dominator->id(), dominator->Mnemonic()); | 3228 id(), Mnemonic(), dominator->id(), dominator->Mnemonic()); |
| 3215 } | 3229 } |
| 3216 return; | 3230 return; |
| 3217 } | 3231 } |
| 3218 | 3232 |
| 3219 // First update the size of the dominator allocate instruction. | 3233 // First update the size of the dominator allocate instruction. |
| 3220 int32_t dominator_size_constant = | 3234 int32_t dominator_size_constant = |
| 3221 HConstant::cast(dominator_size)->GetInteger32Constant(); | 3235 HConstant::cast(dominator_size)->GetInteger32Constant(); |
| 3222 int32_t current_size_constant = | 3236 int32_t current_size_constant = |
| 3223 HConstant::cast(current_size)->GetInteger32Constant(); | 3237 HConstant::cast(current_size)->GetInteger32Constant(); |
| 3238 int32_t new_dominator_size = dominator_size_constant + current_size_constant; |
| 3239 if (new_dominator_size > Page::kMaxNonCodeHeapObjectSize) { |
| 3240 if (FLAG_trace_allocation_folding) { |
| 3241 PrintF("#%d (%s) cannot fold into #%d (%s) due to size: %d\n", |
| 3242 id(), Mnemonic(), dominator->id(), dominator->Mnemonic(), |
| 3243 new_dominator_size); |
| 3244 } |
| 3245 return; |
| 3246 } |
| 3224 HBasicBlock* block = dominator->block(); | 3247 HBasicBlock* block = dominator->block(); |
| 3225 Zone* zone = block->zone(); | 3248 Zone* zone = block->zone(); |
| 3226 HInstruction* new_dominator_size = new(zone) HConstant( | 3249 HInstruction* new_dominator_size_constant = new(zone) HConstant( |
| 3227 dominator_size_constant + current_size_constant); | 3250 new_dominator_size); |
| 3228 new_dominator_size->InsertBefore(dominator_allocate_instr); | 3251 new_dominator_size_constant->InsertBefore(dominator_allocate_instr); |
| 3229 dominator_allocate_instr->UpdateSize(new_dominator_size); | 3252 dominator_allocate_instr->UpdateSize(new_dominator_size_constant); |
| 3230 | 3253 |
| 3231 #ifdef VERIFY_HEAP | 3254 #ifdef VERIFY_HEAP |
| 3232 HInstruction* free_space_instr = | 3255 if (FLAG_verify_heap) { |
| 3233 new(zone) HInnerAllocatedObject(dominator_allocate_instr, | 3256 dominator_allocate_instr->SetFlags(HAllocate::PREFILL_WITH_FILLER); |
| 3234 dominator_size_constant, | 3257 } |
| 3235 type()); | |
| 3236 free_space_instr->InsertAfter(dominator_allocate_instr); | |
| 3237 HConstant* filler_map = new(zone) HConstant( | |
| 3238 isolate()->factory()->free_space_map(), | |
| 3239 UniqueValueId(isolate()->heap()->free_space_map()), | |
| 3240 Representation::Tagged(), | |
| 3241 HType::Tagged(), | |
| 3242 false, | |
| 3243 true, | |
| 3244 false, | |
| 3245 false); | |
| 3246 filler_map->InsertAfter(free_space_instr); | |
| 3247 | |
| 3248 HInstruction* store_map = new(zone) HStoreNamedField( | |
| 3249 free_space_instr, HObjectAccess::ForMap(), filler_map); | |
| 3250 store_map->SetFlag(HValue::kHasNoObservableSideEffects); | |
| 3251 store_map->InsertAfter(filler_map); | |
| 3252 | |
| 3253 HInstruction* free_space_size = new(zone) HConstant(current_size_constant); | |
| 3254 free_space_size->InsertAfter(store_map); | |
| 3255 HObjectAccess access = | |
| 3256 HObjectAccess::ForJSObjectOffset(FreeSpace::kSizeOffset); | |
| 3257 HInstruction* store_size = new(zone) HStoreNamedField( | |
| 3258 free_space_instr, access, free_space_size); | |
| 3259 store_size->SetFlag(HValue::kHasNoObservableSideEffects); | |
| 3260 store_size->InsertAfter(free_space_size); | |
| 3261 #endif | 3258 #endif |
| 3262 | 3259 |
| 3263 // After that replace the dominated allocate instruction. | 3260 // After that replace the dominated allocate instruction. |
| 3264 HInstruction* dominated_allocate_instr = | 3261 HInstruction* dominated_allocate_instr = |
| 3265 new(zone) HInnerAllocatedObject(dominator_allocate_instr, | 3262 new(zone) HInnerAllocatedObject(dominator_allocate_instr, |
| 3266 dominator_size_constant, | 3263 dominator_size_constant, |
| 3267 type()); | 3264 type()); |
| 3268 dominated_allocate_instr->InsertBefore(this); | 3265 dominated_allocate_instr->InsertBefore(this); |
| 3269 DeleteAndReplaceWith(dominated_allocate_instr); | 3266 DeleteAndReplaceWith(dominated_allocate_instr); |
| 3270 if (FLAG_trace_allocation_folding) { | 3267 if (FLAG_trace_allocation_folding) { |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3436 } | 3433 } |
| 3437 | 3434 |
| 3438 | 3435 |
| 3439 DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR(HAdd, +) | 3436 DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR(HAdd, +) |
| 3440 DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR(HMul, *) | 3437 DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR(HMul, *) |
| 3441 DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR(HSub, -) | 3438 DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR(HSub, -) |
| 3442 | 3439 |
| 3443 #undef DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR | 3440 #undef DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR |
| 3444 | 3441 |
| 3445 | 3442 |
| 3446 HInstruction* HStringAdd::New( | 3443 HInstruction* HStringAdd::New(Zone* zone, |
| 3447 Zone* zone, HValue* context, HValue* left, HValue* right) { | 3444 HValue* context, |
| 3445 HValue* left, |
| 3446 HValue* right, |
| 3447 StringAddFlags flags) { |
| 3448 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) { | 3448 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) { |
| 3449 HConstant* c_right = HConstant::cast(right); | 3449 HConstant* c_right = HConstant::cast(right); |
| 3450 HConstant* c_left = HConstant::cast(left); | 3450 HConstant* c_left = HConstant::cast(left); |
| 3451 if (c_left->HasStringValue() && c_right->HasStringValue()) { | 3451 if (c_left->HasStringValue() && c_right->HasStringValue()) { |
| 3452 Handle<String> concat = zone->isolate()->factory()->NewFlatConcatString( | 3452 Handle<String> concat = zone->isolate()->factory()->NewFlatConcatString( |
| 3453 c_left->StringValue(), c_right->StringValue()); | 3453 c_left->StringValue(), c_right->StringValue()); |
| 3454 return new(zone) HConstant(concat, Representation::Tagged()); | 3454 return new(zone) HConstant(concat, Representation::Tagged()); |
| 3455 } | 3455 } |
| 3456 } | 3456 } |
| 3457 return new(zone) HStringAdd(context, left, right); | 3457 return new(zone) HStringAdd(context, left, right, flags); |
| 3458 } | 3458 } |
| 3459 | 3459 |
| 3460 | 3460 |
| 3461 HInstruction* HStringCharFromCode::New( | 3461 HInstruction* HStringCharFromCode::New( |
| 3462 Zone* zone, HValue* context, HValue* char_code) { | 3462 Zone* zone, HValue* context, HValue* char_code) { |
| 3463 if (FLAG_fold_constants && char_code->IsConstant()) { | 3463 if (FLAG_fold_constants && char_code->IsConstant()) { |
| 3464 HConstant* c_code = HConstant::cast(char_code); | 3464 HConstant* c_code = HConstant::cast(char_code); |
| 3465 Isolate* isolate = Isolate::Current(); | 3465 Isolate* isolate = Isolate::Current(); |
| 3466 if (c_code->HasNumberValue()) { | 3466 if (c_code->HasNumberValue()) { |
| 3467 if (std::isfinite(c_code->DoubleValue())) { | 3467 if (std::isfinite(c_code->DoubleValue())) { |
| (...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3986 case kBackingStore: | 3986 case kBackingStore: |
| 3987 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString()); | 3987 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString()); |
| 3988 stream->Add("[backing-store]"); | 3988 stream->Add("[backing-store]"); |
| 3989 break; | 3989 break; |
| 3990 } | 3990 } |
| 3991 | 3991 |
| 3992 stream->Add("@%d", offset()); | 3992 stream->Add("@%d", offset()); |
| 3993 } | 3993 } |
| 3994 | 3994 |
| 3995 } } // namespace v8::internal | 3995 } } // namespace v8::internal |
| OLD | NEW |