[csa] Make more use of CodeStubAssembler::Call

.. to improve code readability.

Change-Id: I130542600bcad2a016f3dbbedab594a71cddcb9d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2061549
Reviewed-by: Michael Stanton <mvstanton@chromium.org>
Reviewed-by: Tobias Tebbi <tebbi@chromium.org>
Commit-Queue: Georg Neis <neis@chromium.org>
Auto-Submit: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66338}
This commit is contained in:
Georg Neis 2020-02-19 13:28:38 +01:00 committed by Commit Bot
parent 62be3c7eb1
commit 377aeb89cb
14 changed files with 37 additions and 65 deletions

View File

@ -50,8 +50,7 @@ TNode<Object> ArrayBuiltinsAssembler::TypedArrayMapProcessor(
// 8. c. Let mapped_value be ? Call(callbackfn, T, « kValue, k, O »).
TNode<Number> k_number = ChangeUintPtrToTagged(k);
TNode<Object> mapped_value =
CallJS(CodeFactory::Call(isolate()), context(), callbackfn(), this_arg(),
k_value, k_number, o());
Call(context(), callbackfn(), this_arg(), k_value, k_number, o());
Label fast(this), slow(this), done(this), detached(this, Label::kDeferred);
// 8. d. Perform ? Set(A, Pk, mapped_value, true).
@ -1420,9 +1419,9 @@ class ArrayFlattenAssembler : public CodeStubAssembler {
// 1. Set element to ? Call(mapperFunction, thisArg , « element,
// sourceIndex, source »).
element_maybe_smi = CallJS(CodeFactory::Call(isolate()), context,
mapper_function.value(), this_arg.value(),
element_maybe_smi, source_index, source);
element_maybe_smi =
Call(context, mapper_function.value(), this_arg.value(),
element_maybe_smi, source_index, source);
}
// iii. Let shouldFlatten be false.

View File

@ -131,8 +131,7 @@ void AsyncFromSyncBuiltinsAssembler::Generate_AsyncFromSyncIteratorMethod(
TNode<Object> iter_result;
{
ScopedExceptionHandler handler(this, &reject_promise, &var_exception);
iter_result = CallJS(CodeFactory::Call(isolate()), context, method,
sync_iterator, sent_value);
iter_result = Call(context, method, sync_iterator, sent_value);
}
TNode<Object> value;

View File

@ -160,12 +160,10 @@ void BaseCollectionsAssembler::AddConstructorEntry(
: LoadKeyValuePair(context, key_value);
TNode<Object> key_n = pair.key;
TNode<Object> value_n = pair.value;
CallJS(CodeFactory::Call(isolate()), context, add_function, collection,
key_n, value_n);
Call(context, add_function, collection, key_n, value_n);
} else {
DCHECK(variant == kSet || variant == kWeakSet);
CallJS(CodeFactory::Call(isolate()), context, add_function, collection,
key_value);
Call(context, add_function, collection, key_value);
}
}
@ -2034,8 +2032,7 @@ TF_BUILTIN(MapPrototypeForEach, CollectionsBuiltinsAssembler) {
// Invoke the {callback} passing the {entry_key}, {entry_value} and the
// {receiver}.
CallJS(CodeFactory::Call(isolate()), context, callback, this_arg,
entry_value, entry_key, receiver);
Call(context, callback, this_arg, entry_value, entry_key, receiver);
// Continue with the next entry.
var_index = index;
@ -2265,8 +2262,7 @@ TF_BUILTIN(SetPrototypeForEach, CollectionsBuiltinsAssembler) {
NextSkipHoles<OrderedHashSet>(table, index, &done_loop);
// Invoke the {callback} passing the {entry_key} (twice) and the {receiver}.
CallJS(CodeFactory::Call(isolate()), context, callback, this_arg, entry_key,
entry_key, receiver);
Call(context, callback, this_arg, entry_key, entry_key, receiver);
// Continue with the next entry.
var_index = index;

View File

@ -39,12 +39,9 @@ void ConversionBuiltinsAssembler::Generate_NonPrimitiveToPrimitive(
{
// Invoke the {exotic_to_prim} method on the {input} with a string
// representation of the {hint}.
Callable callable =
CodeFactory::Call(isolate(), ConvertReceiverMode::kNotNullOrUndefined);
TNode<String> hint_string =
HeapConstant(factory()->ToPrimitiveHintString(hint));
TNode<Object> result =
CallJS(callable, context, exotic_to_prim, input, hint_string);
TNode<Object> result = Call(context, exotic_to_prim, input, hint_string);
// Verify that the {result} is actually a primitive.
Label if_resultisprimitive(this),
@ -248,9 +245,7 @@ void ConversionBuiltinsAssembler::Generate_OrdinaryToPrimitive(
BIND(&if_methodiscallable);
{
// Call the {method} on the {input}.
Callable callable = CodeFactory::Call(
isolate(), ConvertReceiverMode::kNotNullOrUndefined);
TNode<Object> result = CallJS(callable, context, method, input);
TNode<Object> result = Call(context, method, input);
var_result = result;
// Return the {result} if it is a primitive.

View File

@ -42,8 +42,7 @@ IteratorRecord IteratorBuiltinsAssembler::GetIterator(TNode<Context> context,
BIND(&if_callable);
{
TNode<Object> iterator =
CallJS(CodeFactory::Call(isolate()), context, method, object);
TNode<Object> iterator = Call(context, method, object);
Label get_next(this), if_notobject(this, Label::kDeferred);
GotoIf(TaggedIsSmi(iterator), &if_notobject);
@ -66,9 +65,7 @@ TNode<JSReceiver> IteratorBuiltinsAssembler::IteratorStep(
base::Optional<TNode<Map>> fast_iterator_result_map) {
DCHECK_NOT_NULL(if_done);
// 1. a. Let result be ? Invoke(iterator, "next", « »).
Callable callable = CodeFactory::Call(isolate());
TNode<Object> result =
CallJS(callable, context, iterator.next, iterator.object);
TNode<Object> result = Call(context, iterator.next, iterator.object);
// 3. If Type(result) is not Object, throw a TypeError exception.
Label if_notobject(this, Label::kDeferred), return_result(this);
@ -160,7 +157,7 @@ void IteratorBuiltinsAssembler::IteratorCloseOnException(
// Let innerResult be Call(return, iterator, « »).
// If an exception occurs, the original exception remains bound.
compiler::ScopedExceptionHandler handler(this, if_exception, nullptr);
CallJS(CodeFactory::Call(isolate()), context, method, iterator.object);
Call(context, method, iterator.object);
}
// (If completion.[[Type]] is throw) return Completion(completion).

View File

@ -14,6 +14,8 @@
namespace v8 {
namespace internal {
using compiler::ScopedExceptionHandler;
class MicrotaskQueueBuiltinsAssembler : public CodeStubAssembler {
public:
explicit MicrotaskQueueBuiltinsAssembler(compiler::CodeAssemblerState* state)
@ -149,9 +151,7 @@ void MicrotaskQueueBuiltinsAssembler::RunSingleMicrotask(
LoadObjectField<JSReceiver>(microtask, CallableTask::kCallableOffset);
{
ScopedExceptionHandler handler(this, &if_exception, &var_exception);
CallJS(
CodeFactory::Call(isolate(), ConvertReceiverMode::kNullOrUndefined),
microtask_context, callable, UndefinedConstant());
Call(microtask_context, callable, UndefinedConstant());
}
RewindEnteredContext(saved_entered_context_count);
SetCurrentContext(current_context);

View File

@ -359,7 +359,7 @@ TF_BUILTIN(ObjectPrototypeToLocaleString, CodeStubAssembler) {
TNode<Object> method =
GetProperty(context, receiver, factory()->toString_string());
Return(CallJS(CodeFactory::Call(isolate()), context, method, receiver));
Return(Call(context, method, receiver));
BIND(&if_null_or_undefined);
ThrowTypeError(context, MessageTemplate::kCalledOnNullOrUndefined,

View File

@ -126,8 +126,7 @@ TF_BUILTIN(CallProxy, ProxiesCodeStubAssembler) {
UncheckedCast<IntPtrT>(argc_ptr));
// 8. Return Call(trap, handler, «target, thisArgument, argArray»).
TNode<Object> result = CallJS(CodeFactory::Call(isolate()), context, trap,
handler, target, receiver, array);
TNode<Object> result = Call(context, trap, handler, target, receiver, array);
args.PopAndReturn(result);
BIND(&trap_undefined);
@ -181,8 +180,8 @@ TF_BUILTIN(ConstructProxy, ProxiesCodeStubAssembler) {
UncheckedCast<IntPtrT>(argc_ptr));
// 8. Let newObj be ? Call(trap, handler, « target, argArray, newTarget »).
TNode<Object> new_obj = CallJS(CodeFactory::Call(isolate()), context, trap,
handler, target, array, new_target);
TNode<Object> new_obj =
Call(context, trap, handler, target, array, new_target);
// 9. If Type(newObj) is not Object, throw a TypeError exception.
GotoIf(TaggedIsSmi(new_obj), &not_an_object);

View File

@ -1293,8 +1293,7 @@ TF_BUILTIN(StringPrototypeReplace, StringBuiltinsAssembler) {
replace));
},
[=](TNode<Object> fn) {
Callable call_callable = CodeFactory::Call(isolate());
Return(CallJS(call_callable, context, fn, search, receiver, replace));
Return(Call(context, fn, search, receiver, replace));
});
// Convert {receiver} and {search} to strings.
@ -1394,10 +1393,9 @@ TF_BUILTIN(StringPrototypeReplace, StringBuiltinsAssembler) {
BIND(&if_iscallablereplace);
{
Callable call_callable = CodeFactory::Call(isolate());
const TNode<Object> replacement =
CallJS(call_callable, context, replace, UndefinedConstant(),
search_string, match_start_index, subject_string);
Call(context, replace, UndefinedConstant(), search_string,
match_start_index, subject_string);
const TNode<String> replacement_string =
ToString_Inline(context, replacement);
var_result = CAST(CallBuiltin(Builtins::kStringAdd_CheckNone, context,
@ -1463,8 +1461,7 @@ class StringMatchSearchAssembler : public StringBuiltinsAssembler {
context, maybe_regexp, receiver, symbol, property_to_check,
[=] { Return(CallBuiltin(builtin, context, maybe_regexp, receiver)); },
[=](TNode<Object> fn) {
Callable call_callable = CodeFactory::Call(isolate());
Return(CallJS(call_callable, context, fn, maybe_regexp, receiver));
Return(Call(context, fn, maybe_regexp, receiver));
});
// maybe_regexp is not a RegExp nor has [@@match / @@search] property.
@ -1494,9 +1491,7 @@ class StringMatchSearchAssembler : public StringBuiltinsAssembler {
BIND(&slow_path);
{
TNode<Object> maybe_func = GetProperty(context, regexp, symbol);
Callable call_callable = CodeFactory::Call(isolate());
Return(CallJS(call_callable, context, maybe_func, regexp,
receiver_string));
Return(Call(context, maybe_func, regexp, receiver_string));
}
}
}
@ -1588,8 +1583,7 @@ TF_BUILTIN(StringPrototypeMatchAll, StringBuiltinsAssembler) {
RegExpPrototypeMatchAllImpl(context, native_context, maybe_regexp, s));
};
auto if_generic_call = [=](TNode<Object> fn) {
Callable call_callable = CodeFactory::Call(isolate());
Return(CallJS(call_callable, context, fn, maybe_regexp, receiver));
Return(Call(context, fn, maybe_regexp, receiver));
};
MaybeCallFunctionAtSymbol(
context, maybe_regexp, receiver, isolate()->factory()->match_all_symbol(),
@ -1606,10 +1600,9 @@ TF_BUILTIN(StringPrototypeMatchAll, StringBuiltinsAssembler) {
maybe_regexp, StringConstant("g"));
// 5. Return ? Invoke(rx, @@matchAll, « S »).
Callable callable = CodeFactory::Call(isolate());
TNode<Object> match_all_func =
GetProperty(context, rx, isolate()->factory()->match_all_symbol());
Return(CallJS(callable, context, match_all_func, rx, s));
Return(Call(context, match_all_func, rx, s));
}
// ES6 #sec-string.prototype.search
@ -1724,9 +1717,7 @@ TF_BUILTIN(StringPrototypeSplit, StringBuiltinsAssembler) {
separator, receiver, limit));
},
[&](TNode<Object> fn) {
Callable call_callable = CodeFactory::Call(isolate());
args.PopAndReturn(
CallJS(call_callable, context, fn, separator, receiver, limit));
args.PopAndReturn(Call(context, fn, separator, receiver, limit));
});
// String and integer conversions.

View File

@ -8719,8 +8719,7 @@ TNode<Object> CodeStubAssembler::CallGetterIfAccessor(
BIND(&if_callable);
{
// Call the accessor.
Callable callable = CodeFactory::Call(isolate());
var_value = CallJS(callable, context, getter, receiver);
var_value = Call(context, getter, receiver);
Goto(&done);
}
@ -12168,9 +12167,7 @@ TNode<Oddball> CodeStubAssembler::InstanceOf(TNode<Object> object,
GotoIf(IsUndefined(inst_of_handler), &if_nohandler);
// Call the {inst_of_handler} for {callable} and {object}.
Node* result = CallJS(
CodeFactory::Call(isolate(), ConvertReceiverMode::kNotNullOrUndefined),
context, inst_of_handler, callable, object);
Node* result = Call(context, inst_of_handler, callable, object);
// Convert the {result} to a Boolean.
BranchIfToBooleanIsTrue(result, &return_true, &return_false);

View File

@ -3643,8 +3643,8 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
STATIC_ASSERT(sizeof...(TArgs) <= 3);
const TNode<Object> make_type_error = LoadContextElement(
LoadNativeContext(context), Context::MAKE_TYPE_ERROR_INDEX);
return CAST(CallJS(CodeFactory::Call(isolate()), context, make_type_error,
UndefinedConstant(), SmiConstant(message), args...));
return CAST(Call(context, make_type_error, UndefinedConstant(),
SmiConstant(message), args...));
}
void Abort(AbortReason reason) {

View File

@ -948,6 +948,7 @@ static bool TransitivelyCalledBuiltinHasNoSideEffect(Builtins::Name caller,
case Builtins::kArraySomeLoopContinuation:
case Builtins::kArrayTimSort:
case Builtins::kCall_ReceiverIsAny:
case Builtins::kCall_ReceiverIsNotNullOrUndefined:
case Builtins::kCall_ReceiverIsNullOrUndefined:
case Builtins::kCallWithArrayLike:
case Builtins::kCEntry_Return1_DontSaveFPRegs_ArgvOnStack_NoBuiltinExit:

View File

@ -563,8 +563,7 @@ void AccessorAssembler::HandleLoadICSmiHandlerLoadNamedCase(
LoadObjectField(accessor_pair, AccessorPair::kGetterOffset);
CSA_ASSERT(this, Word32BinaryNot(IsTheHole(getter)));
Callable callable = CodeFactory::Call(isolate());
exit_point->Return(CallJS(callable, p->context(), getter, p->receiver()));
exit_point->Return(Call(p->context(), getter, p->receiver()));
}
BIND(&native_data_property);
@ -1496,7 +1495,7 @@ void AccessorAssembler::HandleStoreAccessor(const StoreICParameters* p,
CSA_ASSERT(this, Word32BinaryNot(IsTheHole(setter)));
Callable callable = CodeFactory::Call(isolate());
Return(CallJS(callable, p->context(), setter, p->receiver(), p->value()));
Return(Call(p->context(), setter, p->receiver(), p->value()));
}
void AccessorAssembler::HandleStoreICProtoHandler(

View File

@ -920,8 +920,7 @@ void KeyedStoreGenericAssembler::EmitGenericPropertyStore(
GotoIf(IsFunctionTemplateInfoMap(setter_map), slow);
GotoIfNot(IsCallableMap(setter_map), &not_callable);
Callable callable = CodeFactory::Call(isolate());
CallJS(callable, p->context(), setter, receiver, p->value());
Call(p->context(), setter, receiver, p->value());
exit_point->Return(p->value());
BIND(&not_callable);