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/code_generator.h" | 5 #include "vm/code_generator.h" |
6 | 6 |
7 #include "vm/assembler.h" | 7 #include "vm/assembler.h" |
8 #include "vm/ast.h" | 8 #include "vm/ast.h" |
9 #include "vm/bigint_operations.h" | 9 #include "vm/bigint_operations.h" |
10 #include "vm/code_patcher.h" | 10 #include "vm/code_patcher.h" |
(...skipping 1663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1674 if (right < 0) { | 1674 if (right < 0) { |
1675 remainder -= right; | 1675 remainder -= right; |
1676 } else { | 1676 } else { |
1677 remainder += right; | 1677 remainder += right; |
1678 } | 1678 } |
1679 } | 1679 } |
1680 return remainder; | 1680 return remainder; |
1681 } | 1681 } |
1682 | 1682 |
1683 | 1683 |
1684 static intptr_t GetListLength(const Object& value) { | |
1685 const intptr_t cid = value.GetClassId(); | |
1686 ASSERT(RawObject::IsBuiltinListClassId(cid)); | |
1687 // Extract list length. | |
1688 if (value.IsTypedData()) { | |
1689 const TypedData& list = TypedData::Cast(value); | |
1690 return list.Length(); | |
1691 } else if (value.IsArray()) { | |
1692 const Array& list = Array::Cast(value); | |
1693 return list.Length(); | |
1694 } else if (value.IsGrowableObjectArray()) { | |
1695 // List length is variable. | |
1696 return Field::kNoFixedLength; | |
1697 } else if (value.IsExternalTypedData()) { | |
1698 // TODO(johnmccutchan): Enable for external typed data. | |
1699 return Field::kNoFixedLength; | |
1700 } else if (RawObject::IsTypedDataViewClassId(cid)) { | |
1701 // TODO(johnmccutchan): Enable for typed data views. | |
1702 return Field::kNoFixedLength; | |
1703 } | |
1704 UNIMPLEMENTED(); | |
1705 return Field::kNoFixedLength; | |
1706 } | |
1707 | |
1708 | |
1709 // Update global type feedback recorded for a field recording the assignment | 1684 // Update global type feedback recorded for a field recording the assignment |
1710 // of the given value. | 1685 // of the given value. |
1711 // Arg0: Field object; | 1686 // Arg0: Field object; |
1712 // Arg1: Value that is being stored. | 1687 // Arg1: Value that is being stored. |
1713 DEFINE_RUNTIME_ENTRY(UpdateFieldCid, 2) { | 1688 DEFINE_RUNTIME_ENTRY(UpdateFieldCid, 2) { |
1714 const Field& field = Field::CheckedHandle(arguments.ArgAt(0)); | 1689 const Field& field = Field::CheckedHandle(arguments.ArgAt(0)); |
1715 const Object& value = Object::Handle(arguments.ArgAt(1)); | 1690 const Object& value = Object::Handle(arguments.ArgAt(1)); |
1716 const intptr_t cid = value.GetClassId(); | 1691 field.UpdateGuardedCidAndLength(value); |
1717 field.UpdateCid(cid); | |
1718 intptr_t list_length = Field::kNoFixedLength; | |
1719 if ((field.guarded_cid() != kDynamicCid) && | |
1720 field.is_final() && RawObject::IsBuiltinListClassId(cid)) { | |
1721 list_length = GetListLength(value); | |
1722 } | |
1723 field.UpdateLength(list_length); | |
1724 } | 1692 } |
1725 | 1693 |
1726 } // namespace dart | 1694 } // namespace dart |
OLD | NEW |