Chromium Code Reviews| 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 2122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2133 } | 2133 } |
| 2134 } | 2134 } |
| 2135 | 2135 |
| 2136 | 2136 |
| 2137 Representation HInferRepresentation::TryChange(HValue* value) { | 2137 Representation HInferRepresentation::TryChange(HValue* value) { |
| 2138 // Array of use counts for each representation. | 2138 // Array of use counts for each representation. |
| 2139 int use_count[Representation::kNumRepresentations] = { 0 }; | 2139 int use_count[Representation::kNumRepresentations] = { 0 }; |
| 2140 | 2140 |
| 2141 for (HUseIterator it(value->uses()); !it.Done(); it.Advance()) { | 2141 for (HUseIterator it(value->uses()); !it.Done(); it.Advance()) { |
| 2142 HValue* use = it.value(); | 2142 HValue* use = it.value(); |
| 2143 Representation rep = use->RequiredInputRepresentation(it.index()); | 2143 Representation rep = use->ObservedInputRepresentation(it.index()); |
| 2144 if (rep.IsNone()) continue; | 2144 if (rep.IsNone()) continue; |
| 2145 if (FLAG_trace_representation) { | |
| 2146 PrintF("%d %s is used by %d %s as %s\n", | |
| 2147 value->id(), | |
| 2148 value->Mnemonic(), | |
| 2149 use->id(), | |
| 2150 use->Mnemonic(), | |
| 2151 rep.Mnemonic()); | |
| 2152 } | |
| 2145 if (use->IsPhi()) HPhi::cast(use)->AddIndirectUsesTo(&use_count[0]); | 2153 if (use->IsPhi()) HPhi::cast(use)->AddIndirectUsesTo(&use_count[0]); |
| 2146 use_count[rep.kind()] += use->LoopWeight(); | 2154 use_count[rep.kind()] += use->LoopWeight(); |
| 2147 } | 2155 } |
| 2148 int tagged_count = use_count[Representation::kTagged]; | 2156 int tagged_count = use_count[Representation::kTagged]; |
| 2149 int double_count = use_count[Representation::kDouble]; | 2157 int double_count = use_count[Representation::kDouble]; |
| 2150 int int32_count = use_count[Representation::kInteger32]; | 2158 int int32_count = use_count[Representation::kInteger32]; |
| 2151 int non_tagged_count = double_count + int32_count; | 2159 int non_tagged_count = double_count + int32_count; |
| 2152 | 2160 |
| 2153 // If a non-loop phi has tagged uses, don't convert it to untagged. | 2161 // If a non-loop phi has tagged uses, don't convert it to untagged. |
| 2154 if (value->IsPhi() && !value->block()->IsLoopHeader() && tagged_count > 0) { | 2162 if (value->IsPhi() && !value->block()->IsLoopHeader() && tagged_count > 0) { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2198 HValue* use = it.value(); | 2206 HValue* use = it.value(); |
| 2199 if (use->IsPhi()) { | 2207 if (use->IsPhi()) { |
| 2200 int id = HPhi::cast(use)->phi_id(); | 2208 int id = HPhi::cast(use)->phi_id(); |
| 2201 if (connected_phis[i]->UnionIsChanged(*connected_phis[id])) | 2209 if (connected_phis[i]->UnionIsChanged(*connected_phis[id])) |
| 2202 change = true; | 2210 change = true; |
| 2203 } | 2211 } |
| 2204 } | 2212 } |
| 2205 } | 2213 } |
| 2206 } | 2214 } |
| 2207 | 2215 |
| 2208 // (3) Use the phi reachability information from step 2 to | 2216 // (3a) Use the phi reachability information from step 2 to |
| 2209 // (a) sum up the non-phi use counts of all connected phis. | 2217 // push information about values which can't be converted to integer |
|
Jakob Kummerow
2012/06/07 15:38:05
nit: indentation
| |
| 2210 // (b) push information about values which can't be converted to integer | |
| 2211 // without deoptimization through the phi use-def chains, avoiding | 2218 // without deoptimization through the phi use-def chains, avoiding |
| 2212 // unnecessary deoptimizations later. | 2219 // unnecessary deoptimizations later. |
| 2213 for (int i = 0; i < phi_count; ++i) { | 2220 for (int i = 0; i < phi_count; ++i) { |
| 2214 HPhi* phi = phi_list->at(i); | 2221 HPhi* phi = phi_list->at(i); |
| 2215 bool cti = phi->AllOperandsConvertibleToInteger(); | 2222 bool cti = phi->AllOperandsConvertibleToInteger(); |
| 2223 if (cti) continue; | |
| 2224 | |
| 2225 for (BitVector::Iterator it(connected_phis.at(i)); | |
| 2226 !it.Done(); | |
| 2227 it.Advance()) { | |
| 2228 phi_list->at(it.Current())->set_is_convertible_to_integer(false); | |
| 2229 } | |
| 2230 } | |
| 2231 | |
| 2232 // (3b) Use the phi reachability information from step 2 to | |
| 2233 // sum up the non-phi use counts of all connected phis. | |
|
Jakob Kummerow
2012/06/07 15:38:05
nit: indentation
| |
| 2234 for (int i = 0; i < phi_count; ++i) { | |
| 2235 HPhi* phi = phi_list->at(i); | |
| 2216 for (BitVector::Iterator it(connected_phis.at(i)); | 2236 for (BitVector::Iterator it(connected_phis.at(i)); |
| 2217 !it.Done(); | 2237 !it.Done(); |
| 2218 it.Advance()) { | 2238 it.Advance()) { |
| 2219 int index = it.Current(); | 2239 int index = it.Current(); |
| 2220 HPhi* it_use = phi_list->at(it.Current()); | 2240 HPhi* it_use = phi_list->at(index); |
| 2221 if (index != i) phi->AddNonPhiUsesFrom(it_use); // Don't count twice! | 2241 if (index != i) phi->AddNonPhiUsesFrom(it_use); // Don't count twice. |
| 2222 if (!cti) it_use->set_is_convertible_to_integer(false); | |
| 2223 } | 2242 } |
| 2224 } | 2243 } |
| 2225 | 2244 |
| 2226 // Initialize work list | 2245 // Initialize work list |
| 2227 for (int i = 0; i < graph_->blocks()->length(); ++i) { | 2246 for (int i = 0; i < graph_->blocks()->length(); ++i) { |
| 2228 HBasicBlock* block = graph_->blocks()->at(i); | 2247 HBasicBlock* block = graph_->blocks()->at(i); |
| 2229 const ZoneList<HPhi*>* phis = block->phis(); | 2248 const ZoneList<HPhi*>* phis = block->phis(); |
| 2230 for (int j = 0; j < phis->length(); ++j) { | 2249 for (int j = 0; j < phis->length(); ++j) { |
| 2231 AddToWorklist(phis->at(j)); | 2250 AddToWorklist(phis->at(j)); |
| 2232 } | 2251 } |
| (...skipping 5263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7496 // If we hit an uninitialized binary op stub we will get type info | 7515 // If we hit an uninitialized binary op stub we will get type info |
| 7497 // for a smi operation. If one of the operands is a constant string | 7516 // for a smi operation. If one of the operands is a constant string |
| 7498 // do not generate code assuming it is a smi operation. | 7517 // do not generate code assuming it is a smi operation. |
| 7499 if (info.IsSmi() && | 7518 if (info.IsSmi() && |
| 7500 ((left->IsConstant() && HConstant::cast(left)->HasStringValue()) || | 7519 ((left->IsConstant() && HConstant::cast(left)->HasStringValue()) || |
| 7501 (right->IsConstant() && HConstant::cast(right)->HasStringValue()))) { | 7520 (right->IsConstant() && HConstant::cast(right)->HasStringValue()))) { |
| 7502 return instr; | 7521 return instr; |
| 7503 } | 7522 } |
| 7504 Representation rep = ToRepresentation(info); | 7523 Representation rep = ToRepresentation(info); |
| 7505 // We only generate either int32 or generic tagged bitwise operations. | 7524 // We only generate either int32 or generic tagged bitwise operations. |
| 7506 if (instr->IsBitwiseBinaryOperation() && rep.IsDouble()) { | 7525 if (instr->IsBitwiseBinaryOperation()) { |
| 7507 rep = Representation::Integer32(); | 7526 HBitwiseBinaryOperation::cast(instr)-> |
| 7527 InitializeObservedInputRepresentation(rep); | |
| 7528 if (rep.IsDouble()) rep = Representation::Integer32(); | |
| 7508 } | 7529 } |
| 7509 TraceRepresentation(expr->op(), info, instr, rep); | 7530 TraceRepresentation(expr->op(), info, instr, rep); |
| 7510 instr->AssumeRepresentation(rep); | 7531 instr->AssumeRepresentation(rep); |
| 7511 return instr; | 7532 return instr; |
| 7512 } | 7533 } |
| 7513 | 7534 |
| 7514 | 7535 |
| 7515 // Check for the form (%_ClassOf(foo) === 'BarClass'). | 7536 // Check for the form (%_ClassOf(foo) === 'BarClass'). |
| 7516 static bool IsClassOfTest(CompareOperation* expr) { | 7537 static bool IsClassOfTest(CompareOperation* expr) { |
| 7517 if (expr->op() != Token::EQ_STRICT) return false; | 7538 if (expr->op() != Token::EQ_STRICT) return false; |
| (...skipping 1609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9127 } | 9148 } |
| 9128 } | 9149 } |
| 9129 | 9150 |
| 9130 #ifdef DEBUG | 9151 #ifdef DEBUG |
| 9131 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 9152 if (graph_ != NULL) graph_->Verify(false); // No full verify. |
| 9132 if (allocator_ != NULL) allocator_->Verify(); | 9153 if (allocator_ != NULL) allocator_->Verify(); |
| 9133 #endif | 9154 #endif |
| 9134 } | 9155 } |
| 9135 | 9156 |
| 9136 } } // namespace v8::internal | 9157 } } // namespace v8::internal |
| OLD | NEW |