Refactor recording of safepoints.
Refactor SafepointTableBuilder::DefineSafepoint and ARM LCodeGen::RecordSafepoint to use an enum for different kinds of safepoints. This change removes a lot of duplicated code and makes it easier to include new kinds of safepoints in the future. The remaining variants of LCodeGen::RecordSafepoint remain as a convinient way to record common safepoint kinds. BUG=http://code.google.com/p/v8/issues/detail?id=1043 TEST=none Review URL: http://codereview.chromium.org/6341008 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6505 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
33c591b4ad
commit
3141494c3e
@ -736,37 +736,40 @@ void LCodeGen::PopulateDeoptimizationLiteralsWithInlinedFunctions() {
|
||||
}
|
||||
|
||||
|
||||
void LCodeGen::RecordSafepoint(LPointerMap* pointers,
|
||||
int deoptimization_index) {
|
||||
void LCodeGen::RecordSafepoint(
|
||||
LPointerMap* pointers,
|
||||
Safepoint::Kind kind,
|
||||
int arguments,
|
||||
int deoptimization_index) {
|
||||
const ZoneList<LOperand*>* operands = pointers->operands();
|
||||
Safepoint safepoint = safepoints_.DefineSafepoint(masm(),
|
||||
deoptimization_index);
|
||||
kind, arguments, deoptimization_index);
|
||||
for (int i = 0; i < operands->length(); i++) {
|
||||
LOperand* pointer = operands->at(i);
|
||||
if (pointer->IsStackSlot()) {
|
||||
safepoint.DefinePointerSlot(pointer->index());
|
||||
} else if (pointer->IsRegister() && (kind & Safepoint::kWithRegisters)) {
|
||||
safepoint.DefinePointerRegister(ToRegister(pointer));
|
||||
}
|
||||
}
|
||||
if (kind & Safepoint::kWithRegisters) {
|
||||
// Register cp always contains a pointer to the context.
|
||||
safepoint.DefinePointerRegister(cp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LCodeGen::RecordSafepoint(LPointerMap* pointers,
|
||||
int deoptimization_index) {
|
||||
RecordSafepoint(pointers, Safepoint::kSimple, 0, deoptimization_index);
|
||||
}
|
||||
|
||||
|
||||
void LCodeGen::RecordSafepointWithRegisters(LPointerMap* pointers,
|
||||
int arguments,
|
||||
int deoptimization_index) {
|
||||
const ZoneList<LOperand*>* operands = pointers->operands();
|
||||
Safepoint safepoint =
|
||||
safepoints_.DefineSafepointWithRegisters(
|
||||
masm(), arguments, deoptimization_index);
|
||||
for (int i = 0; i < operands->length(); i++) {
|
||||
LOperand* pointer = operands->at(i);
|
||||
if (pointer->IsStackSlot()) {
|
||||
safepoint.DefinePointerSlot(pointer->index());
|
||||
} else if (pointer->IsRegister()) {
|
||||
safepoint.DefinePointerRegister(ToRegister(pointer));
|
||||
}
|
||||
}
|
||||
// Register cp always contains a pointer to the context.
|
||||
safepoint.DefinePointerRegister(cp);
|
||||
RecordSafepoint(pointers, Safepoint::kWithRegisters, arguments,
|
||||
deoptimization_index);
|
||||
}
|
||||
|
||||
|
||||
@ -774,20 +777,8 @@ void LCodeGen::RecordSafepointWithRegistersAndDoubles(
|
||||
LPointerMap* pointers,
|
||||
int arguments,
|
||||
int deoptimization_index) {
|
||||
const ZoneList<LOperand*>* operands = pointers->operands();
|
||||
Safepoint safepoint =
|
||||
safepoints_.DefineSafepointWithRegistersAndDoubles(
|
||||
masm(), arguments, deoptimization_index);
|
||||
for (int i = 0; i < operands->length(); i++) {
|
||||
LOperand* pointer = operands->at(i);
|
||||
if (pointer->IsStackSlot()) {
|
||||
safepoint.DefinePointerSlot(pointer->index());
|
||||
} else if (pointer->IsRegister()) {
|
||||
safepoint.DefinePointerRegister(ToRegister(pointer));
|
||||
}
|
||||
}
|
||||
// Register cp always contains a pointer to the context.
|
||||
safepoint.DefinePointerRegister(cp);
|
||||
RecordSafepoint(pointers, Safepoint::kWithRegistersAndDoubles, arguments,
|
||||
deoptimization_index);
|
||||
}
|
||||
|
||||
|
||||
|
@ -223,6 +223,10 @@ class LCodeGen BASE_EMBEDDED {
|
||||
void DoMathSqrt(LUnaryMathOperation* instr);
|
||||
|
||||
// Support for recording safepoint and position information.
|
||||
void RecordSafepoint(LPointerMap* pointers,
|
||||
Safepoint::Kind kind,
|
||||
int arguments,
|
||||
int deoptimization_index);
|
||||
void RecordSafepoint(LPointerMap* pointers, int deoptimization_index);
|
||||
void RecordSafepointWithRegisters(LPointerMap* pointers,
|
||||
int arguments,
|
||||
|
@ -566,37 +566,40 @@ void LCodeGen::PopulateDeoptimizationLiteralsWithInlinedFunctions() {
|
||||
}
|
||||
|
||||
|
||||
void LCodeGen::RecordSafepoint(LPointerMap* pointers,
|
||||
int deoptimization_index) {
|
||||
void LCodeGen::RecordSafepoint(
|
||||
LPointerMap* pointers,
|
||||
Safepoint::Kind kind,
|
||||
int arguments,
|
||||
int deoptimization_index) {
|
||||
const ZoneList<LOperand*>* operands = pointers->operands();
|
||||
Safepoint safepoint = safepoints_.DefineSafepoint(masm(),
|
||||
deoptimization_index);
|
||||
kind, arguments, deoptimization_index);
|
||||
for (int i = 0; i < operands->length(); i++) {
|
||||
LOperand* pointer = operands->at(i);
|
||||
if (pointer->IsStackSlot()) {
|
||||
safepoint.DefinePointerSlot(pointer->index());
|
||||
} else if (pointer->IsRegister() && (kind & Safepoint::kWithRegisters)) {
|
||||
safepoint.DefinePointerRegister(ToRegister(pointer));
|
||||
}
|
||||
}
|
||||
if (kind & Safepoint::kWithRegisters) {
|
||||
// Register esi always contains a pointer to the context.
|
||||
safepoint.DefinePointerRegister(esi);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LCodeGen::RecordSafepoint(LPointerMap* pointers,
|
||||
int deoptimization_index) {
|
||||
RecordSafepoint(pointers, Safepoint::kSimple, 0, deoptimization_index);
|
||||
}
|
||||
|
||||
|
||||
void LCodeGen::RecordSafepointWithRegisters(LPointerMap* pointers,
|
||||
int arguments,
|
||||
int deoptimization_index) {
|
||||
const ZoneList<LOperand*>* operands = pointers->operands();
|
||||
Safepoint safepoint =
|
||||
safepoints_.DefineSafepointWithRegisters(
|
||||
masm(), arguments, deoptimization_index);
|
||||
for (int i = 0; i < operands->length(); i++) {
|
||||
LOperand* pointer = operands->at(i);
|
||||
if (pointer->IsStackSlot()) {
|
||||
safepoint.DefinePointerSlot(pointer->index());
|
||||
} else if (pointer->IsRegister()) {
|
||||
safepoint.DefinePointerRegister(ToRegister(pointer));
|
||||
}
|
||||
}
|
||||
// Register esi always contains a pointer to the context.
|
||||
safepoint.DefinePointerRegister(esi);
|
||||
RecordSafepoint(pointers, Safepoint::kWithRegisters, arguments,
|
||||
deoptimization_index);
|
||||
}
|
||||
|
||||
|
||||
|
@ -198,6 +198,10 @@ class LCodeGen BASE_EMBEDDED {
|
||||
void DoMathSin(LUnaryMathOperation* instr);
|
||||
|
||||
// Support for recording safepoint and position information.
|
||||
void RecordSafepoint(LPointerMap* pointers,
|
||||
Safepoint::Kind kind,
|
||||
int arguments,
|
||||
int deoptimization_index);
|
||||
void RecordSafepoint(LPointerMap* pointers, int deoptimization_index);
|
||||
void RecordSafepointWithRegisters(LPointerMap* pointers,
|
||||
int arguments,
|
||||
|
@ -117,24 +117,9 @@ void Safepoint::DefinePointerRegister(Register reg) {
|
||||
}
|
||||
|
||||
|
||||
Safepoint SafepointTableBuilder::DefineSafepoint(Assembler* assembler,
|
||||
int deoptimization_index) {
|
||||
ASSERT(deoptimization_index != -1);
|
||||
DeoptimizationInfo pc_and_deoptimization_index;
|
||||
pc_and_deoptimization_index.pc = assembler->pc_offset();
|
||||
pc_and_deoptimization_index.deoptimization_index = deoptimization_index;
|
||||
pc_and_deoptimization_index.pc_after_gap = assembler->pc_offset();
|
||||
pc_and_deoptimization_index.arguments = 0;
|
||||
pc_and_deoptimization_index.has_doubles = false;
|
||||
deoptimization_info_.Add(pc_and_deoptimization_index);
|
||||
indexes_.Add(new ZoneList<int>(8));
|
||||
registers_.Add(NULL);
|
||||
return Safepoint(indexes_.last(), registers_.last());
|
||||
}
|
||||
|
||||
|
||||
Safepoint SafepointTableBuilder::DefineSafepointWithRegisters(
|
||||
Assembler* assembler, int arguments, int deoptimization_index) {
|
||||
Safepoint SafepointTableBuilder::DefineSafepoint(
|
||||
Assembler* assembler, Safepoint::Kind kind, int arguments,
|
||||
int deoptimization_index) {
|
||||
ASSERT(deoptimization_index != -1);
|
||||
ASSERT(arguments >= 0);
|
||||
DeoptimizationInfo pc_and_deoptimization_index;
|
||||
@ -142,30 +127,16 @@ Safepoint SafepointTableBuilder::DefineSafepointWithRegisters(
|
||||
pc_and_deoptimization_index.deoptimization_index = deoptimization_index;
|
||||
pc_and_deoptimization_index.pc_after_gap = assembler->pc_offset();
|
||||
pc_and_deoptimization_index.arguments = arguments;
|
||||
pc_and_deoptimization_index.has_doubles = false;
|
||||
pc_and_deoptimization_index.has_doubles = (kind & Safepoint::kWithDoubles);
|
||||
deoptimization_info_.Add(pc_and_deoptimization_index);
|
||||
indexes_.Add(new ZoneList<int>(8));
|
||||
registers_.Add(new ZoneList<int>(4));
|
||||
registers_.Add((kind & Safepoint::kWithRegisters)
|
||||
? new ZoneList<int>(4)
|
||||
: NULL);
|
||||
return Safepoint(indexes_.last(), registers_.last());
|
||||
}
|
||||
|
||||
|
||||
Safepoint SafepointTableBuilder::DefineSafepointWithRegistersAndDoubles(
|
||||
Assembler* assembler, int arguments, int deoptimization_index) {
|
||||
ASSERT(deoptimization_index != -1);
|
||||
ASSERT(arguments >= 0);
|
||||
DeoptimizationInfo pc_and_deoptimization_index;
|
||||
pc_and_deoptimization_index.pc = assembler->pc_offset();
|
||||
pc_and_deoptimization_index.deoptimization_index = deoptimization_index;
|
||||
pc_and_deoptimization_index.pc_after_gap = assembler->pc_offset();
|
||||
pc_and_deoptimization_index.arguments = arguments;
|
||||
pc_and_deoptimization_index.has_doubles = true;
|
||||
deoptimization_info_.Add(pc_and_deoptimization_index);
|
||||
indexes_.Add(new ZoneList<int>(8));
|
||||
registers_.Add(new ZoneList<int>(4));
|
||||
return Safepoint(indexes_.last(), registers_.last());
|
||||
}
|
||||
|
||||
unsigned SafepointTableBuilder::GetCodeOffset() const {
|
||||
ASSERT(emitted_);
|
||||
return offset_;
|
||||
|
@ -180,6 +180,13 @@ class SafepointTable BASE_EMBEDDED {
|
||||
|
||||
class Safepoint BASE_EMBEDDED {
|
||||
public:
|
||||
typedef enum {
|
||||
kSimple = 0,
|
||||
kWithRegisters = 1 << 0,
|
||||
kWithDoubles = 1 << 1,
|
||||
kWithRegistersAndDoubles = kWithRegisters | kWithDoubles
|
||||
} Kind;
|
||||
|
||||
static const int kNoDeoptimizationIndex =
|
||||
(1 << (SafepointEntry::kDeoptIndexBits)) - 1;
|
||||
|
||||
@ -210,23 +217,7 @@ class SafepointTableBuilder BASE_EMBEDDED {
|
||||
// Define a new safepoint for the current position in the body.
|
||||
Safepoint DefineSafepoint(
|
||||
Assembler* assembler,
|
||||
int deoptimization_index = Safepoint::kNoDeoptimizationIndex);
|
||||
|
||||
// Define a new safepoint with registers on the stack for the
|
||||
// current position in the body and take the number of arguments on
|
||||
// top of the registers into account.
|
||||
Safepoint DefineSafepointWithRegisters(
|
||||
Assembler* assembler,
|
||||
int arguments,
|
||||
int deoptimization_index = Safepoint::kNoDeoptimizationIndex);
|
||||
|
||||
// Define a new safepoint with all double registers and the normal
|
||||
// registers on the stack for the current position in the body and
|
||||
// take the number of arguments on top of the registers into account.
|
||||
// TODO(1043) Rewrite the three SafepointTableBuilder::DefineSafepoint
|
||||
// methods to one method that uses template arguments.
|
||||
Safepoint DefineSafepointWithRegistersAndDoubles(
|
||||
Assembler* assembler,
|
||||
Safepoint::Kind kind,
|
||||
int arguments,
|
||||
int deoptimization_index = Safepoint::kNoDeoptimizationIndex);
|
||||
|
||||
|
@ -495,37 +495,40 @@ void LCodeGen::PopulateDeoptimizationLiteralsWithInlinedFunctions() {
|
||||
}
|
||||
|
||||
|
||||
void LCodeGen::RecordSafepoint(LPointerMap* pointers,
|
||||
int deoptimization_index) {
|
||||
void LCodeGen::RecordSafepoint(
|
||||
LPointerMap* pointers,
|
||||
Safepoint::Kind kind,
|
||||
int arguments,
|
||||
int deoptimization_index) {
|
||||
const ZoneList<LOperand*>* operands = pointers->operands();
|
||||
Safepoint safepoint = safepoints_.DefineSafepoint(masm(),
|
||||
deoptimization_index);
|
||||
kind, arguments, deoptimization_index);
|
||||
for (int i = 0; i < operands->length(); i++) {
|
||||
LOperand* pointer = operands->at(i);
|
||||
if (pointer->IsStackSlot()) {
|
||||
safepoint.DefinePointerSlot(pointer->index());
|
||||
} else if (pointer->IsRegister() && (kind & Safepoint::kWithRegisters)) {
|
||||
safepoint.DefinePointerRegister(ToRegister(pointer));
|
||||
}
|
||||
}
|
||||
if (kind & Safepoint::kWithRegisters) {
|
||||
// Register rsi always contains a pointer to the context.
|
||||
safepoint.DefinePointerRegister(rsi);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LCodeGen::RecordSafepoint(LPointerMap* pointers,
|
||||
int deoptimization_index) {
|
||||
RecordSafepoint(pointers, Safepoint::kSimple, 0, deoptimization_index);
|
||||
}
|
||||
|
||||
|
||||
void LCodeGen::RecordSafepointWithRegisters(LPointerMap* pointers,
|
||||
int arguments,
|
||||
int deoptimization_index) {
|
||||
const ZoneList<LOperand*>* operands = pointers->operands();
|
||||
Safepoint safepoint =
|
||||
safepoints_.DefineSafepointWithRegisters(
|
||||
masm(), arguments, deoptimization_index);
|
||||
for (int i = 0; i < operands->length(); i++) {
|
||||
LOperand* pointer = operands->at(i);
|
||||
if (pointer->IsStackSlot()) {
|
||||
safepoint.DefinePointerSlot(pointer->index());
|
||||
} else if (pointer->IsRegister()) {
|
||||
safepoint.DefinePointerRegister(ToRegister(pointer));
|
||||
}
|
||||
}
|
||||
// Register rsi always contains a pointer to the context.
|
||||
safepoint.DefinePointerRegister(rsi);
|
||||
RecordSafepoint(pointers, Safepoint::kWithRegisters, arguments,
|
||||
deoptimization_index);
|
||||
}
|
||||
|
||||
|
||||
|
@ -192,6 +192,10 @@ class LCodeGen BASE_EMBEDDED {
|
||||
void DoMathSin(LUnaryMathOperation* instr);
|
||||
|
||||
// Support for recording safepoint and position information.
|
||||
void RecordSafepoint(LPointerMap* pointers,
|
||||
Safepoint::Kind kind,
|
||||
int arguments,
|
||||
int deoptimization_index);
|
||||
void RecordSafepoint(LPointerMap* pointers, int deoptimization_index);
|
||||
void RecordSafepointWithRegisters(LPointerMap* pointers,
|
||||
int arguments,
|
||||
|
Loading…
Reference in New Issue
Block a user