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

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: Incorporated review comments. 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
« 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) 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 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 virtual Value* InputAt(intptr_t i) const = 0; 480 virtual Value* InputAt(intptr_t i) const = 0;
481 virtual void SetInputAt(intptr_t i, Value* value) = 0; 481 virtual void SetInputAt(intptr_t i, Value* value) = 0;
482 482
483 // Remove all inputs (including in the environment) from their 483 // Remove all inputs (including in the environment) from their
484 // definition's use lists. 484 // definition's use lists.
485 void UnuseAllInputs(); 485 void UnuseAllInputs();
486 486
487 // Call instructions override this function and return the number of 487 // Call instructions override this function and return the number of
488 // pushed arguments. 488 // pushed arguments.
489 virtual intptr_t ArgumentCount() const = 0; 489 virtual intptr_t ArgumentCount() const = 0;
490 virtual PushArgumentInstr* ArgumentAt(intptr_t index) const { 490 virtual PushArgumentInstr* PushArgumentAt(intptr_t index) const {
491 UNREACHABLE(); 491 UNREACHABLE();
492 return NULL; 492 return NULL;
493 }; 493 }
494 inline Definition* ArgumentAt(intptr_t index) const;
494 495
495 // Returns true, if this instruction can deoptimize. 496 // Returns true, if this instruction can deoptimize.
496 virtual bool CanDeoptimize() const = 0; 497 virtual bool CanDeoptimize() const = 0;
497 498
498 // Returns true if the instruction may have side effects. 499 // Returns true if the instruction may have side effects.
499 virtual bool HasSideEffect() const = 0; 500 virtual bool HasSideEffect() const = 0;
500 501
501 // Visiting support. 502 // Visiting support.
502 virtual void Accept(FlowGraphVisitor* visitor) = 0; 503 virtual void Accept(FlowGraphVisitor* visitor) = 0;
503 504
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
965 void Advance() { 966 void Advance() {
966 ASSERT(!Done()); 967 ASSERT(!Done());
967 current_ = current_->next(); 968 current_ = current_->next();
968 } 969 }
969 970
970 bool Done() const { return current_ == NULL; } 971 bool Done() const { return current_ == NULL; }
971 972
972 // Removes 'current_' from graph and sets 'current_' to previous instruction. 973 // Removes 'current_' from graph and sets 'current_' to previous instruction.
973 void RemoveCurrentFromGraph(); 974 void RemoveCurrentFromGraph();
974 975
975 // Inserts replaces 'current_', which must be a definition, with another
976 // definition. The new definition becomes 'current_'.
977 void ReplaceCurrentWith(Definition* other);
978
979 Instruction* Current() const { return current_; } 976 Instruction* Current() const { return current_; }
980 977
981 private: 978 private:
982 BlockEntryInstr* block_entry_; 979 BlockEntryInstr* block_entry_;
983 Instruction* current_; 980 Instruction* current_;
984 }; 981 };
985 982
986 983
987 class BackwardInstructionIterator : public ValueObject { 984 class BackwardInstructionIterator : public ValueObject {
988 public: 985 public:
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
1490 virtual void PrintOperandsTo(BufferFormatter* f) const; 1487 virtual void PrintOperandsTo(BufferFormatter* f) const;
1491 1488
1492 private: 1489 private:
1493 Value* value_; 1490 Value* value_;
1494 LocationSummary* locs_; 1491 LocationSummary* locs_;
1495 1492
1496 DISALLOW_COPY_AND_ASSIGN(PushArgumentInstr); 1493 DISALLOW_COPY_AND_ASSIGN(PushArgumentInstr);
1497 }; 1494 };
1498 1495
1499 1496
1497 inline Definition* Instruction::ArgumentAt(intptr_t index) const {
1498 return PushArgumentAt(index)->value()->definition();
1499 }
1500
1501
1500 class ReturnInstr : public TemplateInstruction<1> { 1502 class ReturnInstr : public TemplateInstruction<1> {
1501 public: 1503 public:
1502 ReturnInstr(intptr_t token_pos, Value* value) 1504 ReturnInstr(intptr_t token_pos, Value* value)
1503 : token_pos_(token_pos) { 1505 : token_pos_(token_pos) {
1504 ASSERT(value != NULL); 1506 ASSERT(value != NULL);
1505 inputs_[0] = value; 1507 inputs_[0] = value;
1506 } 1508 }
1507 1509
1508 DECLARE_INSTRUCTION(Return) 1510 DECLARE_INSTRUCTION(Return)
1509 1511
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after
2122 ZoneGrowableArray<PushArgumentInstr*>* arguments) 2124 ZoneGrowableArray<PushArgumentInstr*>* arguments)
2123 : ast_node_(*node), 2125 : ast_node_(*node),
2124 arguments_(arguments) { } 2126 arguments_(arguments) { }
2125 2127
2126 DECLARE_INSTRUCTION(ClosureCall) 2128 DECLARE_INSTRUCTION(ClosureCall)
2127 2129
2128 const Array& argument_names() const { return ast_node_.arguments()->names(); } 2130 const Array& argument_names() const { return ast_node_.arguments()->names(); }
2129 intptr_t token_pos() const { return ast_node_.token_pos(); } 2131 intptr_t token_pos() const { return ast_node_.token_pos(); }
2130 2132
2131 virtual intptr_t ArgumentCount() const { return arguments_->length(); } 2133 virtual intptr_t ArgumentCount() const { return arguments_->length(); }
2132 PushArgumentInstr* ArgumentAt(intptr_t index) const { 2134 virtual PushArgumentInstr* PushArgumentAt(intptr_t index) const {
2133 return (*arguments_)[index]; 2135 return (*arguments_)[index];
2134 } 2136 }
2135 2137
2136 virtual void PrintOperandsTo(BufferFormatter* f) const; 2138 virtual void PrintOperandsTo(BufferFormatter* f) const;
2137 2139
2138 virtual bool CanDeoptimize() const { return true; } 2140 virtual bool CanDeoptimize() const { return true; }
2139 2141
2140 virtual bool HasSideEffect() const { return true; } 2142 virtual bool HasSideEffect() const { return true; }
2141 2143
2142 private: 2144 private:
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2181 return (ic_data() != NULL) && !ic_data()->IsNull(); 2183 return (ic_data() != NULL) && !ic_data()->IsNull();
2182 } 2184 }
2183 2185
2184 // ICData can be replaced by optimizer. 2186 // ICData can be replaced by optimizer.
2185 void set_ic_data(const ICData* value) { ic_data_ = value; } 2187 void set_ic_data(const ICData* value) { ic_data_ = value; }
2186 2188
2187 intptr_t token_pos() const { return token_pos_; } 2189 intptr_t token_pos() const { return token_pos_; }
2188 const String& function_name() const { return function_name_; } 2190 const String& function_name() const { return function_name_; }
2189 Token::Kind token_kind() const { return token_kind_; } 2191 Token::Kind token_kind() const { return token_kind_; }
2190 virtual intptr_t ArgumentCount() const { return arguments_->length(); } 2192 virtual intptr_t ArgumentCount() const { return arguments_->length(); }
2191 PushArgumentInstr* ArgumentAt(intptr_t index) const { 2193 virtual PushArgumentInstr* PushArgumentAt(intptr_t index) const {
2192 return (*arguments_)[index]; 2194 return (*arguments_)[index];
2193 } 2195 }
2194 const Array& argument_names() const { return argument_names_; } 2196 const Array& argument_names() const { return argument_names_; }
2195 intptr_t checked_argument_count() const { return checked_argument_count_; } 2197 intptr_t checked_argument_count() const { return checked_argument_count_; }
2196 2198
2197 virtual void PrintOperandsTo(BufferFormatter* f) const; 2199 virtual void PrintOperandsTo(BufferFormatter* f) const;
2198 2200
2199 virtual bool CanDeoptimize() const { return true; } 2201 virtual bool CanDeoptimize() const { return true; }
2200 2202
2201 virtual bool HasSideEffect() const { return true; } 2203 virtual bool HasSideEffect() const { return true; }
(...skipping 25 matching lines...) Expand all
2227 with_checks_(with_checks) { 2229 with_checks_(with_checks) {
2228 ASSERT(instance_call_ != NULL); 2230 ASSERT(instance_call_ != NULL);
2229 } 2231 }
2230 2232
2231 InstanceCallInstr* instance_call() const { return instance_call_; } 2233 InstanceCallInstr* instance_call() const { return instance_call_; }
2232 bool with_checks() const { return with_checks_; } 2234 bool with_checks() const { return with_checks_; }
2233 2235
2234 virtual intptr_t ArgumentCount() const { 2236 virtual intptr_t ArgumentCount() const {
2235 return instance_call()->ArgumentCount(); 2237 return instance_call()->ArgumentCount();
2236 } 2238 }
2237 PushArgumentInstr* ArgumentAt(intptr_t index) const { 2239 virtual PushArgumentInstr* PushArgumentAt(intptr_t index) const {
2238 return instance_call()->ArgumentAt(index); 2240 return instance_call()->PushArgumentAt(index);
2239 } 2241 }
2240 2242
2241 DECLARE_INSTRUCTION(PolymorphicInstanceCall) 2243 DECLARE_INSTRUCTION(PolymorphicInstanceCall)
2242 2244
2243 const ICData& ic_data() const { return ic_data_; } 2245 const ICData& ic_data() const { return ic_data_; }
2244 2246
2245 virtual bool CanDeoptimize() const { return true; } 2247 virtual bool CanDeoptimize() const { return true; }
2246 2248
2247 virtual bool HasSideEffect() const { return true; } 2249 virtual bool HasSideEffect() const { return true; }
2248 2250
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
2528 2530
2529 DECLARE_INSTRUCTION(StaticCall) 2531 DECLARE_INSTRUCTION(StaticCall)
2530 virtual CompileType* ComputeInitialType() const; 2532 virtual CompileType* ComputeInitialType() const;
2531 2533
2532 // Accessors forwarded to the AST node. 2534 // Accessors forwarded to the AST node.
2533 const Function& function() const { return function_; } 2535 const Function& function() const { return function_; }
2534 const Array& argument_names() const { return argument_names_; } 2536 const Array& argument_names() const { return argument_names_; }
2535 intptr_t token_pos() const { return token_pos_; } 2537 intptr_t token_pos() const { return token_pos_; }
2536 2538
2537 virtual intptr_t ArgumentCount() const { return arguments_->length(); } 2539 virtual intptr_t ArgumentCount() const { return arguments_->length(); }
2538 PushArgumentInstr* ArgumentAt(intptr_t index) const { 2540 virtual PushArgumentInstr* PushArgumentAt(intptr_t index) const {
2539 return (*arguments_)[index]; 2541 return (*arguments_)[index];
2540 } 2542 }
2541 2543
2542 virtual void PrintOperandsTo(BufferFormatter* f) const; 2544 virtual void PrintOperandsTo(BufferFormatter* f) const;
2543 2545
2544 virtual bool CanDeoptimize() const { return true; } 2546 virtual bool CanDeoptimize() const { return true; }
2545 2547
2546 virtual bool HasSideEffect() const { return true; } 2548 virtual bool HasSideEffect() const { return true; }
2547 2549
2548 void set_result_cid(intptr_t value) { result_cid_ = value; } 2550 void set_result_cid(intptr_t value) { result_cid_ = value; }
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
2962 arguments_(arguments), 2964 arguments_(arguments),
2963 cid_(Class::Handle(node->constructor().Owner()).id()) { 2965 cid_(Class::Handle(node->constructor().Owner()).id()) {
2964 // Either no arguments or one type-argument and one instantiator. 2966 // Either no arguments or one type-argument and one instantiator.
2965 ASSERT(arguments->is_empty() || (arguments->length() == 2)); 2967 ASSERT(arguments->is_empty() || (arguments->length() == 2));
2966 } 2968 }
2967 2969
2968 DECLARE_INSTRUCTION(AllocateObject) 2970 DECLARE_INSTRUCTION(AllocateObject)
2969 virtual CompileType* ComputeInitialType() const; 2971 virtual CompileType* ComputeInitialType() const;
2970 2972
2971 virtual intptr_t ArgumentCount() const { return arguments_->length(); } 2973 virtual intptr_t ArgumentCount() const { return arguments_->length(); }
2972 PushArgumentInstr* ArgumentAt(intptr_t index) const { 2974 virtual PushArgumentInstr* PushArgumentAt(intptr_t index) const {
2973 return (*arguments_)[index]; 2975 return (*arguments_)[index];
2974 } 2976 }
2975 2977
2976 const Function& constructor() const { return ast_node_.constructor(); } 2978 const Function& constructor() const { return ast_node_.constructor(); }
2977 intptr_t token_pos() const { return ast_node_.token_pos(); } 2979 intptr_t token_pos() const { return ast_node_.token_pos(); }
2978 2980
2979 virtual void PrintOperandsTo(BufferFormatter* f) const; 2981 virtual void PrintOperandsTo(BufferFormatter* f) const;
2980 2982
2981 virtual bool CanDeoptimize() const { return false; } 2983 virtual bool CanDeoptimize() const { return false; }
2982 2984
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
3072 arguments_(arguments), 3074 arguments_(arguments),
3073 token_pos_(token_pos) { } 3075 token_pos_(token_pos) { }
3074 3076
3075 DECLARE_INSTRUCTION(CreateClosure) 3077 DECLARE_INSTRUCTION(CreateClosure)
3076 virtual CompileType* ComputeInitialType() const; 3078 virtual CompileType* ComputeInitialType() const;
3077 3079
3078 intptr_t token_pos() const { return token_pos_; } 3080 intptr_t token_pos() const { return token_pos_; }
3079 const Function& function() const { return function_; } 3081 const Function& function() const { return function_; }
3080 3082
3081 virtual intptr_t ArgumentCount() const { return arguments_->length(); } 3083 virtual intptr_t ArgumentCount() const { return arguments_->length(); }
3082 PushArgumentInstr* ArgumentAt(intptr_t index) const { 3084 virtual PushArgumentInstr* PushArgumentAt(intptr_t index) const {
3083 return (*arguments_)[index]; 3085 return (*arguments_)[index];
3084 } 3086 }
3085 3087
3086 virtual void PrintOperandsTo(BufferFormatter* f) const; 3088 virtual void PrintOperandsTo(BufferFormatter* f) const;
3087 3089
3088 virtual bool CanDeoptimize() const { return false; } 3090 virtual bool CanDeoptimize() const { return false; }
3089 3091
3090 virtual bool HasSideEffect() const { return true; } 3092 virtual bool HasSideEffect() const { return true; }
3091 3093
3092 private: 3094 private:
(...skipping 1371 matching lines...) Expand 10 before | Expand all | Expand 10 after
4464 ForwardInstructionIterator* current_iterator_; 4466 ForwardInstructionIterator* current_iterator_;
4465 4467
4466 private: 4468 private:
4467 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); 4469 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor);
4468 }; 4470 };
4469 4471
4470 4472
4471 } // namespace dart 4473 } // namespace dart
4472 4474
4473 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 4475 #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