Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(259)

Side by Side Diff: runtime/vm/code_generator.cc

Issue 22915008: Tests for GuardField length check along with bug fixes (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/vm/flow_graph_builder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1835 matching lines...) Expand 10 before | Expand all | Expand 10 after
1846 if (right < 0) { 1846 if (right < 0) {
1847 remainder -= right; 1847 remainder -= right;
1848 } else { 1848 } else {
1849 remainder += right; 1849 remainder += right;
1850 } 1850 }
1851 } 1851 }
1852 return remainder; 1852 return remainder;
1853 } 1853 }
1854 1854
1855 1855
1856 static intptr_t GetListLength(const Object& value) { 1856 static intptr_t GetListLength(const Object& value) {
srdjan 2013/08/26 16:13:38 It is error-prone to pass around the raw value of
1857 const intptr_t cid = value.GetClassId(); 1857 const intptr_t cid = value.GetClassId();
1858 ASSERT(RawObject::IsBuiltinListClassId(cid)); 1858 ASSERT(RawObject::IsBuiltinListClassId(cid));
1859 // Extract list length. 1859 // Extract list length.
1860 if (value.IsTypedData()) { 1860 if (value.IsTypedData()) {
1861 const TypedData& list = TypedData::Cast(value); 1861 const TypedData& list = TypedData::Cast(value);
1862 return list.Length(); 1862 return Smi::RawValue(list.Length());
1863 } else if (value.IsArray()) { 1863 } else if (value.IsArray()) {
1864 const Array& list = Array::Cast(value); 1864 const Array& list = Array::Cast(value);
1865 return list.Length(); 1865 return Smi::RawValue(list.Length());
1866 } else if (value.IsGrowableObjectArray()) { 1866 } else if (value.IsGrowableObjectArray()) {
1867 // List length is variable. 1867 // List length is variable.
1868 return Field::kNoFixedLength; 1868 return Field::kNoFixedLength;
1869 } else if (value.IsExternalTypedData()) { 1869 } else if (value.IsExternalTypedData()) {
1870 // TODO(johnmccutchan): Enable for external typed data. 1870 // TODO(johnmccutchan): Enable for external typed data.
1871 return Field::kNoFixedLength; 1871 return Field::kNoFixedLength;
1872 } else if (RawObject::IsTypedDataViewClassId(cid)) { 1872 } else if (RawObject::IsTypedDataViewClassId(cid)) {
1873 // TODO(johnmccutchan): Enable for typed data views. 1873 // TODO(johnmccutchan): Enable for typed data views.
1874 return Field::kNoFixedLength; 1874 return Field::kNoFixedLength;
1875 } 1875 }
(...skipping 14 matching lines...) Expand all
1890 field.UpdateCid(cid); 1890 field.UpdateCid(cid);
1891 intptr_t list_length = Field::kNoFixedLength; 1891 intptr_t list_length = Field::kNoFixedLength;
1892 if ((field.guarded_cid() != kDynamicCid) && 1892 if ((field.guarded_cid() != kDynamicCid) &&
1893 field.is_final() && RawObject::IsBuiltinListClassId(cid)) { 1893 field.is_final() && RawObject::IsBuiltinListClassId(cid)) {
1894 list_length = GetListLength(value); 1894 list_length = GetListLength(value);
1895 } 1895 }
1896 field.UpdateLength(list_length); 1896 field.UpdateLength(list_length);
1897 } 1897 }
1898 1898
1899 } // namespace dart 1899 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/flow_graph_builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698