Commit 2b0f6654 authored by Igor Sheludko's avatar Igor Sheludko Committed by Commit Bot

[builtins] Don't refer to builtin's parameters from helper methods.

This is a preliminary step before removing BuiltinDescriptor.

Bug: v8:7754
Change-Id: I752134aa29431e5773c9813361a3c6bda6f8872d
Reviewed-on: https://chromium-review.googlesource.com/1104169Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53794}
parent e602c90a
......@@ -2900,7 +2900,8 @@ class ArrayIncludesIndexofAssembler : public CodeStubAssembler {
enum SearchVariant { kIncludes, kIndexOf };
void Generate(SearchVariant variant);
void Generate(SearchVariant variant, TNode<IntPtrT> argc,
TNode<Context> context);
void GenerateSmiOrObject(SearchVariant variant, Node* context, Node* elements,
Node* search_element, Node* array_length,
Node* from_index);
......@@ -2912,18 +2913,17 @@ class ArrayIncludesIndexofAssembler : public CodeStubAssembler {
Node* from_index);
};
void ArrayIncludesIndexofAssembler::Generate(SearchVariant variant) {
void ArrayIncludesIndexofAssembler::Generate(SearchVariant variant,
TNode<IntPtrT> argc,
TNode<Context> context) {
const int kSearchElementArg = 0;
const int kFromIndexArg = 1;
TNode<IntPtrT> argc =
ChangeInt32ToIntPtr(Parameter(BuiltinDescriptor::kArgumentsCount));
CodeStubArguments args(this, argc);
TNode<Object> receiver = args.GetReceiver();
TNode<Object> search_element =
args.GetOptionalArgumentValue(kSearchElementArg);
TNode<Context> context = CAST(Parameter(BuiltinDescriptor::kContext));
Node* intptr_zero = IntPtrConstant(0);
......@@ -3388,7 +3388,11 @@ void ArrayIncludesIndexofAssembler::GenerateHoleyDoubles(SearchVariant variant,
}
TF_BUILTIN(ArrayIncludes, ArrayIncludesIndexofAssembler) {
Generate(kIncludes);
TNode<IntPtrT> argc =
ChangeInt32ToIntPtr(Parameter(BuiltinDescriptor::kArgumentsCount));
TNode<Context> context = CAST(Parameter(BuiltinDescriptor::kContext));
Generate(kIncludes, argc, context);
}
TF_BUILTIN(ArrayIncludesSmiOrObject, ArrayIncludesIndexofAssembler) {
......@@ -3422,7 +3426,13 @@ TF_BUILTIN(ArrayIncludesHoleyDoubles, ArrayIncludesIndexofAssembler) {
from_index);
}
TF_BUILTIN(ArrayIndexOf, ArrayIncludesIndexofAssembler) { Generate(kIndexOf); }
TF_BUILTIN(ArrayIndexOf, ArrayIncludesIndexofAssembler) {
TNode<IntPtrT> argc =
ChangeInt32ToIntPtr(Parameter(BuiltinDescriptor::kArgumentsCount));
TNode<Context> context = CAST(Parameter(BuiltinDescriptor::kContext));
Generate(kIndexOf, argc, context);
}
TF_BUILTIN(ArrayIndexOfSmiOrObject, ArrayIncludesIndexofAssembler) {
Node* context = Parameter(Descriptor::kContext);
......
......@@ -82,7 +82,9 @@ class BaseCollectionsAssembler : public CodeStubAssembler {
// Main entry point for a collection constructor builtin.
void GenerateConstructor(Variant variant,
Handle<String> constructor_function_name);
Handle<String> constructor_function_name,
TNode<Object> new_target, TNode<IntPtrT> argc,
TNode<Context> context);
// Retrieves the collection function that adds an entry. `set` for Maps and
// `add` for Sets.
......@@ -354,13 +356,11 @@ TNode<Object> BaseCollectionsAssembler::AllocateJSCollectionSlow(
}
void BaseCollectionsAssembler::GenerateConstructor(
Variant variant, Handle<String> constructor_function_name) {
Variant variant, Handle<String> constructor_function_name,
TNode<Object> new_target, TNode<IntPtrT> argc, TNode<Context> context) {
const int kIterableArg = 0;
CodeStubArguments args(
this, ChangeInt32ToIntPtr(Parameter(BuiltinDescriptor::kArgumentsCount)));
CodeStubArguments args(this, argc);
TNode<Object> iterable = args.GetOptionalArgumentValue(kIterableArg);
TNode<Object> new_target = CAST(Parameter(BuiltinDescriptor::kNewTarget));
TNode<Context> context = CAST(Parameter(BuiltinDescriptor::kContext));
Label if_undefined(this, Label::kDeferred);
GotoIf(IsUndefined(new_target), &if_undefined);
......@@ -745,11 +745,23 @@ TNode<Object> CollectionsBuiltinsAssembler::AllocateTable(
}
TF_BUILTIN(MapConstructor, CollectionsBuiltinsAssembler) {
GenerateConstructor(kMap, isolate()->factory()->Map_string());
TNode<Object> new_target = CAST(Parameter(BuiltinDescriptor::kNewTarget));
TNode<IntPtrT> argc =
ChangeInt32ToIntPtr(Parameter(BuiltinDescriptor::kArgumentsCount));
TNode<Context> context = CAST(Parameter(BuiltinDescriptor::kContext));
GenerateConstructor(kMap, isolate()->factory()->Map_string(), new_target,
argc, context);
}
TF_BUILTIN(SetConstructor, CollectionsBuiltinsAssembler) {
GenerateConstructor(kSet, isolate()->factory()->Set_string());
TNode<Object> new_target = CAST(Parameter(BuiltinDescriptor::kNewTarget));
TNode<IntPtrT> argc =
ChangeInt32ToIntPtr(Parameter(BuiltinDescriptor::kArgumentsCount));
TNode<Context> context = CAST(Parameter(BuiltinDescriptor::kContext));
GenerateConstructor(kSet, isolate()->factory()->Set_string(), new_target,
argc, context);
}
Node* CollectionsBuiltinsAssembler::CallGetOrCreateHashRaw(Node* const key) {
......@@ -2224,11 +2236,23 @@ TNode<IntPtrT> WeakCollectionsBuiltinsAssembler::ValueIndexFromKeyIndex(
}
TF_BUILTIN(WeakMapConstructor, WeakCollectionsBuiltinsAssembler) {
GenerateConstructor(kWeakMap, isolate()->factory()->WeakMap_string());
TNode<Object> new_target = CAST(Parameter(BuiltinDescriptor::kNewTarget));
TNode<IntPtrT> argc =
ChangeInt32ToIntPtr(Parameter(BuiltinDescriptor::kArgumentsCount));
TNode<Context> context = CAST(Parameter(BuiltinDescriptor::kContext));
GenerateConstructor(kWeakMap, isolate()->factory()->WeakMap_string(),
new_target, argc, context);
}
TF_BUILTIN(WeakSetConstructor, WeakCollectionsBuiltinsAssembler) {
GenerateConstructor(kWeakSet, isolate()->factory()->WeakSet_string());
TNode<Object> new_target = CAST(Parameter(BuiltinDescriptor::kNewTarget));
TNode<IntPtrT> argc =
ChangeInt32ToIntPtr(Parameter(BuiltinDescriptor::kArgumentsCount));
TNode<Context> context = CAST(Parameter(BuiltinDescriptor::kContext));
GenerateConstructor(kWeakSet, isolate()->factory()->WeakSet_string(),
new_target, argc, context);
}
TF_BUILTIN(WeakMapLookupHashIndex, WeakCollectionsBuiltinsAssembler) {
......
......@@ -990,24 +990,30 @@ TF_BUILTIN(StringIndexOf, StringBuiltinsAssembler) {
// ES6 String.prototype.includes(searchString [, position])
// #sec-string.prototype.includes
TF_BUILTIN(StringPrototypeIncludes, StringIncludesIndexOfAssembler) {
Generate(kIncludes);
// TODO(ishell): use constants from Descriptor once the JSFunction linkage
// arguments are reordered.
TNode<IntPtrT> argc =
ChangeInt32ToIntPtr(Parameter(BuiltinDescriptor::kArgumentsCount));
TNode<Context> context = CAST(Parameter(BuiltinDescriptor::kContext));
Generate(kIncludes, argc, context);
}
// ES6 String.prototype.indexOf(searchString [, position])
// #sec-string.prototype.indexof
TF_BUILTIN(StringPrototypeIndexOf, StringIncludesIndexOfAssembler) {
Generate(kIndexOf);
}
void StringIncludesIndexOfAssembler::Generate(SearchVariant variant) {
// TODO(ishell): use constants from Descriptor once the JSFunction linkage
// arguments are reordered.
Node* argc = Parameter(BuiltinDescriptor::kArgumentsCount);
Node* const context = Parameter(BuiltinDescriptor::kContext);
CodeStubArguments arguments(this, ChangeInt32ToIntPtr(argc));
TNode<IntPtrT> argc =
ChangeInt32ToIntPtr(Parameter(BuiltinDescriptor::kArgumentsCount));
TNode<Context> context = CAST(Parameter(BuiltinDescriptor::kContext));
Generate(kIndexOf, argc, context);
}
void StringIncludesIndexOfAssembler::Generate(SearchVariant variant,
TNode<IntPtrT> argc,
TNode<Context> context) {
CodeStubArguments arguments(this, argc);
Node* const receiver = arguments.GetReceiver();
// From now on use word-size argc value.
argc = arguments.GetLength(INTPTR_PARAMETERS);
VARIABLE(var_search_string, MachineRepresentation::kTagged);
VARIABLE(var_position, MachineRepresentation::kTagged);
......@@ -1620,10 +1626,8 @@ class StringPadAssembler : public StringBuiltinsAssembler {
protected:
enum Variant { kStart, kEnd };
void Generate(Variant variant, const char* method_name) {
Node* const context = Parameter(BuiltinDescriptor::kContext);
Node* argc =
ChangeInt32ToIntPtr(Parameter(BuiltinDescriptor::kArgumentsCount));
void Generate(Variant variant, const char* method_name, TNode<IntPtrT> argc,
TNode<Context> context) {
CodeStubArguments arguments(this, argc);
Node* const receiver = arguments.GetReceiver();
Node* const receiver_string = ToThisString(context, receiver, method_name);
......@@ -1733,11 +1737,19 @@ class StringPadAssembler : public StringBuiltinsAssembler {
};
TF_BUILTIN(StringPrototypePadEnd, StringPadAssembler) {
Generate(kEnd, "String.prototype.padEnd");
TNode<IntPtrT> argc =
ChangeInt32ToIntPtr(Parameter(BuiltinDescriptor::kArgumentsCount));
TNode<Context> context = CAST(Parameter(BuiltinDescriptor::kContext));
Generate(kEnd, "String.prototype.padEnd", argc, context);
}
TF_BUILTIN(StringPrototypePadStart, StringPadAssembler) {
Generate(kStart, "String.prototype.padStart");
TNode<IntPtrT> argc =
ChangeInt32ToIntPtr(Parameter(BuiltinDescriptor::kArgumentsCount));
TNode<Context> context = CAST(Parameter(BuiltinDescriptor::kContext));
Generate(kStart, "String.prototype.padStart", argc, context);
}
// ES6 #sec-string.prototype.search
......@@ -2190,26 +2202,37 @@ TF_BUILTIN(StringPrototypeSubstring, StringBuiltinsAssembler) {
// ES6 #sec-string.prototype.trim
TF_BUILTIN(StringPrototypeTrim, StringTrimAssembler) {
Generate(String::kTrim, "String.prototype.trim");
TNode<IntPtrT> argc =
ChangeInt32ToIntPtr(Parameter(BuiltinDescriptor::kArgumentsCount));
TNode<Context> context = CAST(Parameter(BuiltinDescriptor::kContext));
Generate(String::kTrim, "String.prototype.trim", argc, context);
}
// https://github.com/tc39/proposal-string-left-right-trim
TF_BUILTIN(StringPrototypeTrimStart, StringTrimAssembler) {
Generate(String::kTrimStart, "String.prototype.trimLeft");
TNode<IntPtrT> argc =
ChangeInt32ToIntPtr(Parameter(BuiltinDescriptor::kArgumentsCount));
TNode<Context> context = CAST(Parameter(BuiltinDescriptor::kContext));
Generate(String::kTrimStart, "String.prototype.trimLeft", argc, context);
}
// https://github.com/tc39/proposal-string-left-right-trim
TF_BUILTIN(StringPrototypeTrimEnd, StringTrimAssembler) {
Generate(String::kTrimEnd, "String.prototype.trimRight");
TNode<IntPtrT> argc =
ChangeInt32ToIntPtr(Parameter(BuiltinDescriptor::kArgumentsCount));
TNode<Context> context = CAST(Parameter(BuiltinDescriptor::kContext));
Generate(String::kTrimEnd, "String.prototype.trimRight", argc, context);
}
void StringTrimAssembler::Generate(String::TrimMode mode,
const char* method_name) {
const char* method_name, TNode<IntPtrT> argc,
TNode<Context> context) {
Label return_emptystring(this), if_runtime(this);
Node* const argc = Parameter(BuiltinDescriptor::kArgumentsCount);
Node* const context = Parameter(BuiltinDescriptor::kContext);
CodeStubArguments arguments(this, ChangeInt32ToIntPtr(argc));
CodeStubArguments arguments(this, argc);
Node* const receiver = arguments.GetReceiver();
// Check that {receiver} is coercible to Object and convert it to a String.
......
......@@ -120,7 +120,8 @@ class StringIncludesIndexOfAssembler : public StringBuiltinsAssembler {
protected:
enum SearchVariant { kIncludes, kIndexOf };
void Generate(SearchVariant variant);
void Generate(SearchVariant variant, TNode<IntPtrT> argc,
TNode<Context> context);
};
class StringTrimAssembler : public StringBuiltinsAssembler {
......@@ -132,7 +133,8 @@ class StringTrimAssembler : public StringBuiltinsAssembler {
Label* const if_not_whitespace);
protected:
void Generate(String::TrimMode mode, const char* method);
void Generate(String::TrimMode mode, const char* method, TNode<IntPtrT> argc,
TNode<Context> context);
void ScanForNonWhiteSpaceOrLineTerminator(Node* const string_data,
Node* const string_data_offset,
......
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