Commit 3dfb90b6 authored by Pierre Langlois's avatar Pierre Langlois Committed by Commit Bot

[arm64] Mark std::printf as an external reference

Arm64's implementation of `TurboAssembler::Abort()` supports printing the
bailout reason to the standard output without calling to the runtime. For this
to work, we need access to the host's printf function so we can call it
directly. In the general case, `Abort` does call the runtime, however, we cannot
do it if we want to abort from inside CEntryStub.

Bug: v8:6939
Change-Id: I2a57603cdc182a45cf770f405bd6ae449f40a047
Reviewed-on: https://chromium-review.googlesource.com/730746Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Pierre Langlois <pierre.langlois@arm.com>
Cr-Commit-Position: refs/heads/master@{#48790}
parent d672142f
......@@ -2024,6 +2024,15 @@ void TurboAssembler::Call(Handle<Code> code, RelocInfo::Mode rmode) {
#endif
}
void TurboAssembler::Call(ExternalReference target) {
UseScratchRegisterScope temps(this);
Register temp = temps.AcquireX();
// Immediate is in charge of setting the relocation mode to
// EXTERNAL_REFERENCE.
Ldr(temp, Immediate(target));
Call(temp);
}
int TurboAssembler::CallSize(Register target) {
USE(target);
return kInstructionSize;
......@@ -3450,7 +3459,7 @@ void TurboAssembler::CallPrintf(int arg_count, const CPURegister* args) {
dc32(arg_pattern_list); // kPrintfArgPatternListOffset
}
#else
Call(FUNCTION_ADDR(printf), RelocInfo::EXTERNAL_REFERENCE);
Call(ExternalReference::printf_function(isolate()));
#endif
}
......
......@@ -913,6 +913,7 @@ class TurboAssembler : public Assembler {
void Call(Label* target);
void Call(Address target, RelocInfo::Mode rmode);
void Call(Handle<Code> code, RelocInfo::Mode rmode = RelocInfo::CODE_TARGET);
void Call(ExternalReference target);
void CallForDeoptimization(Address target, RelocInfo::Mode rmode) {
Call(target, rmode);
......
......@@ -1375,6 +1375,10 @@ ExternalReference ExternalReference::libc_memset_function(Isolate* isolate) {
return ExternalReference(Redirect(isolate, FUNCTION_ADDR(libc_memset)));
}
ExternalReference ExternalReference::printf_function(Isolate* isolate) {
return ExternalReference(Redirect(isolate, FUNCTION_ADDR(std::printf)));
}
template <typename SubjectChar, typename PatternChar>
ExternalReference ExternalReference::search_string_raw(Isolate* isolate) {
auto f = SearchStringRaw<SubjectChar, PatternChar>;
......
......@@ -959,6 +959,8 @@ class ExternalReference BASE_EMBEDDED {
static ExternalReference libc_memmove_function(Isolate* isolate);
static ExternalReference libc_memset_function(Isolate* isolate);
static ExternalReference printf_function(Isolate* isolate);
static ExternalReference try_internalize_string_function(Isolate* isolate);
static ExternalReference check_object_type(Isolate* isolate);
......
......@@ -241,6 +241,7 @@ void ExternalReferenceTable::AddReferences(Isolate* isolate) {
"libc_memmove");
Add(ExternalReference::libc_memset_function(isolate).address(),
"libc_memset");
Add(ExternalReference::printf_function(isolate).address(), "printf");
Add(ExternalReference::try_internalize_string_function(isolate).address(),
"try_internalize_string_function");
Add(ExternalReference::check_object_type(isolate).address(),
......
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