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/interpreter/interpreter-assembler.h" | 5 #include "src/interpreter/interpreter-assembler.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <ostream> | 8 #include <ostream> |
9 | 9 |
10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
(...skipping 1372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1383 return false; | 1383 return false; |
1384 #elif V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_X87 || \ | 1384 #elif V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_X87 || \ |
1385 V8_TARGET_ARCH_S390 || V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || \ | 1385 V8_TARGET_ARCH_S390 || V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || \ |
1386 V8_TARGET_ARCH_PPC | 1386 V8_TARGET_ARCH_PPC |
1387 return true; | 1387 return true; |
1388 #else | 1388 #else |
1389 #error "Unknown Architecture" | 1389 #error "Unknown Architecture" |
1390 #endif | 1390 #endif |
1391 } | 1391 } |
1392 | 1392 |
1393 Node* InterpreterAssembler::RegisterCount() { | 1393 void InterpreterAssembler::AbortIfRegisterCountInvalid(Node* register_file, |
1394 Node* bytecode_array = LoadRegister(Register::bytecode_array()); | 1394 Node* register_count) { |
1395 Node* frame_size = LoadObjectField( | 1395 Node* array_size = LoadAndUntagFixedArrayBaseLength(register_file); |
1396 bytecode_array, BytecodeArray::kFrameSizeOffset, MachineType::Uint32()); | 1396 |
1397 return WordShr(ChangeUint32ToWord(frame_size), | 1397 Label ok(this), abort(this, Label::kDeferred); |
1398 IntPtrConstant(kPointerSizeLog2)); | 1398 Branch(UintPtrLessThanOrEqual(register_count, array_size), &ok, &abort); |
| 1399 |
| 1400 BIND(&abort); |
| 1401 Abort(kInvalidRegisterFileInGenerator); |
| 1402 Goto(&ok); |
| 1403 |
| 1404 BIND(&ok); |
1399 } | 1405 } |
1400 | 1406 |
1401 Node* InterpreterAssembler::ExportRegisterFile(Node* array) { | 1407 Node* InterpreterAssembler::ExportRegisterFile(Node* array, |
1402 Node* register_count = RegisterCount(); | 1408 Node* register_count) { |
1403 if (FLAG_debug_code) { | 1409 if (FLAG_debug_code) { |
1404 Node* array_size = LoadAndUntagFixedArrayBaseLength(array); | 1410 AbortIfRegisterCountInvalid(array, register_count); |
1405 AbortIfWordNotEqual(array_size, register_count, | |
1406 kInvalidRegisterFileInGenerator); | |
1407 } | 1411 } |
1408 | 1412 |
1409 Variable var_index(this, MachineType::PointerRepresentation()); | 1413 Variable var_index(this, MachineType::PointerRepresentation()); |
1410 var_index.Bind(IntPtrConstant(0)); | 1414 var_index.Bind(IntPtrConstant(0)); |
1411 | 1415 |
1412 // Iterate over register file and write values into array. | 1416 // Iterate over register file and write values into array. |
1413 // The mapping of register to array index must match that used in | 1417 // The mapping of register to array index must match that used in |
1414 // BytecodeGraphBuilder::VisitResumeGenerator. | 1418 // BytecodeGraphBuilder::VisitResumeGenerator. |
1415 Label loop(this, &var_index), done_loop(this); | 1419 Label loop(this, &var_index), done_loop(this); |
1416 Goto(&loop); | 1420 Goto(&loop); |
1417 BIND(&loop); | 1421 BIND(&loop); |
1418 { | 1422 { |
1419 Node* index = var_index.value(); | 1423 Node* index = var_index.value(); |
1420 GotoIfNot(UintPtrLessThan(index, register_count), &done_loop); | 1424 GotoIfNot(UintPtrLessThan(index, register_count), &done_loop); |
1421 | 1425 |
1422 Node* reg_index = IntPtrSub(IntPtrConstant(Register(0).ToOperand()), index); | 1426 Node* reg_index = IntPtrSub(IntPtrConstant(Register(0).ToOperand()), index); |
1423 Node* value = LoadRegister(reg_index); | 1427 Node* value = LoadRegister(reg_index); |
1424 | 1428 |
1425 StoreFixedArrayElement(array, index, value); | 1429 StoreFixedArrayElement(array, index, value); |
1426 | 1430 |
1427 var_index.Bind(IntPtrAdd(index, IntPtrConstant(1))); | 1431 var_index.Bind(IntPtrAdd(index, IntPtrConstant(1))); |
1428 Goto(&loop); | 1432 Goto(&loop); |
1429 } | 1433 } |
1430 BIND(&done_loop); | 1434 BIND(&done_loop); |
1431 | 1435 |
1432 return array; | 1436 return array; |
1433 } | 1437 } |
1434 | 1438 |
1435 Node* InterpreterAssembler::ImportRegisterFile(Node* array) { | 1439 Node* InterpreterAssembler::ImportRegisterFile(Node* array, |
1436 Node* register_count = RegisterCount(); | 1440 Node* register_count) { |
1437 if (FLAG_debug_code) { | 1441 if (FLAG_debug_code) { |
1438 Node* array_size = LoadAndUntagFixedArrayBaseLength(array); | 1442 AbortIfRegisterCountInvalid(array, register_count); |
1439 AbortIfWordNotEqual(array_size, register_count, | |
1440 kInvalidRegisterFileInGenerator); | |
1441 } | 1443 } |
1442 | 1444 |
1443 Variable var_index(this, MachineType::PointerRepresentation()); | 1445 Variable var_index(this, MachineType::PointerRepresentation()); |
1444 var_index.Bind(IntPtrConstant(0)); | 1446 var_index.Bind(IntPtrConstant(0)); |
1445 | 1447 |
1446 // Iterate over array and write values into register file. Also erase the | 1448 // Iterate over array and write values into register file. Also erase the |
1447 // array contents to not keep them alive artificially. | 1449 // array contents to not keep them alive artificially. |
1448 Label loop(this, &var_index), done_loop(this); | 1450 Label loop(this, &var_index), done_loop(this); |
1449 Goto(&loop); | 1451 Goto(&loop); |
1450 BIND(&loop); | 1452 BIND(&loop); |
(...skipping 16 matching lines...) Expand all Loading... |
1467 return array; | 1469 return array; |
1468 } | 1470 } |
1469 | 1471 |
1470 int InterpreterAssembler::CurrentBytecodeSize() const { | 1472 int InterpreterAssembler::CurrentBytecodeSize() const { |
1471 return Bytecodes::Size(bytecode_, operand_scale_); | 1473 return Bytecodes::Size(bytecode_, operand_scale_); |
1472 } | 1474 } |
1473 | 1475 |
1474 } // namespace interpreter | 1476 } // namespace interpreter |
1475 } // namespace internal | 1477 } // namespace internal |
1476 } // namespace v8 | 1478 } // namespace v8 |
OLD | NEW |