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 1271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1282 .Return(); | 1282 .Return(); |
1283 | 1283 |
1284 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); | 1284 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); |
1285 InterpreterTester tester(handles.main_isolate(), bytecode_array); | 1285 InterpreterTester tester(handles.main_isolate(), bytecode_array); |
1286 auto callable = tester.GetCallable<>(); | 1286 auto callable = tester.GetCallable<>(); |
1287 Handle<Object> return_value = callable().ToHandleChecked(); | 1287 Handle<Object> return_value = callable().ToHandleChecked(); |
1288 CHECK(return_value->IsBoolean()); | 1288 CHECK(return_value->IsBoolean()); |
1289 CHECK_EQ(return_value->BooleanValue(), expected_value); | 1289 CHECK_EQ(return_value->BooleanValue(), expected_value); |
1290 } | 1290 } |
1291 } | 1291 } |
| 1292 |
| 1293 |
| 1294 TEST(InterpreterCallRuntime) { |
| 1295 HandleAndZoneScope handles; |
| 1296 |
| 1297 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); |
| 1298 builder.set_locals_count(2); |
| 1299 builder.set_parameter_count(1); |
| 1300 builder.LoadLiteral(Smi::FromInt(15)) |
| 1301 .StoreAccumulatorInRegister(Register(0)) |
| 1302 .LoadLiteral(Smi::FromInt(40)) |
| 1303 .StoreAccumulatorInRegister(Register(1)) |
| 1304 .CallRuntime(Runtime::kAdd, Register(0), 2) |
| 1305 .Return(); |
| 1306 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); |
| 1307 |
| 1308 InterpreterTester tester(handles.main_isolate(), bytecode_array); |
| 1309 auto callable = tester.GetCallable<>(); |
| 1310 |
| 1311 Handle<Object> return_val = callable().ToHandleChecked(); |
| 1312 CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(55)); |
| 1313 } |
OLD | NEW |