Commit eb2906ae authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

[compiler] Don't try to inline allocate large arguments arrays

... otherwise we'd abort at runtime.

Bug: chromium:1178076
Change-Id: Ic7b4a3b27379ec0d42419e2695ab487904eabd72
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2695395Reviewed-by: 's avatarMichael Stanton <mvstanton@chromium.org>
Commit-Queue: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#72744}
parent 053d1e0d
...@@ -27,11 +27,21 @@ void AllocationBuilder::AllocateContext(int variadic_part_length, MapRef map) { ...@@ -27,11 +27,21 @@ void AllocationBuilder::AllocateContext(int variadic_part_length, MapRef map) {
jsgraph()->Constant(variadic_part_length)); jsgraph()->Constant(variadic_part_length));
} }
// static
bool AllocationBuilder::CanAllocateArray(int length, MapRef map,
AllocationType allocation) {
DCHECK(map.instance_type() == FIXED_ARRAY_TYPE ||
map.instance_type() == FIXED_DOUBLE_ARRAY_TYPE);
int const size = (map.instance_type() == FIXED_ARRAY_TYPE)
? FixedArray::SizeFor(length)
: FixedDoubleArray::SizeFor(length);
return size <= Heap::MaxRegularHeapObjectSize(allocation);
}
// Compound allocation of a FixedArray. // Compound allocation of a FixedArray.
void AllocationBuilder::AllocateArray(int length, MapRef map, void AllocationBuilder::AllocateArray(int length, MapRef map,
AllocationType allocation) { AllocationType allocation) {
DCHECK(map.instance_type() == FIXED_ARRAY_TYPE || DCHECK(CanAllocateArray(length, map, allocation));
map.instance_type() == FIXED_DOUBLE_ARRAY_TYPE);
int size = (map.instance_type() == FIXED_ARRAY_TYPE) int size = (map.instance_type() == FIXED_ARRAY_TYPE)
? FixedArray::SizeFor(length) ? FixedArray::SizeFor(length)
: FixedDoubleArray::SizeFor(length); : FixedDoubleArray::SizeFor(length);
...@@ -40,8 +50,16 @@ void AllocationBuilder::AllocateArray(int length, MapRef map, ...@@ -40,8 +50,16 @@ void AllocationBuilder::AllocateArray(int length, MapRef map,
Store(AccessBuilder::ForFixedArrayLength(), jsgraph()->Constant(length)); Store(AccessBuilder::ForFixedArrayLength(), jsgraph()->Constant(length));
} }
// static
bool AllocationBuilder::CanAllocateSloppyArgumentElements(
int length, MapRef map, AllocationType allocation) {
int const size = SloppyArgumentsElements::SizeFor(length);
return size <= Heap::MaxRegularHeapObjectSize(allocation);
}
void AllocationBuilder::AllocateSloppyArgumentElements( void AllocationBuilder::AllocateSloppyArgumentElements(
int length, MapRef map, AllocationType allocation) { int length, MapRef map, AllocationType allocation) {
DCHECK(CanAllocateSloppyArgumentElements(length, map, allocation));
int size = SloppyArgumentsElements::SizeFor(length); int size = SloppyArgumentsElements::SizeFor(length);
Allocate(size, allocation, Type::OtherInternal()); Allocate(size, allocation, Type::OtherInternal());
Store(AccessBuilder::ForMap(), map); Store(AccessBuilder::ForMap(), map);
......
...@@ -52,10 +52,16 @@ class AllocationBuilder final { ...@@ -52,10 +52,16 @@ class AllocationBuilder final {
inline void AllocateContext(int variadic_part_length, MapRef map); inline void AllocateContext(int variadic_part_length, MapRef map);
// Compound allocation of a FixedArray. // Compound allocation of a FixedArray.
inline static bool CanAllocateArray(
int length, MapRef map,
AllocationType allocation = AllocationType::kYoung);
inline void AllocateArray(int length, MapRef map, inline void AllocateArray(int length, MapRef map,
AllocationType allocation = AllocationType::kYoung); AllocationType allocation = AllocationType::kYoung);
// Compound allocation of a SloppyArgumentsElements // Compound allocation of a SloppyArgumentsElements
static inline bool CanAllocateSloppyArgumentElements(
int length, MapRef map,
AllocationType allocation = AllocationType::kYoung);
inline void AllocateSloppyArgumentElements( inline void AllocateSloppyArgumentElements(
int length, MapRef map, int length, MapRef map,
AllocationType allocation = AllocationType::kYoung); AllocationType allocation = AllocationType::kYoung);
......
This diff is collapsed.
...@@ -83,17 +83,21 @@ class V8_EXPORT_PRIVATE JSCreateLowering final ...@@ -83,17 +83,21 @@ class V8_EXPORT_PRIVATE JSCreateLowering final
const SlackTrackingPrediction& slack_tracking_prediction); const SlackTrackingPrediction& slack_tracking_prediction);
Reduction ReduceJSCreateObject(Node* node); Reduction ReduceJSCreateObject(Node* node);
Node* AllocateArguments(Node* effect, Node* control, FrameState frame_state); // The following functions all return nullptr iff there are too many arguments
Node* AllocateRestArguments(Node* effect, Node* control, // for inline allocation.
FrameState frame_state, int start_index); Node* TryAllocateArguments(Node* effect, Node* control,
Node* AllocateAliasedArguments(Node* effect, Node* control, FrameState frame_state);
FrameState frame_state, Node* context, Node* TryAllocateRestArguments(Node* effect, Node* control,
const SharedFunctionInfoRef& shared, FrameState frame_state, int start_index);
bool* has_aliased_arguments); Node* TryAllocateAliasedArguments(Node* effect, Node* control,
Node* AllocateAliasedArguments(Node* effect, Node* control, Node* context, FrameState frame_state, Node* context,
Node* arguments_length, const SharedFunctionInfoRef& shared,
const SharedFunctionInfoRef& shared, bool* has_aliased_arguments);
bool* has_aliased_arguments); Node* TryAllocateAliasedArguments(Node* effect, Node* control, Node* context,
Node* arguments_length,
const SharedFunctionInfoRef& shared,
bool* has_aliased_arguments);
Node* AllocateElements(Node* effect, Node* control, Node* AllocateElements(Node* effect, Node* control,
ElementsKind elements_kind, int capacity, ElementsKind elements_kind, int capacity,
AllocationType allocation); AllocationType allocation);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment