Files
sdk/runtime/vm/code_descriptors.h
T
srdjan@google.com caf04303f7 Deoptimization can occur at Dart calls (includes native calls to C) but not at runtime calls. This assumption (verified with Todd and Gilad) simplifies the implementation of lazy deoptimization considerably.
Add flag --deoptimize-alot, which will lazily deoptimize all live optimized frames. Currently only the presence of deoptimization information is checked.

Add kDeoptAfter deoptimization point, which is the continuation for lazy deoptimization, after a call. Rename kDeopt to kDeoptBefore.

Removed a tests case that called into a native without properly setting up a Dart frame (Ok-d by Siva).

Native functions are not optimizable.

TODO: Split deoptimization information from DeoptimizationStubs. Check for redundant PcDescriptor information (what can be merged, especially at calls).
Review URL: https://chromiumcodereview.appspot.com//10885039

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@11642 260f80e4-7a28-3924-810f-c04153c831b5
2012-08-30 18:53:46 +00:00

150 lines
4.2 KiB
C++

// 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_CODE_DESCRIPTORS_H_
#define VM_CODE_DESCRIPTORS_H_
#include "vm/code_generator.h"
#include "vm/globals.h"
#include "vm/growable_array.h"
#include "vm/object.h"
namespace dart {
class DescriptorList : public ZoneAllocated {
public:
struct PcDesc {
intptr_t pc_offset; // PC offset value of the descriptor.
PcDescriptors::Kind kind; // Descriptor kind (kDeopt, kOther).
intptr_t deopt_id; // Deoptimization id.
intptr_t data; // Token position or deopt rason.
intptr_t try_index; // Try block index of PC or deopt array index.
void SetTokenPos(intptr_t value) { data = value; }
intptr_t TokenPos() const { return data; }
void SetDeoptReason(DeoptReasonId value) { data = value; }
DeoptReasonId DeoptReason() const {
return static_cast<DeoptReasonId>(data);
}
};
explicit DescriptorList(intptr_t initial_capacity) : list_(initial_capacity) {
}
~DescriptorList() { }
intptr_t Length() const {
return list_.length();
}
intptr_t PcOffset(int index) const {
return list_[index].pc_offset;
}
PcDescriptors::Kind Kind(int index) const {
return list_[index].kind;
}
intptr_t DeoptId(int index) const {
return list_[index].deopt_id;
}
intptr_t TokenPos(int index) const {
return list_[index].TokenPos();
}
DeoptReasonId DeoptReason(int index) const {
return list_[index].DeoptReason();
}
intptr_t TryIndex(int index) const {
return list_[index].try_index;
}
void AddDescriptor(PcDescriptors::Kind kind,
intptr_t pc_offset,
intptr_t deopt_id,
intptr_t token_index,
intptr_t try_index);
void AddDeoptIndex(intptr_t pc_offset,
intptr_t deopt_id,
DeoptReasonId deopt_reason,
intptr_t deopt_array_index);
RawPcDescriptors* FinalizePcDescriptors(uword entry_point);
private:
GrowableArray<struct PcDesc> list_;
DISALLOW_COPY_AND_ASSIGN(DescriptorList);
};
class StackmapTableBuilder : public ZoneAllocated {
public:
explicit StackmapTableBuilder()
: stack_map_(Stackmap::ZoneHandle()),
list_(GrowableObjectArray::ZoneHandle(
GrowableObjectArray::New(Heap::kOld))) { }
~StackmapTableBuilder() { }
void AddEntry(intptr_t pc_offset,
BitmapBuilder* bitmap,
intptr_t register_bit_count);
bool Verify();
RawArray* FinalizeStackmaps(const Code& code);
private:
intptr_t Length() const { return list_.Length(); }
RawStackmap* MapAt(int index) const;
Stackmap& stack_map_;
GrowableObjectArray& list_;
DISALLOW_COPY_AND_ASSIGN(StackmapTableBuilder);
};
class ExceptionHandlerList : public ZoneAllocated {
public:
struct HandlerDesc {
intptr_t try_index; // Try block index handled by the handler.
intptr_t pc_offset; // Handler PC offset value.
};
ExceptionHandlerList() : list_() {}
intptr_t Length() const {
return list_.length();
}
intptr_t TryIndex(int index) const {
return list_[index].try_index;
}
intptr_t PcOffset(int index) const {
return list_[index].pc_offset;
}
void SetPcOffset(int index, intptr_t handler_pc) {
list_[index].pc_offset = handler_pc;
}
void AddHandler(intptr_t try_index, intptr_t pc_offset) {
struct HandlerDesc data;
data.try_index = try_index;
data.pc_offset = pc_offset;
list_.Add(data);
}
RawExceptionHandlers* FinalizeExceptionHandlers(uword entry_point) {
intptr_t num_handlers = Length();
const ExceptionHandlers& handlers =
ExceptionHandlers::Handle(ExceptionHandlers::New(num_handlers));
for (intptr_t i = 0; i < num_handlers; i++) {
handlers.SetHandlerEntry(i, TryIndex(i), (entry_point + PcOffset(i)));
}
return handlers.raw();
}
private:
GrowableArray<struct HandlerDesc> list_;
DISALLOW_COPY_AND_ASSIGN(ExceptionHandlerList);
};
} // namespace dart
#endif // VM_CODE_DESCRIPTORS_H_