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

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

Issue 22851003: Initial support for length guards on final fields. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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) {
1857 const intptr_t cid = value.GetClassId();
1858 ASSERT(RawObject::IsBuiltinListClassId(cid));
1859 // Extract list length.
1860 if (value.IsTypedData()) {
1861 const TypedData& list = TypedData::Cast(value);
1862 return list.Length();
1863 } else if (value.IsArray()) {
1864 const Array& list = Array::Cast(value);
1865 return list.Length();
1866 } else if (value.IsGrowableObjectArray()) {
1867 // List length is variable.
1868 return Field::kNoFixedLength;
1869 } else if (value.IsExternalTypedData()) {
1870 // TODO(johnmccutchan): Enable for external typed data.
1871 return Field::kNoFixedLength;
1872 } else if (RawObject::IsTypedDataViewClassId(cid)) {
1873 // TODO(johnmccutchan): Enable for typed data views.
1874 return Field::kNoFixedLength;
1875 }
1876 UNIMPLEMENTED();
1877 return Field::kNoFixedLength;
1878 }
1879
1880
1856 // Update global type feedback recorded for a field recording the assignment 1881 // Update global type feedback recorded for a field recording the assignment
1857 // of the given value. 1882 // of the given value.
1858 // Arg0: Field object; 1883 // Arg0: Field object;
1859 // Arg1: Value that is being stored. 1884 // Arg1: Value that is being stored.
1860 DEFINE_RUNTIME_ENTRY(UpdateFieldCid, 2) { 1885 DEFINE_RUNTIME_ENTRY(UpdateFieldCid, 2) {
1861 ASSERT(arguments.ArgCount() == kUpdateFieldCidRuntimeEntry.argument_count()); 1886 ASSERT(arguments.ArgCount() == kUpdateFieldCidRuntimeEntry.argument_count());
1862 const Field& field = Field::CheckedHandle(arguments.ArgAt(0)); 1887 const Field& field = Field::CheckedHandle(arguments.ArgAt(0));
1863 const Object& value = Object::Handle(arguments.ArgAt(1)); 1888 const Object& value = Object::Handle(arguments.ArgAt(1));
1864 1889 const intptr_t cid = value.GetClassId();
1865 field.UpdateCid(value.GetClassId()); 1890 field.UpdateCid(cid);
1891 intptr_t list_length = Field::kNoFixedLength;
1892 if ((field.guarded_cid() != kDynamicCid) &&
1893 field.is_final() && RawObject::IsBuiltinListClassId(cid)) {
1894 list_length = GetListLength(value);
1895 }
1896 field.UpdateLength(list_length);
1866 } 1897 }
1867 1898
1868 } // 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