From 586e87781a52e4981f7be2abdd9716d2522eebbf Mon Sep 17 00:00:00 2001 From: Jakob Gruber Date: Wed, 19 Sep 2018 17:59:26 +0200 Subject: [PATCH] [ia32,root] Port WasmCompileLazy, ResumeGeneratorTrampoline Bug: v8:6666 Change-Id: I427bb8e54a79eb3d7ee226da2f4d90ab4886e353 Reviewed-on: https://chromium-review.googlesource.com/1233656 Commit-Queue: Sigurd Schneider Commit-Queue: Jakob Gruber Reviewed-by: Sigurd Schneider Cr-Commit-Position: refs/heads/master@{#56078} --- src/builtins/ia32/builtins-ia32.cc | 52 ++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/src/builtins/ia32/builtins-ia32.cc b/src/builtins/ia32/builtins-ia32.cc index e90304b85d..490fb4c155 100644 --- a/src/builtins/ia32/builtins-ia32.cc +++ b/src/builtins/ia32/builtins-ia32.cc @@ -443,6 +443,8 @@ static void GetSharedFunctionInfoBytecode(MacroAssembler* masm, // static void Builtins::Generate_ResumeGeneratorTrampoline(MacroAssembler* masm) { + Assembler::SupportsRootRegisterScope supports_root_register(masm); + // ----------- S t a t e ------------- // -- eax : the value to pass to the generator // -- edx : the JSGeneratorObject to resume @@ -494,26 +496,34 @@ void Builtins::Generate_ResumeGeneratorTrampoline(MacroAssembler* masm) { // -- esp[0] : generator receiver // ----------------------------------- - // Copy the function arguments from the generator object's register file. - __ mov(ecx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); - __ movzx_w( - ecx, FieldOperand(ecx, SharedFunctionInfo::kFormalParameterCountOffset)); - __ mov(ebx, - FieldOperand(edx, JSGeneratorObject::kParametersAndRegistersOffset)); { - Label done_loop, loop; - __ Set(edi, 0); + Assembler::AllowExplicitEbxAccessScope root_is_spilled(masm); + __ movd(xmm0, ebx); - __ bind(&loop); - __ cmp(edi, ecx); - __ j(greater_equal, &done_loop); - __ Push( - FieldOperand(ebx, edi, times_pointer_size, FixedArray::kHeaderSize)); - __ add(edi, Immediate(1)); - __ jmp(&loop); + // Copy the function arguments from the generator object's register file. + __ mov(ecx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); + __ movzx_w(ecx, FieldOperand( + ecx, SharedFunctionInfo::kFormalParameterCountOffset)); + __ mov(ebx, + FieldOperand(edx, JSGeneratorObject::kParametersAndRegistersOffset)); + { + Label done_loop, loop; + __ Set(edi, 0); - __ bind(&done_loop); + __ bind(&loop); + __ cmp(edi, ecx); + __ j(greater_equal, &done_loop); + __ Push( + FieldOperand(ebx, edi, times_pointer_size, FixedArray::kHeaderSize)); + __ add(edi, Immediate(1)); + __ jmp(&loop); + + __ bind(&done_loop); + } + + // Restore registers. __ mov(edi, FieldOperand(edx, JSGeneratorObject::kFunctionOffset)); + __ movd(ebx, xmm0); } // Underlying function needs to have bytecode available. @@ -2420,6 +2430,8 @@ void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) { } void Builtins::Generate_WasmCompileLazy(MacroAssembler* masm) { + Assembler::SupportsRootRegisterScope supports_root_register(masm); + // The function index was put in edi by the jump table trampoline. // Convert to Smi for the runtime call. __ SmiTag(edi); @@ -2430,6 +2442,7 @@ void Builtins::Generate_WasmCompileLazy(MacroAssembler* masm) { // Save all parameter registers (see wasm-linkage.cc). They might be // overwritten in the runtime call below. We don't have any callee-saved // registers in wasm, so no need to store anything else. + Assembler::AllowExplicitEbxAccessScope root_is_spilled(masm); static_assert(WasmCompileLazyFrameConstants::kNumberOfSavedGpParamRegs == arraysize(wasm::kGpParamRegisters), "frame size mismatch"); @@ -2456,7 +2469,12 @@ void Builtins::Generate_WasmCompileLazy(MacroAssembler* masm) { // Initialize the JavaScript context with 0. CEntry will use it to // set the current context on the isolate. __ Move(kContextRegister, Smi::kZero); - __ CallRuntimeWithCEntry(Runtime::kWasmCompileLazy, ecx); + { + // At this point, ebx has been spilled to the stack but is not yet + // overwritten with another value. We can still use it as kRootRegister. + Assembler::SupportsRootRegisterScope root_is_unclobbered(masm); + __ CallRuntimeWithCEntry(Runtime::kWasmCompileLazy, ecx); + } // The entrypoint address is the return value. __ mov(edi, kReturnRegister0);