| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 namespace internal { | 47 namespace internal { |
| 48 | 48 |
| 49 #define DEFINE_COMPILE(type) \ | 49 #define DEFINE_COMPILE(type) \ |
| 50 LInstruction* H##type::CompileToLithium(LChunkBuilder* builder) { \ | 50 LInstruction* H##type::CompileToLithium(LChunkBuilder* builder) { \ |
| 51 return builder->Do##type(this); \ | 51 return builder->Do##type(this); \ |
| 52 } | 52 } |
| 53 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DEFINE_COMPILE) | 53 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DEFINE_COMPILE) |
| 54 #undef DEFINE_COMPILE | 54 #undef DEFINE_COMPILE |
| 55 | 55 |
| 56 | 56 |
| 57 int HValue::LoopWeight() const { | |
| 58 const int w = FLAG_loop_weight; | |
| 59 static const int weights[] = { 1, w, w*w, w*w*w, w*w*w*w }; | |
| 60 return weights[Min(block()->LoopNestingDepth(), | |
| 61 static_cast<int>(ARRAY_SIZE(weights)-1))]; | |
| 62 } | |
| 63 | |
| 64 | |
| 65 Isolate* HValue::isolate() const { | 57 Isolate* HValue::isolate() const { |
| 66 ASSERT(block() != NULL); | 58 ASSERT(block() != NULL); |
| 67 return block()->isolate(); | 59 return block()->isolate(); |
| 68 } | 60 } |
| 69 | 61 |
| 70 | 62 |
| 71 void HValue::AssumeRepresentation(Representation r) { | 63 void HValue::AssumeRepresentation(Representation r) { |
| 72 if (CheckFlag(kFlexibleRepresentation)) { | 64 if (CheckFlag(kFlexibleRepresentation)) { |
| 73 ChangeRepresentation(r); | 65 ChangeRepresentation(r); |
| 74 // The representation of the value is dictated by type feedback and | 66 // The representation of the value is dictated by type feedback and |
| (...skipping 24 matching lines...) Expand all Loading... |
| 99 | 91 |
| 100 for (HUseIterator it(uses()); !it.Done(); it.Advance()) { | 92 for (HUseIterator it(uses()); !it.Done(); it.Advance()) { |
| 101 HValue* use = it.value(); | 93 HValue* use = it.value(); |
| 102 Representation rep = use->observed_input_representation(it.index()); | 94 Representation rep = use->observed_input_representation(it.index()); |
| 103 if (rep.IsNone()) continue; | 95 if (rep.IsNone()) continue; |
| 104 if (FLAG_trace_representation) { | 96 if (FLAG_trace_representation) { |
| 105 PrintF("#%d %s is used by #%d %s as %s%s\n", | 97 PrintF("#%d %s is used by #%d %s as %s%s\n", |
| 106 id(), Mnemonic(), use->id(), use->Mnemonic(), rep.Mnemonic(), | 98 id(), Mnemonic(), use->id(), use->Mnemonic(), rep.Mnemonic(), |
| 107 (use->CheckFlag(kTruncatingToInt32) ? "-trunc" : "")); | 99 (use->CheckFlag(kTruncatingToInt32) ? "-trunc" : "")); |
| 108 } | 100 } |
| 109 use_count[rep.kind()] += use->LoopWeight(); | 101 use_count[rep.kind()] += 1; |
| 110 } | 102 } |
| 111 if (IsPhi()) HPhi::cast(this)->AddIndirectUsesTo(&use_count[0]); | 103 if (IsPhi()) HPhi::cast(this)->AddIndirectUsesTo(&use_count[0]); |
| 112 int tagged_count = use_count[Representation::kTagged]; | 104 int tagged_count = use_count[Representation::kTagged]; |
| 113 int double_count = use_count[Representation::kDouble]; | 105 int double_count = use_count[Representation::kDouble]; |
| 114 int int32_count = use_count[Representation::kInteger32]; | 106 int int32_count = use_count[Representation::kInteger32]; |
| 115 int smi_count = use_count[Representation::kSmi]; | 107 int smi_count = use_count[Representation::kSmi]; |
| 116 | 108 |
| 117 if (tagged_count > 0) return Representation::Tagged(); | 109 if (tagged_count > 0) return Representation::Tagged(); |
| 118 if (double_count > 0) return Representation::Double(); | 110 if (double_count > 0) return Representation::Double(); |
| 119 if (int32_count > 0) return Representation::Integer32(); | 111 if (int32_count > 0) return Representation::Integer32(); |
| (...skipping 2230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2350 phi_id_ = phi_id; | 2342 phi_id_ = phi_id; |
| 2351 // Compute a conservative approximation of truncating uses before inferring | 2343 // Compute a conservative approximation of truncating uses before inferring |
| 2352 // representations. The proper, exact computation will be done later, when | 2344 // representations. The proper, exact computation will be done later, when |
| 2353 // inserting representation changes. | 2345 // inserting representation changes. |
| 2354 SetFlag(kTruncatingToSmi); | 2346 SetFlag(kTruncatingToSmi); |
| 2355 SetFlag(kTruncatingToInt32); | 2347 SetFlag(kTruncatingToInt32); |
| 2356 for (HUseIterator it(uses()); !it.Done(); it.Advance()) { | 2348 for (HUseIterator it(uses()); !it.Done(); it.Advance()) { |
| 2357 HValue* value = it.value(); | 2349 HValue* value = it.value(); |
| 2358 if (!value->IsPhi()) { | 2350 if (!value->IsPhi()) { |
| 2359 Representation rep = value->observed_input_representation(it.index()); | 2351 Representation rep = value->observed_input_representation(it.index()); |
| 2360 non_phi_uses_[rep.kind()] += value->LoopWeight(); | 2352 non_phi_uses_[rep.kind()] += 1; |
| 2361 if (FLAG_trace_representation) { | 2353 if (FLAG_trace_representation) { |
| 2362 PrintF("#%d Phi is used by real #%d %s as %s\n", | 2354 PrintF("#%d Phi is used by real #%d %s as %s\n", |
| 2363 id(), value->id(), value->Mnemonic(), rep.Mnemonic()); | 2355 id(), value->id(), value->Mnemonic(), rep.Mnemonic()); |
| 2364 } | 2356 } |
| 2365 if (!value->IsSimulate()) { | 2357 if (!value->IsSimulate()) { |
| 2366 if (!value->CheckFlag(kTruncatingToSmi)) { | 2358 if (!value->CheckFlag(kTruncatingToSmi)) { |
| 2367 ClearFlag(kTruncatingToSmi); | 2359 ClearFlag(kTruncatingToSmi); |
| 2368 } | 2360 } |
| 2369 if (!value->CheckFlag(kTruncatingToInt32)) { | 2361 if (!value->CheckFlag(kTruncatingToInt32)) { |
| 2370 ClearFlag(kTruncatingToInt32); | 2362 ClearFlag(kTruncatingToInt32); |
| (...skipping 2074 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4445 break; | 4437 break; |
| 4446 case kExternalMemory: | 4438 case kExternalMemory: |
| 4447 stream->Add("[external-memory]"); | 4439 stream->Add("[external-memory]"); |
| 4448 break; | 4440 break; |
| 4449 } | 4441 } |
| 4450 | 4442 |
| 4451 stream->Add("@%d", offset()); | 4443 stream->Add("@%d", offset()); |
| 4452 } | 4444 } |
| 4453 | 4445 |
| 4454 } } // namespace v8::internal | 4446 } } // namespace v8::internal |
| OLD | NEW |