| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef VM_INTERMEDIATE_LANGUAGE_H_ | 5 #ifndef VM_INTERMEDIATE_LANGUAGE_H_ |
| 6 #define VM_INTERMEDIATE_LANGUAGE_H_ | 6 #define VM_INTERMEDIATE_LANGUAGE_H_ |
| 7 | 7 |
| 8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
| 9 #include "vm/ast.h" | 9 #include "vm/ast.h" |
| 10 #include "vm/growable_array.h" | 10 #include "vm/growable_array.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 class Range; | 31 class Range; |
| 32 | 32 |
| 33 | 33 |
| 34 // TODO(srdjan): Unify with INTRINSIC_LIST. | 34 // TODO(srdjan): Unify with INTRINSIC_LIST. |
| 35 // (class-name, function-name, recognized enum, fingerprint). | 35 // (class-name, function-name, recognized enum, fingerprint). |
| 36 // See intrinsifier for fingerprint computation. | 36 // See intrinsifier for fingerprint computation. |
| 37 #define RECOGNIZED_LIST(V) \ | 37 #define RECOGNIZED_LIST(V) \ |
| 38 V(_ObjectArray, get:length, ObjectArrayLength, 405297088) \ | 38 V(_ObjectArray, get:length, ObjectArrayLength, 405297088) \ |
| 39 V(_ImmutableArray, get:length, ImmutableArrayLength, 433698233) \ | 39 V(_ImmutableArray, get:length, ImmutableArrayLength, 433698233) \ |
| 40 V(_TypedList, get:length, TypedDataLength, 231908172) \ | 40 V(_TypedList, get:length, TypedDataLength, 231908172) \ |
| 41 V(_ByteArrayBase, get:length, ByteArrayBaseLength, 1098081765) \ | 41 V(_TypedList, _getInt8, ByteArrayBaseGetInt8, 380843687) \ |
| 42 V(_ByteArrayBase, _getInt8, ByteArrayBaseGetInt8, 261365835) \ | 42 V(_TypedList, _getUint8, ByteArrayBaseGetUint8, 380843687) \ |
| 43 V(_ByteArrayBase, _getUint8, ByteArrayBaseGetUint8, 261365835) \ | 43 V(_TypedList, _getInt16, ByteArrayBaseGetInt16, 380843687) \ |
| 44 V(_ByteArrayBase, _getInt16, ByteArrayBaseGetInt16, 261365835) \ | 44 V(_TypedList, _getUint16, ByteArrayBaseGetUint16, 380843687) \ |
| 45 V(_ByteArrayBase, _getUint16, ByteArrayBaseGetUint16, 261365835) \ | 45 V(_TypedList, _getInt32, ByteArrayBaseGetInt32, 380843687) \ |
| 46 V(_ByteArrayBase, _getInt32, ByteArrayBaseGetInt32, 261365835) \ | 46 V(_TypedList, _getUint32, ByteArrayBaseGetUint32, 380843687) \ |
| 47 V(_ByteArrayBase, _getUint32, ByteArrayBaseGetUint32, 261365835) \ | 47 V(_TypedList, _getFloat32, ByteArrayBaseGetFloat32, 979971573) \ |
| 48 V(_ByteArrayBase, _getFloat32, ByteArrayBaseGetFloat32, 434247298) \ | 48 V(_TypedList, _getFloat64, ByteArrayBaseGetFloat64, 979971573) \ |
| 49 V(_ByteArrayBase, _getFloat64, ByteArrayBaseGetFloat64, 434247298) \ | 49 V(_TypedList, _setInt8, ByteArrayBaseSetInt8, 287047804) \ |
| 50 V(_ByteArrayBase, _setInt8, ByteArrayBaseSetInt8, 501962848) \ | 50 V(_TypedList, _setUint8, ByteArrayBaseSetUint8, 287047804) \ |
| 51 V(_ByteArrayBase, _setUint8, ByteArrayBaseSetUint8, 501962848) \ | 51 V(_TypedList, _setInt16, ByteArrayBaseSetInt16, 287047804) \ |
| 52 V(_ByteArrayBase, _setInt16, ByteArrayBaseSetInt16, 501962848) \ | 52 V(_TypedList, _setUint16, ByteArrayBaseSetUint16, 287047804) \ |
| 53 V(_ByteArrayBase, _setUint16, ByteArrayBaseSetUint16, 501962848) \ | 53 V(_TypedList, _setInt32, ByteArrayBaseSetInt32, 287047804) \ |
| 54 V(_ByteArrayBase, _setInt32, ByteArrayBaseSetInt32, 501962848) \ | 54 V(_TypedList, _setUint32, ByteArrayBaseSetUint32, 287047804) \ |
| 55 V(_ByteArrayBase, _setUint32, ByteArrayBaseSetUint32, 501962848) \ | 55 V(_TypedList, _setFloat32, ByteArrayBaseSetFloat32, 1032541114) \ |
| 56 V(_ByteArrayBase, _setFloat32, ByteArrayBaseSetFloat32, 864506525) \ | 56 V(_TypedList, _setFloat64, ByteArrayBaseSetFloat64, 1032541114) \ |
| 57 V(_ByteArrayBase, _setFloat64, ByteArrayBaseSetFloat64, 864506525) \ | |
| 58 V(_Float32Array, _getIndexed, Float32ArrayGetIndexed, 734006846) \ | |
| 59 V(_Float64Array, _getIndexed, Float64ArrayGetIndexed, 498074772) \ | |
| 60 V(_Int8Array, _getIndexed, Int8ArrayGetIndexed, 712069760) \ | |
| 61 V(_Uint8Array, _getIndexed, Uint8ArrayGetIndexed, 535849990) \ | |
| 62 V(_Uint8ClampedArray, _getIndexed, Uint8ClampedArrayGetIndexed, 873344956) \ | |
| 63 V(_ExternalUint8Array, _getIndexed, ExternalUint8ArrayGetIndexed, 402720239) \ | |
| 64 V(_ExternalUint8ClampedArray, _getIndexed, \ | |
| 65 ExternalUint8ClampedArrayGetIndexed, 682839007) \ | |
| 66 V(_Int16Array, _getIndexed, Int16ArrayGetIndexed, 313999108) \ | |
| 67 V(_Uint16Array, _getIndexed, Uint16ArrayGetIndexed, 539701175) \ | |
| 68 V(_Int32Array, _getIndexed, Int32ArrayGetIndexed, 655321526) \ | |
| 69 V(_Uint32Array, _getIndexed, Uint32ArrayGetIndexed, 1060443550) \ | |
| 70 V(_Float32Array, _setIndexed, Float32ArraySetIndexed, 1040992157) \ | |
| 71 V(_Float64Array, _setIndexed, Float64ArraySetIndexed, 330158324) \ | |
| 72 V(_Int8Array, _setIndexed, Int8ArraySetIndexed, 680713569) \ | |
| 73 V(_Uint8Array, _setIndexed, Uint8ArraySetIndexed, 785627791) \ | |
| 74 V(_Uint8ClampedArray, _setIndexed, Uint8ClampedArraySetIndexed, 464766374) \ | |
| 75 V(_ExternalUint8Array, _setIndexed, ExternalUint8ArraySetIndexed, 159706697) \ | |
| 76 V(_ExternalUint8ClampedArray, _setIndexed, \ | |
| 77 ExternalUint8ClampedArraySetIndexed, 335716123) \ | |
| 78 V(_Int16Array, _setIndexed, Int16ArraySetIndexed, 12169534) \ | |
| 79 V(_Uint16Array, _setIndexed, Uint16ArraySetIndexed, 36054302) \ | |
| 80 V(_Int32Array, _setIndexed, Int32ArraySetIndexed, 306194131) \ | |
| 81 V(_Uint32Array, _setIndexed, Uint32ArraySetIndexed, 410753485) \ | |
| 82 V(_GrowableObjectArray, get:length, GrowableArrayLength, 725548050) \ | 57 V(_GrowableObjectArray, get:length, GrowableArrayLength, 725548050) \ |
| 83 V(_GrowableObjectArray, get:_capacity, GrowableArrayCapacity, 725548050) \ | 58 V(_GrowableObjectArray, get:_capacity, GrowableArrayCapacity, 725548050) \ |
| 84 V(_StringBase, get:length, StringBaseLength, 320803993) \ | 59 V(_StringBase, get:length, StringBaseLength, 320803993) \ |
| 85 V(_StringBase, get:isEmpty, StringBaseIsEmpty, 711547329) \ | 60 V(_StringBase, get:isEmpty, StringBaseIsEmpty, 711547329) \ |
| 86 V(_StringBase, codeUnitAt, StringBaseCodeUnitAt, 984449525) \ | 61 V(_StringBase, codeUnitAt, StringBaseCodeUnitAt, 984449525) \ |
| 87 V(_StringBase, [], StringBaseCharAt, 1062366987) \ | 62 V(_StringBase, [], StringBaseCharAt, 1062366987) \ |
| 88 V(_IntegerImplementation, toDouble, IntegerToDouble, 733149324) \ | 63 V(_IntegerImplementation, toDouble, IntegerToDouble, 733149324) \ |
| 89 V(_Double, toInt, DoubleToInteger, 362666636) \ | 64 V(_Double, toInt, DoubleToInteger, 362666636) \ |
| 90 V(_Double, truncateToDouble, DoubleTruncate, 620870996) \ | 65 V(_Double, truncateToDouble, DoubleTruncate, 620870996) \ |
| 91 V(_Double, roundToDouble, DoubleRound, 620870996) \ | 66 V(_Double, roundToDouble, DoubleRound, 620870996) \ |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 Value* next_use_; | 318 Value* next_use_; |
| 344 Instruction* instruction_; | 319 Instruction* instruction_; |
| 345 intptr_t use_index_; | 320 intptr_t use_index_; |
| 346 | 321 |
| 347 CompileType* reaching_type_; | 322 CompileType* reaching_type_; |
| 348 | 323 |
| 349 DISALLOW_COPY_AND_ASSIGN(Value); | 324 DISALLOW_COPY_AND_ASSIGN(Value); |
| 350 }; | 325 }; |
| 351 | 326 |
| 352 | 327 |
| 353 enum Representation { | |
| 354 kTagged, | |
| 355 kUnboxedDouble, | |
| 356 kUnboxedMint | |
| 357 }; | |
| 358 | |
| 359 | |
| 360 // An embedded container with N elements of type T. Used (with partial | 328 // An embedded container with N elements of type T. Used (with partial |
| 361 // specialization for N=0) because embedded arrays cannot have size 0. | 329 // specialization for N=0) because embedded arrays cannot have size 0. |
| 362 template<typename T, intptr_t N> | 330 template<typename T, intptr_t N> |
| 363 class EmbeddedArray { | 331 class EmbeddedArray { |
| 364 public: | 332 public: |
| 365 EmbeddedArray() : elements_() { } | 333 EmbeddedArray() : elements_() { } |
| 366 | 334 |
| 367 intptr_t length() const { return N; } | 335 intptr_t length() const { return N; } |
| 368 | 336 |
| 369 const T& operator[](intptr_t i) const { | 337 const T& operator[](intptr_t i) const { |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 M(LoadStaticField) \ | 414 M(LoadStaticField) \ |
| 447 M(StoreStaticField) \ | 415 M(StoreStaticField) \ |
| 448 M(BooleanNegate) \ | 416 M(BooleanNegate) \ |
| 449 M(InstanceOf) \ | 417 M(InstanceOf) \ |
| 450 M(CreateArray) \ | 418 M(CreateArray) \ |
| 451 M(CreateClosure) \ | 419 M(CreateClosure) \ |
| 452 M(AllocateObject) \ | 420 M(AllocateObject) \ |
| 453 M(AllocateObjectWithBoundsCheck) \ | 421 M(AllocateObjectWithBoundsCheck) \ |
| 454 M(LoadField) \ | 422 M(LoadField) \ |
| 455 M(StoreVMField) \ | 423 M(StoreVMField) \ |
| 424 M(LoadUntagged) \ |
| 456 M(InstantiateTypeArguments) \ | 425 M(InstantiateTypeArguments) \ |
| 457 M(ExtractConstructorTypeArguments) \ | 426 M(ExtractConstructorTypeArguments) \ |
| 458 M(ExtractConstructorInstantiator) \ | 427 M(ExtractConstructorInstantiator) \ |
| 459 M(AllocateContext) \ | 428 M(AllocateContext) \ |
| 460 M(ChainContext) \ | 429 M(ChainContext) \ |
| 461 M(CloneContext) \ | 430 M(CloneContext) \ |
| 462 M(CatchEntry) \ | 431 M(CatchEntry) \ |
| 463 M(BinarySmiOp) \ | 432 M(BinarySmiOp) \ |
| 464 M(UnarySmiOp) \ | 433 M(UnarySmiOp) \ |
| 465 M(CheckStackOverflow) \ | 434 M(CheckStackOverflow) \ |
| (...skipping 2402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2868 intptr_t deopt_id) | 2837 intptr_t deopt_id) |
| 2869 : index_scale_(index_scale), class_id_(class_id) { | 2838 : index_scale_(index_scale), class_id_(class_id) { |
| 2870 SetInputAt(0, array); | 2839 SetInputAt(0, array); |
| 2871 SetInputAt(1, index); | 2840 SetInputAt(1, index); |
| 2872 deopt_id_ = deopt_id; | 2841 deopt_id_ = deopt_id; |
| 2873 } | 2842 } |
| 2874 | 2843 |
| 2875 DECLARE_INSTRUCTION(LoadIndexed) | 2844 DECLARE_INSTRUCTION(LoadIndexed) |
| 2876 virtual CompileType ComputeType() const; | 2845 virtual CompileType ComputeType() const; |
| 2877 | 2846 |
| 2847 virtual Representation RequiredInputRepresentation(intptr_t idx) const { |
| 2848 ASSERT(idx == 0 || idx == 1); |
| 2849 // The array may be tagged or untagged (for external arrays). |
| 2850 if (idx == 0) return kNoRepresentation; |
| 2851 return kTagged; |
| 2852 } |
| 2853 |
| 2854 bool IsExternal() const { |
| 2855 return array()->definition()->representation() == kUntagged; |
| 2856 } |
| 2857 |
| 2878 Value* array() const { return inputs_[0]; } | 2858 Value* array() const { return inputs_[0]; } |
| 2879 Value* index() const { return inputs_[1]; } | 2859 Value* index() const { return inputs_[1]; } |
| 2880 intptr_t index_scale() const { return index_scale_; } | 2860 intptr_t index_scale() const { return index_scale_; } |
| 2881 intptr_t class_id() const { return class_id_; } | 2861 intptr_t class_id() const { return class_id_; } |
| 2882 | 2862 |
| 2883 virtual bool CanDeoptimize() const { | 2863 virtual bool CanDeoptimize() const { |
| 2884 return deopt_id_ != Isolate::kNoDeoptId; | 2864 return deopt_id_ != Isolate::kNoDeoptId; |
| 2885 } | 2865 } |
| 2886 | 2866 |
| 2887 virtual bool HasSideEffect() const { return false; } | 2867 virtual bool HasSideEffect() const { return false; } |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2962 return value()->NeedsStoreBuffer() | 2942 return value()->NeedsStoreBuffer() |
| 2963 && (emit_store_barrier_ == kEmitStoreBarrier); | 2943 && (emit_store_barrier_ == kEmitStoreBarrier); |
| 2964 } | 2944 } |
| 2965 | 2945 |
| 2966 virtual bool CanDeoptimize() const { return false; } | 2946 virtual bool CanDeoptimize() const { return false; } |
| 2967 | 2947 |
| 2968 virtual bool HasSideEffect() const { return true; } | 2948 virtual bool HasSideEffect() const { return true; } |
| 2969 | 2949 |
| 2970 virtual Representation RequiredInputRepresentation(intptr_t idx) const; | 2950 virtual Representation RequiredInputRepresentation(intptr_t idx) const; |
| 2971 | 2951 |
| 2952 bool IsExternal() const { |
| 2953 return array()->definition()->representation() == kUntagged; |
| 2954 } |
| 2955 |
| 2972 virtual intptr_t DeoptimizationTarget() const { | 2956 virtual intptr_t DeoptimizationTarget() const { |
| 2973 // Direct access since this instruction cannot deoptimize, and the deopt-id | 2957 // Direct access since this instruction cannot deoptimize, and the deopt-id |
| 2974 // was inherited from another instruction that could deoptimize. | 2958 // was inherited from another instruction that could deoptimize. |
| 2975 return deopt_id_; | 2959 return deopt_id_; |
| 2976 } | 2960 } |
| 2977 | 2961 |
| 2978 private: | 2962 private: |
| 2979 const StoreBarrierType emit_store_barrier_; | 2963 const StoreBarrierType emit_store_barrier_; |
| 2980 const intptr_t index_scale_; | 2964 const intptr_t index_scale_; |
| 2981 const intptr_t class_id_; | 2965 const intptr_t class_id_; |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3183 | 3167 |
| 3184 private: | 3168 private: |
| 3185 const Function& function_; | 3169 const Function& function_; |
| 3186 ZoneGrowableArray<PushArgumentInstr*>* arguments_; | 3170 ZoneGrowableArray<PushArgumentInstr*>* arguments_; |
| 3187 intptr_t token_pos_; | 3171 intptr_t token_pos_; |
| 3188 | 3172 |
| 3189 DISALLOW_COPY_AND_ASSIGN(CreateClosureInstr); | 3173 DISALLOW_COPY_AND_ASSIGN(CreateClosureInstr); |
| 3190 }; | 3174 }; |
| 3191 | 3175 |
| 3192 | 3176 |
| 3177 class LoadUntaggedInstr : public TemplateDefinition<1> { |
| 3178 public: |
| 3179 explicit LoadUntaggedInstr(Value* object, intptr_t offset) : offset_(offset) { |
| 3180 SetInputAt(0, object); |
| 3181 } |
| 3182 |
| 3183 virtual Representation representation() const { |
| 3184 return kUntagged; |
| 3185 } |
| 3186 DECLARE_INSTRUCTION(LoadUntagged) |
| 3187 virtual CompileType ComputeType() const; |
| 3188 |
| 3189 Value* object() const { return inputs_[0]; } |
| 3190 intptr_t offset() const { return offset_; } |
| 3191 |
| 3192 virtual bool CanDeoptimize() const { return false; } |
| 3193 |
| 3194 virtual bool HasSideEffect() const { return false; } |
| 3195 |
| 3196 virtual bool AttributesEqual(Instruction* other) const { return true; } |
| 3197 |
| 3198 // This instruction must not be moved without the indexed access that |
| 3199 // depends on it (e.g. out of loops). GC may cause collect |
| 3200 // the array while the external data-array is still accessed. |
| 3201 virtual bool AffectedBySideEffect() const { return true; } |
| 3202 |
| 3203 private: |
| 3204 intptr_t offset_; |
| 3205 |
| 3206 DISALLOW_COPY_AND_ASSIGN(LoadUntaggedInstr); |
| 3207 }; |
| 3208 |
| 3209 |
| 3193 class LoadFieldInstr : public TemplateDefinition<1> { | 3210 class LoadFieldInstr : public TemplateDefinition<1> { |
| 3194 public: | 3211 public: |
| 3195 LoadFieldInstr(Value* value, | 3212 LoadFieldInstr(Value* value, |
| 3196 intptr_t offset_in_bytes, | 3213 intptr_t offset_in_bytes, |
| 3197 const AbstractType& type, | 3214 const AbstractType& type, |
| 3198 bool immutable = false) | 3215 bool immutable = false) |
| 3199 : offset_in_bytes_(offset_in_bytes), | 3216 : offset_in_bytes_(offset_in_bytes), |
| 3200 type_(type), | 3217 type_(type), |
| 3201 result_cid_(kDynamicCid), | 3218 result_cid_(kDynamicCid), |
| 3202 immutable_(immutable), | 3219 immutable_(immutable), |
| (...skipping 1331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4534 ForwardInstructionIterator* current_iterator_; | 4551 ForwardInstructionIterator* current_iterator_; |
| 4535 | 4552 |
| 4536 private: | 4553 private: |
| 4537 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); | 4554 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); |
| 4538 }; | 4555 }; |
| 4539 | 4556 |
| 4540 | 4557 |
| 4541 } // namespace dart | 4558 } // namespace dart |
| 4542 | 4559 |
| 4543 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 4560 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
| OLD | NEW |