Commit a8bff771 authored by Victor Gomes's avatar Victor Gomes Committed by V8 LUCI CQ

[maglev] Support intrinsics

Except CopyDataPropertiesWithExcludedPropertiesOnStack.

Bug: v8:7700
Change-Id: Ie7e070002071291da2d9279c601a78b22113fc9b
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3804864Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Auto-Submit: Victor Gomes <victorgomes@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82157}
parent 59c55c1c
......@@ -4,3 +4,8 @@ include_rules = [
# separate directory.
"+src/compiler",
]
specific_include_rules = {
"maglev-graph-builder\.h": [
"+src/interpreter/interpreter-intrinsics.h",
],
}
\ No newline at end of file
......@@ -1723,7 +1723,154 @@ void MaglevGraphBuilder::VisitCallRuntime() {
MAGLEV_UNIMPLEMENTED_BYTECODE(CallRuntimeForPair)
MAGLEV_UNIMPLEMENTED_BYTECODE(CallJSRuntime)
MAGLEV_UNIMPLEMENTED_BYTECODE(InvokeIntrinsic)
void MaglevGraphBuilder::VisitInvokeIntrinsic() {
// InvokeIntrinsic <function_id> <first_arg> <arg_count>
Runtime::FunctionId intrinsic_id = iterator_.GetIntrinsicIdOperand(0);
interpreter::RegisterList args = iterator_.GetRegisterListOperand(1);
switch (intrinsic_id) {
#define CASE(Name, _, arg_count) \
case Runtime::kInline##Name: \
DCHECK_IMPLIES(arg_count != -1, arg_count == args.register_count()); \
VisitIntrinsic##Name(args); \
break;
INTRINSICS_LIST(CASE)
#undef CASE
default:
UNREACHABLE();
}
}
void MaglevGraphBuilder::VisitIntrinsicCopyDataProperties(
interpreter::RegisterList args) {
DCHECK_EQ(args.register_count(), 2);
SetAccumulator(BuildCallBuiltin<Builtin::kCopyDataProperties>(
{GetTaggedValue(args[0]), GetTaggedValue(args[1])}));
}
void MaglevGraphBuilder::
VisitIntrinsicCopyDataPropertiesWithExcludedPropertiesOnStack(
interpreter::RegisterList args) {
MAGLEV_UNIMPLEMENTED(CopyDataPropertiesWithExcludedPropertiesOnStack);
}
void MaglevGraphBuilder::VisitIntrinsicCreateIterResultObject(
interpreter::RegisterList args) {
DCHECK_EQ(args.register_count(), 2);
SetAccumulator(BuildCallBuiltin<Builtin::kCreateIterResultObject>(
{GetTaggedValue(args[0]), GetTaggedValue(args[1])}));
}
void MaglevGraphBuilder::VisitIntrinsicCreateAsyncFromSyncIterator(
interpreter::RegisterList args) {
DCHECK_EQ(args.register_count(), 1);
SetAccumulator(
BuildCallBuiltin<Builtin::kCreateAsyncFromSyncIteratorBaseline>(
{GetTaggedValue(args[0])}));
}
void MaglevGraphBuilder::VisitIntrinsicCreateJSGeneratorObject(
interpreter::RegisterList args) {
DCHECK_EQ(args.register_count(), 2);
SetAccumulator(BuildCallBuiltin<Builtin::kCreateGeneratorObject>(
{GetTaggedValue(args[0]), GetTaggedValue(args[1])}));
}
void MaglevGraphBuilder::VisitIntrinsicGeneratorGetResumeMode(
interpreter::RegisterList args) {
DCHECK_EQ(args.register_count(), 1);
ValueNode* generator = GetTaggedValue(args[0]);
SetAccumulator(AddNewNode<LoadTaggedField>(
{generator}, JSGeneratorObject::kResumeModeOffset));
}
void MaglevGraphBuilder::VisitIntrinsicGeneratorClose(
interpreter::RegisterList args) {
DCHECK_EQ(args.register_count(), 1);
ValueNode* generator = GetTaggedValue(args[0]);
ValueNode* value = GetSmiConstant(JSGeneratorObject::kGeneratorClosed);
AddNewNode<StoreTaggedFieldNoWriteBarrier>(
{generator, value}, JSGeneratorObject::kContinuationOffset);
SetAccumulator(GetRootConstant(RootIndex::kUndefinedValue));
}
void MaglevGraphBuilder::VisitIntrinsicGetImportMetaObject(
interpreter::RegisterList args) {
DCHECK_EQ(args.register_count(), 0);
SetAccumulator(BuildCallRuntime(Runtime::kGetImportMetaObject, {}));
}
void MaglevGraphBuilder::VisitIntrinsicAsyncFunctionAwaitCaught(
interpreter::RegisterList args) {
DCHECK_EQ(args.register_count(), 2);
SetAccumulator(BuildCallBuiltin<Builtin::kAsyncFunctionAwaitCaught>(
{GetTaggedValue(args[0]), GetTaggedValue(args[1])}));
}
void MaglevGraphBuilder::VisitIntrinsicAsyncFunctionAwaitUncaught(
interpreter::RegisterList args) {
DCHECK_EQ(args.register_count(), 2);
SetAccumulator(BuildCallBuiltin<Builtin::kAsyncFunctionAwaitUncaught>(
{GetTaggedValue(args[0]), GetTaggedValue(args[1])}));
}
void MaglevGraphBuilder::VisitIntrinsicAsyncFunctionEnter(
interpreter::RegisterList args) {
DCHECK_EQ(args.register_count(), 2);
SetAccumulator(BuildCallBuiltin<Builtin::kAsyncFunctionEnter>(
{GetTaggedValue(args[0]), GetTaggedValue(args[1])}));
}
void MaglevGraphBuilder::VisitIntrinsicAsyncFunctionReject(
interpreter::RegisterList args) {
DCHECK_EQ(args.register_count(), 2);
SetAccumulator(BuildCallBuiltin<Builtin::kAsyncFunctionReject>(
{GetTaggedValue(args[0]), GetTaggedValue(args[1])}));
}
void MaglevGraphBuilder::VisitIntrinsicAsyncFunctionResolve(
interpreter::RegisterList args) {
DCHECK_EQ(args.register_count(), 2);
SetAccumulator(BuildCallBuiltin<Builtin::kAsyncFunctionResolve>(
{GetTaggedValue(args[0]), GetTaggedValue(args[1])}));
}
void MaglevGraphBuilder::VisitIntrinsicAsyncGeneratorAwaitCaught(
interpreter::RegisterList args) {
DCHECK_EQ(args.register_count(), 2);
SetAccumulator(BuildCallBuiltin<Builtin::kAsyncGeneratorAwaitCaught>(
{GetTaggedValue(args[0]), GetTaggedValue(args[1])}));
}
void MaglevGraphBuilder::VisitIntrinsicAsyncGeneratorAwaitUncaught(
interpreter::RegisterList args) {
DCHECK_EQ(args.register_count(), 2);
SetAccumulator(BuildCallBuiltin<Builtin::kAsyncGeneratorAwaitUncaught>(
{GetTaggedValue(args[0]), GetTaggedValue(args[1])}));
}
void MaglevGraphBuilder::VisitIntrinsicAsyncGeneratorReject(
interpreter::RegisterList args) {
DCHECK_EQ(args.register_count(), 2);
SetAccumulator(BuildCallBuiltin<Builtin::kAsyncGeneratorReject>(
{GetTaggedValue(args[0]), GetTaggedValue(args[1])}));
}
void MaglevGraphBuilder::VisitIntrinsicAsyncGeneratorResolve(
interpreter::RegisterList args) {
DCHECK_EQ(args.register_count(), 3);
SetAccumulator(BuildCallBuiltin<Builtin::kAsyncGeneratorResolve>(
{GetTaggedValue(args[0]), GetTaggedValue(args[1]),
GetTaggedValue(args[2])}));
}
void MaglevGraphBuilder::VisitIntrinsicAsyncGeneratorYield(
interpreter::RegisterList args) {
DCHECK_EQ(args.register_count(), 3);
SetAccumulator(BuildCallBuiltin<Builtin::kAsyncGeneratorYield>(
{GetTaggedValue(args[0]), GetTaggedValue(args[1]),
GetTaggedValue(args[2])}));
}
void MaglevGraphBuilder::VisitConstruct() {
ValueNode* new_target = GetAccumulatorTagged();
......@@ -2068,8 +2215,8 @@ void MaglevGraphBuilder::MergeDeadIntoFrameState(int target) {
if (merge_states_[target]) {
// If there already is a frame state, merge.
merge_states_[target]->MergeDead(*compilation_unit_, target);
// If this merge is the last one which kills a loop merge, remove that merge
// state.
// If this merge is the last one which kills a loop merge, remove that
// merge state.
if (merge_states_[target]->is_unreachable_loop()) {
merge_states_[target] = nullptr;
}
......
......@@ -20,6 +20,7 @@
#include "src/interpreter/bytecode-array-iterator.h"
#include "src/interpreter/bytecode-decoder.h"
#include "src/interpreter/bytecode-register.h"
#include "src/interpreter/interpreter-intrinsics.h"
#include "src/maglev/maglev-graph-labeller.h"
#include "src/maglev/maglev-graph-printer.h"
#include "src/maglev/maglev-graph.h"
......@@ -238,6 +239,11 @@ class MaglevGraphBuilder {
BYTECODE_LIST(BYTECODE_VISITOR)
#undef BYTECODE_VISITOR
#define DECLARE_VISITOR(name, ...) \
void VisitIntrinsic##name(interpreter::RegisterList args);
INTRINSICS_LIST(DECLARE_VISITOR)
#undef DECLARE_VISITOR
template <typename NodeT>
NodeT* AddNode(NodeT* node) {
if (node->properties().is_required_when_unused()) {
......
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