| 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 1282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1293 Instruction* Current() const { return current_; } | 1293 Instruction* Current() const { return current_; } |
| 1294 | 1294 |
| 1295 private: | 1295 private: |
| 1296 BlockEntryInstr* block_entry_; | 1296 BlockEntryInstr* block_entry_; |
| 1297 Instruction* current_; | 1297 Instruction* current_; |
| 1298 }; | 1298 }; |
| 1299 | 1299 |
| 1300 | 1300 |
| 1301 class GraphEntryInstr : public BlockEntryInstr { | 1301 class GraphEntryInstr : public BlockEntryInstr { |
| 1302 public: | 1302 public: |
| 1303 GraphEntryInstr(const ParsedFunction* parsed_function, | 1303 GraphEntryInstr(const ParsedFunction& parsed_function, |
| 1304 TargetEntryInstr* normal_entry, | 1304 TargetEntryInstr* normal_entry, |
| 1305 intptr_t osr_id); | 1305 intptr_t osr_id); |
| 1306 | 1306 |
| 1307 DECLARE_INSTRUCTION(GraphEntry) | 1307 DECLARE_INSTRUCTION(GraphEntry) |
| 1308 | 1308 |
| 1309 virtual intptr_t PredecessorCount() const { return 0; } | 1309 virtual intptr_t PredecessorCount() const { return 0; } |
| 1310 virtual BlockEntryInstr* PredecessorAt(intptr_t index) const { | 1310 virtual BlockEntryInstr* PredecessorAt(intptr_t index) const { |
| 1311 UNREACHABLE(); | 1311 UNREACHABLE(); |
| 1312 return NULL; | 1312 return NULL; |
| 1313 } | 1313 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1342 // without try-catch, this is 0. Otherwise, it is the number of local | 1342 // without try-catch, this is 0. Otherwise, it is the number of local |
| 1343 // variables. | 1343 // variables. |
| 1344 intptr_t fixed_slot_count() const { return fixed_slot_count_; } | 1344 intptr_t fixed_slot_count() const { return fixed_slot_count_; } |
| 1345 void set_fixed_slot_count(intptr_t count) { | 1345 void set_fixed_slot_count(intptr_t count) { |
| 1346 ASSERT(count >= 0); | 1346 ASSERT(count >= 0); |
| 1347 fixed_slot_count_ = count; | 1347 fixed_slot_count_ = count; |
| 1348 } | 1348 } |
| 1349 TargetEntryInstr* normal_entry() const { return normal_entry_; } | 1349 TargetEntryInstr* normal_entry() const { return normal_entry_; } |
| 1350 | 1350 |
| 1351 const ParsedFunction& parsed_function() const { | 1351 const ParsedFunction& parsed_function() const { |
| 1352 return *parsed_function_; | 1352 return parsed_function_; |
| 1353 } | 1353 } |
| 1354 | 1354 |
| 1355 const GrowableArray<CatchBlockEntryInstr*>& catch_entries() const { | 1355 const GrowableArray<CatchBlockEntryInstr*>& catch_entries() const { |
| 1356 return catch_entries_; | 1356 return catch_entries_; |
| 1357 } | 1357 } |
| 1358 | 1358 |
| 1359 const GrowableArray<IndirectEntryInstr*>& indirect_entries() const { | 1359 const GrowableArray<IndirectEntryInstr*>& indirect_entries() const { |
| 1360 return indirect_entries_; | 1360 return indirect_entries_; |
| 1361 } | 1361 } |
| 1362 | 1362 |
| 1363 virtual void PrintTo(BufferFormatter* f) const; | 1363 virtual void PrintTo(BufferFormatter* f) const; |
| 1364 | 1364 |
| 1365 private: | 1365 private: |
| 1366 virtual void ClearPredecessors() {} | 1366 virtual void ClearPredecessors() {} |
| 1367 virtual void AddPredecessor(BlockEntryInstr* predecessor) { UNREACHABLE(); } | 1367 virtual void AddPredecessor(BlockEntryInstr* predecessor) { UNREACHABLE(); } |
| 1368 | 1368 |
| 1369 const ParsedFunction* parsed_function_; | 1369 const ParsedFunction& parsed_function_; |
| 1370 TargetEntryInstr* normal_entry_; | 1370 TargetEntryInstr* normal_entry_; |
| 1371 GrowableArray<CatchBlockEntryInstr*> catch_entries_; | 1371 GrowableArray<CatchBlockEntryInstr*> catch_entries_; |
| 1372 // Indirect targets are blocks reachable only through indirect gotos. | 1372 // Indirect targets are blocks reachable only through indirect gotos. |
| 1373 GrowableArray<IndirectEntryInstr*> indirect_entries_; | 1373 GrowableArray<IndirectEntryInstr*> indirect_entries_; |
| 1374 GrowableArray<Definition*> initial_definitions_; | 1374 GrowableArray<Definition*> initial_definitions_; |
| 1375 const intptr_t osr_id_; | 1375 const intptr_t osr_id_; |
| 1376 intptr_t entry_count_; | 1376 intptr_t entry_count_; |
| 1377 intptr_t spill_slot_count_; | 1377 intptr_t spill_slot_count_; |
| 1378 intptr_t fixed_slot_count_; // For try-catch in optimized code. | 1378 intptr_t fixed_slot_count_; // For try-catch in optimized code. |
| 1379 | 1379 |
| (...skipping 6534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7914 } | 7914 } |
| 7915 } | 7915 } |
| 7916 | 7916 |
| 7917 ShallowIterator iterator_; | 7917 ShallowIterator iterator_; |
| 7918 }; | 7918 }; |
| 7919 | 7919 |
| 7920 // Construct an environment by constructing uses from an array of definitions. | 7920 // Construct an environment by constructing uses from an array of definitions. |
| 7921 static Environment* From(Isolate* isolate, | 7921 static Environment* From(Isolate* isolate, |
| 7922 const GrowableArray<Definition*>& definitions, | 7922 const GrowableArray<Definition*>& definitions, |
| 7923 intptr_t fixed_parameter_count, | 7923 intptr_t fixed_parameter_count, |
| 7924 const ParsedFunction* parsed_function); | 7924 const ParsedFunction& parsed_function); |
| 7925 | 7925 |
| 7926 void set_locations(Location* locations) { | 7926 void set_locations(Location* locations) { |
| 7927 ASSERT(locations_ == NULL); | 7927 ASSERT(locations_ == NULL); |
| 7928 locations_ = locations; | 7928 locations_ = locations; |
| 7929 } | 7929 } |
| 7930 | 7930 |
| 7931 void set_deopt_id(intptr_t deopt_id) { deopt_id_ = deopt_id; } | 7931 void set_deopt_id(intptr_t deopt_id) { deopt_id_ = deopt_id; } |
| 7932 intptr_t deopt_id() const { return deopt_id_; } | 7932 intptr_t deopt_id() const { return deopt_id_; } |
| 7933 | 7933 |
| 7934 Environment* outer() const { return outer_; } | 7934 Environment* outer() const { return outer_; } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 7960 index -= env->Length(); | 7960 index -= env->Length(); |
| 7961 env = env->outer_; | 7961 env = env->outer_; |
| 7962 } | 7962 } |
| 7963 return env->ValueAt(index); | 7963 return env->ValueAt(index); |
| 7964 } | 7964 } |
| 7965 | 7965 |
| 7966 intptr_t fixed_parameter_count() const { | 7966 intptr_t fixed_parameter_count() const { |
| 7967 return fixed_parameter_count_; | 7967 return fixed_parameter_count_; |
| 7968 } | 7968 } |
| 7969 | 7969 |
| 7970 const Code& code() const { return parsed_function_->code(); } | 7970 const Code& code() const { return parsed_function_.code(); } |
| 7971 | 7971 |
| 7972 Environment* DeepCopy(Isolate* isolate) const { | 7972 Environment* DeepCopy(Isolate* isolate) const { |
| 7973 return DeepCopy(isolate, Length()); | 7973 return DeepCopy(isolate, Length()); |
| 7974 } | 7974 } |
| 7975 | 7975 |
| 7976 void DeepCopyTo(Isolate* isolate, Instruction* instr) const; | 7976 void DeepCopyTo(Isolate* isolate, Instruction* instr) const; |
| 7977 void DeepCopyToOuter(Isolate* isolate, Instruction* instr) const; | 7977 void DeepCopyToOuter(Isolate* isolate, Instruction* instr) const; |
| 7978 | 7978 |
| 7979 void DeepCopyAfterTo(Isolate* isolate, | 7979 void DeepCopyAfterTo(Isolate* isolate, |
| 7980 Instruction* instr, | 7980 Instruction* instr, |
| 7981 intptr_t argc, | 7981 intptr_t argc, |
| 7982 Definition* dead, | 7982 Definition* dead, |
| 7983 Definition* result) const; | 7983 Definition* result) const; |
| 7984 | 7984 |
| 7985 void PrintTo(BufferFormatter* f) const; | 7985 void PrintTo(BufferFormatter* f) const; |
| 7986 const char* ToCString() const; | 7986 const char* ToCString() const; |
| 7987 | 7987 |
| 7988 // Deep copy an environment. The 'length' parameter may be less than the | 7988 // Deep copy an environment. The 'length' parameter may be less than the |
| 7989 // environment's length in order to drop values (e.g., passed arguments) | 7989 // environment's length in order to drop values (e.g., passed arguments) |
| 7990 // from the copy. | 7990 // from the copy. |
| 7991 Environment* DeepCopy(Isolate* isolate, intptr_t length) const; | 7991 Environment* DeepCopy(Isolate* isolate, intptr_t length) const; |
| 7992 | 7992 |
| 7993 private: | 7993 private: |
| 7994 friend class ShallowIterator; | 7994 friend class ShallowIterator; |
| 7995 | 7995 |
| 7996 Environment(intptr_t length, | 7996 Environment(intptr_t length, |
| 7997 intptr_t fixed_parameter_count, | 7997 intptr_t fixed_parameter_count, |
| 7998 intptr_t deopt_id, | 7998 intptr_t deopt_id, |
| 7999 const ParsedFunction* parsed_function, | 7999 const ParsedFunction& parsed_function, |
| 8000 Environment* outer) | 8000 Environment* outer) |
| 8001 : values_(length), | 8001 : values_(length), |
| 8002 locations_(NULL), | 8002 locations_(NULL), |
| 8003 fixed_parameter_count_(fixed_parameter_count), | 8003 fixed_parameter_count_(fixed_parameter_count), |
| 8004 deopt_id_(deopt_id), | 8004 deopt_id_(deopt_id), |
| 8005 parsed_function_(parsed_function), | 8005 parsed_function_(parsed_function), |
| 8006 outer_(outer) { } | 8006 outer_(outer) { } |
| 8007 | 8007 |
| 8008 | 8008 |
| 8009 GrowableArray<Value*> values_; | 8009 GrowableArray<Value*> values_; |
| 8010 Location* locations_; | 8010 Location* locations_; |
| 8011 const intptr_t fixed_parameter_count_; | 8011 const intptr_t fixed_parameter_count_; |
| 8012 intptr_t deopt_id_; | 8012 intptr_t deopt_id_; |
| 8013 const ParsedFunction* parsed_function_; | 8013 const ParsedFunction& parsed_function_; |
| 8014 Environment* outer_; | 8014 Environment* outer_; |
| 8015 | 8015 |
| 8016 DISALLOW_COPY_AND_ASSIGN(Environment); | 8016 DISALLOW_COPY_AND_ASSIGN(Environment); |
| 8017 }; | 8017 }; |
| 8018 | 8018 |
| 8019 | 8019 |
| 8020 // Visitor base class to visit each instruction and computation in a flow | 8020 // Visitor base class to visit each instruction and computation in a flow |
| 8021 // graph as defined by a reversed list of basic blocks. | 8021 // graph as defined by a reversed list of basic blocks. |
| 8022 class FlowGraphVisitor : public ValueObject { | 8022 class FlowGraphVisitor : public ValueObject { |
| 8023 public: | 8023 public: |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8056 LocationSummary* Name::MakeLocationSummary(Zone* zone, bool opt) const { \ | 8056 LocationSummary* Name::MakeLocationSummary(Zone* zone, bool opt) const { \ |
| 8057 UNIMPLEMENTED(); \ | 8057 UNIMPLEMENTED(); \ |
| 8058 return NULL; \ | 8058 return NULL; \ |
| 8059 } \ | 8059 } \ |
| 8060 void Name::EmitNativeCode(FlowGraphCompiler* compiler) { UNIMPLEMENTED(); } | 8060 void Name::EmitNativeCode(FlowGraphCompiler* compiler) { UNIMPLEMENTED(); } |
| 8061 | 8061 |
| 8062 | 8062 |
| 8063 } // namespace dart | 8063 } // namespace dart |
| 8064 | 8064 |
| 8065 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 8065 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
| OLD | NEW |