| 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 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 736 ASSERT(!next->IsBlockEntry()); | 736 ASSERT(!next->IsBlockEntry()); |
| 737 ASSERT(!IsControlInstruction()); | 737 ASSERT(!IsControlInstruction()); |
| 738 ASSERT(!next->block()->IsStartBlock()); | 738 ASSERT(!next->block()->IsStartBlock()); |
| 739 ASSERT(next->previous_ != NULL); | 739 ASSERT(next->previous_ != NULL); |
| 740 HInstruction* prev = next->previous(); | 740 HInstruction* prev = next->previous(); |
| 741 prev->next_ = this; | 741 prev->next_ = this; |
| 742 next->previous_ = this; | 742 next->previous_ = this; |
| 743 next_ = next; | 743 next_ = next; |
| 744 previous_ = prev; | 744 previous_ = prev; |
| 745 SetBlock(next->block()); | 745 SetBlock(next->block()); |
| 746 if (position() == RelocInfo::kNoPosition && |
| 747 next->position() != RelocInfo::kNoPosition) { |
| 748 set_position(next->position()); |
| 749 } |
| 746 } | 750 } |
| 747 | 751 |
| 748 | 752 |
| 749 void HInstruction::InsertAfter(HInstruction* previous) { | 753 void HInstruction::InsertAfter(HInstruction* previous) { |
| 750 ASSERT(!IsLinked()); | 754 ASSERT(!IsLinked()); |
| 751 ASSERT(!previous->IsControlInstruction()); | 755 ASSERT(!previous->IsControlInstruction()); |
| 752 ASSERT(!IsControlInstruction() || previous->next_ == NULL); | 756 ASSERT(!IsControlInstruction() || previous->next_ == NULL); |
| 753 HBasicBlock* block = previous->block(); | 757 HBasicBlock* block = previous->block(); |
| 754 // Never insert anything except constants into the start block after finishing | 758 // Never insert anything except constants into the start block after finishing |
| 755 // it. | 759 // it. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 770 } | 774 } |
| 771 | 775 |
| 772 previous_ = previous; | 776 previous_ = previous; |
| 773 next_ = next; | 777 next_ = next; |
| 774 SetBlock(block); | 778 SetBlock(block); |
| 775 previous->next_ = this; | 779 previous->next_ = this; |
| 776 if (next != NULL) next->previous_ = this; | 780 if (next != NULL) next->previous_ = this; |
| 777 if (block->last() == previous) { | 781 if (block->last() == previous) { |
| 778 block->set_last(this); | 782 block->set_last(this); |
| 779 } | 783 } |
| 784 if (position() == RelocInfo::kNoPosition && |
| 785 previous->position() != RelocInfo::kNoPosition) { |
| 786 set_position(previous->position()); |
| 787 } |
| 780 } | 788 } |
| 781 | 789 |
| 782 | 790 |
| 783 #ifdef DEBUG | 791 #ifdef DEBUG |
| 784 void HInstruction::Verify() { | 792 void HInstruction::Verify() { |
| 785 // Verify that input operands are defined before use. | 793 // Verify that input operands are defined before use. |
| 786 HBasicBlock* cur_block = block(); | 794 HBasicBlock* cur_block = block(); |
| 787 for (int i = 0; i < OperandCount(); ++i) { | 795 for (int i = 0; i < OperandCount(); ++i) { |
| 788 HValue* other_operand = OperandAt(i); | 796 HValue* other_operand = OperandAt(i); |
| 789 if (other_operand == NULL) continue; | 797 if (other_operand == NULL) continue; |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1242 } | 1250 } |
| 1243 | 1251 |
| 1244 | 1252 |
| 1245 static bool IsIdentityOperation(HValue* arg1, HValue* arg2, int32_t identity) { | 1253 static bool IsIdentityOperation(HValue* arg1, HValue* arg2, int32_t identity) { |
| 1246 return arg1->representation().IsSpecialization() && | 1254 return arg1->representation().IsSpecialization() && |
| 1247 arg2->EqualsInteger32Constant(identity); | 1255 arg2->EqualsInteger32Constant(identity); |
| 1248 } | 1256 } |
| 1249 | 1257 |
| 1250 | 1258 |
| 1251 HValue* HAdd::Canonicalize() { | 1259 HValue* HAdd::Canonicalize() { |
| 1252 if (IsIdentityOperation(left(), right(), 0)) return left(); | 1260 // Adding 0 is an identity operation except in case of -0: -0 + 0 = +0 |
| 1253 if (IsIdentityOperation(right(), left(), 0)) return right(); | 1261 if (IsIdentityOperation(left(), right(), 0) && |
| 1262 !left()->representation().IsDouble()) { // Left could be -0. |
| 1263 return left(); |
| 1264 } |
| 1265 if (IsIdentityOperation(right(), left(), 0) && |
| 1266 !left()->representation().IsDouble()) { // Right could be -0. |
| 1267 return right(); |
| 1268 } |
| 1254 return this; | 1269 return this; |
| 1255 } | 1270 } |
| 1256 | 1271 |
| 1257 | 1272 |
| 1258 HValue* HSub::Canonicalize() { | 1273 HValue* HSub::Canonicalize() { |
| 1259 if (IsIdentityOperation(left(), right(), 0)) return left(); | 1274 if (IsIdentityOperation(left(), right(), 0)) return left(); |
| 1260 return this; | 1275 return this; |
| 1261 } | 1276 } |
| 1262 | 1277 |
| 1263 | 1278 |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1587 Range* HConstant::InferRange(Zone* zone) { | 1602 Range* HConstant::InferRange(Zone* zone) { |
| 1588 if (has_int32_value_) { | 1603 if (has_int32_value_) { |
| 1589 Range* result = new(zone) Range(int32_value_, int32_value_); | 1604 Range* result = new(zone) Range(int32_value_, int32_value_); |
| 1590 result->set_can_be_minus_zero(false); | 1605 result->set_can_be_minus_zero(false); |
| 1591 return result; | 1606 return result; |
| 1592 } | 1607 } |
| 1593 return HValue::InferRange(zone); | 1608 return HValue::InferRange(zone); |
| 1594 } | 1609 } |
| 1595 | 1610 |
| 1596 | 1611 |
| 1612 int HPhi::position() const { |
| 1613 return block()->first()->position(); |
| 1614 } |
| 1615 |
| 1616 |
| 1597 Range* HPhi::InferRange(Zone* zone) { | 1617 Range* HPhi::InferRange(Zone* zone) { |
| 1598 Representation r = representation(); | 1618 Representation r = representation(); |
| 1599 if (r.IsSmiOrInteger32()) { | 1619 if (r.IsSmiOrInteger32()) { |
| 1600 if (block()->IsLoopHeader()) { | 1620 if (block()->IsLoopHeader()) { |
| 1601 Range* range = r.IsSmi() | 1621 Range* range = r.IsSmi() |
| 1602 ? new(zone) Range(Smi::kMinValue, Smi::kMaxValue) | 1622 ? new(zone) Range(Smi::kMinValue, Smi::kMaxValue) |
| 1603 : new(zone) Range(kMinInt, kMaxInt); | 1623 : new(zone) Range(kMinInt, kMaxInt); |
| 1604 return range; | 1624 return range; |
| 1605 } else { | 1625 } else { |
| 1606 Range* range = OperandAt(0)->range()->Copy(zone); | 1626 Range* range = OperandAt(0)->range()->Copy(zone); |
| (...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2391 // same capture id in the current and all outer environments. | 2411 // same capture id in the current and all outer environments. |
| 2392 void HCapturedObject::ReplayEnvironment(HEnvironment* env) { | 2412 void HCapturedObject::ReplayEnvironment(HEnvironment* env) { |
| 2393 ASSERT(env != NULL); | 2413 ASSERT(env != NULL); |
| 2394 while (env != NULL) { | 2414 while (env != NULL) { |
| 2395 ReplayEnvironmentNested(env->values(), this); | 2415 ReplayEnvironmentNested(env->values(), this); |
| 2396 env = env->outer(); | 2416 env = env->outer(); |
| 2397 } | 2417 } |
| 2398 } | 2418 } |
| 2399 | 2419 |
| 2400 | 2420 |
| 2421 void HCapturedObject::PrintDataTo(StringStream* stream) { |
| 2422 stream->Add("#%d ", capture_id()); |
| 2423 HDematerializedObject::PrintDataTo(stream); |
| 2424 } |
| 2425 |
| 2426 |
| 2401 void HEnterInlined::RegisterReturnTarget(HBasicBlock* return_target, | 2427 void HEnterInlined::RegisterReturnTarget(HBasicBlock* return_target, |
| 2402 Zone* zone) { | 2428 Zone* zone) { |
| 2403 ASSERT(return_target->IsInlineReturnTarget()); | 2429 ASSERT(return_target->IsInlineReturnTarget()); |
| 2404 return_targets_.Add(return_target, zone); | 2430 return_targets_.Add(return_target, zone); |
| 2405 } | 2431 } |
| 2406 | 2432 |
| 2407 | 2433 |
| 2408 void HEnterInlined::PrintDataTo(StringStream* stream) { | 2434 void HEnterInlined::PrintDataTo(StringStream* stream) { |
| 2409 SmartArrayPointer<char> name = function()->debug_name()->ToCString(); | 2435 SmartArrayPointer<char> name = function()->debug_name()->ToCString(); |
| 2410 stream->Add("%s, id=%d", *name, function()->id().ToInt()); | 2436 stream->Add("%s, id=%d", *name, function()->id().ToInt()); |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2552 } | 2578 } |
| 2553 set_representation(r); | 2579 set_representation(r); |
| 2554 SetFlag(kUseGVN); | 2580 SetFlag(kUseGVN); |
| 2555 } | 2581 } |
| 2556 | 2582 |
| 2557 | 2583 |
| 2558 bool HConstant::EmitAtUses() { | 2584 bool HConstant::EmitAtUses() { |
| 2559 ASSERT(IsLinked()); | 2585 ASSERT(IsLinked()); |
| 2560 if (block()->graph()->has_osr() && | 2586 if (block()->graph()->has_osr() && |
| 2561 block()->graph()->IsStandardConstant(this)) { | 2587 block()->graph()->IsStandardConstant(this)) { |
| 2588 // TODO(titzer): this seems like a hack that should be fixed by custom OSR. |
| 2562 return true; | 2589 return true; |
| 2563 } | 2590 } |
| 2564 if (UseCount() == 0) return true; | 2591 if (UseCount() == 0) return true; |
| 2565 if (IsCell()) return false; | 2592 if (IsCell()) return false; |
| 2566 if (representation().IsDouble()) return false; | 2593 if (representation().IsDouble()) return false; |
| 2567 return true; | 2594 return true; |
| 2568 } | 2595 } |
| 2569 | 2596 |
| 2570 | 2597 |
| 2571 HConstant* HConstant::CopyToRepresentation(Representation r, Zone* zone) const { | 2598 HConstant* HConstant::CopyToRepresentation(Representation r, Zone* zone) const { |
| (...skipping 1460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4032 return r; | 4059 return r; |
| 4033 } | 4060 } |
| 4034 | 4061 |
| 4035 | 4062 |
| 4036 // Returns a representation if all uses agree on the same representation. | 4063 // Returns a representation if all uses agree on the same representation. |
| 4037 // Integer32 is also returned when some uses are Smi but others are Integer32. | 4064 // Integer32 is also returned when some uses are Smi but others are Integer32. |
| 4038 Representation HValue::RepresentationFromUseRequirements() { | 4065 Representation HValue::RepresentationFromUseRequirements() { |
| 4039 Representation rep = Representation::None(); | 4066 Representation rep = Representation::None(); |
| 4040 for (HUseIterator it(uses()); !it.Done(); it.Advance()) { | 4067 for (HUseIterator it(uses()); !it.Done(); it.Advance()) { |
| 4041 // Ignore the use requirement from never run code | 4068 // Ignore the use requirement from never run code |
| 4042 if (it.value()->block()->IsDeoptimizing()) continue; | 4069 if (it.value()->block()->IsUnreachable()) continue; |
| 4043 | 4070 |
| 4044 // We check for observed_input_representation elsewhere. | 4071 // We check for observed_input_representation elsewhere. |
| 4045 Representation use_rep = | 4072 Representation use_rep = |
| 4046 it.value()->RequiredInputRepresentation(it.index()); | 4073 it.value()->RequiredInputRepresentation(it.index()); |
| 4047 if (rep.IsNone()) { | 4074 if (rep.IsNone()) { |
| 4048 rep = use_rep; | 4075 rep = use_rep; |
| 4049 continue; | 4076 continue; |
| 4050 } | 4077 } |
| 4051 if (use_rep.IsNone() || rep.Equals(use_rep)) continue; | 4078 if (use_rep.IsNone() || rep.Equals(use_rep)) continue; |
| 4052 if (rep.generalize(use_rep).IsInteger32()) { | 4079 if (rep.generalize(use_rep).IsInteger32()) { |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4273 break; | 4300 break; |
| 4274 case kExternalMemory: | 4301 case kExternalMemory: |
| 4275 stream->Add("[external-memory]"); | 4302 stream->Add("[external-memory]"); |
| 4276 break; | 4303 break; |
| 4277 } | 4304 } |
| 4278 | 4305 |
| 4279 stream->Add("@%d", offset()); | 4306 stream->Add("@%d", offset()); |
| 4280 } | 4307 } |
| 4281 | 4308 |
| 4282 } } // namespace v8::internal | 4309 } } // namespace v8::internal |
| OLD | NEW |