Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 #ifndef VM_DEOPT_INSTRUCTIONS_H_ | |
| 6 #define VM_DEOPT_INSTRUCTIONS_H_ | |
| 7 | |
| 8 #include "vm/allocation.h" | |
| 9 #include "vm/growable_array.h" | |
| 10 #include "vm/object.h" | |
| 11 | |
| 12 namespace dart { | |
| 13 | |
| 14 class Location; | |
| 15 class Value; | |
| 16 | |
| 17 // Represents one deopt instruction, e.g, setup return address, store object, | |
| 18 // store register, etc. The target is defined by instruction's position in | |
| 19 // the deopt-info array. | |
| 20 class DeoptInstr : public ZoneAllocated { | |
| 21 protected: | |
| 22 enum Kind { | |
| 23 kReturnAddress, | |
| 24 kConstant, | |
| 25 kRegister, | |
| 26 kStackSlot, | |
| 27 kPcMarker, | |
| 28 kCallerFp, | |
| 29 kCallerPc, | |
|
siva
2012/08/04 01:21:50
These names don't seem to convey the intent that t
srdjan
2012/08/06 20:09:05
Did a mixture of kSet and kCopy, e.g., kCopyRegist
| |
| 30 }; | |
| 31 | |
| 32 DeoptInstr() {} | |
| 33 | |
| 34 virtual DeoptInstr::Kind kind() const = 0; | |
| 35 virtual intptr_t from_index() const = 0; | |
|
siva
2012/08/04 01:21:50
It seems too heavy weight to have these methods as
srdjan
2012/08/06 20:09:05
Discussed and left it like that. Let's see once th
| |
| 36 | |
| 37 friend class DeoptInfoBuilder; | |
| 38 | |
| 39 public: | |
| 40 static DeoptInstr* Create(intptr_t kind_as_int, intptr_t from_index); | |
| 41 | |
| 42 virtual const char* ToCString() const = 0; | |
|
siva
2012/08/04 01:21:50
The public part should come first in the class rig
srdjan
2012/08/06 20:09:05
Done.
| |
| 43 | |
| 44 private: | |
| 45 DISALLOW_COPY_AND_ASSIGN(DeoptInstr); | |
| 46 }; | |
| 47 | |
| 48 | |
| 49 | |
| 50 // Builds one instance of DeoptInfo. Call AddXXX methods in the order of | |
| 51 // their target, starting wih deoptimized code continuation pc and ending with | |
| 52 // the first argument of the deoptimized code. | |
| 53 class DeoptInfoBuilder : public ValueObject { | |
| 54 public: | |
| 55 // 'object_table' hold all objects referred to by DeoptInstr in | |
|
siva
2012/08/04 01:21:50
holds
srdjan
2012/08/06 20:09:05
Done.
| |
| 56 // all of DeoptInfo instances for a single Code object. | |
|
siva
2012/08/04 01:21:50
all the DeoptInfo instances ....
srdjan
2012/08/06 20:09:05
Done.
| |
| 57 DeoptInfoBuilder(GrowableArray<const Object*>* object_table, | |
| 58 const intptr_t num_args) | |
| 59 : instructions_(), | |
| 60 object_table_(object_table), | |
| 61 num_args_(num_args) {} | |
| 62 | |
| 63 // Will be neeeded for inlined functions, currently trivial. | |
| 64 void AddReturnAddress(const Function& function, intptr_t deopt_id); | |
| 65 // Copy from optimized frame to unoptimized. | |
| 66 void AddCopy(const Location& loc, const Value& value); | |
| 67 void AddPcMarker(const Function& function); | |
| 68 void AddCallerFp(); | |
| 69 void AddCallerPc(); | |
| 70 | |
| 71 RawDeoptInfo* CreateDeoptInfo(); | |
|
siva
2012/08/04 01:21:50
RawDeoptInfo* CreateDeoptInfo() const;
| |
| 72 | |
| 73 private: | |
| 74 intptr_t FindOrAddObjectInTable(const Object& obj) const; | |
| 75 | |
| 76 GrowableArray<DeoptInstr*> instructions_; | |
| 77 GrowableArray<const Object*>* object_table_; | |
| 78 const intptr_t num_args_; | |
| 79 | |
| 80 DISALLOW_COPY_AND_ASSIGN(DeoptInfoBuilder); | |
| 81 }; | |
| 82 | |
| 83 } // namespace dart | |
| 84 | |
| 85 #endif // VM_DEOPT_INSTRUCTIONS_H_ | |
| 86 | |
| OLD | NEW |