Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Side by Side Diff: src/hydrogen.cc

Issue 15861009: Tag smi-constants as smi. This also fixes code that copies holes into arrays. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/hydrogen.h ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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 // Since we're about to store a hole value, the store instruction below must
1543 // assume an elements kind that supports heap object values.
1544 if (IsFastSmiOrObjectElementsKind(elements_kind)) {
1545 elements_kind = FAST_HOLEY_ELEMENTS;
1546 }
1547
1565 if (unfold_loop) { 1548 if (unfold_loop) {
1566 for (int i = 0; i < initial_capacity; i++) { 1549 for (int i = 0; i < initial_capacity; i++) {
1567 HInstruction* key = AddInstruction(new(zone) 1550 HInstruction* key = AddInstruction(new(zone)
1568 HConstant(i, Representation::Integer32())); 1551 HConstant(i, Representation::Integer32()));
1569 AddInstruction(new(zone) HStoreKeyed(elements, key, hole, elements_kind)); 1552 AddInstruction(new(zone) HStoreKeyed(elements, key, hole, elements_kind));
1570 } 1553 }
1571 } else { 1554 } else {
1572 LoopBuilder builder(this, context, LoopBuilder::kPostIncrement); 1555 LoopBuilder builder(this, context, LoopBuilder::kPostIncrement);
1573 1556
1574 HValue* key = builder.BeginBody(from, to, Token::LT); 1557 HValue* key = builder.BeginBody(from, to, Token::LT);
(...skipping 26 matching lines...) Expand all
1601 1584
1602 LoopBuilder builder(this, context, LoopBuilder::kPostIncrement); 1585 LoopBuilder builder(this, context, LoopBuilder::kPostIncrement);
1603 1586
1604 HValue* key = builder.BeginBody(graph()->GetConstant0(), length, Token::LT); 1587 HValue* key = builder.BeginBody(graph()->GetConstant0(), length, Token::LT);
1605 1588
1606 HValue* element = 1589 HValue* element =
1607 AddInstruction(new(zone()) HLoadKeyed(from_elements, key, NULL, 1590 AddInstruction(new(zone()) HLoadKeyed(from_elements, key, NULL,
1608 from_elements_kind, 1591 from_elements_kind,
1609 ALLOW_RETURN_HOLE)); 1592 ALLOW_RETURN_HOLE));
1610 1593
1611 AddInstruction(new(zone()) HStoreKeyed(to_elements, key, element, 1594 ElementsKind holey_kind = IsFastSmiElementsKind(to_elements_kind)
1612 to_elements_kind)); 1595 ? FAST_HOLEY_ELEMENTS : to_elements_kind;
1596 HInstruction* holey_store = AddInstruction(
1597 new(zone()) HStoreKeyed(to_elements, key, element, holey_kind));
1598 holey_store->ClearFlag(HValue::kDeoptimizeOnUndefined);
1613 1599
1614 builder.EndBody(); 1600 builder.EndBody();
1615 1601
1616 if (!pre_fill_with_holes && length != capacity) { 1602 if (!pre_fill_with_holes && length != capacity) {
1617 // Fill unused capacity with the hole. 1603 // Fill unused capacity with the hole.
1618 BuildFillElementsWithHole(context, to_elements, to_elements_kind, 1604 BuildFillElementsWithHole(context, to_elements, to_elements_kind,
1619 key, capacity); 1605 key, capacity);
1620 } 1606 }
1621 } 1607 }
1622 1608
(...skipping 10734 matching lines...) Expand 10 before | Expand all | Expand 10 after
12357 } 12343 }
12358 } 12344 }
12359 12345
12360 #ifdef DEBUG 12346 #ifdef DEBUG
12361 if (graph_ != NULL) graph_->Verify(false); // No full verify. 12347 if (graph_ != NULL) graph_->Verify(false); // No full verify.
12362 if (allocator_ != NULL) allocator_->Verify(); 12348 if (allocator_ != NULL) allocator_->Verify();
12363 #endif 12349 #endif
12364 } 12350 }
12365 12351
12366 } } // namespace v8::internal 12352 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698