OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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/weak_code.h" | 5 #include "vm/weak_code.h" |
6 | 6 |
7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
8 | 8 |
9 #include "vm/code_generator.h" | 9 #include "vm/code_generator.h" |
10 #include "vm/code_patcher.h" | 10 #include "vm/code_patcher.h" |
| 11 #include "vm/compiler.h" |
11 #include "vm/object.h" | 12 #include "vm/object.h" |
12 #include "vm/stack_frame.h" | 13 #include "vm/stack_frame.h" |
13 | 14 |
14 namespace dart { | 15 namespace dart { |
15 | 16 |
16 void WeakCodeReferences::Register(const Code& value) { | 17 void WeakCodeReferences::Register(const Code& value) { |
17 if (!array_.IsNull()) { | 18 if (!array_.IsNull()) { |
18 // Try to find and reuse cleared WeakProperty to avoid allocating new one. | 19 // Try to find and reuse cleared WeakProperty to avoid allocating new one. |
19 WeakProperty& weak_property = WeakProperty::Handle(); | 20 WeakProperty& weak_property = WeakProperty::Handle(); |
20 for (intptr_t i = 0; i < array_.Length(); i++) { | 21 for (intptr_t i = 0; i < array_.Length(); i++) { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 } | 54 } |
54 return false; | 55 return false; |
55 } | 56 } |
56 | 57 |
57 | 58 |
58 void WeakCodeReferences::DisableCode() { | 59 void WeakCodeReferences::DisableCode() { |
59 const Array& code_objects = Array::Handle(array_.raw()); | 60 const Array& code_objects = Array::Handle(array_.raw()); |
60 if (code_objects.IsNull()) { | 61 if (code_objects.IsNull()) { |
61 return; | 62 return; |
62 } | 63 } |
| 64 ASSERT(Compiler::allow_recompilation()); |
63 UpdateArrayTo(Object::null_array()); | 65 UpdateArrayTo(Object::null_array()); |
64 // Disable all code on stack. | 66 // Disable all code on stack. |
65 Code& code = Code::Handle(); | 67 Code& code = Code::Handle(); |
66 { | 68 { |
67 DartFrameIterator iterator; | 69 DartFrameIterator iterator; |
68 StackFrame* frame = iterator.NextFrame(); | 70 StackFrame* frame = iterator.NextFrame(); |
69 while (frame != NULL) { | 71 while (frame != NULL) { |
70 code = frame->LookupDartCode(); | 72 code = frame->LookupDartCode(); |
71 if (IsOptimizedCode(code_objects, code)) { | 73 if (IsOptimizedCode(code_objects, code)) { |
72 ReportDeoptimization(code); | 74 ReportDeoptimization(code); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 if (!CodePatcher::IsEntryPatched(code)) { | 125 if (!CodePatcher::IsEntryPatched(code)) { |
124 ReportSwitchingCode(code); | 126 ReportSwitchingCode(code); |
125 CodePatcher::PatchEntry(code); | 127 CodePatcher::PatchEntry(code); |
126 } | 128 } |
127 } | 129 } |
128 } | 130 } |
129 } | 131 } |
130 } | 132 } |
131 | 133 |
132 } // namespace dart | 134 } // namespace dart |
OLD | NEW |