| 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 996 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1007 4 * kPointerSize, | 1007 4 * kPointerSize, |
| 1008 3, | 1008 3, |
| 1009 30, | 1009 30, |
| 1010 { | 1010 { |
| 1011 B(Ldar), R(helper.kLastParamIndex - 1), // | 1011 B(Ldar), R(helper.kLastParamIndex - 1), // |
| 1012 B(Star), R(1), // | 1012 B(Star), R(1), // |
| 1013 B(LdaConstant), U8(0), // | 1013 B(LdaConstant), U8(0), // |
| 1014 B(LoadICSloppy), R(1), U8(vector->GetIndex(slot2)), // | 1014 B(LoadICSloppy), R(1), U8(vector->GetIndex(slot2)), // |
| 1015 B(Star), R(0), // | 1015 B(Star), R(0), // |
| 1016 B(Ldar), R(helper.kLastParamIndex), // | 1016 B(Ldar), R(helper.kLastParamIndex), // |
| 1017 B(Star), R(3), // | 1017 B(Star), R(2), // |
| 1018 B(Ldar), R(helper.kLastParamIndex), // | 1018 B(Ldar), R(helper.kLastParamIndex), // |
| 1019 B(Add), R(3), // | 1019 B(Add), R(2), // |
| 1020 B(Star), R(2), // | 1020 B(Star), R(2), // |
| 1021 B(Ldar), R(helper.kLastParamIndex), // | 1021 B(Ldar), R(helper.kLastParamIndex), // |
| 1022 B(Star), R(3), // | 1022 B(Star), R(3), // |
| 1023 B(Call), R(0), R(1), U8(2), // | 1023 B(Call), R(0), R(1), U8(2), // |
| 1024 B(Return), // | 1024 B(Return) // |
| 1025 }, | 1025 }, |
| 1026 1, | 1026 1, |
| 1027 {"func"}}}; | 1027 {"func"}}}; |
| 1028 for (size_t i = 0; i < arraysize(snippets); i++) { | 1028 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 1029 Handle<BytecodeArray> bytecode_array = | 1029 Handle<BytecodeArray> bytecode_array = |
| 1030 helper.MakeBytecode(snippets[i].code_snippet, helper.kFunctionName); | 1030 helper.MakeBytecode(snippets[i].code_snippet, helper.kFunctionName); |
| 1031 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 1031 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 1032 } | 1032 } |
| 1033 } | 1033 } |
| 1034 | 1034 |
| (...skipping 1554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2589 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, | 2589 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, |
| 2590 }; | 2590 }; |
| 2591 | 2591 |
| 2592 for (size_t i = 0; i < arraysize(snippets); i++) { | 2592 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 2593 Handle<BytecodeArray> bytecode_array = | 2593 Handle<BytecodeArray> bytecode_array = |
| 2594 helper.MakeTopLevelBytecode(snippets[i].code_snippet); | 2594 helper.MakeTopLevelBytecode(snippets[i].code_snippet); |
| 2595 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 2595 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 2596 } | 2596 } |
| 2597 } | 2597 } |
| 2598 | 2598 |
| 2599 | |
| 2600 TEST(CallNew) { | |
| 2601 InitializedHandleScope handle_scope; | |
| 2602 BytecodeGeneratorHelper helper; | |
| 2603 | |
| 2604 ExpectedSnippet<InstanceType> snippets[] = { | |
| 2605 {"function bar() { this.value = 0; }\n" | |
| 2606 "function f() { return new bar(); }\n" | |
| 2607 "f()", | |
| 2608 kPointerSize, | |
| 2609 1, | |
| 2610 9, | |
| 2611 { | |
| 2612 B(LdaGlobal), _, // | |
| 2613 B(Star), R(0), // | |
| 2614 B(New), R(0), R(0), U8(0), // | |
| 2615 B(Return), // | |
| 2616 }, | |
| 2617 0}, | |
| 2618 {"function bar(x) { this.value = 18; this.x = x;}\n" | |
| 2619 "function f() { return new bar(3); }\n" | |
| 2620 "f()", | |
| 2621 2 * kPointerSize, | |
| 2622 1, | |
| 2623 13, | |
| 2624 { | |
| 2625 B(LdaGlobal), _, // | |
| 2626 B(Star), R(0), // | |
| 2627 B(LdaSmi8), U8(3), // | |
| 2628 B(Star), R(1), // | |
| 2629 B(New), R(0), R(1), U8(1), // | |
| 2630 B(Return), // | |
| 2631 }, | |
| 2632 0}, | |
| 2633 {"function bar(w, x, y, z) {\n" | |
| 2634 " this.value = 18;\n" | |
| 2635 " this.x = x;\n" | |
| 2636 " this.y = y;\n" | |
| 2637 " this.z = z;\n" | |
| 2638 "}\n" | |
| 2639 "function f() { return new bar(3, 4, 5); }\n" | |
| 2640 "f()", | |
| 2641 4 * kPointerSize, | |
| 2642 1, | |
| 2643 21, | |
| 2644 { | |
| 2645 B(LdaGlobal), _, // | |
| 2646 B(Star), R(0), // | |
| 2647 B(LdaSmi8), U8(3), // | |
| 2648 B(Star), R(1), // | |
| 2649 B(LdaSmi8), U8(4), // | |
| 2650 B(Star), R(2), // | |
| 2651 B(LdaSmi8), U8(5), // | |
| 2652 B(Star), R(3), // | |
| 2653 B(New), R(0), R(1), U8(3), // | |
| 2654 B(Return), // | |
| 2655 }, | |
| 2656 0}}; | |
| 2657 | |
| 2658 for (size_t i = 0; i < arraysize(snippets); i++) { | |
| 2659 Handle<BytecodeArray> bytecode_array = | |
| 2660 helper.MakeBytecode(snippets[i].code_snippet, "f"); | |
| 2661 CheckBytecodeArrayEqual(snippets[i], bytecode_array, true); | |
| 2662 } | |
| 2663 } | |
| 2664 | |
| 2665 } // namespace interpreter | 2599 } // namespace interpreter |
| 2666 } // namespace internal | 2600 } // namespace internal |
| 2667 } // namespace v8 | 2601 } // namespace v8 |
| OLD | NEW |