Use correct call size for PredictableCodeSizeScopes.

If out-of-line constant pool is enabled, then calls can be 3 instructions
rather than 2.  Fix the hard-coded PredictableCodeSizeScopes values with values
based on CallSize instead.

R=ulan@chromium.org

Review URL: https://codereview.chromium.org/226503003

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20577 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
rmcilroy@chromium.org 2014-04-08 12:28:28 +00:00
parent c9d8b90f1b
commit c8df5f42a2
6 changed files with 32 additions and 7 deletions

View File

@ -4951,8 +4951,9 @@ void StubFailureTrampolineStub::Generate(MacroAssembler* masm) {
void ProfileEntryHookStub::MaybeCallEntryHook(MacroAssembler* masm) { void ProfileEntryHookStub::MaybeCallEntryHook(MacroAssembler* masm) {
if (masm->isolate()->function_entry_hook() != NULL) { if (masm->isolate()->function_entry_hook() != NULL) {
PredictableCodeSizeScope predictable(masm, 4 * Assembler::kInstrSize);
ProfileEntryHookStub stub; ProfileEntryHookStub stub;
int code_size = masm->CallStubSize(&stub) + 2 * Assembler::kInstrSize;
PredictableCodeSizeScope predictable(masm, code_size);
__ push(lr); __ push(lr);
__ CallStub(&stub); __ CallStub(&stub);
__ pop(lr); __ pop(lr);

View File

@ -128,8 +128,10 @@ static void EmitStackCheck(MacroAssembler* masm_,
__ LoadRoot(stack_limit_scratch, index); __ LoadRoot(stack_limit_scratch, index);
__ cmp(scratch, Operand(stack_limit_scratch)); __ cmp(scratch, Operand(stack_limit_scratch));
__ b(hs, &ok); __ b(hs, &ok);
PredictableCodeSizeScope predictable(masm_, 2 * Assembler::kInstrSize); Handle<Code> stack_check = isolate->builtins()->StackCheck();
__ Call(isolate->builtins()->StackCheck(), RelocInfo::CODE_TARGET); PredictableCodeSizeScope predictable(masm_,
masm_->CallSize(stack_check, RelocInfo::CODE_TARGET));
__ Call(stack_check, RelocInfo::CODE_TARGET);
__ bind(&ok); __ bind(&ok);
} }

View File

@ -714,6 +714,16 @@ void LCodeGen::AddToTranslation(LEnvironment* environment,
} }
int LCodeGen::CallCodeSize(Handle<Code> code, RelocInfo::Mode mode) {
int size = masm()->CallSize(code, mode);
if (code->kind() == Code::BINARY_OP_IC ||
code->kind() == Code::COMPARE_IC) {
size += Assembler::kInstrSize; // extra nop() added in CallCodeGeneric.
}
return size;
}
void LCodeGen::CallCode(Handle<Code> code, void LCodeGen::CallCode(Handle<Code> code,
RelocInfo::Mode mode, RelocInfo::Mode mode,
LInstruction* instr, LInstruction* instr,
@ -5672,12 +5682,12 @@ void LCodeGen::DoStackCheck(LStackCheck* instr) {
__ LoadRoot(ip, Heap::kStackLimitRootIndex); __ LoadRoot(ip, Heap::kStackLimitRootIndex);
__ cmp(sp, Operand(ip)); __ cmp(sp, Operand(ip));
__ b(hs, &done); __ b(hs, &done);
PredictableCodeSizeScope predictable(masm_, 2 * Assembler::kInstrSize); Handle<Code> stack_check = isolate()->builtins()->StackCheck();
PredictableCodeSizeScope predictable(masm(),
CallCodeSize(stack_check, RelocInfo::CODE_TARGET));
ASSERT(instr->context()->IsRegister()); ASSERT(instr->context()->IsRegister());
ASSERT(ToRegister(instr->context()).is(cp)); ASSERT(ToRegister(instr->context()).is(cp));
CallCode(isolate()->builtins()->StackCheck(), CallCode(stack_check, RelocInfo::CODE_TARGET, instr);
RelocInfo::CODE_TARGET,
instr);
__ bind(&done); __ bind(&done);
} else { } else {
ASSERT(instr->hydrogen()->is_backwards_branch()); ASSERT(instr->hydrogen()->is_backwards_branch());

View File

@ -209,6 +209,8 @@ class LCodeGen: public LCodeGenBase {
RECORD_SAFEPOINT_WITH_REGISTERS_AND_NO_ARGUMENTS RECORD_SAFEPOINT_WITH_REGISTERS_AND_NO_ARGUMENTS
}; };
int CallCodeSize(Handle<Code> code, RelocInfo::Mode mode);
void CallCode( void CallCode(
Handle<Code> code, Handle<Code> code,
RelocInfo::Mode mode, RelocInfo::Mode mode,

View File

@ -107,6 +107,13 @@ int MacroAssembler::CallSize(
} }
int MacroAssembler::CallStubSize(
CodeStub* stub, TypeFeedbackId ast_id, Condition cond) {
return CallSize(
stub->GetCode(isolate()), RelocInfo::CODE_TARGET, ast_id, cond);
}
int MacroAssembler::CallSizeNotPredictableCodeSize( int MacroAssembler::CallSizeNotPredictableCodeSize(
Address target, RelocInfo::Mode rmode, Condition cond) { Address target, RelocInfo::Mode rmode, Condition cond) {
int size = 2 * kInstrSize; int size = 2 * kInstrSize;

View File

@ -102,6 +102,9 @@ class MacroAssembler: public Assembler {
static int CallSize(Register target, Condition cond = al); static int CallSize(Register target, Condition cond = al);
void Call(Register target, Condition cond = al); void Call(Register target, Condition cond = al);
int CallSize(Address target, RelocInfo::Mode rmode, Condition cond = al); int CallSize(Address target, RelocInfo::Mode rmode, Condition cond = al);
int CallStubSize(CodeStub* stub,
TypeFeedbackId ast_id = TypeFeedbackId::None(),
Condition cond = al);
static int CallSizeNotPredictableCodeSize(Address target, static int CallSizeNotPredictableCodeSize(Address target,
RelocInfo::Mode rmode, RelocInfo::Mode rmode,
Condition cond = al); Condition cond = al);