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 3249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3260 | 3260 |
3261 InterpreterTester tester(handles.main_isolate(), script.c_str(), "t"); | 3261 InterpreterTester tester(handles.main_isolate(), script.c_str(), "t"); |
3262 auto callable = tester.GetCallable<>(); | 3262 auto callable = tester.GetCallable<>(); |
3263 | 3263 |
3264 Handle<i::Object> return_value = callable().ToHandleChecked(); | 3264 Handle<i::Object> return_value = callable().ToHandleChecked(); |
3265 CHECK(return_value->SameValue(*lookup_slot[i].second)); | 3265 CHECK(return_value->SameValue(*lookup_slot[i].second)); |
3266 } | 3266 } |
3267 } | 3267 } |
3268 | 3268 |
3269 | 3269 |
| 3270 TEST(InterpreterCallLookupSlot) { |
| 3271 HandleAndZoneScope handles; |
| 3272 i::Isolate* isolate = handles.main_isolate(); |
| 3273 |
| 3274 std::pair<const char*, Handle<Object>> call_lookup[] = { |
| 3275 {"g = function(){ return 2 }; eval(''); return g();", |
| 3276 handle(Smi::FromInt(2), isolate)}, |
| 3277 {"g = function(){ return 2 }; eval('g = function() {return 3}');\n" |
| 3278 "return g();", |
| 3279 handle(Smi::FromInt(3), isolate)}, |
| 3280 {"g = { x: function(){ return this.y }, y: 20 };\n" |
| 3281 "eval('g = { x: g.x, y: 30 }');\n" |
| 3282 "return g.x();", |
| 3283 handle(Smi::FromInt(30), isolate)}, |
| 3284 }; |
| 3285 |
| 3286 for (size_t i = 0; i < arraysize(call_lookup); i++) { |
| 3287 std::string source(InterpreterTester::SourceForBody(call_lookup[i].first)); |
| 3288 InterpreterTester tester(handles.main_isolate(), source.c_str()); |
| 3289 auto callable = tester.GetCallable<>(); |
| 3290 |
| 3291 Handle<i::Object> return_value = callable().ToHandleChecked(); |
| 3292 CHECK(return_value->SameValue(*call_lookup[i].second)); |
| 3293 } |
| 3294 } |
| 3295 |
| 3296 |
3270 TEST(InterpreterLookupSlotWide) { | 3297 TEST(InterpreterLookupSlotWide) { |
3271 HandleAndZoneScope handles; | 3298 HandleAndZoneScope handles; |
3272 i::Isolate* isolate = handles.main_isolate(); | 3299 i::Isolate* isolate = handles.main_isolate(); |
3273 i::Factory* factory = isolate->factory(); | 3300 i::Factory* factory = isolate->factory(); |
3274 | 3301 |
3275 const char* function_prologue = | 3302 const char* function_prologue = |
3276 "var f;" | 3303 "var f;" |
3277 "var x = 1;" | 3304 "var x = 1;" |
3278 "function f1() {" | 3305 "function f1() {" |
3279 " eval(\"function t() {"; | 3306 " eval(\"function t() {"; |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3490 auto callable = tester.GetCallable<>(); | 3517 auto callable = tester.GetCallable<>(); |
3491 | 3518 |
3492 Handle<i::Object> return_value = callable().ToHandleChecked(); | 3519 Handle<i::Object> return_value = callable().ToHandleChecked(); |
3493 CHECK(return_value->SameValue(*eval_global[i].second)); | 3520 CHECK(return_value->SameValue(*eval_global[i].second)); |
3494 } | 3521 } |
3495 } | 3522 } |
3496 | 3523 |
3497 } // namespace interpreter | 3524 } // namespace interpreter |
3498 } // namespace internal | 3525 } // namespace internal |
3499 } // namespace v8 | 3526 } // namespace v8 |
OLD | NEW |