Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Side by Side Diff: src/hydrogen-instructions.cc

Issue 20711002: Remove Uninitialized from HType. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/hydrogen-instructions.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 case kTagged: return "tagged"; 428 case kTagged: return "tagged";
429 case kTaggedPrimitive: return "primitive"; 429 case kTaggedPrimitive: return "primitive";
430 case kTaggedNumber: return "number"; 430 case kTaggedNumber: return "number";
431 case kSmi: return "smi"; 431 case kSmi: return "smi";
432 case kHeapNumber: return "heap-number"; 432 case kHeapNumber: return "heap-number";
433 case kString: return "string"; 433 case kString: return "string";
434 case kBoolean: return "boolean"; 434 case kBoolean: return "boolean";
435 case kNonPrimitive: return "non-primitive"; 435 case kNonPrimitive: return "non-primitive";
436 case kJSArray: return "array"; 436 case kJSArray: return "array";
437 case kJSObject: return "object"; 437 case kJSObject: return "object";
438 case kUninitialized: return "uninitialized";
439 } 438 }
440 UNREACHABLE(); 439 UNREACHABLE();
441 return "unreachable"; 440 return "unreachable";
442 } 441 }
443 442
444 443
445 HType HType::TypeFromValue(Handle<Object> value) { 444 HType HType::TypeFromValue(Handle<Object> value) {
446 HType result = HType::Tagged(); 445 HType result = HType::Tagged();
447 if (value->IsSmi()) { 446 if (value->IsSmi()) {
448 result = HType::Smi(); 447 result = HType::Smi();
(...skipping 1153 matching lines...) Expand 10 before | Expand all | Expand 10 after
1602 1601
1603 // Return NULL to remove this instruction from the graph. 1602 // Return NULL to remove this instruction from the graph.
1604 return NULL; 1603 return NULL;
1605 } 1604 }
1606 } 1605 }
1607 return this; 1606 return this;
1608 } 1607 }
1609 1608
1610 1609
1611 HValue* HCheckInstanceType::Canonicalize() { 1610 HValue* HCheckInstanceType::Canonicalize() {
1612 if (check_ == IS_STRING && 1611 if (check_ == IS_STRING && value()->type().IsString()) {
1613 !value()->type().IsUninitialized() &&
1614 value()->type().IsString()) {
1615 return NULL; 1612 return NULL;
1616 } 1613 }
1617 1614
1618 if (check_ == IS_INTERNALIZED_STRING && value()->IsConstant()) { 1615 if (check_ == IS_INTERNALIZED_STRING && value()->IsConstant()) {
1619 if (HConstant::cast(value())->HasInternalizedStringValue()) return NULL; 1616 if (HConstant::cast(value())->HasInternalizedStringValue()) return NULL;
1620 } 1617 }
1621 return this; 1618 return this;
1622 } 1619 }
1623 1620
1624 1621
(...skipping 979 matching lines...) Expand 10 before | Expand all | Expand 10 after
2604 HConstant::HConstant(Handle<Object> handle, Representation r) 2601 HConstant::HConstant(Handle<Object> handle, Representation r)
2605 : handle_(handle), 2602 : handle_(handle),
2606 unique_id_(), 2603 unique_id_(),
2607 has_smi_value_(false), 2604 has_smi_value_(false),
2608 has_int32_value_(false), 2605 has_int32_value_(false),
2609 has_double_value_(false), 2606 has_double_value_(false),
2610 is_internalized_string_(false), 2607 is_internalized_string_(false),
2611 is_not_in_new_space_(true), 2608 is_not_in_new_space_(true),
2612 is_cell_(false), 2609 is_cell_(false),
2613 boolean_value_(handle->BooleanValue()) { 2610 boolean_value_(handle->BooleanValue()) {
2611 set_type(HType::TypeFromValue(handle));
2612
2614 if (handle_->IsHeapObject()) { 2613 if (handle_->IsHeapObject()) {
2615 Heap* heap = Handle<HeapObject>::cast(handle)->GetHeap(); 2614 Heap* heap = Handle<HeapObject>::cast(handle)->GetHeap();
2616 is_not_in_new_space_ = !heap->InNewSpace(*handle); 2615 is_not_in_new_space_ = !heap->InNewSpace(*handle);
2617 } 2616 }
2618 if (handle_->IsNumber()) { 2617 if (handle_->IsNumber()) {
2619 double n = handle_->Number(); 2618 double n = handle_->Number();
2620 has_int32_value_ = IsInteger32(n); 2619 has_int32_value_ = IsInteger32(n);
2621 int32_value_ = DoubleToInt32(n); 2620 int32_value_ = DoubleToInt32(n);
2622 has_smi_value_ = has_int32_value_ && Smi::IsValid(int32_value_); 2621 has_smi_value_ = has_int32_value_ && Smi::IsValid(int32_value_);
2623 double_value_ = n; 2622 double_value_ = n;
2624 has_double_value_ = true; 2623 has_double_value_ = true;
2625 } else { 2624 } else {
2626 type_from_value_ = HType::TypeFromValue(handle_);
2627 is_internalized_string_ = handle_->IsInternalizedString(); 2625 is_internalized_string_ = handle_->IsInternalizedString();
2628 } 2626 }
2629 2627
2630 is_cell_ = !handle_.is_null() && 2628 is_cell_ = !handle_.is_null() &&
2631 (handle_->IsCell() || handle_->IsPropertyCell()); 2629 (handle_->IsCell() || handle_->IsPropertyCell());
2632 Initialize(r); 2630 Initialize(r);
2633 } 2631 }
2634 2632
2635 2633
2636 HConstant::HConstant(Handle<Object> handle, 2634 HConstant::HConstant(Handle<Object> handle,
2637 UniqueValueId unique_id, 2635 UniqueValueId unique_id,
2638 Representation r, 2636 Representation r,
2639 HType type, 2637 HType type,
2640 bool is_internalize_string, 2638 bool is_internalize_string,
2641 bool is_not_in_new_space, 2639 bool is_not_in_new_space,
2642 bool is_cell, 2640 bool is_cell,
2643 bool boolean_value) 2641 bool boolean_value)
2644 : handle_(handle), 2642 : handle_(handle),
2645 unique_id_(unique_id), 2643 unique_id_(unique_id),
2646 has_smi_value_(false), 2644 has_smi_value_(false),
2647 has_int32_value_(false), 2645 has_int32_value_(false),
2648 has_double_value_(false), 2646 has_double_value_(false),
2649 is_internalized_string_(is_internalize_string), 2647 is_internalized_string_(is_internalize_string),
2650 is_not_in_new_space_(is_not_in_new_space), 2648 is_not_in_new_space_(is_not_in_new_space),
2651 is_cell_(is_cell), 2649 is_cell_(is_cell),
2652 boolean_value_(boolean_value), 2650 boolean_value_(boolean_value) {
2653 type_from_value_(type) {
2654 ASSERT(!handle.is_null()); 2651 ASSERT(!handle.is_null());
2655 ASSERT(!type.IsUninitialized());
2656 ASSERT(!type.IsTaggedNumber()); 2652 ASSERT(!type.IsTaggedNumber());
2653 set_type(type);
2657 Initialize(r); 2654 Initialize(r);
2658 } 2655 }
2659 2656
2660 2657
2661 HConstant::HConstant(int32_t integer_value, 2658 HConstant::HConstant(int32_t integer_value,
2662 Representation r, 2659 Representation r,
2663 bool is_not_in_new_space, 2660 bool is_not_in_new_space,
2664 Handle<Object> optional_handle) 2661 Handle<Object> optional_handle)
2665 : handle_(optional_handle), 2662 : handle_(optional_handle),
2666 unique_id_(), 2663 unique_id_(),
2664 has_smi_value_(Smi::IsValid(integer_value)),
2667 has_int32_value_(true), 2665 has_int32_value_(true),
2668 has_double_value_(true), 2666 has_double_value_(true),
2669 is_internalized_string_(false), 2667 is_internalized_string_(false),
2670 is_not_in_new_space_(is_not_in_new_space), 2668 is_not_in_new_space_(is_not_in_new_space),
2671 is_cell_(false), 2669 is_cell_(false),
2672 boolean_value_(integer_value != 0), 2670 boolean_value_(integer_value != 0),
2673 int32_value_(integer_value), 2671 int32_value_(integer_value),
2674 double_value_(FastI2D(integer_value)) { 2672 double_value_(FastI2D(integer_value)) {
2675 has_smi_value_ = Smi::IsValid(int32_value_); 2673 set_type(has_smi_value_ ? HType::Smi() : HType::TaggedNumber());
2676 Initialize(r); 2674 Initialize(r);
2677 } 2675 }
2678 2676
2679 2677
2680 HConstant::HConstant(double double_value, 2678 HConstant::HConstant(double double_value,
2681 Representation r, 2679 Representation r,
2682 bool is_not_in_new_space, 2680 bool is_not_in_new_space,
2683 Handle<Object> optional_handle) 2681 Handle<Object> optional_handle)
2684 : handle_(optional_handle), 2682 : handle_(optional_handle),
2685 unique_id_(), 2683 unique_id_(),
2686 has_int32_value_(IsInteger32(double_value)), 2684 has_int32_value_(IsInteger32(double_value)),
2687 has_double_value_(true), 2685 has_double_value_(true),
2688 is_internalized_string_(false), 2686 is_internalized_string_(false),
2689 is_not_in_new_space_(is_not_in_new_space), 2687 is_not_in_new_space_(is_not_in_new_space),
2690 is_cell_(false), 2688 is_cell_(false),
2691 boolean_value_(double_value != 0 && !std::isnan(double_value)), 2689 boolean_value_(double_value != 0 && !std::isnan(double_value)),
2692 int32_value_(DoubleToInt32(double_value)), 2690 int32_value_(DoubleToInt32(double_value)),
2693 double_value_(double_value) { 2691 double_value_(double_value) {
2694 has_smi_value_ = has_int32_value_ && Smi::IsValid(int32_value_); 2692 has_smi_value_ = has_int32_value_ && Smi::IsValid(int32_value_);
2693 set_type(has_smi_value_ ? HType::Smi() : HType::TaggedNumber());
2695 Initialize(r); 2694 Initialize(r);
2696 } 2695 }
2697 2696
2698 2697
2699 void HConstant::Initialize(Representation r) { 2698 void HConstant::Initialize(Representation r) {
2700 if (r.IsNone()) { 2699 if (r.IsNone()) {
2701 if (has_smi_value_) { 2700 if (has_smi_value_) {
2702 r = Representation::Smi(); 2701 r = Representation::Smi();
2703 } else if (has_int32_value_) { 2702 } else if (has_int32_value_) {
2704 r = Representation::Integer32(); 2703 r = Representation::Integer32();
(...skipping 26 matching lines...) Expand all
2731 if (has_int32_value_) { 2730 if (has_int32_value_) {
2732 return new(zone) HConstant(int32_value_, r, is_not_in_new_space_, handle_); 2731 return new(zone) HConstant(int32_value_, r, is_not_in_new_space_, handle_);
2733 } 2732 }
2734 if (has_double_value_) { 2733 if (has_double_value_) {
2735 return new(zone) HConstant(double_value_, r, is_not_in_new_space_, handle_); 2734 return new(zone) HConstant(double_value_, r, is_not_in_new_space_, handle_);
2736 } 2735 }
2737 ASSERT(!handle_.is_null()); 2736 ASSERT(!handle_.is_null());
2738 return new(zone) HConstant(handle_, 2737 return new(zone) HConstant(handle_,
2739 unique_id_, 2738 unique_id_,
2740 r, 2739 r,
2741 type_from_value_, 2740 type_,
2742 is_internalized_string_, 2741 is_internalized_string_,
2743 is_not_in_new_space_, 2742 is_not_in_new_space_,
2744 is_cell_, 2743 is_cell_,
2745 boolean_value_); 2744 boolean_value_);
2746 } 2745 }
2747 2746
2748 2747
2749 Maybe<HConstant*> HConstant::CopyToTruncatedInt32(Zone* zone) { 2748 Maybe<HConstant*> HConstant::CopyToTruncatedInt32(Zone* zone) {
2750 HConstant* res = NULL; 2749 HConstant* res = NULL;
2751 if (has_int32_value_) { 2750 if (has_int32_value_) {
(...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after
3603 return HType::NonPrimitive(); 3602 return HType::NonPrimitive();
3604 } 3603 }
3605 3604
3606 3605
3607 HType HCheckSmi::CalculateInferredType() { 3606 HType HCheckSmi::CalculateInferredType() {
3608 return HType::Smi(); 3607 return HType::Smi();
3609 } 3608 }
3610 3609
3611 3610
3612 HType HPhi::CalculateInferredType() { 3611 HType HPhi::CalculateInferredType() {
3613 HType result = HType::Uninitialized(); 3612 if (OperandCount() == 0) return HType::Tagged();
3614 for (int i = 0; i < OperandCount(); ++i) { 3613 HType result = OperandAt(0)->type();
3614 for (int i = 1; i < OperandCount(); ++i) {
3615 HType current = OperandAt(i)->type(); 3615 HType current = OperandAt(i)->type();
3616 result = result.Combine(current); 3616 result = result.Combine(current);
3617 } 3617 }
3618 return result; 3618 return result;
3619 } 3619 }
3620 3620
3621 3621
3622 HType HConstant::CalculateInferredType() {
3623 if (has_int32_value_) {
3624 return Smi::IsValid(int32_value_) ? HType::Smi() : HType::HeapNumber();
3625 }
3626 if (has_double_value_) return HType::HeapNumber();
3627 ASSERT(!type_from_value_.IsUninitialized());
3628 return type_from_value_;
3629 }
3630
3631
3632 HType HCompareGeneric::CalculateInferredType() { 3622 HType HCompareGeneric::CalculateInferredType() {
3633 return HType::Boolean(); 3623 return HType::Boolean();
3634 } 3624 }
3635 3625
3636 3626
3637 HType HInstanceOf::CalculateInferredType() { 3627 HType HInstanceOf::CalculateInferredType() {
3638 return HType::Boolean(); 3628 return HType::Boolean();
3639 } 3629 }
3640 3630
3641 3631
(...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after
4493 case kBackingStore: 4483 case kBackingStore:
4494 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString()); 4484 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString());
4495 stream->Add("[backing-store]"); 4485 stream->Add("[backing-store]");
4496 break; 4486 break;
4497 } 4487 }
4498 4488
4499 stream->Add("@%d", offset()); 4489 stream->Add("@%d", offset());
4500 } 4490 }
4501 4491
4502 } } // namespace v8::internal 4492 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen-instructions.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698