| 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/compiler.h" |
| 12 #include "vm/object.h" | 12 #include "vm/object.h" |
| 13 #include "vm/stack_frame.h" | 13 #include "vm/stack_frame.h" |
| 14 | 14 |
| 15 namespace dart { | 15 namespace dart { |
| 16 | 16 |
| 17 bool WeakCodeReferences::HasCodes() const { |
| 18 return !array_.IsNull() && (array_.Length() > 0); |
| 19 } |
| 20 |
| 21 |
| 17 void WeakCodeReferences::Register(const Code& value) { | 22 void WeakCodeReferences::Register(const Code& value) { |
| 18 if (!array_.IsNull()) { | 23 if (!array_.IsNull()) { |
| 19 // Try to find and reuse cleared WeakProperty to avoid allocating new one. | 24 // Try to find and reuse cleared WeakProperty to avoid allocating new one. |
| 20 WeakProperty& weak_property = WeakProperty::Handle(); | 25 WeakProperty& weak_property = WeakProperty::Handle(); |
| 21 for (intptr_t i = 0; i < array_.Length(); i++) { | 26 for (intptr_t i = 0; i < array_.Length(); i++) { |
| 22 weak_property ^= array_.At(i); | 27 weak_property ^= array_.At(i); |
| 23 if (weak_property.key() == Code::null()) { | 28 if (weak_property.key() == Code::null()) { |
| 24 // Empty property found. Reuse it. | 29 // Empty property found. Reuse it. |
| 25 weak_property.set_key(value); | 30 weak_property.set_key(value); |
| 26 return; | 31 return; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 // Make non-OSR code non-entrant. | 129 // Make non-OSR code non-entrant. |
| 125 if (!code.IsDisabled()) { | 130 if (!code.IsDisabled()) { |
| 126 ReportSwitchingCode(code); | 131 ReportSwitchingCode(code); |
| 127 code.DisableDartCode(); | 132 code.DisableDartCode(); |
| 128 } | 133 } |
| 129 } | 134 } |
| 130 } | 135 } |
| 131 } | 136 } |
| 132 | 137 |
| 133 } // namespace dart | 138 } // namespace dart |
| OLD | NEW |