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 2557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2568 ASSERT(!HasNumberValue()); | 2568 ASSERT(!HasNumberValue()); |
2569 Maybe<HConstant*> number = CopyToTruncatedNumber(zone); | 2569 Maybe<HConstant*> number = CopyToTruncatedNumber(zone); |
2570 if (number.has_value) return number.value->CopyToTruncatedInt32(zone); | 2570 if (number.has_value) return number.value->CopyToTruncatedInt32(zone); |
2571 } | 2571 } |
2572 return Maybe<HConstant*>(res != NULL, res); | 2572 return Maybe<HConstant*>(res != NULL, res); |
2573 } | 2573 } |
2574 | 2574 |
2575 | 2575 |
2576 Maybe<HConstant*> HConstant::CopyToTruncatedNumber(Zone* zone) { | 2576 Maybe<HConstant*> HConstant::CopyToTruncatedNumber(Zone* zone) { |
2577 HConstant* res = NULL; | 2577 HConstant* res = NULL; |
2578 if (handle()->IsBoolean()) { | 2578 Handle<Object> handle = this->handle(zone->isolate()); |
2579 res = handle()->BooleanValue() ? | 2579 if (handle->IsBoolean()) { |
| 2580 res = handle->BooleanValue() ? |
2580 new(zone) HConstant(1) : new(zone) HConstant(0); | 2581 new(zone) HConstant(1) : new(zone) HConstant(0); |
2581 } else if (handle()->IsUndefined()) { | 2582 } else if (handle->IsUndefined()) { |
2582 res = new(zone) HConstant(OS::nan_value()); | 2583 res = new(zone) HConstant(OS::nan_value()); |
2583 } else if (handle()->IsNull()) { | 2584 } else if (handle->IsNull()) { |
2584 res = new(zone) HConstant(0); | 2585 res = new(zone) HConstant(0); |
2585 } | 2586 } |
2586 return Maybe<HConstant*>(res != NULL, res); | 2587 return Maybe<HConstant*>(res != NULL, res); |
2587 } | 2588 } |
2588 | 2589 |
2589 | 2590 |
2590 void HConstant::PrintDataTo(StringStream* stream) { | 2591 void HConstant::PrintDataTo(StringStream* stream) { |
2591 if (has_int32_value_) { | 2592 if (has_int32_value_) { |
2592 stream->Add("%d ", int32_value_); | 2593 stream->Add("%d ", int32_value_); |
2593 } else if (has_double_value_) { | 2594 } else if (has_double_value_) { |
2594 stream->Add("%f ", FmtElm(double_value_)); | 2595 stream->Add("%f ", FmtElm(double_value_)); |
2595 } else if (has_external_reference_value_) { | 2596 } else if (has_external_reference_value_) { |
2596 stream->Add("%p ", reinterpret_cast<void*>( | 2597 stream->Add("%p ", reinterpret_cast<void*>( |
2597 external_reference_value_.address())); | 2598 external_reference_value_.address())); |
2598 } else { | 2599 } else { |
2599 handle()->ShortPrint(stream); | 2600 handle(Isolate::Current())->ShortPrint(stream); |
2600 } | 2601 } |
2601 } | 2602 } |
2602 | 2603 |
2603 | 2604 |
2604 void HBinaryOperation::PrintDataTo(StringStream* stream) { | 2605 void HBinaryOperation::PrintDataTo(StringStream* stream) { |
2605 left()->PrintNameTo(stream); | 2606 left()->PrintNameTo(stream); |
2606 stream->Add(" "); | 2607 stream->Add(" "); |
2607 right()->PrintNameTo(stream); | 2608 right()->PrintNameTo(stream); |
2608 if (CheckFlag(kCanOverflow)) stream->Add(" !"); | 2609 if (CheckFlag(kCanOverflow)) stream->Add(" !"); |
2609 if (CheckFlag(kBailoutOnMinusZero)) stream->Add(" -0?"); | 2610 if (CheckFlag(kBailoutOnMinusZero)) stream->Add(" -0?"); |
(...skipping 1618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4228 break; | 4229 break; |
4229 case kExternalMemory: | 4230 case kExternalMemory: |
4230 stream->Add("[external-memory]"); | 4231 stream->Add("[external-memory]"); |
4231 break; | 4232 break; |
4232 } | 4233 } |
4233 | 4234 |
4234 stream->Add("@%d", offset()); | 4235 stream->Add("@%d", offset()); |
4235 } | 4236 } |
4236 | 4237 |
4237 } } // namespace v8::internal | 4238 } } // namespace v8::internal |
OLD | NEW |