OLD | NEW |
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/compiler.h" | 7 #include "src/compiler.h" |
8 #include "src/interpreter/bytecode-array-iterator.h" | 8 #include "src/interpreter/bytecode-array-iterator.h" |
9 #include "src/interpreter/bytecode-generator.h" | 9 #include "src/interpreter/bytecode-generator.h" |
10 #include "src/interpreter/interpreter.h" | 10 #include "src/interpreter/interpreter.h" |
(...skipping 7258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7269 std::string script = std::string(function_prologue) + | 7269 std::string script = std::string(function_prologue) + |
7270 std::string(snippets[i].code_snippet) + | 7270 std::string(snippets[i].code_snippet) + |
7271 std::string(function_epilogue); | 7271 std::string(function_epilogue); |
7272 Handle<BytecodeArray> bytecode_array = | 7272 Handle<BytecodeArray> bytecode_array = |
7273 helper.MakeBytecode(script.c_str(), "*", "f"); | 7273 helper.MakeBytecode(script.c_str(), "*", "f"); |
7274 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 7274 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
7275 } | 7275 } |
7276 } | 7276 } |
7277 | 7277 |
7278 TEST(WideRegisters) { | 7278 TEST(WideRegisters) { |
7279 InitializedHandleScope handle_scope; | |
7280 BytecodeGeneratorHelper helper; | |
7281 | |
7282 // Prepare prologue that creates frame for lots of registers. | 7279 // Prepare prologue that creates frame for lots of registers. |
7283 std::ostringstream os; | 7280 std::ostringstream os; |
7284 for (size_t i = 0; i < 157; ++i) { | 7281 for (size_t i = 0; i < 157; ++i) { |
7285 os << "var x" << i << ";\n"; | 7282 os << "var x" << i << ";\n"; |
7286 } | 7283 } |
7287 std::string prologue(os.str()); | 7284 std::string prologue(os.str()); |
7288 | 7285 |
7289 ExpectedSnippet<int> snippets[] = { | 7286 ExpectedSnippet<int> snippets[] = { |
7290 {"x0 = x127;\n" | 7287 {"x0 = x127;\n" |
7291 "return x0;\n", | 7288 "return x0;\n", |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7486 B(Ldar), R(125), // | 7483 B(Ldar), R(125), // |
7487 B(Star), R(125), // | 7484 B(Star), R(125), // |
7488 B(MovWide), R16(125), R16(162), // | 7485 B(MovWide), R16(125), R16(162), // |
7489 B(CallRuntimeWide), U16(Runtime::kAdd), R16(161), U8(2), // | 7486 B(CallRuntimeWide), U16(Runtime::kAdd), R16(161), U8(2), // |
7490 B(Star), R(1), // | 7487 B(Star), R(1), // |
7491 B(CallRuntime), U16(Runtime::kTheHole), R(0), U8(0), // | 7488 B(CallRuntime), U16(Runtime::kTheHole), R(0), U8(0), // |
7492 B(Ldar), R(1), // | 7489 B(Ldar), R(1), // |
7493 B(Return), // | 7490 B(Return), // |
7494 }}}; | 7491 }}}; |
7495 | 7492 |
| 7493 InitializedHandleScope handle_scope; |
| 7494 BytecodeGeneratorHelper helper; |
| 7495 |
7496 for (size_t i = 0; i < arraysize(snippets); ++i) { | 7496 for (size_t i = 0; i < arraysize(snippets); ++i) { |
7497 std::string body = prologue + snippets[i].code_snippet; | 7497 std::string body = prologue + snippets[i].code_snippet; |
7498 Handle<BytecodeArray> bytecode_array = | 7498 Handle<BytecodeArray> bytecode_array = |
7499 helper.MakeBytecodeForFunctionBody(body.c_str()); | 7499 helper.MakeBytecodeForFunctionBody(body.c_str()); |
7500 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 7500 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
7501 } | 7501 } |
7502 } | 7502 } |
7503 | 7503 |
7504 TEST(DoExpression) { | 7504 TEST(DoExpression) { |
7505 bool old_flag = FLAG_harmony_do_expressions; | 7505 bool old_flag = FLAG_harmony_do_expressions; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7559 Handle<BytecodeArray> bytecode_array = | 7559 Handle<BytecodeArray> bytecode_array = |
7560 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); | 7560 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); |
7561 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 7561 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
7562 } | 7562 } |
7563 FLAG_harmony_do_expressions = old_flag; | 7563 FLAG_harmony_do_expressions = old_flag; |
7564 } | 7564 } |
7565 | 7565 |
7566 } // namespace interpreter | 7566 } // namespace interpreter |
7567 } // namespace internal | 7567 } // namespace internal |
7568 } // namespace v8 | 7568 } // namespace v8 |
OLD | NEW |