Commit 37cdb18b authored by rmcilroy's avatar rmcilroy Committed by Commit bot

Revert of [Parse] ParseInfo owns the parsing Zone. (patchset #4 id:60001 of...

Revert of [Parse] ParseInfo owns the parsing Zone. (patchset #4 id:60001 of https://codereview.chromium.org/2632123006/ )

Reason for revert:
Crashes on Windows in:
 CompilerDispatcherJobTest.CompileFailureToFinalize
 CompilerDispatcherJobTest.ScopeChain

Original issue's description:
> [Parse] ParseInfo owns the parsing Zone.
>
> Moves ownership of the parsing Zone to ParseInfo with a shared_ptr. This is
> in preperation for enabling background compilation jobs for inner functions
> share the AST in the outer-function's parse zone memory (read-only), with the
> and zone being released when all compilation jobs have completed.
>
> BUG=v8:5203,v8:5215
>
> Review-Url: https://codereview.chromium.org/2632123006
> Cr-Commit-Position: refs/heads/master@{#42539}
> Committed: https://chromium.googlesource.com/v8/v8/+/839b06b64fcaaaa9cceb2c3fd8fd5429e2932095

TBR=marja@chromium.org,mstarzinger@chromium.org,ahaas@chromium.org,verwaest@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=v8:5203,v8:5215

Review-Url: https://codereview.chromium.org/2645613008
Cr-Commit-Position: refs/heads/master@{#42542}
parent d2fe6dfa
...@@ -142,27 +142,27 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> { ...@@ -142,27 +142,27 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
DCHECK_EQ(kModuleScope, scope_); DCHECK_EQ(kModuleScope, scope_);
DCHECK_NULL(current_function_builder_); DCHECK_NULL(current_function_builder_);
FunctionLiteral* old_func = decl->fun(); FunctionLiteral* old_func = decl->fun();
Zone zone(isolate_->allocator(), ZONE_NAME);
DeclarationScope* new_func_scope = nullptr; DeclarationScope* new_func_scope = nullptr;
std::unique_ptr<ParseInfo> info;
if (decl->fun()->body() == nullptr) { if (decl->fun()->body() == nullptr) {
// TODO(titzer/bradnelson): Reuse SharedFunctionInfos used here when // TODO(titzer/bradnelson): Reuse SharedFunctionInfos used here when
// compiling the wasm module. // compiling the wasm module.
Handle<SharedFunctionInfo> shared = Handle<SharedFunctionInfo> shared =
Compiler::GetSharedFunctionInfo(decl->fun(), script_, info_); Compiler::GetSharedFunctionInfo(decl->fun(), script_, info_);
shared->set_is_toplevel(false); shared->set_is_toplevel(false);
info.reset(new ParseInfo(script_)); ParseInfo info(&zone, script_);
info->set_shared_info(shared); info.set_shared_info(shared);
info->set_toplevel(false); info.set_toplevel(false);
info->set_language_mode(decl->fun()->scope()->language_mode()); info.set_language_mode(decl->fun()->scope()->language_mode());
info->set_allow_lazy_parsing(false); info.set_allow_lazy_parsing(false);
info->set_function_literal_id(shared->function_literal_id()); info.set_function_literal_id(shared->function_literal_id());
info->set_ast_value_factory(ast_value_factory_); info.set_ast_value_factory(ast_value_factory_);
info->set_ast_value_factory_owned(false); info.set_ast_value_factory_owned(false);
// Create fresh function scope to use to parse the function in. // Create fresh function scope to use to parse the function in.
new_func_scope = new (info->zone()) DeclarationScope( new_func_scope = new (info.zone()) DeclarationScope(
info->zone(), decl->fun()->scope()->outer_scope(), FUNCTION_SCOPE); info.zone(), decl->fun()->scope()->outer_scope(), FUNCTION_SCOPE);
info->set_asm_function_scope(new_func_scope); info.set_asm_function_scope(new_func_scope);
if (!Compiler::ParseAndAnalyze(info.get())) { if (!Compiler::ParseAndAnalyze(&info)) {
decl->fun()->scope()->outer_scope()->RemoveInnerScope(new_func_scope); decl->fun()->scope()->outer_scope()->RemoveInnerScope(new_func_scope);
if (isolate_->has_pending_exception()) { if (isolate_->has_pending_exception()) {
isolate_->clear_pending_exception(); isolate_->clear_pending_exception();
...@@ -171,7 +171,7 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> { ...@@ -171,7 +171,7 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
typer_failed_ = true; typer_failed_ = true;
return; return;
} }
FunctionLiteral* func = info->literal(); FunctionLiteral* func = info.literal();
DCHECK_NOT_NULL(func); DCHECK_NOT_NULL(func);
decl->set_fun(func); decl->set_fun(func);
} }
......
...@@ -13,6 +13,7 @@ namespace internal { ...@@ -13,6 +13,7 @@ namespace internal {
void StreamedSource::Release() { void StreamedSource::Release() {
parser.reset(); parser.reset();
info.reset(); info.reset();
zone.reset();
} }
BackgroundParsingTask::BackgroundParsingTask( BackgroundParsingTask::BackgroundParsingTask(
...@@ -28,8 +29,10 @@ BackgroundParsingTask::BackgroundParsingTask( ...@@ -28,8 +29,10 @@ BackgroundParsingTask::BackgroundParsingTask(
// Prepare the data for the internalization phase and compilation phase, which // Prepare the data for the internalization phase and compilation phase, which
// will happen in the main thread after parsing. // will happen in the main thread after parsing.
ParseInfo* info = new ParseInfo(isolate->allocator()); Zone* zone = new Zone(isolate->allocator(), ZONE_NAME);
ParseInfo* info = new ParseInfo(zone);
info->set_toplevel(); info->set_toplevel();
source->zone.reset(zone);
source->info.reset(info); source->info.reset(info);
info->set_isolate(isolate); info->set_isolate(isolate);
info->set_source_stream(source->source_stream.get()); info->set_source_stream(source->source_stream.get());
......
...@@ -38,6 +38,7 @@ struct StreamedSource { ...@@ -38,6 +38,7 @@ struct StreamedSource {
// between parsing and compilation. These need to be initialized before the // between parsing and compilation. These need to be initialized before the
// compilation starts. // compilation starts.
UnicodeCache unicode_cache; UnicodeCache unicode_cache;
std::unique_ptr<Zone> zone;
std::unique_ptr<ParseInfo> info; std::unique_ptr<ParseInfo> info;
std::unique_ptr<Parser> parser; std::unique_ptr<Parser> parser;
......
...@@ -105,11 +105,11 @@ void CompilerDispatcherJob::PrepareToParseOnMainThread() { ...@@ -105,11 +105,11 @@ void CompilerDispatcherJob::PrepareToParseOnMainThread() {
} }
HandleScope scope(isolate_); HandleScope scope(isolate_);
unicode_cache_.reset(new UnicodeCache()); unicode_cache_.reset(new UnicodeCache());
zone_.reset(new Zone(isolate_->allocator(), ZONE_NAME));
Handle<Script> script(Script::cast(shared_->script()), isolate_); Handle<Script> script(Script::cast(shared_->script()), isolate_);
DCHECK(script->type() != Script::TYPE_NATIVE); DCHECK(script->type() != Script::TYPE_NATIVE);
Handle<String> source(String::cast(script->source()), isolate_); Handle<String> source(String::cast(script->source()), isolate_);
parse_info_.reset(new ParseInfo(isolate_->allocator()));
if (source->IsExternalTwoByteString() || source->IsExternalOneByteString()) { if (source->IsExternalTwoByteString() || source->IsExternalOneByteString()) {
character_stream_.reset(ScannerStream::For( character_stream_.reset(ScannerStream::For(
source, shared_->start_position(), shared_->end_position())); source, shared_->start_position(), shared_->end_position()));
...@@ -140,7 +140,7 @@ void CompilerDispatcherJob::PrepareToParseOnMainThread() { ...@@ -140,7 +140,7 @@ void CompilerDispatcherJob::PrepareToParseOnMainThread() {
offset = shared_->start_position(); offset = shared_->start_position();
int byte_len = length * (source->IsOneByteRepresentation() ? 1 : 2); int byte_len = length * (source->IsOneByteRepresentation() ? 1 : 2);
data = parse_info_->zone()->New(byte_len); data = zone_->New(byte_len);
DisallowHeapAllocation no_allocation; DisallowHeapAllocation no_allocation;
String::FlatContent content = source->GetFlatContent(); String::FlatContent content = source->GetFlatContent();
...@@ -178,6 +178,7 @@ void CompilerDispatcherJob::PrepareToParseOnMainThread() { ...@@ -178,6 +178,7 @@ void CompilerDispatcherJob::PrepareToParseOnMainThread() {
ScannerStream::For(wrapper_, shared_->start_position() - offset, ScannerStream::For(wrapper_, shared_->start_position() - offset,
shared_->end_position() - offset)); shared_->end_position() - offset));
} }
parse_info_.reset(new ParseInfo(zone_.get()));
parse_info_->set_isolate(isolate_); parse_info_->set_isolate(isolate_);
parse_info_->set_character_stream(character_stream_.get()); parse_info_->set_character_stream(character_stream_.get());
parse_info_->set_hash_seed(isolate_->heap()->HashSeed()); parse_info_->set_hash_seed(isolate_->heap()->HashSeed());
...@@ -350,6 +351,7 @@ bool CompilerDispatcherJob::FinalizeCompilingOnMainThread() { ...@@ -350,6 +351,7 @@ bool CompilerDispatcherJob::FinalizeCompilingOnMainThread() {
return false; return false;
} }
zone_.reset();
parse_info_.reset(); parse_info_.reset();
compile_info_.reset(); compile_info_.reset();
compile_job_.reset(); compile_job_.reset();
...@@ -373,6 +375,7 @@ void CompilerDispatcherJob::ResetOnMainThread() { ...@@ -373,6 +375,7 @@ void CompilerDispatcherJob::ResetOnMainThread() {
handles_from_parsing_.reset(); handles_from_parsing_.reset();
compile_info_.reset(); compile_info_.reset();
compile_job_.reset(); compile_job_.reset();
zone_.reset();
if (!source_.is_null()) { if (!source_.is_null()) {
i::GlobalHandles::Destroy(Handle<Object>::cast(source_).location()); i::GlobalHandles::Destroy(Handle<Object>::cast(source_).location());
......
...@@ -97,6 +97,7 @@ class V8_EXPORT_PRIVATE CompilerDispatcherJob { ...@@ -97,6 +97,7 @@ class V8_EXPORT_PRIVATE CompilerDispatcherJob {
// Members required for parsing. // Members required for parsing.
std::unique_ptr<UnicodeCache> unicode_cache_; std::unique_ptr<UnicodeCache> unicode_cache_;
std::unique_ptr<Zone> zone_;
std::unique_ptr<Utf16CharacterStream> character_stream_; std::unique_ptr<Utf16CharacterStream> character_stream_;
std::unique_ptr<ParseInfo> parse_info_; std::unique_ptr<ParseInfo> parse_info_;
std::unique_ptr<Parser> parser_; std::unique_ptr<Parser> parser_;
......
...@@ -507,7 +507,8 @@ bool CompileUnoptimizedInnerFunctionsRecursively( ...@@ -507,7 +507,8 @@ bool CompileUnoptimizedInnerFunctionsRecursively(
shared->set_is_toplevel(false); shared->set_is_toplevel(false);
} }
ParseInfo parse_info(script); Zone zone(isolate->allocator(), ZONE_NAME);
ParseInfo parse_info(&zone, script);
parse_info.set_literal(literal); parse_info.set_literal(literal);
parse_info.set_shared_info(shared); parse_info.set_shared_info(shared);
parse_info.set_function_literal_id(shared->function_literal_id()); parse_info.set_function_literal_id(shared->function_literal_id());
...@@ -895,7 +896,8 @@ MaybeHandle<Code> GetBaselineCode(Handle<JSFunction> function) { ...@@ -895,7 +896,8 @@ MaybeHandle<Code> GetBaselineCode(Handle<JSFunction> function) {
Isolate* isolate = function->GetIsolate(); Isolate* isolate = function->GetIsolate();
VMState<COMPILER> state(isolate); VMState<COMPILER> state(isolate);
PostponeInterruptsScope postpone(isolate); PostponeInterruptsScope postpone(isolate);
ParseInfo parse_info(handle(function->shared())); Zone zone(isolate->allocator(), ZONE_NAME);
ParseInfo parse_info(&zone, handle(function->shared()));
CompilationInfo info(&parse_info, function); CompilationInfo info(&parse_info, function);
DCHECK(function->shared()->is_compiled()); DCHECK(function->shared()->is_compiled());
...@@ -1028,7 +1030,8 @@ MaybeHandle<Code> GetLazyCode(Handle<JSFunction> function) { ...@@ -1028,7 +1030,8 @@ MaybeHandle<Code> GetLazyCode(Handle<JSFunction> function) {
return entry; return entry;
} }
ParseInfo parse_info(handle(function->shared())); Zone zone(isolate->allocator(), ZONE_NAME);
ParseInfo parse_info(&zone, handle(function->shared()));
CompilationInfo info(&parse_info, function); CompilationInfo info(&parse_info, function);
Handle<Code> result; Handle<Code> result;
ASSIGN_RETURN_ON_EXCEPTION(isolate, result, GetUnoptimizedCode(&info), Code); ASSIGN_RETURN_ON_EXCEPTION(isolate, result, GetUnoptimizedCode(&info), Code);
...@@ -1207,7 +1210,8 @@ bool Compiler::CompileOptimized(Handle<JSFunction> function, ...@@ -1207,7 +1210,8 @@ bool Compiler::CompileOptimized(Handle<JSFunction> function,
code = isolate->builtins()->InterpreterEntryTrampoline(); code = isolate->builtins()->InterpreterEntryTrampoline();
function->shared()->ReplaceCode(*code); function->shared()->ReplaceCode(*code);
} else { } else {
ParseInfo parse_info(handle(function->shared())); Zone zone(isolate->allocator(), ZONE_NAME);
ParseInfo parse_info(&zone, handle(function->shared()));
CompilationInfo info(&parse_info, function); CompilationInfo info(&parse_info, function);
if (!GetUnoptimizedCode(&info).ToHandle(&code)) { if (!GetUnoptimizedCode(&info).ToHandle(&code)) {
return false; return false;
...@@ -1231,7 +1235,8 @@ bool Compiler::CompileDebugCode(Handle<SharedFunctionInfo> shared) { ...@@ -1231,7 +1235,8 @@ bool Compiler::CompileDebugCode(Handle<SharedFunctionInfo> shared) {
DCHECK(AllowCompilation::IsAllowed(isolate)); DCHECK(AllowCompilation::IsAllowed(isolate));
// Start a compilation. // Start a compilation.
ParseInfo parse_info(shared); Zone zone(isolate->allocator(), ZONE_NAME);
ParseInfo parse_info(&zone, shared);
CompilationInfo info(&parse_info, Handle<JSFunction>::null()); CompilationInfo info(&parse_info, Handle<JSFunction>::null());
info.MarkAsDebug(); info.MarkAsDebug();
if (GetUnoptimizedCode(&info).is_null()) { if (GetUnoptimizedCode(&info).is_null()) {
...@@ -1258,7 +1263,8 @@ MaybeHandle<JSArray> Compiler::CompileForLiveEdit(Handle<Script> script) { ...@@ -1258,7 +1263,8 @@ MaybeHandle<JSArray> Compiler::CompileForLiveEdit(Handle<Script> script) {
script->set_shared_function_infos(isolate->heap()->empty_fixed_array()); script->set_shared_function_infos(isolate->heap()->empty_fixed_array());
// Start a compilation. // Start a compilation.
ParseInfo parse_info(script); Zone zone(isolate->allocator(), ZONE_NAME);
ParseInfo parse_info(&zone, script);
CompilationInfo info(&parse_info, Handle<JSFunction>::null()); CompilationInfo info(&parse_info, Handle<JSFunction>::null());
info.MarkAsDebug(); info.MarkAsDebug();
...@@ -1269,7 +1275,7 @@ MaybeHandle<JSArray> Compiler::CompileForLiveEdit(Handle<Script> script) { ...@@ -1269,7 +1275,7 @@ MaybeHandle<JSArray> Compiler::CompileForLiveEdit(Handle<Script> script) {
// Check postconditions on success. // Check postconditions on success.
DCHECK(!isolate->has_pending_exception()); DCHECK(!isolate->has_pending_exception());
infos = LiveEditFunctionTracker::Collect(parse_info.literal(), script, infos = LiveEditFunctionTracker::Collect(parse_info.literal(), script,
parse_info.zone(), isolate); &zone, isolate);
} }
// Restore the original function info list in order to remain side-effect // Restore the original function info list in order to remain side-effect
...@@ -1393,7 +1399,8 @@ MaybeHandle<JSFunction> Compiler::GetFunctionFromEval( ...@@ -1393,7 +1399,8 @@ MaybeHandle<JSFunction> Compiler::GetFunctionFromEval(
script->set_compilation_type(Script::COMPILATION_TYPE_EVAL); script->set_compilation_type(Script::COMPILATION_TYPE_EVAL);
Script::SetEvalOrigin(script, outer_info, eval_position); Script::SetEvalOrigin(script, outer_info, eval_position);
ParseInfo parse_info(script); Zone zone(isolate->allocator(), ZONE_NAME);
ParseInfo parse_info(&zone, script);
CompilationInfo info(&parse_info, Handle<JSFunction>::null()); CompilationInfo info(&parse_info, Handle<JSFunction>::null());
parse_info.set_eval(); parse_info.set_eval();
parse_info.set_language_mode(language_mode); parse_info.set_language_mode(language_mode);
...@@ -1571,7 +1578,8 @@ Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfoForScript( ...@@ -1571,7 +1578,8 @@ Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfoForScript(
} }
// Compile the function and add it to the cache. // Compile the function and add it to the cache.
ParseInfo parse_info(script); Zone zone(isolate->allocator(), ZONE_NAME);
ParseInfo parse_info(&zone, script);
CompilationInfo info(&parse_info, Handle<JSFunction>::null()); CompilationInfo info(&parse_info, Handle<JSFunction>::null());
if (resource_options.IsModule()) parse_info.set_module(); if (resource_options.IsModule()) parse_info.set_module();
if (compile_options != ScriptCompiler::kNoCompileOptions) { if (compile_options != ScriptCompiler::kNoCompileOptions) {
......
...@@ -474,7 +474,8 @@ Reduction JSInliner::ReduceJSCall(Node* node, Handle<JSFunction> function) { ...@@ -474,7 +474,8 @@ Reduction JSInliner::ReduceJSCall(Node* node, Handle<JSFunction> function) {
} }
} }
ParseInfo parse_info(shared_info); Zone zone(info_->isolate()->allocator(), ZONE_NAME);
ParseInfo parse_info(&zone, shared_info);
CompilationInfo info(&parse_info, Handle<JSFunction>::null()); CompilationInfo info(&parse_info, Handle<JSFunction>::null());
if (info_->is_deoptimization_enabled()) info.MarkAsDeoptimizationEnabled(); if (info_->is_deoptimization_enabled()) info.MarkAsDeoptimizationEnabled();
info.MarkAsOptimizeFromBytecode(); info.MarkAsOptimizeFromBytecode();
...@@ -513,7 +514,7 @@ Reduction JSInliner::ReduceJSCall(Node* node, Handle<JSFunction> function) { ...@@ -513,7 +514,7 @@ Reduction JSInliner::ReduceJSCall(Node* node, Handle<JSFunction> function) {
// Run the BytecodeGraphBuilder to create the subgraph. // Run the BytecodeGraphBuilder to create the subgraph.
Graph::SubgraphScope scope(graph()); Graph::SubgraphScope scope(graph());
BytecodeGraphBuilder graph_builder( BytecodeGraphBuilder graph_builder(
parse_info.zone(), shared_info, handle(function->feedback_vector()), &zone, shared_info, handle(function->feedback_vector()),
BailoutId::None(), jsgraph(), call.frequency(), source_positions_, BailoutId::None(), jsgraph(), call.frequency(), source_positions_,
inlining_id); inlining_id);
graph_builder.CreateGraph(false); graph_builder.CreateGraph(false);
......
...@@ -550,8 +550,9 @@ class PipelineCompilationJob final : public CompilationJob { ...@@ -550,8 +550,9 @@ class PipelineCompilationJob final : public CompilationJob {
// Note that the CompilationInfo is not initialized at the time we pass it // Note that the CompilationInfo is not initialized at the time we pass it
// to the CompilationJob constructor, but it is not dereferenced there. // to the CompilationJob constructor, but it is not dereferenced there.
: CompilationJob(isolate, &info_, "TurboFan"), : CompilationJob(isolate, &info_, "TurboFan"),
parse_info_(handle(function->shared())), zone_(isolate->allocator(), ZONE_NAME),
zone_stats_(isolate->allocator()), zone_stats_(isolate->allocator()),
parse_info_(&zone_, handle(function->shared())),
info_(&parse_info_, function), info_(&parse_info_, function),
pipeline_statistics_(CreatePipelineStatistics(info(), &zone_stats_)), pipeline_statistics_(CreatePipelineStatistics(info(), &zone_stats_)),
data_(&zone_stats_, info(), pipeline_statistics_.get()), data_(&zone_stats_, info(), pipeline_statistics_.get()),
...@@ -564,8 +565,9 @@ class PipelineCompilationJob final : public CompilationJob { ...@@ -564,8 +565,9 @@ class PipelineCompilationJob final : public CompilationJob {
Status FinalizeJobImpl() final; Status FinalizeJobImpl() final;
private: private:
ParseInfo parse_info_; Zone zone_;
ZoneStats zone_stats_; ZoneStats zone_stats_;
ParseInfo parse_info_;
CompilationInfo info_; CompilationInfo info_;
std::unique_ptr<PipelineStatistics> pipeline_statistics_; std::unique_ptr<PipelineStatistics> pipeline_statistics_;
PipelineData data_; PipelineData data_;
...@@ -602,8 +604,7 @@ PipelineCompilationJob::Status PipelineCompilationJob::PrepareJobImpl() { ...@@ -602,8 +604,7 @@ PipelineCompilationJob::Status PipelineCompilationJob::PrepareJobImpl() {
info()->MarkAsInliningEnabled(); info()->MarkAsInliningEnabled();
} }
linkage_ = new (info()->zone()) linkage_ = new (&zone_) Linkage(Linkage::ComputeIncoming(&zone_, info()));
Linkage(Linkage::ComputeIncoming(info()->zone(), info()));
if (!pipeline_.CreateGraph()) { if (!pipeline_.CreateGraph()) {
if (isolate()->has_pending_exception()) return FAILED; // Stack overflowed. if (isolate()->has_pending_exception()) return FAILED; // Stack overflowed.
......
...@@ -8032,7 +8032,7 @@ bool HOptimizedGraphBuilder::TryInline(Handle<JSFunction> target, ...@@ -8032,7 +8032,7 @@ bool HOptimizedGraphBuilder::TryInline(Handle<JSFunction> target,
// Use the same AstValueFactory for creating strings in the sub-compilation // Use the same AstValueFactory for creating strings in the sub-compilation
// step, but don't transfer ownership to target_info. // step, but don't transfer ownership to target_info.
Handle<SharedFunctionInfo> target_shared(target->shared()); Handle<SharedFunctionInfo> target_shared(target->shared());
ParseInfo parse_info(target_shared, top_info()->parse_info()->zone_shared()); ParseInfo parse_info(zone(), target_shared);
parse_info.set_ast_value_factory( parse_info.set_ast_value_factory(
top_info()->parse_info()->ast_value_factory()); top_info()->parse_info()->ast_value_factory());
parse_info.set_ast_value_factory_owned(false); parse_info.set_ast_value_factory_owned(false);
......
...@@ -37,7 +37,8 @@ class HCompilationJob final : public CompilationJob { ...@@ -37,7 +37,8 @@ class HCompilationJob final : public CompilationJob {
public: public:
explicit HCompilationJob(Handle<JSFunction> function) explicit HCompilationJob(Handle<JSFunction> function)
: CompilationJob(function->GetIsolate(), &info_, "Crankshaft"), : CompilationJob(function->GetIsolate(), &info_, "Crankshaft"),
parse_info_(handle(function->shared())), zone_(function->GetIsolate()->allocator(), ZONE_NAME),
parse_info_(&zone_, handle(function->shared())),
info_(&parse_info_, function), info_(&parse_info_, function),
graph_(nullptr), graph_(nullptr),
chunk_(nullptr) {} chunk_(nullptr) {}
...@@ -48,6 +49,7 @@ class HCompilationJob final : public CompilationJob { ...@@ -48,6 +49,7 @@ class HCompilationJob final : public CompilationJob {
virtual Status FinalizeJobImpl(); virtual Status FinalizeJobImpl();
private: private:
Zone zone_;
ParseInfo parse_info_; ParseInfo parse_info_;
CompilationInfo info_; CompilationInfo info_;
HGraph* graph_; HGraph* graph_;
......
...@@ -87,11 +87,12 @@ ScopeIterator::ScopeIterator(Isolate* isolate, FrameInspector* frame_inspector, ...@@ -87,11 +87,12 @@ ScopeIterator::ScopeIterator(Isolate* isolate, FrameInspector* frame_inspector,
// Reparse the code and analyze the scopes. // Reparse the code and analyze the scopes.
// Check whether we are in global, eval or function code. // Check whether we are in global, eval or function code.
Zone zone(isolate->allocator(), ZONE_NAME);
std::unique_ptr<ParseInfo> info; std::unique_ptr<ParseInfo> info;
if (scope_info->scope_type() != FUNCTION_SCOPE) { if (scope_info->scope_type() != FUNCTION_SCOPE) {
// Global or eval code. // Global or eval code.
Handle<Script> script(Script::cast(shared_info->script())); Handle<Script> script(Script::cast(shared_info->script()));
info.reset(new ParseInfo(script)); info.reset(new ParseInfo(&zone, script));
if (scope_info->scope_type() == EVAL_SCOPE) { if (scope_info->scope_type() == EVAL_SCOPE) {
info->set_eval(); info->set_eval();
if (!function->context()->IsNativeContext()) { if (!function->context()->IsNativeContext()) {
...@@ -107,7 +108,7 @@ ScopeIterator::ScopeIterator(Isolate* isolate, FrameInspector* frame_inspector, ...@@ -107,7 +108,7 @@ ScopeIterator::ScopeIterator(Isolate* isolate, FrameInspector* frame_inspector,
} }
} else { } else {
// Inner function. // Inner function.
info.reset(new ParseInfo(shared_info)); info.reset(new ParseInfo(&zone, shared_info));
} }
if (parsing::ParseAny(info.get()) && Rewriter::Rewrite(info.get())) { if (parsing::ParseAny(info.get()) && Rewriter::Rewrite(info.get())) {
DeclarationScope* scope = info->literal()->scope(); DeclarationScope* scope = info->literal()->scope();
......
...@@ -7,13 +7,12 @@ ...@@ -7,13 +7,12 @@
#include "src/ast/ast-value-factory.h" #include "src/ast/ast-value-factory.h"
#include "src/ast/ast.h" #include "src/ast/ast.h"
#include "src/objects-inl.h" #include "src/objects-inl.h"
#include "src/zone/zone.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {
ParseInfo::ParseInfo(AccountingAllocator* zone_allocator) ParseInfo::ParseInfo(Zone* zone)
: zone_(std::make_shared<Zone>(zone_allocator, ZONE_NAME)), : zone_(zone),
flags_(0), flags_(0),
source_stream_(nullptr), source_stream_(nullptr),
source_stream_encoding_(ScriptCompiler::StreamedSource::ONE_BYTE), source_stream_encoding_(ScriptCompiler::StreamedSource::ONE_BYTE),
...@@ -36,8 +35,8 @@ ParseInfo::ParseInfo(AccountingAllocator* zone_allocator) ...@@ -36,8 +35,8 @@ ParseInfo::ParseInfo(AccountingAllocator* zone_allocator)
function_name_(nullptr), function_name_(nullptr),
literal_(nullptr) {} literal_(nullptr) {}
ParseInfo::ParseInfo(Handle<SharedFunctionInfo> shared) ParseInfo::ParseInfo(Zone* zone, Handle<SharedFunctionInfo> shared)
: ParseInfo(shared->GetIsolate()->allocator()) { : ParseInfo(zone) {
isolate_ = shared->GetIsolate(); isolate_ = shared->GetIsolate();
set_toplevel(shared->is_toplevel()); set_toplevel(shared->is_toplevel());
...@@ -67,14 +66,7 @@ ParseInfo::ParseInfo(Handle<SharedFunctionInfo> shared) ...@@ -67,14 +66,7 @@ ParseInfo::ParseInfo(Handle<SharedFunctionInfo> shared)
} }
} }
ParseInfo::ParseInfo(Handle<SharedFunctionInfo> shared, ParseInfo::ParseInfo(Zone* zone, Handle<Script> script) : ParseInfo(zone) {
std::shared_ptr<Zone> zone)
: ParseInfo(shared) {
zone_.swap(zone);
}
ParseInfo::ParseInfo(Handle<Script> script)
: ParseInfo(script->GetIsolate()->allocator()) {
isolate_ = script->GetIsolate(); isolate_ = script->GetIsolate();
set_allow_lazy_parsing(); set_allow_lazy_parsing();
......
...@@ -5,8 +5,6 @@ ...@@ -5,8 +5,6 @@
#ifndef V8_PARSING_PARSE_INFO_H_ #ifndef V8_PARSING_PARSE_INFO_H_
#define V8_PARSING_PARSE_INFO_H_ #define V8_PARSING_PARSE_INFO_H_
#include <memory>
#include "include/v8.h" #include "include/v8.h"
#include "src/globals.h" #include "src/globals.h"
#include "src/handles.h" #include "src/handles.h"
...@@ -18,7 +16,6 @@ class Extension; ...@@ -18,7 +16,6 @@ class Extension;
namespace internal { namespace internal {
class AccountingAllocator;
class AstRawString; class AstRawString;
class AstValueFactory; class AstValueFactory;
class DeclarationScope; class DeclarationScope;
...@@ -32,18 +29,13 @@ class Zone; ...@@ -32,18 +29,13 @@ class Zone;
// A container for the inputs, configuration options, and outputs of parsing. // A container for the inputs, configuration options, and outputs of parsing.
class V8_EXPORT_PRIVATE ParseInfo { class V8_EXPORT_PRIVATE ParseInfo {
public: public:
explicit ParseInfo(AccountingAllocator* zone_allocator); explicit ParseInfo(Zone* zone);
ParseInfo(Handle<Script> script); ParseInfo(Zone* zone, Handle<Script> script);
ParseInfo(Handle<SharedFunctionInfo> shared); ParseInfo(Zone* zone, Handle<SharedFunctionInfo> shared);
// TODO(rmcilroy): Remove once Hydrogen no longer needs this.
ParseInfo(Handle<SharedFunctionInfo> shared, std::shared_ptr<Zone> zone);
~ParseInfo(); ~ParseInfo();
Zone* zone() const { return zone_.get(); } Zone* zone() const { return zone_; }
std::shared_ptr<Zone> zone_shared() const { return zone_; }
// Convenience accessor methods for flags. // Convenience accessor methods for flags.
#define FLAG_ACCESSOR(flag, getter, setter) \ #define FLAG_ACCESSOR(flag, getter, setter) \
...@@ -232,7 +224,7 @@ class V8_EXPORT_PRIVATE ParseInfo { ...@@ -232,7 +224,7 @@ class V8_EXPORT_PRIVATE ParseInfo {
}; };
//------------- Inputs to parsing and scope analysis ----------------------- //------------- Inputs to parsing and scope analysis -----------------------
std::shared_ptr<Zone> zone_; Zone* zone_;
unsigned flags_; unsigned flags_;
ScriptCompiler::ExternalSourceStream* source_stream_; ScriptCompiler::ExternalSourceStream* source_stream_;
ScriptCompiler::StreamedSource::Encoding source_stream_encoding_; ScriptCompiler::StreamedSource::Encoding source_stream_encoding_;
......
...@@ -352,7 +352,8 @@ bool ComputeLocation(Isolate* isolate, MessageLocation* target) { ...@@ -352,7 +352,8 @@ bool ComputeLocation(Isolate* isolate, MessageLocation* target) {
Handle<String> RenderCallSite(Isolate* isolate, Handle<Object> object) { Handle<String> RenderCallSite(Isolate* isolate, Handle<Object> object) {
MessageLocation location; MessageLocation location;
if (ComputeLocation(isolate, &location)) { if (ComputeLocation(isolate, &location)) {
std::unique_ptr<ParseInfo> info(new ParseInfo(location.shared())); Zone zone(isolate->allocator(), ZONE_NAME);
std::unique_ptr<ParseInfo> info(new ParseInfo(&zone, location.shared()));
if (parsing::ParseAny(info.get())) { if (parsing::ParseAny(info.get())) {
CallPrinter printer(isolate, location.shared()->IsUserJavaScript()); CallPrinter printer(isolate, location.shared()->IsUserJavaScript());
Handle<String> str = printer.Print(info->literal(), location.start_pos()); Handle<String> str = printer.Print(info->literal(), location.start_pos());
......
...@@ -45,32 +45,33 @@ class AsmTyperHarnessBuilder { ...@@ -45,32 +45,33 @@ class AsmTyperHarnessBuilder {
: source_(source), : source_(source),
validation_type_(type), validation_type_(type),
handles_(), handles_(),
zone_(handles_.main_zone()),
isolate_(CcTest::i_isolate()), isolate_(CcTest::i_isolate()),
ast_value_factory_(zone_, isolate_->ast_string_constants(),
isolate_->heap()->HashSeed()),
factory_(isolate_->factory()), factory_(isolate_->factory()),
source_code_( source_code_(
factory_->NewStringFromUtf8(CStrVector(source)).ToHandleChecked()), factory_->NewStringFromUtf8(CStrVector(source)).ToHandleChecked()),
script_(factory_->NewScript(source_code_)), script_(factory_->NewScript(source_code_)) {
info_(script_), ParseInfo info(zone_, script_);
ast_value_factory_(info_.zone(), isolate_->ast_string_constants(), info.set_allow_lazy_parsing(false);
isolate_->heap()->HashSeed()) { info.set_toplevel(true);
info_.set_allow_lazy_parsing(false); info.set_ast_value_factory(&ast_value_factory_);
info_.set_toplevel(true); info.set_ast_value_factory_owned(false);
info_.set_ast_value_factory(&ast_value_factory_); Parser parser(&info);
info_.set_ast_value_factory_owned(false);
Parser parser(&info_); if (!Compiler::ParseAndAnalyze(&info)) {
if (!Compiler::ParseAndAnalyze(&info_)) {
std::cerr << "Failed to parse:\n" << source_ << "\n"; std::cerr << "Failed to parse:\n" << source_ << "\n";
CHECK(false); CHECK(false);
} }
outer_scope_ = info_.script_scope(); outer_scope_ = info.script_scope();
module_ = info_.scope() module_ = info.scope()
->declarations() ->declarations()
->AtForTest(0) ->AtForTest(0)
->AsFunctionDeclaration() ->AsFunctionDeclaration()
->fun(); ->fun();
typer_.reset(new AsmTyper(isolate_, zone(), script_, module_)); typer_.reset(new AsmTyper(isolate_, zone_, script_, module_));
if (validation_type_ == ValidateStatement || if (validation_type_ == ValidateStatement ||
validation_type_ == ValidateExpression) { validation_type_ == ValidateExpression) {
...@@ -103,7 +104,7 @@ class AsmTyperHarnessBuilder { ...@@ -103,7 +104,7 @@ class AsmTyperHarnessBuilder {
if (var->IsUnallocated()) { if (var->IsUnallocated()) {
var->AllocateTo(VariableLocation::LOCAL, -1); var->AllocateTo(VariableLocation::LOCAL, -1);
} }
auto* var_info = new (zone()) AsmTyper::VariableInfo(type); auto* var_info = new (zone_) AsmTyper::VariableInfo(type);
var_info->set_mutability(AsmTyper::VariableInfo::kLocal); var_info->set_mutability(AsmTyper::VariableInfo::kLocal);
CHECK(typer_->AddLocal(var, var_info)); CHECK(typer_->AddLocal(var, var_info));
return this; return this;
...@@ -115,7 +116,7 @@ class AsmTyperHarnessBuilder { ...@@ -115,7 +116,7 @@ class AsmTyperHarnessBuilder {
var->AllocateTo(VariableLocation::MODULE, -1); var->AllocateTo(VariableLocation::MODULE, -1);
} }
if (type != nullptr) { if (type != nullptr) {
auto* var_info = new (zone()) AsmTyper::VariableInfo(type); auto* var_info = new (zone_) AsmTyper::VariableInfo(type);
var_info->set_mutability(AsmTyper::VariableInfo::kMutableGlobal); var_info->set_mutability(AsmTyper::VariableInfo::kMutableGlobal);
CHECK(typer_->AddGlobal(var, var_info)); CHECK(typer_->AddGlobal(var, var_info));
} }
...@@ -124,12 +125,12 @@ class AsmTyperHarnessBuilder { ...@@ -124,12 +125,12 @@ class AsmTyperHarnessBuilder {
AsmTyperHarnessBuilder* WithGlobal( AsmTyperHarnessBuilder* WithGlobal(
VariableName var_name, std::function<AsmType*(Zone*)> type_creator) { VariableName var_name, std::function<AsmType*(Zone*)> type_creator) {
return WithGlobal(var_name, type_creator(zone())); return WithGlobal(var_name, type_creator(zone_));
} }
AsmTyperHarnessBuilder* WithUndefinedGlobal( AsmTyperHarnessBuilder* WithUndefinedGlobal(
VariableName var_name, std::function<AsmType*(Zone*)> type_creator) { VariableName var_name, std::function<AsmType*(Zone*)> type_creator) {
auto* type = type_creator(zone()); auto* type = type_creator(zone_);
CHECK(type->AsFunctionType() != nullptr || CHECK(type->AsFunctionType() != nullptr ||
type->AsFunctionTableType() != nullptr); type->AsFunctionTableType() != nullptr);
WithGlobal(var_name, type); WithGlobal(var_name, type);
...@@ -156,8 +157,7 @@ class AsmTyperHarnessBuilder { ...@@ -156,8 +157,7 @@ class AsmTyperHarnessBuilder {
CHECK(false); CHECK(false);
case AsmTyper::kFFI: case AsmTyper::kFFI:
stdlib_map = nullptr; stdlib_map = nullptr;
var_info = var_info = new (zone_) AsmTyper::VariableInfo(AsmType::FFIType(zone_));
new (zone()) AsmTyper::VariableInfo(AsmType::FFIType(zone()));
var_info->set_mutability(AsmTyper::VariableInfo::kImmutableGlobal); var_info->set_mutability(AsmTyper::VariableInfo::kImmutableGlobal);
break; break;
case AsmTyper::kInfinity: case AsmTyper::kInfinity:
...@@ -176,7 +176,7 @@ class AsmTyperHarnessBuilder { ...@@ -176,7 +176,7 @@ class AsmTyperHarnessBuilder {
} }
CHECK(var_info != nullptr); CHECK(var_info != nullptr);
var_info = var_info->Clone(zone()); var_info = var_info->Clone(zone_);
} }
CHECK(typer_->AddGlobal(var, var_info)); CHECK(typer_->AddGlobal(var, var_info));
...@@ -193,7 +193,7 @@ class AsmTyperHarnessBuilder { ...@@ -193,7 +193,7 @@ class AsmTyperHarnessBuilder {
AsmTyperHarnessBuilder* WithStdlib(VariableName var_name) { AsmTyperHarnessBuilder* WithStdlib(VariableName var_name) {
auto* var = DeclareVariable(var_name); auto* var = DeclareVariable(var_name);
auto* var_info = auto* var_info =
AsmTyper::VariableInfo::ForSpecialSymbol(zone(), AsmTyper::kStdlib); AsmTyper::VariableInfo::ForSpecialSymbol(zone_, AsmTyper::kStdlib);
CHECK(typer_->AddGlobal(var, var_info)); CHECK(typer_->AddGlobal(var, var_info));
return this; return this;
} }
...@@ -201,7 +201,7 @@ class AsmTyperHarnessBuilder { ...@@ -201,7 +201,7 @@ class AsmTyperHarnessBuilder {
AsmTyperHarnessBuilder* WithHeap(VariableName var_name) { AsmTyperHarnessBuilder* WithHeap(VariableName var_name) {
auto* var = DeclareVariable(var_name); auto* var = DeclareVariable(var_name);
auto* var_info = auto* var_info =
AsmTyper::VariableInfo::ForSpecialSymbol(zone(), AsmTyper::kHeap); AsmTyper::VariableInfo::ForSpecialSymbol(zone_, AsmTyper::kHeap);
CHECK(typer_->AddGlobal(var, var_info)); CHECK(typer_->AddGlobal(var, var_info));
return this; return this;
} }
...@@ -209,7 +209,7 @@ class AsmTyperHarnessBuilder { ...@@ -209,7 +209,7 @@ class AsmTyperHarnessBuilder {
AsmTyperHarnessBuilder* WithFFI(VariableName var_name) { AsmTyperHarnessBuilder* WithFFI(VariableName var_name) {
auto* var = DeclareVariable(var_name); auto* var = DeclareVariable(var_name);
auto* var_info = auto* var_info =
AsmTyper::VariableInfo::ForSpecialSymbol(zone(), AsmTyper::kFFI); AsmTyper::VariableInfo::ForSpecialSymbol(zone_, AsmTyper::kFFI);
CHECK(typer_->AddGlobal(var, var_info)); CHECK(typer_->AddGlobal(var, var_info));
return this; return this;
} }
...@@ -305,7 +305,7 @@ class AsmTyperHarnessBuilder { ...@@ -305,7 +305,7 @@ class AsmTyperHarnessBuilder {
} }
bool ValidateAllStatements(FunctionDeclaration* fun_decl) { bool ValidateAllStatements(FunctionDeclaration* fun_decl) {
AsmTyper::FlattenedStatements iter(zone(), fun_decl->fun()->body()); AsmTyper::FlattenedStatements iter(zone_, fun_decl->fun()->body());
while (auto* curr = iter.Next()) { while (auto* curr = iter.Next()) {
if (typer_->ValidateStatement(curr) == AsmType::None()) { if (typer_->ValidateStatement(curr) == AsmType::None()) {
return false; return false;
...@@ -315,7 +315,7 @@ class AsmTyperHarnessBuilder { ...@@ -315,7 +315,7 @@ class AsmTyperHarnessBuilder {
} }
AsmType* ValidateExpressionStatment(FunctionDeclaration* fun_decl) { AsmType* ValidateExpressionStatment(FunctionDeclaration* fun_decl) {
AsmTyper::FlattenedStatements iter(zone(), fun_decl->fun()->body()); AsmTyper::FlattenedStatements iter(zone_, fun_decl->fun()->body());
AsmType* ret = AsmType::None(); AsmType* ret = AsmType::None();
bool last_was_expression_statement = false; bool last_was_expression_statement = false;
while (auto* curr = iter.Next()) { while (auto* curr = iter.Next()) {
...@@ -337,17 +337,15 @@ class AsmTyperHarnessBuilder { ...@@ -337,17 +337,15 @@ class AsmTyperHarnessBuilder {
return ret; return ret;
} }
Zone* zone() { return info_.zone(); }
std::string source_; std::string source_;
ValidationType validation_type_; ValidationType validation_type_;
HandleAndZoneScope handles_; HandleAndZoneScope handles_;
Zone* zone_;
Isolate* isolate_; Isolate* isolate_;
AstValueFactory ast_value_factory_;
Factory* factory_; Factory* factory_;
Handle<String> source_code_; Handle<String> source_code_;
Handle<Script> script_; Handle<Script> script_;
ParseInfo info_;
AstValueFactory ast_value_factory_;
DeclarationScope* outer_scope_; DeclarationScope* outer_scope_;
FunctionLiteral* module_; FunctionLiteral* module_;
......
...@@ -155,7 +155,8 @@ Handle<JSFunction> FunctionTester::ForMachineGraph(Graph* graph, ...@@ -155,7 +155,8 @@ Handle<JSFunction> FunctionTester::ForMachineGraph(Graph* graph,
} }
Handle<JSFunction> FunctionTester::Compile(Handle<JSFunction> function) { Handle<JSFunction> FunctionTester::Compile(Handle<JSFunction> function) {
ParseInfo parse_info(handle(function->shared())); Zone zone(function->GetIsolate()->allocator(), ZONE_NAME);
ParseInfo parse_info(&zone, handle(function->shared()));
CompilationInfo info(&parse_info, function); CompilationInfo info(&parse_info, function);
info.SetOptimizing(); info.SetOptimizing();
...@@ -184,7 +185,8 @@ Handle<JSFunction> FunctionTester::Compile(Handle<JSFunction> function) { ...@@ -184,7 +185,8 @@ Handle<JSFunction> FunctionTester::Compile(Handle<JSFunction> function) {
// Compile the given machine graph instead of the source of the function // Compile the given machine graph instead of the source of the function
// and replace the JSFunction's code with the result. // and replace the JSFunction's code with the result.
Handle<JSFunction> FunctionTester::CompileGraph(Graph* graph) { Handle<JSFunction> FunctionTester::CompileGraph(Graph* graph) {
ParseInfo parse_info(handle(function->shared())); Zone zone(function->GetIsolate()->allocator(), ZONE_NAME);
ParseInfo parse_info(&zone, handle(function->shared()));
CompilationInfo info(&parse_info, function); CompilationInfo info(&parse_info, function);
CHECK(parsing::ParseFunction(info.parse_info())); CHECK(parsing::ParseFunction(info.parse_info()));
......
...@@ -43,7 +43,7 @@ static Handle<JSFunction> Compile(const char* source) { ...@@ -43,7 +43,7 @@ static Handle<JSFunction> Compile(const char* source) {
TEST(TestLinkageCreate) { TEST(TestLinkageCreate) {
HandleAndZoneScope handles; HandleAndZoneScope handles;
Handle<JSFunction> function = Compile("a + b"); Handle<JSFunction> function = Compile("a + b");
ParseInfo parse_info(handle(function->shared())); ParseInfo parse_info(handles.main_zone(), handle(function->shared()));
CompilationInfo info(&parse_info, function); CompilationInfo info(&parse_info, function);
CallDescriptor* descriptor = Linkage::ComputeIncoming(info.zone(), &info); CallDescriptor* descriptor = Linkage::ComputeIncoming(info.zone(), &info);
CHECK(descriptor); CHECK(descriptor);
...@@ -59,7 +59,7 @@ TEST(TestLinkageJSFunctionIncoming) { ...@@ -59,7 +59,7 @@ TEST(TestLinkageJSFunctionIncoming) {
Handle<JSFunction> function = Handle<JSFunction> function =
Handle<JSFunction>::cast(v8::Utils::OpenHandle( Handle<JSFunction>::cast(v8::Utils::OpenHandle(
*v8::Local<v8::Function>::Cast(CompileRun(sources[i])))); *v8::Local<v8::Function>::Cast(CompileRun(sources[i]))));
ParseInfo parse_info(handle(function->shared())); ParseInfo parse_info(handles.main_zone(), handle(function->shared()));
CompilationInfo info(&parse_info, function); CompilationInfo info(&parse_info, function);
CallDescriptor* descriptor = Linkage::ComputeIncoming(info.zone(), &info); CallDescriptor* descriptor = Linkage::ComputeIncoming(info.zone(), &info);
CHECK(descriptor); CHECK(descriptor);
...@@ -75,7 +75,7 @@ TEST(TestLinkageJSFunctionIncoming) { ...@@ -75,7 +75,7 @@ TEST(TestLinkageJSFunctionIncoming) {
TEST(TestLinkageJSCall) { TEST(TestLinkageJSCall) {
HandleAndZoneScope handles; HandleAndZoneScope handles;
Handle<JSFunction> function = Compile("a + c"); Handle<JSFunction> function = Compile("a + c");
ParseInfo parse_info(handle(function->shared())); ParseInfo parse_info(handles.main_zone(), handle(function->shared()));
CompilationInfo info(&parse_info, function); CompilationInfo info(&parse_info, function);
for (int i = 0; i < 32; i++) { for (int i = 0; i < 32; i++) {
......
...@@ -33,7 +33,7 @@ struct TestHelper : public HandleAndZoneScope { ...@@ -33,7 +33,7 @@ struct TestHelper : public HandleAndZoneScope {
void CheckLoopAssignedCount(int expected, const char* var_name) { void CheckLoopAssignedCount(int expected, const char* var_name) {
// TODO(titzer): don't scope analyze every single time. // TODO(titzer): don't scope analyze every single time.
ParseInfo parse_info(handle(function->shared())); ParseInfo parse_info(main_zone(), handle(function->shared()));
CompilationInfo info(&parse_info, function); CompilationInfo info(&parse_info, function);
CHECK(parsing::ParseFunction(&parse_info)); CHECK(parsing::ParseFunction(&parse_info));
......
...@@ -825,7 +825,8 @@ TEST(ScopeUsesArgumentsSuperThis) { ...@@ -825,7 +825,8 @@ TEST(ScopeUsesArgumentsSuperThis) {
factory->NewStringFromUtf8(i::CStrVector(program.start())) factory->NewStringFromUtf8(i::CStrVector(program.start()))
.ToHandleChecked(); .ToHandleChecked();
i::Handle<i::Script> script = factory->NewScript(source); i::Handle<i::Script> script = factory->NewScript(source);
i::ParseInfo info(script); i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
i::ParseInfo info(&zone, script);
// The information we're checking is only produced when eager parsing. // The information we're checking is only produced when eager parsing.
info.set_allow_lazy_parsing(false); info.set_allow_lazy_parsing(false);
CHECK(i::parsing::ParseProgram(&info)); CHECK(i::parsing::ParseProgram(&info));
...@@ -881,7 +882,7 @@ static void CheckParsesToNumber(const char* source, bool with_dot) { ...@@ -881,7 +882,7 @@ static void CheckParsesToNumber(const char* source, bool with_dot) {
i::Handle<i::Script> script = factory->NewScript(source_code); i::Handle<i::Script> script = factory->NewScript(source_code);
i::ParseInfo info(script); i::ParseInfo info(handles.main_zone(), script);
i::Parser parser(&info); i::Parser parser(&info);
info.set_allow_lazy_parsing(false); info.set_allow_lazy_parsing(false);
info.set_toplevel(true); info.set_toplevel(true);
...@@ -1179,7 +1180,8 @@ TEST(ScopePositions) { ...@@ -1179,7 +1180,8 @@ TEST(ScopePositions) {
i::CStrVector(program.start())).ToHandleChecked(); i::CStrVector(program.start())).ToHandleChecked();
CHECK_EQ(source->length(), kProgramSize); CHECK_EQ(source->length(), kProgramSize);
i::Handle<i::Script> script = factory->NewScript(source); i::Handle<i::Script> script = factory->NewScript(source);
i::ParseInfo info(script); i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
i::ParseInfo info(&zone, script);
info.set_language_mode(source_data[i].language_mode); info.set_language_mode(source_data[i].language_mode);
i::parsing::ParseProgram(&info); i::parsing::ParseProgram(&info);
CHECK_NOT_NULL(info.literal()); CHECK_NOT_NULL(info.literal());
...@@ -1225,7 +1227,8 @@ TEST(DiscardFunctionBody) { ...@@ -1225,7 +1227,8 @@ TEST(DiscardFunctionBody) {
i::Handle<i::String> source_code = i::Handle<i::String> source_code =
factory->NewStringFromUtf8(i::CStrVector(source)).ToHandleChecked(); factory->NewStringFromUtf8(i::CStrVector(source)).ToHandleChecked();
i::Handle<i::Script> script = factory->NewScript(source_code); i::Handle<i::Script> script = factory->NewScript(source_code);
i::ParseInfo info(script); i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
i::ParseInfo info(&zone, script);
i::parsing::ParseProgram(&info); i::parsing::ParseProgram(&info);
function = info.literal(); function = info.literal();
CHECK_NOT_NULL(function); CHECK_NOT_NULL(function);
...@@ -1351,7 +1354,8 @@ void TestParserSyncWithFlags(i::Handle<i::String> source, ...@@ -1351,7 +1354,8 @@ void TestParserSyncWithFlags(i::Handle<i::String> source,
i::FunctionLiteral* function; i::FunctionLiteral* function;
{ {
i::Handle<i::Script> script = factory->NewScript(source); i::Handle<i::Script> script = factory->NewScript(source);
i::ParseInfo info(script); i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
i::ParseInfo info(&zone, script);
info.set_allow_lazy_parsing(flags.Contains(kAllowLazy)); info.set_allow_lazy_parsing(flags.Contains(kAllowLazy));
SetGlobalFlags(flags); SetGlobalFlags(flags);
if (is_module) info.set_module(); if (is_module) info.set_module();
...@@ -2482,7 +2486,8 @@ TEST(DontRegressPreParserDataSizes) { ...@@ -2482,7 +2486,8 @@ TEST(DontRegressPreParserDataSizes) {
i::Handle<i::String> source = i::Handle<i::String> source =
factory->NewStringFromUtf8(i::CStrVector(program)).ToHandleChecked(); factory->NewStringFromUtf8(i::CStrVector(program)).ToHandleChecked();
i::Handle<i::Script> script = factory->NewScript(source); i::Handle<i::Script> script = factory->NewScript(source);
i::ParseInfo info(script); i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
i::ParseInfo info(&zone, script);
i::ScriptData* sd = NULL; i::ScriptData* sd = NULL;
info.set_cached_data(&sd); info.set_cached_data(&sd);
info.set_compile_options(v8::ScriptCompiler::kProduceParserCache); info.set_compile_options(v8::ScriptCompiler::kProduceParserCache);
...@@ -3369,6 +3374,7 @@ TEST(InnerAssignment) { ...@@ -3369,6 +3374,7 @@ TEST(InnerAssignment) {
i::SNPrintF(program, "%s%s%s%s%s", prefix, outer, midfix, inner, i::SNPrintF(program, "%s%s%s%s%s", prefix, outer, midfix, inner,
suffix); suffix);
i::Zone zone(isolate->allocator(), ZONE_NAME);
std::unique_ptr<i::ParseInfo> info; std::unique_ptr<i::ParseInfo> info;
if (lazy) { if (lazy) {
printf("%s\n", program.start()); printf("%s\n", program.start());
...@@ -3376,7 +3382,7 @@ TEST(InnerAssignment) { ...@@ -3376,7 +3382,7 @@ TEST(InnerAssignment) {
i::Handle<i::Object> o = v8::Utils::OpenHandle(*v); i::Handle<i::Object> o = v8::Utils::OpenHandle(*v);
i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(o); i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(o);
i::Handle<i::SharedFunctionInfo> shared = i::handle(f->shared()); i::Handle<i::SharedFunctionInfo> shared = i::handle(f->shared());
info = std::unique_ptr<i::ParseInfo>(new i::ParseInfo(shared)); info = std::unique_ptr<i::ParseInfo>(new i::ParseInfo(&zone, shared));
CHECK(i::parsing::ParseFunction(info.get())); CHECK(i::parsing::ParseFunction(info.get()));
} else { } else {
i::Handle<i::String> source = i::Handle<i::String> source =
...@@ -3384,7 +3390,7 @@ TEST(InnerAssignment) { ...@@ -3384,7 +3390,7 @@ TEST(InnerAssignment) {
source->PrintOn(stdout); source->PrintOn(stdout);
printf("\n"); printf("\n");
i::Handle<i::Script> script = factory->NewScript(source); i::Handle<i::Script> script = factory->NewScript(source);
info = std::unique_ptr<i::ParseInfo>(new i::ParseInfo(script)); info = std::unique_ptr<i::ParseInfo>(new i::ParseInfo(&zone, script));
info->set_allow_lazy_parsing(false); info->set_allow_lazy_parsing(false);
CHECK(i::parsing::ParseProgram(info.get())); CHECK(i::parsing::ParseProgram(info.get()));
} }
...@@ -3483,13 +3489,14 @@ TEST(MaybeAssignedParameters) { ...@@ -3483,13 +3489,14 @@ TEST(MaybeAssignedParameters) {
i::ScopedVector<char> program(Utf8LengthHelper(source) + i::ScopedVector<char> program(Utf8LengthHelper(source) +
Utf8LengthHelper(suffix) + 1); Utf8LengthHelper(suffix) + 1);
i::SNPrintF(program, "%s%s", source, suffix); i::SNPrintF(program, "%s%s", source, suffix);
i::Zone zone(isolate->allocator(), ZONE_NAME);
std::unique_ptr<i::ParseInfo> info; std::unique_ptr<i::ParseInfo> info;
printf("%s\n", program.start()); printf("%s\n", program.start());
v8::Local<v8::Value> v = CompileRun(program.start()); v8::Local<v8::Value> v = CompileRun(program.start());
i::Handle<i::Object> o = v8::Utils::OpenHandle(*v); i::Handle<i::Object> o = v8::Utils::OpenHandle(*v);
i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(o); i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(o);
i::Handle<i::SharedFunctionInfo> shared = i::handle(f->shared()); i::Handle<i::SharedFunctionInfo> shared = i::handle(f->shared());
info = std::unique_ptr<i::ParseInfo>(new i::ParseInfo(shared)); info = std::unique_ptr<i::ParseInfo>(new i::ParseInfo(&zone, shared));
info->set_allow_lazy_parsing(allow_lazy); info->set_allow_lazy_parsing(allow_lazy);
CHECK(i::parsing::ParseFunction(info.get())); CHECK(i::parsing::ParseFunction(info.get()));
CHECK(i::Compiler::Analyze(info.get())); CHECK(i::Compiler::Analyze(info.get()));
...@@ -3534,6 +3541,7 @@ TEST(MaybeAssignedTopLevel) { ...@@ -3534,6 +3541,7 @@ TEST(MaybeAssignedTopLevel) {
i::ScopedVector<char> program(Utf8LengthHelper(prefix) + i::ScopedVector<char> program(Utf8LengthHelper(prefix) +
Utf8LengthHelper(source) + 1); Utf8LengthHelper(source) + 1);
i::SNPrintF(program, "%s%s", prefix, source); i::SNPrintF(program, "%s%s", prefix, source);
i::Zone zone(isolate->allocator(), ZONE_NAME);
i::Handle<i::String> string = i::Handle<i::String> string =
factory->InternalizeUtf8String(program.start()); factory->InternalizeUtf8String(program.start());
...@@ -3544,7 +3552,7 @@ TEST(MaybeAssignedTopLevel) { ...@@ -3544,7 +3552,7 @@ TEST(MaybeAssignedTopLevel) {
for (unsigned allow_lazy = 0; allow_lazy < 2; ++allow_lazy) { for (unsigned allow_lazy = 0; allow_lazy < 2; ++allow_lazy) {
for (unsigned module = 0; module < 2; ++module) { for (unsigned module = 0; module < 2; ++module) {
std::unique_ptr<i::ParseInfo> info; std::unique_ptr<i::ParseInfo> info;
info = std::unique_ptr<i::ParseInfo>(new i::ParseInfo(script)); info = std::unique_ptr<i::ParseInfo>(new i::ParseInfo(&zone, script));
info->set_module(module); info->set_module(module);
info->set_allow_lazy_parsing(allow_lazy); info->set_allow_lazy_parsing(allow_lazy);
...@@ -5863,7 +5871,8 @@ TEST(BasicImportExportParsing) { ...@@ -5863,7 +5871,8 @@ TEST(BasicImportExportParsing) {
// Show that parsing as a module works // Show that parsing as a module works
{ {
i::Handle<i::Script> script = factory->NewScript(source); i::Handle<i::Script> script = factory->NewScript(source);
i::ParseInfo info(script); i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
i::ParseInfo info(&zone, script);
info.set_module(); info.set_module();
if (!i::parsing::ParseProgram(&info)) { if (!i::parsing::ParseProgram(&info)) {
i::Handle<i::JSObject> exception_handle( i::Handle<i::JSObject> exception_handle(
...@@ -5887,7 +5896,8 @@ TEST(BasicImportExportParsing) { ...@@ -5887,7 +5896,8 @@ TEST(BasicImportExportParsing) {
// And that parsing a script does not. // And that parsing a script does not.
{ {
i::Handle<i::Script> script = factory->NewScript(source); i::Handle<i::Script> script = factory->NewScript(source);
i::ParseInfo info(script); i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
i::ParseInfo info(&zone, script);
CHECK(!i::parsing::ParseProgram(&info)); CHECK(!i::parsing::ParseProgram(&info));
isolate->clear_pending_exception(); isolate->clear_pending_exception();
} }
...@@ -5977,7 +5987,8 @@ TEST(ImportExportParsingErrors) { ...@@ -5977,7 +5987,8 @@ TEST(ImportExportParsingErrors) {
factory->NewStringFromAsciiChecked(kErrorSources[i]); factory->NewStringFromAsciiChecked(kErrorSources[i]);
i::Handle<i::Script> script = factory->NewScript(source); i::Handle<i::Script> script = factory->NewScript(source);
i::ParseInfo info(script); i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
i::ParseInfo info(&zone, script);
info.set_module(); info.set_module();
CHECK(!i::parsing::ParseProgram(&info)); CHECK(!i::parsing::ParseProgram(&info));
isolate->clear_pending_exception(); isolate->clear_pending_exception();
...@@ -6013,7 +6024,8 @@ TEST(ModuleTopLevelFunctionDecl) { ...@@ -6013,7 +6024,8 @@ TEST(ModuleTopLevelFunctionDecl) {
factory->NewStringFromAsciiChecked(kErrorSources[i]); factory->NewStringFromAsciiChecked(kErrorSources[i]);
i::Handle<i::Script> script = factory->NewScript(source); i::Handle<i::Script> script = factory->NewScript(source);
i::ParseInfo info(script); i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
i::ParseInfo info(&zone, script);
info.set_module(); info.set_module();
CHECK(!i::parsing::ParseProgram(&info)); CHECK(!i::parsing::ParseProgram(&info));
isolate->clear_pending_exception(); isolate->clear_pending_exception();
...@@ -6210,7 +6222,8 @@ TEST(ModuleParsingInternals) { ...@@ -6210,7 +6222,8 @@ TEST(ModuleParsingInternals) {
"export {foob};"; "export {foob};";
i::Handle<i::String> source = factory->NewStringFromAsciiChecked(kSource); i::Handle<i::String> source = factory->NewStringFromAsciiChecked(kSource);
i::Handle<i::Script> script = factory->NewScript(source); i::Handle<i::Script> script = factory->NewScript(source);
i::ParseInfo info(script); i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
i::ParseInfo info(&zone, script);
info.set_module(); info.set_module();
CHECK(i::parsing::ParseProgram(&info)); CHECK(i::parsing::ParseProgram(&info));
CHECK(i::Compiler::Analyze(&info)); CHECK(i::Compiler::Analyze(&info));
...@@ -6469,7 +6482,8 @@ void TestLanguageMode(const char* source, ...@@ -6469,7 +6482,8 @@ void TestLanguageMode(const char* source,
i::Handle<i::Script> script = i::Handle<i::Script> script =
factory->NewScript(factory->NewStringFromAsciiChecked(source)); factory->NewScript(factory->NewStringFromAsciiChecked(source));
i::ParseInfo info(script); i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
i::ParseInfo info(&zone, script);
i::parsing::ParseProgram(&info); i::parsing::ParseProgram(&info);
CHECK(info.literal() != NULL); CHECK(info.literal() != NULL);
CHECK_EQ(expected_language_mode, info.literal()->language_mode()); CHECK_EQ(expected_language_mode, info.literal()->language_mode());
...@@ -8915,7 +8929,8 @@ TEST(NoPessimisticContextAllocation) { ...@@ -8915,7 +8929,8 @@ TEST(NoPessimisticContextAllocation) {
printf("\n"); printf("\n");
i::Handle<i::Script> script = factory->NewScript(source); i::Handle<i::Script> script = factory->NewScript(source);
i::ParseInfo info(script); i::Zone zone(isolate->allocator(), ZONE_NAME);
i::ParseInfo info(&zone, script);
CHECK(i::parsing::ParseProgram(&info)); CHECK(i::parsing::ParseProgram(&info));
CHECK(i::Compiler::Analyze(&info)); CHECK(i::Compiler::Analyze(&info));
......
...@@ -35,7 +35,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { ...@@ -35,7 +35,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
v8::internal::Handle<v8::internal::Script> script = v8::internal::Handle<v8::internal::Script> script =
factory->NewScript(source.ToHandleChecked()); factory->NewScript(source.ToHandleChecked());
v8::internal::ParseInfo info(script); v8::internal::Zone zone(i_isolate->allocator(), ZONE_NAME);
v8::internal::ParseInfo info(&zone, script);
v8::internal::parsing::ParseProgram(&info); v8::internal::parsing::ParseProgram(&info);
isolate->RequestGarbageCollectionForTesting( isolate->RequestGarbageCollectionForTesting(
v8::Isolate::kFullGarbageCollection); v8::Isolate::kFullGarbageCollection);
......
...@@ -94,7 +94,8 @@ std::pair<v8::base::TimeDelta, v8::base::TimeDelta> RunBaselineParser( ...@@ -94,7 +94,8 @@ std::pair<v8::base::TimeDelta, v8::base::TimeDelta> RunBaselineParser(
i::ScriptData* cached_data_impl = NULL; i::ScriptData* cached_data_impl = NULL;
// First round of parsing (produce data to cache). // First round of parsing (produce data to cache).
{ {
ParseInfo info(script); Zone zone(reinterpret_cast<i::Isolate*>(isolate)->allocator(), ZONE_NAME);
ParseInfo info(&zone, script);
info.set_cached_data(&cached_data_impl); info.set_cached_data(&cached_data_impl);
info.set_compile_options(v8::ScriptCompiler::kProduceParserCache); info.set_compile_options(v8::ScriptCompiler::kProduceParserCache);
v8::base::ElapsedTimer timer; v8::base::ElapsedTimer timer;
...@@ -108,7 +109,8 @@ std::pair<v8::base::TimeDelta, v8::base::TimeDelta> RunBaselineParser( ...@@ -108,7 +109,8 @@ std::pair<v8::base::TimeDelta, v8::base::TimeDelta> RunBaselineParser(
} }
// Second round of parsing (consume cached data). // Second round of parsing (consume cached data).
{ {
ParseInfo info(script); Zone zone(reinterpret_cast<i::Isolate*>(isolate)->allocator(), ZONE_NAME);
ParseInfo info(&zone, script);
info.set_cached_data(&cached_data_impl); info.set_cached_data(&cached_data_impl);
info.set_compile_options(v8::ScriptCompiler::kConsumeParserCache); info.set_compile_options(v8::ScriptCompiler::kConsumeParserCache);
v8::base::ElapsedTimer timer; v8::base::ElapsedTimer timer;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment