[wasm] Save FP & PC when calling C functions (x64 only)
This change is needed for profiling of Wasm code that calls C-function to ignore the C-stack above the Wasm stack that otherwise couldn't be parsed otherwise. R=clemensb@chromium.org R=petermarshall@chromium.org R=jgruber@chromium.org Bug: chromium:1045860 Change-Id: Ia0788189ca666e77f1564576903c1dc4fd745b8d Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2066964 Commit-Queue: Emanuel Ziegler <ecmziegler@chromium.org> Reviewed-by: Peter Marshall <petermarshall@chromium.org> Reviewed-by: Clemens Backes <clemensb@chromium.org> Cr-Commit-Position: refs/heads/master@{#66408}
This commit is contained in:
parent
75931f18ee
commit
1a2a812382
@ -2651,26 +2651,35 @@ void TurboAssembler::CallCFunction(Register function, int num_arguments) {
|
||||
|
||||
// Save the frame pointer and PC so that the stack layout remains iterable,
|
||||
// even without an ExitFrame which normally exists between JS and C frames.
|
||||
if (isolate() != nullptr) {
|
||||
if (isolate() != nullptr || root_array_available_) {
|
||||
Label get_pc;
|
||||
DCHECK(!AreAliased(kScratchRegister, function));
|
||||
leaq(kScratchRegister, Operand(&get_pc, 0));
|
||||
bind(&get_pc);
|
||||
movq(ExternalReferenceAsOperand(
|
||||
ExternalReference::fast_c_call_caller_pc_address(isolate())),
|
||||
movq(isolate() != nullptr
|
||||
? ExternalReferenceAsOperand(
|
||||
ExternalReference::fast_c_call_caller_pc_address(isolate()))
|
||||
: Operand(kRootRegister,
|
||||
IsolateData::fast_c_call_caller_pc_offset()),
|
||||
kScratchRegister);
|
||||
movq(ExternalReferenceAsOperand(
|
||||
ExternalReference::fast_c_call_caller_fp_address(isolate())),
|
||||
movq(isolate() != nullptr
|
||||
? ExternalReferenceAsOperand(
|
||||
ExternalReference::fast_c_call_caller_fp_address(isolate()))
|
||||
: Operand(kRootRegister,
|
||||
IsolateData::fast_c_call_caller_fp_offset()),
|
||||
rbp);
|
||||
}
|
||||
|
||||
call(function);
|
||||
|
||||
if (isolate() != nullptr) {
|
||||
// We don't unset the PC; the FP is the source of truth.
|
||||
if (isolate() != nullptr) {
|
||||
movq(ExternalReferenceAsOperand(
|
||||
ExternalReference::fast_c_call_caller_fp_address(isolate())),
|
||||
Immediate(0));
|
||||
} else if (root_array_available_) {
|
||||
movq(Operand(kRootRegister, IsolateData::fast_c_call_caller_fp_offset()),
|
||||
Immediate(0));
|
||||
}
|
||||
|
||||
DCHECK_NE(base::OS::ActivationFrameAlignment(), 0);
|
||||
|
@ -62,6 +62,14 @@ class IsolateData final {
|
||||
return kBuiltinsTableOffset - kIsolateRootBias;
|
||||
}
|
||||
|
||||
static constexpr int fast_c_call_caller_fp_offset() {
|
||||
return kFastCCallCallerFPOffset - kIsolateRootBias;
|
||||
}
|
||||
|
||||
static constexpr int fast_c_call_caller_pc_offset() {
|
||||
return kFastCCallCallerPCOffset - kIsolateRootBias;
|
||||
}
|
||||
|
||||
// Root-register-relative offset of the given builtin table entry.
|
||||
// TODO(ishell): remove in favour of typified id version.
|
||||
static int builtin_slot_offset(int builtin_index) {
|
||||
|
Loading…
Reference in New Issue
Block a user