Commit a9af61d0 authored by oth's avatar oth Committed by Commit bot

[interpreter] Ensure optimizations preserve source positions.

The optimization stages in the bytecode generation pipeline must
preserve source position information. Failure to preserve
source position information could result in single stepping
in the debugger misbehaving or mis-reporting in exception stack traces.

This change adds tests intended to check optimizations do not damage
source position info.

BUG=v8:4280
LOG=N

Review-Url: https://codereview.chromium.org/2042633002
Cr-Commit-Position: refs/heads/master@{#36855}
parent 172ddf42
......@@ -173,6 +173,7 @@ namespace {
void TransformLdaStarToLdrLdar(Bytecode new_bytecode, BytecodeNode* const last,
BytecodeNode* const current) {
DCHECK_EQ(current->bytecode(), Bytecode::kStar);
//
// An example transformation here would be:
//
......@@ -186,20 +187,17 @@ void TransformLdaStarToLdrLdar(Bytecode new_bytecode, BytecodeNode* const last,
last->Transform(new_bytecode, current->operand(0), current->operand_scale());
current->set_bytecode(Bytecode::kLdar, current->operand(0),
current->operand_scale());
// If there was a source position on |current| transfer it to the
// updated |last| to maintain the debugger's causal view. ie. if an
// expression position LdrGlobal is the bytecode that could throw
// and if a statement position it needs to be placed before the
// store to R occurs.
last->source_info().Update(current->source_info());
current->source_info().set_invalid();
}
} // namespace
bool BytecodePeepholeOptimizer::ChangeLdaToLdr(BytecodeNode* const current) {
if (current->bytecode() == Bytecode::kStar) {
bool BytecodePeepholeOptimizer::TransformLastAndCurrentBytecodes(
BytecodeNode* const current) {
if (current->bytecode() == Bytecode::kStar &&
!current->source_info().is_statement()) {
// Note: If the Star is tagged with a statement position, we can't
// perform this transform as the store to the register will
// have the wrong ordering for stepping in the debugger.
switch (last_.bytecode()) {
case Bytecode::kLdaNamedProperty:
TransformLdaStarToLdrLdar(Bytecode::kLdrNamedProperty, &last_, current);
......@@ -252,10 +250,10 @@ bool BytecodePeepholeOptimizer::RemoveToBooleanFromLogicalNot(
return can_remove;
}
bool BytecodePeepholeOptimizer::TransformLastAndCurrentBytecodes(
bool BytecodePeepholeOptimizer::TransformCurrentBytecode(
BytecodeNode* const current) {
return RemoveToBooleanFromJump(current) ||
RemoveToBooleanFromLogicalNot(current) || ChangeLdaToLdr(current);
RemoveToBooleanFromLogicalNot(current);
}
bool BytecodePeepholeOptimizer::CanElideLast(
......@@ -283,7 +281,8 @@ bool BytecodePeepholeOptimizer::CanElideLast(
BytecodeNode* BytecodePeepholeOptimizer::Optimize(BytecodeNode* current) {
TryToRemoveLastExpressionPosition(current);
if (TransformLastAndCurrentBytecodes(current)) {
if (TransformCurrentBytecode(current) ||
TransformLastAndCurrentBytecodes(current)) {
return current;
}
......
......@@ -37,6 +37,7 @@ class BytecodePeepholeOptimizer final : public BytecodePipelineStage,
void Flush();
void TryToRemoveLastExpressionPosition(const BytecodeNode* const current);
bool TransformCurrentBytecode(BytecodeNode* const current);
bool TransformLastAndCurrentBytecodes(BytecodeNode* const current);
bool CanElideCurrent(const BytecodeNode* const current) const;
bool CanElideLast(const BytecodeNode* const current) const;
......@@ -46,7 +47,6 @@ class BytecodePeepholeOptimizer final : public BytecodePipelineStage,
// Simple substitution methods.
bool RemoveToBooleanFromJump(BytecodeNode* const current);
bool RemoveToBooleanFromLogicalNot(BytecodeNode* const current);
bool ChangeLdaToLdr(BytecodeNode* const current);
void InvalidateLast();
bool LastIsValid() const;
......
......@@ -107,7 +107,6 @@ Bytecode Bytecodes::FromByte(uint8_t value) {
return bytecode;
}
// static
Bytecode Bytecodes::GetDebugBreak(Bytecode bytecode) {
DCHECK(!IsDebugBreak(bytecode));
......@@ -140,7 +139,6 @@ int Bytecodes::Size(Bytecode bytecode, OperandScale operand_scale) {
return size;
}
// static
size_t Bytecodes::ReturnCount(Bytecode bytecode) {
return bytecode == Bytecode::kReturn ? 1 : 0;
......@@ -160,7 +158,6 @@ int Bytecodes::NumberOfOperands(Bytecode bytecode) {
return 0;
}
// static
int Bytecodes::NumberOfRegisterOperands(Bytecode bytecode) {
DCHECK(bytecode <= Bytecode::kLast);
......@@ -276,6 +273,34 @@ bool Bytecodes::IsAccumulatorLoadWithoutEffects(Bytecode bytecode) {
}
}
// static
bool Bytecodes::IsJumpWithoutEffects(Bytecode bytecode) {
return IsJump(bytecode) && !IsJumpIfToBoolean(bytecode);
}
// static
bool Bytecodes::IsRegisterLoadWithoutEffects(Bytecode bytecode) {
switch (bytecode) {
case Bytecode::kMov:
case Bytecode::kPopContext:
case Bytecode::kPushContext:
case Bytecode::kStar:
case Bytecode::kLdrUndefined:
return true;
default:
return false;
}
}
// static
bool Bytecodes::IsWithoutExternalSideEffects(Bytecode bytecode) {
// These bytecodes only manipulate interpreter frame state and will
// never throw.
return (IsAccumulatorLoadWithoutEffects(bytecode) ||
IsRegisterLoadWithoutEffects(bytecode) ||
bytecode == Bytecode::kNop || IsJumpWithoutEffects(bytecode));
}
// static
OperandType Bytecodes::GetOperandType(Bytecode bytecode, int i) {
DCHECK_LE(bytecode, Bytecode::kLast);
......@@ -487,15 +512,6 @@ bool Bytecodes::IsPrefixScalingBytecode(Bytecode bytecode) {
}
}
// static
bool Bytecodes::IsWithoutExternalSideEffects(Bytecode bytecode) {
// These bytecodes only manipulate interpreter frame state and will
// never throw.
return (IsAccumulatorLoadWithoutEffects(bytecode) || IsLdarOrStar(bytecode) ||
bytecode == Bytecode::kMov || bytecode == Bytecode::kNop ||
IsJump(bytecode));
}
// static
bool Bytecodes::IsJumpOrReturn(Bytecode bytecode) {
return bytecode == Bytecode::kReturn || IsJump(bytecode);
......
......@@ -495,10 +495,22 @@ class Bytecodes {
// Return true if |bytecode| writes the accumulator with a boolean value.
static bool WritesBooleanToAccumulator(Bytecode bytecode);
// Return true if |bytecode| is an accumulator load bytecode,
// Return true if |bytecode| is an accumulator load without effects,
// e.g. LdaConstant, LdaTrue, Ldar.
static bool IsAccumulatorLoadWithoutEffects(Bytecode bytecode);
// Return true if |bytecode| is a jump without effects,
// e.g. any jump excluding those that include type coercion like
// JumpIfTrueToBoolean.
static bool IsJumpWithoutEffects(Bytecode bytecode);
// Return true if |bytecode| is a register load without effects,
// e.g. Mov, Star, LdrUndefined.
static bool IsRegisterLoadWithoutEffects(Bytecode bytecode);
// Returns true if |bytecode| has no effects.
static bool IsWithoutExternalSideEffects(Bytecode bytecode);
// Returns the i-th operand of |bytecode|.
static OperandType GetOperandType(Bytecode bytecode, int i);
......@@ -588,10 +600,6 @@ class Bytecodes {
// Returns true if the bytecode is a scaling prefix bytecode.
static bool IsPrefixScalingBytecode(Bytecode bytecode);
// Returns true if the bytecode has no effects outside the current
// interpreter frame.
static bool IsWithoutExternalSideEffects(Bytecode bytecode);
// Returns true if |operand_type| is any type of register operand.
static bool IsRegisterOperandType(OperandType operand_type);
......
......@@ -72,9 +72,12 @@ executable("cctest") {
"interpreter/bytecode-expectations-printer.cc",
"interpreter/bytecode-expectations-printer.h",
"interpreter/interpreter-tester.cc",
"interpreter/source-position-matcher.cc",
"interpreter/source-position-matcher.h",
"interpreter/test-bytecode-generator.cc",
"interpreter/test-interpreter-intrinsics.cc",
"interpreter/test-interpreter.cc",
"interpreter/test-source-positions.cc",
"libsampler/test-sampler.cc",
"print-extension.cc",
"profiler-extension.cc",
......
......@@ -91,9 +91,12 @@
'expression-type-collector.cc',
'expression-type-collector.h',
'interpreter/interpreter-tester.cc',
'interpreter/source-position-matcher.cc',
'interpreter/source-position-matcher.h',
'interpreter/test-bytecode-generator.cc',
'interpreter/test-interpreter.cc',
'interpreter/test-interpreter-intrinsics.cc',
'interpreter/test-source-positions.cc',
'interpreter/bytecode-expectations-printer.cc',
'interpreter/bytecode-expectations-printer.h',
'gay-fixed.cc',
......
......@@ -109,7 +109,7 @@ bytecodes: [
B(Star), R(3),
B(LdaSmi), U8(1),
B(Sub), R(3),
/* 56 E> */ B(LdrUndefined), R(1),
B(LdrUndefined), R(1),
B(Ldar), R(1),
/* 74 S> */ B(Nop),
/* 84 S> */ B(Return),
......
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "test/cctest/interpreter/source-position-matcher.h"
#include "src/objects-inl.h"
#include "src/objects.h"
namespace v8 {
namespace internal {
namespace interpreter {
// Comparer for PositionTableEntry instances.
struct PositionTableEntryComparer {
bool operator()(const PositionTableEntry& lhs,
const PositionTableEntry& rhs) {
int lhs_type_score = type_score(lhs);
int rhs_type_score = type_score(rhs);
if (lhs_type_score == rhs_type_score) {
return lhs.source_position < rhs.source_position;
} else {
return lhs_type_score < rhs_type_score;
}
}
int type_score(const PositionTableEntry& entry) {
return entry.is_statement ? 1 : 0;
}
};
//
// The principles for comparing source positions in bytecode arrays
// are:
//
// 1. The number of statement positions must be the same in both.
//
// 2. Statement positions may be moved provide they do not affect the
// debuggers causal view of the v8 heap and local state. This means
// statement positions may be moved when their initial position is
// on bytecodes that manipulate the accumulator and temporary
// registers.
//
// 3. When duplicate expression positions are present, either may
// be dropped.
//
// 4. Expression positions may be applied to later bytecodes in the
// bytecode array if the current bytecode does not throw.
//
// 5. Expression positions may be dropped when they are applied to
// bytecodes that manipulate local frame state and immediately
// proceeded by another source position.
//
// 6. The relative ordering of source positions must be preserved.
//
bool SourcePositionMatcher::Match(Handle<BytecodeArray> original_bytecode,
Handle<BytecodeArray> optimized_bytecode) {
SourcePositionTableIterator original(
original_bytecode->source_position_table());
SourcePositionTableIterator optimized(
optimized_bytecode->source_position_table());
int last_original_bytecode_offset = 0;
int last_optimized_bytecode_offset = 0;
// Ordered lists of expression positions immediately before the
// latest statements in each bytecode array.
std::vector<PositionTableEntry> original_expression_entries;
std::vector<PositionTableEntry> optimized_expression_entries;
while (true) {
MoveToNextStatement(&original, &original_expression_entries);
MoveToNextStatement(&optimized, &optimized_expression_entries);
if (original.done() && optimized.done()) {
return true;
} else if (original.done()) {
return false;
} else if (optimized.done()) {
return false;
}
if (HasNewExpressionPositionsInOptimized(&original_expression_entries,
&optimized_expression_entries)) {
return false;
}
StripUnneededExpressionPositions(original_bytecode,
&original_expression_entries,
original.bytecode_offset());
StripUnneededExpressionPositions(optimized_bytecode,
&optimized_expression_entries,
optimized.bytecode_offset());
if (!CompareExpressionPositions(&original_expression_entries,
&optimized_expression_entries)) {
// Message logged in CompareExpressionPositions().
return false;
}
// Check original and optimized have matching source positions.
if (original.source_position() != optimized.source_position()) {
return false;
}
if (original.bytecode_offset() < last_original_bytecode_offset) {
return false;
}
last_original_bytecode_offset = original.bytecode_offset();
if (optimized.bytecode_offset() < last_optimized_bytecode_offset) {
return false;
}
last_optimized_bytecode_offset = optimized.bytecode_offset();
// TODO(oth): Can we compare statement positions are semantically
// equivalent? e.g. before a bytecode that has debugger observable
// effects. This is likely non-trivial.
}
return true;
}
bool SourcePositionMatcher::HasNewExpressionPositionsInOptimized(
const std::vector<PositionTableEntry>* const original_positions,
const std::vector<PositionTableEntry>* const optimized_positions) {
std::set<PositionTableEntry, PositionTableEntryComparer> original_set(
original_positions->begin(), original_positions->end());
bool retval = false;
for (auto optimized_position : *optimized_positions) {
if (original_set.find(optimized_position) == original_set.end()) {
retval = true;
}
}
return retval;
}
bool SourcePositionMatcher::CompareExpressionPositions(
const std::vector<PositionTableEntry>* const original_positions,
const std::vector<PositionTableEntry>* const optimized_positions) {
if (original_positions->size() != optimized_positions->size()) {
return false;
}
if (original_positions->size() == 0) {
return true;
}
for (size_t i = 0; i < original_positions->size(); ++i) {
PositionTableEntry original = original_positions->at(i);
PositionTableEntry optimized = original_positions->at(i);
CHECK(original.source_position > 0);
if ((original.is_statement || optimized.is_statement) ||
(original.source_position != optimized.source_position) ||
(original.source_position < 0)) {
return false;
}
}
return true;
}
void SourcePositionMatcher::StripUnneededExpressionPositions(
Handle<BytecodeArray> bytecode_array,
std::vector<PositionTableEntry>* expression_positions,
int next_statement_bytecode_offset) {
size_t j = 0;
for (size_t i = 0; i < expression_positions->size(); ++i) {
CHECK(expression_positions->at(i).source_position > 0 &&
!expression_positions->at(i).is_statement);
int bytecode_end = (i == expression_positions->size() - 1)
? next_statement_bytecode_offset
: expression_positions->at(i + 1).bytecode_offset;
if (ExpressionPositionIsNeeded(bytecode_array,
expression_positions->at(i).bytecode_offset,
bytecode_end)) {
expression_positions->at(j++) = expression_positions->at(i);
}
}
expression_positions->resize(j);
}
void SourcePositionMatcher::AdvanceBytecodeIterator(
BytecodeArrayIterator* iterator, int bytecode_offset) {
while (iterator->current_offset() != bytecode_offset) {
iterator->Advance();
}
}
bool SourcePositionMatcher::ExpressionPositionIsNeeded(
Handle<BytecodeArray> bytecode_array, int start_offset, int end_offset) {
CHECK_GT(end_offset, start_offset);
BytecodeArrayIterator iterator(bytecode_array);
AdvanceBytecodeIterator(&iterator, start_offset);
while (iterator.current_offset() != end_offset) {
if (Bytecodes::IsWithoutExternalSideEffects(iterator.current_bytecode())) {
iterator.Advance();
} else {
// Bytecode could throw so need an expression position.
return true;
}
}
return false;
}
void SourcePositionMatcher::MoveToNextStatement(
SourcePositionTableIterator* iterator,
std::vector<PositionTableEntry>* positions) {
iterator->Advance();
positions->clear();
while (!iterator->done()) {
if (iterator->is_statement()) {
break;
}
positions->push_back({iterator->bytecode_offset(),
iterator->source_position(),
iterator->is_statement()});
iterator->Advance();
}
}
} // namespace interpreter
} // namespace internal
} // namespace v8
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef TEST_CCTEST_INTERPRETER_SOURCE_POSITION_COMPARER_H_
#define TEST_CCTEST_INTERPRETER_SOURCE_POSITION_COMPARER_H_
#include "src/interpreter/bytecode-array-iterator.h"
#include "src/interpreter/source-position-table.h"
#include "src/objects.h"
#include "src/v8.h"
namespace v8 {
namespace internal {
namespace interpreter {
class SourcePositionMatcher final {
public:
bool Match(Handle<BytecodeArray> original, Handle<BytecodeArray> optimized);
private:
bool HasNewExpressionPositionsInOptimized(
const std::vector<PositionTableEntry>* const original_positions,
const std::vector<PositionTableEntry>* const optimized_positions);
bool CompareExpressionPositions(
const std::vector<PositionTableEntry>* const original_positions,
const std::vector<PositionTableEntry>* const optimized_positions);
void StripUnneededExpressionPositions(
Handle<BytecodeArray> bytecode_array,
std::vector<PositionTableEntry>* positions,
int next_statement_bytecode_offset);
bool ExpressionPositionIsNeeded(Handle<BytecodeArray> bytecode_array,
int start_offset, int end_offset);
void MoveToNextStatement(
SourcePositionTableIterator* iterator,
std::vector<PositionTableEntry>* expression_positions);
void AdvanceBytecodeIterator(BytecodeArrayIterator* iterator,
int bytecode_offset);
};
} // namespace interpreter
} // namespace internal
} // namespace v8
#endif // TEST_CCTEST_INTERPRETER_SOURCE_POSITION_COMPARER_H_
// Copyright 2015 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/v8.h"
#include "src/compiler/pipeline.h"
#include "src/handles.h"
#include "src/interpreter/bytecode-generator.h"
#include "src/interpreter/interpreter.h"
#include "src/isolate.h"
#include "src/parsing/parser.h"
#include "test/cctest/cctest.h"
#include "test/cctest/interpreter/source-position-matcher.h"
namespace v8 {
namespace internal {
namespace interpreter {
// Flags enabling optimizations that change generated bytecode array.
// Format is <command-line flag> <flag name> <bit index>
#define OPTIMIZATION_FLAGS(V) \
V(FLAG_ignition_reo, kUseReo, 0) \
V(FLAG_ignition_peephole, kUsePeephole, 1)
#define DECLARE_BIT(_, Name, BitIndex) static const int Name = 1 << BitIndex;
OPTIMIZATION_FLAGS(DECLARE_BIT)
#undef DECLARE_BIT
// Test cases source positions are checked for. Please ensure all
// combinations of flags are present here. This is done manually
// because it provides easier to comprehend failure case for humans.
#define TEST_CASES(V) \
V(UsingReo, kUseReo) \
V(UsingReoAndPeephole, kUseReo | kUsePeephole) \
V(UsingPeephole, kUsePeephole)
static const char* kTestScripts[] = {
"var x = (y = 3) + (x = y); return x + y;",
"var x = 55;\n"
"var y = x + (x = 1) + (x = 2) + (x = 3);\n"
"return y;",
"var x = 10; return x >>> 3;",
"var x = 0; return x || (1, 2, 3);",
"return a || (a, b, a, b, c = 5, 3); ",
"var a = 3; var b = 4; a = b; b = a; a = b; return a;",
"var a = 1; return [[a, 2], [a + 2]];",
"var a = 1; if (a || a < 0) { return 1; }",
"var b;"
"b = a.name;"
"b = a.name;"
"a.name = a;"
"b = a.name;"
"a.name = a;"
"return b;",
"var sum = 0;\n"
"outer: {\n"
" for (var x = 0; x < 10; ++x) {\n"
" for (var y = 0; y < 3; ++y) {\n"
" ++sum;\n"
" if (x + y == 12) { break outer; }\n"
" }\n"
" }\n"
"}\n"
"return sum;\n",
"var a = 1;"
"switch (a) {"
" case 1: return a * a + 1;"
" case 1: break;"
" case 2: return (a = 3) * a + (a = 4);"
" case 3:"
"}"
"return a;",
"for (var p of [0, 1, 2]) {}",
"var x = { 'a': 1, 'b': 2 };"
"for (x['a'] of [1,2,3]) { return x['a']; }",
"while (x == 4) {\n"
" var y = x + 1;\n"
" if (y == 2) break;\n"
" for (z['a'] of [0]) {\n"
" x += (x *= 3) + y;"
" }\n"
"}\n",
"function g(a, b) { return a.func(b + b, b); }\n"
"g(new (function Obj() { this.func = function() { return; }})(), 1)\n"};
class OptimizedBytecodeSourcePositionTester final {
public:
explicit OptimizedBytecodeSourcePositionTester(Isolate* isolate)
: isolate_(isolate) {
SaveOptimizationFlags();
saved_flag_ignition_ = FLAG_ignition;
FLAG_ignition = true;
saved_flag_always_opt_ = FLAG_always_opt;
FLAG_always_opt = false;
}
~OptimizedBytecodeSourcePositionTester() {
RestoreOptimizationFlags();
FLAG_ignition = saved_flag_ignition_;
FLAG_always_opt = saved_flag_always_opt_;
}
bool SourcePositionsMatch(int optimization_bitmap, const char* function_body,
const char* function_decl_params = "",
const char* function_args = "");
private:
Handle<BytecodeArray> MakeBytecode(int optimization_bitmap,
const char* function_body,
const char* function_decl_params,
const char* function_args);
static std::string MakeFunctionName(int optimization_bitmap);
static std::string MakeScript(const char* function_name,
const char* function_body,
const char* function_decl_params,
const char* function_args);
void SetOptimizationFlags(int optimization_bitmap);
void SaveOptimizationFlags();
void RestoreOptimizationFlags();
Isolate* isolate() const { return isolate_; }
Isolate* isolate_;
int saved_optimization_bitmap_;
bool saved_flag_ignition_;
bool saved_flag_always_opt_;
};
// static
std::string OptimizedBytecodeSourcePositionTester::MakeFunctionName(
int optimization_bitmap) {
std::ostringstream os;
os << "test_function_" << optimization_bitmap;
return os.str();
}
// static
std::string OptimizedBytecodeSourcePositionTester::MakeScript(
const char* function_name, const char* function_body,
const char* function_decl_params, const char* function_args) {
std::ostringstream os;
os << "function " << function_name << "(" << function_decl_params << ") {";
os << function_body;
os << "}";
os << function_name << "(" << function_args << ");";
return os.str();
}
Handle<BytecodeArray> OptimizedBytecodeSourcePositionTester::MakeBytecode(
int optimization_bitmap, const char* function_body,
const char* function_decl_params, const char* function_args) {
std::string function_name = MakeFunctionName(optimization_bitmap);
std::string script = MakeScript(function_name.c_str(), function_body,
function_decl_params, function_args);
SetOptimizationFlags(optimization_bitmap);
CompileRun(script.c_str());
Local<Function> api_function =
Local<Function>::Cast(CcTest::global()
->Get(CcTest::isolate()->GetCurrentContext(),
v8_str(function_name.c_str()))
.ToLocalChecked());
Handle<JSFunction> function =
Handle<JSFunction>::cast(v8::Utils::OpenHandle(*api_function));
return handle(function->shared()->bytecode_array());
}
void OptimizedBytecodeSourcePositionTester::SetOptimizationFlags(
int optimization_bitmap) {
#define SET_FLAG(V8Flag, BitName, _) \
V8Flag = (optimization_bitmap & BitName) ? true : false;
OPTIMIZATION_FLAGS(SET_FLAG)
#undef SET_FLAG
}
void OptimizedBytecodeSourcePositionTester::SaveOptimizationFlags() {
saved_optimization_bitmap_ = 0;
#define SAVE_FLAG(V8Flag, BitName, _) \
if (V8Flag) saved_optimization_bitmap_ |= BitName;
#undef SET_FLAG
}
void OptimizedBytecodeSourcePositionTester::RestoreOptimizationFlags() {
SetOptimizationFlags(saved_optimization_bitmap_);
}
bool OptimizedBytecodeSourcePositionTester::SourcePositionsMatch(
int optimization_bitmap, const char* function_body,
const char* function_decl_params, const char* function_args) {
Handle<BytecodeArray> unoptimized_bytecode =
MakeBytecode(0, function_body, function_decl_params, function_args);
Handle<BytecodeArray> optimized_bytecode = MakeBytecode(
optimization_bitmap, function_body, function_decl_params, function_args);
SourcePositionMatcher matcher;
if (!matcher.Match(unoptimized_bytecode, optimized_bytecode)) {
return false;
}
return true;
}
void TestSourcePositionsEquivalent(int optimization_bitmap) {
HandleAndZoneScope handles;
// Ensure handler table is generated.
handles.main_isolate()->interpreter()->Initialize();
OptimizedBytecodeSourcePositionTester tester(handles.main_isolate());
for (auto test_script : kTestScripts) {
CHECK(tester.SourcePositionsMatch(optimization_bitmap, test_script));
}
}
#define MAKE_TEST(Name, Bitmap) \
TEST(TestSourcePositionsEquivalent##Name) { \
TestSourcePositionsEquivalent(Bitmap); \
}
TEST_CASES(MAKE_TEST)
#undef MAKE_TEST
} // namespace interpreter
} // namespace internal
} // namespace v8
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