Commit 9e939c09 authored by Leszek Swirski's avatar Leszek Swirski Committed by Commit Bot

[sparkplug] Pass flags to CreateShallowArrayLiteral

CreateShallowArrayLiteral can fail and bail out to the runtime. We
therefore have to pass the literal flags to the builtin, so that the
runtime e.g. initialises the AllocationSite correctly.

Bug: v8:11420
Change-Id: I57dfbbc202aa2c3b0e7ac01f65ee84f6e3763180
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2786848Reviewed-by: 's avatarMaya Lekova <mslekova@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Commit-Queue: Maya Lekova <mslekova@chromium.org>
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#73666}
parent af08fdbf
...@@ -1792,15 +1792,16 @@ void BaselineCompiler::VisitCreateRegExpLiteral() { ...@@ -1792,15 +1792,16 @@ void BaselineCompiler::VisitCreateRegExpLiteral() {
void BaselineCompiler::VisitCreateArrayLiteral() { void BaselineCompiler::VisitCreateArrayLiteral() {
uint32_t flags = Flag(2); uint32_t flags = Flag(2);
int32_t flags_raw = static_cast<int32_t>(
interpreter::CreateArrayLiteralFlags::FlagsBits::decode(flags));
if (flags & if (flags &
interpreter::CreateArrayLiteralFlags::FastCloneSupportedBit::kMask) { interpreter::CreateArrayLiteralFlags::FastCloneSupportedBit::kMask) {
CallBuiltin(Builtins::kCreateShallowArrayLiteral, CallBuiltin(Builtins::kCreateShallowArrayLiteral,
FeedbackVector(), // feedback vector FeedbackVector(), // feedback vector
IndexAsTagged(1), // slot IndexAsTagged(1), // slot
Constant<HeapObject>(0)); // constant elements Constant<HeapObject>(0), // constant elements
Smi::FromInt(flags_raw)); // flags
} else { } else {
int32_t flags_raw = static_cast<int32_t>(
interpreter::CreateArrayLiteralFlags::FlagsBits::decode(flags));
CallRuntime(Runtime::kCreateArrayLiteral, CallRuntime(Runtime::kCreateArrayLiteral,
FeedbackVector(), // feedback vector FeedbackVector(), // feedback vector
IndexAsTagged(1), // slot IndexAsTagged(1), // slot
......
...@@ -61,7 +61,7 @@ builtin CreateRegExpLiteral(implicit context: Context)( ...@@ -61,7 +61,7 @@ builtin CreateRegExpLiteral(implicit context: Context)(
builtin CreateShallowArrayLiteral(implicit context: Context)( builtin CreateShallowArrayLiteral(implicit context: Context)(
maybeFeedbackVector: Undefined|FeedbackVector, slot: TaggedIndex, maybeFeedbackVector: Undefined|FeedbackVector, slot: TaggedIndex,
constantElements: ArrayBoilerplateDescription): HeapObject { constantElements: ArrayBoilerplateDescription, flags: Smi): HeapObject {
try { try {
const vector = Cast<FeedbackVector>(maybeFeedbackVector) const vector = Cast<FeedbackVector>(maybeFeedbackVector)
otherwise CallRuntime; otherwise CallRuntime;
...@@ -70,8 +70,7 @@ builtin CreateShallowArrayLiteral(implicit context: Context)( ...@@ -70,8 +70,7 @@ builtin CreateShallowArrayLiteral(implicit context: Context)(
otherwise CallRuntime; otherwise CallRuntime;
} label CallRuntime deferred { } label CallRuntime deferred {
tail runtime::CreateArrayLiteral( tail runtime::CreateArrayLiteral(
context, maybeFeedbackVector, slot, constantElements, context, maybeFeedbackVector, slot, constantElements, flags);
SmiConstant(kIsShallow));
} }
} }
......
...@@ -700,6 +700,7 @@ void JSGenericLowering::LowerJSCreateLiteralArray(Node* node) { ...@@ -700,6 +700,7 @@ void JSGenericLowering::LowerJSCreateLiteralArray(Node* node) {
node->InsertInput(zone(), 1, node->InsertInput(zone(), 1,
jsgraph()->TaggedIndexConstant(p.feedback().index())); jsgraph()->TaggedIndexConstant(p.feedback().index()));
node->InsertInput(zone(), 2, jsgraph()->HeapConstant(p.constant())); node->InsertInput(zone(), 2, jsgraph()->HeapConstant(p.constant()));
node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.flags()));
// Use the CreateShallowArrayLiteral builtin only for shallow boilerplates // Use the CreateShallowArrayLiteral builtin only for shallow boilerplates
// without properties up to the number of elements that the stubs can handle. // without properties up to the number of elements that the stubs can handle.
...@@ -707,7 +708,6 @@ void JSGenericLowering::LowerJSCreateLiteralArray(Node* node) { ...@@ -707,7 +708,6 @@ void JSGenericLowering::LowerJSCreateLiteralArray(Node* node) {
p.length() < ConstructorBuiltins::kMaximumClonedShallowArrayElements) { p.length() < ConstructorBuiltins::kMaximumClonedShallowArrayElements) {
ReplaceWithBuiltinCall(node, Builtins::kCreateShallowArrayLiteral); ReplaceWithBuiltinCall(node, Builtins::kCreateShallowArrayLiteral);
} else { } else {
node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.flags()));
ReplaceWithRuntimeCall(node, Runtime::kCreateArrayLiteral); ReplaceWithRuntimeCall(node, Runtime::kCreateArrayLiteral);
} }
} }
......
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