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 5778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5789 std::string(snippets[i].code_snippet) + | 5789 std::string(snippets[i].code_snippet) + |
5790 std::string(function_epilogue); | 5790 std::string(function_epilogue); |
5791 // TODO(mythria): use * as filter when function declarations are supported | 5791 // TODO(mythria): use * as filter when function declarations are supported |
5792 // inside eval. | 5792 // inside eval. |
5793 Handle<BytecodeArray> bytecode_array = | 5793 Handle<BytecodeArray> bytecode_array = |
5794 helper.MakeBytecode(script.c_str(), "t", "f"); | 5794 helper.MakeBytecode(script.c_str(), "t", "f"); |
5795 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 5795 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
5796 } | 5796 } |
5797 } | 5797 } |
5798 | 5798 |
| 5799 |
| 5800 TEST(DeleteLookupSlot) { |
| 5801 InitializedHandleScope handle_scope; |
| 5802 BytecodeGeneratorHelper helper; |
| 5803 |
| 5804 const char* function_prologue = "var f;" |
| 5805 "var x = 1;" |
| 5806 "z = 10;" |
| 5807 "function f1() {" |
| 5808 " var y;" |
| 5809 " eval(\"function t() {"; |
| 5810 const char* function_epilogue = " }; f = t; f();\");" |
| 5811 "}" |
| 5812 "f1();"; |
| 5813 |
| 5814 ExpectedSnippet<const char*> snippets[] = { |
| 5815 {"delete x;", |
| 5816 0 * kPointerSize, |
| 5817 1, |
| 5818 5, |
| 5819 { |
| 5820 B(LdaConstant), U8(0), // |
| 5821 B(DeleteLookupSlot), // |
| 5822 B(LdaUndefined), // |
| 5823 B(Return) // |
| 5824 }, |
| 5825 1, |
| 5826 {"x"}}, |
| 5827 {"return delete y;", |
| 5828 0 * kPointerSize, |
| 5829 1, |
| 5830 2, |
| 5831 { |
| 5832 B(LdaFalse), // |
| 5833 B(Return) // |
| 5834 }, |
| 5835 0}, |
| 5836 {"return delete z;", |
| 5837 0 * kPointerSize, |
| 5838 1, |
| 5839 4, |
| 5840 { |
| 5841 B(LdaConstant), U8(0), // |
| 5842 B(DeleteLookupSlot), // |
| 5843 B(Return) // |
| 5844 }, |
| 5845 1, |
| 5846 {"z"}}, |
| 5847 }; |
| 5848 |
| 5849 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 5850 std::string script = std::string(function_prologue) + |
| 5851 std::string(snippets[i].code_snippet) + |
| 5852 std::string(function_epilogue); |
| 5853 Handle<BytecodeArray> bytecode_array = |
| 5854 helper.MakeBytecode(script.c_str(), "t", "f"); |
| 5855 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 5856 } |
| 5857 } |
| 5858 |
5799 } // namespace interpreter | 5859 } // namespace interpreter |
5800 } // namespace internal | 5860 } // namespace internal |
5801 } // namespace v8 | 5861 } // namespace v8 |
OLD | NEW |