Reviewers: rossberg, danno, Jakob, Paul Lind, kisg,
Message:
PTAL, if this looks OK, we can add this change to the other arch's in a 2nd
patchset. This has already been tested OK on the other arch's, and should
provide a tiny perf. improvement to them as well (in theory, fetching
aligned
doubles is slightly faster).
Description:
MIPS: Ensure double aligned allocations through runtime routines.
3rd (of 3) CLs to ensure complete alignment of FixedDoubleArrays.
TEST=
BUG=
Please review this at https://codereview.chromium.org/35313002/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+73, -12 lines):
M src/mips/lithium-codegen-mips.h
M src/mips/lithium-codegen-mips.cc
M src/runtime.h
M src/runtime.cc
Index: src/mips/lithium-codegen-mips.cc
diff --git a/src/mips/lithium-codegen-mips.cc
b/src/mips/lithium-codegen-mips.cc
index
2c6e5a501af061844956d05a03fc01884f993481..4b7f4b84380f5ac875c33736dd066417bd07b6aa
100644
--- a/src/mips/lithium-codegen-mips.cc
+++ b/src/mips/lithium-codegen-mips.cc
@@ -5257,19 +5257,17 @@ void LCodeGen::DoClampTToUint8(LClampTToUint8*
instr) {
void LCodeGen::DoAllocate(LAllocate* instr) {
class DeferredAllocate V8_FINAL : public LDeferredCode {
public:
- DeferredAllocate(LCodeGen* codegen, LAllocate* instr)
- : LDeferredCode(codegen), instr_(instr) { }
+ DeferredAllocate(LCodeGen* codegen, LAllocate* instr, AllocationFlags
flags)
+ : LDeferredCode(codegen), instr_(instr), flags_(flags) { }
virtual void Generate() V8_OVERRIDE {
- codegen()->DoDeferredAllocate(instr_);
+ codegen()->DoDeferredAllocate(instr_, flags_);
}
virtual LInstruction* instr() V8_OVERRIDE { return instr_; }
private:
LAllocate* instr_;
+ AllocationFlags flags_;
};
- DeferredAllocate* deferred =
- new(zone()) DeferredAllocate(this, instr);
-
Register result = ToRegister(instr->result());
Register scratch = ToRegister(instr->temp1());
Register scratch2 = ToRegister(instr->temp2());
@@ -5287,6 +5285,10 @@ void LCodeGen::DoAllocate(LAllocate* instr) {
ASSERT(!instr->hydrogen()->IsNewSpaceAllocation());
flags = static_cast<AllocationFlags>(flags | PRETENURE_OLD_DATA_SPACE);
}
+
+ DeferredAllocate* deferred =
+ new(zone()) DeferredAllocate(this, instr, flags);
+
if (instr->size()->IsConstantOperand()) {
int32_t size = ToInteger32(LConstantOperand::cast(instr->size()));
__ Allocate(size, result, scratch, scratch2, deferred->entry(), flags);
@@ -5323,7 +5325,7 @@ void LCodeGen::DoAllocate(LAllocate* instr) {
}
-void LCodeGen::DoDeferredAllocate(LAllocate* instr) {
+void LCodeGen::DoDeferredAllocate(LAllocate* instr, AllocationFlags flags)
{
Register result = ToRegister(instr->result());
// TODO(3095996): Get rid of this. For now, we need to make the
@@ -5349,11 +5351,21 @@ void LCodeGen::DoDeferredAllocate(LAllocate* instr)
{
instr->context());
} else if (instr->hydrogen()->IsOldDataSpaceAllocation()) {
ASSERT(!instr->hydrogen()->IsNewSpaceAllocation());
- CallRuntimeFromDeferred(Runtime::kAllocateInOldDataSpace, 1, instr,
- instr->context());
+ if ((flags & DOUBLE_ALIGNMENT) == 0) {
+ CallRuntimeFromDeferred(Runtime::kAllocateInOldDataSpace, 1, instr,
+ instr->context());
+ } else {
+ CallRuntimeFromDeferred(Runtime::kAllocateInOldDataSpaceAligned, 1,
+ instr, instr->context());
+ }
} else {
- CallRuntimeFromDeferred(Runtime::kAllocateInNewSpace, 1, instr,
- instr->context());
+ if ((flags & DOUBLE_ALIGNMENT) == 0) {
+ CallRuntimeFromDeferred(Runtime::kAllocateInNewSpace, 1,
+ instr, instr->context());
+ } else {
+ CallRuntimeFromDeferred(Runtime::kAllocateInNewSpaceAligned, 1,
+ instr, instr->context());
+ }
}
__ StoreToSafepointRegisterSlot(v0, result);
}
Index: src/mips/lithium-codegen-mips.h
diff --git a/src/mips/lithium-codegen-mips.h
b/src/mips/lithium-codegen-mips.h
index
f643d021912b4c0cd5971f5c1fab8700b3330750..1cf26ed3c7449d91b32ec070ff236c37309b9e32
100644
--- a/src/mips/lithium-codegen-mips.h
+++ b/src/mips/lithium-codegen-mips.h
@@ -133,7 +133,7 @@ class LCodeGen: public LCodeGenBase {
void DoDeferredStackCheck(LStackCheck* instr);
void DoDeferredStringCharCodeAt(LStringCharCodeAt* instr);
void DoDeferredStringCharFromCode(LStringCharFromCode* instr);
- void DoDeferredAllocate(LAllocate* instr);
+ void DoDeferredAllocate(LAllocate* instr, AllocationFlags flags);
void DoDeferredInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr,
Label* map_check);
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index
b25547b23e235e64a7366110c249bb5f4de11016..c96a4f750eae93543a4bd5db799676afd0beb7ba
100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -9782,6 +9782,37 @@ static MaybeObject* Allocate(Isolate* isolate,
}
+static MaybeObject* AllocateDoubleAligned(Isolate* isolate,
+ int size,
+ AllocationSpace space) {
+ // Allocate a block of memory in the given space (filled with a filler).
+ // Use as fallback for allocation in generated code when the space
+ // is full.
+ SealHandleScope shs(isolate);
+ RUNTIME_ASSERT(IsAligned(size, kPointerSize));
+ RUNTIME_ASSERT(size > 0);
+ Heap* heap = isolate->heap();
+ RUNTIME_ASSERT(size <= heap->MaxRegularSpaceAllocationSize());
+ Object* allocation;
+ int allocation_size = size + kPointerSize;
+ { MaybeObject* maybe_allocation;
+ if (space == NEW_SPACE) {
+ maybe_allocation = heap->new_space()->AllocateRaw(allocation_size);
+ } else {
+ ASSERT(space == OLD_DATA_SPACE);
+ maybe_allocation =
heap->paged_space(space)->AllocateRaw(allocation_size);
+ }
+ if (maybe_allocation->ToObject(&allocation)) {
+ HeapObject* object = HeapObject::cast(allocation);
+ object = heap->EnsureDoubleAligned(object, allocation_size);
+ heap->CreateFillerObjectAt(object->address(), size);
+ return object;
+ }
+ return maybe_allocation;
+ }
+}
+
+
RUNTIME_FUNCTION(MaybeObject*, Runtime_AllocateInNewSpace) {
SealHandleScope shs(isolate);
ASSERT(args.length() == 1);
@@ -9790,6 +9821,14 @@ RUNTIME_FUNCTION(MaybeObject*,
Runtime_AllocateInNewSpace) {
}
+RUNTIME_FUNCTION(MaybeObject*, Runtime_AllocateInNewSpaceAligned) {
+ SealHandleScope shs(isolate);
+ ASSERT(args.length() == 1);
+ CONVERT_ARG_HANDLE_CHECKED(Smi, size_smi, 0);
+ return AllocateDoubleAligned(isolate, size_smi->value(), NEW_SPACE);
+}
+
+
RUNTIME_FUNCTION(MaybeObject*, Runtime_AllocateInOldPointerSpace) {
SealHandleScope shs(isolate);
ASSERT(args.length() == 1);
@@ -9806,6 +9845,14 @@ RUNTIME_FUNCTION(MaybeObject*,
Runtime_AllocateInOldDataSpace) {
}
+RUNTIME_FUNCTION(MaybeObject*, Runtime_AllocateInOldDataSpaceAligned) {
+ SealHandleScope shs(isolate);
+ ASSERT(args.length() == 1);
+ CONVERT_ARG_HANDLE_CHECKED(Smi, size_smi, 0);
+ return AllocateDoubleAligned(isolate, size_smi->value(), OLD_DATA_SPACE);
+}
+
+
// Push an object unto an array of objects if it is not already in the
// array. Returns true if the element was pushed on the stack and
// false otherwise.
Index: src/runtime.h
diff --git a/src/runtime.h b/src/runtime.h
index
1b7e32e7a1860c631d75f8b958ccc347ea115b89..ad903b3361a6b1f0f62b067df465962feb921f85
100644
--- a/src/runtime.h
+++ b/src/runtime.h
@@ -103,8 +103,10 @@ namespace internal {
F(CompileForOnStackReplacement, 2, 1) \
F(SetAllocationTimeout, 2, 1) \
F(AllocateInNewSpace, 1, 1) \
+ F(AllocateInNewSpaceAligned, 1, 1) \
F(AllocateInOldPointerSpace, 1, 1) \
F(AllocateInOldDataSpace, 1, 1) \
+ F(AllocateInOldDataSpaceAligned, 1, 1) \
F(SetNativeFlag, 1, 1) \
F(StoreArrayLiteralElement, 5, 1) \
F(DebugCallbackSupportsStepping, 1, 1) \
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.