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

Side by Side Diff: src/hydrogen.cc

Issue 22876009: Improve and simplify removal of unreachable code (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix ia32 Created 7 years, 4 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
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 predecessors_(2, graph->zone()), 86 predecessors_(2, graph->zone()),
87 dominator_(NULL), 87 dominator_(NULL),
88 dominated_blocks_(4, graph->zone()), 88 dominated_blocks_(4, graph->zone()),
89 last_environment_(NULL), 89 last_environment_(NULL),
90 argument_count_(-1), 90 argument_count_(-1),
91 first_instruction_index_(-1), 91 first_instruction_index_(-1),
92 last_instruction_index_(-1), 92 last_instruction_index_(-1),
93 deleted_phis_(4, graph->zone()), 93 deleted_phis_(4, graph->zone()),
94 parent_loop_header_(NULL), 94 parent_loop_header_(NULL),
95 inlined_entry_block_(NULL), 95 inlined_entry_block_(NULL),
96 is_reachable_(true),
96 is_inline_return_target_(false), 97 is_inline_return_target_(false),
97 is_deoptimizing_(false), 98 is_deoptimizing_(false),
98 dominates_loop_successors_(false), 99 dominates_loop_successors_(false),
99 is_osr_entry_(false) { } 100 is_osr_entry_(false) { }
100 101
101 102
102 Isolate* HBasicBlock::isolate() const { 103 Isolate* HBasicBlock::isolate() const {
103 return graph_->isolate(); 104 return graph_->isolate();
104 } 105 }
105 106
106 107
108 void HBasicBlock::MarkUnreachable() {
109 if (!is_osr_entry()) {
110 is_reachable_ = false;
111 graph()->MarkHasUnreachableCode();
112 }
113 }
114
115
116 void HBasicBlock::MarkAsDeoptimizing() {
117 is_deoptimizing_ = true;
118 graph()->MarkHasUnreachableCode();
119 }
120
121
107 void HBasicBlock::AttachLoopInformation() { 122 void HBasicBlock::AttachLoopInformation() {
108 ASSERT(!IsLoopHeader()); 123 ASSERT(!IsLoopHeader());
109 loop_information_ = new(zone()) HLoopInformation(this, zone()); 124 loop_information_ = new(zone()) HLoopInformation(this, zone());
110 } 125 }
111 126
112 127
113 void HBasicBlock::DetachLoopInformation() { 128 void HBasicBlock::DetachLoopInformation() {
114 ASSERT(IsLoopHeader()); 129 ASSERT(IsLoopHeader());
115 loop_information_ = NULL; 130 loop_information_ = NULL;
116 } 131 }
(...skipping 1942 matching lines...) Expand 10 before | Expand all | Expand 10 after
2059 : isolate_(info->isolate()), 2074 : isolate_(info->isolate()),
2060 next_block_id_(0), 2075 next_block_id_(0),
2061 entry_block_(NULL), 2076 entry_block_(NULL),
2062 blocks_(8, info->zone()), 2077 blocks_(8, info->zone()),
2063 values_(16, info->zone()), 2078 values_(16, info->zone()),
2064 phi_list_(NULL), 2079 phi_list_(NULL),
2065 uint32_instructions_(NULL), 2080 uint32_instructions_(NULL),
2066 osr_(NULL), 2081 osr_(NULL),
2067 info_(info), 2082 info_(info),
2068 zone_(info->zone()), 2083 zone_(info->zone()),
2084 has_unreachable_code_(false),
2069 is_recursive_(false), 2085 is_recursive_(false),
2070 use_optimistic_licm_(false), 2086 use_optimistic_licm_(false),
2071 has_soft_deoptimize_(false), 2087 has_soft_deoptimize_(false),
2072 depends_on_empty_array_proto_elements_(false), 2088 depends_on_empty_array_proto_elements_(false),
2073 type_change_checksum_(0), 2089 type_change_checksum_(0),
2074 maximum_environment_size_(0), 2090 maximum_environment_size_(0),
2075 no_side_effects_scope_count_(0) { 2091 no_side_effects_scope_count_(0) {
2076 if (info->IsStub()) { 2092 if (info->IsStub()) {
2077 HydrogenCodeStub* stub = info->code_stub(); 2093 HydrogenCodeStub* stub = info->code_stub();
2078 CodeStubInterfaceDescriptor* descriptor = 2094 CodeStubInterfaceDescriptor* descriptor =
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after
2722 2738
2723 void TestContext::BuildBranch(HValue* value) { 2739 void TestContext::BuildBranch(HValue* value) {
2724 // We expect the graph to be in edge-split form: there is no edge that 2740 // We expect the graph to be in edge-split form: there is no edge that
2725 // connects a branch node to a join node. We conservatively ensure that 2741 // connects a branch node to a join node. We conservatively ensure that
2726 // property by always adding an empty block on the outgoing edges of this 2742 // property by always adding an empty block on the outgoing edges of this
2727 // branch. 2743 // branch.
2728 HOptimizedGraphBuilder* builder = owner(); 2744 HOptimizedGraphBuilder* builder = owner();
2729 if (value != NULL && value->CheckFlag(HValue::kIsArguments)) { 2745 if (value != NULL && value->CheckFlag(HValue::kIsArguments)) {
2730 builder->Bailout(kArgumentsObjectValueInATestContext); 2746 builder->Bailout(kArgumentsObjectValueInATestContext);
2731 } 2747 }
2732 if (value->IsConstant()) {
2733 HConstant* constant_value = HConstant::cast(value);
2734 if (constant_value->BooleanValue()) {
2735 builder->current_block()->Goto(if_true(), builder->function_state());
2736 } else {
2737 builder->current_block()->Goto(if_false(), builder->function_state());
2738 }
2739 builder->set_current_block(NULL);
2740 return;
2741 }
2742 HBasicBlock* empty_true = builder->graph()->CreateBasicBlock(); 2748 HBasicBlock* empty_true = builder->graph()->CreateBasicBlock();
2743 HBasicBlock* empty_false = builder->graph()->CreateBasicBlock(); 2749 HBasicBlock* empty_false = builder->graph()->CreateBasicBlock();
2744 ToBooleanStub::Types expected(condition()->to_boolean_types()); 2750 ToBooleanStub::Types expected(condition()->to_boolean_types());
2745 HBranch* test = new(zone()) HBranch(value, expected, empty_true, empty_false); 2751 HBranch* test = new(zone()) HBranch(value, expected, empty_true, empty_false);
2746 builder->current_block()->Finish(test); 2752 builder->current_block()->Finish(test);
2747 2753
2748 empty_true->Goto(if_true(), builder->function_state()); 2754 empty_true->Goto(if_true(), builder->function_state());
2749 empty_false->Goto(if_false(), builder->function_state()); 2755 empty_false->Goto(if_false(), builder->function_state());
2750 builder->set_current_block(NULL); 2756 builder->set_current_block(NULL);
2751 } 2757 }
(...skipping 5258 matching lines...) Expand 10 before | Expand all | Expand 10 after
8010 HValue* value = Pop(); 8016 HValue* value = Pop();
8011 HTypeofIsAndBranch* instr = new(zone()) HTypeofIsAndBranch(value, check); 8017 HTypeofIsAndBranch* instr = new(zone()) HTypeofIsAndBranch(value, check);
8012 instr->set_position(expr->position()); 8018 instr->set_position(expr->position());
8013 return ast_context()->ReturnControl(instr, expr->id()); 8019 return ast_context()->ReturnControl(instr, expr->id());
8014 } 8020 }
8015 8021
8016 8022
8017 static bool IsLiteralCompareBool(HValue* left, 8023 static bool IsLiteralCompareBool(HValue* left,
8018 Token::Value op, 8024 Token::Value op,
8019 HValue* right) { 8025 HValue* right) {
8020 return op == Token::EQ_STRICT && 8026 if (op != Token::EQ_STRICT) return false;
8021 ((left->IsConstant() && HConstant::cast(left)->handle()->IsBoolean()) || 8027 if (left->IsConstant() && HConstant::cast(left)->handle()->IsBoolean()) {
8022 (right->IsConstant() && HConstant::cast(right)->handle()->IsBoolean())); 8028 return !right->IsConstant() ||
Michael Starzinger 2013/08/16 15:02:20 nit: Should fit into one line.
danno 2013/10/01 10:43:18 Done.
8029 !HConstant::cast(right)->handle()->IsSmi();
8030 }
8031 if (right->IsConstant() && HConstant::cast(right)->handle()->IsBoolean()) {
8032 return !left->IsConstant() ||
Michael Starzinger 2013/08/16 15:02:20 nit: Should fit into one line.
danno 2013/10/01 10:43:18 Done.
8033 !HConstant::cast(left)->handle()->IsSmi();
8034 }
8035 return false;
8023 } 8036 }
8024 8037
8025 8038
8026 void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) { 8039 void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) {
8027 ASSERT(!HasStackOverflow()); 8040 ASSERT(!HasStackOverflow());
8028 ASSERT(current_block() != NULL); 8041 ASSERT(current_block() != NULL);
8029 ASSERT(current_block()->HasPredecessor()); 8042 ASSERT(current_block()->HasPredecessor());
8030 8043
8031 // Check for a few fast cases. The AST visiting behavior must be in sync 8044 // Check for a few fast cases. The AST visiting behavior must be in sync
8032 // with the full codegen: We don't push both left and right values onto 8045 // with the full codegen: We don't push both left and right values onto
(...skipping 1810 matching lines...) Expand 10 before | Expand all | Expand 10 after
9843 if (ShouldProduceTraceOutput()) { 9856 if (ShouldProduceTraceOutput()) {
9844 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 9857 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
9845 } 9858 }
9846 9859
9847 #ifdef DEBUG 9860 #ifdef DEBUG
9848 graph_->Verify(false); // No full verify. 9861 graph_->Verify(false); // No full verify.
9849 #endif 9862 #endif
9850 } 9863 }
9851 9864
9852 } } // namespace v8::internal 9865 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | src/hydrogen-instructions.h » ('j') | src/hydrogen-instructions.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698