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

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

Issue 12212093: Convert some compiler passes to preserve valid def-use chains. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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) 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 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 virtual Value* InputAt(intptr_t i) const = 0; 359 virtual Value* InputAt(intptr_t i) const = 0;
360 virtual void SetInputAt(intptr_t i, Value* value) = 0; 360 virtual void SetInputAt(intptr_t i, Value* value) = 0;
361 361
362 // Remove all inputs (including in the environment) from their 362 // Remove all inputs (including in the environment) from their
363 // definition's use lists. 363 // definition's use lists.
364 void UnuseAllInputs(); 364 void UnuseAllInputs();
365 365
366 // Call instructions override this function and return the number of 366 // Call instructions override this function and return the number of
367 // pushed arguments. 367 // pushed arguments.
368 virtual intptr_t ArgumentCount() const = 0; 368 virtual intptr_t ArgumentCount() const = 0;
369 virtual PushArgumentInstr* ArgumentAt(intptr_t index) const { 369 virtual PushArgumentInstr* PushArgumentAt(intptr_t index) const {
370 UNREACHABLE(); 370 UNREACHABLE();
371 return NULL; 371 return NULL;
372 }; 372 }
373 inline Definition* ArgumentAt(intptr_t index) const;
Vyacheslav Egorov (Google) 2013/02/08 16:44:49 I like the naming cleanup.
373 374
374 // Returns true, if this instruction can deoptimize. 375 // Returns true, if this instruction can deoptimize.
375 virtual bool CanDeoptimize() const = 0; 376 virtual bool CanDeoptimize() const = 0;
376 377
377 // Returns true if the instruction may have side effects. 378 // Returns true if the instruction may have side effects.
378 virtual bool HasSideEffect() const = 0; 379 virtual bool HasSideEffect() const = 0;
379 380
380 // Visiting support. 381 // Visiting support.
381 virtual void Accept(FlowGraphVisitor* visitor) = 0; 382 virtual void Accept(FlowGraphVisitor* visitor) = 0;
382 383
(...skipping 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after
1401 virtual void PrintOperandsTo(BufferFormatter* f) const; 1402 virtual void PrintOperandsTo(BufferFormatter* f) const;
1402 1403
1403 private: 1404 private:
1404 Value* value_; 1405 Value* value_;
1405 LocationSummary* locs_; 1406 LocationSummary* locs_;
1406 1407
1407 DISALLOW_COPY_AND_ASSIGN(PushArgumentInstr); 1408 DISALLOW_COPY_AND_ASSIGN(PushArgumentInstr);
1408 }; 1409 };
1409 1410
1410 1411
1412 inline Definition* Instruction::ArgumentAt(intptr_t index) const {
1413 return PushArgumentAt(index)->value()->definition();
1414 }
1415
1416
1411 class ReturnInstr : public TemplateInstruction<1> { 1417 class ReturnInstr : public TemplateInstruction<1> {
1412 public: 1418 public:
1413 ReturnInstr(intptr_t token_pos, Value* value) 1419 ReturnInstr(intptr_t token_pos, Value* value)
1414 : token_pos_(token_pos) { 1420 : token_pos_(token_pos) {
1415 ASSERT(value != NULL); 1421 ASSERT(value != NULL);
1416 inputs_[0] = value; 1422 inputs_[0] = value;
1417 } 1423 }
1418 1424
1419 DECLARE_INSTRUCTION(Return) 1425 DECLARE_INSTRUCTION(Return)
1420 1426
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
2068 : ast_node_(*node), 2074 : ast_node_(*node),
2069 arguments_(arguments) { } 2075 arguments_(arguments) { }
2070 2076
2071 DECLARE_INSTRUCTION(ClosureCall) 2077 DECLARE_INSTRUCTION(ClosureCall)
2072 virtual RawAbstractType* CompileType() const; 2078 virtual RawAbstractType* CompileType() const;
2073 2079
2074 const Array& argument_names() const { return ast_node_.arguments()->names(); } 2080 const Array& argument_names() const { return ast_node_.arguments()->names(); }
2075 intptr_t token_pos() const { return ast_node_.token_pos(); } 2081 intptr_t token_pos() const { return ast_node_.token_pos(); }
2076 2082
2077 virtual intptr_t ArgumentCount() const { return arguments_->length(); } 2083 virtual intptr_t ArgumentCount() const { return arguments_->length(); }
2078 PushArgumentInstr* ArgumentAt(intptr_t index) const { 2084 virtual PushArgumentInstr* PushArgumentAt(intptr_t index) const {
2079 return (*arguments_)[index]; 2085 return (*arguments_)[index];
2080 } 2086 }
2081 2087
2082 virtual void PrintOperandsTo(BufferFormatter* f) const; 2088 virtual void PrintOperandsTo(BufferFormatter* f) const;
2083 2089
2084 virtual bool CanDeoptimize() const { return true; } 2090 virtual bool CanDeoptimize() const { return true; }
2085 2091
2086 virtual bool HasSideEffect() const { return true; } 2092 virtual bool HasSideEffect() const { return true; }
2087 2093
2088 virtual intptr_t ResultCid() const { return kDynamicCid; } 2094 virtual intptr_t ResultCid() const { return kDynamicCid; }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
2130 return (ic_data() != NULL) && !ic_data()->IsNull(); 2136 return (ic_data() != NULL) && !ic_data()->IsNull();
2131 } 2137 }
2132 2138
2133 // ICData can be replaced by optimizer. 2139 // ICData can be replaced by optimizer.
2134 void set_ic_data(const ICData* value) { ic_data_ = value; } 2140 void set_ic_data(const ICData* value) { ic_data_ = value; }
2135 2141
2136 intptr_t token_pos() const { return token_pos_; } 2142 intptr_t token_pos() const { return token_pos_; }
2137 const String& function_name() const { return function_name_; } 2143 const String& function_name() const { return function_name_; }
2138 Token::Kind token_kind() const { return token_kind_; } 2144 Token::Kind token_kind() const { return token_kind_; }
2139 virtual intptr_t ArgumentCount() const { return arguments_->length(); } 2145 virtual intptr_t ArgumentCount() const { return arguments_->length(); }
2140 PushArgumentInstr* ArgumentAt(intptr_t index) const { 2146 virtual PushArgumentInstr* PushArgumentAt(intptr_t index) const {
2141 return (*arguments_)[index]; 2147 return (*arguments_)[index];
2142 } 2148 }
2143 const Array& argument_names() const { return argument_names_; } 2149 const Array& argument_names() const { return argument_names_; }
2144 intptr_t checked_argument_count() const { return checked_argument_count_; } 2150 intptr_t checked_argument_count() const { return checked_argument_count_; }
2145 2151
2146 virtual void PrintOperandsTo(BufferFormatter* f) const; 2152 virtual void PrintOperandsTo(BufferFormatter* f) const;
2147 2153
2148 virtual bool CanDeoptimize() const { return true; } 2154 virtual bool CanDeoptimize() const { return true; }
2149 2155
2150 virtual bool HasSideEffect() const { return true; } 2156 virtual bool HasSideEffect() const { return true; }
(...skipping 27 matching lines...) Expand all
2178 with_checks_(with_checks) { 2184 with_checks_(with_checks) {
2179 ASSERT(instance_call_ != NULL); 2185 ASSERT(instance_call_ != NULL);
2180 } 2186 }
2181 2187
2182 InstanceCallInstr* instance_call() const { return instance_call_; } 2188 InstanceCallInstr* instance_call() const { return instance_call_; }
2183 bool with_checks() const { return with_checks_; } 2189 bool with_checks() const { return with_checks_; }
2184 2190
2185 virtual intptr_t ArgumentCount() const { 2191 virtual intptr_t ArgumentCount() const {
2186 return instance_call()->ArgumentCount(); 2192 return instance_call()->ArgumentCount();
2187 } 2193 }
2188 PushArgumentInstr* ArgumentAt(intptr_t index) const { 2194 virtual PushArgumentInstr* PushArgumentAt(intptr_t index) const {
2189 return instance_call()->ArgumentAt(index); 2195 return instance_call()->PushArgumentAt(index);
2190 } 2196 }
2191 2197
2192 DECLARE_INSTRUCTION(PolymorphicInstanceCall) 2198 DECLARE_INSTRUCTION(PolymorphicInstanceCall)
2193 virtual RawAbstractType* CompileType() const; 2199 virtual RawAbstractType* CompileType() const;
2194 2200
2195 const ICData& ic_data() const { return ic_data_; } 2201 const ICData& ic_data() const { return ic_data_; }
2196 2202
2197 virtual bool CanDeoptimize() const { return true; } 2203 virtual bool CanDeoptimize() const { return true; }
2198 2204
2199 virtual bool HasSideEffect() const { return true; } 2205 virtual bool HasSideEffect() const { return true; }
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
2483 2489
2484 DECLARE_INSTRUCTION(StaticCall) 2490 DECLARE_INSTRUCTION(StaticCall)
2485 virtual RawAbstractType* CompileType() const; 2491 virtual RawAbstractType* CompileType() const;
2486 2492
2487 // Accessors forwarded to the AST node. 2493 // Accessors forwarded to the AST node.
2488 const Function& function() const { return function_; } 2494 const Function& function() const { return function_; }
2489 const Array& argument_names() const { return argument_names_; } 2495 const Array& argument_names() const { return argument_names_; }
2490 intptr_t token_pos() const { return token_pos_; } 2496 intptr_t token_pos() const { return token_pos_; }
2491 2497
2492 virtual intptr_t ArgumentCount() const { return arguments_->length(); } 2498 virtual intptr_t ArgumentCount() const { return arguments_->length(); }
2493 PushArgumentInstr* ArgumentAt(intptr_t index) const { 2499 virtual PushArgumentInstr* PushArgumentAt(intptr_t index) const {
2494 return (*arguments_)[index]; 2500 return (*arguments_)[index];
2495 } 2501 }
2496 2502
2497 virtual void PrintOperandsTo(BufferFormatter* f) const; 2503 virtual void PrintOperandsTo(BufferFormatter* f) const;
2498 2504
2499 virtual bool CanDeoptimize() const { return true; } 2505 virtual bool CanDeoptimize() const { return true; }
2500 2506
2501 virtual bool HasSideEffect() const { return true; } 2507 virtual bool HasSideEffect() const { return true; }
2502 2508
2503 virtual intptr_t ResultCid() const { return result_cid_; } 2509 virtual intptr_t ResultCid() const { return result_cid_; }
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
2943 arguments_(arguments), 2949 arguments_(arguments),
2944 cid_(Class::Handle(node->constructor().Owner()).id()) { 2950 cid_(Class::Handle(node->constructor().Owner()).id()) {
2945 // Either no arguments or one type-argument and one instantiator. 2951 // Either no arguments or one type-argument and one instantiator.
2946 ASSERT(arguments->is_empty() || (arguments->length() == 2)); 2952 ASSERT(arguments->is_empty() || (arguments->length() == 2));
2947 } 2953 }
2948 2954
2949 DECLARE_INSTRUCTION(AllocateObject) 2955 DECLARE_INSTRUCTION(AllocateObject)
2950 virtual RawAbstractType* CompileType() const; 2956 virtual RawAbstractType* CompileType() const;
2951 2957
2952 virtual intptr_t ArgumentCount() const { return arguments_->length(); } 2958 virtual intptr_t ArgumentCount() const { return arguments_->length(); }
2953 PushArgumentInstr* ArgumentAt(intptr_t index) const { 2959 virtual PushArgumentInstr* PushArgumentAt(intptr_t index) const {
2954 return (*arguments_)[index]; 2960 return (*arguments_)[index];
2955 } 2961 }
2956 2962
2957 const Function& constructor() const { return ast_node_.constructor(); } 2963 const Function& constructor() const { return ast_node_.constructor(); }
2958 intptr_t token_pos() const { return ast_node_.token_pos(); } 2964 intptr_t token_pos() const { return ast_node_.token_pos(); }
2959 2965
2960 virtual void PrintOperandsTo(BufferFormatter* f) const; 2966 virtual void PrintOperandsTo(BufferFormatter* f) const;
2961 2967
2962 virtual bool CanDeoptimize() const { return false; } 2968 virtual bool CanDeoptimize() const { return false; }
2963 2969
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
3011 public: 3017 public:
3012 CreateArrayInstr(intptr_t token_pos, 3018 CreateArrayInstr(intptr_t token_pos,
3013 ZoneGrowableArray<PushArgumentInstr*>* arguments, 3019 ZoneGrowableArray<PushArgumentInstr*>* arguments,
3014 const AbstractType& type, 3020 const AbstractType& type,
3015 Value* element_type) 3021 Value* element_type)
3016 : token_pos_(token_pos), 3022 : token_pos_(token_pos),
3017 arguments_(arguments), 3023 arguments_(arguments),
3018 type_(type) { 3024 type_(type) {
3019 #if defined(DEBUG) 3025 #if defined(DEBUG)
3020 for (int i = 0; i < ArgumentCount(); ++i) { 3026 for (int i = 0; i < ArgumentCount(); ++i) {
3021 ASSERT(ArgumentAt(i) != NULL); 3027 ASSERT(PushArgumentAt(i) != NULL);
3022 } 3028 }
3023 ASSERT(element_type != NULL); 3029 ASSERT(element_type != NULL);
3024 ASSERT(type_.IsZoneHandle()); 3030 ASSERT(type_.IsZoneHandle());
3025 ASSERT(!type_.IsNull()); 3031 ASSERT(!type_.IsNull());
3026 ASSERT(type_.IsFinalized()); 3032 ASSERT(type_.IsFinalized());
3027 #endif 3033 #endif
3028 inputs_[0] = element_type; 3034 inputs_[0] = element_type;
3029 } 3035 }
3030 3036
3031 DECLARE_INSTRUCTION(CreateArray) 3037 DECLARE_INSTRUCTION(CreateArray)
3032 virtual RawAbstractType* CompileType() const; 3038 virtual RawAbstractType* CompileType() const;
3033 3039
3034 virtual intptr_t ArgumentCount() const { return arguments_->length(); } 3040 virtual intptr_t ArgumentCount() const { return arguments_->length(); }
3041 virtual PushArgumentInstr* PushArgumentAt(intptr_t i) const {
3042 return (*arguments_)[i];
3043 }
3035 3044
3036 intptr_t token_pos() const { return token_pos_; } 3045 intptr_t token_pos() const { return token_pos_; }
3037 PushArgumentInstr* ArgumentAt(intptr_t i) const { return (*arguments_)[i]; }
3038 const AbstractType& type() const { return type_; } 3046 const AbstractType& type() const { return type_; }
3039 Value* element_type() const { return inputs_[0]; } 3047 Value* element_type() const { return inputs_[0]; }
3040 3048
3041 virtual void PrintOperandsTo(BufferFormatter* f) const; 3049 virtual void PrintOperandsTo(BufferFormatter* f) const;
3042 3050
3043 virtual bool CanDeoptimize() const { return false; } 3051 virtual bool CanDeoptimize() const { return false; }
3044 3052
3045 virtual bool HasSideEffect() const { return true; } 3053 virtual bool HasSideEffect() const { return true; }
3046 3054
3047 virtual intptr_t ResultCid() const { return kArrayCid; } 3055 virtual intptr_t ResultCid() const { return kArrayCid; }
(...skipping 16 matching lines...) Expand all
3064 arguments_(arguments), 3072 arguments_(arguments),
3065 token_pos_(token_pos) { } 3073 token_pos_(token_pos) { }
3066 3074
3067 DECLARE_INSTRUCTION(CreateClosure) 3075 DECLARE_INSTRUCTION(CreateClosure)
3068 virtual RawAbstractType* CompileType() const; 3076 virtual RawAbstractType* CompileType() const;
3069 3077
3070 intptr_t token_pos() const { return token_pos_; } 3078 intptr_t token_pos() const { return token_pos_; }
3071 const Function& function() const { return function_; } 3079 const Function& function() const { return function_; }
3072 3080
3073 virtual intptr_t ArgumentCount() const { return arguments_->length(); } 3081 virtual intptr_t ArgumentCount() const { return arguments_->length(); }
3074 PushArgumentInstr* ArgumentAt(intptr_t index) const { 3082 virtual PushArgumentInstr* PushArgumentAt(intptr_t index) const {
3075 return (*arguments_)[index]; 3083 return (*arguments_)[index];
3076 } 3084 }
3077 3085
3078 virtual void PrintOperandsTo(BufferFormatter* f) const; 3086 virtual void PrintOperandsTo(BufferFormatter* f) const;
3079 3087
3080 virtual bool CanDeoptimize() const { return false; } 3088 virtual bool CanDeoptimize() const { return false; }
3081 3089
3082 virtual bool HasSideEffect() const { return true; } 3090 virtual bool HasSideEffect() const { return true; }
3083 3091
3084 virtual intptr_t ResultCid() const { return kDynamicCid; } 3092 virtual intptr_t ResultCid() const { return kDynamicCid; }
(...skipping 1429 matching lines...) Expand 10 before | Expand all | Expand 10 after
4514 ForwardInstructionIterator* current_iterator_; 4522 ForwardInstructionIterator* current_iterator_;
4515 4523
4516 private: 4524 private:
4517 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); 4525 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor);
4518 }; 4526 };
4519 4527
4520 4528
4521 } // namespace dart 4529 } // namespace dart
4522 4530
4523 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 4531 #endif // VM_INTERMEDIATE_LANGUAGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698