OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/code-stubs.h" | 7 #include "src/code-stubs.h" |
8 #include "src/field-index.h" | 8 #include "src/field-index.h" |
9 #include "src/hydrogen.h" | 9 #include "src/hydrogen.h" |
10 #include "src/lithium.h" | 10 #include "src/lithium.h" |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 return feedback_vector; | 532 return feedback_vector; |
533 } | 533 } |
534 | 534 |
535 | 535 |
536 Handle<Code> CreateAllocationSiteStub::GenerateCode() { | 536 Handle<Code> CreateAllocationSiteStub::GenerateCode() { |
537 return DoGenerateCode(this); | 537 return DoGenerateCode(this); |
538 } | 538 } |
539 | 539 |
540 | 540 |
541 template <> | 541 template <> |
542 HValue* CodeStubGraphBuilder<KeyedLoadFastElementStub>::BuildCodeStub() { | 542 HValue* CodeStubGraphBuilder<LoadFastElementStub>::BuildCodeStub() { |
543 HInstruction* load = BuildUncheckedMonomorphicElementAccess( | 543 HInstruction* load = BuildUncheckedMonomorphicElementAccess( |
544 GetParameter(KeyedLoadIC::kReceiverIndex), | 544 GetParameter(KeyedLoadIC::kReceiverIndex), |
545 GetParameter(KeyedLoadIC::kNameIndex), | 545 GetParameter(KeyedLoadIC::kNameIndex), |
546 NULL, | 546 NULL, |
547 casted_stub()->is_js_array(), | 547 casted_stub()->is_js_array(), |
548 casted_stub()->elements_kind(), | 548 casted_stub()->elements_kind(), |
549 LOAD, | 549 LOAD, |
550 NEVER_RETURN_HOLE, | 550 NEVER_RETURN_HOLE, |
551 STANDARD_STORE); | 551 STANDARD_STORE); |
552 return load; | 552 return load; |
553 } | 553 } |
554 | 554 |
555 | 555 |
556 Handle<Code> KeyedLoadFastElementStub::GenerateCode() { | 556 Handle<Code> LoadFastElementStub::GenerateCode() { |
557 return DoGenerateCode(this); | 557 return DoGenerateCode(this); |
558 } | 558 } |
559 | 559 |
560 | 560 |
561 HLoadNamedField* CodeStubGraphBuilderBase::BuildLoadNamedField( | 561 HLoadNamedField* CodeStubGraphBuilderBase::BuildLoadNamedField( |
562 HValue* object, FieldIndex index) { | 562 HValue* object, FieldIndex index) { |
563 Representation representation = index.is_double() | 563 Representation representation = index.is_double() |
564 ? Representation::Double() | 564 ? Representation::Double() |
565 : Representation::Tagged(); | 565 : Representation::Tagged(); |
566 int offset = index.offset(); | 566 int offset = index.offset(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 FieldIndex::ForInObjectOffset(String::kLengthOffset)); | 598 FieldIndex::ForInObjectOffset(String::kLengthOffset)); |
599 } | 599 } |
600 | 600 |
601 | 601 |
602 Handle<Code> StringLengthStub::GenerateCode() { | 602 Handle<Code> StringLengthStub::GenerateCode() { |
603 return DoGenerateCode(this); | 603 return DoGenerateCode(this); |
604 } | 604 } |
605 | 605 |
606 | 606 |
607 template <> | 607 template <> |
608 HValue* CodeStubGraphBuilder<KeyedStoreFastElementStub>::BuildCodeStub() { | 608 HValue* CodeStubGraphBuilder<StoreFastElementStub>::BuildCodeStub() { |
609 BuildUncheckedMonomorphicElementAccess( | 609 BuildUncheckedMonomorphicElementAccess( |
610 GetParameter(StoreIC::kReceiverIndex), | 610 GetParameter(StoreIC::kReceiverIndex), |
611 GetParameter(StoreIC::kNameIndex), | 611 GetParameter(StoreIC::kNameIndex), |
612 GetParameter(StoreIC::kValueIndex), | 612 GetParameter(StoreIC::kValueIndex), |
613 casted_stub()->is_js_array(), casted_stub()->elements_kind(), | 613 casted_stub()->is_js_array(), casted_stub()->elements_kind(), |
614 STORE, NEVER_RETURN_HOLE, casted_stub()->store_mode()); | 614 STORE, NEVER_RETURN_HOLE, casted_stub()->store_mode()); |
615 | 615 |
616 return GetParameter(2); | 616 return GetParameter(2); |
617 } | 617 } |
618 | 618 |
619 | 619 |
620 Handle<Code> KeyedStoreFastElementStub::GenerateCode() { | 620 Handle<Code> StoreFastElementStub::GenerateCode() { |
621 return DoGenerateCode(this); | 621 return DoGenerateCode(this); |
622 } | 622 } |
623 | 623 |
624 | 624 |
625 template <> | 625 template <> |
626 HValue* CodeStubGraphBuilder<TransitionElementsKindStub>::BuildCodeStub() { | 626 HValue* CodeStubGraphBuilder<TransitionElementsKindStub>::BuildCodeStub() { |
627 info()->MarkAsSavesCallerDoubles(); | 627 info()->MarkAsSavesCallerDoubles(); |
628 | 628 |
629 BuildTransitionElementsKind(GetParameter(0), | 629 BuildTransitionElementsKind(GetParameter(0), |
630 GetParameter(1), | 630 GetParameter(1), |
(...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1371 | 1371 |
1372 return function_context; | 1372 return function_context; |
1373 } | 1373 } |
1374 | 1374 |
1375 | 1375 |
1376 Handle<Code> FastNewContextStub::GenerateCode() { | 1376 Handle<Code> FastNewContextStub::GenerateCode() { |
1377 return DoGenerateCode(this); | 1377 return DoGenerateCode(this); |
1378 } | 1378 } |
1379 | 1379 |
1380 | 1380 |
1381 template<> | 1381 template <> |
1382 HValue* CodeStubGraphBuilder<KeyedLoadDictionaryElementStub>::BuildCodeStub() { | 1382 HValue* CodeStubGraphBuilder<LoadDictionaryElementStub>::BuildCodeStub() { |
1383 HValue* receiver = GetParameter(KeyedLoadIC::kReceiverIndex); | 1383 HValue* receiver = GetParameter(KeyedLoadIC::kReceiverIndex); |
1384 HValue* key = GetParameter(KeyedLoadIC::kNameIndex); | 1384 HValue* key = GetParameter(KeyedLoadIC::kNameIndex); |
1385 | 1385 |
1386 Add<HCheckSmi>(key); | 1386 Add<HCheckSmi>(key); |
1387 | 1387 |
1388 HValue* elements = AddLoadElements(receiver); | 1388 HValue* elements = AddLoadElements(receiver); |
1389 | 1389 |
1390 HValue* hash = BuildElementIndexHash(key); | 1390 HValue* hash = BuildElementIndexHash(key); |
1391 | 1391 |
1392 return BuildUncheckedDictionaryElementLoad(receiver, elements, key, hash); | 1392 return BuildUncheckedDictionaryElementLoad(receiver, elements, key, hash); |
1393 } | 1393 } |
1394 | 1394 |
1395 | 1395 |
1396 Handle<Code> KeyedLoadDictionaryElementStub::GenerateCode() { | 1396 Handle<Code> LoadDictionaryElementStub::GenerateCode() { |
1397 return DoGenerateCode(this); | 1397 return DoGenerateCode(this); |
1398 } | 1398 } |
1399 | 1399 |
1400 | 1400 |
1401 template<> | 1401 template<> |
1402 HValue* CodeStubGraphBuilder<RegExpConstructResultStub>::BuildCodeStub() { | 1402 HValue* CodeStubGraphBuilder<RegExpConstructResultStub>::BuildCodeStub() { |
1403 // Determine the parameters. | 1403 // Determine the parameters. |
1404 HValue* length = GetParameter(RegExpConstructResultStub::kLength); | 1404 HValue* length = GetParameter(RegExpConstructResultStub::kLength); |
1405 HValue* index = GetParameter(RegExpConstructResultStub::kIndex); | 1405 HValue* index = GetParameter(RegExpConstructResultStub::kIndex); |
1406 HValue* input = GetParameter(RegExpConstructResultStub::kInput); | 1406 HValue* input = GetParameter(RegExpConstructResultStub::kInput); |
1407 | 1407 |
1408 info()->MarkMustNotHaveEagerFrame(); | 1408 info()->MarkMustNotHaveEagerFrame(); |
1409 | 1409 |
1410 return BuildRegExpConstructResult(length, index, input); | 1410 return BuildRegExpConstructResult(length, index, input); |
1411 } | 1411 } |
1412 | 1412 |
1413 | 1413 |
1414 Handle<Code> RegExpConstructResultStub::GenerateCode() { | 1414 Handle<Code> RegExpConstructResultStub::GenerateCode() { |
1415 return DoGenerateCode(this); | 1415 return DoGenerateCode(this); |
1416 } | 1416 } |
1417 | 1417 |
1418 | 1418 |
1419 template <> | 1419 template <> |
1420 class CodeStubGraphBuilder<KeyedLoadGenericElementStub> | 1420 class CodeStubGraphBuilder<KeyedLoadGenericStub> |
1421 : public CodeStubGraphBuilderBase { | 1421 : public CodeStubGraphBuilderBase { |
1422 public: | 1422 public: |
1423 CodeStubGraphBuilder(Isolate* isolate, | 1423 CodeStubGraphBuilder(Isolate* isolate, KeyedLoadGenericStub* stub) |
1424 KeyedLoadGenericElementStub* stub) | 1424 : CodeStubGraphBuilderBase(isolate, stub) {} |
1425 : CodeStubGraphBuilderBase(isolate, stub) {} | |
1426 | 1425 |
1427 protected: | 1426 protected: |
1428 virtual HValue* BuildCodeStub(); | 1427 virtual HValue* BuildCodeStub(); |
1429 | 1428 |
1430 void BuildElementsKindLimitCheck(HGraphBuilder::IfBuilder* if_builder, | 1429 void BuildElementsKindLimitCheck(HGraphBuilder::IfBuilder* if_builder, |
1431 HValue* bit_field2, | 1430 HValue* bit_field2, |
1432 ElementsKind kind); | 1431 ElementsKind kind); |
1433 | 1432 |
1434 void BuildFastElementLoad(HGraphBuilder::IfBuilder* if_builder, | 1433 void BuildFastElementLoad(HGraphBuilder::IfBuilder* if_builder, |
1435 HValue* receiver, | 1434 HValue* receiver, |
1436 HValue* key, | 1435 HValue* key, |
1437 HValue* instance_type, | 1436 HValue* instance_type, |
1438 HValue* bit_field2, | 1437 HValue* bit_field2, |
1439 ElementsKind kind); | 1438 ElementsKind kind); |
1440 | 1439 |
1441 void BuildExternalElementLoad(HGraphBuilder::IfBuilder* if_builder, | 1440 void BuildExternalElementLoad(HGraphBuilder::IfBuilder* if_builder, |
1442 HValue* receiver, | 1441 HValue* receiver, |
1443 HValue* key, | 1442 HValue* key, |
1444 HValue* instance_type, | 1443 HValue* instance_type, |
1445 HValue* bit_field2, | 1444 HValue* bit_field2, |
1446 ElementsKind kind); | 1445 ElementsKind kind); |
1447 | 1446 |
1448 KeyedLoadGenericElementStub* casted_stub() { | 1447 KeyedLoadGenericStub* casted_stub() { |
1449 return static_cast<KeyedLoadGenericElementStub*>(stub()); | 1448 return static_cast<KeyedLoadGenericStub*>(stub()); |
1450 } | 1449 } |
1451 }; | 1450 }; |
1452 | 1451 |
1453 | 1452 |
1454 void CodeStubGraphBuilder< | 1453 void CodeStubGraphBuilder<KeyedLoadGenericStub>::BuildElementsKindLimitCheck( |
1455 KeyedLoadGenericElementStub>::BuildElementsKindLimitCheck( | 1454 HGraphBuilder::IfBuilder* if_builder, HValue* bit_field2, |
1456 HGraphBuilder::IfBuilder* if_builder, | |
1457 HValue* bit_field2, | |
1458 ElementsKind kind) { | 1455 ElementsKind kind) { |
1459 ElementsKind next_kind = static_cast<ElementsKind>(kind + 1); | 1456 ElementsKind next_kind = static_cast<ElementsKind>(kind + 1); |
1460 HValue* kind_limit = Add<HConstant>( | 1457 HValue* kind_limit = Add<HConstant>( |
1461 static_cast<int>(Map::ElementsKindBits::encode(next_kind))); | 1458 static_cast<int>(Map::ElementsKindBits::encode(next_kind))); |
1462 | 1459 |
1463 if_builder->If<HCompareNumericAndBranch>(bit_field2, kind_limit, Token::LT); | 1460 if_builder->If<HCompareNumericAndBranch>(bit_field2, kind_limit, Token::LT); |
1464 if_builder->Then(); | 1461 if_builder->Then(); |
1465 } | 1462 } |
1466 | 1463 |
1467 | 1464 |
1468 void CodeStubGraphBuilder<KeyedLoadGenericElementStub>::BuildFastElementLoad( | 1465 void CodeStubGraphBuilder<KeyedLoadGenericStub>::BuildFastElementLoad( |
1469 HGraphBuilder::IfBuilder* if_builder, | 1466 HGraphBuilder::IfBuilder* if_builder, HValue* receiver, HValue* key, |
1470 HValue* receiver, | 1467 HValue* instance_type, HValue* bit_field2, ElementsKind kind) { |
1471 HValue* key, | |
1472 HValue* instance_type, | |
1473 HValue* bit_field2, | |
1474 ElementsKind kind) { | |
1475 ASSERT(!IsExternalArrayElementsKind(kind)); | 1468 ASSERT(!IsExternalArrayElementsKind(kind)); |
1476 | 1469 |
1477 BuildElementsKindLimitCheck(if_builder, bit_field2, kind); | 1470 BuildElementsKindLimitCheck(if_builder, bit_field2, kind); |
1478 | 1471 |
1479 IfBuilder js_array_check(this); | 1472 IfBuilder js_array_check(this); |
1480 js_array_check.If<HCompareNumericAndBranch>( | 1473 js_array_check.If<HCompareNumericAndBranch>( |
1481 instance_type, Add<HConstant>(JS_ARRAY_TYPE), Token::EQ); | 1474 instance_type, Add<HConstant>(JS_ARRAY_TYPE), Token::EQ); |
1482 js_array_check.Then(); | 1475 js_array_check.Then(); |
1483 Push(BuildUncheckedMonomorphicElementAccess(receiver, key, NULL, | 1476 Push(BuildUncheckedMonomorphicElementAccess(receiver, key, NULL, |
1484 true, kind, | 1477 true, kind, |
1485 LOAD, NEVER_RETURN_HOLE, | 1478 LOAD, NEVER_RETURN_HOLE, |
1486 STANDARD_STORE)); | 1479 STANDARD_STORE)); |
1487 js_array_check.Else(); | 1480 js_array_check.Else(); |
1488 Push(BuildUncheckedMonomorphicElementAccess(receiver, key, NULL, | 1481 Push(BuildUncheckedMonomorphicElementAccess(receiver, key, NULL, |
1489 false, kind, | 1482 false, kind, |
1490 LOAD, NEVER_RETURN_HOLE, | 1483 LOAD, NEVER_RETURN_HOLE, |
1491 STANDARD_STORE)); | 1484 STANDARD_STORE)); |
1492 js_array_check.End(); | 1485 js_array_check.End(); |
1493 } | 1486 } |
1494 | 1487 |
1495 | 1488 |
1496 void CodeStubGraphBuilder< | 1489 void CodeStubGraphBuilder<KeyedLoadGenericStub>::BuildExternalElementLoad( |
1497 KeyedLoadGenericElementStub>::BuildExternalElementLoad( | 1490 HGraphBuilder::IfBuilder* if_builder, HValue* receiver, HValue* key, |
1498 HGraphBuilder::IfBuilder* if_builder, | 1491 HValue* instance_type, HValue* bit_field2, ElementsKind kind) { |
1499 HValue* receiver, | |
1500 HValue* key, | |
1501 HValue* instance_type, | |
1502 HValue* bit_field2, | |
1503 ElementsKind kind) { | |
1504 ASSERT(IsExternalArrayElementsKind(kind)); | 1492 ASSERT(IsExternalArrayElementsKind(kind)); |
1505 | 1493 |
1506 BuildElementsKindLimitCheck(if_builder, bit_field2, kind); | 1494 BuildElementsKindLimitCheck(if_builder, bit_field2, kind); |
1507 | 1495 |
1508 Push(BuildUncheckedMonomorphicElementAccess(receiver, key, NULL, | 1496 Push(BuildUncheckedMonomorphicElementAccess(receiver, key, NULL, |
1509 false, kind, | 1497 false, kind, |
1510 LOAD, NEVER_RETURN_HOLE, | 1498 LOAD, NEVER_RETURN_HOLE, |
1511 STANDARD_STORE)); | 1499 STANDARD_STORE)); |
1512 } | 1500 } |
1513 | 1501 |
1514 | 1502 |
1515 HValue* CodeStubGraphBuilder<KeyedLoadGenericElementStub>::BuildCodeStub() { | 1503 HValue* CodeStubGraphBuilder<KeyedLoadGenericStub>::BuildCodeStub() { |
1516 HValue* receiver = GetParameter(KeyedLoadIC::kReceiverIndex); | 1504 HValue* receiver = GetParameter(KeyedLoadIC::kReceiverIndex); |
1517 HValue* key = GetParameter(KeyedLoadIC::kNameIndex); | 1505 HValue* key = GetParameter(KeyedLoadIC::kNameIndex); |
1518 | 1506 |
1519 // Split into a smi/integer case and unique string case. | 1507 // Split into a smi/integer case and unique string case. |
1520 HIfContinuation index_name_split_continuation(graph()->CreateBasicBlock(), | 1508 HIfContinuation index_name_split_continuation(graph()->CreateBasicBlock(), |
1521 graph()->CreateBasicBlock()); | 1509 graph()->CreateBasicBlock()); |
1522 | 1510 |
1523 BuildKeyedIndexCheck(key, &index_name_split_continuation); | 1511 BuildKeyedIndexCheck(key, &index_name_split_continuation); |
1524 | 1512 |
1525 IfBuilder index_name_split(this, &index_name_split_continuation); | 1513 IfBuilder index_name_split(this, &index_name_split_continuation); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1562 HValue* hash = BuildElementIndexHash(key); | 1550 HValue* hash = BuildElementIndexHash(key); |
1563 | 1551 |
1564 Push(BuildUncheckedDictionaryElementLoad(receiver, elements, key, hash)); | 1552 Push(BuildUncheckedDictionaryElementLoad(receiver, elements, key, hash)); |
1565 } | 1553 } |
1566 kind_if.Else(); | 1554 kind_if.Else(); |
1567 | 1555 |
1568 // The SLOPPY_ARGUMENTS_ELEMENTS check generates a "kind_if.Then" | 1556 // The SLOPPY_ARGUMENTS_ELEMENTS check generates a "kind_if.Then" |
1569 BuildElementsKindLimitCheck(&kind_if, bit_field2, | 1557 BuildElementsKindLimitCheck(&kind_if, bit_field2, |
1570 SLOPPY_ARGUMENTS_ELEMENTS); | 1558 SLOPPY_ARGUMENTS_ELEMENTS); |
1571 // Non-strict elements are not handled. | 1559 // Non-strict elements are not handled. |
1572 Add<HDeoptimize>("non-strict elements in KeyedLoadGenericElementStub", | 1560 Add<HDeoptimize>("non-strict elements in KeyedLoadGenericStub", |
1573 Deoptimizer::EAGER); | 1561 Deoptimizer::EAGER); |
1574 Push(graph()->GetConstant0()); | 1562 Push(graph()->GetConstant0()); |
1575 | 1563 |
1576 kind_if.Else(); | 1564 kind_if.Else(); |
1577 BuildExternalElementLoad(&kind_if, receiver, key, instance_type, bit_field2, | 1565 BuildExternalElementLoad(&kind_if, receiver, key, instance_type, bit_field2, |
1578 EXTERNAL_INT8_ELEMENTS); | 1566 EXTERNAL_INT8_ELEMENTS); |
1579 | 1567 |
1580 kind_if.Else(); | 1568 kind_if.Else(); |
1581 BuildExternalElementLoad(&kind_if, receiver, key, instance_type, bit_field2, | 1569 BuildExternalElementLoad(&kind_if, receiver, key, instance_type, bit_field2, |
1582 EXTERNAL_UINT8_ELEMENTS); | 1570 EXTERNAL_UINT8_ELEMENTS); |
(...skipping 19 matching lines...) Expand all Loading... |
1602 EXTERNAL_FLOAT32_ELEMENTS); | 1590 EXTERNAL_FLOAT32_ELEMENTS); |
1603 | 1591 |
1604 kind_if.Else(); | 1592 kind_if.Else(); |
1605 BuildExternalElementLoad(&kind_if, receiver, key, instance_type, bit_field2, | 1593 BuildExternalElementLoad(&kind_if, receiver, key, instance_type, bit_field2, |
1606 EXTERNAL_FLOAT64_ELEMENTS); | 1594 EXTERNAL_FLOAT64_ELEMENTS); |
1607 | 1595 |
1608 kind_if.Else(); | 1596 kind_if.Else(); |
1609 BuildExternalElementLoad(&kind_if, receiver, key, instance_type, bit_field2, | 1597 BuildExternalElementLoad(&kind_if, receiver, key, instance_type, bit_field2, |
1610 EXTERNAL_UINT8_CLAMPED_ELEMENTS); | 1598 EXTERNAL_UINT8_CLAMPED_ELEMENTS); |
1611 | 1599 |
1612 kind_if.ElseDeopt("ElementsKind unhandled in KeyedLoadGenericElementStub"); | 1600 kind_if.ElseDeopt("ElementsKind unhandled in KeyedLoadGenericStub"); |
1613 | 1601 |
1614 kind_if.End(); | 1602 kind_if.End(); |
1615 } | 1603 } |
1616 index_name_split.Else(); | 1604 index_name_split.Else(); |
1617 { | 1605 { |
1618 // Key is a unique string. | 1606 // Key is a unique string. |
1619 key = Pop(); | 1607 key = Pop(); |
1620 | 1608 |
1621 int bit_field_mask = (1 << Map::kIsAccessCheckNeeded) | | 1609 int bit_field_mask = (1 << Map::kIsAccessCheckNeeded) | |
1622 (1 << Map::kHasNamedInterceptor); | 1610 (1 << Map::kHasNamedInterceptor); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1723 inline_or_runtime.End(); | 1711 inline_or_runtime.End(); |
1724 } | 1712 } |
1725 if_dict_properties.End(); | 1713 if_dict_properties.End(); |
1726 } | 1714 } |
1727 index_name_split.End(); | 1715 index_name_split.End(); |
1728 | 1716 |
1729 return Pop(); | 1717 return Pop(); |
1730 } | 1718 } |
1731 | 1719 |
1732 | 1720 |
1733 Handle<Code> KeyedLoadGenericElementStub::GenerateCode() { | 1721 Handle<Code> KeyedLoadGenericStub::GenerateCode() { |
1734 return DoGenerateCode(this); | 1722 return DoGenerateCode(this); |
1735 } | 1723 } |
1736 | 1724 |
1737 | 1725 |
1738 } } // namespace v8::internal | 1726 } } // namespace v8::internal |
OLD | NEW |