Commit bee98aec authored by peterwmwong's avatar peterwmwong Committed by Commit Bot

Remove SubString intrinsic and convert SubString code stub to CSA.

Bug: v8:5049
Change-Id: Ia4f5729be64794e9080eb0e644b86cd5d8c88a11
Reviewed-on: https://chromium-review.googlesource.com/722168Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48661}
parent 1cee0e01
......@@ -100,6 +100,7 @@ namespace internal {
TFC(StringLessThan, Compare, 1) \
TFC(StringLessThanOrEqual, Compare, 1) \
TFS(StringRepeat, kString, kCount) \
TFS(SubString, kString, kFrom, kTo) \
\
/* OrderedHashTable helpers */ \
TFS(OrderedHashTableHealIndex, kTable, kIndex) \
......
......@@ -1166,8 +1166,8 @@ compiler::Node* StringBuiltinsAssembler::GetSubstitution(
{
CSA_ASSERT(this, TaggedIsPositiveSmi(dollar_index));
Callable substring_callable = CodeFactory::SubString(isolate());
Node* const matched = CallStub(substring_callable, context, subject_string,
Node* const matched =
CallBuiltin(Builtins::kSubString, context, subject_string,
match_start_index, match_end_index);
Node* const replacement_string =
CallRuntime(Runtime::kGetSubstitution, context, matched, subject_string,
......@@ -1396,7 +1396,6 @@ TF_BUILTIN(StringPrototypeReplace, StringBuiltinsAssembler) {
Node* const match_end_index = SmiAdd(match_start_index, search_length);
Callable substring_callable = CodeFactory::SubString(isolate());
Callable stringadd_callable =
CodeFactory::StringAdd(isolate(), STRING_ADD_CHECK_NONE, NOT_TENURED);
......@@ -1407,8 +1406,9 @@ TF_BUILTIN(StringPrototypeReplace, StringBuiltinsAssembler) {
Label next(this);
GotoIf(SmiEqual(match_start_index, smi_zero), &next);
Node* const prefix = CallStub(substring_callable, context, subject_string,
smi_zero, match_start_index);
Node* const prefix =
CallBuiltin(Builtins::kSubString, context, subject_string, smi_zero,
match_start_index);
var_result.Bind(prefix);
Goto(&next);
......@@ -1447,7 +1447,8 @@ TF_BUILTIN(StringPrototypeReplace, StringBuiltinsAssembler) {
BIND(&out);
{
Node* const suffix = CallStub(substring_callable, context, subject_string,
Node* const suffix =
CallBuiltin(Builtins::kSubString, context, subject_string,
match_end_index, subject_length);
Node* const result =
CallStub(stringadd_callable, context, var_result.value(), suffix);
......@@ -1628,9 +1629,8 @@ class StringPadAssembler : public StringBuiltinsAssembler {
GotoIfNot(remaining_word32, &return_result);
{
Callable substring_callable = CodeFactory::SubString(isolate());
Node* const remainder_string =
CallStub(substring_callable, context, var_fill_string.value(),
Node* const remainder_string = CallBuiltin(
Builtins::kSubString, context, var_fill_string.value(),
SmiConstant(0), SmiFromWord32(remaining_word32));
var_pad.Bind(CallStub(stringadd_callable, context, var_pad.value(),
remainder_string));
......@@ -1998,6 +1998,15 @@ TNode<Smi> StringBuiltinsAssembler::ToSmiBetweenZeroAnd(
return var_result;
}
TF_BUILTIN(SubString, CodeStubAssembler) {
Node* context = Parameter(Descriptor::kContext);
Node* string = Parameter(Descriptor::kString);
Node* from = Parameter(Descriptor::kFrom);
Node* to = Parameter(Descriptor::kTo);
Return(SubString(context, string, from, to));
}
// ES6 #sec-string.prototype.substring
TF_BUILTIN(StringPrototypeSubstring, StringBuiltinsAssembler) {
const int kStartArg = 0;
......
......@@ -178,12 +178,6 @@ Callable CodeFactory::StringCompare(Isolate* isolate, Token::Value token) {
UNREACHABLE();
}
// static
Callable CodeFactory::SubString(Isolate* isolate) {
SubStringStub stub(isolate);
return Callable(stub.GetCode(), stub.GetCallInterfaceDescriptor());
}
// static
Callable CodeFactory::ResumeGenerator(Isolate* isolate) {
return Callable(BUILTIN_CODE(isolate, ResumeGeneratorTrampoline),
......
......@@ -58,7 +58,6 @@ class V8_EXPORT_PRIVATE CodeFactory final {
StringAddFlags flags = STRING_ADD_CHECK_NONE,
PretenureFlag pretenure_flag = NOT_TENURED);
static Callable StringCompare(Isolate* isolate, Token::Value token);
static Callable SubString(Isolate* isolate);
static Callable FastNewFunctionContext(Isolate* isolate,
ScopeType scope_type);
......
......@@ -362,16 +362,6 @@ TF_STUB(NumberToStringStub, CodeStubAssembler) {
Return(NumberToString(context, argument));
}
// TODO(ishell): move to builtins.
TF_STUB(SubStringStub, CodeStubAssembler) {
Node* context = Parameter(Descriptor::kContext);
Node* string = Parameter(Descriptor::kString);
Node* from = Parameter(Descriptor::kFrom);
Node* to = Parameter(Descriptor::kTo);
Return(SubString(context, string, from, to));
}
// TODO(ishell): move to builtins-handler-gen.
TF_STUB(KeyedLoadSloppyArgumentsStub, CodeStubAssembler) {
Node* receiver = Parameter(Descriptor::kReceiver);
......
......@@ -41,7 +41,6 @@ class Node;
V(RecordWrite) \
V(StoreBufferOverflow) \
V(StoreSlowElement) \
V(SubString) \
V(NameDictionaryLookup) \
/* --- TurboFanCodeStubs --- */ \
V(ArrayNoArgumentConstructor) \
......@@ -1114,15 +1113,6 @@ class StoreBufferOverflowStub : public PlatformCodeStub {
DEFINE_PLATFORM_CODE_STUB(StoreBufferOverflow, PlatformCodeStub);
};
class SubStringStub : public TurboFanCodeStub {
public:
explicit SubStringStub(Isolate* isolate) : TurboFanCodeStub(isolate) {}
DEFINE_CALL_INTERFACE_DESCRIPTOR(SubString);
DEFINE_TURBOFAN_CODE_STUB(SubString, TurboFanCodeStub);
};
#undef DEFINE_CALL_INTERFACE_DESCRIPTOR
#undef DEFINE_PLATFORM_CODE_STUB
#undef DEFINE_HANDLER_CODE_STUB
......
......@@ -69,8 +69,6 @@ Reduction JSIntrinsicLowering::Reduce(Node* node) {
return ReduceIsJSReceiver(node);
case Runtime::kInlineIsSmi:
return ReduceIsSmi(node);
case Runtime::kInlineSubString:
return ReduceSubString(node);
case Runtime::kInlineToInteger:
return ReduceToInteger(node);
case Runtime::kInlineToLength:
......@@ -281,11 +279,6 @@ Reduction JSIntrinsicLowering::Change(Node* node, const Operator* op) {
return Changed(node);
}
Reduction JSIntrinsicLowering::ReduceSubString(Node* node) {
return Change(node, CodeFactory::SubString(isolate()), 3);
}
Reduction JSIntrinsicLowering::ReduceToInteger(Node* node) {
NodeProperties::ChangeOp(node, javascript()->ToInteger());
return Changed(node);
......
......@@ -54,7 +54,6 @@ class V8_EXPORT_PRIVATE JSIntrinsicLowering final
Reduction ReduceIsInstanceType(Node* node, InstanceType instance_type);
Reduction ReduceIsJSReceiver(Node* node);
Reduction ReduceIsSmi(Node* node);
Reduction ReduceSubString(Node* node);
Reduction ReduceToInteger(Node* node);
Reduction ReduceToLength(Node* node);
Reduction ReduceToNumber(Node* node);
......
......@@ -1678,7 +1678,6 @@ Type* Typer::Visitor::TypeJSCallRuntime(Node* node) {
return Type::Boolean();
case Runtime::kInlineCreateIterResultObject:
return Type::OtherObject();
case Runtime::kInlineSubString:
case Runtime::kInlineStringCharFromCode:
return Type::String();
case Runtime::kInlineToInteger:
......
......@@ -630,6 +630,7 @@ bool BuiltinHasNoSideEffect(Builtins::Name id) {
case Builtins::kStringPrototypeTrimRight:
case Builtins::kStringPrototypeValueOf:
case Builtins::kStringToNumber:
case Builtins::kSubString:
// Symbol builtins.
case Builtins::kSymbolConstructor:
case Builtins::kSymbolKeyFor:
......
......@@ -63,7 +63,6 @@ class PlatformInterfaceDescriptor;
V(StringCharAt) \
V(StringCharCodeAt) \
V(StringCompare) \
V(SubString) \
V(ForInPrepare) \
V(GetProperty) \
V(ArgumentAdaptor) \
......@@ -750,13 +749,6 @@ class StringCompareDescriptor : public CallInterfaceDescriptor {
static const Register RightRegister();
};
class SubStringDescriptor : public CallInterfaceDescriptor {
public:
DEFINE_PARAMETERS(kString, kFrom, kTo)
DECLARE_DESCRIPTOR_WITH_STACK_ARGS(SubStringDescriptor,
CallInterfaceDescriptor)
};
class ArgumentAdaptorDescriptor : public CallInterfaceDescriptor {
public:
DEFINE_PARAMETERS(kFunction, kNewTarget, kActualArgumentsCount,
......
......@@ -282,11 +282,6 @@ Node* IntrinsicsGenerator::HasProperty(Node* input, Node* arg_count,
input, context, Builtins::CallableFor(isolate(), Builtins::kHasProperty));
}
Node* IntrinsicsGenerator::SubString(Node* input, Node* arg_count,
Node* context) {
return IntrinsicAsStubCall(input, context, CodeFactory::SubString(isolate()));
}
Node* IntrinsicsGenerator::ToString(Node* input, Node* arg_count,
Node* context) {
return IntrinsicAsStubCall(
......
......@@ -36,7 +36,6 @@ namespace interpreter {
V(IsJSWeakSet, is_js_weak_set, 1) \
V(IsSmi, is_smi, 1) \
V(IsTypedArray, is_typed_array, 1) \
V(SubString, sub_string, 3) \
V(ToString, to_string, 1) \
V(ToLength, to_length, 1) \
V(ToInteger, to_integer, 1) \
......
......@@ -237,8 +237,9 @@ RUNTIME_FUNCTION(Runtime_SubString) {
} else {
return isolate->ThrowIllegalOperation();
}
// The following condition is intentionally robust because the SubStringStub
// delegates here and we test this in cctest/test-strings/RobustSubStringStub.
// The following condition is intentionally robust because the SubString
// builtin delegates here and we test this in
// cctest/test-strings/RobustSubStringStub.
if (end < start || start < 0 || end > string->length()) {
return isolate->ThrowIllegalOperation();
}
......
......@@ -116,14 +116,6 @@ TEST(StringCompare) {
}
TEST(SubString) {
FunctionTester T("(function(a,b) { return %_SubString(a,b,b+3); })", flags);
T.CheckCall(T.Val("aaa"), T.Val("aaabbb"), T.Val(0.0));
T.CheckCall(T.Val("abb"), T.Val("aaabbb"), T.Val(2));
T.CheckCall(T.Val("aaa"), T.Val("aaa"), T.Val(0.0));
}
} // namespace compiler
} // namespace internal
} // namespace v8
......@@ -216,14 +216,6 @@ TEST(IntrinsicAsStubCall) {
*has_property_helper.Invoke(
has_property_helper.NewObject("'y'"),
has_property_helper.NewObject("({ x: 20 })")));
InvokeIntrinsicHelper sub_string_helper(isolate, handles.main_zone(),
Runtime::kInlineSubString);
CHECK(sub_string_helper
.Invoke(sub_string_helper.NewObject("'foobar'"),
sub_string_helper.NewObject("3"),
sub_string_helper.NewObject("6"))
->SameValue(*sub_string_helper.NewObject("'bar'")));
}
TEST(ClassOf) {
......
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