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 1490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1501 expected_input_types_(expected_input_types) { | 1501 expected_input_types_(expected_input_types) { |
1502 SetFlag(kAllowUndefinedAsNaN); | 1502 SetFlag(kAllowUndefinedAsNaN); |
1503 } | 1503 } |
1504 | 1504 |
1505 ToBooleanStub::Types expected_input_types_; | 1505 ToBooleanStub::Types expected_input_types_; |
1506 }; | 1506 }; |
1507 | 1507 |
1508 | 1508 |
1509 class HCompareMap V8_FINAL : public HUnaryControlInstruction { | 1509 class HCompareMap V8_FINAL : public HUnaryControlInstruction { |
1510 public: | 1510 public: |
1511 DECLARE_INSTRUCTION_FACTORY_P3(HCompareMap, HValue*, Handle<Map>, | 1511 DECLARE_INSTRUCTION_FACTORY_P2(HCompareMap, HValue*, Handle<Map>); |
1512 CompilationInfo*); | 1512 DECLARE_INSTRUCTION_FACTORY_P4(HCompareMap, HValue*, Handle<Map>, |
1513 DECLARE_INSTRUCTION_FACTORY_P5(HCompareMap, HValue*, Handle<Map>, | |
1514 CompilationInfo*, | |
1515 HBasicBlock*, HBasicBlock*); | 1513 HBasicBlock*, HBasicBlock*); |
1516 | 1514 |
1517 virtual bool KnownSuccessorBlock(HBasicBlock** block) V8_OVERRIDE { | 1515 virtual bool KnownSuccessorBlock(HBasicBlock** block) V8_OVERRIDE { |
1518 if (known_successor_index() != kNoKnownSuccessorIndex) { | 1516 if (known_successor_index() != kNoKnownSuccessorIndex) { |
1519 *block = SuccessorAt(known_successor_index()); | 1517 *block = SuccessorAt(known_successor_index()); |
1520 return true; | 1518 return true; |
1521 } | 1519 } |
1522 *block = NULL; | 1520 *block = NULL; |
1523 return false; | 1521 return false; |
1524 } | 1522 } |
1525 | 1523 |
1526 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE; | 1524 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE; |
1527 | 1525 |
1528 static const int kNoKnownSuccessorIndex = -1; | 1526 static const int kNoKnownSuccessorIndex = -1; |
1529 int known_successor_index() const { return known_successor_index_; } | 1527 int known_successor_index() const { return known_successor_index_; } |
1530 void set_known_successor_index(int known_successor_index) { | 1528 void set_known_successor_index(int known_successor_index) { |
1531 known_successor_index_ = known_successor_index; | 1529 known_successor_index_ = known_successor_index; |
1532 } | 1530 } |
1533 | 1531 |
1534 Unique<Map> map() const { return map_; } | 1532 Unique<Map> map() const { return map_; } |
1535 | 1533 |
1536 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { | 1534 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { |
1537 return Representation::Tagged(); | 1535 return Representation::Tagged(); |
1538 } | 1536 } |
1539 | 1537 |
1540 bool is_stable() const { | |
1541 return is_stable_; | |
1542 } | |
1543 | |
1544 DECLARE_CONCRETE_INSTRUCTION(CompareMap) | 1538 DECLARE_CONCRETE_INSTRUCTION(CompareMap) |
1545 | 1539 |
1546 protected: | 1540 protected: |
1547 virtual int RedefinedOperandIndex() { return 0; } | 1541 virtual int RedefinedOperandIndex() { return 0; } |
1548 | 1542 |
1549 private: | 1543 private: |
1550 HCompareMap(HValue* value, | 1544 HCompareMap(HValue* value, |
1551 Handle<Map> map, | 1545 Handle<Map> map, |
1552 CompilationInfo* info, | |
1553 HBasicBlock* true_target = NULL, | 1546 HBasicBlock* true_target = NULL, |
1554 HBasicBlock* false_target = NULL) | 1547 HBasicBlock* false_target = NULL) |
1555 : HUnaryControlInstruction(value, true_target, false_target), | 1548 : HUnaryControlInstruction(value, true_target, false_target), |
1556 known_successor_index_(kNoKnownSuccessorIndex), map_(Unique<Map>(map)) { | 1549 known_successor_index_(kNoKnownSuccessorIndex), map_(Unique<Map>(map)) { |
1557 ASSERT(!map.is_null()); | 1550 ASSERT(!map.is_null()); |
1558 is_stable_ = map->is_stable(); | |
1559 | |
1560 if (FLAG_check_elimination && is_stable_) { | |
1561 map->AddDependentCompilationInfo( | |
1562 DependentCode::kPrototypeCheckGroup, info); | |
1563 } | |
1564 } | 1551 } |
1565 | 1552 |
1566 int known_successor_index_; | 1553 int known_successor_index_; |
1567 bool is_stable_; | |
1568 Unique<Map> map_; | 1554 Unique<Map> map_; |
1569 }; | 1555 }; |
1570 | 1556 |
1571 | 1557 |
1572 class HContext V8_FINAL : public HTemplateInstruction<0> { | 1558 class HContext V8_FINAL : public HTemplateInstruction<0> { |
1573 public: | 1559 public: |
1574 static HContext* New(Zone* zone) { | 1560 static HContext* New(Zone* zone) { |
1575 return new(zone) HContext(); | 1561 return new(zone) HContext(); |
1576 } | 1562 } |
1577 | 1563 |
(...skipping 1062 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2640 }; | 2626 }; |
2641 | 2627 |
2642 | 2628 |
2643 class HCheckMaps V8_FINAL : public HTemplateInstruction<2> { | 2629 class HCheckMaps V8_FINAL : public HTemplateInstruction<2> { |
2644 public: | 2630 public: |
2645 static HCheckMaps* New(Zone* zone, HValue* context, HValue* value, | 2631 static HCheckMaps* New(Zone* zone, HValue* context, HValue* value, |
2646 Handle<Map> map, CompilationInfo* info, | 2632 Handle<Map> map, CompilationInfo* info, |
2647 HValue* typecheck = NULL); | 2633 HValue* typecheck = NULL); |
2648 static HCheckMaps* New(Zone* zone, HValue* context, | 2634 static HCheckMaps* New(Zone* zone, HValue* context, |
2649 HValue* value, SmallMapList* maps, | 2635 HValue* value, SmallMapList* maps, |
2650 CompilationInfo* info, | |
2651 HValue* typecheck = NULL) { | 2636 HValue* typecheck = NULL) { |
2652 HCheckMaps* check_map = new(zone) HCheckMaps(value, zone, typecheck); | 2637 HCheckMaps* check_map = new(zone) HCheckMaps(value, zone, typecheck); |
2653 for (int i = 0; i < maps->length(); i++) { | 2638 for (int i = 0; i < maps->length(); i++) { |
2654 check_map->Add(maps->at(i), info, zone); | 2639 check_map->Add(maps->at(i), zone); |
2655 } | 2640 } |
2656 return check_map; | 2641 return check_map; |
2657 } | 2642 } |
2658 | 2643 |
2659 bool CanOmitMapChecks() { return omit_; } | 2644 bool CanOmitMapChecks() { return omit_; } |
2660 | 2645 |
2661 virtual bool HasEscapingOperandAt(int index) V8_OVERRIDE { return false; } | 2646 virtual bool HasEscapingOperandAt(int index) V8_OVERRIDE { return false; } |
2662 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { | 2647 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { |
2663 return Representation::Tagged(); | 2648 return Representation::Tagged(); |
2664 } | 2649 } |
(...skipping 11 matching lines...) Expand all Loading... |
2676 map_set_.Clear(); | 2661 map_set_.Clear(); |
2677 for (int i = 0; i < maps->size(); i++) { | 2662 for (int i = 0; i < maps->size(); i++) { |
2678 map_set_.Add(maps->at(i), zone); | 2663 map_set_.Add(maps->at(i), zone); |
2679 } | 2664 } |
2680 } | 2665 } |
2681 | 2666 |
2682 bool has_migration_target() const { | 2667 bool has_migration_target() const { |
2683 return has_migration_target_; | 2668 return has_migration_target_; |
2684 } | 2669 } |
2685 | 2670 |
2686 bool is_stable() const { | |
2687 return is_stable_; | |
2688 } | |
2689 | |
2690 DECLARE_CONCRETE_INSTRUCTION(CheckMaps) | 2671 DECLARE_CONCRETE_INSTRUCTION(CheckMaps) |
2691 | 2672 |
2692 protected: | 2673 protected: |
2693 virtual bool DataEquals(HValue* other) V8_OVERRIDE { | 2674 virtual bool DataEquals(HValue* other) V8_OVERRIDE { |
2694 return this->map_set_.Equals(&HCheckMaps::cast(other)->map_set_); | 2675 return this->map_set_.Equals(&HCheckMaps::cast(other)->map_set_); |
2695 } | 2676 } |
2696 | 2677 |
2697 virtual int RedefinedOperandIndex() { return 0; } | 2678 virtual int RedefinedOperandIndex() { return 0; } |
2698 | 2679 |
2699 private: | 2680 private: |
2700 void Add(Handle<Map> map, CompilationInfo* info, Zone* zone) { | 2681 void Add(Handle<Map> map, Zone* zone) { |
2701 map_set_.Add(Unique<Map>(map), zone); | 2682 map_set_.Add(Unique<Map>(map), zone); |
2702 is_stable_ = is_stable_ && map->is_stable(); | |
2703 | |
2704 if (FLAG_check_elimination && is_stable_) { | |
2705 map->AddDependentCompilationInfo( | |
2706 DependentCode::kPrototypeCheckGroup, info); | |
2707 } | |
2708 | |
2709 if (!has_migration_target_ && map->is_migration_target()) { | 2683 if (!has_migration_target_ && map->is_migration_target()) { |
2710 has_migration_target_ = true; | 2684 has_migration_target_ = true; |
2711 SetChangesFlag(kNewSpacePromotion); | 2685 SetChangesFlag(kNewSpacePromotion); |
2712 } | 2686 } |
2713 } | 2687 } |
2714 | 2688 |
2715 // Clients should use one of the static New* methods above. | 2689 // Clients should use one of the static New* methods above. |
2716 HCheckMaps(HValue* value, Zone *zone, HValue* typecheck) | 2690 HCheckMaps(HValue* value, Zone *zone, HValue* typecheck) |
2717 : HTemplateInstruction<2>(value->type()), | 2691 : HTemplateInstruction<2>(value->type()), |
2718 omit_(false), has_migration_target_(false), is_stable_(true) { | 2692 omit_(false), has_migration_target_(false) { |
2719 SetOperandAt(0, value); | 2693 SetOperandAt(0, value); |
2720 // Use the object value for the dependency if NULL is passed. | 2694 // Use the object value for the dependency if NULL is passed. |
2721 SetOperandAt(1, typecheck != NULL ? typecheck : value); | 2695 SetOperandAt(1, typecheck != NULL ? typecheck : value); |
2722 set_representation(Representation::Tagged()); | 2696 set_representation(Representation::Tagged()); |
2723 SetFlag(kUseGVN); | 2697 SetFlag(kUseGVN); |
2724 SetFlag(kTrackSideEffectDominators); | 2698 SetFlag(kTrackSideEffectDominators); |
2725 SetDependsOnFlag(kMaps); | 2699 SetDependsOnFlag(kMaps); |
2726 SetDependsOnFlag(kElementsKind); | 2700 SetDependsOnFlag(kElementsKind); |
2727 } | 2701 } |
2728 | 2702 |
2729 bool omit_; | 2703 bool omit_; |
2730 bool has_migration_target_; | 2704 bool has_migration_target_; |
2731 bool is_stable_; | |
2732 UniqueSet<Map> map_set_; | 2705 UniqueSet<Map> map_set_; |
2733 }; | 2706 }; |
2734 | 2707 |
2735 | 2708 |
2736 class HCheckValue V8_FINAL : public HUnaryOperation { | 2709 class HCheckValue V8_FINAL : public HUnaryOperation { |
2737 public: | 2710 public: |
2738 static HCheckValue* New(Zone* zone, HValue* context, | 2711 static HCheckValue* New(Zone* zone, HValue* context, |
2739 HValue* value, Handle<JSFunction> func) { | 2712 HValue* value, Handle<JSFunction> func) { |
2740 bool in_new_space = zone->isolate()->heap()->InNewSpace(*func); | 2713 bool in_new_space = zone->isolate()->heap()->InNewSpace(*func); |
2741 // NOTE: We create an uninitialized Unique and initialize it later. | 2714 // NOTE: We create an uninitialized Unique and initialize it later. |
(...skipping 3755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6497 } | 6470 } |
6498 | 6471 |
6499 void SetTransition(HConstant* map_constant, CompilationInfo* info) { | 6472 void SetTransition(HConstant* map_constant, CompilationInfo* info) { |
6500 ASSERT(!has_transition()); // Only set once. | 6473 ASSERT(!has_transition()); // Only set once. |
6501 Handle<Map> map = Handle<Map>::cast(map_constant->handle(info->isolate())); | 6474 Handle<Map> map = Handle<Map>::cast(map_constant->handle(info->isolate())); |
6502 if (map->CanBeDeprecated()) { | 6475 if (map->CanBeDeprecated()) { |
6503 map->AddDependentCompilationInfo(DependentCode::kTransitionGroup, info); | 6476 map->AddDependentCompilationInfo(DependentCode::kTransitionGroup, info); |
6504 } | 6477 } |
6505 SetOperandAt(2, map_constant); | 6478 SetOperandAt(2, map_constant); |
6506 has_transition_ = true; | 6479 has_transition_ = true; |
6507 is_stable_ = map->is_stable(); | |
6508 | |
6509 if (FLAG_check_elimination && is_stable_) { | |
6510 map->AddDependentCompilationInfo( | |
6511 DependentCode::kPrototypeCheckGroup, info); | |
6512 } | |
6513 } | |
6514 | |
6515 bool is_stable() const { | |
6516 return is_stable_; | |
6517 } | 6480 } |
6518 | 6481 |
6519 bool NeedsWriteBarrier() { | 6482 bool NeedsWriteBarrier() { |
6520 ASSERT(!(FLAG_track_double_fields && field_representation().IsDouble()) || | 6483 ASSERT(!(FLAG_track_double_fields && field_representation().IsDouble()) || |
6521 !has_transition()); | 6484 !has_transition()); |
6522 if (IsSkipWriteBarrier()) return false; | 6485 if (IsSkipWriteBarrier()) return false; |
6523 if (field_representation().IsDouble()) return false; | 6486 if (field_representation().IsDouble()) return false; |
6524 if (field_representation().IsSmi()) return false; | 6487 if (field_representation().IsSmi()) return false; |
6525 if (field_representation().IsInteger32()) return false; | 6488 if (field_representation().IsInteger32()) return false; |
6526 if (field_representation().IsExternal()) return false; | 6489 if (field_representation().IsExternal()) return false; |
(...skipping 18 matching lines...) Expand all Loading... |
6545 | 6508 |
6546 private: | 6509 private: |
6547 HStoreNamedField(HValue* obj, | 6510 HStoreNamedField(HValue* obj, |
6548 HObjectAccess access, | 6511 HObjectAccess access, |
6549 HValue* val, | 6512 HValue* val, |
6550 StoreFieldOrKeyedMode store_mode = INITIALIZING_STORE) | 6513 StoreFieldOrKeyedMode store_mode = INITIALIZING_STORE) |
6551 : access_(access), | 6514 : access_(access), |
6552 new_space_dominator_(NULL), | 6515 new_space_dominator_(NULL), |
6553 write_barrier_mode_(UPDATE_WRITE_BARRIER), | 6516 write_barrier_mode_(UPDATE_WRITE_BARRIER), |
6554 has_transition_(false), | 6517 has_transition_(false), |
6555 is_stable_(false), | |
6556 store_mode_(store_mode) { | 6518 store_mode_(store_mode) { |
6557 // Stores to a non existing in-object property are allowed only to the | 6519 // Stores to a non existing in-object property are allowed only to the |
6558 // newly allocated objects (via HAllocate or HInnerAllocatedObject). | 6520 // newly allocated objects (via HAllocate or HInnerAllocatedObject). |
6559 ASSERT(!access.IsInobject() || access.existing_inobject_property() || | 6521 ASSERT(!access.IsInobject() || access.existing_inobject_property() || |
6560 obj->IsAllocate() || obj->IsInnerAllocatedObject()); | 6522 obj->IsAllocate() || obj->IsInnerAllocatedObject()); |
6561 SetOperandAt(0, obj); | 6523 SetOperandAt(0, obj); |
6562 SetOperandAt(1, val); | 6524 SetOperandAt(1, val); |
6563 SetOperandAt(2, obj); | 6525 SetOperandAt(2, obj); |
6564 access.SetGVNFlags(this, STORE); | 6526 access.SetGVNFlags(this, STORE); |
6565 } | 6527 } |
6566 | 6528 |
6567 HObjectAccess access_; | 6529 HObjectAccess access_; |
6568 HValue* new_space_dominator_; | 6530 HValue* new_space_dominator_; |
6569 WriteBarrierMode write_barrier_mode_ : 1; | 6531 WriteBarrierMode write_barrier_mode_ : 1; |
6570 bool has_transition_ : 1; | 6532 bool has_transition_ : 1; |
6571 bool is_stable_ : 1; | |
6572 StoreFieldOrKeyedMode store_mode_ : 1; | 6533 StoreFieldOrKeyedMode store_mode_ : 1; |
6573 }; | 6534 }; |
6574 | 6535 |
6575 | 6536 |
6576 class HStoreNamedGeneric V8_FINAL : public HTemplateInstruction<3> { | 6537 class HStoreNamedGeneric V8_FINAL : public HTemplateInstruction<3> { |
6577 public: | 6538 public: |
6578 DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P4(HStoreNamedGeneric, HValue*, | 6539 DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P4(HStoreNamedGeneric, HValue*, |
6579 Handle<String>, HValue*, | 6540 Handle<String>, HValue*, |
6580 StrictModeFlag); | 6541 StrictModeFlag); |
6581 HValue* object() { return OperandAt(0); } | 6542 HValue* object() { return OperandAt(0); } |
(...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7455 virtual bool IsDeletable() const V8_OVERRIDE { return true; } | 7416 virtual bool IsDeletable() const V8_OVERRIDE { return true; } |
7456 }; | 7417 }; |
7457 | 7418 |
7458 | 7419 |
7459 #undef DECLARE_INSTRUCTION | 7420 #undef DECLARE_INSTRUCTION |
7460 #undef DECLARE_CONCRETE_INSTRUCTION | 7421 #undef DECLARE_CONCRETE_INSTRUCTION |
7461 | 7422 |
7462 } } // namespace v8::internal | 7423 } } // namespace v8::internal |
7463 | 7424 |
7464 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 7425 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
OLD | NEW |