Commit cfdf6ff8 authored by Jakob Gruber's avatar Jakob Gruber Committed by Commit Bot

[nojit] Migrate CallApi stubs to builtins

Bug: v8:7777
Change-Id: Iee3e03b0a3fea245408de4d675caa634a74aa188
Reviewed-on: https://chromium-review.googlesource.com/c/1357053Reviewed-by: 's avatarJaroslav Sevcik <jarin@chromium.org>
Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58036}
parent 8abde08a
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -155,6 +155,8 @@ namespace internal {
ASM(ContinueToJavaScriptBuiltinWithResult) \
\
/* API callback handling */ \
ASM(CallApiCallback) \
ASM(CallApiGetter) \
API(HandleApiCall) \
API(HandleApiCallAsFunction) \
API(HandleApiCallAsConstructor) \
......@@ -1341,9 +1343,6 @@ namespace internal {
TFS(SubString, kString, kFrom, kTo) \
\
/* Miscellaneous */ \
ASM(CallApiCallback_Argc0) \
ASM(CallApiCallback_Argc1) \
ASM(CallApiGetter) \
ASM(DoubleToI) \
TFC(GetProperty, GetProperty, 1) \
TFS(SetProperty, kReceiver, kKey, kValue) \
......
......@@ -758,34 +758,6 @@ void Builtins::Generate_CEntry_Return2_SaveFPRegs_ArgvOnStack_BuiltinExit(
Generate_CEntry(masm, 2, kSaveFPRegs, kArgvOnStack, true);
}
void Builtins::Generate_CallApiGetter(MacroAssembler* masm) {
// CallApiGetterStub only exists as a stub to avoid duplicating code between
// here and code-stubs-<arch>.cc. For example, see CallApiFunctionAndReturn.
// Here we abuse the instantiated stub to generate code.
CallApiGetterStub stub(masm->isolate());
stub.Generate(masm);
}
void Builtins::Generate_CallApiCallback_Argc0(MacroAssembler* masm) {
// The common variants of CallApiCallbackStub (i.e. all that are embedded into
// the snapshot) are generated as builtins. The rest remain available as code
// stubs. Here we abuse the instantiated stub to generate code and avoid
// duplication.
const int kArgc = 0;
CallApiCallbackStub stub(masm->isolate(), kArgc);
stub.Generate(masm);
}
void Builtins::Generate_CallApiCallback_Argc1(MacroAssembler* masm) {
// The common variants of CallApiCallbackStub (i.e. all that are embedded into
// the snapshot) are generated as builtins. The rest remain available as code
// stubs. Here we abuse the instantiated stub to generate code and avoid
// duplication.
const int kArgc = 1;
CallApiCallbackStub stub(masm->isolate(), kArgc);
stub.Generate(masm);
}
// ES6 [[Get]] operation.
TF_BUILTIN(GetProperty, CodeStubAssembler) {
Node* object = Parameter(Descriptor::kObject);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -74,20 +74,9 @@ Callable CodeFactory::ApiGetter(Isolate* isolate) {
}
// static
Callable CodeFactory::CallApiCallback(Isolate* isolate, int argc) {
switch (argc) {
case 0:
return Callable(BUILTIN_CODE(isolate, CallApiCallback_Argc0),
ApiCallbackDescriptor{});
case 1:
return Callable(BUILTIN_CODE(isolate, CallApiCallback_Argc1),
ApiCallbackDescriptor{});
default: {
CallApiCallbackStub stub(isolate, argc);
return make_callable(stub);
}
}
UNREACHABLE();
Callable CodeFactory::CallApiCallback(Isolate* isolate) {
return Callable(BUILTIN_CODE(isolate, CallApiCallback),
ApiCallbackDescriptor{});
}
// static
......
......@@ -59,7 +59,7 @@ class V8_EXPORT_PRIVATE CodeFactory final {
static Callable BinaryOperation(Isolate* isolate, Operation op);
static Callable ApiGetter(Isolate* isolate);
static Callable CallApiCallback(Isolate* isolate, int argc);
static Callable CallApiCallback(Isolate* isolate);
// Code stubs. Add methods here as needed to reduce dependency on
// code-stubs.h.
......
......@@ -24,8 +24,6 @@ class CodeAssemblerState;
// List of code stubs used on all platforms.
#define CODE_STUB_LIST_ALL_PLATFORMS(V) \
/* --- PlatformCodeStubs --- */ \
V(CallApiCallback) \
V(CallApiGetter) \
V(JSEntry)
// List of code stubs only used on ARM 32 bits platforms.
......@@ -383,44 +381,6 @@ class CodeStubDescriptor {
namespace v8 {
namespace internal {
class CommonStoreModeBits : public BitField<KeyedAccessStoreMode, 0, 3> {};
class CallApiCallbackStub : public PlatformCodeStub {
public:
static const int kArgBits = 7;
static const int kArgMax = (1 << kArgBits) - 1;
CallApiCallbackStub(Isolate* isolate, int argc)
: PlatformCodeStub(isolate) {
CHECK_LE(0, argc); // The argc in {0, 1} cases are covered by builtins.
CHECK_LE(argc, kArgMax);
minor_key_ = ArgumentBits::encode(argc);
}
private:
int argc() const { return ArgumentBits::decode(minor_key_); }
class ArgumentBits : public BitField<int, 0, kArgBits> {};
friend class Builtins; // For generating the related builtin.
DEFINE_CALL_INTERFACE_DESCRIPTOR(ApiCallback);
DEFINE_PLATFORM_CODE_STUB(CallApiCallback, PlatformCodeStub);
};
// TODO(jgruber): This stub only exists to avoid code duplication between
// code-stubs-<arch>.cc and builtins-<arch>.cc. If CallApiCallbackStub is ever
// completely removed, CallApiGetterStub can also be deleted.
class CallApiGetterStub : public PlatformCodeStub {
private:
// For generating the related builtin.
explicit CallApiGetterStub(Isolate* isolate) : PlatformCodeStub(isolate) {}
friend class Builtins;
DEFINE_CALL_INTERFACE_DESCRIPTOR(ApiGetter);
DEFINE_PLATFORM_CODE_STUB(CallApiGetter, PlatformCodeStub);
};
class JSEntryStub : public PlatformCodeStub {
public:
enum class SpecialTarget { kNone, kRunMicrotasks };
......
......@@ -2868,8 +2868,6 @@ Reduction JSCallReducer::ReduceCallApiFunction(
Handle<FunctionTemplateInfo> function_template_info(
FunctionTemplateInfo::cast(shared.object()->function_data()), isolate());
if (argc > CallApiCallbackStub::kArgMax) return NoChange();
// Infer the {receiver} maps, and check if we can inline the API function
// callback based on those.
ZoneHandleSet<Map> receiver_maps;
......@@ -2927,7 +2925,7 @@ Reduction JSCallReducer::ReduceCallApiFunction(
Handle<CallHandlerInfo> call_handler_info(
CallHandlerInfo::cast(function_template_info->call_code()), isolate());
Handle<Object> data(call_handler_info->data(), isolate());
Callable call_api_callback = CodeFactory::CallApiCallback(isolate(), argc);
Callable call_api_callback = CodeFactory::CallApiCallback(isolate());
CallInterfaceDescriptor cid = call_api_callback.descriptor();
auto call_descriptor = Linkage::GetStubCallDescriptor(
graph()->zone(), cid,
......
......@@ -2020,7 +2020,7 @@ Node* JSNativeContextSpecialization::InlineApiCall(
// Only setters have a value.
int const argc = value == nullptr ? 0 : 1;
// The stub always expects the receiver as the first param on the stack.
Callable call_api_callback = CodeFactory::CallApiCallback(isolate(), argc);
Callable call_api_callback = CodeFactory::CallApiCallback(isolate());
CallInterfaceDescriptor call_interface_descriptor =
call_api_callback.descriptor();
auto call_descriptor = Linkage::GetStubCallDescriptor(
......
This diff is collapsed.
......@@ -272,7 +272,7 @@ void AccessorAssembler::HandleLoadAccessor(
Goto(&load);
BIND(&load);
Callable callable = CodeFactory::CallApiCallback(isolate(), 0);
Callable callable = CodeFactory::CallApiCallback(isolate());
TNode<IntPtrT> argc = IntPtrConstant(0);
exit_point->Return(CallStub(callable, nullptr, context, callback, argc,
data, api_holder.value(), p->receiver));
......@@ -1415,7 +1415,7 @@ void AccessorAssembler::HandleStoreICProtoHandler(
Goto(&store);
BIND(&store);
Callable callable = CodeFactory::CallApiCallback(isolate(), 1);
Callable callable = CodeFactory::CallApiCallback(isolate());
TNode<IntPtrT> argc = IntPtrConstant(1);
Return(CallStub(callable, nullptr, context, callback, argc, data,
api_holder.value(), p->receiver, p->value));
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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