From 7758713a8a6de254f4a70fa1d08ce3ac02b0f2fb Mon Sep 17 00:00:00 2001 From: "mstarzinger@chromium.org" Date: Fri, 15 Nov 2013 13:49:41 +0000 Subject: [PATCH] Allow passing flags to Runtime_AllocateInTargetSpace. R=ulan@chromium.org Review URL: https://codereview.chromium.org/73973002 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@17792 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/arm/lithium-codegen-arm.cc | 15 +++++++++------ src/ia32/lithium-codegen-ia32.cc | 15 +++++++++------ src/mips/lithium-codegen-mips.cc | 15 +++++++++------ src/runtime.cc | 24 ++++++++++-------------- src/runtime.h | 6 ++++-- src/serialize.cc | 28 +++++++++++----------------- src/x64/lithium-codegen-x64.cc | 14 ++++++++------ 7 files changed, 60 insertions(+), 57 deletions(-) diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc index de9123d..56717a2 100644 --- a/src/arm/lithium-codegen-arm.cc +++ b/src/arm/lithium-codegen-arm.cc @@ -5497,19 +5497,22 @@ void LCodeGen::DoDeferredAllocate(LAllocate* instr) { __ Push(Smi::FromInt(size)); } + int flags = AllocateDoubleAlignFlag::encode( + instr->hydrogen()->MustAllocateDoubleAligned()); if (instr->hydrogen()->IsOldPointerSpaceAllocation()) { ASSERT(!instr->hydrogen()->IsOldDataSpaceAllocation()); ASSERT(!instr->hydrogen()->IsNewSpaceAllocation()); - CallRuntimeFromDeferred(Runtime::kAllocateInOldPointerSpace, 1, instr, - instr->context()); + flags = AllocateTargetSpace::update(flags, OLD_POINTER_SPACE); } else if (instr->hydrogen()->IsOldDataSpaceAllocation()) { ASSERT(!instr->hydrogen()->IsNewSpaceAllocation()); - CallRuntimeFromDeferred(Runtime::kAllocateInOldDataSpace, 1, instr, - instr->context()); + flags = AllocateTargetSpace::update(flags, OLD_DATA_SPACE); } else { - CallRuntimeFromDeferred(Runtime::kAllocateInNewSpace, 1, instr, - instr->context()); + flags = AllocateTargetSpace::update(flags, NEW_SPACE); } + __ Push(Smi::FromInt(flags)); + + CallRuntimeFromDeferred( + Runtime::kAllocateInTargetSpace, 2, instr, instr->context()); __ StoreToSafepointRegisterSlot(r0, result); } diff --git a/src/ia32/lithium-codegen-ia32.cc b/src/ia32/lithium-codegen-ia32.cc index e6b1c8f..fd70b77 100644 --- a/src/ia32/lithium-codegen-ia32.cc +++ b/src/ia32/lithium-codegen-ia32.cc @@ -6069,19 +6069,22 @@ void LCodeGen::DoDeferredAllocate(LAllocate* instr) { __ push(Immediate(Smi::FromInt(size))); } + int flags = AllocateDoubleAlignFlag::encode( + instr->hydrogen()->MustAllocateDoubleAligned()); if (instr->hydrogen()->IsOldPointerSpaceAllocation()) { ASSERT(!instr->hydrogen()->IsOldDataSpaceAllocation()); ASSERT(!instr->hydrogen()->IsNewSpaceAllocation()); - CallRuntimeFromDeferred( - Runtime::kAllocateInOldPointerSpace, 1, instr, instr->context()); + flags = AllocateTargetSpace::update(flags, OLD_POINTER_SPACE); } else if (instr->hydrogen()->IsOldDataSpaceAllocation()) { ASSERT(!instr->hydrogen()->IsNewSpaceAllocation()); - CallRuntimeFromDeferred( - Runtime::kAllocateInOldDataSpace, 1, instr, instr->context()); + flags = AllocateTargetSpace::update(flags, OLD_DATA_SPACE); } else { - CallRuntimeFromDeferred( - Runtime::kAllocateInNewSpace, 1, instr, instr->context()); + flags = AllocateTargetSpace::update(flags, NEW_SPACE); } + __ push(Immediate(Smi::FromInt(flags))); + + CallRuntimeFromDeferred( + Runtime::kAllocateInTargetSpace, 2, instr, instr->context()); __ StoreToSafepointRegisterSlot(result, eax); } diff --git a/src/mips/lithium-codegen-mips.cc b/src/mips/lithium-codegen-mips.cc index 7f6e869..60f8e23 100644 --- a/src/mips/lithium-codegen-mips.cc +++ b/src/mips/lithium-codegen-mips.cc @@ -5411,19 +5411,22 @@ void LCodeGen::DoDeferredAllocate(LAllocate* instr) { __ Push(Smi::FromInt(size)); } + int flags = AllocateDoubleAlignFlag::encode( + instr->hydrogen()->MustAllocateDoubleAligned()); if (instr->hydrogen()->IsOldPointerSpaceAllocation()) { ASSERT(!instr->hydrogen()->IsOldDataSpaceAllocation()); ASSERT(!instr->hydrogen()->IsNewSpaceAllocation()); - CallRuntimeFromDeferred(Runtime::kAllocateInOldPointerSpace, 1, instr, - instr->context()); + flags = AllocateTargetSpace::update(flags, OLD_POINTER_SPACE); } else if (instr->hydrogen()->IsOldDataSpaceAllocation()) { ASSERT(!instr->hydrogen()->IsNewSpaceAllocation()); - CallRuntimeFromDeferred(Runtime::kAllocateInOldDataSpace, 1, instr, - instr->context()); + flags = AllocateTargetSpace::update(flags, OLD_DATA_SPACE); } else { - CallRuntimeFromDeferred(Runtime::kAllocateInNewSpace, 1, instr, - instr->context()); + flags = AllocateTargetSpace::update(flags, NEW_SPACE); } + __ Push(Smi::FromInt(flags)); + + CallRuntimeFromDeferred( + Runtime::kAllocateInTargetSpace, 2, instr, instr->context()); __ StoreToSafepointRegisterSlot(v0, result); } diff --git a/src/runtime.cc b/src/runtime.cc index 2cf033c..881020c 100644 --- a/src/runtime.cc +++ b/src/runtime.cc @@ -9775,6 +9775,7 @@ RUNTIME_FUNCTION(ObjectPair, Runtime_ResolvePossiblyDirectEval) { // Used as a fall-back for generated code when the space is full. static MaybeObject* Allocate(Isolate* isolate, int size, + bool double_align, AllocationSpace space) { Heap* heap = isolate->heap(); RUNTIME_ASSERT(IsAligned(size, kPointerSize)); @@ -9796,24 +9797,19 @@ static MaybeObject* Allocate(Isolate* isolate, RUNTIME_FUNCTION(MaybeObject*, Runtime_AllocateInNewSpace) { SealHandleScope shs(isolate); ASSERT(args.length() == 1); - CONVERT_ARG_HANDLE_CHECKED(Smi, size_smi, 0); - return Allocate(isolate, size_smi->value(), NEW_SPACE); + CONVERT_SMI_ARG_CHECKED(size, 0); + return Allocate(isolate, size, false, NEW_SPACE); } -RUNTIME_FUNCTION(MaybeObject*, Runtime_AllocateInOldPointerSpace) { +RUNTIME_FUNCTION(MaybeObject*, Runtime_AllocateInTargetSpace) { SealHandleScope shs(isolate); - ASSERT(args.length() == 1); - CONVERT_ARG_HANDLE_CHECKED(Smi, size_smi, 0); - return Allocate(isolate, size_smi->value(), OLD_POINTER_SPACE); -} - - -RUNTIME_FUNCTION(MaybeObject*, Runtime_AllocateInOldDataSpace) { - SealHandleScope shs(isolate); - ASSERT(args.length() == 1); - CONVERT_ARG_HANDLE_CHECKED(Smi, size_smi, 0); - return Allocate(isolate, size_smi->value(), OLD_DATA_SPACE); + ASSERT(args.length() == 2); + CONVERT_SMI_ARG_CHECKED(size, 0); + CONVERT_SMI_ARG_CHECKED(flags, 1); + bool double_align = AllocateDoubleAlignFlag::decode(flags); + AllocationSpace space = AllocateTargetSpace::decode(flags); + return Allocate(isolate, size, double_align, space); } diff --git a/src/runtime.h b/src/runtime.h index 734875f..0ba07db 100644 --- a/src/runtime.h +++ b/src/runtime.h @@ -103,8 +103,7 @@ namespace internal { F(CompileForOnStackReplacement, 2, 1) \ F(SetAllocationTimeout, 2, 1) \ F(AllocateInNewSpace, 1, 1) \ - F(AllocateInOldPointerSpace, 1, 1) \ - F(AllocateInOldDataSpace, 1, 1) \ + F(AllocateInTargetSpace, 2, 1) \ F(SetNativeFlag, 1, 1) \ F(SetInlineBuiltinFlag, 1, 1) \ F(StoreArrayLiteralElement, 5, 1) \ @@ -844,6 +843,9 @@ class Runtime : public AllStatic { //--------------------------------------------------------------------------- // Constants used by interface to runtime functions. +class AllocateDoubleAlignFlag: public BitField {}; +class AllocateTargetSpace: public BitField {}; + class DeclareGlobalsEvalFlag: public BitField {}; class DeclareGlobalsNativeFlag: public BitField {}; class DeclareGlobalsLanguageMode: public BitField {}; diff --git a/src/serialize.cc b/src/serialize.cc index 26611e7..36e19c1 100644 --- a/src/serialize.cc +++ b/src/serialize.cc @@ -320,8 +320,6 @@ void ExternalReferenceTable::PopulateTable(Isolate* isolate) { 7, "IncrementalMarking::RecordWrite"); - - // Miscellaneous Add(ExternalReference::roots_array_start(isolate).address(), UNCLASSIFIED, @@ -531,20 +529,20 @@ void ExternalReferenceTable::PopulateTable(Isolate* isolate) { UNCLASSIFIED, 53, "Runtime::AllocateInNewSpace"); + Add(ExternalReference(Runtime::kAllocateInTargetSpace, isolate).address(), + UNCLASSIFIED, + 54, + "Runtime::AllocateInTargetSpace"); Add(ExternalReference::old_pointer_space_allocation_top_address( isolate).address(), UNCLASSIFIED, - 54, + 55, "Heap::OldPointerSpaceAllocationTopAddress"); Add(ExternalReference::old_pointer_space_allocation_limit_address( isolate).address(), UNCLASSIFIED, - 55, - "Heap::OldPointerSpaceAllocationLimitAddress"); - Add(ExternalReference(Runtime::kAllocateInOldPointerSpace, isolate).address(), - UNCLASSIFIED, 56, - "Runtime::AllocateInOldPointerSpace"); + "Heap::OldPointerSpaceAllocationLimitAddress"); Add(ExternalReference::old_data_space_allocation_top_address( isolate).address(), UNCLASSIFIED, @@ -555,26 +553,22 @@ void ExternalReferenceTable::PopulateTable(Isolate* isolate) { UNCLASSIFIED, 58, "Heap::OldDataSpaceAllocationLimitAddress"); - Add(ExternalReference(Runtime::kAllocateInOldDataSpace, isolate).address(), - UNCLASSIFIED, - 59, - "Runtime::AllocateInOldDataSpace"); Add(ExternalReference::new_space_high_promotion_mode_active_address(isolate). address(), UNCLASSIFIED, - 60, + 59, "Heap::NewSpaceAllocationLimitAddress"); Add(ExternalReference::allocation_sites_list_address(isolate).address(), UNCLASSIFIED, - 61, + 60, "Heap::allocation_sites_list_address()"); Add(ExternalReference::address_of_uint32_bias().address(), UNCLASSIFIED, - 62, + 61, "uint32_bias"); Add(ExternalReference::get_mark_code_as_executed_function(isolate).address(), UNCLASSIFIED, - 63, + 62, "Code::MarkCodeAsExecuted"); // Add a small set of deopt entry addresses to encoder without generating the @@ -586,7 +580,7 @@ void ExternalReferenceTable::PopulateTable(Isolate* isolate) { entry, Deoptimizer::LAZY, Deoptimizer::CALCULATE_ENTRY_ADDRESS); - Add(address, LAZY_DEOPTIMIZATION, 64 + entry, "lazy_deopt"); + Add(address, LAZY_DEOPTIMIZATION, entry, "lazy_deopt"); } } diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc index 242f749..c45f91e 100644 --- a/src/x64/lithium-codegen-x64.cc +++ b/src/x64/lithium-codegen-x64.cc @@ -5248,19 +5248,21 @@ void LCodeGen::DoDeferredAllocate(LAllocate* instr) { __ Push(Smi::FromInt(size)); } + int flags = 0; if (instr->hydrogen()->IsOldPointerSpaceAllocation()) { ASSERT(!instr->hydrogen()->IsOldDataSpaceAllocation()); ASSERT(!instr->hydrogen()->IsNewSpaceAllocation()); - CallRuntimeFromDeferred( - Runtime::kAllocateInOldPointerSpace, 1, instr, instr->context()); + flags = AllocateTargetSpace::update(flags, OLD_POINTER_SPACE); } else if (instr->hydrogen()->IsOldDataSpaceAllocation()) { ASSERT(!instr->hydrogen()->IsNewSpaceAllocation()); - CallRuntimeFromDeferred( - Runtime::kAllocateInOldDataSpace, 1, instr, instr->context()); + flags = AllocateTargetSpace::update(flags, OLD_DATA_SPACE); } else { - CallRuntimeFromDeferred( - Runtime::kAllocateInNewSpace, 1, instr, instr->context()); + flags = AllocateTargetSpace::update(flags, NEW_SPACE); } + __ Push(Smi::FromInt(flags)); + + CallRuntimeFromDeferred( + Runtime::kAllocateInTargetSpace, 2, instr, instr->context()); __ StoreToSafepointRegisterSlot(result, rax); } -- 2.7.4