Commit 32991272 authored by Sigurd Schneider's avatar Sigurd Schneider Committed by Commit Bot

[ia32,root] Make API entry code isolate independent

Change-Id: I7691c12acc1b2d0be3e35cf699bb16df4ca84b6e
Bug: v8:6666
Reviewed-on: https://chromium-review.googlesource.com/c/1280435
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56695}
parent 08403cc7
......@@ -2576,7 +2576,7 @@ void Builtins::Generate_CEntry(MacroAssembler* masm, int result_size,
if (argv_mode == kArgvInRegister) {
DCHECK(save_doubles == kDontSaveFPRegs);
DCHECK(!builtin_exit_frame);
__ EnterApiExitFrame(arg_stack_space);
__ EnterApiExitFrame(arg_stack_space, edi);
// Move argc and argv into the correct registers.
__ mov(esi, ecx);
......
......@@ -182,8 +182,9 @@ static Operand ApiParameterOperand(int index) {
// Arguments must be stored in ApiParameterOperand(0), ApiParameterOperand(1)
// etc. Saves context (esi). If space was reserved for return value then
// stores the pointer to the reserved slot into esi.
static void PrepareCallApiFunction(MacroAssembler* masm, int argc) {
__ EnterApiExitFrame(argc);
static void PrepareCallApiFunction(MacroAssembler* masm, int argc,
Register scratch) {
__ EnterApiExitFrame(argc, scratch);
if (__ emit_debug_code()) {
__ mov(esi, Immediate(bit_cast<int32_t>(kZapValue)));
}
......@@ -211,16 +212,16 @@ static void CallApiFunctionAndReturn(MacroAssembler* masm,
DCHECK(edx == function_address);
// Allocate HandleScope in callee-save registers.
__ mov(esi, __ StaticVariable(next_address));
__ mov(edi, __ StaticVariable(limit_address));
__ add(__ StaticVariable(level_address), Immediate(1));
__ add(__ ExternalReferenceAsOperand(level_address, esi), Immediate(1));
__ mov(esi, __ ExternalReferenceAsOperand(next_address, esi));
__ mov(edi, __ ExternalReferenceAsOperand(limit_address, edi));
if (FLAG_log_timer_events) {
FrameScope frame(masm, StackFrame::MANUAL);
__ PushSafepointRegisters();
__ PrepareCallCFunction(1, eax);
__ mov(Operand(esp, 0),
Immediate(ExternalReference::isolate_address(isolate)));
__ Move(Operand(esp, 0),
Immediate(ExternalReference::isolate_address(isolate)));
__ CallCFunction(ExternalReference::log_enter_external_function(), 1);
__ PopSafepointRegisters();
}
......@@ -248,8 +249,8 @@ static void CallApiFunctionAndReturn(MacroAssembler* masm,
FrameScope frame(masm, StackFrame::MANUAL);
__ PushSafepointRegisters();
__ PrepareCallCFunction(1, eax);
__ mov(Operand(esp, 0),
Immediate(ExternalReference::isolate_address(isolate)));
__ mov(eax, Immediate(ExternalReference::isolate_address(isolate)));
__ mov(Operand(esp, 0), eax);
__ CallCFunction(ExternalReference::log_leave_external_function(), 1);
__ PopSafepointRegisters();
}
......@@ -265,10 +266,10 @@ static void CallApiFunctionAndReturn(MacroAssembler* masm,
__ bind(&prologue);
// No more valid handles (the result handle was the last one). Restore
// previous handle scope.
__ mov(__ StaticVariable(next_address), esi);
__ sub(__ StaticVariable(level_address), Immediate(1));
__ mov(__ ExternalReferenceAsOperand(next_address, ecx), esi);
__ sub(__ ExternalReferenceAsOperand(level_address, ecx), Immediate(1));
__ Assert(above_equal, AbortReason::kInvalidHandleScopeLevel);
__ cmp(edi, __ StaticVariable(limit_address));
__ cmp(edi, __ ExternalReferenceAsOperand(limit_address, ecx));
__ j(not_equal, &delete_allocated_handles);
// Leave the API exit frame.
......@@ -281,7 +282,7 @@ static void CallApiFunctionAndReturn(MacroAssembler* masm,
// Check if the function scheduled an exception.
ExternalReference scheduled_exception_address =
ExternalReference::scheduled_exception_address(isolate);
__ cmp(__ StaticVariable(scheduled_exception_address),
__ cmp(__ ExternalReferenceAsOperand(scheduled_exception_address, ecx),
Immediate(isolate->factory()->the_hole_value()));
__ j(not_equal, &promote_scheduled_exception);
......@@ -337,7 +338,7 @@ static void CallApiFunctionAndReturn(MacroAssembler* masm,
ExternalReference delete_extensions =
ExternalReference::delete_handle_scope_extensions();
__ bind(&delete_allocated_handles);
__ mov(__ StaticVariable(limit_address), edi);
__ mov(__ ExternalReferenceAsOperand(limit_address, ecx), edi);
__ mov(edi, eax);
__ mov(Operand(esp, 0),
Immediate(ExternalReference::isolate_address(isolate)));
......@@ -412,7 +413,7 @@ void CallApiCallbackStub::Generate(MacroAssembler* masm) {
// it's not controlled by GC.
const int kApiStackSpace = 3;
PrepareCallApiFunction(masm, kApiArgc + kApiStackSpace);
PrepareCallApiFunction(masm, kApiArgc + kApiStackSpace, edi);
// FunctionCallbackInfo::implicit_args_.
__ mov(ApiParameterOperand(2), scratch);
......@@ -479,10 +480,11 @@ void CallApiGetterStub::Generate(MacroAssembler* masm) {
// active) in non-GCed stack space.
const int kApiArgc = 3 + 1;
// Load address of v8::PropertyAccessorInfo::args_ array.
__ lea(scratch, Operand(esp, 2 * kPointerSize));
PrepareCallApiFunction(masm, kApiArgc, scratch);
PrepareCallApiFunction(masm, kApiArgc);
// Load address of v8::PropertyAccessorInfo::args_ array. The value in ebp
// here corresponds to esp + kPointersize before PrepareCallApiFunction.
__ lea(scratch, Operand(ebp, kPointerSize + 2 * kPointerSize));
// Create v8::PropertyCallbackInfo object on the stack and initialize
// it's args_ field.
Operand info_object = ApiParameterOperand(3);
......
......@@ -49,7 +49,7 @@ void Deoptimizer::TableEntryGenerator::Generate() {
ExternalReference c_entry_fp_address =
ExternalReference::Create(IsolateAddressId::kCEntryFPAddress, isolate());
__ mov(masm()->StaticVariable(c_entry_fp_address), ebp);
__ mov(masm()->ExternalReferenceAsOperand(c_entry_fp_address, esi), ebp);
const int kSavedRegistersAreaSize =
kNumberOfRegisters * kPointerSize + kDoubleRegsSize + kFloatRegsSize;
......
......@@ -850,7 +850,8 @@ void MacroAssembler::LeaveBuiltinFrame(Register context, Register target,
leave();
}
void MacroAssembler::EnterExitFramePrologue(StackFrame::Type frame_type) {
void MacroAssembler::EnterExitFramePrologue(StackFrame::Type frame_type,
Register scratch) {
DCHECK(frame_type == StackFrame::EXIT ||
frame_type == StackFrame::BUILTIN_EXIT);
......@@ -878,9 +879,11 @@ void MacroAssembler::EnterExitFramePrologue(StackFrame::Type frame_type) {
ExternalReference::Create(IsolateAddressId::kContextAddress, isolate());
ExternalReference c_function_address =
ExternalReference::Create(IsolateAddressId::kCFunctionAddress, isolate());
mov(StaticVariable(c_entry_fp_address), ebp);
mov(StaticVariable(context_address), esi);
mov(StaticVariable(c_function_address), edx);
DCHECK(!AreAliased(scratch, ebp, esi, edx));
mov(ExternalReferenceAsOperand(c_entry_fp_address, scratch), ebp);
mov(ExternalReferenceAsOperand(context_address, scratch), esi);
mov(ExternalReferenceAsOperand(c_function_address, scratch), edx);
}
......@@ -911,7 +914,7 @@ void MacroAssembler::EnterExitFrameEpilogue(int argc, bool save_doubles) {
void MacroAssembler::EnterExitFrame(int argc, bool save_doubles,
StackFrame::Type frame_type) {
EnterExitFramePrologue(frame_type);
EnterExitFramePrologue(frame_type, edi);
// Set up argc and argv in callee-saved registers.
int offset = StandardFrameConstants::kCallerSPOffset - kPointerSize;
......@@ -922,9 +925,8 @@ void MacroAssembler::EnterExitFrame(int argc, bool save_doubles,
EnterExitFrameEpilogue(argc, save_doubles);
}
void MacroAssembler::EnterApiExitFrame(int argc) {
EnterExitFramePrologue(StackFrame::EXIT);
void MacroAssembler::EnterApiExitFrame(int argc, Register scratch) {
EnterExitFramePrologue(StackFrame::EXIT, scratch);
EnterExitFrameEpilogue(argc, false);
}
......@@ -958,18 +960,21 @@ void MacroAssembler::LeaveExitFrame(bool save_doubles, bool pop_arguments) {
}
void MacroAssembler::LeaveExitFrameEpilogue() {
// Clear the top frame.
ExternalReference c_entry_fp_address =
ExternalReference::Create(IsolateAddressId::kCEntryFPAddress, isolate());
mov(ExternalReferenceAsOperand(c_entry_fp_address, esi), Immediate(0));
// Restore current context from top and clear it in debug mode.
ExternalReference context_address =
ExternalReference::Create(IsolateAddressId::kContextAddress, isolate());
mov(esi, StaticVariable(context_address));
mov(esi, ExternalReferenceAsOperand(context_address, esi));
#ifdef DEBUG
mov(StaticVariable(context_address), Immediate(Context::kInvalidContext));
push(eax);
mov(ExternalReferenceAsOperand(context_address, eax),
Immediate(Context::kInvalidContext));
pop(eax);
#endif
// Clear the top frame.
ExternalReference c_entry_fp_address =
ExternalReference::Create(IsolateAddressId::kCEntryFPAddress, isolate());
mov(StaticVariable(c_entry_fp_address), Immediate(0));
}
void MacroAssembler::LeaveApiExitFrame() {
......@@ -1238,7 +1243,9 @@ void MacroAssembler::CheckDebugHook(Register fun, Register new_target,
ExternalReference debug_hook_active =
ExternalReference::debug_hook_on_function_call_address(isolate());
cmpb(StaticVariable(debug_hook_active), Immediate(0));
push(eax);
cmpb(ExternalReferenceAsOperand(debug_hook_active, eax), Immediate(0));
pop(eax);
j(equal, &skip_hook);
{
......
......@@ -545,7 +545,7 @@ class MacroAssembler : public TurboAssembler {
// esi.
void EnterExitFrame(int argc, bool save_doubles, StackFrame::Type frame_type);
void EnterApiExitFrame(int argc);
void EnterApiExitFrame(int argc, Register scratch);
// Leave the current exit frame. Expects the return value in
// register eax:edx (untouched) and the pointer to the first
......@@ -741,7 +741,7 @@ class MacroAssembler : public TurboAssembler {
bool* definitely_mismatches, InvokeFlag flag,
Label::Distance done_distance);
void EnterExitFramePrologue(StackFrame::Type frame_type);
void EnterExitFramePrologue(StackFrame::Type frame_type, Register scratch);
void EnterExitFrameEpilogue(int argc, bool save_doubles);
void LeaveExitFrameEpilogue();
......
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