Chromium Code Reviews| Index: runtime/vm/deopt_instructions.h |
| =================================================================== |
| --- runtime/vm/deopt_instructions.h (revision 0) |
| +++ runtime/vm/deopt_instructions.h (revision 0) |
| @@ -0,0 +1,86 @@ |
| +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +#ifndef VM_DEOPT_INSTRUCTIONS_H_ |
| +#define VM_DEOPT_INSTRUCTIONS_H_ |
| + |
| +#include "vm/allocation.h" |
| +#include "vm/growable_array.h" |
| +#include "vm/object.h" |
| + |
| +namespace dart { |
| + |
| +class Location; |
| +class Value; |
| + |
| +// Represents one deopt instruction, e.g, setup return address, store object, |
| +// store register, etc. The target is defined by instruction's position in |
| +// the deopt-info array. |
| +class DeoptInstr : public ZoneAllocated { |
| + protected: |
| + enum Kind { |
| + kReturnAddress, |
| + kConstant, |
| + kRegister, |
| + kStackSlot, |
| + kPcMarker, |
| + kCallerFp, |
| + 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
|
| + }; |
| + |
| + DeoptInstr() {} |
| + |
| + virtual DeoptInstr::Kind kind() const = 0; |
| + 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
|
| + |
| + friend class DeoptInfoBuilder; |
| + |
| + public: |
| + static DeoptInstr* Create(intptr_t kind_as_int, intptr_t from_index); |
| + |
| + 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.
|
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(DeoptInstr); |
| +}; |
| + |
| + |
| + |
| +// Builds one instance of DeoptInfo. Call AddXXX methods in the order of |
| +// their target, starting wih deoptimized code continuation pc and ending with |
| +// the first argument of the deoptimized code. |
| +class DeoptInfoBuilder : public ValueObject { |
| + public: |
| + // '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.
|
| + // 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.
|
| + DeoptInfoBuilder(GrowableArray<const Object*>* object_table, |
| + const intptr_t num_args) |
| + : instructions_(), |
| + object_table_(object_table), |
| + num_args_(num_args) {} |
| + |
| + // Will be neeeded for inlined functions, currently trivial. |
| + void AddReturnAddress(const Function& function, intptr_t deopt_id); |
| + // Copy from optimized frame to unoptimized. |
| + void AddCopy(const Location& loc, const Value& value); |
| + void AddPcMarker(const Function& function); |
| + void AddCallerFp(); |
| + void AddCallerPc(); |
| + |
| + RawDeoptInfo* CreateDeoptInfo(); |
|
siva
2012/08/04 01:21:50
RawDeoptInfo* CreateDeoptInfo() const;
|
| + |
| + private: |
| + intptr_t FindOrAddObjectInTable(const Object& obj) const; |
| + |
| + GrowableArray<DeoptInstr*> instructions_; |
| + GrowableArray<const Object*>* object_table_; |
| + const intptr_t num_args_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(DeoptInfoBuilder); |
| +}; |
| + |
| +} // namespace dart |
| + |
| +#endif // VM_DEOPT_INSTRUCTIONS_H_ |
| + |