Commit 452ca36b authored by Mythri A's avatar Mythri A Committed by Commit Bot

[csa][cleanup] TNodify StringAdd_CheckNone buitin

StringAdd_CheckNone is called from Turbofan with an empty context. This
builtin needs context when calling the StringAdd runtime function which
could potentially throw. Turbofan does bounds check before calling this
builtin so it is safe to pass an empty context. To enable TNodification
of this builtin this cl adds a new type that either accepts a context
or an empty context (Smi::Zero) and updates the builtin to use this new
type.

Bug: v8:6949, v8:11074
Change-Id: Iff12b391ff95109649f2c81fe081e277850f60d6
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2523205
Commit-Queue: Mythri Alle <mythria@chromium.org>
Reviewed-by: 's avatarDan Elphick <delphick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71018}
parent 0ca4ad1f
......@@ -343,9 +343,11 @@ TNode<String> StringBuiltinsAssembler::AllocateConsString(TNode<Uint32T> length,
return CAST(result);
}
TNode<String> StringBuiltinsAssembler::StringAdd(SloppyTNode<Context> context,
TNode<String> left,
TNode<String> right) {
TNode<String> StringBuiltinsAssembler::StringAdd(
TNode<ContextOrEmptyContext> context, TNode<String> left,
TNode<String> right) {
CSA_ASSERT(this, IsZeroOrContext(context));
TVARIABLE(String, result);
Label check_right(this), runtime(this, Label::kDeferred), cons(this),
done(this, &result), done_native(this, &result);
......@@ -541,7 +543,9 @@ TNode<String> StringBuiltinsAssembler::DerefIndirectString(
TF_BUILTIN(StringAdd_CheckNone, StringBuiltinsAssembler) {
auto left = Parameter<String>(Descriptor::kLeft);
auto right = Parameter<String>(Descriptor::kRight);
Node* context = UntypedParameter(Descriptor::kContext);
TNode<ContextOrEmptyContext> context =
UncheckedParameter<ContextOrEmptyContext>(Descriptor::kContext);
CSA_ASSERT(this, IsZeroOrContext(context));
Return(StringAdd(context, left, right));
}
......
......@@ -113,8 +113,8 @@ class StringBuiltinsAssembler : public CodeStubAssembler {
TNode<String> AllocateConsString(TNode<Uint32T> length, TNode<String> left,
TNode<String> right);
TNode<String> StringAdd(SloppyTNode<Context> context, TNode<String> left,
TNode<String> right);
TNode<String> StringAdd(TNode<ContextOrEmptyContext> context,
TNode<String> left, TNode<String> right);
// Check if |string| is an indirect (thin or flat cons) string type that can
// be dereferenced by DerefIndirectString.
......
......@@ -238,6 +238,7 @@ struct UnionT {
using AnyTaggedT = UnionT<Object, MaybeObject>;
using Number = UnionT<Smi, HeapNumber>;
using Numeric = UnionT<Number, BigInt>;
using ContextOrEmptyContext = UnionT<Context, Smi>;
// A pointer to a builtin function, used by Torque's function pointers.
using BuiltinPtr = Smi;
......
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