Commit e4d5a446 authored by rmcilroy's avatar rmcilroy Committed by Commit bot

[Interpreter] Pass CompileInfo to BytecodeGenerator's constructor.

BUG=v8:4280
LOG=N

Review URL: https://codereview.chromium.org/1902013002

Cr-Commit-Position: refs/heads/master@{#35622}
parent 3e5f45b6
...@@ -554,41 +554,35 @@ class BytecodeGenerator::RegisterResultScope final ...@@ -554,41 +554,35 @@ class BytecodeGenerator::RegisterResultScope final
Register result_register_; Register result_register_;
}; };
BytecodeGenerator::BytecodeGenerator(Isolate* isolate, Zone* zone) BytecodeGenerator::BytecodeGenerator(CompilationInfo* info)
: isolate_(isolate), : isolate_(info->isolate()),
zone_(zone), zone_(info->zone()),
builder_(nullptr), builder_(new (zone()) BytecodeArrayBuilder(
info_(nullptr), info->isolate(), info->zone(), info->num_parameters_including_this(),
scope_(nullptr), info->scope()->MaxNestedContextChainLength(),
globals_(0, zone), info->scope()->num_stack_slots(), info->literal())),
info_(info),
scope_(info->scope()),
globals_(0, info->zone()),
execution_control_(nullptr), execution_control_(nullptr),
execution_context_(nullptr), execution_context_(nullptr),
execution_result_(nullptr), execution_result_(nullptr),
register_allocator_(nullptr), register_allocator_(nullptr),
generator_resume_points_(0, zone), generator_resume_points_(info->literal()->yield_count(), info->zone()),
try_catch_nesting_level_(0), try_catch_nesting_level_(0),
try_finally_nesting_level_(0), try_finally_nesting_level_(0),
generator_yields_seen_(0) { generator_yields_seen_(0) {
InitializeAstVisitor(isolate); InitializeAstVisitor(isolate());
} }
Handle<BytecodeArray> BytecodeGenerator::MakeBytecode(CompilationInfo* info) { Handle<BytecodeArray> BytecodeGenerator::MakeBytecode() {
set_info(info);
set_scope(info->scope());
// Initialize bytecode array builder.
set_builder(new (zone()) BytecodeArrayBuilder(
isolate(), zone(), info->num_parameters_including_this(),
scope()->MaxNestedContextChainLength(), scope()->num_stack_slots(),
info->literal()));
// Initialize the incoming context. // Initialize the incoming context.
ContextScope incoming_context(this, scope(), false); ContextScope incoming_context(this, scope(), false);
// Initialize control scope. // Initialize control scope.
ControlScopeForTopLevel control(this); ControlScopeForTopLevel control(this);
if (IsGeneratorFunction(info->literal()->kind())) { if (IsGeneratorFunction(info()->literal()->kind())) {
VisitGeneratorPrologue(); VisitGeneratorPrologue();
} }
...@@ -604,8 +598,6 @@ Handle<BytecodeArray> BytecodeGenerator::MakeBytecode(CompilationInfo* info) { ...@@ -604,8 +598,6 @@ Handle<BytecodeArray> BytecodeGenerator::MakeBytecode(CompilationInfo* info) {
} }
builder()->EnsureReturn(); builder()->EnsureReturn();
set_scope(nullptr);
set_info(nullptr);
return builder()->ToBytecodeArray(); return builder()->ToBytecodeArray();
} }
...@@ -641,9 +633,6 @@ void BytecodeGenerator::MakeBytecodeBody() { ...@@ -641,9 +633,6 @@ void BytecodeGenerator::MakeBytecodeBody() {
} }
void BytecodeGenerator::VisitGeneratorPrologue() { void BytecodeGenerator::VisitGeneratorPrologue() {
generator_resume_points_.clear();
generator_resume_points_.resize(info()->literal()->yield_count());
BytecodeLabel regular_call; BytecodeLabel regular_call;
builder() builder()
->LoadAccumulatorWithRegister(Register::new_target()) ->LoadAccumulatorWithRegister(Register::new_target())
......
...@@ -17,9 +17,9 @@ class LoopBuilder; ...@@ -17,9 +17,9 @@ class LoopBuilder;
class BytecodeGenerator final : public AstVisitor { class BytecodeGenerator final : public AstVisitor {
public: public:
BytecodeGenerator(Isolate* isolate, Zone* zone); explicit BytecodeGenerator(CompilationInfo* info);
Handle<BytecodeArray> MakeBytecode(CompilationInfo* info); Handle<BytecodeArray> MakeBytecode();
#define DECLARE_VISIT(type) void Visit##type(type* node) override; #define DECLARE_VISIT(type) void Visit##type(type* node) override;
AST_NODE_LIST(DECLARE_VISIT) AST_NODE_LIST(DECLARE_VISIT)
...@@ -161,16 +161,11 @@ class BytecodeGenerator final : public AstVisitor { ...@@ -161,16 +161,11 @@ class BytecodeGenerator final : public AstVisitor {
template <size_t N> template <size_t N>
void InitializeWithConsecutiveRegisters(Register (&registers)[N]); void InitializeWithConsecutiveRegisters(Register (&registers)[N]);
inline void set_builder(BytecodeArrayBuilder* builder) { builder_ = builder; }
inline BytecodeArrayBuilder* builder() const { return builder_; } inline BytecodeArrayBuilder* builder() const { return builder_; }
inline Isolate* isolate() const { return isolate_; } inline Isolate* isolate() const { return isolate_; }
inline Zone* zone() const { return zone_; } inline Zone* zone() const { return zone_; }
inline Scope* scope() const { return scope_; } inline Scope* scope() const { return scope_; }
inline void set_scope(Scope* scope) { scope_ = scope; }
inline CompilationInfo* info() const { return info_; } inline CompilationInfo* info() const { return info_; }
inline void set_info(CompilationInfo* info) { info_ = info; }
inline ControlScope* execution_control() const { return execution_control_; } inline ControlScope* execution_control() const { return execution_control_; }
inline void set_execution_control(ControlScope* scope) { inline void set_execution_control(ControlScope* scope) {
......
...@@ -149,8 +149,8 @@ bool Interpreter::MakeBytecode(CompilationInfo* info) { ...@@ -149,8 +149,8 @@ bool Interpreter::MakeBytecode(CompilationInfo* info) {
} }
#endif // DEBUG #endif // DEBUG
BytecodeGenerator generator(info->isolate(), info->zone()); BytecodeGenerator generator(info);
Handle<BytecodeArray> bytecodes = generator.MakeBytecode(info); Handle<BytecodeArray> bytecodes = generator.MakeBytecode();
if (generator.HasStackOverflow()) return false; if (generator.HasStackOverflow()) return false;
......
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