Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(181)

Unified Diff: test/cctest/interpreter/test-source-positions.cc

Issue 2038083002: [Interpreter] Add a simple dead-code elimination bytecode optimizer. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@int_jump_writer
Patch Set: Fix tests Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/cctest/interpreter/test-interpreter.cc ('k') | test/unittests/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/interpreter/test-source-positions.cc
diff --git a/test/cctest/interpreter/test-source-positions.cc b/test/cctest/interpreter/test-source-positions.cc
index d50bb62b2b31ca9c4de77d112dd27c0020695419..19be47fa8e141192d67258203045158ead5f4e60 100644
--- a/test/cctest/interpreter/test-source-positions.cc
+++ b/test/cctest/interpreter/test-source-positions.cc
@@ -19,11 +19,12 @@ 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) \
- V(FLAG_ignition_filter_expression_positions, \
- kUseUseFilterExpressionPositions, 2)
+#define OPTIMIZATION_FLAGS(V) \
+ V(FLAG_ignition_reo, kUseReo, 0) \
+ V(FLAG_ignition_peephole, kUsePeephole, 1) \
+ V(FLAG_ignition_filter_expression_positions, kUseFilterExpressionPositions, \
+ 2) \
+ V(FLAG_ignition_deadcode, kUseDeadCode, 3)
#define DECLARE_BIT(_, Name, BitIndex) static const int Name = 1 << BitIndex;
OPTIMIZATION_FLAGS(DECLARE_BIT)
@@ -32,17 +33,22 @@ OPTIMIZATION_FLAGS(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(UsingPeephole, kUsePeephole) \
- V(UsingReoAndPeephole, kUseReo | kUsePeephole) \
- V(UsingUseFilterExpressionPositions, kUseUseFilterExpressionPositions) \
- V(UsingReoAndUseFilterExpressionPositions, \
- kUseReo | kUseUseFilterExpressionPositions) \
- V(UsingPeepholeAndUseFilterExpressionPositions, \
- kUsePeephole | kUseUseFilterExpressionPositions) \
- V(UsingAllOptimizations, \
- kUseReo | kUsePeephole | kUseUseFilterExpressionPositions)
+#define TEST_CASES(V) \
+ V(UsingReo, kUseReo) \
+ V(UsingPeephole, kUsePeephole) \
+ V(UsingDeadCode, kUseDeadCode) \
+ V(UsingFilterExpressionPositions, kUseFilterExpressionPositions) \
+ V(UsingReoAndPeephole, kUseReo | kUsePeephole) \
+ V(UsingReoAndFilterExpressionPositions, \
+ kUseReo | kUseFilterExpressionPositions) \
+ V(UsingReoAndDeadCode, kUseReo | kUseDeadCode) \
+ V(UsingPeepholeAndFilterExpressionPositions, \
+ kUsePeephole | kUseFilterExpressionPositions) \
+ V(UsingPeepholeAndDeadCode, kUsePeephole | kUseDeadCode) \
+ V(UsingFilterExpressionPositionsAndDeadCode, \
+ kUseFilterExpressionPositions | kUseDeadCode) \
+ V(UsingAllOptimizations, \
+ kUseReo | kUsePeephole | kUseFilterExpressionPositions | kUseDeadCode)
struct TestCaseData {
TestCaseData(const char* const script,
@@ -142,9 +148,7 @@ class OptimizedBytecodeSourcePositionTester final {
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,
+ static std::string MakeScript(const char* function_body,
const char* function_decl_params,
const char* function_args);
@@ -161,39 +165,30 @@ class OptimizedBytecodeSourcePositionTester final {
};
// 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) {
+ 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 test_function"
+ << "(" << function_decl_params << ") {";
os << function_body;
os << "}";
- os << function_name << "(" << function_args << ");";
+ os << "test_function(" << 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);
+ std::string script =
+ MakeScript(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());
+ Local<Function> api_function = Local<Function>::Cast(
+ CcTest::global()
+ ->Get(CcTest::isolate()->GetCurrentContext(), v8_str("test_function"))
+ .ToLocalChecked());
Handle<JSFunction> function =
Handle<JSFunction>::cast(v8::Utils::OpenHandle(*api_function));
return handle(function->shared()->bytecode_array());
« no previous file with comments | « test/cctest/interpreter/test-interpreter.cc ('k') | test/unittests/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698