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

Side by Side Diff: runtime/vm/intermediate_language.h

Issue 10911214: Split array loads/stores for growable arrays into two IL instructions. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 949 matching lines...) Expand 10 before | Expand all | Expand 10 after
960 960
961 bool has_propagated_cid() const { return propagated_cid_ != kIllegalCid; } 961 bool has_propagated_cid() const { return propagated_cid_ != kIllegalCid; }
962 intptr_t propagated_cid() const { return propagated_cid_; } 962 intptr_t propagated_cid() const { return propagated_cid_; }
963 963
964 // May compute and set propagated cid. 964 // May compute and set propagated cid.
965 virtual intptr_t GetPropagatedCid(); 965 virtual intptr_t GetPropagatedCid();
966 966
967 // Returns true if the propagated cid has changed. 967 // Returns true if the propagated cid has changed.
968 bool SetPropagatedCid(intptr_t cid); 968 bool SetPropagatedCid(intptr_t cid);
969 969
970 // Returns true if the definition may have side effects. 970 // Returns true if the definition is affected by side effects.
971 // Only instructions that are not affected by side effects can participate
972 // in redundancy elimination or loop invariant code motion.
971 // TODO(fschneider): Make this abstract and implement for all definitions 973 // TODO(fschneider): Make this abstract and implement for all definitions
972 // instead of returning the safe default (true). 974 // instead of returning the safe default (true).
973 virtual bool HasSideEffect() const { return true; } 975 virtual bool AffectedBySideEffect() const { return true; }
974 976
975 Value* input_use_list() { return input_use_list_; } 977 Value* input_use_list() { return input_use_list_; }
976 void set_input_use_list(Value* head) { input_use_list_ = head; } 978 void set_input_use_list(Value* head) { input_use_list_ = head; }
977 979
978 Value* env_use_list() { return env_use_list_; } 980 Value* env_use_list() { return env_use_list_; }
979 void set_env_use_list(Value* head) { env_use_list_ = head; } 981 void set_env_use_list(Value* head) { env_use_list_ = head; }
980 982
981 // Returns a replacement for the definition or NULL if the definition can 983 // Returns a replacement for the definition or NULL if the definition can
982 // be eliminated. By default returns the definition (input parameter) 984 // be eliminated. By default returns the definition (input parameter)
983 // which means no change. 985 // which means no change.
(...skipping 1237 matching lines...) Expand 10 before | Expand all | Expand 10 after
2221 const Field& field_; 2223 const Field& field_;
2222 2224
2223 DISALLOW_COPY_AND_ASSIGN(StoreStaticFieldInstr); 2225 DISALLOW_COPY_AND_ASSIGN(StoreStaticFieldInstr);
2224 }; 2226 };
2225 2227
2226 2228
2227 class LoadIndexedInstr : public TemplateDefinition<2> { 2229 class LoadIndexedInstr : public TemplateDefinition<2> {
2228 public: 2230 public:
2229 LoadIndexedInstr(Value* array, Value* index, intptr_t receiver_type) 2231 LoadIndexedInstr(Value* array, Value* index, intptr_t receiver_type)
2230 : receiver_type_(receiver_type) { 2232 : receiver_type_(receiver_type) {
2233 ASSERT(receiver_type == kArrayCid ||
2234 receiver_type == kImmutableArrayCid ||
2235 receiver_type == kGrowableObjectArrayCid);
2231 ASSERT(array != NULL); 2236 ASSERT(array != NULL);
2232 ASSERT(index != NULL); 2237 ASSERT(index != NULL);
2233 inputs_[0] = array; 2238 inputs_[0] = array;
2234 inputs_[1] = index; 2239 inputs_[1] = index;
2235 } 2240 }
2236 2241
2237 DECLARE_INSTRUCTION(LoadIndexed) 2242 DECLARE_INSTRUCTION(LoadIndexed)
2238 virtual RawAbstractType* CompileType() const; 2243 virtual RawAbstractType* CompileType() const;
2239 2244
2240 Value* array() const { return inputs_[0]; } 2245 Value* array() const { return inputs_[0]; }
(...skipping 11 matching lines...) Expand all
2252 }; 2257 };
2253 2258
2254 2259
2255 class StoreIndexedInstr : public TemplateDefinition<3> { 2260 class StoreIndexedInstr : public TemplateDefinition<3> {
2256 public: 2261 public:
2257 StoreIndexedInstr(Value* array, 2262 StoreIndexedInstr(Value* array,
2258 Value* index, 2263 Value* index,
2259 Value* value, 2264 Value* value,
2260 intptr_t receiver_type) 2265 intptr_t receiver_type)
2261 : receiver_type_(receiver_type) { 2266 : receiver_type_(receiver_type) {
2267 ASSERT(receiver_type == kArrayCid ||
2268 receiver_type == kImmutableArrayCid ||
2269 receiver_type == kGrowableObjectArrayCid);
2262 ASSERT(array != NULL); 2270 ASSERT(array != NULL);
2263 ASSERT(index != NULL); 2271 ASSERT(index != NULL);
2264 ASSERT(value != NULL); 2272 ASSERT(value != NULL);
2265 inputs_[0] = array; 2273 inputs_[0] = array;
2266 inputs_[1] = index; 2274 inputs_[1] = index;
2267 inputs_[2] = value; 2275 inputs_[2] = value;
2268 } 2276 }
2269 2277
2270 DECLARE_INSTRUCTION(StoreIndexed) 2278 DECLARE_INSTRUCTION(StoreIndexed)
2271 virtual RawAbstractType* CompileType() const; 2279 virtual RawAbstractType* CompileType() const;
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
2491 ZoneGrowableArray<PushArgumentInstr*>* arguments_; 2499 ZoneGrowableArray<PushArgumentInstr*>* arguments_;
2492 2500
2493 DISALLOW_COPY_AND_ASSIGN(CreateClosureInstr); 2501 DISALLOW_COPY_AND_ASSIGN(CreateClosureInstr);
2494 }; 2502 };
2495 2503
2496 2504
2497 class LoadVMFieldInstr : public TemplateDefinition<1> { 2505 class LoadVMFieldInstr : public TemplateDefinition<1> {
2498 public: 2506 public:
2499 LoadVMFieldInstr(Value* value, 2507 LoadVMFieldInstr(Value* value,
2500 intptr_t offset_in_bytes, 2508 intptr_t offset_in_bytes,
2501 const AbstractType& type) 2509 const AbstractType& type,
2510 bool immutable = false)
srdjan 2012/09/12 07:06:40 I think setting immutable_ via a setter (similar t
Florian Schneider 2012/09/12 08:27:29 Done. Making it const for now.
2502 : offset_in_bytes_(offset_in_bytes), 2511 : offset_in_bytes_(offset_in_bytes),
2503 type_(type), 2512 type_(type),
2504 result_cid_(kDynamicCid) { 2513 result_cid_(kDynamicCid),
2514 immutable_(immutable) {
2505 ASSERT(value != NULL); 2515 ASSERT(value != NULL);
2506 ASSERT(type.IsZoneHandle()); // May be null if field is not an instance. 2516 ASSERT(type.IsZoneHandle()); // May be null if field is not an instance.
2507 inputs_[0] = value; 2517 inputs_[0] = value;
2508 } 2518 }
2509 2519
2510 DECLARE_INSTRUCTION(LoadVMField) 2520 DECLARE_INSTRUCTION(LoadVMField)
2511 virtual RawAbstractType* CompileType() const; 2521 virtual RawAbstractType* CompileType() const;
2512 2522
2513 Value* value() const { return inputs_[0]; } 2523 Value* value() const { return inputs_[0]; }
2514 intptr_t offset_in_bytes() const { return offset_in_bytes_; } 2524 intptr_t offset_in_bytes() const { return offset_in_bytes_; }
2515 const AbstractType& type() const { return type_; } 2525 const AbstractType& type() const { return type_; }
2516 void set_result_cid(intptr_t value) { result_cid_ = value; } 2526 void set_result_cid(intptr_t value) { result_cid_ = value; }
2517 2527
2518 virtual void PrintOperandsTo(BufferFormatter* f) const; 2528 virtual void PrintOperandsTo(BufferFormatter* f) const;
2519 2529
2520 virtual bool CanDeoptimize() const { return false; } 2530 virtual bool CanDeoptimize() const { return false; }
2521 virtual intptr_t ResultCid() const { return result_cid_; } 2531 virtual intptr_t ResultCid() const { return result_cid_; }
2522 2532
2533 bool AttributesEqual(Definition* other) const;
2534
2535 virtual bool AffectedBySideEffect() const { return !immutable_; }
2536
2523 private: 2537 private:
2524 const intptr_t offset_in_bytes_; 2538 const intptr_t offset_in_bytes_;
2525 const AbstractType& type_; 2539 const AbstractType& type_;
2526 intptr_t result_cid_; 2540 intptr_t result_cid_;
2541 bool immutable_;
2527 2542
2528 DISALLOW_COPY_AND_ASSIGN(LoadVMFieldInstr); 2543 DISALLOW_COPY_AND_ASSIGN(LoadVMFieldInstr);
2529 }; 2544 };
2530 2545
2531 2546
2532 class StoreVMFieldInstr : public TemplateDefinition<2> { 2547 class StoreVMFieldInstr : public TemplateDefinition<2> {
2533 public: 2548 public:
2534 StoreVMFieldInstr(Value* dest, 2549 StoreVMFieldInstr(Value* dest,
2535 intptr_t offset_in_bytes, 2550 intptr_t offset_in_bytes,
2536 Value* value, 2551 Value* value,
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
2769 } 2784 }
2770 2785
2771 DECLARE_INSTRUCTION(CheckEitherNonSmi) 2786 DECLARE_INSTRUCTION(CheckEitherNonSmi)
2772 virtual RawAbstractType* CompileType() const; 2787 virtual RawAbstractType* CompileType() const;
2773 2788
2774 virtual bool CanDeoptimize() const { return true; } 2789 virtual bool CanDeoptimize() const { return true; }
2775 virtual intptr_t ResultCid() const { return kIllegalCid; } 2790 virtual intptr_t ResultCid() const { return kIllegalCid; }
2776 2791
2777 virtual bool AttributesEqual(Definition* other) const { return true; } 2792 virtual bool AttributesEqual(Definition* other) const { return true; }
2778 2793
2779 virtual bool HasSideEffect() const { return false; } 2794 virtual bool AffectedBySideEffect() const { return false; }
2780 2795
2781 Value* left() const { return inputs_[0]; } 2796 Value* left() const { return inputs_[0]; }
2782 2797
2783 Value* right() const { return inputs_[1]; } 2798 Value* right() const { return inputs_[1]; }
2784 2799
2785 virtual Definition* Canonicalize(); 2800 virtual Definition* Canonicalize();
2786 2801
2787 private: 2802 private:
2788 DISALLOW_COPY_AND_ASSIGN(CheckEitherNonSmiInstr); 2803 DISALLOW_COPY_AND_ASSIGN(CheckEitherNonSmiInstr);
2789 }; 2804 };
2790 2805
2791 2806
2792 class BoxDoubleInstr : public TemplateDefinition<1> { 2807 class BoxDoubleInstr : public TemplateDefinition<1> {
2793 public: 2808 public:
2794 BoxDoubleInstr(Value* value, InstanceCallInstr* instance_call) 2809 BoxDoubleInstr(Value* value, InstanceCallInstr* instance_call)
2795 : token_pos_((instance_call != NULL) ? instance_call->token_pos() : 0) { 2810 : token_pos_((instance_call != NULL) ? instance_call->token_pos() : 0) {
2796 ASSERT(value != NULL); 2811 ASSERT(value != NULL);
2797 inputs_[0] = value; 2812 inputs_[0] = value;
2798 } 2813 }
2799 2814
2800 Value* value() const { return inputs_[0]; } 2815 Value* value() const { return inputs_[0]; }
2801 2816
2802 intptr_t token_pos() const { return token_pos_; } 2817 intptr_t token_pos() const { return token_pos_; }
2803 2818
2804 virtual bool CanDeoptimize() const { return false; } 2819 virtual bool CanDeoptimize() const { return false; }
2805 virtual bool HasSideEffect() const { return false; } 2820 virtual bool AffectedBySideEffect() const { return false; }
2806 virtual bool AttributesEqual(Definition* other) const { return true; } 2821 virtual bool AttributesEqual(Definition* other) const { return true; }
2807 2822
2808 virtual intptr_t ResultCid() const; 2823 virtual intptr_t ResultCid() const;
2809 2824
2810 virtual Representation RequiredInputRepresentation(intptr_t idx) const { 2825 virtual Representation RequiredInputRepresentation(intptr_t idx) const {
2811 ASSERT(idx == 0); 2826 ASSERT(idx == 0);
2812 return kUnboxedDouble; 2827 return kUnboxedDouble;
2813 } 2828 }
2814 2829
2815 DECLARE_INSTRUCTION(BoxDouble) 2830 DECLARE_INSTRUCTION(BoxDouble)
(...skipping 20 matching lines...) Expand all
2836 return value()->ResultCid() != kDoubleCid; 2851 return value()->ResultCid() != kDoubleCid;
2837 } 2852 }
2838 2853
2839 // The output is not an instance but when it is boxed it becomes double. 2854 // The output is not an instance but when it is boxed it becomes double.
2840 virtual intptr_t ResultCid() const { return kDoubleCid; } 2855 virtual intptr_t ResultCid() const { return kDoubleCid; }
2841 2856
2842 virtual Representation representation() const { 2857 virtual Representation representation() const {
2843 return kUnboxedDouble; 2858 return kUnboxedDouble;
2844 } 2859 }
2845 2860
2846 virtual bool HasSideEffect() const { return false; } 2861 virtual bool AffectedBySideEffect() const { return false; }
2847 virtual bool AttributesEqual(Definition* other) const { return true; } 2862 virtual bool AttributesEqual(Definition* other) const { return true; }
2848 2863
2849 DECLARE_INSTRUCTION(UnboxDouble) 2864 DECLARE_INSTRUCTION(UnboxDouble)
2850 virtual RawAbstractType* CompileType() const; 2865 virtual RawAbstractType* CompileType() const;
2851 2866
2852 private: 2867 private:
2853 DISALLOW_COPY_AND_ASSIGN(UnboxDoubleInstr); 2868 DISALLOW_COPY_AND_ASSIGN(UnboxDoubleInstr);
2854 }; 2869 };
2855 2870
2856 2871
(...skipping 12 matching lines...) Expand all
2869 } 2884 }
2870 2885
2871 Value* left() const { return inputs_[0]; } 2886 Value* left() const { return inputs_[0]; }
2872 Value* right() const { return inputs_[1]; } 2887 Value* right() const { return inputs_[1]; }
2873 2888
2874 Token::Kind op_kind() const { return op_kind_; } 2889 Token::Kind op_kind() const { return op_kind_; }
2875 2890
2876 virtual void PrintOperandsTo(BufferFormatter* f) const; 2891 virtual void PrintOperandsTo(BufferFormatter* f) const;
2877 2892
2878 virtual bool CanDeoptimize() const { return false; } 2893 virtual bool CanDeoptimize() const { return false; }
2879 virtual bool HasSideEffect() const { return false; } 2894 virtual bool AffectedBySideEffect() const { return false; }
2880 2895
2881 virtual bool AttributesEqual(Definition* other) const { 2896 virtual bool AttributesEqual(Definition* other) const {
2882 return op_kind() == other->AsUnboxedDoubleBinaryOp()->op_kind(); 2897 return op_kind() == other->AsUnboxedDoubleBinaryOp()->op_kind();
2883 } 2898 }
2884 2899
2885 // The output is not an instance but when it is boxed it becomes double. 2900 // The output is not an instance but when it is boxed it becomes double.
2886 virtual intptr_t ResultCid() const { return kDoubleCid; } 2901 virtual intptr_t ResultCid() const { return kDoubleCid; }
2887 2902
2888 virtual Representation representation() const { 2903 virtual Representation representation() const {
2889 return kUnboxedDouble; 2904 return kUnboxedDouble;
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
3129 } 3144 }
3130 3145
3131 DECLARE_INSTRUCTION(CheckClass) 3146 DECLARE_INSTRUCTION(CheckClass)
3132 virtual RawAbstractType* CompileType() const; 3147 virtual RawAbstractType* CompileType() const;
3133 3148
3134 virtual bool CanDeoptimize() const { return true; } 3149 virtual bool CanDeoptimize() const { return true; }
3135 virtual intptr_t ResultCid() const { return kIllegalCid; } 3150 virtual intptr_t ResultCid() const { return kIllegalCid; }
3136 3151
3137 virtual bool AttributesEqual(Definition* other) const; 3152 virtual bool AttributesEqual(Definition* other) const;
3138 3153
3139 virtual bool HasSideEffect() const { return false; } 3154 virtual bool AffectedBySideEffect() const { return false; }
3140 3155
3141 Value* value() const { return inputs_[0]; } 3156 Value* value() const { return inputs_[0]; }
3142 3157
3143 const ICData& unary_checks() const { return unary_checks_; } 3158 const ICData& unary_checks() const { return unary_checks_; }
3144 3159
3145 virtual Definition* Canonicalize(); 3160 virtual Definition* Canonicalize();
3146 3161
3147 virtual void PrintOperandsTo(BufferFormatter* f) const; 3162 virtual void PrintOperandsTo(BufferFormatter* f) const;
3148 3163
3149 private: 3164 private:
(...skipping 13 matching lines...) Expand all
3163 } 3178 }
3164 3179
3165 DECLARE_INSTRUCTION(CheckSmi) 3180 DECLARE_INSTRUCTION(CheckSmi)
3166 virtual RawAbstractType* CompileType() const; 3181 virtual RawAbstractType* CompileType() const;
3167 3182
3168 virtual bool CanDeoptimize() const { return true; } 3183 virtual bool CanDeoptimize() const { return true; }
3169 virtual intptr_t ResultCid() const { return kIllegalCid; } 3184 virtual intptr_t ResultCid() const { return kIllegalCid; }
3170 3185
3171 virtual bool AttributesEqual(Definition* other) const { return true; } 3186 virtual bool AttributesEqual(Definition* other) const { return true; }
3172 3187
3173 virtual bool HasSideEffect() const { return false; } 3188 virtual bool AffectedBySideEffect() const { return false; }
3174 3189
3175 virtual Definition* Canonicalize(); 3190 virtual Definition* Canonicalize();
3176 3191
3177 Value* value() const { return inputs_[0]; } 3192 Value* value() const { return inputs_[0]; }
3178 3193
3179 private: 3194 private:
3180 DISALLOW_COPY_AND_ASSIGN(CheckSmiInstr); 3195 DISALLOW_COPY_AND_ASSIGN(CheckSmiInstr);
3181 }; 3196 };
3182 3197
3183 3198
(...skipping 12 matching lines...) Expand all
3196 } 3211 }
3197 3212
3198 DECLARE_INSTRUCTION(CheckArrayBound) 3213 DECLARE_INSTRUCTION(CheckArrayBound)
3199 virtual RawAbstractType* CompileType() const; 3214 virtual RawAbstractType* CompileType() const;
3200 3215
3201 virtual bool CanDeoptimize() const { return true; } 3216 virtual bool CanDeoptimize() const { return true; }
3202 virtual intptr_t ResultCid() const { return kIllegalCid; } 3217 virtual intptr_t ResultCid() const { return kIllegalCid; }
3203 3218
3204 virtual bool AttributesEqual(Definition* other) const; 3219 virtual bool AttributesEqual(Definition* other) const;
3205 3220
3206 virtual bool HasSideEffect() const { return false; } 3221 virtual bool AffectedBySideEffect() const { return false; }
3207 3222
3208 Value* array() const { return inputs_[0]; } 3223 Value* array() const { return inputs_[0]; }
3209 Value* index() const { return inputs_[1]; } 3224 Value* index() const { return inputs_[1]; }
3210 3225
3211 intptr_t array_type() const { return array_type_; } 3226 intptr_t array_type() const { return array_type_; }
3212 3227
3213 private: 3228 private:
3214 intptr_t array_type_; 3229 intptr_t array_type_;
3215 3230
3216 DISALLOW_COPY_AND_ASSIGN(CheckArrayBoundInstr); 3231 DISALLOW_COPY_AND_ASSIGN(CheckArrayBoundInstr);
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
3398 ForwardInstructionIterator* current_iterator_; 3413 ForwardInstructionIterator* current_iterator_;
3399 3414
3400 private: 3415 private:
3401 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); 3416 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor);
3402 }; 3417 };
3403 3418
3404 3419
3405 } // namespace dart 3420 } // namespace dart
3406 3421
3407 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 3422 #endif // VM_INTERMEDIATE_LANGUAGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698