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

Side by Side Diff: test/cctest/interpreter/test-interpreter.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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/execution.h" 7 #include "src/execution.h"
8 #include "src/handles.h" 8 #include "src/handles.h"
9 #include "src/interpreter/bytecode-array-builder.h" 9 #include "src/interpreter/bytecode-array-builder.h"
10 #include "src/interpreter/bytecode-array-iterator.h" 10 #include "src/interpreter/bytecode-array-iterator.h"
(...skipping 1035 matching lines...) Expand 10 before | Expand all | Expand 10 after
1046 Handle<Object> return_value = callable().ToHandleChecked(); 1046 Handle<Object> return_value = callable().ToHandleChecked();
1047 CHECK_EQ(Smi::cast(*return_value)->value(), 7); 1047 CHECK_EQ(Smi::cast(*return_value)->value(), 7);
1048 } 1048 }
1049 1049
1050 TEST(InterpreterJumpConstantWith16BitOperand) { 1050 TEST(InterpreterJumpConstantWith16BitOperand) {
1051 HandleAndZoneScope handles; 1051 HandleAndZoneScope handles;
1052 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 1, 1052 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone(), 1,
1053 0, 257); 1053 0, 257);
1054 1054
1055 Register reg(0), scratch(256); 1055 Register reg(0), scratch(256);
1056 BytecodeLabel done; 1056 BytecodeLabel done, fake;
1057 1057
1058 builder.LoadLiteral(Smi::FromInt(0)); 1058 builder.LoadLiteral(Smi::FromInt(0));
1059 builder.StoreAccumulatorInRegister(reg); 1059 builder.StoreAccumulatorInRegister(reg);
1060 // Consume all 8-bit operands 1060 // Consume all 8-bit operands
1061 for (int i = 1; i <= 256; i++) { 1061 for (int i = 1; i <= 256; i++) {
1062 builder.LoadLiteral(handles.main_isolate()->factory()->NewNumber(i)); 1062 builder.LoadLiteral(handles.main_isolate()->factory()->NewNumber(i));
1063 builder.BinaryOperation(Token::Value::ADD, reg); 1063 builder.BinaryOperation(Token::Value::ADD, reg);
1064 builder.StoreAccumulatorInRegister(reg); 1064 builder.StoreAccumulatorInRegister(reg);
1065 } 1065 }
1066 builder.Jump(&done); 1066 builder.Jump(&done);
1067 1067
1068 // Emit more than 16-bit immediate operands worth of code to jump over. 1068 // Emit more than 16-bit immediate operands worth of code to jump over.
1069 builder.Bind(&fake);
1069 for (int i = 0; i < 6600; i++) { 1070 for (int i = 0; i < 6600; i++) {
1070 builder.LoadLiteral(Smi::FromInt(0)); // 1-byte 1071 builder.LoadLiteral(Smi::FromInt(0)); // 1-byte
1071 builder.BinaryOperation(Token::Value::ADD, scratch); // 4-bytes 1072 builder.BinaryOperation(Token::Value::ADD, scratch); // 4-bytes
1072 builder.StoreAccumulatorInRegister(scratch); // 4-bytes 1073 builder.StoreAccumulatorInRegister(scratch); // 4-bytes
1073 builder.MoveRegister(scratch, reg); // 6-bytes 1074 builder.MoveRegister(scratch, reg); // 6-bytes
1074 } 1075 }
1075 builder.Bind(&done); 1076 builder.Bind(&done);
1076 builder.LoadAccumulatorWithRegister(reg); 1077 builder.LoadAccumulatorWithRegister(reg);
1077 builder.Return(); 1078 builder.Return();
1078 1079
(...skipping 3114 matching lines...) Expand 10 before | Expand all | Expand 10 after
4193 Handle<i::Object> return_value = callable().ToHandleChecked(); 4194 Handle<i::Object> return_value = callable().ToHandleChecked();
4194 CHECK(return_value->SameValue(*tests[i].second)); 4195 CHECK(return_value->SameValue(*tests[i].second));
4195 } 4196 }
4196 4197
4197 FLAG_ignition_generators = old_flag; 4198 FLAG_ignition_generators = old_flag;
4198 } 4199 }
4199 4200
4200 } // namespace interpreter 4201 } // namespace interpreter
4201 } // namespace internal 4202 } // namespace internal
4202 } // namespace v8 4203 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/interpreter/bytecode_expectations/WithStatement.golden ('k') | test/cctest/interpreter/test-source-positions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698