diff --git a/deps/v8/include/v8-message.h b/deps/v8/include/v8-message.h index 09f9a0a97ddb64..a680ea5d1dfd79 100644 --- a/deps/v8/include/v8-message.h +++ b/deps/v8/include/v8-message.h @@ -61,6 +61,7 @@ class ScriptOriginOptions { */ class V8_EXPORT ScriptOrigin { public: + V8_DEPRECATE_SOON("Use constructor without the isolate.") V8_INLINE ScriptOrigin(Isolate* isolate, Local resource_name, int resource_line_offset = 0, int resource_column_offset = 0, @@ -70,17 +71,30 @@ class V8_EXPORT ScriptOrigin { bool resource_is_opaque = false, bool is_wasm = false, bool is_module = false, Local host_defined_options = Local()) - : v8_isolate_(isolate), - resource_name_(resource_name), + : resource_name_(resource_name), resource_line_offset_(resource_line_offset), resource_column_offset_(resource_column_offset), options_(resource_is_shared_cross_origin, resource_is_opaque, is_wasm, is_module), script_id_(script_id), source_map_url_(source_map_url), - host_defined_options_(host_defined_options) { - VerifyHostDefinedOptions(); - } + host_defined_options_(host_defined_options) {} + + V8_INLINE explicit ScriptOrigin( + Local resource_name, int resource_line_offset = 0, + int resource_column_offset = 0, + bool resource_is_shared_cross_origin = false, int script_id = -1, + Local source_map_url = Local(), + bool resource_is_opaque = false, bool is_wasm = false, + bool is_module = false, Local host_defined_options = Local()) + : resource_name_(resource_name), + resource_line_offset_(resource_line_offset), + resource_column_offset_(resource_column_offset), + options_(resource_is_shared_cross_origin, resource_is_opaque, is_wasm, + is_module), + script_id_(script_id), + source_map_url_(source_map_url), + host_defined_options_(host_defined_options) {} V8_INLINE Local ResourceName() const; V8_INLINE int LineOffset() const; @@ -91,8 +105,6 @@ class V8_EXPORT ScriptOrigin { V8_INLINE ScriptOriginOptions Options() const { return options_; } private: - void VerifyHostDefinedOptions() const; - Isolate* v8_isolate_; Local resource_name_; int resource_line_offset_; int resource_column_offset_; diff --git a/deps/v8/samples/shell.cc b/deps/v8/samples/shell.cc index 046ed1e4eb53b7..fce0d459c3d955 100644 --- a/deps/v8/samples/shell.cc +++ b/deps/v8/samples/shell.cc @@ -313,7 +313,7 @@ bool ExecuteString(v8::Isolate* isolate, v8::Local source, bool report_exceptions) { v8::HandleScope handle_scope(isolate); v8::TryCatch try_catch(isolate); - v8::ScriptOrigin origin(isolate, name); + v8::ScriptOrigin origin(name); v8::Local context(isolate->GetCurrentContext()); v8::Local script; if (!v8::Script::Compile(context, source, &origin).ToLocal(&script)) { diff --git a/deps/v8/src/api/api.cc b/deps/v8/src/api/api.cc index a4a4381614e1fd..b6d3e9f24140c9 100644 --- a/deps/v8/src/api/api.cc +++ b/deps/v8/src/api/api.cc @@ -179,17 +179,15 @@ static ScriptOrigin GetScriptOriginForScript(i::Isolate* i_isolate, i::Handle script) { i::Handle scriptName(script->GetNameOrSourceURL(), i_isolate); i::Handle source_map_url(script->source_mapping_url(), i_isolate); - i::Handle host_defined_options(script->host_defined_options(), - i_isolate); + i::Handle host_defined_options; ScriptOriginOptions options(script->origin_options()); bool is_wasm = false; #if V8_ENABLE_WEBASSEMBLY is_wasm = script->type() == i::Script::TYPE_WASM; #endif // V8_ENABLE_WEBASSEMBLY v8::ScriptOrigin origin( - reinterpret_cast(i_isolate), Utils::ToLocal(scriptName), - script->line_offset(), script->column_offset(), - options.IsSharedCrossOrigin(), script->id(), + Utils::ToLocal(scriptName), script->line_offset(), + script->column_offset(), options.IsSharedCrossOrigin(), script->id(), Utils::ToLocal(source_map_url), options.IsOpaque(), is_wasm, options.IsModule(), Utils::ToLocal(host_defined_options)); return origin; @@ -2142,11 +2140,10 @@ MaybeLocal Script::Run(Local context, } i::Handle receiver = i_isolate->global_proxy(); - // TODO(cbruni, chromium:1244145): Remove once migrated to the context. - i::Handle options( - i::Script::cast(fun->shared().script()).host_defined_options(), - i_isolate); Local result; + i::Handle options = host_defined_options.IsEmpty() + ? i_isolate->factory()->empty_fixed_array() + : Utils::OpenHandle(*host_defined_options); has_pending_exception = !ToLocal( i::Execution::CallScript(i_isolate, fun, receiver, options), &result); @@ -2500,18 +2497,16 @@ Module::GetStalledTopLevelAwaitMessage(Isolate* isolate) { namespace { -i::ScriptDetails GetScriptDetails( - i::Isolate* i_isolate, Local resource_name, int resource_line_offset, - int resource_column_offset, Local source_map_url, - Local host_defined_options, ScriptOriginOptions origin_options) { +i::ScriptDetails GetScriptDetails(i::Isolate* i_isolate, + Local resource_name, + int resource_line_offset, + int resource_column_offset, + Local source_map_url, + ScriptOriginOptions origin_options) { i::ScriptDetails script_details(Utils::OpenHandle(*(resource_name), true), origin_options); script_details.line_offset = resource_line_offset; script_details.column_offset = resource_column_offset; - script_details.host_defined_options = - host_defined_options.IsEmpty() - ? i_isolate->factory()->empty_fixed_array() - : Utils::OpenHandle(*(host_defined_options)); if (!source_map_url.IsEmpty()) { script_details.source_map_url = Utils::OpenHandle(*(source_map_url)); } @@ -2536,7 +2531,7 @@ MaybeLocal ScriptCompiler::CompileUnboundInternal( i::ScriptDetails script_details = GetScriptDetails( i_isolate, source->resource_name, source->resource_line_offset, source->resource_column_offset, source->source_map_url, - source->host_defined_options, source->resource_options); + source->resource_options); i::MaybeHandle maybe_function_info; if (options == kConsumeCodeCache) { @@ -2615,7 +2610,12 @@ MaybeLocal ScriptCompiler::CompileModule( if (!maybe.ToLocal(&unbound)) return MaybeLocal(); i::Handle shared = Utils::OpenHandle(*unbound); i::Isolate* i_isolate = reinterpret_cast(v8_isolate); - return ToApiHandle(i_isolate->factory()->NewSourceTextModule(shared)); + i::Handle host_defined_options = + source->host_defined_options.IsEmpty() + ? i_isolate->factory()->empty_fixed_array() + : Utils::OpenHandle(*source->host_defined_options); + return ToApiHandle( + i_isolate->factory()->NewSourceTextModule(shared, host_defined_options)); } // static @@ -2690,7 +2690,7 @@ MaybeLocal ScriptCompiler::CompileFunctionInternal( i::ScriptDetails script_details = GetScriptDetails( i_isolate, source->resource_name, source->resource_line_offset, source->resource_column_offset, source->source_map_url, - source->host_defined_options, source->resource_options); + source->resource_options); std::unique_ptr cached_data; if (options == kConsumeCodeCache) { @@ -2714,16 +2714,19 @@ MaybeLocal ScriptCompiler::CompileFunctionInternal( } // TODO(cbruni): remove script_or_module_out paramater if (script_or_module_out != nullptr) { - i::Handle function = - i::Handle::cast(Utils::OpenHandle(*result)); + auto function = i::Handle::cast(Utils::OpenHandle(*result)); i::Isolate* i_isolate = function->GetIsolate(); i::Handle shared(function->shared(), i_isolate); i::Handle script(i::Script::cast(shared->script()), i_isolate); + i::Handle host_defined_options = + source->host_defined_options.IsEmpty() + ? i_isolate->factory()->empty_fixed_array() + : Utils::OpenHandle(*source->host_defined_options); // TODO(cbruni, v8:12302): Avoid creating tempory ScriptOrModule objects. auto script_or_module = i::Handle::cast( i_isolate->factory()->NewStruct(i::SCRIPT_OR_MODULE_TYPE)); script_or_module->set_resource_name(script->name()); - script_or_module->set_host_defined_options(script->host_defined_options()); + script_or_module->set_host_defined_options(*host_defined_options); #ifdef V8_SCRIPTORMODULE_LEGACY_LIFETIME i::Handle list = i::handle(script->script_or_modules(), i_isolate); @@ -2767,10 +2770,9 @@ void ScriptCompiler::ConsumeCodeCacheTask::SourceTextAvailable( i::Isolate* i_isolate = reinterpret_cast(v8_isolate); DCHECK_NO_SCRIPT_NO_EXCEPTION(i_isolate); i::Handle str = Utils::OpenHandle(*(source_text)); - i::ScriptDetails script_details = - GetScriptDetails(i_isolate, origin.ResourceName(), origin.LineOffset(), - origin.ColumnOffset(), origin.SourceMapUrl(), - origin.GetHostDefinedOptions(), origin.Options()); + i::ScriptDetails script_details = GetScriptDetails( + i_isolate, origin.ResourceName(), origin.LineOffset(), + origin.ColumnOffset(), origin.SourceMapUrl(), origin.Options()); impl_->SourceTextAvailable(i_isolate, str, script_details); } @@ -2804,10 +2806,9 @@ i::MaybeHandle CompileStreamedSource( i::Isolate* i_isolate, ScriptCompiler::StreamedSource* v8_source, Local full_source_string, const ScriptOrigin& origin) { i::Handle str = Utils::OpenHandle(*(full_source_string)); - i::ScriptDetails script_details = - GetScriptDetails(i_isolate, origin.ResourceName(), origin.LineOffset(), - origin.ColumnOffset(), origin.SourceMapUrl(), - origin.GetHostDefinedOptions(), origin.Options()); + i::ScriptDetails script_details = GetScriptDetails( + i_isolate, origin.ResourceName(), origin.LineOffset(), + origin.ColumnOffset(), origin.SourceMapUrl(), origin.Options()); i::ScriptStreamingData* data = v8_source->impl(); return i::Compiler::GetSharedFunctionInfoForStreamedScript( i_isolate, str, script_details, data); @@ -2849,8 +2850,13 @@ MaybeLocal ScriptCompiler::CompileModule( has_pending_exception = !maybe_sfi.ToHandle(&sfi); if (has_pending_exception) i_isolate->ReportPendingMessages(); RETURN_ON_FAILED_EXECUTION(Module); - RETURN_ESCAPED( - ToApiHandle(i_isolate->factory()->NewSourceTextModule(sfi))); + // TODO(cleanup) + i::Handle options = + origin.GetHostDefinedOptions().IsEmpty() + ? i_isolate->factory()->empty_fixed_array() + : Utils::OpenHandle(*origin.GetHostDefinedOptions()); + RETURN_ESCAPED(ToApiHandle( + i_isolate->factory()->NewSourceTextModule(sfi, options))); } uint32_t ScriptCompiler::CachedDataVersionTag() { @@ -3061,21 +3067,6 @@ ScriptOrigin Message::GetScriptOrigin() const { return GetScriptOriginForScript(i_isolate, script); } -void ScriptOrigin::VerifyHostDefinedOptions() const { - // TODO(cbruni, chromium:1244145): Remove checks once we allow arbitrary - // host-defined options. - USE(v8_isolate_); - if (host_defined_options_.IsEmpty()) return; - Utils::ApiCheck(host_defined_options_->IsFixedArray(), "ScriptOrigin()", - "Host-defined options has to be a PrimitiveArray"); - i::Handle options = - Utils::OpenHandle(*host_defined_options_.As()); - for (int i = 0; i < options->length(); i++) { - Utils::ApiCheck(options->get(i).IsPrimitive(), "ScriptOrigin()", - "PrimitiveArray can only contain primtive values"); - } -} - v8::Local Message::GetScriptResourceName() const { DCHECK_NO_SCRIPT_NO_EXCEPTION(Utils::OpenHandle(this)->GetIsolate()); return GetScriptOrigin().ResourceName(); @@ -5372,15 +5363,14 @@ Local Function::GetDebugName() const { ScriptOrigin Function::GetScriptOrigin() const { auto self = Utils::OpenHandle(this); - auto i_isolate = reinterpret_cast(self->GetIsolate()); - if (!self->IsJSFunction()) return v8::ScriptOrigin(i_isolate, Local()); + if (!self->IsJSFunction()) return v8::ScriptOrigin(Local()); auto func = i::Handle::cast(self); if (func->shared().script().IsScript()) { i::Handle script(i::Script::cast(func->shared().script()), func->GetIsolate()); return GetScriptOriginForScript(func->GetIsolate(), script); } - return v8::ScriptOrigin(i_isolate, Local()); + return v8::ScriptOrigin(Local()); } const int Function::kLineOffsetNotFound = -1; diff --git a/deps/v8/src/ast/scopes.cc b/deps/v8/src/ast/scopes.cc index 8d52d0792bcfc1..df00187a0fd4d7 100644 --- a/deps/v8/src/ast/scopes.cc +++ b/deps/v8/src/ast/scopes.cc @@ -244,7 +244,6 @@ Scope::Scope(Zone* zone, ScopeType scope_type, already_resolved_ = true; #endif set_language_mode(scope_info->language_mode()); - DCHECK_EQ(ContextHeaderLength(), num_heap_slots_); private_name_lookup_skips_outer_class_ = scope_info->PrivateNameLookupSkipsOuterClass(); // We don't really need to use the preparsed scope data; this is just to @@ -276,6 +275,8 @@ DeclarationScope::DeclarationScope(Zone* zone, ScopeType scope_type, if (scope_info->SloppyEvalCanExtendVars()) { DCHECK(!is_eval_scope()); sloppy_eval_can_extend_vars_ = true; + has_context_extension_slot_ = HasContextExtensionSlot(); + num_heap_slots_ = ContextHeaderLength(); } if (scope_info->ClassScopeHasPrivateBrand()) { DCHECK(IsClassConstructor(function_kind())); @@ -358,8 +359,11 @@ void Scope::SetDefaults() { is_debug_evaluate_scope_ = false; inner_scope_calls_eval_ = false; + inner_scope_calls_dynamic_import_ = false; force_context_allocation_for_parameters_ = false; + has_context_extension_slot_ = HasContextExtensionSlot(); + is_declaration_scope_ = false; private_name_lookup_skips_outer_class_ = false; @@ -860,6 +864,9 @@ Scope* Scope::FinalizeBlockScope() { } if (inner_scope_calls_eval_) outer_scope()->inner_scope_calls_eval_ = true; + if (inner_scope_calls_dynamic_import_) { + outer_scope()->set_inner_scope_calls_dynamic_import(); + } // No need to propagate sloppy_eval_can_extend_vars_, since if it was relevant // to this scope we would have had to bail out at the top. @@ -899,12 +906,18 @@ void Scope::Snapshot::Reparent(DeclarationScope* new_parent) { if (inner_scope->inner_scope_calls_eval_) { new_parent->inner_scope_calls_eval_ = true; } + if (inner_scope->inner_scope_calls_dynamic_import_) { + new_parent->set_inner_scope_calls_dynamic_import(); + } DCHECK_NE(inner_scope, new_parent); } inner_scope->outer_scope_ = new_parent; if (inner_scope->inner_scope_calls_eval_) { new_parent->inner_scope_calls_eval_ = true; } + if (inner_scope->inner_scope_calls_dynamic_import_) { + new_parent->set_inner_scope_calls_dynamic_import(); + } new_parent->inner_scope_ = new_parent->sibling_; inner_scope->sibling_ = nullptr; // Reset the sibling rather than the inner_scope_ since we @@ -1949,6 +1962,12 @@ void Scope::Print(int n) { Indent(n1, "// scope skips outer class for #-names\n"); } if (inner_scope_calls_eval_) Indent(n1, "// inner scope calls 'eval'\n"); + if (inner_scope_calls_dynamic_import_) { + Indent(n1, "// inner scope calls 'import'\n"); + } + if (has_context_extension_slot_) { + Indent(n1, "// has context extension slot\n"); + } if (is_declaration_scope()) { DeclarationScope* scope = AsDeclarationScope(); if (scope->was_lazily_parsed()) Indent(n1, "// lazily parsed\n"); @@ -2596,6 +2615,7 @@ void Scope::AllocateVariablesRecursively() { // scope. bool must_have_context = scope->is_with_scope() || scope->is_module_scope() || + scope->NeedsHostDefinedOptions() || #if V8_ENABLE_WEBASSEMBLY scope->IsAsmModule() || #endif // V8_ENABLE_WEBASSEMBLY @@ -2607,12 +2627,17 @@ void Scope::AllocateVariablesRecursively() { // If we didn't allocate any locals in the local context, then we only // need the minimal number of slots if we must have a context. - if (scope->num_heap_slots_ == scope->ContextHeaderLength() && - !must_have_context) { + if (!must_have_context && + scope->num_heap_slots() == scope->ContextHeaderLength()) { scope->num_heap_slots_ = 0; } - - // Allocation done. + DCHECK_EQ(scope->has_context_extension_slot_, + scope->HasContextExtensionSlot()); + DCHECK_IMPLIES(scope->has_context_extension_slot_, must_have_context); + DCHECK_IMPLIES( + scope->has_context_extension_slot_, + scope->num_heap_slots() >= Context::MIN_CONTEXT_EXTENDED_SLOTS); + DCHECK_IMPLIES(must_have_context, scope->num_heap_slots() > 0); DCHECK(scope->num_heap_slots_ == 0 || scope->num_heap_slots_ >= scope->ContextHeaderLength()); return Iteration::kDescend; diff --git a/deps/v8/src/ast/scopes.h b/deps/v8/src/ast/scopes.h index 32e16b80b261fb..31efe80f3bcc48 100644 --- a/deps/v8/src/ast/scopes.h +++ b/deps/v8/src/ast/scopes.h @@ -296,7 +296,9 @@ class V8_EXPORT_PRIVATE Scope : public NON_EXPORTED_BASE(ZoneObject) { // eval call. inline void RecordEvalCall(); - void RecordInnerScopeEvalCall() { + void RecordInnerScopeCallsEval() { + DisallowGarbageCollection no_gc; + if (inner_scope_calls_eval_) return; inner_scope_calls_eval_ = true; for (Scope* scope = outer_scope(); scope != nullptr; scope = scope->outer_scope()) { @@ -305,6 +307,28 @@ class V8_EXPORT_PRIVATE Scope : public NON_EXPORTED_BASE(ZoneObject) { } } + void RecordInnerScopeCallsDynamicImport() { + DisallowGarbageCollection no_gc; + if (inner_scope_calls_dynamic_import_) return; + set_inner_scope_calls_dynamic_import(); + for (Scope* scope = outer_scope(); scope != nullptr; + scope = scope->outer_scope()) { + if (scope->inner_scope_calls_dynamic_import_) return; + scope->set_inner_scope_calls_dynamic_import(); + } + } + + void set_inner_scope_calls_dynamic_import() { + if (inner_scope_calls_dynamic_import_) return; + inner_scope_calls_dynamic_import_ = true; + if (!has_context_extension_slot_) { + has_context_extension_slot_ = HasContextExtensionSlot(); + DCHECK_EQ(num_heap_slots_, Context::MIN_CONTEXT_SLOTS); + num_heap_slots_ = ContextHeaderLength(); + } + DCHECK_GE(num_heap_slots_, ContextHeaderLength()); + } + // Set the language mode flag (unless disabled by a global flag). void SetLanguageMode(LanguageMode language_mode) { DCHECK(!is_module_scope() || is_strict(language_mode)); @@ -396,6 +420,9 @@ class V8_EXPORT_PRIVATE Scope : public NON_EXPORTED_BASE(ZoneObject) { } bool inner_scope_calls_eval() const { return inner_scope_calls_eval_; } + bool inner_scope_calls_dynamic_import() const { + return inner_scope_calls_dynamic_import_; + } bool private_name_lookup_skips_outer_class() const { return private_name_lookup_skips_outer_class_; } @@ -429,6 +456,9 @@ class V8_EXPORT_PRIVATE Scope : public NON_EXPORTED_BASE(ZoneObject) { DCHECK_IMPLIES(is_catch_scope(), num_heap_slots() > 0); DCHECK_IMPLIES(is_with_scope(), num_heap_slots() > 0); DCHECK_IMPLIES(ForceContextForLanguageMode(), num_heap_slots() > 0); + DCHECK_IMPLIES(HasContextExtensionSlot(), has_context_extension_slot_); + DCHECK_IMPLIES(has_context_extension_slot_, + num_heap_slots() >= Context::MIN_CONTEXT_EXTENDED_SLOTS); return num_heap_slots() > 0; } @@ -502,21 +532,30 @@ class V8_EXPORT_PRIVATE Scope : public NON_EXPORTED_BASE(ZoneObject) { int num_stack_slots() const { return num_stack_slots_; } int num_heap_slots() const { return num_heap_slots_; } + bool NeedsHostDefinedOptions() const { + // For dynamic imports we need to provide host-defined options. + return inner_scope_calls_dynamic_import_; + } + bool HasContextExtensionSlot() const { switch (scope_type_) { case MODULE_SCOPE: case WITH_SCOPE: // DebugEvaluateContext as well return true; - default: - DCHECK_IMPLIES(sloppy_eval_can_extend_vars_, - scope_type_ == FUNCTION_SCOPE || - scope_type_ == EVAL_SCOPE || - scope_type_ == BLOCK_SCOPE); + case CATCH_SCOPE: + case CLASS_SCOPE: + return false; + case SCRIPT_SCOPE: + return NeedsHostDefinedOptions(); + case FUNCTION_SCOPE: + case EVAL_SCOPE: + case BLOCK_SCOPE: DCHECK_IMPLIES(sloppy_eval_can_extend_vars_, is_declaration_scope()); return sloppy_eval_can_extend_vars_; } UNREACHABLE(); } + int ContextHeaderLength() const { return HasContextExtensionSlot() ? Context::MIN_CONTEXT_EXTENDED_SLOTS : Context::MIN_CONTEXT_SLOTS; @@ -832,6 +871,11 @@ class V8_EXPORT_PRIVATE Scope : public NON_EXPORTED_BASE(ZoneObject) { // True if one of the inner scopes or the scope itself calls eval. bool inner_scope_calls_eval_ : 1; + // True if the scope or any inner scope calls dynamic import. + bool inner_scope_calls_dynamic_import_ : 1; + + bool has_context_extension_slot_ : 1; + bool force_context_allocation_for_parameters_ : 1; // True if it holds 'var' declarations. @@ -926,7 +970,10 @@ class V8_EXPORT_PRIVATE DeclarationScope : public Scope { // isn't extendable anyway, or // 3. This is a debug evaluate and all bets are off. DeclarationScope* outer_decl_scope = outer_scope()->GetDeclarationScope(); - while (outer_decl_scope->is_eval_scope()) { + while (outer_decl_scope->is_eval_scope() && + !outer_decl_scope->is_declaration_scope()) { + DeclarationScope* next = outer_decl_scope->GetDeclarationScope(); + DCHECK_NE(outer_decl_scope, next); outer_decl_scope = outer_decl_scope->GetDeclarationScope(); } if (outer_decl_scope->is_debug_evaluate_scope()) { @@ -942,7 +989,9 @@ class V8_EXPORT_PRIVATE DeclarationScope : public Scope { } sloppy_eval_can_extend_vars_ = true; + has_context_extension_slot_ = true; num_heap_slots_ = Context::MIN_CONTEXT_EXTENDED_SLOTS; + DCHECK(HasContextExtensionSlot()); } bool sloppy_eval_can_extend_vars() const { @@ -1368,7 +1417,7 @@ class V8_EXPORT_PRIVATE DeclarationScope : public Scope { void Scope::RecordEvalCall() { calls_eval_ = true; GetDeclarationScope()->RecordDeclarationScopeEvalCall(); - RecordInnerScopeEvalCall(); + RecordInnerScopeCallsEval(); // The eval contents might access "super" (if it's inside a function that // binds super). DeclarationScope* receiver_scope = GetReceiverScope(); @@ -1385,9 +1434,11 @@ Scope::Snapshot::Snapshot(Scope* scope) top_unresolved_(scope->unresolved_list_.end()), top_local_(scope->GetClosureScope()->locals_.end()) { // Reset in order to record eval calls during this Snapshot's lifetime. - outer_scope_and_calls_eval_.GetPointer()->calls_eval_ = false; - outer_scope_and_calls_eval_.GetPointer()->sloppy_eval_can_extend_vars_ = - false; + Scope* outer_scope = outer_scope_and_calls_eval_.GetPointer(); + outer_scope->calls_eval_ = false; + outer_scope->sloppy_eval_can_extend_vars_ = false; + outer_scope->has_context_extension_slot_ = + outer_scope->HasContextExtensionSlot(); } class ModuleScope final : public DeclarationScope { diff --git a/deps/v8/src/codegen/compiler.cc b/deps/v8/src/codegen/compiler.cc index 5431deb83e743d..3da190ac19f8ee 100644 --- a/deps/v8/src/codegen/compiler.cc +++ b/deps/v8/src/codegen/compiler.cc @@ -1643,13 +1643,6 @@ void SetScriptFieldsFromDetails(Isolate* isolate, Script script, script.source_mapping_url(isolate).IsUndefined(isolate)) { script.set_source_mapping_url(*source_map_url); } - Handle host_defined_options; - if (script_details.host_defined_options.ToHandle(&host_defined_options)) { - // TODO(cbruni, chromium:1244145): Remove once migrated to the context. - if (host_defined_options->IsFixedArray()) { - script.set_host_defined_options(FixedArray::cast(*host_defined_options)); - } - } } #ifdef ENABLE_SLOW_DCHECKS diff --git a/deps/v8/src/codegen/script-details.h b/deps/v8/src/codegen/script-details.h index 5317ae989e1fb7..c55172af4614dc 100644 --- a/deps/v8/src/codegen/script-details.h +++ b/deps/v8/src/codegen/script-details.h @@ -29,7 +29,6 @@ struct ScriptDetails { int column_offset; MaybeHandle name_obj; MaybeHandle source_map_url; - MaybeHandle host_defined_options; REPLMode repl_mode; const ScriptOriginOptions origin_options; }; diff --git a/deps/v8/src/d8/d8.cc b/deps/v8/src/d8/d8.cc index 37f7de888070ee..9efe0468ca92ad 100644 --- a/deps/v8/src/d8/d8.cc +++ b/deps/v8/src/d8/d8.cc @@ -762,8 +762,8 @@ ScriptOrigin CreateScriptOrigin(Isolate* isolate, Local resource_name, options->Set(isolate, 0, v8::Uint32::New(isolate, kHostDefinedOptionsMagicConstant)); options->Set(isolate, 1, resource_name); - return ScriptOrigin(isolate, resource_name, 0, 0, false, -1, Local(), - false, false, type == v8::ScriptType::kModule, options); + return ScriptOrigin(resource_name, 0, 0, false, -1, Local(), false, + false, type == v8::ScriptType::kModule, options); } bool IsValidHostDefinedOptions(Local context, Local options, @@ -868,15 +868,7 @@ bool Shell::ExecuteString(Isolate* isolate, Local source, delete cached_data; } if (options.compile_only) return true; - if (options.compile_options == ScriptCompiler::kConsumeCodeCache) { - i::Handle i_script( - i::Script::cast(Utils::OpenHandle(*script)->shared().script()), - i_isolate); - // TODO(cbruni, chromium:1244145): remove once context-allocated. - i_script->set_host_defined_options(i::FixedArray::cast( - *Utils::OpenHandle(*(origin.GetHostDefinedOptions())))); - } - maybe_result = script->Run(realm); + maybe_result = script->Run(realm, origin.GetHostDefinedOptions()); if (options.code_cache_options == ShellOptions::CodeCacheOptions::kProduceCacheAfterExecute) { // Serialize and store it in memory for the next execution. @@ -3161,7 +3153,7 @@ Local Shell::Stringify(Isolate* isolate, Local value) { Local source = String::NewFromUtf8(isolate, stringify_source_).ToLocalChecked(); Local name = String::NewFromUtf8Literal(isolate, "d8-stringify"); - ScriptOrigin origin(isolate, name); + ScriptOrigin origin(name); Local