Skip to content

Commit

Permalink
Merged: [Interpreter] Add check that local registers are valid.
Browse files Browse the repository at this point in the history
Revision: a4c6126

BUG=chromium:706234
LOG=N
NOTRY=true
NOPRESUBMIT=true
NOTREECHECKS=true

Change-Id: I7bcdc5788373be211c5c563dd974627eedd06719
Reviewed-on: https://chromium-review.googlesource.com/472629
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/branch-heads/5.8@{crosswalk-project#53}
Cr-Branched-From: eda659c-refs/heads/5.8.283@{crosswalk-project#1}
Cr-Branched-From: 4310cd0-refs/heads/master@{#43429}
  • Loading branch information
rmcilroy committed Apr 10, 2017
1 parent 506e9c7 commit 4e9adf7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
6 changes: 6 additions & 0 deletions src/interpreter/bytecode-array-builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ Register BytecodeArrayBuilder::Parameter(int parameter_index) const {
return Register::FromParameterIndex(parameter_index, parameter_count());
}

Register BytecodeArrayBuilder::Local(int index) const {
// TODO(marja): Make a DCHECK once crbug.com/706234 is fixed.
CHECK_LT(index, locals_count());
return Register(index);
}

Handle<BytecodeArray> BytecodeArrayBuilder::ToBytecodeArray(Isolate* isolate) {
DCHECK(return_seen_in_block_);
DCHECK(!bytecode_generated_);
Expand Down
1 change: 1 addition & 0 deletions src/interpreter/bytecode-array-builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class V8_EXPORT_PRIVATE BytecodeArrayBuilder final
return register_allocator()->maximum_register_count();
}

Register Local(int index) const;
Register Parameter(int parameter_index) const;

// Constant loads to accumulator.
Expand Down
8 changes: 4 additions & 4 deletions src/interpreter/bytecode-generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@ void BytecodeGenerator::VisitVariableDeclaration(VariableDeclaration* decl) {
}
case VariableLocation::LOCAL:
if (variable->binding_needs_init()) {
Register destination(variable->index());
Register destination(builder()->Local(variable->index()));
builder()->LoadTheHole().StoreAccumulatorInRegister(destination);
}
break;
Expand Down Expand Up @@ -1918,7 +1918,7 @@ void BytecodeGenerator::BuildVariableLoad(Variable* variable, FeedbackSlot slot,
TypeofMode typeof_mode) {
switch (variable->location()) {
case VariableLocation::LOCAL: {
Register source(Register(variable->index()));
Register source(builder()->Local(variable->index()));
// We need to load the variable into the accumulator, even when in a
// VisitForRegisterScope, in order to avoid register aliasing if
// subsequent expressions assign to the same variable.
Expand Down Expand Up @@ -2112,9 +2112,9 @@ void BytecodeGenerator::BuildVariableAssignment(Variable* variable,
case VariableLocation::LOCAL: {
Register destination;
if (VariableLocation::PARAMETER == variable->location()) {
destination = Register(builder()->Parameter(variable->index() + 1));
destination = builder()->Parameter(variable->index() + 1);
} else {
destination = Register(variable->index());
destination = builder()->Local(variable->index());
}

if (hole_check_mode == HoleCheckMode::kRequired) {
Expand Down

0 comments on commit 4e9adf7

Please sign in to comment.