summaryrefslogtreecommitdiff
path: root/deps/v8/src/interpreter/interpreter-intrinsics-generator.cc
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/interpreter/interpreter-intrinsics-generator.cc')
-rw-r--r--deps/v8/src/interpreter/interpreter-intrinsics-generator.cc199
1 files changed, 110 insertions, 89 deletions
diff --git a/deps/v8/src/interpreter/interpreter-intrinsics-generator.cc b/deps/v8/src/interpreter/interpreter-intrinsics-generator.cc
index 03ca61de52..b9975e66ea 100644
--- a/deps/v8/src/interpreter/interpreter-intrinsics-generator.cc
+++ b/deps/v8/src/interpreter/interpreter-intrinsics-generator.cc
@@ -20,14 +20,14 @@ namespace v8 {
namespace internal {
namespace interpreter {
-using compiler::Node;
-
class IntrinsicsGenerator {
public:
explicit IntrinsicsGenerator(InterpreterAssembler* assembler)
: isolate_(assembler->isolate()),
zone_(assembler->zone()),
assembler_(assembler) {}
+ IntrinsicsGenerator(const IntrinsicsGenerator&) = delete;
+ IntrinsicsGenerator& operator=(const IntrinsicsGenerator&) = delete;
TNode<Object> InvokeIntrinsic(
TNode<Uint32T> function_id, TNode<Context> context,
@@ -42,17 +42,14 @@ class IntrinsicsGenerator {
TNode<Oddball> IsInstanceType(TNode<Object> input, int type);
TNode<BoolT> CompareInstanceType(TNode<HeapObject> map, int type,
InstanceTypeCompareMode mode);
- TNode<Object> IntrinsicAsStubCall(
- const InterpreterAssembler::RegListNodePair& args, TNode<Context> context,
- Callable const& callable);
TNode<Object> IntrinsicAsBuiltinCall(
const InterpreterAssembler::RegListNodePair& args, TNode<Context> context,
- Builtins::Name name);
+ Builtins::Name name, int arg_count);
void AbortIfArgCountMismatch(int expected, TNode<Word32T> actual);
#define DECLARE_INTRINSIC_HELPER(name, lower_case, count) \
TNode<Object> name(const InterpreterAssembler::RegListNodePair& args, \
- TNode<Context> context);
+ TNode<Context> context, int arg_count);
INTRINSICS_LIST(DECLARE_INTRINSIC_HELPER)
#undef DECLARE_INTRINSIC_HELPER
@@ -63,8 +60,6 @@ class IntrinsicsGenerator {
Isolate* isolate_;
Zone* zone_;
InterpreterAssembler* assembler_;
-
- DISALLOW_COPY_AND_ASSIGN(IntrinsicsGenerator);
};
TNode<Object> GenerateInvokeIntrinsic(
@@ -103,7 +98,7 @@ TNode<Object> IntrinsicsGenerator::InvokeIntrinsic(
if (FLAG_debug_code && expected_arg_count >= 0) { \
AbortIfArgCountMismatch(expected_arg_count, args.reg_count()); \
} \
- TNode<Object> value = name(args, context); \
+ TNode<Object> value = name(args, context, expected_arg_count); \
if (value) { \
result = value; \
__ Goto(&end); \
@@ -146,8 +141,34 @@ TNode<Oddball> IntrinsicsGenerator::IsInstanceType(TNode<Object> input,
return result;
}
+TNode<Object> IntrinsicsGenerator::IntrinsicAsBuiltinCall(
+ const InterpreterAssembler::RegListNodePair& args, TNode<Context> context,
+ Builtins::Name name, int arg_count) {
+ Callable callable = Builtins::CallableFor(isolate_, name);
+ switch (arg_count) {
+ case 1:
+ return __ CallStub(callable, context,
+ __ LoadRegisterFromRegisterList(args, 0));
+ break;
+ case 2:
+ return __ CallStub(callable, context,
+ __ LoadRegisterFromRegisterList(args, 0),
+ __ LoadRegisterFromRegisterList(args, 1));
+ break;
+ case 3:
+ return __ CallStub(callable, context,
+ __ LoadRegisterFromRegisterList(args, 0),
+ __ LoadRegisterFromRegisterList(args, 1),
+ __ LoadRegisterFromRegisterList(args, 2));
+ break;
+ default:
+ UNREACHABLE();
+ }
+}
+
TNode<Object> IntrinsicsGenerator::IsJSReceiver(
- const InterpreterAssembler::RegListNodePair& args, TNode<Context> context) {
+ const InterpreterAssembler::RegListNodePair& args, TNode<Context> context,
+ int arg_count) {
TNode<Object> input = __ LoadRegisterFromRegisterList(args, 0);
TNode<Oddball> result = __ Select<Oddball>(
__ TaggedIsSmi(input), [=] { return __ FalseConstant(); },
@@ -158,81 +179,61 @@ TNode<Object> IntrinsicsGenerator::IsJSReceiver(
}
TNode<Object> IntrinsicsGenerator::IsArray(
- const InterpreterAssembler::RegListNodePair& args, TNode<Context> context) {
+ const InterpreterAssembler::RegListNodePair& args, TNode<Context> context,
+ int arg_count) {
TNode<Object> input = __ LoadRegisterFromRegisterList(args, 0);
return IsInstanceType(input, JS_ARRAY_TYPE);
}
TNode<Object> IntrinsicsGenerator::IsSmi(
- const InterpreterAssembler::RegListNodePair& args, TNode<Context> context) {
+ const InterpreterAssembler::RegListNodePair& args, TNode<Context> context,
+ int arg_count) {
TNode<Object> input = __ LoadRegisterFromRegisterList(args, 0);
return __ SelectBooleanConstant(__ TaggedIsSmi(input));
}
-TNode<Object> IntrinsicsGenerator::IntrinsicAsStubCall(
- const InterpreterAssembler::RegListNodePair& args, TNode<Context> context,
- Callable const& callable) {
- int param_count = callable.descriptor().GetParameterCount();
- int input_count = param_count + 2; // +2 for target and context
- Node** stub_args = zone()->NewArray<Node*>(input_count);
- int index = 0;
- stub_args[index++] = __ HeapConstant(callable.code());
- for (int i = 0; i < param_count; i++) {
- stub_args[index++] = __ LoadRegisterFromRegisterList(args, i);
- }
- stub_args[index++] = context;
- return __ CAST(__ CallStubN(StubCallMode::kCallCodeObject,
- callable.descriptor(), 1, input_count,
- stub_args));
-}
-
-TNode<Object> IntrinsicsGenerator::IntrinsicAsBuiltinCall(
- const InterpreterAssembler::RegListNodePair& args, TNode<Context> context,
- Builtins::Name name) {
- Callable callable = Builtins::CallableFor(isolate_, name);
- return IntrinsicAsStubCall(args, context, callable);
-}
-
TNode<Object> IntrinsicsGenerator::CopyDataProperties(
- const InterpreterAssembler::RegListNodePair& args, TNode<Context> context) {
- return IntrinsicAsStubCall(
- args, context,
- Builtins::CallableFor(isolate(), Builtins::kCopyDataProperties));
+ const InterpreterAssembler::RegListNodePair& args, TNode<Context> context,
+ int arg_count) {
+ return IntrinsicAsBuiltinCall(args, context, Builtins::kCopyDataProperties,
+ arg_count);
}
TNode<Object> IntrinsicsGenerator::CreateIterResultObject(
- const InterpreterAssembler::RegListNodePair& args, TNode<Context> context) {
- return IntrinsicAsStubCall(
- args, context,
- Builtins::CallableFor(isolate(), Builtins::kCreateIterResultObject));
+ const InterpreterAssembler::RegListNodePair& args, TNode<Context> context,
+ int arg_count) {
+ return IntrinsicAsBuiltinCall(args, context,
+ Builtins::kCreateIterResultObject, arg_count);
}
TNode<Object> IntrinsicsGenerator::HasProperty(
- const InterpreterAssembler::RegListNodePair& args, TNode<Context> context) {
- return IntrinsicAsStubCall(
- args, context, Builtins::CallableFor(isolate(), Builtins::kHasProperty));
+ const InterpreterAssembler::RegListNodePair& args, TNode<Context> context,
+ int arg_count) {
+ return IntrinsicAsBuiltinCall(args, context, Builtins::kHasProperty,
+ arg_count);
}
TNode<Object> IntrinsicsGenerator::ToString(
- const InterpreterAssembler::RegListNodePair& args, TNode<Context> context) {
- return IntrinsicAsStubCall(
- args, context, Builtins::CallableFor(isolate(), Builtins::kToString));
+ const InterpreterAssembler::RegListNodePair& args, TNode<Context> context,
+ int arg_count) {
+ return IntrinsicAsBuiltinCall(args, context, Builtins::kToString, arg_count);
}
TNode<Object> IntrinsicsGenerator::ToLength(
- const InterpreterAssembler::RegListNodePair& args, TNode<Context> context) {
- return IntrinsicAsStubCall(
- args, context, Builtins::CallableFor(isolate(), Builtins::kToLength));
+ const InterpreterAssembler::RegListNodePair& args, TNode<Context> context,
+ int arg_count) {
+ return IntrinsicAsBuiltinCall(args, context, Builtins::kToLength, arg_count);
}
TNode<Object> IntrinsicsGenerator::ToObject(
- const InterpreterAssembler::RegListNodePair& args, TNode<Context> context) {
- return IntrinsicAsStubCall(
- args, context, Builtins::CallableFor(isolate(), Builtins::kToObject));
+ const InterpreterAssembler::RegListNodePair& args, TNode<Context> context,
+ int arg_count) {
+ return IntrinsicAsBuiltinCall(args, context, Builtins::kToObject, arg_count);
}
TNode<Object> IntrinsicsGenerator::Call(
- const InterpreterAssembler::RegListNodePair& args, TNode<Context> context) {
+ const InterpreterAssembler::RegListNodePair& args, TNode<Context> context,
+ int arg_count) {
// First argument register contains the function target.
TNode<Object> function = __ LoadRegisterFromRegisterList(args, 0);
@@ -258,7 +259,8 @@ TNode<Object> IntrinsicsGenerator::Call(
}
TNode<Object> IntrinsicsGenerator::CreateAsyncFromSyncIterator(
- const InterpreterAssembler::RegListNodePair& args, TNode<Context> context) {
+ const InterpreterAssembler::RegListNodePair& args, TNode<Context> context,
+ int arg_count) {
InterpreterAssembler::Label not_receiver(
assembler_, InterpreterAssembler::Label::kDeferred);
InterpreterAssembler::Label done(assembler_);
@@ -299,13 +301,15 @@ TNode<Object> IntrinsicsGenerator::CreateAsyncFromSyncIterator(
}
TNode<Object> IntrinsicsGenerator::CreateJSGeneratorObject(
- const InterpreterAssembler::RegListNodePair& args, TNode<Context> context) {
- return IntrinsicAsBuiltinCall(args, context,
- Builtins::kCreateGeneratorObject);
+ const InterpreterAssembler::RegListNodePair& args, TNode<Context> context,
+ int arg_count) {
+ return IntrinsicAsBuiltinCall(args, context, Builtins::kCreateGeneratorObject,
+ arg_count);
}
TNode<Object> IntrinsicsGenerator::GeneratorGetResumeMode(
- const InterpreterAssembler::RegListNodePair& args, TNode<Context> context) {
+ const InterpreterAssembler::RegListNodePair& args, TNode<Context> context,
+ int arg_count) {
TNode<JSGeneratorObject> generator =
__ CAST(__ LoadRegisterFromRegisterList(args, 0));
const TNode<Object> value =
@@ -315,7 +319,8 @@ TNode<Object> IntrinsicsGenerator::GeneratorGetResumeMode(
}
TNode<Object> IntrinsicsGenerator::GeneratorClose(
- const InterpreterAssembler::RegListNodePair& args, TNode<Context> context) {
+ const InterpreterAssembler::RegListNodePair& args, TNode<Context> context,
+ int arg_count) {
TNode<JSGeneratorObject> generator =
__ CAST(__ LoadRegisterFromRegisterList(args, 0));
__ StoreObjectFieldNoWriteBarrier(
@@ -325,7 +330,8 @@ TNode<Object> IntrinsicsGenerator::GeneratorClose(
}
TNode<Object> IntrinsicsGenerator::GetImportMetaObject(
- const InterpreterAssembler::RegListNodePair& args, TNode<Context> context) {
+ const InterpreterAssembler::RegListNodePair& args, TNode<Context> context,
+ int arg_count) {
const TNode<Context> module_context = __ LoadModuleContext(context);
const TNode<HeapObject> module =
__ CAST(__ LoadContextElement(module_context, Context::EXTENSION_INDEX));
@@ -346,58 +352,73 @@ TNode<Object> IntrinsicsGenerator::GetImportMetaObject(
}
TNode<Object> IntrinsicsGenerator::AsyncFunctionAwaitCaught(
- const InterpreterAssembler::RegListNodePair& args, TNode<Context> context) {
+ const InterpreterAssembler::RegListNodePair& args, TNode<Context> context,
+ int arg_count) {
return IntrinsicAsBuiltinCall(args, context,
- Builtins::kAsyncFunctionAwaitCaught);
+ Builtins::kAsyncFunctionAwaitCaught, arg_count);
}
TNode<Object> IntrinsicsGenerator::AsyncFunctionAwaitUncaught(
- const InterpreterAssembler::RegListNodePair& args, TNode<Context> context) {
- return IntrinsicAsBuiltinCall(args, context,
- Builtins::kAsyncFunctionAwaitUncaught);
+ const InterpreterAssembler::RegListNodePair& args, TNode<Context> context,
+ int arg_count) {
+ return IntrinsicAsBuiltinCall(
+ args, context, Builtins::kAsyncFunctionAwaitUncaught, arg_count);
}
TNode<Object> IntrinsicsGenerator::AsyncFunctionEnter(
- const InterpreterAssembler::RegListNodePair& args, TNode<Context> context) {
- return IntrinsicAsBuiltinCall(args, context, Builtins::kAsyncFunctionEnter);
+ const InterpreterAssembler::RegListNodePair& args, TNode<Context> context,
+ int arg_count) {
+ return IntrinsicAsBuiltinCall(args, context, Builtins::kAsyncFunctionEnter,
+ arg_count);
}
TNode<Object> IntrinsicsGenerator::AsyncFunctionReject(
- const InterpreterAssembler::RegListNodePair& args, TNode<Context> context) {
- return IntrinsicAsBuiltinCall(args, context, Builtins::kAsyncFunctionReject);
+ const InterpreterAssembler::RegListNodePair& args, TNode<Context> context,
+ int arg_count) {
+ return IntrinsicAsBuiltinCall(args, context, Builtins::kAsyncFunctionReject,
+ arg_count);
}
TNode<Object> IntrinsicsGenerator::AsyncFunctionResolve(
- const InterpreterAssembler::RegListNodePair& args, TNode<Context> context) {
- return IntrinsicAsBuiltinCall(args, context, Builtins::kAsyncFunctionResolve);
+ const InterpreterAssembler::RegListNodePair& args, TNode<Context> context,
+ int arg_count) {
+ return IntrinsicAsBuiltinCall(args, context, Builtins::kAsyncFunctionResolve,
+ arg_count);
}
TNode<Object> IntrinsicsGenerator::AsyncGeneratorAwaitCaught(
- const InterpreterAssembler::RegListNodePair& args, TNode<Context> context) {
- return IntrinsicAsBuiltinCall(args, context,
- Builtins::kAsyncGeneratorAwaitCaught);
+ const InterpreterAssembler::RegListNodePair& args, TNode<Context> context,
+ int arg_count) {
+ return IntrinsicAsBuiltinCall(
+ args, context, Builtins::kAsyncGeneratorAwaitCaught, arg_count);
}
TNode<Object> IntrinsicsGenerator::AsyncGeneratorAwaitUncaught(
- const InterpreterAssembler::RegListNodePair& args, TNode<Context> context) {
- return IntrinsicAsBuiltinCall(args, context,
- Builtins::kAsyncGeneratorAwaitUncaught);
+ const InterpreterAssembler::RegListNodePair& args, TNode<Context> context,
+ int arg_count) {
+ return IntrinsicAsBuiltinCall(
+ args, context, Builtins::kAsyncGeneratorAwaitUncaught, arg_count);
}
TNode<Object> IntrinsicsGenerator::AsyncGeneratorReject(
- const InterpreterAssembler::RegListNodePair& args, TNode<Context> context) {
- return IntrinsicAsBuiltinCall(args, context, Builtins::kAsyncGeneratorReject);
+ const InterpreterAssembler::RegListNodePair& args, TNode<Context> context,
+ int arg_count) {
+ return IntrinsicAsBuiltinCall(args, context, Builtins::kAsyncGeneratorReject,
+ arg_count);
}
TNode<Object> IntrinsicsGenerator::AsyncGeneratorResolve(
- const InterpreterAssembler::RegListNodePair& args, TNode<Context> context) {
- return IntrinsicAsBuiltinCall(args, context,
- Builtins::kAsyncGeneratorResolve);
+ const InterpreterAssembler::RegListNodePair& args, TNode<Context> context,
+ int arg_count) {
+ return IntrinsicAsBuiltinCall(args, context, Builtins::kAsyncGeneratorResolve,
+ arg_count);
}
TNode<Object> IntrinsicsGenerator::AsyncGeneratorYield(
- const InterpreterAssembler::RegListNodePair& args, TNode<Context> context) {
- return IntrinsicAsBuiltinCall(args, context, Builtins::kAsyncGeneratorYield);
+ const InterpreterAssembler::RegListNodePair& args, TNode<Context> context,
+ int arg_count) {
+ return IntrinsicAsBuiltinCall(args, context, Builtins::kAsyncGeneratorYield,
+ arg_count);
}
void IntrinsicsGenerator::AbortIfArgCountMismatch(int expected,