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/bytecode-array-builder.h" | 5 #include "src/interpreter/bytecode-array-builder.h" |
6 #include "src/compiler.h" | 6 #include "src/compiler.h" |
7 | 7 |
8 namespace v8 { | 8 namespace v8 { |
9 namespace internal { | 9 namespace internal { |
10 namespace interpreter { | 10 namespace interpreter { |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 } else if (FitsInReg8OperandUntranslated(to)) { | 357 } else if (FitsInReg8OperandUntranslated(to)) { |
358 CHECK(RegisterIsValid(from, OperandType::kReg16) && | 358 CHECK(RegisterIsValid(from, OperandType::kReg16) && |
359 RegisterIsValid(to, OperandType::kReg8)); | 359 RegisterIsValid(to, OperandType::kReg8)); |
360 } else { | 360 } else { |
361 UNIMPLEMENTED(); | 361 UNIMPLEMENTED(); |
362 } | 362 } |
363 Output(Bytecode::kMovWide, from.ToRawOperand(), to.ToRawOperand()); | 363 Output(Bytecode::kMovWide, from.ToRawOperand(), to.ToRawOperand()); |
364 } | 364 } |
365 | 365 |
366 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadGlobal( | 366 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadGlobal( |
367 const Handle<String> name, int feedback_slot, LanguageMode language_mode, | 367 const Handle<String> name, int feedback_slot, TypeofMode typeof_mode) { |
368 TypeofMode typeof_mode) { | 368 // TODO(rmcilroy): Potentially store typeof information in an |
369 // TODO(rmcilroy): Potentially store language and typeof information in an | |
370 // operand rather than having extra bytecodes. | 369 // operand rather than having extra bytecodes. |
371 Bytecode bytecode = BytecodeForLoadGlobal(language_mode, typeof_mode); | 370 Bytecode bytecode = BytecodeForLoadGlobal(typeof_mode); |
372 size_t name_index = GetConstantPoolEntry(name); | 371 size_t name_index = GetConstantPoolEntry(name); |
373 if (FitsInIdx8Operand(name_index) && FitsInIdx8Operand(feedback_slot)) { | 372 if (FitsInIdx8Operand(name_index) && FitsInIdx8Operand(feedback_slot)) { |
374 Output(bytecode, static_cast<uint8_t>(name_index), | 373 Output(bytecode, static_cast<uint8_t>(name_index), |
375 static_cast<uint8_t>(feedback_slot)); | 374 static_cast<uint8_t>(feedback_slot)); |
376 } else if (FitsInIdx16Operand(name_index) && | 375 } else if (FitsInIdx16Operand(name_index) && |
377 FitsInIdx16Operand(feedback_slot)) { | 376 FitsInIdx16Operand(feedback_slot)) { |
378 Output(BytecodeForWideOperands(bytecode), static_cast<uint16_t>(name_index), | 377 Output(BytecodeForWideOperands(bytecode), static_cast<uint16_t>(name_index), |
379 static_cast<uint16_t>(feedback_slot)); | 378 static_cast<uint16_t>(feedback_slot)); |
380 } else { | 379 } else { |
381 UNIMPLEMENTED(); | 380 UNIMPLEMENTED(); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 } else if (FitsInIdx16Operand(name_index)) { | 460 } else if (FitsInIdx16Operand(name_index)) { |
462 Output(BytecodeForWideOperands(bytecode), | 461 Output(BytecodeForWideOperands(bytecode), |
463 static_cast<uint16_t>(name_index)); | 462 static_cast<uint16_t>(name_index)); |
464 } else { | 463 } else { |
465 UNIMPLEMENTED(); | 464 UNIMPLEMENTED(); |
466 } | 465 } |
467 return *this; | 466 return *this; |
468 } | 467 } |
469 | 468 |
470 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadNamedProperty( | 469 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadNamedProperty( |
471 Register object, const Handle<Name> name, int feedback_slot, | 470 Register object, const Handle<Name> name, int feedback_slot) { |
472 LanguageMode language_mode) { | |
473 Bytecode bytecode = BytecodeForLoadIC(language_mode); | |
474 size_t name_index = GetConstantPoolEntry(name); | 471 size_t name_index = GetConstantPoolEntry(name); |
475 if (FitsInIdx8Operand(name_index) && FitsInIdx8Operand(feedback_slot)) { | 472 if (FitsInIdx8Operand(name_index) && FitsInIdx8Operand(feedback_slot)) { |
476 Output(bytecode, object.ToRawOperand(), static_cast<uint8_t>(name_index), | 473 Output(Bytecode::kLoadIC, object.ToRawOperand(), |
| 474 static_cast<uint8_t>(name_index), |
477 static_cast<uint8_t>(feedback_slot)); | 475 static_cast<uint8_t>(feedback_slot)); |
478 } else if (FitsInIdx16Operand(name_index) && | 476 } else if (FitsInIdx16Operand(name_index) && |
479 FitsInIdx16Operand(feedback_slot)) { | 477 FitsInIdx16Operand(feedback_slot)) { |
480 Output(BytecodeForWideOperands(bytecode), object.ToRawOperand(), | 478 Output(Bytecode::kLoadICWide, object.ToRawOperand(), |
481 static_cast<uint16_t>(name_index), | 479 static_cast<uint16_t>(name_index), |
482 static_cast<uint16_t>(feedback_slot)); | 480 static_cast<uint16_t>(feedback_slot)); |
483 } else { | 481 } else { |
484 UNIMPLEMENTED(); | 482 UNIMPLEMENTED(); |
485 } | 483 } |
486 return *this; | 484 return *this; |
487 } | 485 } |
488 | 486 |
489 | |
490 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadKeyedProperty( | 487 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadKeyedProperty( |
491 Register object, int feedback_slot, LanguageMode language_mode) { | 488 Register object, int feedback_slot) { |
492 Bytecode bytecode = BytecodeForKeyedLoadIC(language_mode); | |
493 if (FitsInIdx8Operand(feedback_slot)) { | 489 if (FitsInIdx8Operand(feedback_slot)) { |
494 Output(bytecode, object.ToRawOperand(), | 490 Output(Bytecode::kKeyedLoadIC, object.ToRawOperand(), |
495 static_cast<uint8_t>(feedback_slot)); | 491 static_cast<uint8_t>(feedback_slot)); |
496 } else if (FitsInIdx16Operand(feedback_slot)) { | 492 } else if (FitsInIdx16Operand(feedback_slot)) { |
497 Output(BytecodeForWideOperands(bytecode), object.ToRawOperand(), | 493 Output(Bytecode::kKeyedLoadICWide, object.ToRawOperand(), |
498 static_cast<uint16_t>(feedback_slot)); | 494 static_cast<uint16_t>(feedback_slot)); |
499 } else { | 495 } else { |
500 UNIMPLEMENTED(); | 496 UNIMPLEMENTED(); |
501 } | 497 } |
502 return *this; | 498 return *this; |
503 } | 499 } |
504 | 500 |
505 BytecodeArrayBuilder& BytecodeArrayBuilder::StoreNamedProperty( | 501 BytecodeArrayBuilder& BytecodeArrayBuilder::StoreNamedProperty( |
506 Register object, const Handle<Name> name, int feedback_slot, | 502 Register object, const Handle<Name> name, int feedback_slot, |
507 LanguageMode language_mode) { | 503 LanguageMode language_mode) { |
(...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1422 default: | 1418 default: |
1423 UNREACHABLE(); | 1419 UNREACHABLE(); |
1424 return static_cast<Bytecode>(-1); | 1420 return static_cast<Bytecode>(-1); |
1425 } | 1421 } |
1426 } | 1422 } |
1427 | 1423 |
1428 | 1424 |
1429 // static | 1425 // static |
1430 Bytecode BytecodeArrayBuilder::BytecodeForWideOperands(Bytecode bytecode) { | 1426 Bytecode BytecodeArrayBuilder::BytecodeForWideOperands(Bytecode bytecode) { |
1431 switch (bytecode) { | 1427 switch (bytecode) { |
1432 case Bytecode::kLoadICSloppy: | 1428 case Bytecode::kLoadIC: |
1433 return Bytecode::kLoadICSloppyWide; | 1429 return Bytecode::kLoadICWide; |
1434 case Bytecode::kLoadICStrict: | 1430 case Bytecode::kKeyedLoadIC: |
1435 return Bytecode::kLoadICStrictWide; | 1431 return Bytecode::kKeyedLoadICWide; |
1436 case Bytecode::kKeyedLoadICSloppy: | |
1437 return Bytecode::kKeyedLoadICSloppyWide; | |
1438 case Bytecode::kKeyedLoadICStrict: | |
1439 return Bytecode::kKeyedLoadICStrictWide; | |
1440 case Bytecode::kStoreICSloppy: | 1432 case Bytecode::kStoreICSloppy: |
1441 return Bytecode::kStoreICSloppyWide; | 1433 return Bytecode::kStoreICSloppyWide; |
1442 case Bytecode::kStoreICStrict: | 1434 case Bytecode::kStoreICStrict: |
1443 return Bytecode::kStoreICStrictWide; | 1435 return Bytecode::kStoreICStrictWide; |
1444 case Bytecode::kKeyedStoreICSloppy: | 1436 case Bytecode::kKeyedStoreICSloppy: |
1445 return Bytecode::kKeyedStoreICSloppyWide; | 1437 return Bytecode::kKeyedStoreICSloppyWide; |
1446 case Bytecode::kKeyedStoreICStrict: | 1438 case Bytecode::kKeyedStoreICStrict: |
1447 return Bytecode::kKeyedStoreICStrictWide; | 1439 return Bytecode::kKeyedStoreICStrictWide; |
1448 case Bytecode::kLdaGlobalSloppy: | 1440 case Bytecode::kLdaGlobal: |
1449 return Bytecode::kLdaGlobalSloppyWide; | 1441 return Bytecode::kLdaGlobalWide; |
1450 case Bytecode::kLdaGlobalStrict: | 1442 case Bytecode::kLdaGlobalInsideTypeof: |
1451 return Bytecode::kLdaGlobalStrictWide; | 1443 return Bytecode::kLdaGlobalInsideTypeofWide; |
1452 case Bytecode::kLdaGlobalInsideTypeofSloppy: | |
1453 return Bytecode::kLdaGlobalInsideTypeofSloppyWide; | |
1454 case Bytecode::kLdaGlobalInsideTypeofStrict: | |
1455 return Bytecode::kLdaGlobalInsideTypeofStrictWide; | |
1456 case Bytecode::kStaGlobalSloppy: | 1444 case Bytecode::kStaGlobalSloppy: |
1457 return Bytecode::kStaGlobalSloppyWide; | 1445 return Bytecode::kStaGlobalSloppyWide; |
1458 case Bytecode::kStaGlobalStrict: | 1446 case Bytecode::kStaGlobalStrict: |
1459 return Bytecode::kStaGlobalStrictWide; | 1447 return Bytecode::kStaGlobalStrictWide; |
1460 case Bytecode::kLdaLookupSlot: | 1448 case Bytecode::kLdaLookupSlot: |
1461 return Bytecode::kLdaLookupSlotWide; | 1449 return Bytecode::kLdaLookupSlotWide; |
1462 case Bytecode::kLdaLookupSlotInsideTypeof: | 1450 case Bytecode::kLdaLookupSlotInsideTypeof: |
1463 return Bytecode::kLdaLookupSlotInsideTypeofWide; | 1451 return Bytecode::kLdaLookupSlotInsideTypeofWide; |
1464 case Bytecode::kStaLookupSlotStrict: | 1452 case Bytecode::kStaLookupSlotStrict: |
1465 return Bytecode::kStaLookupSlotStrictWide; | 1453 return Bytecode::kStaLookupSlotStrictWide; |
1466 case Bytecode::kStaLookupSlotSloppy: | 1454 case Bytecode::kStaLookupSlotSloppy: |
1467 return Bytecode::kStaLookupSlotSloppyWide; | 1455 return Bytecode::kStaLookupSlotSloppyWide; |
1468 default: | 1456 default: |
1469 UNREACHABLE(); | 1457 UNREACHABLE(); |
1470 return static_cast<Bytecode>(-1); | 1458 return static_cast<Bytecode>(-1); |
1471 } | 1459 } |
1472 } | 1460 } |
1473 | 1461 |
1474 | 1462 |
1475 // static | 1463 // static |
1476 Bytecode BytecodeArrayBuilder::BytecodeForLoadIC(LanguageMode language_mode) { | |
1477 switch (language_mode) { | |
1478 case SLOPPY: | |
1479 return Bytecode::kLoadICSloppy; | |
1480 case STRICT: | |
1481 return Bytecode::kLoadICStrict; | |
1482 case STRONG: | |
1483 UNIMPLEMENTED(); | |
1484 default: | |
1485 UNREACHABLE(); | |
1486 } | |
1487 return static_cast<Bytecode>(-1); | |
1488 } | |
1489 | |
1490 | |
1491 // static | |
1492 Bytecode BytecodeArrayBuilder::BytecodeForKeyedLoadIC( | |
1493 LanguageMode language_mode) { | |
1494 switch (language_mode) { | |
1495 case SLOPPY: | |
1496 return Bytecode::kKeyedLoadICSloppy; | |
1497 case STRICT: | |
1498 return Bytecode::kKeyedLoadICStrict; | |
1499 case STRONG: | |
1500 UNIMPLEMENTED(); | |
1501 default: | |
1502 UNREACHABLE(); | |
1503 } | |
1504 return static_cast<Bytecode>(-1); | |
1505 } | |
1506 | |
1507 | |
1508 // static | |
1509 Bytecode BytecodeArrayBuilder::BytecodeForStoreIC(LanguageMode language_mode) { | 1464 Bytecode BytecodeArrayBuilder::BytecodeForStoreIC(LanguageMode language_mode) { |
1510 switch (language_mode) { | 1465 switch (language_mode) { |
1511 case SLOPPY: | 1466 case SLOPPY: |
1512 return Bytecode::kStoreICSloppy; | 1467 return Bytecode::kStoreICSloppy; |
1513 case STRICT: | 1468 case STRICT: |
1514 return Bytecode::kStoreICStrict; | 1469 return Bytecode::kStoreICStrict; |
1515 case STRONG: | 1470 case STRONG: |
1516 UNIMPLEMENTED(); | 1471 UNIMPLEMENTED(); |
1517 default: | 1472 default: |
1518 UNREACHABLE(); | 1473 UNREACHABLE(); |
(...skipping 13 matching lines...) Expand all Loading... |
1532 case STRONG: | 1487 case STRONG: |
1533 UNIMPLEMENTED(); | 1488 UNIMPLEMENTED(); |
1534 default: | 1489 default: |
1535 UNREACHABLE(); | 1490 UNREACHABLE(); |
1536 } | 1491 } |
1537 return static_cast<Bytecode>(-1); | 1492 return static_cast<Bytecode>(-1); |
1538 } | 1493 } |
1539 | 1494 |
1540 | 1495 |
1541 // static | 1496 // static |
1542 Bytecode BytecodeArrayBuilder::BytecodeForLoadGlobal(LanguageMode language_mode, | 1497 Bytecode BytecodeArrayBuilder::BytecodeForLoadGlobal(TypeofMode typeof_mode) { |
1543 TypeofMode typeof_mode) { | 1498 return typeof_mode == INSIDE_TYPEOF ? Bytecode::kLdaGlobalInsideTypeof |
1544 switch (language_mode) { | 1499 : Bytecode::kLdaGlobal; |
1545 case SLOPPY: | |
1546 return typeof_mode == INSIDE_TYPEOF | |
1547 ? Bytecode::kLdaGlobalInsideTypeofSloppy | |
1548 : Bytecode::kLdaGlobalSloppy; | |
1549 case STRICT: | |
1550 return typeof_mode == INSIDE_TYPEOF | |
1551 ? Bytecode::kLdaGlobalInsideTypeofStrict | |
1552 : Bytecode::kLdaGlobalStrict; | |
1553 case STRONG: | |
1554 UNIMPLEMENTED(); | |
1555 default: | |
1556 UNREACHABLE(); | |
1557 } | |
1558 return static_cast<Bytecode>(-1); | |
1559 } | 1500 } |
1560 | 1501 |
1561 | 1502 |
1562 // static | 1503 // static |
1563 Bytecode BytecodeArrayBuilder::BytecodeForStoreGlobal( | 1504 Bytecode BytecodeArrayBuilder::BytecodeForStoreGlobal( |
1564 LanguageMode language_mode) { | 1505 LanguageMode language_mode) { |
1565 switch (language_mode) { | 1506 switch (language_mode) { |
1566 case SLOPPY: | 1507 case SLOPPY: |
1567 return Bytecode::kStaGlobalSloppy; | 1508 return Bytecode::kStaGlobalSloppy; |
1568 case STRICT: | 1509 case STRICT: |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1671 } | 1612 } |
1672 | 1613 |
1673 // static | 1614 // static |
1674 bool BytecodeArrayBuilder::FitsInReg16OperandUntranslated(Register value) { | 1615 bool BytecodeArrayBuilder::FitsInReg16OperandUntranslated(Register value) { |
1675 return value.is_short_operand(); | 1616 return value.is_short_operand(); |
1676 } | 1617 } |
1677 | 1618 |
1678 } // namespace interpreter | 1619 } // namespace interpreter |
1679 } // namespace internal | 1620 } // namespace internal |
1680 } // namespace v8 | 1621 } // namespace v8 |
OLD | NEW |