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

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

Issue 17233003: Reapply "Initial implementation of on-stack replacement (OSR)." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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"
11 #include "vm/handles_impl.h" 11 #include "vm/handles_impl.h"
12 #include "vm/locations.h" 12 #include "vm/locations.h"
13 #include "vm/object.h" 13 #include "vm/object.h"
14 14
15 namespace dart { 15 namespace dart {
16 16
17 class BitVector; 17 class BitVector;
18 class BlockEntryInstr; 18 class BlockEntryInstr;
19 class BufferFormatter; 19 class BufferFormatter;
20 class CatchBlockEntryInstr; 20 class CatchBlockEntryInstr;
21 class ComparisonInstr; 21 class ComparisonInstr;
22 class ControlInstruction; 22 class ControlInstruction;
23 class Definition; 23 class Definition;
24 class Environment; 24 class Environment;
25 class FlowGraph; 25 class FlowGraph;
26 class FlowGraphBuilder;
26 class FlowGraphCompiler; 27 class FlowGraphCompiler;
27 class FlowGraphVisitor; 28 class FlowGraphVisitor;
28 class Instruction; 29 class Instruction;
29 class LocalVariable; 30 class LocalVariable;
30 class ParsedFunction; 31 class ParsedFunction;
31 class Range; 32 class Range;
32 33
33 34
34 // TODO(srdjan): Unify with INTRINSIC_LIST. 35 // TODO(srdjan): Unify with INTRINSIC_LIST.
35 // (class-name, function-name, recognized enum, fingerprint). 36 // (class-name, function-name, recognized enum, fingerprint).
(...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 862
862 protected: 863 protected:
863 // Fetch deopt id without checking if this computation can deoptimize. 864 // Fetch deopt id without checking if this computation can deoptimize.
864 intptr_t GetDeoptId() const { 865 intptr_t GetDeoptId() const {
865 return deopt_id_; 866 return deopt_id_;
866 } 867 }
867 868
868 private: 869 private:
869 friend class Definition; // Needed for InsertBefore, InsertAfter. 870 friend class Definition; // Needed for InsertBefore, InsertAfter.
870 871
871 // Classes that set deopt_id_. 872 // Classes that set or read deopt_id_.
872 friend class UnboxIntegerInstr; 873 friend class UnboxIntegerInstr;
873 friend class UnboxDoubleInstr; 874 friend class UnboxDoubleInstr;
874 friend class UnboxFloat32x4Instr; 875 friend class UnboxFloat32x4Instr;
875 friend class UnboxUint32x4Instr; 876 friend class UnboxUint32x4Instr;
876 friend class BinaryDoubleOpInstr; 877 friend class BinaryDoubleOpInstr;
877 friend class BinaryFloat32x4OpInstr; 878 friend class BinaryFloat32x4OpInstr;
878 friend class Float32x4ZeroInstr; 879 friend class Float32x4ZeroInstr;
879 friend class Float32x4SplatInstr; 880 friend class Float32x4SplatInstr;
880 friend class Float32x4ShuffleInstr; 881 friend class Float32x4ShuffleInstr;
881 friend class Float32x4ConstructorInstr; 882 friend class Float32x4ConstructorInstr;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
914 friend class StoreInstanceFieldInstr; 915 friend class StoreInstanceFieldInstr;
915 friend class ControlInstruction; 916 friend class ControlInstruction;
916 friend class ComparisonInstr; 917 friend class ComparisonInstr;
917 friend class TargetEntryInstr; 918 friend class TargetEntryInstr;
918 friend class JoinEntryInstr; 919 friend class JoinEntryInstr;
919 friend class InstanceOfInstr; 920 friend class InstanceOfInstr;
920 friend class PolymorphicInstanceCallInstr; 921 friend class PolymorphicInstanceCallInstr;
921 friend class SmiToDoubleInstr; 922 friend class SmiToDoubleInstr;
922 friend class DoubleToIntegerInstr; 923 friend class DoubleToIntegerInstr;
923 friend class BranchSimplifier; 924 friend class BranchSimplifier;
925 friend class BlockEntryInstr;
924 926
925 virtual void RawSetInputAt(intptr_t i, Value* value) = 0; 927 virtual void RawSetInputAt(intptr_t i, Value* value) = 0;
926 928
927 enum { 929 enum {
928 kNoExprId = -1 930 kNoExprId = -1
929 }; 931 };
930 932
931 intptr_t deopt_id_; 933 intptr_t deopt_id_;
932 intptr_t lifetime_position_; // Position used by register allocator. 934 intptr_t lifetime_position_; // Position used by register allocator.
933 Instruction* previous_; 935 Instruction* previous_;
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
1136 // block entry instructions of predecessor blocks) and also the last 1138 // block entry instructions of predecessor blocks) and also the last
1137 // instruction in the block is recorded in each entry instruction. 1139 // instruction in the block is recorded in each entry instruction.
1138 void DiscoverBlocks( 1140 void DiscoverBlocks(
1139 BlockEntryInstr* predecessor, 1141 BlockEntryInstr* predecessor,
1140 GrowableArray<BlockEntryInstr*>* preorder, 1142 GrowableArray<BlockEntryInstr*>* preorder,
1141 GrowableArray<BlockEntryInstr*>* postorder, 1143 GrowableArray<BlockEntryInstr*>* postorder,
1142 GrowableArray<intptr_t>* parent, 1144 GrowableArray<intptr_t>* parent,
1143 intptr_t variable_count, 1145 intptr_t variable_count,
1144 intptr_t fixed_parameter_count); 1146 intptr_t fixed_parameter_count);
1145 1147
1148 // Perform a depth first search to prune code not reachable from an OSR
1149 // entry point.
1150 bool PruneUnreachable(FlowGraphBuilder* builder,
1151 GraphEntryInstr* graph_entry,
1152 intptr_t osr_id,
1153 BitVector* block_marks);
1154
1146 virtual intptr_t InputCount() const { return 0; } 1155 virtual intptr_t InputCount() const { return 0; }
1147 virtual Value* InputAt(intptr_t i) const { 1156 virtual Value* InputAt(intptr_t i) const {
1148 UNREACHABLE(); 1157 UNREACHABLE();
1149 return NULL; 1158 return NULL;
1150 } 1159 }
1151 1160
1152 virtual intptr_t ArgumentCount() const { return 0; } 1161 virtual intptr_t ArgumentCount() const { return 0; }
1153 1162
1154 virtual bool CanBecomeDeoptimizationTarget() const { 1163 virtual bool CanBecomeDeoptimizationTarget() const {
1155 // BlockEntry environment is copied to Goto and Branch instructions 1164 // BlockEntry environment is copied to Goto and Branch instructions
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1274 1283
1275 private: 1284 private:
1276 BlockEntryInstr* block_entry_; 1285 BlockEntryInstr* block_entry_;
1277 Instruction* current_; 1286 Instruction* current_;
1278 }; 1287 };
1279 1288
1280 1289
1281 class GraphEntryInstr : public BlockEntryInstr { 1290 class GraphEntryInstr : public BlockEntryInstr {
1282 public: 1291 public:
1283 GraphEntryInstr(const ParsedFunction& parsed_function, 1292 GraphEntryInstr(const ParsedFunction& parsed_function,
1284 TargetEntryInstr* normal_entry); 1293 TargetEntryInstr* normal_entry,
1294 intptr_t osr_id);
1285 1295
1286 DECLARE_INSTRUCTION(GraphEntry) 1296 DECLARE_INSTRUCTION(GraphEntry)
1287 1297
1288 virtual intptr_t PredecessorCount() const { return 0; } 1298 virtual intptr_t PredecessorCount() const { return 0; }
1289 virtual BlockEntryInstr* PredecessorAt(intptr_t index) const { 1299 virtual BlockEntryInstr* PredecessorAt(intptr_t index) const {
1290 UNREACHABLE(); 1300 UNREACHABLE();
1291 return NULL; 1301 return NULL;
1292 } 1302 }
1293 virtual intptr_t SuccessorCount() const; 1303 virtual intptr_t SuccessorCount() const;
1294 virtual BlockEntryInstr* SuccessorAt(intptr_t index) const; 1304 virtual BlockEntryInstr* SuccessorAt(intptr_t index) const;
1295 1305
1296 void AddCatchEntry(CatchBlockEntryInstr* entry) { catch_entries_.Add(entry); } 1306 void AddCatchEntry(CatchBlockEntryInstr* entry) { catch_entries_.Add(entry); }
1297 1307
1298 CatchBlockEntryInstr* GetCatchEntry(intptr_t index); 1308 CatchBlockEntryInstr* GetCatchEntry(intptr_t index);
1299 1309
1300 GrowableArray<Definition*>* initial_definitions() { 1310 GrowableArray<Definition*>* initial_definitions() {
1301 return &initial_definitions_; 1311 return &initial_definitions_;
1302 } 1312 }
1303 ConstantInstr* constant_null(); 1313 ConstantInstr* constant_null();
1304 1314
1315 bool IsCompiledForOsr() const { return osr_id_ != Isolate::kNoDeoptId; }
1316
1305 intptr_t spill_slot_count() const { return spill_slot_count_; } 1317 intptr_t spill_slot_count() const { return spill_slot_count_; }
1306 void set_spill_slot_count(intptr_t count) { 1318 void set_spill_slot_count(intptr_t count) {
1307 ASSERT(count >= 0); 1319 ASSERT(count >= 0);
1308 spill_slot_count_ = count; 1320 spill_slot_count_ = count;
1309 } 1321 }
1310 1322
1311 // Number of stack slots reserved for compiling try-catch. For functions 1323 // Number of stack slots reserved for compiling try-catch. For functions
1312 // without try-catch, this is 0. Otherwise, it is the number of local 1324 // without try-catch, this is 0. Otherwise, it is the number of local
1313 // variables. 1325 // variables.
1314 intptr_t fixed_slot_count() const { return fixed_slot_count_; } 1326 intptr_t fixed_slot_count() const { return fixed_slot_count_; }
(...skipping 14 matching lines...) Expand all
1329 virtual void PrintTo(BufferFormatter* f) const; 1341 virtual void PrintTo(BufferFormatter* f) const;
1330 1342
1331 private: 1343 private:
1332 virtual void ClearPredecessors() {} 1344 virtual void ClearPredecessors() {}
1333 virtual void AddPredecessor(BlockEntryInstr* predecessor) { UNREACHABLE(); } 1345 virtual void AddPredecessor(BlockEntryInstr* predecessor) { UNREACHABLE(); }
1334 1346
1335 const ParsedFunction& parsed_function_; 1347 const ParsedFunction& parsed_function_;
1336 TargetEntryInstr* normal_entry_; 1348 TargetEntryInstr* normal_entry_;
1337 GrowableArray<CatchBlockEntryInstr*> catch_entries_; 1349 GrowableArray<CatchBlockEntryInstr*> catch_entries_;
1338 GrowableArray<Definition*> initial_definitions_; 1350 GrowableArray<Definition*> initial_definitions_;
1351 const intptr_t osr_id_;
1339 intptr_t spill_slot_count_; 1352 intptr_t spill_slot_count_;
1340 intptr_t fixed_slot_count_; // For try-catch in optimized code. 1353 intptr_t fixed_slot_count_; // For try-catch in optimized code.
1341 1354
1342 DISALLOW_COPY_AND_ASSIGN(GraphEntryInstr); 1355 DISALLOW_COPY_AND_ASSIGN(GraphEntryInstr);
1343 }; 1356 };
1344 1357
1345 1358
1346 class JoinEntryInstr : public BlockEntryInstr { 1359 class JoinEntryInstr : public BlockEntryInstr {
1347 public: 1360 public:
1348 JoinEntryInstr(intptr_t block_id, intptr_t try_index) 1361 JoinEntryInstr(intptr_t block_id, intptr_t try_index)
(...skipping 4551 matching lines...) Expand 10 before | Expand all | Expand 10 after
5900 5913
5901 private: 5914 private:
5902 const Token::Kind op_kind_; 5915 const Token::Kind op_kind_;
5903 5916
5904 DISALLOW_COPY_AND_ASSIGN(UnarySmiOpInstr); 5917 DISALLOW_COPY_AND_ASSIGN(UnarySmiOpInstr);
5905 }; 5918 };
5906 5919
5907 5920
5908 class CheckStackOverflowInstr : public TemplateInstruction<0> { 5921 class CheckStackOverflowInstr : public TemplateInstruction<0> {
5909 public: 5922 public:
5910 explicit CheckStackOverflowInstr(intptr_t token_pos) 5923 CheckStackOverflowInstr(intptr_t token_pos, bool in_loop)
5911 : token_pos_(token_pos) {} 5924 : token_pos_(token_pos), in_loop_(in_loop) {}
5912 5925
5913 intptr_t token_pos() const { return token_pos_; } 5926 intptr_t token_pos() const { return token_pos_; }
5927 bool in_loop() const { return in_loop_; }
5914 5928
5915 DECLARE_INSTRUCTION(CheckStackOverflow) 5929 DECLARE_INSTRUCTION(CheckStackOverflow)
5916 5930
5917 virtual intptr_t ArgumentCount() const { return 0; } 5931 virtual intptr_t ArgumentCount() const { return 0; }
5918 5932
5919 virtual bool CanDeoptimize() const { return true; } 5933 virtual bool CanDeoptimize() const { return true; }
5920 5934
5921 virtual EffectSet Effects() const { return EffectSet::None(); } 5935 virtual EffectSet Effects() const { return EffectSet::None(); }
5922 5936
5923 virtual bool MayThrow() const { return false; } 5937 virtual bool MayThrow() const { return false; }
5924 5938
5939 virtual void PrintOperandsTo(BufferFormatter* f) const;
5940
5925 private: 5941 private:
5926 const intptr_t token_pos_; 5942 const intptr_t token_pos_;
5943 const bool in_loop_;
5927 5944
5928 DISALLOW_COPY_AND_ASSIGN(CheckStackOverflowInstr); 5945 DISALLOW_COPY_AND_ASSIGN(CheckStackOverflowInstr);
5929 }; 5946 };
5930 5947
5931 5948
5932 class SmiToDoubleInstr : public TemplateDefinition<1> { 5949 class SmiToDoubleInstr : public TemplateDefinition<1> {
5933 public: 5950 public:
5934 explicit SmiToDoubleInstr(Value* value) { 5951 explicit SmiToDoubleInstr(Value* value) {
5935 SetInputAt(0, value); 5952 SetInputAt(0, value);
5936 } 5953 }
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
6471 ForwardInstructionIterator* current_iterator_; 6488 ForwardInstructionIterator* current_iterator_;
6472 6489
6473 private: 6490 private:
6474 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); 6491 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor);
6475 }; 6492 };
6476 6493
6477 6494
6478 } // namespace dart 6495 } // namespace dart
6479 6496
6480 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 6497 #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