| 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 SNPrintF(program, "%s\n%s();", function, kFunctionName); | 87 SNPrintF(program, "%s\n%s();", function, kFunctionName); |
| 88 return MakeBytecode(program.start(), "*", kFunctionName); | 88 return MakeBytecode(program.start(), "*", kFunctionName); |
| 89 } | 89 } |
| 90 }; | 90 }; |
| 91 | 91 |
| 92 | 92 |
| 93 // Helper macros for handcrafting bytecode sequences. | 93 // Helper macros for handcrafting bytecode sequences. |
| 94 #define B(x) static_cast<uint8_t>(Bytecode::k##x) | 94 #define B(x) static_cast<uint8_t>(Bytecode::k##x) |
| 95 #define U8(x) static_cast<uint8_t>((x) & 0xff) | 95 #define U8(x) static_cast<uint8_t>((x) & 0xff) |
| 96 #define R(x) static_cast<uint8_t>(-(x) & 0xff) | 96 #define R(x) static_cast<uint8_t>(-(x) & 0xff) |
| 97 #define R16(x) U16(-(x)) |
| 97 #define A(x, n) R(helper.kLastParamIndex - (n) + 1 + (x)) | 98 #define A(x, n) R(helper.kLastParamIndex - (n) + 1 + (x)) |
| 98 #define THIS(n) A(0, n) | 99 #define THIS(n) A(0, n) |
| 99 #if defined(V8_TARGET_LITTLE_ENDIAN) | 100 #if defined(V8_TARGET_LITTLE_ENDIAN) |
| 100 #define U16(x) static_cast<uint8_t>((x) & 0xff), \ | 101 #define U16(x) static_cast<uint8_t>((x) & 0xff), \ |
| 101 static_cast<uint8_t>(((x) >> kBitsPerByte) & 0xff) | 102 static_cast<uint8_t>(((x) >> kBitsPerByte) & 0xff) |
| 102 #define U16I(x) static_cast<uint8_t>((x) & 0xff), \ | 103 #define U16I(x) static_cast<uint8_t>((x) & 0xff), \ |
| 103 static_cast<uint8_t>(((x++) >> kBitsPerByte) & 0xff) | 104 static_cast<uint8_t>(((x++) >> kBitsPerByte) & 0xff) |
| 104 #elif defined(V8_TARGET_BIG_ENDIAN) | 105 #elif defined(V8_TARGET_BIG_ENDIAN) |
| 105 #define U16(x) static_cast<uint8_t>(((x) >> kBitsPerByte) & 0xff), \ | 106 #define U16(x) static_cast<uint8_t>(((x) >> kBitsPerByte) & 0xff), \ |
| 106 static_cast<uint8_t>((x) & 0xff) | 107 static_cast<uint8_t>((x) & 0xff) |
| (...skipping 1326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1433 B(Return), // | 1434 B(Return), // |
| 1434 }, | 1435 }, |
| 1435 1, | 1436 1, |
| 1436 {"func"}}, | 1437 {"func"}}, |
| 1437 {"function f(a) {\n" | 1438 {"function f(a) {\n" |
| 1438 " a.func;\n" | 1439 " a.func;\n" |
| 1439 REPEAT_127(SPACE, " a.func;\n") | 1440 REPEAT_127(SPACE, " a.func;\n") |
| 1440 " return a.func(); }\nf(" FUNC_ARG ")", | 1441 " return a.func(); }\nf(" FUNC_ARG ")", |
| 1441 2 * kPointerSize, | 1442 2 * kPointerSize, |
| 1442 2, | 1443 2, |
| 1443 1044, | 1444 1046, |
| 1444 { | 1445 { |
| 1445 B(Ldar), A(1, 2), // | 1446 B(Ldar), A(1, 2), // |
| 1446 B(Star), R(0), // | 1447 B(Star), R(0), // |
| 1447 B(LoadICSloppy), R(0), U8(0), U8(wide_idx += 2), // | 1448 B(LoadICSloppy), R(0), U8(0), U8(wide_idx += 2), // |
| 1448 REPEAT_127(COMMA, // | 1449 REPEAT_127(COMMA, // |
| 1449 B(Ldar), A(1, 2), // | 1450 B(Ldar), A(1, 2), // |
| 1450 B(Star), R(0), // | 1451 B(Star), R(0), // |
| 1451 B(LoadICSloppy), R(0), U8(0), U8((wide_idx += 2))), // | 1452 B(LoadICSloppy), R(0), U8(0), U8((wide_idx += 2))), // |
| 1452 B(Ldar), A(1, 2), // | 1453 B(Ldar), A(1, 2), // |
| 1453 B(Star), R(1), // | 1454 B(Star), R(1), // |
| 1454 B(LoadICSloppyWide), R(1), U16(0), U16(wide_idx + 4), // | 1455 B(LoadICSloppyWide), R(1), U16(0), U16(wide_idx + 4), // |
| 1455 B(Star), R(0), // | 1456 B(Star), R(0), // |
| 1456 B(CallWide), R(0), R(1), U16(0), U16(wide_idx + 2), // | 1457 B(CallWide), R16(0), R16(1), U16(0), U16(wide_idx + 2), // |
| 1457 B(Return), // | 1458 B(Return), // |
| 1458 }, | 1459 }, |
| 1459 1, | 1460 1, |
| 1460 {"func"}}, | 1461 {"func"}}, |
| 1461 }; | 1462 }; |
| 1462 for (size_t i = 0; i < arraysize(snippets); i++) { | 1463 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 1463 Handle<BytecodeArray> bytecode_array = | 1464 Handle<BytecodeArray> bytecode_array = |
| 1464 helper.MakeBytecode(snippets[i].code_snippet, helper.kFunctionName); | 1465 helper.MakeBytecode(snippets[i].code_snippet, helper.kFunctionName); |
| 1465 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 1466 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 1466 } | 1467 } |
| (...skipping 5260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6727 std::string(function_epilogue); | 6728 std::string(function_epilogue); |
| 6728 Handle<BytecodeArray> bytecode_array = | 6729 Handle<BytecodeArray> bytecode_array = |
| 6729 helper.MakeBytecode(script.c_str(), "*", "f"); | 6730 helper.MakeBytecode(script.c_str(), "*", "f"); |
| 6730 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 6731 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 6731 } | 6732 } |
| 6732 } | 6733 } |
| 6733 | 6734 |
| 6734 } // namespace interpreter | 6735 } // namespace interpreter |
| 6735 } // namespace internal | 6736 } // namespace internal |
| 6736 } // namespace v8 | 6737 } // namespace v8 |
| OLD | NEW |