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

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

Issue 300893003: Refactor HType to get rid of various hacks. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix compilation. Created 6 years, 6 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') | src/hydrogen-types.h » ('j') | 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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "v8.h" 5 #include "v8.h"
6 6
7 #include "double.h" 7 #include "double.h"
8 #include "factory.h" 8 #include "factory.h"
9 #include "hydrogen-infer-representation.h" 9 #include "hydrogen-infer-representation.h"
10 #include "property-details-inl.h" 10 #include "property-details-inl.h"
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 int v4 = MulWithoutOverflow(r, upper_, other->upper(), &may_overflow); 301 int v4 = MulWithoutOverflow(r, upper_, other->upper(), &may_overflow);
302 lower_ = Min(Min(v1, v2), Min(v3, v4)); 302 lower_ = Min(Min(v1, v2), Min(v3, v4));
303 upper_ = Max(Max(v1, v2), Max(v3, v4)); 303 upper_ = Max(Max(v1, v2), Max(v3, v4));
304 #ifdef DEBUG 304 #ifdef DEBUG
305 Verify(); 305 Verify();
306 #endif 306 #endif
307 return may_overflow; 307 return may_overflow;
308 } 308 }
309 309
310 310
311 const char* HType::ToString() {
312 // Note: The c1visualizer syntax for locals allows only a sequence of the
313 // following characters: A-Za-z0-9_-|:
314 switch (type_) {
315 case kNone: return "none";
316 case kTagged: return "tagged";
317 case kTaggedPrimitive: return "primitive";
318 case kTaggedNumber: return "number";
319 case kSmi: return "smi";
320 case kHeapNumber: return "heap-number";
321 case kString: return "string";
322 case kBoolean: return "boolean";
323 case kNonPrimitive: return "non-primitive";
324 case kJSArray: return "array";
325 case kJSObject: return "object";
326 }
327 UNREACHABLE();
328 return "unreachable";
329 }
330
331
332 HType HType::TypeFromValue(Handle<Object> value) {
333 HType result = HType::Tagged();
334 if (value->IsSmi()) {
335 result = HType::Smi();
336 } else if (value->IsHeapNumber()) {
337 result = HType::HeapNumber();
338 } else if (value->IsString()) {
339 result = HType::String();
340 } else if (value->IsBoolean()) {
341 result = HType::Boolean();
342 } else if (value->IsJSObject()) {
343 result = HType::JSObject();
344 } else if (value->IsJSArray()) {
345 result = HType::JSArray();
346 } else if (value->IsHeapObject()) {
347 result = HType::NonPrimitive();
348 }
349 return result;
350 }
351
352
353 bool HValue::IsDefinedAfter(HBasicBlock* other) const { 311 bool HValue::IsDefinedAfter(HBasicBlock* other) const {
354 return block()->block_id() > other->block_id(); 312 return block()->block_id() > other->block_id();
355 } 313 }
356 314
357 315
358 HUseListNode* HUseListNode::tail() { 316 HUseListNode* HUseListNode::tail() {
359 // Skip and remove dead items in the use list. 317 // Skip and remove dead items in the use list.
360 while (tail_ != NULL && tail_->value()->CheckFlag(HValue::kIsDead)) { 318 while (tail_ != NULL && tail_->value()->CheckFlag(HValue::kIsDead)) {
361 tail_ = tail_->tail_; 319 tail_ = tail_->tail_;
362 } 320 }
(...skipping 1268 matching lines...) Expand 10 before | Expand all | Expand 10 after
1631 } 1589 }
1632 1590
1633 return Prepend(HMathFloorOfDiv::New( 1591 return Prepend(HMathFloorOfDiv::New(
1634 block()->zone(), context(), left, right)); 1592 block()->zone(), context(), left, right));
1635 } 1593 }
1636 return this; 1594 return this;
1637 } 1595 }
1638 1596
1639 1597
1640 HValue* HCheckInstanceType::Canonicalize() { 1598 HValue* HCheckInstanceType::Canonicalize() {
1641 if (check_ == IS_STRING && value()->type().IsString()) { 1599 if ((check_ == IS_SPEC_OBJECT && value()->type().IsJSObject()) ||
1600 (check_ == IS_JS_ARRAY && value()->type().IsJSArray()) ||
1601 (check_ == IS_STRING && value()->type().IsString())) {
1642 return value(); 1602 return value();
1643 } 1603 }
1644 1604
1645 if (check_ == IS_INTERNALIZED_STRING && value()->IsConstant()) { 1605 if (check_ == IS_INTERNALIZED_STRING && value()->IsConstant()) {
1646 if (HConstant::cast(value())->HasInternalizedStringValue()) { 1606 if (HConstant::cast(value())->HasInternalizedStringValue()) {
1647 return value(); 1607 return value();
1648 } 1608 }
1649 } 1609 }
1650 return this; 1610 return this;
1651 } 1611 }
(...skipping 1039 matching lines...) Expand 10 before | Expand all | Expand 10 after
2691 } 2651 }
2692 2652
2693 2653
2694 static bool IsInteger32(double value) { 2654 static bool IsInteger32(double value) {
2695 double roundtrip_value = static_cast<double>(static_cast<int32_t>(value)); 2655 double roundtrip_value = static_cast<double>(static_cast<int32_t>(value));
2696 return BitCast<int64_t>(roundtrip_value) == BitCast<int64_t>(value); 2656 return BitCast<int64_t>(roundtrip_value) == BitCast<int64_t>(value);
2697 } 2657 }
2698 2658
2699 2659
2700 HConstant::HConstant(Handle<Object> object, Representation r) 2660 HConstant::HConstant(Handle<Object> object, Representation r)
2701 : HTemplateInstruction<0>(HType::TypeFromValue(object)), 2661 : HTemplateInstruction<0>(HType::FromValue(object)),
2702 object_(Unique<Object>::CreateUninitialized(object)), 2662 object_(Unique<Object>::CreateUninitialized(object)),
2703 object_map_(Handle<Map>::null()), 2663 object_map_(Handle<Map>::null()),
2704 has_stable_map_value_(false), 2664 has_stable_map_value_(false),
2705 has_smi_value_(false), 2665 has_smi_value_(false),
2706 has_int32_value_(false), 2666 has_int32_value_(false),
2707 has_double_value_(false), 2667 has_double_value_(false),
2708 has_external_reference_value_(false), 2668 has_external_reference_value_(false),
2709 is_not_in_new_space_(true), 2669 is_not_in_new_space_(true),
2710 boolean_value_(object->BooleanValue()), 2670 boolean_value_(object->BooleanValue()),
2711 is_undetectable_(false), 2671 is_undetectable_(false),
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2750 has_stable_map_value_(has_stable_map_value), 2710 has_stable_map_value_(has_stable_map_value),
2751 has_smi_value_(false), 2711 has_smi_value_(false),
2752 has_int32_value_(false), 2712 has_int32_value_(false),
2753 has_double_value_(false), 2713 has_double_value_(false),
2754 has_external_reference_value_(false), 2714 has_external_reference_value_(false),
2755 is_not_in_new_space_(is_not_in_new_space), 2715 is_not_in_new_space_(is_not_in_new_space),
2756 boolean_value_(boolean_value), 2716 boolean_value_(boolean_value),
2757 is_undetectable_(is_undetectable), 2717 is_undetectable_(is_undetectable),
2758 instance_type_(instance_type) { 2718 instance_type_(instance_type) {
2759 ASSERT(!object.handle().is_null()); 2719 ASSERT(!object.handle().is_null());
2760 ASSERT(!type.IsTaggedNumber()); 2720 ASSERT(!type.IsTaggedNumber() || type.IsNone());
2761 Initialize(r); 2721 Initialize(r);
2762 } 2722 }
2763 2723
2764 2724
2765 HConstant::HConstant(int32_t integer_value, 2725 HConstant::HConstant(int32_t integer_value,
2766 Representation r, 2726 Representation r,
2767 bool is_not_in_new_space, 2727 bool is_not_in_new_space,
2768 Unique<Object> object) 2728 Unique<Object> object)
2769 : object_(object), 2729 : object_(object),
2770 object_map_(Handle<Map>::null()), 2730 object_map_(Handle<Map>::null()),
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
2808 // It's possible to create a constant with a value in Smi-range but stored 2768 // It's possible to create a constant with a value in Smi-range but stored
2809 // in a (pre-existing) HeapNumber. See crbug.com/349878. 2769 // in a (pre-existing) HeapNumber. See crbug.com/349878.
2810 bool could_be_heapobject = r.IsTagged() && !object.handle().is_null(); 2770 bool could_be_heapobject = r.IsTagged() && !object.handle().is_null();
2811 bool is_smi = has_smi_value_ && !could_be_heapobject; 2771 bool is_smi = has_smi_value_ && !could_be_heapobject;
2812 set_type(is_smi ? HType::Smi() : HType::TaggedNumber()); 2772 set_type(is_smi ? HType::Smi() : HType::TaggedNumber());
2813 Initialize(r); 2773 Initialize(r);
2814 } 2774 }
2815 2775
2816 2776
2817 HConstant::HConstant(ExternalReference reference) 2777 HConstant::HConstant(ExternalReference reference)
2818 : HTemplateInstruction<0>(HType::None()), 2778 : HTemplateInstruction<0>(HType::Any()),
2819 object_(Unique<Object>(Handle<Object>::null())), 2779 object_(Unique<Object>(Handle<Object>::null())),
2820 object_map_(Handle<Map>::null()), 2780 object_map_(Handle<Map>::null()),
2821 has_stable_map_value_(false), 2781 has_stable_map_value_(false),
2822 has_smi_value_(false), 2782 has_smi_value_(false),
2823 has_int32_value_(false), 2783 has_int32_value_(false),
2824 has_double_value_(false), 2784 has_double_value_(false),
2825 has_external_reference_value_(true), 2785 has_external_reference_value_(true),
2826 is_not_in_new_space_(true), 2786 is_not_in_new_space_(true),
2827 boolean_value_(true), 2787 boolean_value_(true),
2828 is_undetectable_(false), 2788 is_undetectable_(false),
(...skipping 1958 matching lines...) Expand 10 before | Expand all | Expand 10 after
4787 break; 4747 break;
4788 case kExternalMemory: 4748 case kExternalMemory:
4789 stream->Add("[external-memory]"); 4749 stream->Add("[external-memory]");
4790 break; 4750 break;
4791 } 4751 }
4792 4752
4793 stream->Add("@%d", offset()); 4753 stream->Add("@%d", offset());
4794 } 4754 }
4795 4755
4796 } } // namespace v8::internal 4756 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen-instructions.h ('k') | src/hydrogen-types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698