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

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') | runtime/vm/object.h » ('J')
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 1843 matching lines...) Expand 10 before | Expand all | Expand 10 after
1854 if (right < 0) { 1854 if (right < 0) {
1855 remainder -= right; 1855 remainder -= right;
1856 } else { 1856 } else {
1857 remainder += right; 1857 remainder += right;
1858 } 1858 }
1859 } 1859 }
1860 return remainder; 1860 return remainder;
1861 } 1861 }
1862 1862
1863 1863
1864 static intptr_t GetListLength(const Object& value) {
1865 const intptr_t cid = value.GetClassId();
1866 ASSERT(RawObject::IsBuiltinListClassId(cid));
1867 // Extract list length.
1868 if (value.IsTypedData()) {
1869 const TypedData& list = TypedData::Cast(value);
1870 return list.Length();
1871 } else if (value.IsArray()) {
1872 const Array& list = Array::Cast(value);
1873 return list.Length();
1874 } else if (value.IsGrowableObjectArray()) {
1875 // List length is variable.
1876 return Field::kNoLength;
srdjan 2013/08/16 22:26:01 It may be easier to understand if renamed to kNoFi
Cutch 2013/08/19 21:52:01 Done.
1877 } else if (value.IsExternalTypedData()) {
1878 // TODO(johnmccutchan): Enable for external typed data.
1879 return Field::kNoLength;
1880 } else if (RawObject::IsTypedDataViewClassId(cid)) {
1881 // TODO(johnmccutchan): Enable for typed data views.
1882 return Field::kNoLength;
1883 }
1884 UNIMPLEMENTED();
1885 return Field::kNoLength;
1886 }
1887
1888
1864 // Update global type feedback recorded for a field recording the assignment 1889 // Update global type feedback recorded for a field recording the assignment
1865 // of the given value. 1890 // of the given value.
1866 // Arg0: Field object; 1891 // Arg0: Field object;
1867 // Arg1: Value that is being stored. 1892 // Arg1: Value that is being stored.
1868 DEFINE_RUNTIME_ENTRY(UpdateFieldCid, 2) { 1893 DEFINE_RUNTIME_ENTRY(UpdateFieldCid, 2) {
1869 ASSERT(arguments.ArgCount() == kUpdateFieldCidRuntimeEntry.argument_count()); 1894 ASSERT(arguments.ArgCount() == kUpdateFieldCidRuntimeEntry.argument_count());
1870 const Field& field = Field::CheckedHandle(arguments.ArgAt(0)); 1895 const Field& field = Field::CheckedHandle(arguments.ArgAt(0));
1871 const Object& value = Object::Handle(arguments.ArgAt(1)); 1896 const Object& value = Object::Handle(arguments.ArgAt(1));
1872 1897 const intptr_t cid = value.GetClassId();
1873 field.UpdateCid(value.GetClassId()); 1898 field.UpdateCid(cid);
1899 intptr_t list_length = Field::kNoLength;
1900 if ((field.guarded_cid() != kDynamicCid) &&
1901 field.is_final() && RawObject::IsBuiltinListClassId(cid)) {
1902 list_length = GetListLength(value);
1903 }
1904 field.UpdateLength(list_length);
1874 } 1905 }
1875 1906
1876 } // namespace dart 1907 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/flow_graph_builder.cc » ('j') | runtime/vm/object.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698