OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
596 if (!pointer->is_set()) { | 596 if (!pointer->is_set()) { |
597 HConstant* constant = | 597 HConstant* constant = |
598 new(zone()) HConstant(value, Representation::Integer32()); | 598 new(zone()) HConstant(value, Representation::Integer32()); |
599 constant->InsertAfter(GetConstantUndefined()); | 599 constant->InsertAfter(GetConstantUndefined()); |
600 pointer->set(constant); | 600 pointer->set(constant); |
601 } | 601 } |
602 return pointer->get(); | 602 return pointer->get(); |
603 } | 603 } |
604 | 604 |
605 | 605 |
606 HConstant* HGraph::GetConstantSmi(SetOncePointer<HConstant>* pointer, | |
607 int32_t value) { | |
608 if (!pointer->is_set()) { | |
609 HConstant* constant = | |
610 new(zone()) HConstant(Handle<Object>(Smi::FromInt(value), isolate()), | |
611 Representation::Tagged()); | |
612 constant->InsertAfter(GetConstantUndefined()); | |
613 pointer->set(constant); | |
614 } | |
615 return pointer->get(); | |
616 } | |
617 | |
618 | |
619 HConstant* HGraph::GetConstant0() { | 606 HConstant* HGraph::GetConstant0() { |
620 return GetConstantInt32(&constant_0_, 0); | 607 return GetConstantInt32(&constant_0_, 0); |
621 } | 608 } |
622 | 609 |
623 | 610 |
624 HConstant* HGraph::GetConstant1() { | 611 HConstant* HGraph::GetConstant1() { |
625 return GetConstantInt32(&constant_1_, 1); | 612 return GetConstantInt32(&constant_1_, 1); |
626 } | 613 } |
627 | 614 |
628 | 615 |
(...skipping 19 matching lines...) Expand all Loading... | |
648 return constant_##name##_.get(); \ | 635 return constant_##name##_.get(); \ |
649 } | 636 } |
650 | 637 |
651 | 638 |
652 DEFINE_GET_CONSTANT(True, true, HType::Boolean(), true) | 639 DEFINE_GET_CONSTANT(True, true, HType::Boolean(), true) |
653 DEFINE_GET_CONSTANT(False, false, HType::Boolean(), false) | 640 DEFINE_GET_CONSTANT(False, false, HType::Boolean(), false) |
654 DEFINE_GET_CONSTANT(Hole, the_hole, HType::Tagged(), false) | 641 DEFINE_GET_CONSTANT(Hole, the_hole, HType::Tagged(), false) |
655 DEFINE_GET_CONSTANT(Null, null, HType::Tagged(), false) | 642 DEFINE_GET_CONSTANT(Null, null, HType::Tagged(), false) |
656 | 643 |
657 | 644 |
658 HConstant* HGraph::GetConstantSmi0() { | |
659 return GetConstantSmi(&constant_smi_0_, 0); | |
660 } | |
661 | |
662 | |
663 HConstant* HGraph::GetConstantSmi1() { | |
664 return GetConstantSmi(&constant_smi_1_, 1); | |
665 } | |
666 | |
667 | |
668 #undef DEFINE_GET_CONSTANT | 645 #undef DEFINE_GET_CONSTANT |
669 | 646 |
670 | 647 |
671 HConstant* HGraph::GetInvalidContext() { | 648 HConstant* HGraph::GetInvalidContext() { |
672 return GetConstantInt32(&constant_invalid_context_, 0xFFFFC0C7); | 649 return GetConstantInt32(&constant_invalid_context_, 0xFFFFC0C7); |
673 } | 650 } |
674 | 651 |
675 | 652 |
676 HGraphBuilder::IfBuilder::IfBuilder(HGraphBuilder* builder, int position) | 653 HGraphBuilder::IfBuilder::IfBuilder(HGraphBuilder* builder, int position) |
677 : builder_(builder), | 654 : builder_(builder), |
(...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1555 HConstant* constant_to = HConstant::cast(to); | 1532 HConstant* constant_to = HConstant::cast(to); |
1556 | 1533 |
1557 if (constant_from->HasInteger32Value() && | 1534 if (constant_from->HasInteger32Value() && |
1558 constant_from->Integer32Value() == 0 && | 1535 constant_from->Integer32Value() == 0 && |
1559 constant_to->HasInteger32Value() && | 1536 constant_to->HasInteger32Value() && |
1560 constant_to->Integer32Value() == initial_capacity) { | 1537 constant_to->Integer32Value() == initial_capacity) { |
1561 unfold_loop = true; | 1538 unfold_loop = true; |
1562 } | 1539 } |
1563 } | 1540 } |
1564 | 1541 |
1542 if (IsFastSmiOrObjectElementsKind(elements_kind)) { | |
1543 elements_kind = FAST_HOLEY_ELEMENTS; | |
Jakob Kummerow
2013/05/27 07:15:44
nit: this looks a bit surprising, please add a com
| |
1544 } | |
1565 if (unfold_loop) { | 1545 if (unfold_loop) { |
1566 for (int i = 0; i < initial_capacity; i++) { | 1546 for (int i = 0; i < initial_capacity; i++) { |
1567 HInstruction* key = AddInstruction(new(zone) | 1547 HInstruction* key = AddInstruction(new(zone) |
1568 HConstant(i, Representation::Integer32())); | 1548 HConstant(i, Representation::Integer32())); |
1569 AddInstruction(new(zone) HStoreKeyed(elements, key, hole, elements_kind)); | 1549 AddInstruction(new(zone) HStoreKeyed(elements, key, hole, elements_kind)); |
1570 } | 1550 } |
1571 } else { | 1551 } else { |
1572 LoopBuilder builder(this, context, LoopBuilder::kPostIncrement); | 1552 LoopBuilder builder(this, context, LoopBuilder::kPostIncrement); |
1573 | 1553 |
1574 HValue* key = builder.BeginBody(from, to, Token::LT); | 1554 HValue* key = builder.BeginBody(from, to, Token::LT); |
(...skipping 26 matching lines...) Expand all Loading... | |
1601 | 1581 |
1602 LoopBuilder builder(this, context, LoopBuilder::kPostIncrement); | 1582 LoopBuilder builder(this, context, LoopBuilder::kPostIncrement); |
1603 | 1583 |
1604 HValue* key = builder.BeginBody(graph()->GetConstant0(), length, Token::LT); | 1584 HValue* key = builder.BeginBody(graph()->GetConstant0(), length, Token::LT); |
1605 | 1585 |
1606 HValue* element = | 1586 HValue* element = |
1607 AddInstruction(new(zone()) HLoadKeyed(from_elements, key, NULL, | 1587 AddInstruction(new(zone()) HLoadKeyed(from_elements, key, NULL, |
1608 from_elements_kind, | 1588 from_elements_kind, |
1609 ALLOW_RETURN_HOLE)); | 1589 ALLOW_RETURN_HOLE)); |
1610 | 1590 |
1611 AddInstruction(new(zone()) HStoreKeyed(to_elements, key, element, | 1591 ElementsKind holey_kind = IsFastSmiElementsKind(to_elements_kind) |
1612 to_elements_kind)); | 1592 ? FAST_HOLEY_ELEMENTS : to_elements_kind; |
1593 HInstruction* holey_store = AddInstruction( | |
1594 new(zone()) HStoreKeyed(to_elements, key, element, holey_kind)); | |
1595 holey_store->ClearFlag(HValue::kDeoptimizeOnUndefined); | |
1613 | 1596 |
1614 builder.EndBody(); | 1597 builder.EndBody(); |
1615 | 1598 |
1616 if (!pre_fill_with_holes && length != capacity) { | 1599 if (!pre_fill_with_holes && length != capacity) { |
1617 // Fill unused capacity with the hole. | 1600 // Fill unused capacity with the hole. |
1618 BuildFillElementsWithHole(context, to_elements, to_elements_kind, | 1601 BuildFillElementsWithHole(context, to_elements, to_elements_kind, |
1619 key, capacity); | 1602 key, capacity); |
1620 } | 1603 } |
1621 } | 1604 } |
1622 | 1605 |
(...skipping 10734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
12357 } | 12340 } |
12358 } | 12341 } |
12359 | 12342 |
12360 #ifdef DEBUG | 12343 #ifdef DEBUG |
12361 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 12344 if (graph_ != NULL) graph_->Verify(false); // No full verify. |
12362 if (allocator_ != NULL) allocator_->Verify(); | 12345 if (allocator_ != NULL) allocator_->Verify(); |
12363 #endif | 12346 #endif |
12364 } | 12347 } |
12365 | 12348 |
12366 } } // namespace v8::internal | 12349 } } // namespace v8::internal |
OLD | NEW |