Add write barrier helper for code patching and refactor stack check patching.
The new helper avoids expensive FindCodeForInnerPointer invocation when we have the host code object available. It is used when patching stack checks. Also some comments on the ARM platform are corrected. Review URL: http://codereview.chromium.org/8330021 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9687 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
75dc771098
commit
e8a26d1eb1
@ -100,7 +100,6 @@ void Deoptimizer::DeoptimizeFunction(JSFunction* function) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
// Destroy the code which is not supposed to be run again.
|
||||
int instructions =
|
||||
@ -178,16 +177,13 @@ void Deoptimizer::PatchStackCheckCodeAt(Code* unoptimized_code,
|
||||
Memory::uint32_at(stack_check_address_pointer) =
|
||||
reinterpret_cast<uint32_t>(replacement_code->entry());
|
||||
|
||||
RelocInfo rinfo(pc_after - 2 * kInstrSize,
|
||||
RelocInfo::CODE_TARGET,
|
||||
0,
|
||||
unoptimized_code);
|
||||
unoptimized_code->GetHeap()->incremental_marking()->RecordWriteIntoCode(
|
||||
unoptimized_code, &rinfo, replacement_code);
|
||||
unoptimized_code->GetHeap()->incremental_marking()->RecordCodeTargetPatch(
|
||||
unoptimized_code, pc_after - 2 * kInstrSize, replacement_code);
|
||||
}
|
||||
|
||||
|
||||
void Deoptimizer::RevertStackCheckCodeAt(Address pc_after,
|
||||
void Deoptimizer::RevertStackCheckCodeAt(Code* unoptimized_code,
|
||||
Address pc_after,
|
||||
Code* check_code,
|
||||
Code* replacement_code) {
|
||||
const int kInstrSize = Assembler::kInstrSize;
|
||||
@ -209,8 +205,8 @@ void Deoptimizer::RevertStackCheckCodeAt(Address pc_after,
|
||||
Memory::uint32_at(stack_check_address_pointer) =
|
||||
reinterpret_cast<uint32_t>(check_code->entry());
|
||||
|
||||
check_code->GetHeap()->incremental_marking()->
|
||||
RecordCodeTargetPatch(pc_after - 2 * kInstrSize, check_code);
|
||||
check_code->GetHeap()->incremental_marking()->RecordCodeTargetPatch(
|
||||
unoptimized_code, pc_after - 2 * kInstrSize, check_code);
|
||||
}
|
||||
|
||||
|
||||
@ -727,7 +723,6 @@ void Deoptimizer::EntryGenerator::Generate() {
|
||||
__ ldr(r3, MemOperand(r2, FrameDescription::frame_size_offset()));
|
||||
__ bind(&inner_push_loop);
|
||||
__ sub(r3, r3, Operand(sizeof(uint32_t)));
|
||||
// __ add(r6, r2, Operand(r3, LSL, 1));
|
||||
__ add(r6, r2, Operand(r3));
|
||||
__ ldr(r7, MemOperand(r6, FrameDescription::frame_content_offset()));
|
||||
__ push(r7);
|
||||
|
@ -206,7 +206,7 @@ class LCodeGen BASE_EMBEDDED {
|
||||
LInstruction* instr);
|
||||
|
||||
// Generate a direct call to a known function. Expects the function
|
||||
// to be in edi.
|
||||
// to be in r1.
|
||||
void CallKnownFunction(Handle<JSFunction> function,
|
||||
int arity,
|
||||
LInstruction* instr,
|
||||
|
@ -1007,7 +1007,10 @@ void Deoptimizer::RevertStackCheckCode(Code* unoptimized_code,
|
||||
for (uint32_t i = 0; i < table_length; ++i) {
|
||||
uint32_t pc_offset = Memory::uint32_at(stack_check_cursor + kIntSize);
|
||||
Address pc_after = unoptimized_code->instruction_start() + pc_offset;
|
||||
RevertStackCheckCodeAt(pc_after, check_code, replacement_code);
|
||||
RevertStackCheckCodeAt(unoptimized_code,
|
||||
pc_after,
|
||||
check_code,
|
||||
replacement_code);
|
||||
stack_check_cursor += 2 * kIntSize;
|
||||
}
|
||||
}
|
||||
|
@ -186,7 +186,8 @@ class Deoptimizer : public Malloced {
|
||||
|
||||
// Change all patched stack guard checks in the unoptimized code
|
||||
// back to a normal stack guard check.
|
||||
static void RevertStackCheckCodeAt(Address pc_after,
|
||||
static void RevertStackCheckCodeAt(Code* unoptimized_code,
|
||||
Address pc_after,
|
||||
Code* check_code,
|
||||
Code* replacement_code);
|
||||
|
||||
|
@ -258,16 +258,13 @@ void Deoptimizer::PatchStackCheckCodeAt(Code* unoptimized_code,
|
||||
Assembler::set_target_address_at(call_target_address,
|
||||
replacement_code->entry());
|
||||
|
||||
RelocInfo rinfo(call_target_address,
|
||||
RelocInfo::CODE_TARGET,
|
||||
0,
|
||||
unoptimized_code);
|
||||
unoptimized_code->GetHeap()->incremental_marking()->RecordWriteIntoCode(
|
||||
unoptimized_code, &rinfo, replacement_code);
|
||||
unoptimized_code->GetHeap()->incremental_marking()->RecordCodeTargetPatch(
|
||||
unoptimized_code, call_target_address, replacement_code);
|
||||
}
|
||||
|
||||
|
||||
void Deoptimizer::RevertStackCheckCodeAt(Address pc_after,
|
||||
void Deoptimizer::RevertStackCheckCodeAt(Code* unoptimized_code,
|
||||
Address pc_after,
|
||||
Code* check_code,
|
||||
Code* replacement_code) {
|
||||
Address call_target_address = pc_after - kIntSize;
|
||||
@ -283,8 +280,8 @@ void Deoptimizer::RevertStackCheckCodeAt(Address pc_after,
|
||||
Assembler::set_target_address_at(call_target_address,
|
||||
check_code->entry());
|
||||
|
||||
check_code->GetHeap()->incremental_marking()->
|
||||
RecordCodeTargetPatch(call_target_address, check_code);
|
||||
check_code->GetHeap()->incremental_marking()->RecordCodeTargetPatch(
|
||||
unoptimized_code, call_target_address, check_code);
|
||||
}
|
||||
|
||||
|
||||
|
@ -87,6 +87,16 @@ void IncrementalMarking::RecordWriteForEvacuationFromCode(HeapObject* obj,
|
||||
}
|
||||
|
||||
|
||||
void IncrementalMarking::RecordCodeTargetPatch(Code* host,
|
||||
Address pc,
|
||||
HeapObject* value) {
|
||||
if (IsMarking()) {
|
||||
RelocInfo rinfo(pc, RelocInfo::CODE_TARGET, 0, host);
|
||||
RecordWriteIntoCode(host, &rinfo, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void IncrementalMarking::RecordCodeTargetPatch(Address pc, HeapObject* value) {
|
||||
if (IsMarking()) {
|
||||
Code* host = heap_->isolate()->inner_pointer_to_code_cache()->
|
||||
|
@ -127,6 +127,7 @@ class IncrementalMarking {
|
||||
inline void RecordWriteIntoCode(HeapObject* obj,
|
||||
RelocInfo* rinfo,
|
||||
Object* value);
|
||||
void RecordCodeTargetPatch(Code* host, Address pc, HeapObject* value);
|
||||
void RecordCodeTargetPatch(Address pc, HeapObject* value);
|
||||
void RecordWriteOfCodeEntry(JSFunction* host, Object** slot, Code* value);
|
||||
|
||||
|
@ -258,16 +258,13 @@ void Deoptimizer::PatchStackCheckCodeAt(Code* unoptimized_code,
|
||||
Assembler::set_target_address_at(call_target_address,
|
||||
replacement_code->entry());
|
||||
|
||||
RelocInfo rinfo(call_target_address,
|
||||
RelocInfo::CODE_TARGET,
|
||||
0,
|
||||
unoptimized_code);
|
||||
unoptimized_code->GetHeap()->incremental_marking()->RecordWriteIntoCode(
|
||||
unoptimized_code, &rinfo, replacement_code);
|
||||
unoptimized_code->GetHeap()->incremental_marking()->RecordCodeTargetPatch(
|
||||
unoptimized_code, call_target_address, replacement_code);
|
||||
}
|
||||
|
||||
|
||||
void Deoptimizer::RevertStackCheckCodeAt(Address pc_after,
|
||||
void Deoptimizer::RevertStackCheckCodeAt(Code* unoptimized_code,
|
||||
Address pc_after,
|
||||
Code* check_code,
|
||||
Code* replacement_code) {
|
||||
Address call_target_address = pc_after - kIntSize;
|
||||
@ -282,8 +279,9 @@ void Deoptimizer::RevertStackCheckCodeAt(Address pc_after,
|
||||
*(call_target_address - 2) = 0x07; // offset
|
||||
Assembler::set_target_address_at(call_target_address,
|
||||
check_code->entry());
|
||||
check_code->GetHeap()->incremental_marking()->
|
||||
RecordCodeTargetPatch(call_target_address, check_code);
|
||||
|
||||
check_code->GetHeap()->incremental_marking()->RecordCodeTargetPatch(
|
||||
unoptimized_code, call_target_address, check_code);
|
||||
}
|
||||
|
||||
|
||||
|
@ -190,9 +190,8 @@ class LCodeGen BASE_EMBEDDED {
|
||||
int argc,
|
||||
LInstruction* instr);
|
||||
|
||||
|
||||
// Generate a direct call to a known function. Expects the function
|
||||
// to be in edi.
|
||||
// to be in rdi.
|
||||
void CallKnownFunction(Handle<JSFunction> function,
|
||||
int arity,
|
||||
LInstruction* instr,
|
||||
|
Loading…
Reference in New Issue
Block a user