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

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

Issue 90643003: Experimental implementation: Exposing SIMD instructions into JavaScript Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years 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.cc ('k') | src/hydrogen-instructions.cc » ('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 // 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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 V(StringCompareAndBranch) \ 179 V(StringCompareAndBranch) \
180 V(Sub) \ 180 V(Sub) \
181 V(ThisFunction) \ 181 V(ThisFunction) \
182 V(Throw) \ 182 V(Throw) \
183 V(ToFastProperties) \ 183 V(ToFastProperties) \
184 V(TransitionElementsKind) \ 184 V(TransitionElementsKind) \
185 V(TrapAllocationMemento) \ 185 V(TrapAllocationMemento) \
186 V(Typeof) \ 186 V(Typeof) \
187 V(TypeofIsAndBranch) \ 187 V(TypeofIsAndBranch) \
188 V(UnaryMathOperation) \ 188 V(UnaryMathOperation) \
189 V(NullarySIMDOperation) \
190 V(UnarySIMDOperation) \
191 V(BinarySIMDOperation) \
192 V(TernarySIMDOperation) \
193 V(QuarternarySIMDOperation) \
189 V(UnknownOSRValue) \ 194 V(UnknownOSRValue) \
190 V(UseConst) \ 195 V(UseConst) \
191 V(ValueOf) \ 196 V(ValueOf) \
192 V(WrapReceiver) 197 V(WrapReceiver)
193 198
194 #define GVN_TRACKED_FLAG_LIST(V) \ 199 #define GVN_TRACKED_FLAG_LIST(V) \
195 V(Maps) \ 200 V(Maps) \
196 V(NewSpacePromotion) 201 V(NewSpacePromotion)
197 202
198 #define GVN_UNTRACKED_FLAG_LIST(V) \ 203 #define GVN_UNTRACKED_FLAG_LIST(V) \
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 314
310 315
311 class HType V8_FINAL { 316 class HType V8_FINAL {
312 public: 317 public:
313 static HType None() { return HType(kNone); } 318 static HType None() { return HType(kNone); }
314 static HType Tagged() { return HType(kTagged); } 319 static HType Tagged() { return HType(kTagged); }
315 static HType TaggedPrimitive() { return HType(kTaggedPrimitive); } 320 static HType TaggedPrimitive() { return HType(kTaggedPrimitive); }
316 static HType TaggedNumber() { return HType(kTaggedNumber); } 321 static HType TaggedNumber() { return HType(kTaggedNumber); }
317 static HType Smi() { return HType(kSmi); } 322 static HType Smi() { return HType(kSmi); }
318 static HType HeapNumber() { return HType(kHeapNumber); } 323 static HType HeapNumber() { return HType(kHeapNumber); }
324 static HType Float32x4() { return HType(kFloat32x4); }
325 static HType Int32x4() { return HType(kInt32x4); }
319 static HType String() { return HType(kString); } 326 static HType String() { return HType(kString); }
320 static HType Boolean() { return HType(kBoolean); } 327 static HType Boolean() { return HType(kBoolean); }
321 static HType NonPrimitive() { return HType(kNonPrimitive); } 328 static HType NonPrimitive() { return HType(kNonPrimitive); }
322 static HType JSArray() { return HType(kJSArray); } 329 static HType JSArray() { return HType(kJSArray); }
323 static HType JSObject() { return HType(kJSObject); } 330 static HType JSObject() { return HType(kJSObject); }
324 331
325 // Return the weakest (least precise) common type. 332 // Return the weakest (least precise) common type.
326 HType Combine(HType other) { 333 HType Combine(HType other) {
327 return HType(static_cast<Type>(type_ & other.type_)); 334 return HType(static_cast<Type>(type_ & other.type_));
328 } 335 }
(...skipping 15 matching lines...) Expand all
344 } 351 }
345 352
346 bool IsSmi() const { 353 bool IsSmi() const {
347 return ((type_ & kSmi) == kSmi); 354 return ((type_ & kSmi) == kSmi);
348 } 355 }
349 356
350 bool IsHeapNumber() const { 357 bool IsHeapNumber() const {
351 return ((type_ & kHeapNumber) == kHeapNumber); 358 return ((type_ & kHeapNumber) == kHeapNumber);
352 } 359 }
353 360
361 bool IsFloat32x4() const {
362 return ((type_ & kFloat32x4) == kFloat32x4);
363 }
364
365 bool IsInt32x4() const {
366 return ((type_ & kInt32x4) == kInt32x4);
367 }
368
354 bool IsString() const { 369 bool IsString() const {
355 return ((type_ & kString) == kString); 370 return ((type_ & kString) == kString);
356 } 371 }
357 372
358 bool IsNonString() const { 373 bool IsNonString() const {
359 return IsTaggedPrimitive() || IsSmi() || IsHeapNumber() || 374 return IsTaggedPrimitive() || IsSmi() || IsHeapNumber() ||
360 IsBoolean() || IsJSArray(); 375 IsFloat32x4() || IsInt32x4() || IsBoolean() || IsJSArray();
361 } 376 }
362 377
363 bool IsBoolean() const { 378 bool IsBoolean() const {
364 return ((type_ & kBoolean) == kBoolean); 379 return ((type_ & kBoolean) == kBoolean);
365 } 380 }
366 381
367 bool IsNonPrimitive() const { 382 bool IsNonPrimitive() const {
368 return ((type_ & kNonPrimitive) == kNonPrimitive); 383 return ((type_ & kNonPrimitive) == kNonPrimitive);
369 } 384 }
370 385
371 bool IsJSArray() const { 386 bool IsJSArray() const {
372 return ((type_ & kJSArray) == kJSArray); 387 return ((type_ & kJSArray) == kJSArray);
373 } 388 }
374 389
375 bool IsJSObject() const { 390 bool IsJSObject() const {
376 return ((type_ & kJSObject) == kJSObject); 391 return ((type_ & kJSObject) == kJSObject);
377 } 392 }
378 393
379 bool IsHeapObject() const { 394 bool IsHeapObject() const {
380 return IsHeapNumber() || IsString() || IsBoolean() || IsNonPrimitive(); 395 return IsHeapNumber() || IsFloat32x4() || IsInt32x4() || IsString() ||
396 IsBoolean() || IsNonPrimitive();
381 } 397 }
382 398
383 bool ToStringOrToNumberCanBeObserved(Representation representation) { 399 bool ToStringOrToNumberCanBeObserved(Representation representation) {
384 switch (type_) { 400 switch (type_) {
385 case kTaggedPrimitive: // fallthru 401 case kTaggedPrimitive: // fallthru
386 case kTaggedNumber: // fallthru 402 case kTaggedNumber: // fallthru
387 case kSmi: // fallthru 403 case kSmi: // fallthru
388 case kHeapNumber: // fallthru 404 case kHeapNumber: // fallthru
405 case kFloat32x4: // fallthru
406 case kInt32x4: // fallthru
389 case kString: // fallthru 407 case kString: // fallthru
390 case kBoolean: 408 case kBoolean:
391 return false; 409 return false;
392 case kJSArray: // fallthru 410 case kJSArray: // fallthru
393 case kJSObject: 411 case kJSObject:
394 return true; 412 return true;
395 case kTagged: 413 case kTagged:
396 break; 414 break;
397 } 415 }
398 return !representation.IsSmiOrInteger32() && !representation.IsDouble(); 416 return !representation.IsSmiOrInteger32() && !representation.IsDouble();
399 } 417 }
400 418
401 static HType TypeFromValue(Handle<Object> value); 419 static HType TypeFromValue(Handle<Object> value);
420 static HType TypeFromRepresentation(Representation representation);
402 421
403 const char* ToString(); 422 const char* ToString();
404 423
405 private: 424 private:
406 enum Type { 425 enum Type {
407 kNone = 0x0, // 0000 0000 0000 0000 426 kNone = 0x0, // 0000 0000 0000 0000
408 kTagged = 0x1, // 0000 0000 0000 0001 427 kTagged = 0x1, // 0000 0000 0000 0001
409 kTaggedPrimitive = 0x5, // 0000 0000 0000 0101 428 kTaggedPrimitive = 0x5, // 0000 0000 0000 0101
410 kTaggedNumber = 0xd, // 0000 0000 0000 1101 429 kTaggedNumber = 0xd, // 0000 0000 0000 1101
411 kSmi = 0x1d, // 0000 0000 0001 1101 430 kSmi = 0x1d, // 0000 0000 0001 1101
412 kHeapNumber = 0x2d, // 0000 0000 0010 1101 431 kHeapNumber = 0x2d, // 0000 0000 0010 1101
413 kString = 0x45, // 0000 0000 0100 0101 432 kFloat32x4 = 0x45, // 0000 0000 0100 0101
414 kBoolean = 0x85, // 0000 0000 1000 0101 433 kInt32x4 = 0x85, // 0000 0000 1000 0101
415 kNonPrimitive = 0x101, // 0000 0001 0000 0001 434 kString = 0x105, // 0000 0001 0000 0101
416 kJSObject = 0x301, // 0000 0011 0000 0001 435 kBoolean = 0x205, // 0000 0010 1000 0101
417 kJSArray = 0x701 // 0000 0111 0000 0001 436 kNonPrimitive = 0x401, // 0000 0100 0000 0001
437 kJSObject = 0xc01, // 0000 1100 0000 0001
438 kJSArray = 0x1c01 // 0001 1100 0000 0001
418 }; 439 };
419 440
420 // Make sure type fits in int16. 441 // Make sure type fits in int16.
421 STATIC_ASSERT(kJSArray < (1 << (2 * kBitsPerByte))); 442 STATIC_ASSERT(kJSArray < (1 << (2 * kBitsPerByte)));
422 443
423 explicit HType(Type t) : type_(t) { } 444 explicit HType(Type t) : type_(t) { }
424 445
425 int16_t type_; 446 int16_t type_;
426 }; 447 };
427 448
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 } 690 }
670 } 691 }
671 virtual void AssumeRepresentation(Representation r); 692 virtual void AssumeRepresentation(Representation r);
672 693
673 virtual Representation KnownOptimalRepresentation() { 694 virtual Representation KnownOptimalRepresentation() {
674 Representation r = representation(); 695 Representation r = representation();
675 if (r.IsTagged()) { 696 if (r.IsTagged()) {
676 HType t = type(); 697 HType t = type();
677 if (t.IsSmi()) return Representation::Smi(); 698 if (t.IsSmi()) return Representation::Smi();
678 if (t.IsHeapNumber()) return Representation::Double(); 699 if (t.IsHeapNumber()) return Representation::Double();
700 if (t.IsFloat32x4()) return Representation::Float32x4();
701 if (t.IsInt32x4()) return Representation::Int32x4();
679 if (t.IsHeapObject()) return r; 702 if (t.IsHeapObject()) return r;
680 return Representation::None(); 703 return Representation::None();
681 } 704 }
682 return r; 705 return r;
683 } 706 }
684 707
685 HType type() const { return type_; } 708 HType type() const { return type_; }
686 void set_type(HType new_type) { 709 void set_type(HType new_type) {
687 ASSERT(new_type.IsSubtypeOf(type_)); 710 ASSERT(new_type.IsSubtypeOf(type_));
688 type_ = new_type; 711 type_ = new_type;
(...skipping 1022 matching lines...) Expand 10 before | Expand all | Expand 10 after
1711 set_representation(to); 1734 set_representation(to);
1712 SetFlag(kUseGVN); 1735 SetFlag(kUseGVN);
1713 if (is_truncating_to_smi) { 1736 if (is_truncating_to_smi) {
1714 SetFlag(kTruncatingToSmi); 1737 SetFlag(kTruncatingToSmi);
1715 SetFlag(kTruncatingToInt32); 1738 SetFlag(kTruncatingToInt32);
1716 } 1739 }
1717 if (is_truncating_to_int32) SetFlag(kTruncatingToInt32); 1740 if (is_truncating_to_int32) SetFlag(kTruncatingToInt32);
1718 if (value->representation().IsSmi() || value->type().IsSmi()) { 1741 if (value->representation().IsSmi() || value->type().IsSmi()) {
1719 set_type(HType::Smi()); 1742 set_type(HType::Smi());
1720 } else { 1743 } else {
1721 set_type(HType::TaggedNumber()); 1744 if (to.IsFloat32x4()) {
1745 set_type(HType::Float32x4());
1746 } else if (to.IsInt32x4()) {
1747 set_type(HType::Int32x4());
1748 } else {
1749 set_type(HType::TaggedNumber());
1750 }
1722 if (to.IsTagged()) SetGVNFlag(kChangesNewSpacePromotion); 1751 if (to.IsTagged()) SetGVNFlag(kChangesNewSpacePromotion);
1723 } 1752 }
1724 } 1753 }
1725 1754
1726 bool can_convert_undefined_to_nan() { 1755 bool can_convert_undefined_to_nan() {
1727 return CheckUsesForFlag(kAllowUndefinedAsNaN); 1756 return CheckUsesForFlag(kAllowUndefinedAsNaN);
1728 } 1757 }
1729 1758
1730 virtual HValue* EnsureAndPropagateNotMinusZero( 1759 virtual HValue* EnsureAndPropagateNotMinusZero(
1731 BitVector* visited) V8_OVERRIDE; 1760 BitVector* visited) V8_OVERRIDE;
(...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after
2737 // corresponding HStoreRoot instruction. 2766 // corresponding HStoreRoot instruction.
2738 SetGVNFlag(kDependsOnCalls); 2767 SetGVNFlag(kDependsOnCalls);
2739 } 2768 }
2740 2769
2741 virtual bool IsDeletable() const V8_OVERRIDE { return true; } 2770 virtual bool IsDeletable() const V8_OVERRIDE { return true; }
2742 2771
2743 const Heap::RootListIndex index_; 2772 const Heap::RootListIndex index_;
2744 }; 2773 };
2745 2774
2746 2775
2776 class HNullarySIMDOperation V8_FINAL : public HTemplateInstruction<1> {
2777 public:
2778 static HInstruction* New(Zone* zone,
2779 HValue* context,
2780 BuiltinFunctionId op);
2781
2782 HValue* context() { return OperandAt(0); }
2783
2784 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2785
2786 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
2787 return Representation::Tagged();
2788 }
2789
2790 virtual Range* InferRange(Zone* zone) V8_OVERRIDE;
2791 virtual HValue* Canonicalize() V8_OVERRIDE;
2792
2793 BuiltinFunctionId op() const { return op_; }
2794 const char* OpName() const;
2795
2796 DECLARE_CONCRETE_INSTRUCTION(NullarySIMDOperation)
2797
2798 protected:
2799 virtual bool DataEquals(HValue* other) V8_OVERRIDE {
2800 HNullarySIMDOperation* b = HNullarySIMDOperation::cast(other);
2801 return op_ == b->op();
2802 }
2803
2804 private:
2805 HNullarySIMDOperation(HValue* context, BuiltinFunctionId op)
2806 : HTemplateInstruction<1>(HType::Float32x4()), op_(op) {
2807 SetOperandAt(0, context);
2808 switch (op) {
2809 case kFloat32x4Zero:
2810 set_representation(Representation::Float32x4());
2811 break;
2812 default:
2813 UNREACHABLE();
2814 }
2815 SetFlag(kUseGVN);
2816 }
2817
2818 virtual bool IsDeletable() const V8_OVERRIDE { return true; }
2819
2820 BuiltinFunctionId op_;
2821 };
2822
2823
2824 class HUnarySIMDOperation V8_FINAL : public HTemplateInstruction<2> {
2825 public:
2826 static HInstruction* New(Zone* zone,
2827 HValue* context,
2828 HValue* value,
2829 BuiltinFunctionId op,
2830 Representation to = Representation::Float32x4());
2831
2832 HValue* context() { return OperandAt(0); }
2833 HValue* value() { return OperandAt(1); }
2834
2835 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2836
2837 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
2838 if (op_ == kFloat32x4OrInt32x4Change) {
2839 return value()->representation();
2840 } else if (index == 0) {
2841 return Representation::Tagged();
2842 } else {
2843 switch (op_) {
2844 case kSIMDAbs:
2845 case kSIMDNeg:
2846 case kSIMDReciprocal:
2847 case kSIMDReciprocalSqrt:
2848 case kSIMDSqrt:
2849 case kSIMDBitsToInt32x4:
2850 case kSIMDToInt32x4:
2851 case kFloat32x4SignMask:
2852 case kFloat32x4X:
2853 case kFloat32x4Y:
2854 case kFloat32x4Z:
2855 case kFloat32x4W:
2856 return Representation::Float32x4();
2857 case kSIMDBitsToFloat32x4:
2858 case kSIMDToFloat32x4:
2859 case kInt32x4SignMask:
2860 case kInt32x4X:
2861 case kInt32x4Y:
2862 case kInt32x4Z:
2863 case kInt32x4W:
2864 case kInt32x4FlagX:
2865 case kInt32x4FlagY:
2866 case kInt32x4FlagZ:
2867 case kInt32x4FlagW:
2868 case kSIMDNegU32:
2869 return Representation::Int32x4();
2870 case kFloat32x4Splat:
2871 return Representation::Double();
2872 case kInt32x4Splat:
2873 return Representation::Integer32();
2874 default:
2875 UNREACHABLE();
2876 return Representation::None();
2877 }
2878 }
2879 }
2880
2881 virtual Range* InferRange(Zone* zone) V8_OVERRIDE;
2882
2883 virtual HValue* Canonicalize() V8_OVERRIDE;
2884 virtual Representation RepresentationFromInputs() V8_OVERRIDE;
2885
2886 BuiltinFunctionId op() const { return op_; }
2887 const char* OpName() const;
2888
2889 DECLARE_CONCRETE_INSTRUCTION(UnarySIMDOperation)
2890
2891 protected:
2892 virtual bool DataEquals(HValue* other) V8_OVERRIDE {
2893 HUnarySIMDOperation* b = HUnarySIMDOperation::cast(other);
2894 return op_ == b->op();
2895 }
2896
2897 private:
2898 HUnarySIMDOperation(HValue* context, HValue* value, BuiltinFunctionId op,
2899 Representation to = Representation::Float32x4())
2900 : HTemplateInstruction<2>(HType::TypeFromRepresentation(to)), op_(op) {
2901 SetOperandAt(0, context);
2902 SetOperandAt(1, value);
2903 switch (op) {
2904 case kFloat32x4OrInt32x4Change:
2905 set_representation(to);
2906 break;
2907 case kSIMDAbs:
2908 case kSIMDNeg:
2909 case kSIMDReciprocal:
2910 case kSIMDReciprocalSqrt:
2911 case kSIMDSqrt:
2912 case kSIMDBitsToFloat32x4:
2913 case kSIMDToFloat32x4:
2914 case kFloat32x4Splat:
2915 set_representation(Representation::Float32x4());
2916 break;
2917 case kSIMDBitsToInt32x4:
2918 case kSIMDToInt32x4:
2919 case kInt32x4Splat:
2920 case kSIMDNegU32:
2921 set_representation(Representation::Int32x4());
2922 type_ = HType::Int32x4();
2923 break;
2924 case kFloat32x4SignMask:
2925 case kInt32x4SignMask:
2926 set_representation(Representation::Integer32());
2927 break;
2928 case kFloat32x4X:
2929 case kFloat32x4Y:
2930 case kFloat32x4Z:
2931 case kFloat32x4W:
2932 set_representation(Representation::Double());
2933 break;
2934 case kInt32x4X:
2935 case kInt32x4Y:
2936 case kInt32x4Z:
2937 case kInt32x4W:
2938 set_representation(Representation::Integer32());
2939 break;
2940 case kInt32x4FlagX:
2941 case kInt32x4FlagY:
2942 case kInt32x4FlagZ:
2943 case kInt32x4FlagW:
2944 set_representation(Representation::Tagged());
2945 break;
2946 default:
2947 UNREACHABLE();
2948 }
2949 SetFlag(kUseGVN);
2950 }
2951
2952 virtual bool IsDeletable() const V8_OVERRIDE { return true; }
2953
2954 BuiltinFunctionId op_;
2955 };
2956
2957
2958 class HBinarySIMDOperation V8_FINAL : public HTemplateInstruction<3> {
2959 public:
2960 static HInstruction* New(Zone* zone,
2961 HValue* context,
2962 HValue* left,
2963 HValue* right,
2964 BuiltinFunctionId op);
2965
2966 HValue* context() { return OperandAt(0); }
2967 HValue* left() { return OperandAt(1); }
2968 HValue* right() { return OperandAt(2); }
2969
2970 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2971
2972 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
2973 if (index == 0) {
2974 return Representation::Tagged();
2975 } else {
2976 switch (op_) {
2977 case kSIMDAdd:
2978 case kSIMDSub:
2979 case kSIMDMul:
2980 case kSIMDDiv:
2981 case kSIMDMin:
2982 case kSIMDMax:
2983 case kSIMDLessThan:
2984 case kSIMDLessThanOrEqual:
2985 case kSIMDEqual:
2986 case kSIMDNotEqual:
2987 case kSIMDGreaterThanOrEqual:
2988 case kSIMDGreaterThan:
2989 return Representation::Float32x4();
2990 case kSIMDAnd:
2991 case kSIMDOr:
2992 case kSIMDXor:
2993 case kSIMDAddU32:
2994 case kSIMDSubU32:
2995 case kSIMDMulU32:
2996 return Representation::Int32x4();
2997 case kSIMDShuffle:
2998 return index == 1 ? Representation::Float32x4()
2999 : Representation::Integer32();
3000 case kSIMDScale:
3001 case kSIMDWithX:
3002 case kSIMDWithY:
3003 case kSIMDWithZ:
3004 case kSIMDWithW:
3005 return index == 1 ? Representation::Float32x4()
3006 : Representation::Double();
3007 case kSIMDWithXu32:
3008 case kSIMDWithYu32:
3009 case kSIMDWithZu32:
3010 case kSIMDWithWu32:
3011 case kSIMDShuffleU32:
3012 return index == 1 ? Representation::Int32x4()
3013 : Representation::Integer32();
3014 case kSIMDWithFlagX:
3015 case kSIMDWithFlagY:
3016 case kSIMDWithFlagZ:
3017 case kSIMDWithFlagW:
3018 return index == 1 ? Representation::Int32x4()
3019 : Representation::Tagged();
3020 default:
3021 UNREACHABLE();
3022 return Representation::None();
3023 }
3024 }
3025 }
3026
3027 virtual Range* InferRange(Zone* zone) V8_OVERRIDE;
3028
3029 virtual HValue* Canonicalize() V8_OVERRIDE;
3030 virtual Representation RepresentationFromInputs() V8_OVERRIDE;
3031
3032 BuiltinFunctionId op() const { return op_; }
3033 const char* OpName() const;
3034
3035 DECLARE_CONCRETE_INSTRUCTION(BinarySIMDOperation)
3036
3037 protected:
3038 virtual bool DataEquals(HValue* other) V8_OVERRIDE {
3039 HBinarySIMDOperation* b = HBinarySIMDOperation::cast(other);
3040 return op_ == b->op();
3041 }
3042
3043 private:
3044 HBinarySIMDOperation(HValue* context, HValue* left, HValue* right,
3045 BuiltinFunctionId op)
3046 : HTemplateInstruction<3>(HType::Float32x4()), op_(op) {
3047 SetOperandAt(0, context);
3048 SetOperandAt(1, left);
3049 SetOperandAt(2, right);
3050 switch (op) {
3051 case kSIMDAdd:
3052 case kSIMDSub:
3053 case kSIMDMul:
3054 case kSIMDDiv:
3055 case kSIMDMin:
3056 case kSIMDMax:
3057 case kSIMDScale:
3058 case kSIMDShuffle:
3059 case kSIMDWithX:
3060 case kSIMDWithY:
3061 case kSIMDWithZ:
3062 case kSIMDWithW:
3063 set_representation(Representation::Float32x4());
3064 break;
3065 case kSIMDAnd:
3066 case kSIMDOr:
3067 case kSIMDXor:
3068 case kSIMDAddU32:
3069 case kSIMDSubU32:
3070 case kSIMDMulU32:
3071 case kSIMDLessThan:
3072 case kSIMDLessThanOrEqual:
3073 case kSIMDEqual:
3074 case kSIMDNotEqual:
3075 case kSIMDGreaterThanOrEqual:
3076 case kSIMDGreaterThan:
3077 case kSIMDWithXu32:
3078 case kSIMDWithYu32:
3079 case kSIMDWithZu32:
3080 case kSIMDWithWu32:
3081 case kSIMDWithFlagX:
3082 case kSIMDWithFlagY:
3083 case kSIMDWithFlagZ:
3084 case kSIMDWithFlagW:
3085 case kSIMDShuffleU32:
3086 set_representation(Representation::Int32x4());
3087 type_ = HType::Int32x4();
3088 break;
3089 default:
3090 UNREACHABLE();
3091 }
3092 SetFlag(kUseGVN);
3093 }
3094
3095 virtual bool IsDeletable() const V8_OVERRIDE { return true; }
3096
3097 BuiltinFunctionId op_;
3098 };
3099
3100
3101 class HTernarySIMDOperation V8_FINAL : public HTemplateInstruction<4> {
3102 public:
3103 static HInstruction* New(Zone* zone,
3104 HValue* context,
3105 HValue* first,
3106 HValue* second,
3107 HValue* third,
3108 BuiltinFunctionId op);
3109
3110 HValue* context() { return OperandAt(0); }
3111 HValue* first() { return OperandAt(1); }
3112 HValue* second() { return OperandAt(2); }
3113 HValue* third() { return OperandAt(3); }
3114
3115 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
3116
3117 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
3118 if (index == 0) {
3119 return Representation::Tagged();
3120 } else {
3121 switch (op_) {
3122 case kSIMDSelect:
3123 switch (index) {
3124 case 1: return Representation::Int32x4();
3125 case 2: return Representation::Float32x4();
3126 case 3: return Representation::Float32x4();
3127 default:
3128 UNREACHABLE();
3129 return Representation::None();
3130 }
3131 case kSIMDShuffleMix:
3132 switch (index) {
3133 case 1: return Representation::Float32x4();
3134 case 2: return Representation::Float32x4();
3135 case 3: return Representation::Integer32();
3136 default:
3137 UNREACHABLE();
3138 return Representation::None();
3139 }
3140 case kSIMDClamp:
3141 return Representation::Float32x4();
3142 default:
3143 UNREACHABLE();
3144 return Representation::None();
3145 }
3146 }
3147 }
3148
3149 virtual Range* InferRange(Zone* zone) V8_OVERRIDE;
3150
3151 virtual HValue* Canonicalize() V8_OVERRIDE;
3152 virtual Representation RepresentationFromInputs() V8_OVERRIDE;
3153
3154 BuiltinFunctionId op() const { return op_; }
3155 const char* OpName() const;
3156
3157 DECLARE_CONCRETE_INSTRUCTION(TernarySIMDOperation)
3158
3159 protected:
3160 virtual bool DataEquals(HValue* other) V8_OVERRIDE {
3161 HTernarySIMDOperation* b = HTernarySIMDOperation::cast(other);
3162 return op_ == b->op();
3163 }
3164
3165 private:
3166 HTernarySIMDOperation(HValue* context, HValue* first, HValue* second,
3167 HValue* third, BuiltinFunctionId op)
3168 : HTemplateInstruction<4>(HType::Float32x4()), op_(op) {
3169 SetOperandAt(0, context);
3170 SetOperandAt(1, first);
3171 SetOperandAt(2, second);
3172 SetOperandAt(3, third);
3173 switch (op) {
3174 case kSIMDSelect:
3175 case kSIMDShuffleMix:
3176 case kSIMDClamp:
3177 set_representation(Representation::Float32x4());
3178 break;
3179 default:
3180 UNREACHABLE();
3181 }
3182 SetFlag(kUseGVN);
3183 }
3184
3185 virtual bool IsDeletable() const V8_OVERRIDE { return true; }
3186
3187 BuiltinFunctionId op_;
3188 };
3189
3190
3191 class HQuarternarySIMDOperation V8_FINAL : public HTemplateInstruction<5> {
3192 public:
3193 static HInstruction* New(Zone* zone,
3194 HValue* context,
3195 HValue* x,
3196 HValue* y,
3197 HValue* z,
3198 HValue* w,
3199 BuiltinFunctionId op);
3200
3201 HValue* context() { return OperandAt(0); }
3202 HValue* x() { return OperandAt(1); }
3203 HValue* y() { return OperandAt(2); }
3204 HValue* z() { return OperandAt(3); }
3205 HValue* w() { return OperandAt(4); }
3206
3207 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
3208
3209 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
3210 if (index == 0) {
3211 return Representation::Tagged();
3212 } else {
3213 switch (op_) {
3214 case kFloat32x4Constructor: return Representation::Double();
3215 case kInt32x4Constructor:
3216 return Representation::Integer32();
3217 case kInt32x4Bool:
3218 return Representation::Tagged();
3219 default:
3220 UNREACHABLE();
3221 return Representation::None();
3222 }
3223 }
3224 }
3225
3226 virtual Range* InferRange(Zone* zone) V8_OVERRIDE;
3227
3228 virtual HValue* Canonicalize() V8_OVERRIDE;
3229 virtual Representation RepresentationFromInputs() V8_OVERRIDE;
3230
3231 BuiltinFunctionId op() const { return op_; }
3232 const char* OpName() const;
3233
3234 DECLARE_CONCRETE_INSTRUCTION(QuarternarySIMDOperation)
3235
3236 protected:
3237 virtual bool DataEquals(HValue* other) V8_OVERRIDE {
3238 HQuarternarySIMDOperation* b = HQuarternarySIMDOperation::cast(other);
3239 return op_ == b->op();
3240 }
3241
3242 private:
3243 HQuarternarySIMDOperation(HValue* context, HValue* x, HValue* y, HValue* z,
3244 HValue* w, BuiltinFunctionId op)
3245 : HTemplateInstruction<5>(HType::Float32x4()), op_(op) {
3246 SetOperandAt(0, context);
3247 SetOperandAt(1, x);
3248 SetOperandAt(2, y);
3249 SetOperandAt(3, z);
3250 SetOperandAt(4, w);
3251 switch (op) {
3252 case kFloat32x4Constructor:
3253 set_representation(Representation::Float32x4());
3254 break;
3255 case kInt32x4Constructor:
3256 case kInt32x4Bool:
3257 set_representation(Representation::Int32x4());
3258 type_ = HType::Int32x4();
3259 break;
3260 default:
3261 UNREACHABLE();
3262 }
3263 SetFlag(kUseGVN);
3264 }
3265
3266 virtual bool IsDeletable() const V8_OVERRIDE { return true; }
3267
3268 BuiltinFunctionId op_;
3269 };
3270
3271
2747 class HLoadExternalArrayPointer V8_FINAL : public HUnaryOperation { 3272 class HLoadExternalArrayPointer V8_FINAL : public HUnaryOperation {
2748 public: 3273 public:
2749 DECLARE_INSTRUCTION_FACTORY_P1(HLoadExternalArrayPointer, HValue*); 3274 DECLARE_INSTRUCTION_FACTORY_P1(HLoadExternalArrayPointer, HValue*);
2750 3275
2751 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { 3276 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
2752 return Representation::Tagged(); 3277 return Representation::Tagged();
2753 } 3278 }
2754 3279
2755 virtual HType CalculateInferredType() V8_OVERRIDE { 3280 virtual HType CalculateInferredType() V8_OVERRIDE {
2756 return HType::None(); 3281 return HType::None();
(...skipping 1847 matching lines...) Expand 10 before | Expand all | Expand 10 after
4604 Handle<String> class_name_; 5129 Handle<String> class_name_;
4605 }; 5130 };
4606 5131
4607 5132
4608 class HTypeofIsAndBranch V8_FINAL : public HUnaryControlInstruction { 5133 class HTypeofIsAndBranch V8_FINAL : public HUnaryControlInstruction {
4609 public: 5134 public:
4610 DECLARE_INSTRUCTION_FACTORY_P2(HTypeofIsAndBranch, HValue*, Handle<String>); 5135 DECLARE_INSTRUCTION_FACTORY_P2(HTypeofIsAndBranch, HValue*, Handle<String>);
4611 5136
4612 Handle<String> type_literal() { return type_literal_; } 5137 Handle<String> type_literal() { return type_literal_; }
4613 bool compares_number_type() { return compares_number_type_; } 5138 bool compares_number_type() { return compares_number_type_; }
5139 bool compares_float32x4_type() { return compares_float32x4_type_; }
5140 bool compares_int32x4_type() { return compares_int32x4_type_; }
4614 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE; 5141 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
4615 5142
4616 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch) 5143 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch)
4617 5144
4618 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { 5145 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
4619 return Representation::None(); 5146 return Representation::None();
4620 } 5147 }
4621 5148
4622 virtual bool KnownSuccessorBlock(HBasicBlock** block) V8_OVERRIDE; 5149 virtual bool KnownSuccessorBlock(HBasicBlock** block) V8_OVERRIDE;
4623 5150
4624 private: 5151 private:
4625 HTypeofIsAndBranch(HValue* value, Handle<String> type_literal) 5152 HTypeofIsAndBranch(HValue* value, Handle<String> type_literal)
4626 : HUnaryControlInstruction(value, NULL, NULL), 5153 : HUnaryControlInstruction(value, NULL, NULL),
4627 type_literal_(type_literal) { 5154 type_literal_(type_literal) {
4628 Heap* heap = type_literal->GetHeap(); 5155 Heap* heap = type_literal->GetHeap();
4629 compares_number_type_ = type_literal->Equals(heap->number_string()); 5156 compares_number_type_ = type_literal->Equals(heap->number_string());
5157 compares_float32x4_type_ = type_literal->Equals(heap->float32x4_string());
5158 compares_int32x4_type_ = type_literal->Equals(heap->int32x4_string());
4630 } 5159 }
4631 5160
4632 Handle<String> type_literal_; 5161 Handle<String> type_literal_;
4633 bool compares_number_type_ : 1; 5162 bool compares_number_type_ : 1;
5163 bool compares_float32x4_type_ : 1;
5164 bool compares_int32x4_type_ : 1;
4634 }; 5165 };
4635 5166
4636 5167
4637 class HInstanceOf V8_FINAL : public HBinaryOperation { 5168 class HInstanceOf V8_FINAL : public HBinaryOperation {
4638 public: 5169 public:
4639 DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P2(HInstanceOf, HValue*, HValue*); 5170 DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P2(HInstanceOf, HValue*, HValue*);
4640 5171
4641 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { 5172 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
4642 return Representation::Tagged(); 5173 return Representation::Tagged();
4643 } 5174 }
(...skipping 1379 matching lines...) Expand 10 before | Expand all | Expand 10 after
6023 Map::kInstanceSizeOffset, 6554 Map::kInstanceSizeOffset,
6024 Representation::UInteger8()); 6555 Representation::UInteger8());
6025 } 6556 }
6026 6557
6027 static HObjectAccess ForMapInstanceType() { 6558 static HObjectAccess ForMapInstanceType() {
6028 return HObjectAccess(kInobject, 6559 return HObjectAccess(kInobject,
6029 Map::kInstanceTypeOffset, 6560 Map::kInstanceTypeOffset,
6030 Representation::UInteger8()); 6561 Representation::UInteger8());
6031 } 6562 }
6032 6563
6564 static HObjectAccess ForMapPrototype() {
6565 return HObjectAccess(kInobject, Map::kPrototypeOffset);
6566 }
6567
6033 static HObjectAccess ForPropertyCellValue() { 6568 static HObjectAccess ForPropertyCellValue() {
6034 return HObjectAccess(kInobject, PropertyCell::kValueOffset); 6569 return HObjectAccess(kInobject, PropertyCell::kValueOffset);
6035 } 6570 }
6036 6571
6037 static HObjectAccess ForCellValue() { 6572 static HObjectAccess ForCellValue() {
6038 return HObjectAccess(kInobject, Cell::kValueOffset); 6573 return HObjectAccess(kInobject, Cell::kValueOffset);
6039 } 6574 }
6040 6575
6041 static HObjectAccess ForAllocationMementoSite() { 6576 static HObjectAccess ForAllocationMementoSite() {
6042 return HObjectAccess(kInobject, AllocationMemento::kAllocationSiteOffset); 6577 return HObjectAccess(kInobject, AllocationMemento::kAllocationSiteOffset);
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
6410 6945
6411 SetGVNFlag(kDependsOnArrayElements); 6946 SetGVNFlag(kDependsOnArrayElements);
6412 } else { 6947 } else {
6413 set_representation(Representation::Double()); 6948 set_representation(Representation::Double());
6414 SetGVNFlag(kDependsOnDoubleArrayElements); 6949 SetGVNFlag(kDependsOnDoubleArrayElements);
6415 } 6950 }
6416 } else { 6951 } else {
6417 if (elements_kind == EXTERNAL_FLOAT_ELEMENTS || 6952 if (elements_kind == EXTERNAL_FLOAT_ELEMENTS ||
6418 elements_kind == EXTERNAL_DOUBLE_ELEMENTS) { 6953 elements_kind == EXTERNAL_DOUBLE_ELEMENTS) {
6419 set_representation(Representation::Double()); 6954 set_representation(Representation::Double());
6955 } else if (elements_kind == EXTERNAL_FLOAT32x4_ELEMENTS) {
6956 set_representation(CpuFeatures::IsSupported(SSE2) ?
6957 Representation::Float32x4() : Representation::Tagged());
6958 } else if (elements_kind == EXTERNAL_INT32x4_ELEMENTS) {
6959 set_representation(CpuFeatures::IsSupported(SSE2) ?
6960 Representation::Int32x4() : Representation::Tagged());
6420 } else { 6961 } else {
6421 set_representation(Representation::Integer32()); 6962 set_representation(Representation::Integer32());
6422 } 6963 }
6423 6964
6424 SetGVNFlag(kDependsOnExternalMemory); 6965 SetGVNFlag(kDependsOnExternalMemory);
6425 // Native code could change the specialized array. 6966 // Native code could change the specialized array.
6426 SetGVNFlag(kDependsOnCalls); 6967 SetGVNFlag(kDependsOnCalls);
6427 } 6968 }
6428 6969
6429 SetFlag(kUseGVN); 6970 SetFlag(kUseGVN);
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
6664 // kind_external: external[int32] = (double | int32) 7205 // kind_external: external[int32] = (double | int32)
6665 if (index == 0) { 7206 if (index == 0) {
6666 return is_external() ? Representation::External() 7207 return is_external() ? Representation::External()
6667 : Representation::Tagged(); 7208 : Representation::Tagged();
6668 } else if (index == 1) { 7209 } else if (index == 1) {
6669 return ArrayInstructionInterface::KeyedAccessIndexRequirement( 7210 return ArrayInstructionInterface::KeyedAccessIndexRequirement(
6670 OperandAt(1)->representation()); 7211 OperandAt(1)->representation());
6671 } 7212 }
6672 7213
6673 ASSERT_EQ(index, 2); 7214 ASSERT_EQ(index, 2);
7215
6674 if (IsDoubleOrFloatElementsKind(elements_kind())) { 7216 if (IsDoubleOrFloatElementsKind(elements_kind())) {
6675 return Representation::Double(); 7217 return Representation::Double();
6676 } 7218 }
6677 7219
7220 if (IsExternalFloat32x4ElementsKind(elements_kind())) {
7221 return CpuFeatures::IsSupported(SSE2) ?
7222 Representation::Float32x4() : Representation::Tagged();
7223 }
7224
7225 if (IsExternalInt32x4ElementsKind(elements_kind())) {
7226 return CpuFeatures::IsSupported(SSE2) ?
7227 Representation::Int32x4() : Representation::Tagged();
7228 }
7229
6678 if (IsFastSmiElementsKind(elements_kind())) { 7230 if (IsFastSmiElementsKind(elements_kind())) {
6679 return Representation::Smi(); 7231 return Representation::Smi();
6680 } 7232 }
6681 7233
6682 return is_external() ? Representation::Integer32() 7234 return is_external() ? Representation::Integer32()
6683 : Representation::Tagged(); 7235 : Representation::Tagged();
6684 } 7236 }
6685 7237
6686 bool is_external() const { 7238 bool is_external() const {
6687 return IsExternalArrayElementsKind(elements_kind()); 7239 return IsExternalArrayElementsKind(elements_kind());
6688 } 7240 }
6689 7241
6690 virtual Representation observed_input_representation(int index) V8_OVERRIDE { 7242 virtual Representation observed_input_representation(int index) V8_OVERRIDE {
6691 if (index < 2) return RequiredInputRepresentation(index); 7243 if (index < 2) return RequiredInputRepresentation(index);
6692 if (IsUninitialized()) { 7244 if (IsUninitialized()) {
6693 return Representation::None(); 7245 return Representation::None();
6694 } 7246 }
6695 if (IsFastSmiElementsKind(elements_kind())) { 7247 if (IsFastSmiElementsKind(elements_kind())) {
6696 return Representation::Smi(); 7248 return Representation::Smi();
6697 } 7249 }
6698 if (IsDoubleOrFloatElementsKind(elements_kind())) { 7250 if (IsDoubleOrFloatElementsKind(elements_kind())) {
6699 return Representation::Double(); 7251 return Representation::Double();
6700 } 7252 }
7253 if (IsExternalFloat32x4ElementsKind(elements_kind())) {
7254 return CpuFeatures::IsSupported(SSE2) ?
7255 Representation::Float32x4() : Representation::Tagged();
7256 }
7257 if (IsExternalInt32x4ElementsKind(elements_kind())) {
7258 return CpuFeatures::IsSupported(SSE2) ?
7259 Representation::Int32x4() : Representation::Tagged();
7260 }
6701 if (is_external()) { 7261 if (is_external()) {
6702 return Representation::Integer32(); 7262 return Representation::Integer32();
6703 } 7263 }
6704 // For fast object elements kinds, don't assume anything. 7264 // For fast object elements kinds, don't assume anything.
6705 return Representation::None(); 7265 return Representation::None();
6706 } 7266 }
6707 7267
6708 HValue* elements() { return OperandAt(0); } 7268 HValue* elements() { return OperandAt(0); }
6709 HValue* key() { return OperandAt(1); } 7269 HValue* key() { return OperandAt(1); }
6710 HValue* value() { return OperandAt(2); } 7270 HValue* value() { return OperandAt(2); }
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after
7473 virtual bool IsDeletable() const V8_OVERRIDE { return true; } 8033 virtual bool IsDeletable() const V8_OVERRIDE { return true; }
7474 }; 8034 };
7475 8035
7476 8036
7477 #undef DECLARE_INSTRUCTION 8037 #undef DECLARE_INSTRUCTION
7478 #undef DECLARE_CONCRETE_INSTRUCTION 8038 #undef DECLARE_CONCRETE_INSTRUCTION
7479 8039
7480 } } // namespace v8::internal 8040 } } // namespace v8::internal
7481 8041
7482 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ 8042 #endif // V8_HYDROGEN_INSTRUCTIONS_H_
OLDNEW
« no previous file with comments | « src/hydrogen.cc ('k') | src/hydrogen-instructions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698