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 956 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
967 .Bind(&done) | 967 .Bind(&done) |
968 .Bind(&done1) | 968 .Bind(&done1) |
969 .Return(); | 969 .Return(); |
970 | 970 |
971 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); | 971 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); |
972 InterpreterTester tester(handles.main_isolate(), bytecode_array); | 972 InterpreterTester tester(handles.main_isolate(), bytecode_array); |
973 auto callable = tester.GetCallable<>(); | 973 auto callable = tester.GetCallable<>(); |
974 Handle<Object> return_value = callable().ToHandleChecked(); | 974 Handle<Object> return_value = callable().ToHandleChecked(); |
975 CHECK_EQ(Smi::cast(*return_value)->value(), 7); | 975 CHECK_EQ(Smi::cast(*return_value)->value(), 7); |
976 } | 976 } |
| 977 |
| 978 |
| 979 TEST(InterpreterCallRuntime) { |
| 980 HandleAndZoneScope handles; |
| 981 |
| 982 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); |
| 983 builder.set_locals_count(2); |
| 984 builder.set_parameter_count(1); |
| 985 builder.LoadLiteral(Smi::FromInt(15)) |
| 986 .StoreAccumulatorInRegister(Register(0)) |
| 987 .LoadLiteral(Smi::FromInt(40)) |
| 988 .StoreAccumulatorInRegister(Register(1)) |
| 989 .CallRuntime(Runtime::kAdd, Register(0), 2) |
| 990 .Return(); |
| 991 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); |
| 992 |
| 993 InterpreterTester tester(handles.main_isolate(), bytecode_array); |
| 994 auto callable = tester.GetCallable<>(); |
| 995 |
| 996 Handle<Object> return_val = callable().ToHandleChecked(); |
| 997 CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(55)); |
| 998 } |
OLD | NEW |