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

Unified Diff: runtime/vm/deopt_instructions.h

Issue 10823131: Add deopt info to code object and print it (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
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_
+

Powered by Google App Engine
This is Rietveld 408576698