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 <tuple> | 5 #include <tuple> |
6 | 6 |
7 #include "src/v8.h" | 7 #include "src/v8.h" |
8 | 8 |
9 #include "src/execution.h" | 9 #include "src/execution.h" |
10 #include "src/handles.h" | 10 #include "src/handles.h" |
(...skipping 1237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1248 | 1248 |
1249 // Check with no args. | 1249 // Check with no args. |
1250 { | 1250 { |
1251 BytecodeArrayBuilder builder(isolate, handles.main_zone(), 1, 0, 1); | 1251 BytecodeArrayBuilder builder(isolate, handles.main_zone(), 1, 0, 1); |
1252 Register reg = builder.register_allocator()->NewRegister(); | 1252 Register reg = builder.register_allocator()->NewRegister(); |
1253 RegisterList args = builder.register_allocator()->NewRegisterList(1); | 1253 RegisterList args = builder.register_allocator()->NewRegisterList(1); |
1254 builder.LoadNamedProperty(builder.Parameter(0), name, slot_index) | 1254 builder.LoadNamedProperty(builder.Parameter(0), name, slot_index) |
1255 .StoreAccumulatorInRegister(reg) | 1255 .StoreAccumulatorInRegister(reg) |
1256 .MoveRegister(builder.Parameter(0), args[0]); | 1256 .MoveRegister(builder.Parameter(0), args[0]); |
1257 | 1257 |
1258 builder.Call(reg, args, call_slot_index, tail_call_mode); | 1258 builder.Call(reg, args, call_slot_index, Call::GLOBAL_CALL, tail_call_mode); |
1259 | 1259 |
1260 builder.Return(); | 1260 builder.Return(); |
1261 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate); | 1261 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate); |
1262 | 1262 |
1263 InterpreterTester tester(isolate, bytecode_array, vector); | 1263 InterpreterTester tester(isolate, bytecode_array, vector); |
1264 auto callable = tester.GetCallable<Handle<Object>>(); | 1264 auto callable = tester.GetCallable<Handle<Object>>(); |
1265 | 1265 |
1266 Handle<Object> object = InterpreterTester::NewObject( | 1266 Handle<Object> object = InterpreterTester::NewObject( |
1267 "new (function Obj() { this.func = function() { return 0x265; }})()"); | 1267 "new (function Obj() { this.func = function() { return 0x265; }})()"); |
1268 Handle<Object> return_val = callable(object).ToHandleChecked(); | 1268 Handle<Object> return_val = callable(object).ToHandleChecked(); |
1269 CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(0x265)); | 1269 CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(0x265)); |
1270 } | 1270 } |
1271 | 1271 |
1272 // Check that receiver is passed properly. | 1272 // Check that receiver is passed properly. |
1273 { | 1273 { |
1274 BytecodeArrayBuilder builder(isolate, handles.main_zone(), 1, 0, 1); | 1274 BytecodeArrayBuilder builder(isolate, handles.main_zone(), 1, 0, 1); |
1275 Register reg = builder.register_allocator()->NewRegister(); | 1275 Register reg = builder.register_allocator()->NewRegister(); |
1276 RegisterList args = builder.register_allocator()->NewRegisterList(1); | 1276 RegisterList args = builder.register_allocator()->NewRegisterList(1); |
1277 builder.LoadNamedProperty(builder.Parameter(0), name, slot_index) | 1277 builder.LoadNamedProperty(builder.Parameter(0), name, slot_index) |
1278 .StoreAccumulatorInRegister(reg) | 1278 .StoreAccumulatorInRegister(reg) |
1279 .MoveRegister(builder.Parameter(0), args[0]); | 1279 .MoveRegister(builder.Parameter(0), args[0]); |
1280 builder.Call(reg, args, call_slot_index, tail_call_mode); | 1280 builder.Call(reg, args, call_slot_index, Call::GLOBAL_CALL, tail_call_mode); |
1281 builder.Return(); | 1281 builder.Return(); |
1282 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate); | 1282 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate); |
1283 | 1283 |
1284 InterpreterTester tester(isolate, bytecode_array, vector); | 1284 InterpreterTester tester(isolate, bytecode_array, vector); |
1285 auto callable = tester.GetCallable<Handle<Object>>(); | 1285 auto callable = tester.GetCallable<Handle<Object>>(); |
1286 | 1286 |
1287 Handle<Object> object = InterpreterTester::NewObject( | 1287 Handle<Object> object = InterpreterTester::NewObject( |
1288 "new (function Obj() {" | 1288 "new (function Obj() {" |
1289 " this.val = 1234;" | 1289 " this.val = 1234;" |
1290 " this.func = function() { return this.val; };" | 1290 " this.func = function() { return this.val; };" |
(...skipping 10 matching lines...) Expand all Loading... |
1301 | 1301 |
1302 builder.LoadNamedProperty(builder.Parameter(0), name, slot_index) | 1302 builder.LoadNamedProperty(builder.Parameter(0), name, slot_index) |
1303 .StoreAccumulatorInRegister(reg) | 1303 .StoreAccumulatorInRegister(reg) |
1304 .LoadAccumulatorWithRegister(builder.Parameter(0)) | 1304 .LoadAccumulatorWithRegister(builder.Parameter(0)) |
1305 .StoreAccumulatorInRegister(args[0]) | 1305 .StoreAccumulatorInRegister(args[0]) |
1306 .LoadLiteral(Smi::FromInt(51)) | 1306 .LoadLiteral(Smi::FromInt(51)) |
1307 .StoreAccumulatorInRegister(args[1]) | 1307 .StoreAccumulatorInRegister(args[1]) |
1308 .LoadLiteral(Smi::FromInt(11)) | 1308 .LoadLiteral(Smi::FromInt(11)) |
1309 .StoreAccumulatorInRegister(args[2]); | 1309 .StoreAccumulatorInRegister(args[2]); |
1310 | 1310 |
1311 builder.Call(reg, args, call_slot_index, tail_call_mode); | 1311 builder.Call(reg, args, call_slot_index, Call::GLOBAL_CALL, tail_call_mode); |
1312 | 1312 |
1313 builder.Return(); | 1313 builder.Return(); |
1314 | 1314 |
1315 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate); | 1315 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate); |
1316 | 1316 |
1317 InterpreterTester tester(isolate, bytecode_array, vector); | 1317 InterpreterTester tester(isolate, bytecode_array, vector); |
1318 auto callable = tester.GetCallable<Handle<Object>>(); | 1318 auto callable = tester.GetCallable<Handle<Object>>(); |
1319 | 1319 |
1320 Handle<Object> object = InterpreterTester::NewObject( | 1320 Handle<Object> object = InterpreterTester::NewObject( |
1321 "new (function Obj() { " | 1321 "new (function Obj() { " |
(...skipping 27 matching lines...) Expand all Loading... |
1349 .StoreAccumulatorInRegister(args[6]) | 1349 .StoreAccumulatorInRegister(args[6]) |
1350 .LoadLiteral(factory->NewStringFromAsciiChecked("g")) | 1350 .LoadLiteral(factory->NewStringFromAsciiChecked("g")) |
1351 .StoreAccumulatorInRegister(args[7]) | 1351 .StoreAccumulatorInRegister(args[7]) |
1352 .LoadLiteral(factory->NewStringFromAsciiChecked("h")) | 1352 .LoadLiteral(factory->NewStringFromAsciiChecked("h")) |
1353 .StoreAccumulatorInRegister(args[8]) | 1353 .StoreAccumulatorInRegister(args[8]) |
1354 .LoadLiteral(factory->NewStringFromAsciiChecked("i")) | 1354 .LoadLiteral(factory->NewStringFromAsciiChecked("i")) |
1355 .StoreAccumulatorInRegister(args[9]) | 1355 .StoreAccumulatorInRegister(args[9]) |
1356 .LoadLiteral(factory->NewStringFromAsciiChecked("j")) | 1356 .LoadLiteral(factory->NewStringFromAsciiChecked("j")) |
1357 .StoreAccumulatorInRegister(args[10]); | 1357 .StoreAccumulatorInRegister(args[10]); |
1358 | 1358 |
1359 builder.Call(reg, args, call_slot_index, tail_call_mode); | 1359 builder.Call(reg, args, call_slot_index, Call::GLOBAL_CALL, tail_call_mode); |
1360 | 1360 |
1361 builder.Return(); | 1361 builder.Return(); |
1362 | 1362 |
1363 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate); | 1363 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate); |
1364 | 1364 |
1365 InterpreterTester tester(isolate, bytecode_array, vector); | 1365 InterpreterTester tester(isolate, bytecode_array, vector); |
1366 auto callable = tester.GetCallable<Handle<Object>>(); | 1366 auto callable = tester.GetCallable<Handle<Object>>(); |
1367 | 1367 |
1368 Handle<Object> object = InterpreterTester::NewObject( | 1368 Handle<Object> object = InterpreterTester::NewObject( |
1369 "new (function Obj() { " | 1369 "new (function Obj() { " |
(...skipping 3451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4821 auto callable = tester.GetCallable<>(); | 4821 auto callable = tester.GetCallable<>(); |
4822 | 4822 |
4823 Handle<i::Object> return_value = callable().ToHandleChecked(); | 4823 Handle<i::Object> return_value = callable().ToHandleChecked(); |
4824 CHECK(return_value->SameValue(*tests[i].second)); | 4824 CHECK(return_value->SameValue(*tests[i].second)); |
4825 } | 4825 } |
4826 } | 4826 } |
4827 | 4827 |
4828 } // namespace interpreter | 4828 } // namespace interpreter |
4829 } // namespace internal | 4829 } // namespace internal |
4830 } // namespace v8 | 4830 } // namespace v8 |
OLD | NEW |