diff --git a/src/execution/execution.cc b/src/execution/execution.cc index f85bfcff22..dbf988b0e1 100644 --- a/src/execution/execution.cc +++ b/src/execution/execution.cc @@ -57,6 +57,15 @@ struct InvokeParams { return function->shared().is_script(); } + Handle GetAndResetHostDefinedOptions() { + DCHECK(IsScript()); + DCHECK_EQ(argc, 1); + auto options = Handle::cast(argv[0]); + argv = nullptr; + argc = 0; + return options; + } + Handle target; Handle receiver; int argc; @@ -330,10 +339,9 @@ V8_WARN_UNUSED_RESULT MaybeHandle Invoke(Isolate* isolate, #endif // Set up a ScriptContext when running scripts that need it. if (function->shared().needs_script_context()) { - DCHECK_EQ(params.argc, 1); Handle context; Handle host_defined_options = - Handle::cast(params.argv[0]); + const_cast(params).GetAndResetHostDefinedOptions(); if (!NewScriptContext(isolate, function, host_defined_options) .ToHandle(&context)) { if (params.message_handling == Execution::MessageHandling::kReport) {