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/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/interpreter.h" | 10 #include "src/interpreter/interpreter.h" |
(...skipping 3111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3122 std::string(function_epilogue); | 3122 std::string(function_epilogue); |
3123 | 3123 |
3124 InterpreterTester tester(handles.main_isolate(), script.c_str(), "t"); | 3124 InterpreterTester tester(handles.main_isolate(), script.c_str(), "t"); |
3125 auto callable = tester.GetCallable<>(); | 3125 auto callable = tester.GetCallable<>(); |
3126 | 3126 |
3127 Handle<i::Object> return_value = callable().ToHandleChecked(); | 3127 Handle<i::Object> return_value = callable().ToHandleChecked(); |
3128 CHECK(return_value->SameValue(*lookup_slot[i].second)); | 3128 CHECK(return_value->SameValue(*lookup_slot[i].second)); |
3129 } | 3129 } |
3130 } | 3130 } |
3131 | 3131 |
| 3132 |
| 3133 TEST(InterpreterDeleteLookupSlot) { |
| 3134 HandleAndZoneScope handles; |
| 3135 i::Isolate* isolate = handles.main_isolate(); |
| 3136 i::Factory* factory = isolate->factory(); |
| 3137 |
| 3138 // TODO(mythria): Add more tests when we have support for eval/with. |
| 3139 const char* function_prologue = "var f;" |
| 3140 "var x = 1;" |
| 3141 "y = 10;" |
| 3142 "var obj = {val:10};" |
| 3143 "var z = 30;" |
| 3144 "function f1() {" |
| 3145 " var z = 20;" |
| 3146 " eval(\"function t() {"; |
| 3147 const char* function_epilogue = " }; f = t;\");" |
| 3148 "}" |
| 3149 "f1();"; |
| 3150 |
| 3151 |
| 3152 std::pair<const char*, Handle<Object>> delete_lookup_slot[] = { |
| 3153 {"return delete x;", factory->false_value()}, |
| 3154 {"return delete y;", factory->true_value()}, |
| 3155 {"return delete z;", factory->false_value()}, |
| 3156 {"return delete obj.val;", factory->true_value()}, |
| 3157 {"'use strict'; return delete obj.val;", factory->true_value()}, |
| 3158 }; |
| 3159 |
| 3160 for (size_t i = 0; i < arraysize(delete_lookup_slot); i++) { |
| 3161 std::string script = std::string(function_prologue) + |
| 3162 std::string(delete_lookup_slot[i].first) + |
| 3163 std::string(function_epilogue); |
| 3164 |
| 3165 InterpreterTester tester(handles.main_isolate(), script.c_str(), "t"); |
| 3166 auto callable = tester.GetCallable<>(); |
| 3167 |
| 3168 Handle<i::Object> return_value = callable().ToHandleChecked(); |
| 3169 CHECK(return_value->SameValue(*delete_lookup_slot[i].second)); |
| 3170 } |
| 3171 } |
| 3172 |
3132 } // namespace interpreter | 3173 } // namespace interpreter |
3133 } // namespace internal | 3174 } // namespace internal |
3134 } // namespace v8 | 3175 } // namespace v8 |
OLD | NEW |