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

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
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 1833 matching lines...) Expand 10 before | Expand all | Expand 10 after
1844 if (right < 0) { 1844 if (right < 0) {
1845 remainder -= right; 1845 remainder -= right;
1846 } else { 1846 } else {
1847 remainder += right; 1847 remainder += right;
1848 } 1848 }
1849 } 1849 }
1850 return remainder; 1850 return remainder;
1851 } 1851 }
1852 1852
1853 1853
1854 static intptr_t GetListLength(const Object& value) {
1855 const intptr_t cid = value.GetClassId();
1856 ASSERT(RawObject::IsBuiltinListClassId(cid));
1857 // Extract list length.
1858 if (value.IsTypedData()) {
1859 const TypedData& list = TypedData::Cast(value);
1860 return list.Length();
1861 } else if (value.IsArray()) {
1862 const Array& list = Array::Cast(value);
1863 return list.Length();
1864 } else if (value.IsGrowableObjectArray()) {
1865 // List length is variable.
1866 return Field::kNoFixedLength;
1867 } else if (value.IsExternalTypedData()) {
1868 // TODO(johnmccutchan): Enable for external typed data.
1869 return Field::kNoFixedLength;
1870 } else if (RawObject::IsTypedDataViewClassId(cid)) {
1871 // TODO(johnmccutchan): Enable for typed data views.
1872 return Field::kNoFixedLength;
1873 }
1874 UNIMPLEMENTED();
1875 return Field::kNoFixedLength;
1876 }
1877
1878
1854 // Update global type feedback recorded for a field recording the assignment 1879 // Update global type feedback recorded for a field recording the assignment
1855 // of the given value. 1880 // of the given value.
1856 // Arg0: Field object; 1881 // Arg0: Field object;
1857 // Arg1: Value that is being stored. 1882 // Arg1: Value that is being stored.
1858 DEFINE_RUNTIME_ENTRY(UpdateFieldCid, 2) { 1883 DEFINE_RUNTIME_ENTRY(UpdateFieldCid, 2) {
1859 ASSERT(arguments.ArgCount() == kUpdateFieldCidRuntimeEntry.argument_count()); 1884 ASSERT(arguments.ArgCount() == kUpdateFieldCidRuntimeEntry.argument_count());
1860 const Field& field = Field::CheckedHandle(arguments.ArgAt(0)); 1885 const Field& field = Field::CheckedHandle(arguments.ArgAt(0));
1861 const Object& value = Object::Handle(arguments.ArgAt(1)); 1886 const Object& value = Object::Handle(arguments.ArgAt(1));
1862 1887 const intptr_t cid = value.GetClassId();
1863 field.UpdateCid(value.GetClassId()); 1888 field.UpdateCid(cid);
1889 intptr_t list_length = Field::kNoFixedLength;
1890 if ((field.guarded_cid() != kDynamicCid) &&
1891 field.is_final() && RawObject::IsBuiltinListClassId(cid)) {
1892 list_length = GetListLength(value);
1893 }
1894 field.UpdateLength(list_length);
1864 } 1895 }
1865 1896
1866 } // namespace dart 1897 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/flow_graph_builder.cc » ('j') | runtime/vm/intermediate_language_arm.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698