| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/intermediate_language.h" | 5 #include "vm/intermediate_language.h" |
| 6 | 6 |
| 7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
| 8 #include "vm/cpu.h" | 8 #include "vm/cpu.h" |
| 9 #include "vm/dart_entry.h" | 9 #include "vm/dart_entry.h" |
| 10 #include "vm/flow_graph_allocator.h" | 10 #include "vm/flow_graph_allocator.h" |
| (...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 732 void Instruction::UnuseAllInputs() { | 732 void Instruction::UnuseAllInputs() { |
| 733 for (intptr_t i = InputCount() - 1; i >= 0; --i) { | 733 for (intptr_t i = InputCount() - 1; i >= 0; --i) { |
| 734 InputAt(i)->RemoveFromUseList(); | 734 InputAt(i)->RemoveFromUseList(); |
| 735 } | 735 } |
| 736 for (Environment::DeepIterator it(env()); !it.Done(); it.Advance()) { | 736 for (Environment::DeepIterator it(env()); !it.Done(); it.Advance()) { |
| 737 it.CurrentValue()->RemoveFromUseList(); | 737 it.CurrentValue()->RemoveFromUseList(); |
| 738 } | 738 } |
| 739 } | 739 } |
| 740 | 740 |
| 741 | 741 |
| 742 void Instruction::InheritDeoptTargetAfter(Isolate* isolate, | 742 void Instruction::InheritDeoptTargetAfter(FlowGraph* flow_graph, |
| 743 Instruction* other) { | 743 Definition* call, |
| 744 ASSERT(other->env() != NULL); | 744 Definition* result) { |
| 745 deopt_id_ = Isolate::ToDeoptAfter(other->deopt_id_); | 745 ASSERT(call->env() != NULL); |
| 746 other->env()->DeepCopyTo(isolate, this); | 746 deopt_id_ = Isolate::ToDeoptAfter(call->deopt_id_); |
| 747 call->env()->DeepCopyAfterTo(flow_graph->isolate(), |
| 748 this, |
| 749 call->ArgumentCount(), |
| 750 flow_graph->constant_dead(), |
| 751 result != NULL ? result |
| 752 : flow_graph->constant_dead()); |
| 747 env()->set_deopt_id(deopt_id_); | 753 env()->set_deopt_id(deopt_id_); |
| 748 } | 754 } |
| 749 | 755 |
| 750 | 756 |
| 751 void Instruction::InheritDeoptTarget(Isolate* isolate, Instruction* other) { | 757 void Instruction::InheritDeoptTarget(Isolate* isolate, Instruction* other) { |
| 752 ASSERT(other->env() != NULL); | 758 ASSERT(other->env() != NULL); |
| 753 deopt_id_ = other->deopt_id_; | 759 deopt_id_ = other->deopt_id_; |
| 754 other->env()->DeepCopyTo(isolate, this); | 760 other->env()->DeepCopyTo(isolate, this); |
| 755 env()->set_deopt_id(deopt_id_); | 761 env()->set_deopt_id(deopt_id_); |
| 756 } | 762 } |
| (...skipping 2263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3020 | 3026 |
| 3021 Environment* copy = DeepCopy(isolate); | 3027 Environment* copy = DeepCopy(isolate); |
| 3022 instr->SetEnvironment(copy); | 3028 instr->SetEnvironment(copy); |
| 3023 for (Environment::DeepIterator it(copy); !it.Done(); it.Advance()) { | 3029 for (Environment::DeepIterator it(copy); !it.Done(); it.Advance()) { |
| 3024 Value* value = it.CurrentValue(); | 3030 Value* value = it.CurrentValue(); |
| 3025 value->definition()->AddEnvUse(value); | 3031 value->definition()->AddEnvUse(value); |
| 3026 } | 3032 } |
| 3027 } | 3033 } |
| 3028 | 3034 |
| 3029 | 3035 |
| 3036 void Environment::DeepCopyAfterTo(Isolate* isolate, |
| 3037 Instruction* instr, |
| 3038 intptr_t argc, |
| 3039 Definition* dead, |
| 3040 Definition* result) const { |
| 3041 for (Environment::DeepIterator it(instr->env()); !it.Done(); it.Advance()) { |
| 3042 it.CurrentValue()->RemoveFromUseList(); |
| 3043 } |
| 3044 |
| 3045 Environment* copy = DeepCopy(isolate, values_.length() - argc); |
| 3046 for (intptr_t i = 0; i < argc; i++) { |
| 3047 copy->values_.Add(new(isolate) Value(dead)); |
| 3048 } |
| 3049 copy->values_.Add(new(isolate) Value(result)); |
| 3050 |
| 3051 instr->SetEnvironment(copy); |
| 3052 for (Environment::DeepIterator it(copy); !it.Done(); it.Advance()) { |
| 3053 Value* value = it.CurrentValue(); |
| 3054 value->definition()->AddEnvUse(value); |
| 3055 } |
| 3056 } |
| 3057 |
| 3058 |
| 3030 // Copies the environment as outer on an inlined instruction and updates the | 3059 // Copies the environment as outer on an inlined instruction and updates the |
| 3031 // environment use lists. | 3060 // environment use lists. |
| 3032 void Environment::DeepCopyToOuter(Isolate* isolate, Instruction* instr) const { | 3061 void Environment::DeepCopyToOuter(Isolate* isolate, Instruction* instr) const { |
| 3033 // Create a deep copy removing caller arguments from the environment. | 3062 // Create a deep copy removing caller arguments from the environment. |
| 3034 ASSERT(this != NULL); | 3063 ASSERT(this != NULL); |
| 3035 ASSERT(instr->env()->outer() == NULL); | 3064 ASSERT(instr->env()->outer() == NULL); |
| 3036 intptr_t argument_count = instr->env()->fixed_parameter_count(); | 3065 intptr_t argument_count = instr->env()->fixed_parameter_count(); |
| 3037 Environment* copy = DeepCopy(isolate, values_.length() - argument_count); | 3066 Environment* copy = DeepCopy(isolate, values_.length() - argument_count); |
| 3038 instr->env()->outer_ = copy; | 3067 instr->env()->outer_ = copy; |
| 3039 intptr_t use_index = instr->env()->Length(); // Start index after inner. | 3068 intptr_t use_index = instr->env()->Length(); // Start index after inner. |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3441 case Token::kTRUNCDIV: return 0; | 3470 case Token::kTRUNCDIV: return 0; |
| 3442 case Token::kMOD: return 1; | 3471 case Token::kMOD: return 1; |
| 3443 default: UNIMPLEMENTED(); return -1; | 3472 default: UNIMPLEMENTED(); return -1; |
| 3444 } | 3473 } |
| 3445 } | 3474 } |
| 3446 | 3475 |
| 3447 | 3476 |
| 3448 #undef __ | 3477 #undef __ |
| 3449 | 3478 |
| 3450 } // namespace dart | 3479 } // namespace dart |
| OLD | NEW |