Reviewers: Jakob,
Description:
Wire up profiling budget to the Code object.
[email protected]
BUG=
Please review this at https://codereview.chromium.org/23747003/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/arm/full-codegen-arm.cc
M src/full-codegen.h
M src/full-codegen.cc
M src/ia32/full-codegen-ia32.cc
M src/mips/full-codegen-mips.cc
M src/objects-inl.h
M src/objects.h
M src/x64/full-codegen-x64.cc
Index: src/arm/full-codegen-arm.cc
diff --git a/src/arm/full-codegen-arm.cc b/src/arm/full-codegen-arm.cc
index
34002488c19b88a025663acab36bd5ec1f2e21e6..940093512b4b3e800755c5e0b2dc2bce9be9a450
100644
--- a/src/arm/full-codegen-arm.cc
+++ b/src/arm/full-codegen-arm.cc
@@ -129,7 +129,7 @@ void FullCodeGenerator::Generate() {
CompilationInfo* info = info_;
handler_table_ =
isolate()->factory()->NewFixedArray(function()->handler_count(),
TENURED);
- profiling_counter_ = isolate()->factory()->NewCell(
+ profiling_budget_ = isolate()->factory()->NewCell(
Handle<Smi>(Smi::FromInt(FLAG_interrupt_budget), isolate()));
SetFunctionPosition(function());
Comment cmnt(masm_, "[ function compiled by full code generator");
@@ -327,7 +327,7 @@ void FullCodeGenerator::ClearAccumulator() {
void FullCodeGenerator::EmitProfilingCounterDecrement(int delta) {
- __ mov(r2, Operand(profiling_counter_));
+ __ mov(r2, Operand(profiling_budget_));
__ ldr(r3, FieldMemOperand(r2, Cell::kValueOffset));
__ sub(r3, r3, Operand(Smi::FromInt(delta)), SetCC);
__ str(r3, FieldMemOperand(r2, Cell::kValueOffset));
@@ -344,7 +344,7 @@ void FullCodeGenerator::EmitProfilingCounterReset() {
// Detect debug break requests as soon as possible.
reset_value = FLAG_interrupt_budget >> 4;
}
- __ mov(r2, Operand(profiling_counter_));
+ __ mov(r2, Operand(profiling_budget_));
__ mov(r3, Operand(Smi::FromInt(reset_value)));
__ str(r3, FieldMemOperand(r2, Cell::kValueOffset));
}
Index: src/full-codegen.cc
diff --git a/src/full-codegen.cc b/src/full-codegen.cc
index
8846107acf8e90db9e631ca24347f3d5c5d60d57..27bce08a4d80d618115976b15d21d48cc724a6ad
100644
--- a/src/full-codegen.cc
+++ b/src/full-codegen.cc
@@ -338,6 +338,7 @@ bool FullCodeGenerator::MakeCode(CompilationInfo* info)
{
cgen.PopulateDeoptimizationData(code);
cgen.PopulateTypeFeedbackInfo(code);
cgen.PopulateTypeFeedbackCells(code);
+ cgen.SetProfilingBudgetCell(code);
code->set_has_deoptimization_support(info->HasDeoptimizationSupport());
code->set_handler_table(*cgen.handler_table());
#ifdef ENABLE_DEBUGGER_SUPPORT
@@ -434,6 +435,11 @@ void
FullCodeGenerator::PopulateTypeFeedbackCells(Handle<Code> code) {
}
+void FullCodeGenerator::SetProfilingBudgetCell(Handle<Code> code) {
+ ASSERT(!profiling_budget_.is_null());
+ code->set_profiling_budget(*profiling_budget_);
+}
+
void FullCodeGenerator::PrepareForBailout(Expression* node, State state) {
PrepareForBailoutForId(node->id(), state);
Index: src/full-codegen.h
diff --git a/src/full-codegen.h b/src/full-codegen.h
index
af63aedfbff2e4e6dafc0485b37191d8862a6104..43d57d33d204ab3a3f9c3877a830e8bf1c689b28
100644
--- a/src/full-codegen.h
+++ b/src/full-codegen.h
@@ -100,6 +100,7 @@ class FullCodeGenerator: public AstVisitor {
? info->function()->ast_node_count() : 0,
info->zone()),
ic_total_count_(0),
+ profiling_budget_(),
zone_(info->zone()) {
Initialize();
}
@@ -695,6 +696,7 @@ class FullCodeGenerator: public AstVisitor {
void PopulateDeoptimizationData(Handle<Code> code);
void PopulateTypeFeedbackInfo(Handle<Code> code);
void PopulateTypeFeedbackCells(Handle<Code> code);
+ void SetProfilingBudgetCell(Handle<Code> code);
Handle<FixedArray> handler_table() { return handler_table_; }
@@ -907,7 +909,7 @@ class FullCodeGenerator: public AstVisitor {
ZoneList<TypeFeedbackCellEntry> type_feedback_cells_;
int ic_total_count_;
Handle<FixedArray> handler_table_;
- Handle<Cell> profiling_counter_;
+ Handle<Cell> profiling_budget_;
bool generate_debug_code_;
Zone* zone_;
Index: src/ia32/full-codegen-ia32.cc
diff --git a/src/ia32/full-codegen-ia32.cc b/src/ia32/full-codegen-ia32.cc
index
775a1688c764a4668d7f7c15b247e971041058ee..c1530c5c2f41f055779ef132fa98a9a86f108cf8
100644
--- a/src/ia32/full-codegen-ia32.cc
+++ b/src/ia32/full-codegen-ia32.cc
@@ -119,7 +119,7 @@ void FullCodeGenerator::Generate() {
CompilationInfo* info = info_;
handler_table_ =
isolate()->factory()->NewFixedArray(function()->handler_count(),
TENURED);
- profiling_counter_ = isolate()->factory()->NewCell(
+ profiling_budget_ = isolate()->factory()->NewCell(
Handle<Smi>(Smi::FromInt(FLAG_interrupt_budget), isolate()));
SetFunctionPosition(function());
Comment cmnt(masm_, "[ function compiled by full code generator");
@@ -315,7 +315,7 @@ void FullCodeGenerator::ClearAccumulator() {
void FullCodeGenerator::EmitProfilingCounterDecrement(int delta) {
- __ mov(ebx, Immediate(profiling_counter_));
+ __ mov(ebx, Immediate(profiling_budget_));
__ sub(FieldOperand(ebx, Cell::kValueOffset),
Immediate(Smi::FromInt(delta)));
}
@@ -327,7 +327,7 @@ void FullCodeGenerator::EmitProfilingCounterReset() {
// Self-optimization is a one-off thing: if it fails, don't try again.
reset_value = Smi::kMaxValue;
}
- __ mov(ebx, Immediate(profiling_counter_));
+ __ mov(ebx, Immediate(profiling_budget_));
__ mov(FieldOperand(ebx, Cell::kValueOffset),
Immediate(Smi::FromInt(reset_value)));
}
Index: src/mips/full-codegen-mips.cc
diff --git a/src/mips/full-codegen-mips.cc b/src/mips/full-codegen-mips.cc
index
d59820f727bc084c5857460e52a0251356e1e7fe..1783334ec679f69be48ea197750629107bdbc923
100644
--- a/src/mips/full-codegen-mips.cc
+++ b/src/mips/full-codegen-mips.cc
@@ -138,7 +138,7 @@ void FullCodeGenerator::Generate() {
CompilationInfo* info = info_;
handler_table_ =
isolate()->factory()->NewFixedArray(function()->handler_count(),
TENURED);
- profiling_counter_ = isolate()->factory()->NewCell(
+ profiling_budget_ = isolate()->factory()->NewCell(
Handle<Smi>(Smi::FromInt(FLAG_interrupt_budget), isolate()));
SetFunctionPosition(function());
Comment cmnt(masm_, "[ function compiled by full code generator");
@@ -326,7 +326,7 @@ void FullCodeGenerator::ClearAccumulator() {
void FullCodeGenerator::EmitProfilingCounterDecrement(int delta) {
- __ li(a2, Operand(profiling_counter_));
+ __ li(a2, Operand(profiling_budget_));
__ lw(a3, FieldMemOperand(a2, Cell::kValueOffset));
__ Subu(a3, a3, Operand(Smi::FromInt(delta)));
__ sw(a3, FieldMemOperand(a2, Cell::kValueOffset));
@@ -343,7 +343,7 @@ void FullCodeGenerator::EmitProfilingCounterReset() {
// Detect debug break requests as soon as possible.
reset_value = FLAG_interrupt_budget >> 4;
}
- __ li(a2, Operand(profiling_counter_));
+ __ li(a2, Operand(profiling_budget_));
__ li(a3, Operand(Smi::FromInt(reset_value)));
__ sw(a3, FieldMemOperand(a2, Cell::kValueOffset));
}
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index
77b4e3816cd064e3004cedf13f244580c912a5b6..dd6eede22a34cd36bfcbae838a343e26b2a87b10
100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -5355,9 +5355,15 @@ Object** Code::code_to_deoptimize_link_slot() {
ACCESSORS(Code, gc_metadata, Object, kGCMetadataOffset)
+ACCESSORS(Code, profiling_budget, Cell, kProfilingBudgetOffset)
INT_ACCESSORS(Code, ic_age, kICAgeOffset)
+void Code::ResetProfilingBudget(int value) {
+ profiling_budget()->set_value(Smi::FromInt(value));
+}
+
+
byte* Code::instruction_start() {
return FIELD_ADDR(this, kHeaderSize);
}
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index
040664dc06641f4df917320456564869c86e8242..dc1cb20d767ce108c7c14b3fe30475f9d99879b9
100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -4872,6 +4872,11 @@ class Code: public HeapObject {
// it is only used by the garbage collector itself.
DECL_ACCESSORS(gc_metadata, Object)
+ // Profiling budget counter to govern when to invoke the runtime
profiler.
+ DECL_ACCESSORS(profiling_budget, Cell)
+
+ inline void ResetProfilingBudget(int value);
+
// [ic_age]: Inline caching age: the value of the Heap::global_ic_age
// at the moment when this object was created.
inline void set_ic_age(int count);
@@ -5185,8 +5190,8 @@ class Code: public HeapObject {
static const int kTypeFeedbackInfoOffset =
kDeoptimizationDataOffset + kPointerSize;
static const int kGCMetadataOffset = kTypeFeedbackInfoOffset +
kPointerSize;
- static const int kICAgeOffset =
- kGCMetadataOffset + kPointerSize;
+ static const int kProfilingBudgetOffset = kGCMetadataOffset +
kPointerSize;
+ static const int kICAgeOffset = kProfilingBudgetOffset + kPointerSize;
static const int kFlagsOffset = kICAgeOffset + kIntSize;
static const int kKindSpecificFlags1Offset = kFlagsOffset + kIntSize;
static const int kKindSpecificFlags2Offset =
Index: src/x64/full-codegen-x64.cc
diff --git a/src/x64/full-codegen-x64.cc b/src/x64/full-codegen-x64.cc
index
04005ac30af4103e3ba8808a390770bec44166b9..ff41fdabcf284a178ad7c51f7faafd9124bf2ffb
100644
--- a/src/x64/full-codegen-x64.cc
+++ b/src/x64/full-codegen-x64.cc
@@ -118,7 +118,7 @@ void FullCodeGenerator::Generate() {
CompilationInfo* info = info_;
handler_table_ =
isolate()->factory()->NewFixedArray(function()->handler_count(),
TENURED);
- profiling_counter_ = isolate()->factory()->NewCell(
+ profiling_budget_ = isolate()->factory()->NewCell(
Handle<Smi>(Smi::FromInt(FLAG_interrupt_budget), isolate()));
SetFunctionPosition(function());
Comment cmnt(masm_, "[ function compiled by full code generator");
@@ -307,7 +307,7 @@ void FullCodeGenerator::ClearAccumulator() {
void FullCodeGenerator::EmitProfilingCounterDecrement(int delta) {
- __ movq(rbx, profiling_counter_, RelocInfo::EMBEDDED_OBJECT);
+ __ movq(rbx, profiling_budget_, RelocInfo::EMBEDDED_OBJECT);
__ SmiAddConstant(FieldOperand(rbx, Cell::kValueOffset),
Smi::FromInt(-delta));
}
@@ -319,7 +319,7 @@ void FullCodeGenerator::EmitProfilingCounterReset() {
// Self-optimization is a one-off thing; if it fails, don't try again.
reset_value = Smi::kMaxValue;
}
- __ movq(rbx, profiling_counter_, RelocInfo::EMBEDDED_OBJECT);
+ __ movq(rbx, profiling_budget_, RelocInfo::EMBEDDED_OBJECT);
__ movq(kScratchRegister,
reinterpret_cast<uint64_t>(Smi::FromInt(reset_value)),
RelocInfo::NONE64);
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.