// Copyright 2016 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "src/parsing/parse-info.h" #include "src/ast/ast-source-ranges.h" #include "src/ast/ast-value-factory.h" #include "src/ast/ast.h" #include "src/base/template-utils.h" #include "src/heap/heap-inl.h" #include "src/objects-inl.h" #include "src/objects/scope-info.h" #include "src/zone/zone.h" namespace v8 { namespace internal { ParseInfo::ParseInfo(Isolate* isolate, AccountingAllocator* zone_allocator) : zone_(base::make_unique(zone_allocator, ZONE_NAME)), flags_(0), extension_(nullptr), script_scope_(nullptr), unicode_cache_(nullptr), stack_limit_(0), hash_seed_(0), function_kind_(FunctionKind::kNormalFunction), script_id_(-1), start_position_(0), end_position_(0), parameters_end_pos_(kNoSourcePosition), function_literal_id_(FunctionLiteral::kIdTypeInvalid), max_function_literal_id_(FunctionLiteral::kIdTypeInvalid), character_stream_(nullptr), ast_value_factory_(nullptr), ast_string_constants_(nullptr), function_name_(nullptr), runtime_call_stats_(nullptr), source_range_map_(nullptr), literal_(nullptr) { set_hash_seed(isolate->heap()->HashSeed()); set_stack_limit(isolate->stack_guard()->real_climit()); set_unicode_cache(isolate->unicode_cache()); set_runtime_call_stats(isolate->counters()->runtime_call_stats()); set_logger(isolate->logger()); set_ast_string_constants(isolate->ast_string_constants()); if (isolate->is_block_code_coverage()) set_block_coverage_enabled(); if (isolate->is_collecting_type_profile()) set_collect_type_profile(); } ParseInfo::ParseInfo(Isolate* isolate) : ParseInfo(isolate, isolate->allocator()) { script_id_ = isolate->heap()->NextScriptId(); LOG(isolate, ScriptEvent(Logger::ScriptEventType::kReserveId, script_id_)); } ParseInfo::ParseInfo(Isolate* isolate, Handle shared) : ParseInfo(isolate, isolate->allocator()) { // Do not support re-parsing top-level function of a wrapped script. // TODO(yangguo): consider whether we need a top-level function in a // wrapped script at all. DCHECK_IMPLIES(is_toplevel(), !Script::cast(shared->script())->is_wrapped()); set_toplevel(shared->is_toplevel()); set_wrapped_as_function(shared->is_wrapped()); set_allow_lazy_parsing(FLAG_lazy_inner_functions); set_is_named_expression(shared->is_named_expression()); set_start_position(shared->StartPosition()); set_end_position(shared->EndPosition()); function_literal_id_ = shared->FunctionLiteralId(isolate); set_language_mode(shared->language_mode()); set_function_kind(shared->kind()); set_declaration(shared->is_declaration()); set_requires_instance_fields_initializer( shared->requires_instance_fields_initializer()); set_asm_wasm_broken(shared->is_asm_wasm_broken()); Handle