Commit b95b6362 authored by Andreas Haas's avatar Andreas Haas Committed by Commit Bot

[arm] Do not check the constant pool in a PredictableSizeScope.

In a recent CL (https://codereview.chromium.org/2738683003) I changed
the generation of call instructions on arm to emit a constant pool if
necessary. However it can happen now that a call is generated within a
PredictableSizeScope, which causes a crash if a constant pool is
actually emitted, which naturally changes the size of the generated
code. With this CL I add a flag to the generation of a call where we
can state explicitly that for particular calls, i.e. those calls within
a PredictableSizeScope, we do not want to emit a constant pool.

BUG=chromium:704528

Change-Id: I7740d5440d007a2a5457c524aa8eec1b74944d57
Reviewed-on: https://chromium-review.googlesource.com/459602Reviewed-by: 's avatarJacob Bramley <jacob.bramley@arm.com>
Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#44181}
parent 34ffdd62
...@@ -2333,6 +2333,7 @@ void StubFailureTrampolineStub::Generate(MacroAssembler* masm) { ...@@ -2333,6 +2333,7 @@ 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) {
ProfileEntryHookStub stub(masm->isolate()); ProfileEntryHookStub stub(masm->isolate());
masm->MaybeCheckConstPool();
PredictableCodeSizeScope predictable(masm); PredictableCodeSizeScope predictable(masm);
predictable.ExpectSize(masm->CallStubSize(&stub) + predictable.ExpectSize(masm->CallStubSize(&stub) +
2 * Assembler::kInstrSize); 2 * Assembler::kInstrSize);
......
...@@ -97,13 +97,11 @@ int MacroAssembler::CallStubSize( ...@@ -97,13 +97,11 @@ int MacroAssembler::CallStubSize(
return CallSize(stub->GetCode(), RelocInfo::CODE_TARGET, ast_id, cond); return CallSize(stub->GetCode(), RelocInfo::CODE_TARGET, ast_id, cond);
} }
void MacroAssembler::Call(Address target, RelocInfo::Mode rmode, Condition cond,
void MacroAssembler::Call(Address target, TargetAddressStorageMode mode,
RelocInfo::Mode rmode, bool check_constant_pool) {
Condition cond,
TargetAddressStorageMode mode) {
// Check if we have to emit the constant pool before we block it. // Check if we have to emit the constant pool before we block it.
MaybeCheckConstPool(); if (check_constant_pool) MaybeCheckConstPool();
// Block constant pool for the call instruction sequence. // Block constant pool for the call instruction sequence.
BlockConstPoolScope block_const_pool(this); BlockConstPoolScope block_const_pool(this);
Label start; Label start;
...@@ -151,7 +149,8 @@ int MacroAssembler::CallSize(Handle<Code> code, ...@@ -151,7 +149,8 @@ int MacroAssembler::CallSize(Handle<Code> code,
void MacroAssembler::Call(Handle<Code> code, RelocInfo::Mode rmode, void MacroAssembler::Call(Handle<Code> code, RelocInfo::Mode rmode,
TypeFeedbackId ast_id, Condition cond, TypeFeedbackId ast_id, Condition cond,
TargetAddressStorageMode mode) { TargetAddressStorageMode mode,
bool check_constant_pool) {
Label start; Label start;
bind(&start); bind(&start);
DCHECK(RelocInfo::IsCodeTarget(rmode)); DCHECK(RelocInfo::IsCodeTarget(rmode));
...@@ -2412,7 +2411,8 @@ void MacroAssembler::CallStub(CodeStub* stub, ...@@ -2412,7 +2411,8 @@ void MacroAssembler::CallStub(CodeStub* stub,
TypeFeedbackId ast_id, TypeFeedbackId ast_id,
Condition cond) { Condition cond) {
DCHECK(AllowThisStubCall(stub)); // Stub calls are not allowed in some stubs. DCHECK(AllowThisStubCall(stub)); // Stub calls are not allowed in some stubs.
Call(stub->GetCode(), RelocInfo::CODE_TARGET, ast_id, cond); Call(stub->GetCode(), RelocInfo::CODE_TARGET, ast_id, cond,
CAN_INLINE_TARGET_ADDRESS, false);
} }
......
...@@ -111,12 +111,13 @@ class MacroAssembler: public Assembler { ...@@ -111,12 +111,13 @@ class MacroAssembler: public Assembler {
void Jump(Address target, RelocInfo::Mode rmode, Condition cond = al); void Jump(Address target, RelocInfo::Mode rmode, Condition cond = al);
void Jump(Handle<Code> code, RelocInfo::Mode rmode, Condition cond = al); void Jump(Handle<Code> code, RelocInfo::Mode rmode, Condition cond = al);
void Call(Register target, Condition cond = al); void Call(Register target, Condition cond = al);
void Call(Address target, RelocInfo::Mode rmode, void Call(Address target, RelocInfo::Mode rmode, Condition cond = al,
Condition cond = al, TargetAddressStorageMode mode = CAN_INLINE_TARGET_ADDRESS,
TargetAddressStorageMode mode = CAN_INLINE_TARGET_ADDRESS); bool check_constant_pool = true);
void Call(Handle<Code> code, RelocInfo::Mode rmode = RelocInfo::CODE_TARGET, void Call(Handle<Code> code, RelocInfo::Mode rmode = RelocInfo::CODE_TARGET,
TypeFeedbackId ast_id = TypeFeedbackId::None(), Condition cond = al, TypeFeedbackId ast_id = TypeFeedbackId::None(), Condition cond = al,
TargetAddressStorageMode mode = CAN_INLINE_TARGET_ADDRESS); TargetAddressStorageMode mode = CAN_INLINE_TARGET_ADDRESS,
bool check_constant_pool = true);
int CallSize(Handle<Code> code, int CallSize(Handle<Code> code,
RelocInfo::Mode rmode = RelocInfo::CODE_TARGET, RelocInfo::Mode rmode = RelocInfo::CODE_TARGET,
TypeFeedbackId ast_id = TypeFeedbackId::None(), TypeFeedbackId ast_id = TypeFeedbackId::None(),
......
...@@ -689,7 +689,7 @@ void LCodeGen::CallCodeGeneric(Handle<Code> code, ...@@ -689,7 +689,7 @@ void LCodeGen::CallCodeGeneric(Handle<Code> code,
// Block literal pool emission to ensure nop indicating no inlined smi code // Block literal pool emission to ensure nop indicating no inlined smi code
// is in the correct position. // is in the correct position.
Assembler::BlockConstPoolScope block_const_pool(masm()); Assembler::BlockConstPoolScope block_const_pool(masm());
__ Call(code, mode, TypeFeedbackId::None(), al, storage_mode); __ Call(code, mode, TypeFeedbackId::None(), al, storage_mode, false);
RecordSafepointWithLazyDeopt(instr, safepoint_mode); RecordSafepointWithLazyDeopt(instr, safepoint_mode);
// Signal that we don't inline smi code before these stubs in the // Signal that we don't inline smi code before these stubs in the
...@@ -5224,6 +5224,7 @@ void LCodeGen::DoStackCheck(LStackCheck* instr) { ...@@ -5224,6 +5224,7 @@ void LCodeGen::DoStackCheck(LStackCheck* instr) {
__ cmp(sp, Operand(ip)); __ cmp(sp, Operand(ip));
__ b(hs, &done); __ b(hs, &done);
Handle<Code> stack_check = isolate()->builtins()->StackCheck(); Handle<Code> stack_check = isolate()->builtins()->StackCheck();
masm()->MaybeCheckConstPool();
PredictableCodeSizeScope predictable(masm()); PredictableCodeSizeScope predictable(masm());
predictable.ExpectSize(CallCodeSize(stack_check, RelocInfo::CODE_TARGET)); predictable.ExpectSize(CallCodeSize(stack_check, RelocInfo::CODE_TARGET));
DCHECK(instr->context()->IsRegister()); DCHECK(instr->context()->IsRegister());
......
...@@ -314,10 +314,12 @@ void FullCodeGenerator::Generate() { ...@@ -314,10 +314,12 @@ void FullCodeGenerator::Generate() {
__ cmp(sp, Operand(ip)); __ cmp(sp, Operand(ip));
__ b(hs, &ok); __ b(hs, &ok);
Handle<Code> stack_check = isolate()->builtins()->StackCheck(); Handle<Code> stack_check = isolate()->builtins()->StackCheck();
masm_->MaybeCheckConstPool();
PredictableCodeSizeScope predictable(masm_); PredictableCodeSizeScope predictable(masm_);
predictable.ExpectSize( predictable.ExpectSize(
masm_->CallSize(stack_check, RelocInfo::CODE_TARGET)); masm_->CallSize(stack_check, RelocInfo::CODE_TARGET));
__ Call(stack_check, RelocInfo::CODE_TARGET); __ Call(stack_check, RelocInfo::CODE_TARGET, TypeFeedbackId::None(), al,
CAN_INLINE_TARGET_ADDRESS, false);
__ bind(&ok); __ bind(&ok);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment