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 2508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2519 r = Representation::Tagged(); | 2519 r = Representation::Tagged(); |
2520 } | 2520 } |
2521 } | 2521 } |
2522 set_representation(r); | 2522 set_representation(r); |
2523 SetFlag(kUseGVN); | 2523 SetFlag(kUseGVN); |
2524 } | 2524 } |
2525 | 2525 |
2526 | 2526 |
2527 bool HConstant::EmitAtUses() { | 2527 bool HConstant::EmitAtUses() { |
2528 ASSERT(IsLinked()); | 2528 ASSERT(IsLinked()); |
2529 if (block()->graph()->has_osr() && | 2529 if (block()->graph()->has_osr()) { |
2530 block()->graph()->IsStandardConstant(this)) { | 2530 return block()->graph()->IsStandardConstant(this); |
2531 return true; | |
2532 } | 2531 } |
2533 if (UseCount() == 0) return true; | |
2534 if (IsCell()) return false; | 2532 if (IsCell()) return false; |
2535 if (representation().IsDouble()) return false; | 2533 if (representation().IsDouble()) return false; |
2536 return true; | 2534 return true; |
2537 } | 2535 } |
2538 | 2536 |
2539 | 2537 |
2540 HConstant* HConstant::CopyToRepresentation(Representation r, Zone* zone) const { | 2538 HConstant* HConstant::CopyToRepresentation(Representation r, Zone* zone) const { |
2541 if (r.IsSmi() && !has_smi_value_) return NULL; | 2539 if (r.IsSmi() && !has_smi_value_) return NULL; |
2542 if (r.IsInteger32() && !has_int32_value_) return NULL; | 2540 if (r.IsInteger32() && !has_int32_value_) return NULL; |
2543 if (r.IsDouble() && !has_double_value_) return NULL; | 2541 if (r.IsDouble() && !has_double_value_) return NULL; |
(...skipping 24 matching lines...) Expand all Loading... |
2568 if (has_int32_value_) { | 2566 if (has_int32_value_) { |
2569 res = new(zone) HConstant(int32_value_, | 2567 res = new(zone) HConstant(int32_value_, |
2570 Representation::Integer32(), | 2568 Representation::Integer32(), |
2571 is_not_in_new_space_, | 2569 is_not_in_new_space_, |
2572 handle_); | 2570 handle_); |
2573 } else if (has_double_value_) { | 2571 } else if (has_double_value_) { |
2574 res = new(zone) HConstant(DoubleToInt32(double_value_), | 2572 res = new(zone) HConstant(DoubleToInt32(double_value_), |
2575 Representation::Integer32(), | 2573 Representation::Integer32(), |
2576 is_not_in_new_space_, | 2574 is_not_in_new_space_, |
2577 handle_); | 2575 handle_); |
| 2576 } else { |
| 2577 ASSERT(!HasNumberValue()); |
| 2578 Maybe<HConstant*> number = CopyToTruncatedNumber(zone); |
| 2579 if (number.has_value) return number.value->CopyToTruncatedInt32(zone); |
2578 } | 2580 } |
2579 return Maybe<HConstant*>(res != NULL, res); | 2581 return Maybe<HConstant*>(res != NULL, res); |
2580 } | 2582 } |
2581 | 2583 |
2582 | 2584 |
2583 Maybe<HConstant*> HConstant::CopyToTruncatedNumber(Zone* zone) { | 2585 Maybe<HConstant*> HConstant::CopyToTruncatedNumber(Zone* zone) { |
2584 HConstant* res = NULL; | 2586 HConstant* res = NULL; |
2585 Handle<Object> handle = this->handle(zone->isolate()); | 2587 Handle<Object> handle = this->handle(zone->isolate()); |
2586 if (handle->IsBoolean()) { | 2588 if (handle->IsBoolean()) { |
2587 res = handle->BooleanValue() ? | 2589 res = handle->BooleanValue() ? |
(...skipping 1648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4236 break; | 4238 break; |
4237 case kExternalMemory: | 4239 case kExternalMemory: |
4238 stream->Add("[external-memory]"); | 4240 stream->Add("[external-memory]"); |
4239 break; | 4241 break; |
4240 } | 4242 } |
4241 | 4243 |
4242 stream->Add("@%d", offset()); | 4244 stream->Add("@%d", offset()); |
4243 } | 4245 } |
4244 | 4246 |
4245 } } // namespace v8::internal | 4247 } } // namespace v8::internal |
OLD | NEW |