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

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: addressed comments 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
« no previous file with comments | « runtime/vm/il_printer.cc ('k') | runtime/vm/intermediate_language.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 (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 1235 matching lines...) Expand 10 before | Expand all | Expand 10 after
2219 2221
2220 private: 2222 private:
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) {
2230 : receiver_type_(receiver_type) {
2231 ASSERT(array != NULL); 2232 ASSERT(array != NULL);
2232 ASSERT(index != NULL); 2233 ASSERT(index != NULL);
2233 inputs_[0] = array; 2234 inputs_[0] = array;
2234 inputs_[1] = index; 2235 inputs_[1] = index;
2235 } 2236 }
2236 2237
2237 DECLARE_INSTRUCTION(LoadIndexed) 2238 DECLARE_INSTRUCTION(LoadIndexed)
2238 virtual RawAbstractType* CompileType() const; 2239 virtual RawAbstractType* CompileType() const;
2239 2240
2240 Value* array() const { return inputs_[0]; } 2241 Value* array() const { return inputs_[0]; }
2241 Value* index() const { return inputs_[1]; } 2242 Value* index() const { return inputs_[1]; }
2242 2243
2243 intptr_t receiver_type() const { return receiver_type_; }
2244
2245 virtual bool CanDeoptimize() const { return false; } 2244 virtual bool CanDeoptimize() const { return false; }
2246 virtual intptr_t ResultCid() const { return kDynamicCid; } 2245 virtual intptr_t ResultCid() const { return kDynamicCid; }
2247 2246
2248 private: 2247 private:
2249 intptr_t receiver_type_;
2250
2251 DISALLOW_COPY_AND_ASSIGN(LoadIndexedInstr); 2248 DISALLOW_COPY_AND_ASSIGN(LoadIndexedInstr);
2252 }; 2249 };
2253 2250
2254 2251
2255 class StoreIndexedInstr : public TemplateDefinition<3> { 2252 class StoreIndexedInstr : public TemplateDefinition<3> {
2256 public: 2253 public:
2257 StoreIndexedInstr(Value* array, 2254 StoreIndexedInstr(Value* array, Value* index, Value* value) {
2258 Value* index,
2259 Value* value,
2260 intptr_t receiver_type)
2261 : receiver_type_(receiver_type) {
2262 ASSERT(array != NULL); 2255 ASSERT(array != NULL);
2263 ASSERT(index != NULL); 2256 ASSERT(index != NULL);
2264 ASSERT(value != NULL); 2257 ASSERT(value != NULL);
2265 inputs_[0] = array; 2258 inputs_[0] = array;
2266 inputs_[1] = index; 2259 inputs_[1] = index;
2267 inputs_[2] = value; 2260 inputs_[2] = value;
2268 } 2261 }
2269 2262
2270 DECLARE_INSTRUCTION(StoreIndexed) 2263 DECLARE_INSTRUCTION(StoreIndexed)
2271 virtual RawAbstractType* CompileType() const; 2264 virtual RawAbstractType* CompileType() const;
2272 2265
2273 Value* array() const { return inputs_[0]; } 2266 Value* array() const { return inputs_[0]; }
2274 Value* index() const { return inputs_[1]; } 2267 Value* index() const { return inputs_[1]; }
2275 Value* value() const { return inputs_[2]; } 2268 Value* value() const { return inputs_[2]; }
2276 2269
2277 intptr_t receiver_type() const { return receiver_type_; }
2278
2279 virtual bool CanDeoptimize() const { return false; } 2270 virtual bool CanDeoptimize() const { return false; }
2280 virtual intptr_t ResultCid() const { return kDynamicCid; } 2271 virtual intptr_t ResultCid() const { return kDynamicCid; }
2281 2272
2282 private: 2273 private:
2283 intptr_t receiver_type_;
2284
2285 DISALLOW_COPY_AND_ASSIGN(StoreIndexedInstr); 2274 DISALLOW_COPY_AND_ASSIGN(StoreIndexedInstr);
2286 }; 2275 };
2287 2276
2288 2277
2289 // Note overrideable, built-in: value? false : true. 2278 // Note overrideable, built-in: value? false : true.
2290 class BooleanNegateInstr : public TemplateDefinition<1> { 2279 class BooleanNegateInstr : public TemplateDefinition<1> {
2291 public: 2280 public:
2292 explicit BooleanNegateInstr(Value* value) { 2281 explicit BooleanNegateInstr(Value* value) {
2293 ASSERT(value != NULL); 2282 ASSERT(value != NULL);
2294 inputs_[0] = value; 2283 inputs_[0] = value;
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
2491 ZoneGrowableArray<PushArgumentInstr*>* arguments_; 2480 ZoneGrowableArray<PushArgumentInstr*>* arguments_;
2492 2481
2493 DISALLOW_COPY_AND_ASSIGN(CreateClosureInstr); 2482 DISALLOW_COPY_AND_ASSIGN(CreateClosureInstr);
2494 }; 2483 };
2495 2484
2496 2485
2497 class LoadVMFieldInstr : public TemplateDefinition<1> { 2486 class LoadVMFieldInstr : public TemplateDefinition<1> {
2498 public: 2487 public:
2499 LoadVMFieldInstr(Value* value, 2488 LoadVMFieldInstr(Value* value,
2500 intptr_t offset_in_bytes, 2489 intptr_t offset_in_bytes,
2501 const AbstractType& type) 2490 const AbstractType& type,
2491 bool immutable = false)
2502 : offset_in_bytes_(offset_in_bytes), 2492 : offset_in_bytes_(offset_in_bytes),
2503 type_(type), 2493 type_(type),
2504 result_cid_(kDynamicCid) { 2494 result_cid_(kDynamicCid),
2495 immutable_(immutable) {
2505 ASSERT(value != NULL); 2496 ASSERT(value != NULL);
2506 ASSERT(type.IsZoneHandle()); // May be null if field is not an instance. 2497 ASSERT(type.IsZoneHandle()); // May be null if field is not an instance.
2507 inputs_[0] = value; 2498 inputs_[0] = value;
2508 } 2499 }
2509 2500
2510 DECLARE_INSTRUCTION(LoadVMField) 2501 DECLARE_INSTRUCTION(LoadVMField)
2511 virtual RawAbstractType* CompileType() const; 2502 virtual RawAbstractType* CompileType() const;
2512 2503
2513 Value* value() const { return inputs_[0]; } 2504 Value* value() const { return inputs_[0]; }
2514 intptr_t offset_in_bytes() const { return offset_in_bytes_; } 2505 intptr_t offset_in_bytes() const { return offset_in_bytes_; }
2515 const AbstractType& type() const { return type_; } 2506 const AbstractType& type() const { return type_; }
2516 void set_result_cid(intptr_t value) { result_cid_ = value; } 2507 void set_result_cid(intptr_t value) { result_cid_ = value; }
2517 2508
2518 virtual void PrintOperandsTo(BufferFormatter* f) const; 2509 virtual void PrintOperandsTo(BufferFormatter* f) const;
2519 2510
2520 virtual bool CanDeoptimize() const { return false; } 2511 virtual bool CanDeoptimize() const { return false; }
2521 virtual intptr_t ResultCid() const { return result_cid_; } 2512 virtual intptr_t ResultCid() const { return result_cid_; }
2522 2513
2514 bool AttributesEqual(Definition* other) const;
2515
2516 virtual bool AffectedBySideEffect() const { return !immutable_; }
2517
2523 private: 2518 private:
2524 const intptr_t offset_in_bytes_; 2519 const intptr_t offset_in_bytes_;
2525 const AbstractType& type_; 2520 const AbstractType& type_;
2526 intptr_t result_cid_; 2521 intptr_t result_cid_;
2522 const bool immutable_;
2527 2523
2528 DISALLOW_COPY_AND_ASSIGN(LoadVMFieldInstr); 2524 DISALLOW_COPY_AND_ASSIGN(LoadVMFieldInstr);
2529 }; 2525 };
2530 2526
2531 2527
2532 class StoreVMFieldInstr : public TemplateDefinition<2> { 2528 class StoreVMFieldInstr : public TemplateDefinition<2> {
2533 public: 2529 public:
2534 StoreVMFieldInstr(Value* dest, 2530 StoreVMFieldInstr(Value* dest,
2535 intptr_t offset_in_bytes, 2531 intptr_t offset_in_bytes,
2536 Value* value, 2532 Value* value,
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
2769 } 2765 }
2770 2766
2771 DECLARE_INSTRUCTION(CheckEitherNonSmi) 2767 DECLARE_INSTRUCTION(CheckEitherNonSmi)
2772 virtual RawAbstractType* CompileType() const; 2768 virtual RawAbstractType* CompileType() const;
2773 2769
2774 virtual bool CanDeoptimize() const { return true; } 2770 virtual bool CanDeoptimize() const { return true; }
2775 virtual intptr_t ResultCid() const { return kIllegalCid; } 2771 virtual intptr_t ResultCid() const { return kIllegalCid; }
2776 2772
2777 virtual bool AttributesEqual(Definition* other) const { return true; } 2773 virtual bool AttributesEqual(Definition* other) const { return true; }
2778 2774
2779 virtual bool HasSideEffect() const { return false; } 2775 virtual bool AffectedBySideEffect() const { return false; }
2780 2776
2781 Value* left() const { return inputs_[0]; } 2777 Value* left() const { return inputs_[0]; }
2782 2778
2783 Value* right() const { return inputs_[1]; } 2779 Value* right() const { return inputs_[1]; }
2784 2780
2785 virtual Definition* Canonicalize(); 2781 virtual Definition* Canonicalize();
2786 2782
2787 private: 2783 private:
2788 DISALLOW_COPY_AND_ASSIGN(CheckEitherNonSmiInstr); 2784 DISALLOW_COPY_AND_ASSIGN(CheckEitherNonSmiInstr);
2789 }; 2785 };
2790 2786
2791 2787
2792 class BoxDoubleInstr : public TemplateDefinition<1> { 2788 class BoxDoubleInstr : public TemplateDefinition<1> {
2793 public: 2789 public:
2794 BoxDoubleInstr(Value* value, InstanceCallInstr* instance_call) 2790 BoxDoubleInstr(Value* value, InstanceCallInstr* instance_call)
2795 : token_pos_((instance_call != NULL) ? instance_call->token_pos() : 0) { 2791 : token_pos_((instance_call != NULL) ? instance_call->token_pos() : 0) {
2796 ASSERT(value != NULL); 2792 ASSERT(value != NULL);
2797 inputs_[0] = value; 2793 inputs_[0] = value;
2798 } 2794 }
2799 2795
2800 Value* value() const { return inputs_[0]; } 2796 Value* value() const { return inputs_[0]; }
2801 2797
2802 intptr_t token_pos() const { return token_pos_; } 2798 intptr_t token_pos() const { return token_pos_; }
2803 2799
2804 virtual bool CanDeoptimize() const { return false; } 2800 virtual bool CanDeoptimize() const { return false; }
2805 virtual bool HasSideEffect() const { return false; } 2801 virtual bool AffectedBySideEffect() const { return false; }
2806 virtual bool AttributesEqual(Definition* other) const { return true; } 2802 virtual bool AttributesEqual(Definition* other) const { return true; }
2807 2803
2808 virtual intptr_t ResultCid() const; 2804 virtual intptr_t ResultCid() const;
2809 2805
2810 virtual Representation RequiredInputRepresentation(intptr_t idx) const { 2806 virtual Representation RequiredInputRepresentation(intptr_t idx) const {
2811 ASSERT(idx == 0); 2807 ASSERT(idx == 0);
2812 return kUnboxedDouble; 2808 return kUnboxedDouble;
2813 } 2809 }
2814 2810
2815 DECLARE_INSTRUCTION(BoxDouble) 2811 DECLARE_INSTRUCTION(BoxDouble)
(...skipping 20 matching lines...) Expand all
2836 return value()->ResultCid() != kDoubleCid; 2832 return value()->ResultCid() != kDoubleCid;
2837 } 2833 }
2838 2834
2839 // The output is not an instance but when it is boxed it becomes double. 2835 // The output is not an instance but when it is boxed it becomes double.
2840 virtual intptr_t ResultCid() const { return kDoubleCid; } 2836 virtual intptr_t ResultCid() const { return kDoubleCid; }
2841 2837
2842 virtual Representation representation() const { 2838 virtual Representation representation() const {
2843 return kUnboxedDouble; 2839 return kUnboxedDouble;
2844 } 2840 }
2845 2841
2846 virtual bool HasSideEffect() const { return false; } 2842 virtual bool AffectedBySideEffect() const { return false; }
2847 virtual bool AttributesEqual(Definition* other) const { return true; } 2843 virtual bool AttributesEqual(Definition* other) const { return true; }
2848 2844
2849 DECLARE_INSTRUCTION(UnboxDouble) 2845 DECLARE_INSTRUCTION(UnboxDouble)
2850 virtual RawAbstractType* CompileType() const; 2846 virtual RawAbstractType* CompileType() const;
2851 2847
2852 private: 2848 private:
2853 DISALLOW_COPY_AND_ASSIGN(UnboxDoubleInstr); 2849 DISALLOW_COPY_AND_ASSIGN(UnboxDoubleInstr);
2854 }; 2850 };
2855 2851
2856 2852
(...skipping 12 matching lines...) Expand all
2869 } 2865 }
2870 2866
2871 Value* left() const { return inputs_[0]; } 2867 Value* left() const { return inputs_[0]; }
2872 Value* right() const { return inputs_[1]; } 2868 Value* right() const { return inputs_[1]; }
2873 2869
2874 Token::Kind op_kind() const { return op_kind_; } 2870 Token::Kind op_kind() const { return op_kind_; }
2875 2871
2876 virtual void PrintOperandsTo(BufferFormatter* f) const; 2872 virtual void PrintOperandsTo(BufferFormatter* f) const;
2877 2873
2878 virtual bool CanDeoptimize() const { return false; } 2874 virtual bool CanDeoptimize() const { return false; }
2879 virtual bool HasSideEffect() const { return false; } 2875 virtual bool AffectedBySideEffect() const { return false; }
2880 2876
2881 virtual bool AttributesEqual(Definition* other) const { 2877 virtual bool AttributesEqual(Definition* other) const {
2882 return op_kind() == other->AsUnboxedDoubleBinaryOp()->op_kind(); 2878 return op_kind() == other->AsUnboxedDoubleBinaryOp()->op_kind();
2883 } 2879 }
2884 2880
2885 // The output is not an instance but when it is boxed it becomes double. 2881 // The output is not an instance but when it is boxed it becomes double.
2886 virtual intptr_t ResultCid() const { return kDoubleCid; } 2882 virtual intptr_t ResultCid() const { return kDoubleCid; }
2887 2883
2888 virtual Representation representation() const { 2884 virtual Representation representation() const {
2889 return kUnboxedDouble; 2885 return kUnboxedDouble;
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
3129 } 3125 }
3130 3126
3131 DECLARE_INSTRUCTION(CheckClass) 3127 DECLARE_INSTRUCTION(CheckClass)
3132 virtual RawAbstractType* CompileType() const; 3128 virtual RawAbstractType* CompileType() const;
3133 3129
3134 virtual bool CanDeoptimize() const { return true; } 3130 virtual bool CanDeoptimize() const { return true; }
3135 virtual intptr_t ResultCid() const { return kIllegalCid; } 3131 virtual intptr_t ResultCid() const { return kIllegalCid; }
3136 3132
3137 virtual bool AttributesEqual(Definition* other) const; 3133 virtual bool AttributesEqual(Definition* other) const;
3138 3134
3139 virtual bool HasSideEffect() const { return false; } 3135 virtual bool AffectedBySideEffect() const { return false; }
3140 3136
3141 Value* value() const { return inputs_[0]; } 3137 Value* value() const { return inputs_[0]; }
3142 3138
3143 const ICData& unary_checks() const { return unary_checks_; } 3139 const ICData& unary_checks() const { return unary_checks_; }
3144 3140
3145 virtual Definition* Canonicalize(); 3141 virtual Definition* Canonicalize();
3146 3142
3147 virtual void PrintOperandsTo(BufferFormatter* f) const; 3143 virtual void PrintOperandsTo(BufferFormatter* f) const;
3148 3144
3149 private: 3145 private:
(...skipping 13 matching lines...) Expand all
3163 } 3159 }
3164 3160
3165 DECLARE_INSTRUCTION(CheckSmi) 3161 DECLARE_INSTRUCTION(CheckSmi)
3166 virtual RawAbstractType* CompileType() const; 3162 virtual RawAbstractType* CompileType() const;
3167 3163
3168 virtual bool CanDeoptimize() const { return true; } 3164 virtual bool CanDeoptimize() const { return true; }
3169 virtual intptr_t ResultCid() const { return kIllegalCid; } 3165 virtual intptr_t ResultCid() const { return kIllegalCid; }
3170 3166
3171 virtual bool AttributesEqual(Definition* other) const { return true; } 3167 virtual bool AttributesEqual(Definition* other) const { return true; }
3172 3168
3173 virtual bool HasSideEffect() const { return false; } 3169 virtual bool AffectedBySideEffect() const { return false; }
3174 3170
3175 virtual Definition* Canonicalize(); 3171 virtual Definition* Canonicalize();
3176 3172
3177 Value* value() const { return inputs_[0]; } 3173 Value* value() const { return inputs_[0]; }
3178 3174
3179 private: 3175 private:
3180 DISALLOW_COPY_AND_ASSIGN(CheckSmiInstr); 3176 DISALLOW_COPY_AND_ASSIGN(CheckSmiInstr);
3181 }; 3177 };
3182 3178
3183 3179
(...skipping 12 matching lines...) Expand all
3196 } 3192 }
3197 3193
3198 DECLARE_INSTRUCTION(CheckArrayBound) 3194 DECLARE_INSTRUCTION(CheckArrayBound)
3199 virtual RawAbstractType* CompileType() const; 3195 virtual RawAbstractType* CompileType() const;
3200 3196
3201 virtual bool CanDeoptimize() const { return true; } 3197 virtual bool CanDeoptimize() const { return true; }
3202 virtual intptr_t ResultCid() const { return kIllegalCid; } 3198 virtual intptr_t ResultCid() const { return kIllegalCid; }
3203 3199
3204 virtual bool AttributesEqual(Definition* other) const; 3200 virtual bool AttributesEqual(Definition* other) const;
3205 3201
3206 virtual bool HasSideEffect() const { return false; } 3202 virtual bool AffectedBySideEffect() const { return false; }
3207 3203
3208 Value* array() const { return inputs_[0]; } 3204 Value* array() const { return inputs_[0]; }
3209 Value* index() const { return inputs_[1]; } 3205 Value* index() const { return inputs_[1]; }
3210 3206
3211 intptr_t array_type() const { return array_type_; } 3207 intptr_t array_type() const { return array_type_; }
3212 3208
3213 private: 3209 private:
3214 intptr_t array_type_; 3210 intptr_t array_type_;
3215 3211
3216 DISALLOW_COPY_AND_ASSIGN(CheckArrayBoundInstr); 3212 DISALLOW_COPY_AND_ASSIGN(CheckArrayBoundInstr);
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
3398 ForwardInstructionIterator* current_iterator_; 3394 ForwardInstructionIterator* current_iterator_;
3399 3395
3400 private: 3396 private:
3401 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); 3397 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor);
3402 }; 3398 };
3403 3399
3404 3400
3405 } // namespace dart 3401 } // namespace dart
3406 3402
3407 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 3403 #endif // VM_INTERMEDIATE_LANGUAGE_H_
OLDNEW
« no previous file with comments | « runtime/vm/il_printer.cc ('k') | runtime/vm/intermediate_language.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698