[execution] Reset InvokeParams when calling scripts
We use the InvokeParams to pass host-defined options to Invoke. The script should never access them directly and thus we should clear out the argv and argc values. Bug: chromium:1244145 Change-Id: I915186d624f92581af79ca62bcb1613bc4069640 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3263891 Reviewed-by: Igor Sheludko <ishell@chromium.org> Commit-Queue: Camillo Bruni <cbruni@chromium.org> Cr-Commit-Position: refs/heads/main@{#77738}
This commit is contained in:
parent
1fa34d14b8
commit
d261a8943c
@ -57,6 +57,15 @@ struct InvokeParams {
|
||||
return function->shared().is_script();
|
||||
}
|
||||
|
||||
Handle<FixedArray> GetAndResetHostDefinedOptions() {
|
||||
DCHECK(IsScript());
|
||||
DCHECK_EQ(argc, 1);
|
||||
auto options = Handle<FixedArray>::cast(argv[0]);
|
||||
argv = nullptr;
|
||||
argc = 0;
|
||||
return options;
|
||||
}
|
||||
|
||||
Handle<Object> target;
|
||||
Handle<Object> receiver;
|
||||
int argc;
|
||||
@ -330,10 +339,9 @@ V8_WARN_UNUSED_RESULT MaybeHandle<Object> 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> context;
|
||||
Handle<FixedArray> host_defined_options =
|
||||
Handle<FixedArray>::cast(params.argv[0]);
|
||||
const_cast<InvokeParams&>(params).GetAndResetHostDefinedOptions();
|
||||
if (!NewScriptContext(isolate, function, host_defined_options)
|
||||
.ToHandle(&context)) {
|
||||
if (params.message_handling == Execution::MessageHandling::kReport) {
|
||||
|
Loading…
Reference in New Issue
Block a user