| 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 2559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2570 ASSERT(!HasNumberValue()); | 2570 ASSERT(!HasNumberValue()); |
| 2571 Maybe<HConstant*> number = CopyToTruncatedNumber(zone); | 2571 Maybe<HConstant*> number = CopyToTruncatedNumber(zone); |
| 2572 if (number.has_value) return number.value->CopyToTruncatedInt32(zone); | 2572 if (number.has_value) return number.value->CopyToTruncatedInt32(zone); |
| 2573 } | 2573 } |
| 2574 return Maybe<HConstant*>(res != NULL, res); | 2574 return Maybe<HConstant*>(res != NULL, res); |
| 2575 } | 2575 } |
| 2576 | 2576 |
| 2577 | 2577 |
| 2578 Maybe<HConstant*> HConstant::CopyToTruncatedNumber(Zone* zone) { | 2578 Maybe<HConstant*> HConstant::CopyToTruncatedNumber(Zone* zone) { |
| 2579 HConstant* res = NULL; | 2579 HConstant* res = NULL; |
| 2580 if (handle()->IsBoolean()) { | 2580 Handle<Object> handle = this->handle(zone->isolate()); |
| 2581 res = handle()->BooleanValue() ? | 2581 if (handle->IsBoolean()) { |
| 2582 res = handle->BooleanValue() ? |
| 2582 new(zone) HConstant(1) : new(zone) HConstant(0); | 2583 new(zone) HConstant(1) : new(zone) HConstant(0); |
| 2583 } else if (handle()->IsUndefined()) { | 2584 } else if (handle->IsUndefined()) { |
| 2584 res = new(zone) HConstant(OS::nan_value()); | 2585 res = new(zone) HConstant(OS::nan_value()); |
| 2585 } else if (handle()->IsNull()) { | 2586 } else if (handle->IsNull()) { |
| 2586 res = new(zone) HConstant(0); | 2587 res = new(zone) HConstant(0); |
| 2587 } | 2588 } |
| 2588 return Maybe<HConstant*>(res != NULL, res); | 2589 return Maybe<HConstant*>(res != NULL, res); |
| 2589 } | 2590 } |
| 2590 | 2591 |
| 2591 | 2592 |
| 2592 void HConstant::PrintDataTo(StringStream* stream) { | 2593 void HConstant::PrintDataTo(StringStream* stream) { |
| 2593 if (has_int32_value_) { | 2594 if (has_int32_value_) { |
| 2594 stream->Add("%d ", int32_value_); | 2595 stream->Add("%d ", int32_value_); |
| 2595 } else if (has_double_value_) { | 2596 } else if (has_double_value_) { |
| 2596 stream->Add("%f ", FmtElm(double_value_)); | 2597 stream->Add("%f ", FmtElm(double_value_)); |
| 2597 } else if (has_external_reference_value_) { | 2598 } else if (has_external_reference_value_) { |
| 2598 stream->Add("%p ", reinterpret_cast<void*>( | 2599 stream->Add("%p ", reinterpret_cast<void*>( |
| 2599 external_reference_value_.address())); | 2600 external_reference_value_.address())); |
| 2600 } else { | 2601 } else { |
| 2601 handle()->ShortPrint(stream); | 2602 handle(Isolate::Current())->ShortPrint(stream); |
| 2602 } | 2603 } |
| 2603 } | 2604 } |
| 2604 | 2605 |
| 2605 | 2606 |
| 2606 void HBinaryOperation::PrintDataTo(StringStream* stream) { | 2607 void HBinaryOperation::PrintDataTo(StringStream* stream) { |
| 2607 left()->PrintNameTo(stream); | 2608 left()->PrintNameTo(stream); |
| 2608 stream->Add(" "); | 2609 stream->Add(" "); |
| 2609 right()->PrintNameTo(stream); | 2610 right()->PrintNameTo(stream); |
| 2610 if (CheckFlag(kCanOverflow)) stream->Add(" !"); | 2611 if (CheckFlag(kCanOverflow)) stream->Add(" !"); |
| 2611 if (CheckFlag(kBailoutOnMinusZero)) stream->Add(" -0?"); | 2612 if (CheckFlag(kBailoutOnMinusZero)) stream->Add(" -0?"); |
| (...skipping 1051 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3663 } | 3664 } |
| 3664 } | 3665 } |
| 3665 return new(zone) HStringAdd(context, left, right, flags); | 3666 return new(zone) HStringAdd(context, left, right, flags); |
| 3666 } | 3667 } |
| 3667 | 3668 |
| 3668 | 3669 |
| 3669 HInstruction* HStringCharFromCode::New( | 3670 HInstruction* HStringCharFromCode::New( |
| 3670 Zone* zone, HValue* context, HValue* char_code) { | 3671 Zone* zone, HValue* context, HValue* char_code) { |
| 3671 if (FLAG_fold_constants && char_code->IsConstant()) { | 3672 if (FLAG_fold_constants && char_code->IsConstant()) { |
| 3672 HConstant* c_code = HConstant::cast(char_code); | 3673 HConstant* c_code = HConstant::cast(char_code); |
| 3673 Isolate* isolate = Isolate::Current(); | 3674 Isolate* isolate = zone->isolate(); |
| 3674 if (c_code->HasNumberValue()) { | 3675 if (c_code->HasNumberValue()) { |
| 3675 if (std::isfinite(c_code->DoubleValue())) { | 3676 if (std::isfinite(c_code->DoubleValue())) { |
| 3676 uint32_t code = c_code->NumberValueAsInteger32() & 0xffff; | 3677 uint32_t code = c_code->NumberValueAsInteger32() & 0xffff; |
| 3677 return HConstant::New(zone, context, | 3678 return HConstant::New(zone, context, |
| 3678 LookupSingleCharacterStringFromCode(isolate, code)); | 3679 LookupSingleCharacterStringFromCode(isolate, code)); |
| 3679 } | 3680 } |
| 3680 return HConstant::New(zone, context, isolate->factory()->empty_string()); | 3681 return HConstant::New(zone, context, isolate->factory()->empty_string()); |
| 3681 } | 3682 } |
| 3682 } | 3683 } |
| 3683 return new(zone) HStringCharFromCode(context, char_code); | 3684 return new(zone) HStringCharFromCode(context, char_code); |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3988 } | 3989 } |
| 3989 return r; | 3990 return r; |
| 3990 } | 3991 } |
| 3991 | 3992 |
| 3992 | 3993 |
| 3993 // Returns a representation if all uses agree on the same representation. | 3994 // Returns a representation if all uses agree on the same representation. |
| 3994 // Integer32 is also returned when some uses are Smi but others are Integer32. | 3995 // Integer32 is also returned when some uses are Smi but others are Integer32. |
| 3995 Representation HValue::RepresentationFromUseRequirements() { | 3996 Representation HValue::RepresentationFromUseRequirements() { |
| 3996 Representation rep = Representation::None(); | 3997 Representation rep = Representation::None(); |
| 3997 for (HUseIterator it(uses()); !it.Done(); it.Advance()) { | 3998 for (HUseIterator it(uses()); !it.Done(); it.Advance()) { |
| 3999 // Ignore the use requirement from never run code |
| 4000 if (it.value()->block()->IsDeoptimizing()) continue; |
| 4001 |
| 3998 // We check for observed_input_representation elsewhere. | 4002 // We check for observed_input_representation elsewhere. |
| 3999 Representation use_rep = | 4003 Representation use_rep = |
| 4000 it.value()->RequiredInputRepresentation(it.index()); | 4004 it.value()->RequiredInputRepresentation(it.index()); |
| 4001 if (rep.IsNone()) { | 4005 if (rep.IsNone()) { |
| 4002 rep = use_rep; | 4006 rep = use_rep; |
| 4003 continue; | 4007 continue; |
| 4004 } | 4008 } |
| 4005 if (use_rep.IsNone() || rep.Equals(use_rep)) continue; | 4009 if (use_rep.IsNone() || rep.Equals(use_rep)) continue; |
| 4006 if (rep.generalize(use_rep).IsInteger32()) { | 4010 if (rep.generalize(use_rep).IsInteger32()) { |
| 4007 rep = Representation::Integer32(); | 4011 rep = Representation::Integer32(); |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4227 break; | 4231 break; |
| 4228 case kExternalMemory: | 4232 case kExternalMemory: |
| 4229 stream->Add("[external-memory]"); | 4233 stream->Add("[external-memory]"); |
| 4230 break; | 4234 break; |
| 4231 } | 4235 } |
| 4232 | 4236 |
| 4233 stream->Add("@%d", offset()); | 4237 stream->Add("@%d", offset()); |
| 4234 } | 4238 } |
| 4235 | 4239 |
| 4236 } } // namespace v8::internal | 4240 } } // namespace v8::internal |
| OLD | NEW |