Commit 5595d357 authored by neis's avatar neis Committed by Commit bot

[ignition] Reactivate check for jumps to unbound targets.

- Move the check from the BytecodeArrayBuilder destructor, which doesn't get
  called, to the ToBytecodeArray function.
- Remove the now empty destructor.
- For generators, bind unused resume point labels somewhere.

R=rmcilroy@chromium.org
BUG=

Review-Url: https://codereview.chromium.org/1924093005
Cr-Commit-Position: refs/heads/master@{#35862}
parent e045a066
......@@ -121,8 +121,6 @@ BytecodeArrayBuilder::BytecodeArrayBuilder(Isolate* isolate, Zone* zone,
source_position_table_builder()));
}
BytecodeArrayBuilder::~BytecodeArrayBuilder() { DCHECK_EQ(0, unbound_jumps_); }
Register BytecodeArrayBuilder::first_context_register() const {
DCHECK_GT(context_register_count_, 0);
return Register(local_register_count_);
......@@ -147,6 +145,7 @@ bool BytecodeArrayBuilder::RegisterIsParameterOrLocal(Register reg) const {
Handle<BytecodeArray> BytecodeArrayBuilder::ToBytecodeArray() {
DCHECK_EQ(0, unbound_jumps_);
DCHECK_EQ(bytecode_generated_, false);
DCHECK(exit_seen_in_block_);
......
......@@ -28,7 +28,6 @@ class BytecodeArrayBuilder final : public ZoneObject {
BytecodeArrayBuilder(Isolate* isolate, Zone* zone, int parameter_count,
int context_count, int locals_count,
FunctionLiteral* literal = nullptr);
~BytecodeArrayBuilder();
Handle<BytecodeArray> ToBytecodeArray();
......
......@@ -601,6 +601,14 @@ Handle<BytecodeArray> BytecodeGenerator::MakeBytecode() {
MakeBytecodeBody();
}
// In generator functions, we may not have visited every yield in the AST
// since we skip some obviously dead code. Hence the generated bytecode may
// contain jumps to unbound labels (resume points that will never be used).
// We bind these now.
for (auto& label : generator_resume_points_) {
if (!label.is_bound()) builder()->Bind(&label);
}
builder()->EnsureReturn();
return builder()->ToBytecodeArray();
}
......
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