Commit b208c459 authored by Yang Guo's avatar Yang Guo Committed by Commit Bot

[ignition] use std::vector for eager inner literals list

The lifetime of this list is fairly simple to reason about. There
is no need to allocate it into the zone.

R=leszeks@chromium.org

Change-Id: I9c918f7e5fddc24c943206aa82be859f27acc2fe
Reviewed-on: https://chromium-review.googlesource.com/c/1325610
Commit-Queue: Yang Guo <yangguo@chromium.org>
Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57359}
parent 36e1e460
......@@ -6,7 +6,6 @@
#include <algorithm>
#include <memory>
#include <queue>
#include "src/api-inl.h"
#include "src/asmjs/asm-js.h"
......@@ -452,7 +451,7 @@ std::unique_ptr<UnoptimizedCompilationJob> ExecuteUnoptimizedCompileJobs(
// with a validation error or another error that could be solve by falling
// through to standard unoptimized compile.
}
ZoneVector<FunctionLiteral*> eager_inner_literals(0, parse_info->zone());
std::vector<FunctionLiteral*> eager_inner_literals;
std::unique_ptr<UnoptimizedCompilationJob> job(
interpreter::Interpreter::NewCompilationJob(
parse_info, literal, allocator, &eager_inner_literals));
......@@ -512,12 +511,12 @@ MaybeHandle<SharedFunctionInfo> GenerateUnoptimizedCodeForToplevel(
isolate->factory()->NewSharedFunctionInfoForLiteral(parse_info->literal(),
script, true);
std::queue<FunctionLiteral*> queue;
queue.push(parse_info->literal());
std::vector<FunctionLiteral*> functions_to_compile;
functions_to_compile.push_back(parse_info->literal());
while (!queue.empty()) {
FunctionLiteral* literal = queue.front();
queue.pop();
while (!functions_to_compile.empty()) {
FunctionLiteral* literal = functions_to_compile.back();
functions_to_compile.pop_back();
Handle<SharedFunctionInfo> shared_info =
Compiler::GetSharedFunctionInfo(literal, script, isolate);
// TODO(rmcilroy): Fix this and DCHECK !is_compiled() once Full-Codegen dies
......@@ -538,23 +537,14 @@ MaybeHandle<SharedFunctionInfo> GenerateUnoptimizedCodeForToplevel(
// through to standard unoptimized compile.
}
ZoneVector<FunctionLiteral*> eager_inner_literals(0, parse_info->zone());
{
std::unique_ptr<UnoptimizedCompilationJob> job(
interpreter::Interpreter::NewCompilationJob(
parse_info, literal, allocator, &eager_inner_literals));
std::unique_ptr<UnoptimizedCompilationJob> job(
interpreter::Interpreter::NewCompilationJob(
parse_info, literal, allocator, &functions_to_compile));
if (job->ExecuteJob() == CompilationJob::FAILED ||
FinalizeUnoptimizedCompilationJob(job.get(), shared_info, isolate) ==
CompilationJob::FAILED) {
return MaybeHandle<SharedFunctionInfo>();
}
}
// Add eagerly compiled inner literals to the queue. The compilation order
// is not important, so breadth-first traversal is not a requirement.
for (FunctionLiteral* inner_literal : eager_inner_literals) {
queue.push(inner_literal);
if (job->ExecuteJob() == CompilationJob::FAILED ||
FinalizeUnoptimizedCompilationJob(job.get(), shared_info, isolate) ==
CompilationJob::FAILED) {
return MaybeHandle<SharedFunctionInfo>();
}
}
......
......@@ -873,7 +873,7 @@ class BytecodeGenerator::IteratorRecord final {
static bool IsInEagerLiterals(
FunctionLiteral* literal,
const ZoneVector<FunctionLiteral*>& eager_literals) {
const std::vector<FunctionLiteral*>& eager_literals) {
for (FunctionLiteral* eager_literal : eager_literals) {
if (literal == eager_literal) return true;
}
......@@ -885,7 +885,7 @@ static bool IsInEagerLiterals(
BytecodeGenerator::BytecodeGenerator(
UnoptimizedCompilationInfo* info,
const AstStringConstants* ast_string_constants,
ZoneVector<FunctionLiteral*>* eager_inner_literals)
std::vector<FunctionLiteral*>* eager_inner_literals)
: zone_(info->zone()),
builder_(zone(), info->num_parameters_including_this(),
info->scope()->num_stack_slots(), info->feedback_vector_spec(),
......
......@@ -32,7 +32,7 @@ class BytecodeGenerator final : public AstVisitor<BytecodeGenerator> {
explicit BytecodeGenerator(
UnoptimizedCompilationInfo* info,
const AstStringConstants* ast_string_constants,
ZoneVector<FunctionLiteral*>* eager_inner_literals);
std::vector<FunctionLiteral*>* eager_inner_literals);
void GenerateBytecode(uintptr_t stack_limit);
Handle<BytecodeArray> FinalizeBytecode(Isolate* isolate,
......@@ -353,7 +353,7 @@ class BytecodeGenerator final : public AstVisitor<BytecodeGenerator> {
Scope* current_scope_;
// External vector of literals to be eagerly compiled.
ZoneVector<FunctionLiteral*>* eager_inner_literals_;
std::vector<FunctionLiteral*>* eager_inner_literals_;
FeedbackSlotCache* feedback_slot_cache_;
......
......@@ -30,9 +30,10 @@ namespace interpreter {
class InterpreterCompilationJob final : public UnoptimizedCompilationJob {
public:
InterpreterCompilationJob(ParseInfo* parse_info, FunctionLiteral* literal,
AccountingAllocator* allocator,
ZoneVector<FunctionLiteral*>* eager_inner_literals);
InterpreterCompilationJob(
ParseInfo* parse_info, FunctionLiteral* literal,
AccountingAllocator* allocator,
std::vector<FunctionLiteral*>* eager_inner_literals);
protected:
Status ExecuteJobImpl() final;
......@@ -169,7 +170,7 @@ bool ShouldPrintBytecode(Handle<SharedFunctionInfo> shared) {
InterpreterCompilationJob::InterpreterCompilationJob(
ParseInfo* parse_info, FunctionLiteral* literal,
AccountingAllocator* allocator,
ZoneVector<FunctionLiteral*>* eager_inner_literals)
std::vector<FunctionLiteral*>* eager_inner_literals)
: UnoptimizedCompilationJob(parse_info->stack_limit(), parse_info,
&compilation_info_),
zone_(allocator, ZONE_NAME),
......@@ -229,7 +230,7 @@ InterpreterCompilationJob::Status InterpreterCompilationJob::FinalizeJobImpl(
UnoptimizedCompilationJob* Interpreter::NewCompilationJob(
ParseInfo* parse_info, FunctionLiteral* literal,
AccountingAllocator* allocator,
ZoneVector<FunctionLiteral*>* eager_inner_literals) {
std::vector<FunctionLiteral*>* eager_inner_literals) {
return new InterpreterCompilationJob(parse_info, literal, allocator,
eager_inner_literals);
}
......
......@@ -46,7 +46,7 @@ class Interpreter {
static UnoptimizedCompilationJob* NewCompilationJob(
ParseInfo* parse_info, FunctionLiteral* literal,
AccountingAllocator* allocator,
ZoneVector<FunctionLiteral*>* eager_inner_literals);
std::vector<FunctionLiteral*>* eager_inner_literals);
// If the bytecode handler for |bytecode| and |operand_scale| has not yet
// been loaded, deserialize it. Then return the handler.
......
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