From ab30559feed7c10b18a08ba81a050d0e39cde3ac Mon Sep 17 00:00:00 2001 From: "erik.corry@gmail.com" Date: Fri, 16 Sep 2011 11:29:13 +0000 Subject: [PATCH] Fix some stub calling asserts on x64. Review URL: http://codereview.chromium.org/7922008 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9309 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/arm/code-stubs-arm.cc | 7 +++++++ src/code-stubs.h | 8 ++++++-- src/heap.cc | 9 +++++++++ src/ia32/code-stubs-ia32.cc | 9 +++++++++ src/mips/code-stubs-mips.cc | 9 +++++++++ src/x64/code-stubs-x64.cc | 12 ++++++++++++ 6 files changed, 52 insertions(+), 2 deletions(-) diff --git a/src/arm/code-stubs-arm.cc b/src/arm/code-stubs-arm.cc index 9b7f640aab..4ccdd7bbfc 100644 --- a/src/arm/code-stubs-arm.cc +++ b/src/arm/code-stubs-arm.cc @@ -3333,6 +3333,13 @@ bool CEntryStub::NeedsImmovableCode() { } +bool CEntryStub::CompilingCallsToThisStubIsGCSafe() { + return !save_doubles_ && result_size_ == 1; +} + + +void CodeStub::GenerateStubsAheadOfTime() { +} void CEntryStub::GenerateThrowTOS(MacroAssembler* masm) { __ Throw(r0); } diff --git a/src/code-stubs.h b/src/code-stubs.h index bb758e3458..6bed221f8f 100644 --- a/src/code-stubs.h +++ b/src/code-stubs.h @@ -147,6 +147,9 @@ class CodeStub BASE_EMBEDDED { return MajorKey() <= Instanceof; } + + static void GenerateStubsAheadOfTime(); + // Some stubs put untagged junk on the stack that cannot be scanned by the // GC. This means that we must be statically sure that no GC can occur while // they are running. If that is the case they should override this to return @@ -549,8 +552,9 @@ class CEntryStub : public CodeStub { // The version of this stub that doesn't save doubles is generated ahead of // time, so it's OK to call it from other stubs that can't cope with GC during - // their code generation. - virtual bool CompilingCallsToThisStubIsGCSafe() { return !save_doubles_; } + // their code generation. On machines that always have gp registers (x64) we + // can generate both variants ahead of time. + virtual bool CompilingCallsToThisStubIsGCSafe(); private: void GenerateCore(MacroAssembler* masm, diff --git a/src/heap.cc b/src/heap.cc index f2c782533b..e3293d6b98 100644 --- a/src/heap.cc +++ b/src/heap.cc @@ -2056,6 +2056,15 @@ void Heap::CreateFixedStubs() { // To workaround the problem, make separate functions without inlining. Heap::CreateJSEntryStub(); Heap::CreateJSConstructEntryStub(); + + // Create stubs that should be there, so we don't unexpectedly have to + // create them if we need them during the creation of another stub. + // Stub creation mixes raw pointers and handles in an unsafe manner so + // we cannot create stubs while we are creating stubs. + CEntryStub ces(1); + ces.GetCode(); + + CodeStub::GenerateStubsAheadOfTime(); } diff --git a/src/ia32/code-stubs-ia32.cc b/src/ia32/code-stubs-ia32.cc index bbb814e1f3..97025df59a 100644 --- a/src/ia32/code-stubs-ia32.cc +++ b/src/ia32/code-stubs-ia32.cc @@ -4292,6 +4292,15 @@ bool CEntryStub::NeedsImmovableCode() { } +bool CEntryStub::CompilingCallsToThisStubIsGCSafe() { + return !save_doubles_ && result_size_ == 1; +} + + +void CodeStub::GenerateStubsAheadOfTime() { +} + + void CEntryStub::GenerateThrowTOS(MacroAssembler* masm) { __ Throw(eax); } diff --git a/src/mips/code-stubs-mips.cc b/src/mips/code-stubs-mips.cc index d62b757521..37d51331f7 100644 --- a/src/mips/code-stubs-mips.cc +++ b/src/mips/code-stubs-mips.cc @@ -3476,6 +3476,15 @@ bool CEntryStub::NeedsImmovableCode() { } +bool CEntryStub::CompilingCallsToThisStubIsGCSafe() { + return !save_doubles_ && result_size_ == 1; +} + + +void CodeStub::GenerateStubsAheadOfTime() { +} + + void CEntryStub::GenerateThrowTOS(MacroAssembler* masm) { __ Throw(v0); } diff --git a/src/x64/code-stubs-x64.cc b/src/x64/code-stubs-x64.cc index 2ff1233dbe..1c07dfbd25 100644 --- a/src/x64/code-stubs-x64.cc +++ b/src/x64/code-stubs-x64.cc @@ -3324,6 +3324,18 @@ bool CEntryStub::NeedsImmovableCode() { } +bool CEntryStub::CompilingCallsToThisStubIsGCSafe() { + return result_size_ == 1; +} + + +void CodeStub::GenerateStubsAheadOfTime() { + CEntryStub save_doubles(1); + save_doubles.SaveDoubles(); + save_doubles.GetCode(); +} + + void CEntryStub::GenerateThrowTOS(MacroAssembler* masm) { // Throw exception in eax. __ Throw(rax);