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

Unified Diff: src/ia32/codegen-ia32.cc

Issue 23480031: Enable preaging of code objects when --optimize-for-size. (Closed) Base URL: https://v8.googlecode.com/svn/trunk
Patch Set: Limit to pre-age patch. Created 7 years, 3 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: src/ia32/codegen-ia32.cc
diff --git a/src/ia32/codegen-ia32.cc b/src/ia32/codegen-ia32.cc
index 9385423578ae0aeeeeee6d63ab9be2be50b4c78a..b6e2b3519056a183c32fe1fe1c59bee8abfd4b2a 100644
--- a/src/ia32/codegen-ia32.cc
+++ b/src/ia32/codegen-ia32.cc
@@ -1120,19 +1120,20 @@ void MathExpGenerator::EmitMathExp(MacroAssembler* masm,
#undef __
-static const int kNoCodeAgeSequenceLength = 5;
+static const int kCodeAgeSequenceLength = 6;
static byte* GetNoCodeAgeSequence(uint32_t* length) {
static bool initialized = false;
- static byte sequence[kNoCodeAgeSequenceLength];
- *length = kNoCodeAgeSequenceLength;
+ static byte sequence[kCodeAgeSequenceLength];
+ *length = kCodeAgeSequenceLength;
if (!initialized) {
// The sequence of instructions that is patched out for aging code is the
// following boilerplate stack-building prologue that is found both in
// FUNCTION and OPTIMIZED_FUNCTION code:
- CodePatcher patcher(sequence, kNoCodeAgeSequenceLength);
+ CodePatcher patcher(sequence, kCodeAgeSequenceLength);
patcher.masm()->push(ebp);
patcher.masm()->mov(ebp, esp);
+ patcher.masm()->nop();
patcher.masm()->push(esi);
patcher.masm()->push(edi);
initialized = true;
@@ -1141,11 +1142,40 @@ static byte* GetNoCodeAgeSequence(uint32_t* length) {
}
+static byte* GetPreAgedCodeAgeSequence(uint32_t* length) {
+ static bool initialized = false;
+ static byte sequence[kCodeAgeSequenceLength];
+ *length = kCodeAgeSequenceLength;
+ if (!initialized) {
+ // If code is "pre-aged" then this sequence of instructions is found in the
+ // boilerplate stack-building prologue that is found in FUNCTIONS and
+ // OPTIMIZED_FUNCTION code, and is patched out for code aging.
+ CodePatcher patcher(sequence, kCodeAgeSequenceLength);
+ patcher.masm()->push(ebp);
+ patcher.masm()->mov(ebp, esp);
+ patcher.masm()->push(esi);
+ patcher.masm()->nop();
+ patcher.masm()->push(edi);
+ initialized = true;
+ }
+ return sequence;
+}
+
+
bool Code::IsYoungSequence(byte* sequence) {
uint32_t young_length;
byte* young_sequence = GetNoCodeAgeSequence(&young_length);
bool result = (!memcmp(sequence, young_sequence, young_length));
- ASSERT(result || *sequence == kCallOpcode);
+ ASSERT(result || *sequence == kCallOpcode || IsPreAgedSequence(sequence));
+ return result;
+}
+
+
+bool Code::IsPreAgedSequence(byte* sequence) {
+ uint32_t pre_aged_length;
+ byte* pre_aged_sequence = GetPreAgedCodeAgeSequence(&pre_aged_length);
+ bool result = (!memcmp(sequence, pre_aged_sequence, pre_aged_length));
+ ASSERT(result || *sequence == kCallOpcode || IsYoungSequence(sequence));
return result;
}
@@ -1155,6 +1185,9 @@ void Code::GetCodeAgeAndParity(byte* sequence, Age* age,
if (IsYoungSequence(sequence)) {
*age = kNoAge;
*parity = NO_MARKING_PARITY;
+ } else if (IsPreAgedSequence(sequence)) {
+ *age = kPreAgedCodeAge;
+ *parity = NO_MARKING_PARITY;
} else {
sequence++; // Skip the kCallOpcode byte
Address target_address = sequence + *reinterpret_cast<int*>(sequence) +
@@ -1178,6 +1211,7 @@ void Code::PatchPlatformCodeAge(Isolate* isolate,
Code* stub = GetCodeAgeStub(isolate, age, parity);
CodePatcher patcher(sequence, young_length);
patcher.masm()->call(stub->instruction_start(), RelocInfo::NONE32);
+ patcher.masm()->nop();
}
}
« no previous file with comments | « src/assembler.cc ('k') | src/ia32/full-codegen-ia32.cc » ('j') | src/ia32/full-codegen-ia32.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698