aboutsummaryrefslogtreecommitdiff
path: root/deps/v8/src/parsing/parse-info.cc
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/parsing/parse-info.cc')
-rw-r--r--deps/v8/src/parsing/parse-info.cc96
1 files changed, 56 insertions, 40 deletions
diff --git a/deps/v8/src/parsing/parse-info.cc b/deps/v8/src/parsing/parse-info.cc
index 0a58c4f0bd..129b00a2c2 100644
--- a/deps/v8/src/parsing/parse-info.cc
+++ b/deps/v8/src/parsing/parse-info.cc
@@ -16,7 +16,7 @@
namespace v8 {
namespace internal {
-ParseInfo::ParseInfo(Isolate* isolate, AccountingAllocator* zone_allocator)
+ParseInfo::ParseInfo(AccountingAllocator* zone_allocator)
: zone_(base::make_unique<Zone>(zone_allocator, ZONE_NAME)),
flags_(0),
extension_(nullptr),
@@ -37,7 +37,10 @@ ParseInfo::ParseInfo(Isolate* isolate, AccountingAllocator* zone_allocator)
function_name_(nullptr),
runtime_call_stats_(nullptr),
source_range_map_(nullptr),
- literal_(nullptr) {
+ literal_(nullptr) {}
+
+ParseInfo::ParseInfo(Isolate* isolate, AccountingAllocator* zone_allocator)
+ : ParseInfo(zone_allocator) {
set_hash_seed(isolate->heap()->HashSeed());
set_stack_limit(isolate->stack_guard()->real_climit());
set_unicode_cache(isolate->unicode_cache());
@@ -54,6 +57,18 @@ ParseInfo::ParseInfo(Isolate* isolate)
LOG(isolate, ScriptEvent(Logger::ScriptEventType::kReserveId, script_id_));
}
+template <typename T>
+void ParseInfo::SetFunctionInfo(T function) {
+ set_is_named_expression(function->is_named_expression());
+ set_language_mode(function->language_mode());
+ set_function_kind(function->kind());
+ set_declaration(function->is_declaration());
+ set_requires_instance_fields_initializer(
+ function->requires_instance_fields_initializer());
+ set_toplevel(function->is_toplevel());
+ set_wrapped_as_function(function->is_wrapped());
+}
+
ParseInfo::ParseInfo(Isolate* isolate, Handle<SharedFunctionInfo> shared)
: ParseInfo(isolate, isolate->allocator()) {
// Do not support re-parsing top-level function of a wrapped script.
@@ -61,19 +76,13 @@ ParseInfo::ParseInfo(Isolate* isolate, Handle<SharedFunctionInfo> shared)
// 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_asm_wasm_broken(shared->is_asm_wasm_broken());
+
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());
+ SetFunctionInfo(shared);
Handle<Script> script(Script::cast(shared->script()), isolate);
set_script(script);
@@ -99,37 +108,44 @@ ParseInfo::ParseInfo(Isolate* isolate, Handle<Script> script)
script->IsUserJavaScript());
}
-ParseInfo::~ParseInfo() {}
-
-DeclarationScope* ParseInfo::scope() const { return literal()->scope(); }
-
-void ParseInfo::EmitBackgroundParseStatisticsOnBackgroundThread() {
- // If runtime call stats was enabled by tracing, emit a trace event at the
- // end of background parsing on the background thread.
- if (runtime_call_stats_ &&
- (FLAG_runtime_stats &
- v8::tracing::TracingCategoryObserver::ENABLED_BY_TRACING)) {
- auto value = v8::tracing::TracedValue::Create();
- runtime_call_stats_->Dump(value.get());
- TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("v8.runtime_stats"),
- "V8.RuntimeStats", TRACE_EVENT_SCOPE_THREAD,
- "runtime-call-stats", std::move(value));
- }
+// static
+std::unique_ptr<ParseInfo> ParseInfo::FromParent(
+ const ParseInfo* outer_parse_info, AccountingAllocator* zone_allocator,
+ const FunctionLiteral* literal, const AstRawString* function_name) {
+ std::unique_ptr<ParseInfo> result =
+ base::make_unique<ParseInfo>(zone_allocator);
+
+ // Replicate shared state of the outer_parse_info.
+ result->flags_ = outer_parse_info->flags_;
+ result->script_id_ = outer_parse_info->script_id_;
+ result->set_logger(outer_parse_info->logger());
+ result->set_ast_string_constants(outer_parse_info->ast_string_constants());
+ result->set_hash_seed(outer_parse_info->hash_seed());
+
+ DCHECK_EQ(outer_parse_info->parameters_end_pos(), kNoSourcePosition);
+ DCHECK_NULL(outer_parse_info->extension());
+ DCHECK(outer_parse_info->maybe_outer_scope_info().is_null());
+
+ // Clone the function_name AstRawString into the ParseInfo's own
+ // AstValueFactory.
+ const AstRawString* cloned_function_name =
+ result->GetOrCreateAstValueFactory()->CloneFromOtherFactory(
+ function_name);
+
+ // Setup function specific details.
+ DCHECK(!literal->is_toplevel());
+ result->set_function_name(cloned_function_name);
+ result->set_start_position(literal->start_position());
+ result->set_end_position(literal->end_position());
+ result->set_function_literal_id(literal->function_literal_id());
+ result->SetFunctionInfo(literal);
+
+ return result;
}
-void ParseInfo::UpdateBackgroundParseStatisticsOnMainThread(Isolate* isolate) {
- // Copy over the counters from the background thread to the main counters on
- // the isolate.
- RuntimeCallStats* main_call_stats = isolate->counters()->runtime_call_stats();
- if (FLAG_runtime_stats ==
- v8::tracing::TracingCategoryObserver::ENABLED_BY_NATIVE) {
- DCHECK_NE(main_call_stats, runtime_call_stats());
- DCHECK_NOT_NULL(main_call_stats);
- DCHECK_NOT_NULL(runtime_call_stats());
- main_call_stats->Add(runtime_call_stats());
- }
- set_runtime_call_stats(main_call_stats);
-}
+ParseInfo::~ParseInfo() = default;
+
+DeclarationScope* ParseInfo::scope() const { return literal()->scope(); }
Handle<Script> ParseInfo::CreateScript(Isolate* isolate, Handle<String> source,
ScriptOriginOptions origin_options,