From 2846d9f3947168c0ca63e9d4faa2251d9cfce72e Mon Sep 17 00:00:00 2001 From: "rodolph.perfetta@gmail.com" Date: Tue, 10 Sep 2013 13:50:26 +0000 Subject: [PATCH] ARM: replace RegExpCEntryStub with DirectCEntryStub. RegExpCEntryStub is therefore removed. BUG=none TEST=none R=bmeurer@chromium.org Review URL: https://codereview.chromium.org/23468015 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16618 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/arm/code-stubs-arm.cc | 21 ++++------- src/arm/code-stubs-arm.h | 17 --------- src/arm/regexp-macro-assembler-arm.cc | 52 ++++++++++++--------------- src/arm/regexp-macro-assembler-arm.h | 8 ----- src/code-stubs.h | 1 - 5 files changed, 29 insertions(+), 70 deletions(-) diff --git a/src/arm/code-stubs-arm.cc b/src/arm/code-stubs-arm.cc index 310cf3e3d7..4b964adcba 100644 --- a/src/arm/code-stubs-arm.cc +++ b/src/arm/code-stubs-arm.cc @@ -6143,6 +6143,11 @@ void ICCompareStub::GenerateMiss(MacroAssembler* masm) { void DirectCEntryStub::Generate(MacroAssembler* masm) { + // Place the return address on the stack, making the call + // GC safe. The RegExp backend also relies on this. + __ str(lr, MemOperand(sp, 0)); + __ blx(ip); // Call the C++ function. + __ VFPEnsureFPSCRState(r2); __ ldr(pc, MemOperand(sp, 0)); } @@ -6151,21 +6156,9 @@ void DirectCEntryStub::GenerateCall(MacroAssembler* masm, Register target) { intptr_t code = reinterpret_cast(GetCode(masm->isolate()).location()); + __ Move(ip, target); __ mov(lr, Operand(code, RelocInfo::CODE_TARGET)); - - // Prevent literal pool emission during calculation of return address. - Assembler::BlockConstPoolScope block_const_pool(masm); - - // Push return address (accessible to GC through exit frame pc). - // Note that using pc with str is deprecated. - Label start; - __ bind(&start); - __ add(ip, pc, Operand(Assembler::kInstrSize)); - __ str(ip, MemOperand(sp, 0)); - __ Jump(target); // Call the C++ function. - ASSERT_EQ(Assembler::kInstrSize + Assembler::kPcLoadDelta, - masm->SizeOfCodeGeneratedSince(&start)); - __ VFPEnsureFPSCRState(r2); + __ blx(lr); // Call the stub. } diff --git a/src/arm/code-stubs-arm.h b/src/arm/code-stubs-arm.h index bee3e1e126..e7e7bfc00d 100644 --- a/src/arm/code-stubs-arm.h +++ b/src/arm/code-stubs-arm.h @@ -465,23 +465,6 @@ class RecordWriteStub: public PlatformCodeStub { }; -// Enter C code from generated RegExp code in a way that allows -// the C code to fix the return address in case of a GC. -// Currently only needed on ARM. -class RegExpCEntryStub: public PlatformCodeStub { - public: - RegExpCEntryStub() {} - virtual ~RegExpCEntryStub() {} - void Generate(MacroAssembler* masm); - - private: - Major MajorKey() { return RegExpCEntry; } - int MinorKey() { return 0; } - - bool NeedsImmovableCode() { return true; } -}; - - // Trampoline stub to call into native code. To call safely into native code // in the presence of compacting GC (which can move code objects) we need to // keep the code which called into native pinned in the memory. Currently the diff --git a/src/arm/regexp-macro-assembler-arm.cc b/src/arm/regexp-macro-assembler-arm.cc index 189ea8d777..2a81facacf 100644 --- a/src/arm/regexp-macro-assembler-arm.cc +++ b/src/arm/regexp-macro-assembler-arm.cc @@ -1055,16 +1055,34 @@ void RegExpMacroAssemblerARM::WriteStackPointerToRegister(int reg) { // Private methods: void RegExpMacroAssemblerARM::CallCheckStackGuardState(Register scratch) { - static const int num_arguments = 3; - __ PrepareCallCFunction(num_arguments, scratch); + __ PrepareCallCFunction(3, scratch); + // RegExp code frame pointer. __ mov(r2, frame_pointer()); // Code* of self. __ mov(r1, Operand(masm_->CodeObject())); - // r0 becomes return address pointer. + + // We need to make room for the return address on the stack. + int stack_alignment = OS::ActivationFrameAlignment(); + ASSERT(IsAligned(stack_alignment, kPointerSize)); + __ sub(sp, sp, Operand(stack_alignment)); + + // r0 will point to the return address, placed by DirectCEntry. + __ mov(r0, sp); + ExternalReference stack_guard_check = ExternalReference::re_check_stack_guard_state(isolate()); - CallCFunctionUsingStub(stack_guard_check, num_arguments); + __ mov(ip, Operand(stack_guard_check)); + DirectCEntryStub stub; + stub.GenerateCall(masm_, ip); + + // Drop the return address from the stack. + __ add(sp, sp, Operand(stack_alignment)); + + ASSERT(stack_alignment != 0); + __ ldr(sp, MemOperand(sp, 0)); + + __ mov(code_pointer(), Operand(masm_->CodeObject())); } @@ -1294,21 +1312,6 @@ int RegExpMacroAssemblerARM::GetBacktrackConstantPoolEntry() { } -void RegExpMacroAssemblerARM::CallCFunctionUsingStub( - ExternalReference function, - int num_arguments) { - // Must pass all arguments in registers. The stub pushes on the stack. - ASSERT(num_arguments <= 4); - __ mov(code_pointer(), Operand(function)); - RegExpCEntryStub stub; - __ CallStub(&stub); - if (OS::ActivationFrameAlignment() != 0) { - __ ldr(sp, MemOperand(sp, 0)); - } - __ mov(code_pointer(), Operand(masm_->CodeObject())); -} - - bool RegExpMacroAssemblerARM::CanReadUnaligned() { return CpuFeatures::IsSupported(UNALIGNED_ACCESSES) && !slow_safe(); } @@ -1351,17 +1354,6 @@ void RegExpMacroAssemblerARM::LoadCurrentCharacterUnchecked(int cp_offset, } -void RegExpCEntryStub::Generate(MacroAssembler* masm_) { - int stack_alignment = OS::ActivationFrameAlignment(); - if (stack_alignment < kPointerSize) stack_alignment = kPointerSize; - // Stack is already aligned for call, so decrement by alignment - // to make room for storing the link register. - __ str(lr, MemOperand(sp, stack_alignment, NegPreIndex)); - __ mov(r0, sp); - __ Call(r5); - __ ldr(pc, MemOperand(sp, stack_alignment, PostIndex)); -} - #undef __ #endif // V8_INTERPRETED_REGEXP diff --git a/src/arm/regexp-macro-assembler-arm.h b/src/arm/regexp-macro-assembler-arm.h index 1825752ebc..0874ad1ab8 100644 --- a/src/arm/regexp-macro-assembler-arm.h +++ b/src/arm/regexp-macro-assembler-arm.h @@ -212,14 +212,6 @@ class RegExpMacroAssemblerARM: public NativeRegExpMacroAssembler { // and increments it by a word size. inline void Pop(Register target); - // Calls a C function and cleans up the frame alignment done by - // by FrameAlign. The called function *is* allowed to trigger a garbage - // collection, but may not take more than four arguments (no arguments - // passed on the stack), and the first argument will be a pointer to the - // return address. - inline void CallCFunctionUsingStub(ExternalReference function, - int num_arguments); - Isolate* isolate() const { return masm_->isolate(); } MacroAssembler* masm_; diff --git a/src/code-stubs.h b/src/code-stubs.h index 4fe4e074cc..3138efbde6 100644 --- a/src/code-stubs.h +++ b/src/code-stubs.h @@ -102,7 +102,6 @@ namespace internal { V(GetProperty) \ V(SetProperty) \ V(InvokeBuiltin) \ - V(RegExpCEntry) \ V(DirectCEntry) #else #define CODE_STUB_LIST_ARM(V)