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

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/flow_graph_builder.cc » ('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 intptr_t list_length = Field::kNoLength;
srdjan 2013/08/14 17:01:08 You can eliminate list_length variable and return
Cutch 2013/08/15 16:39:12 Done.
1868 // Extract list length.
1869 if (value.IsTypedData()) {
1870 const TypedData& list = TypedData::Cast(value);
1871 list_length = list.Length();
1872 } else if (value.IsArray()) {
1873 const Array& list = Array::Cast(value);
1874 list_length = list.Length();
1875 } else if (value.IsGrowableObjectArray()) {
1876 // List length is variable.
1877 } else if (value.IsExternalTypedData()) {
1878 const ExternalTypedData& list = ExternalTypedData::Cast(value);
1879 list_length = list.Length();
1880 } else if (RawObject::IsTypedDataViewClassId(cid)) {
1881 const Instance& list = Instance::Cast(value);
1882 list_length = Smi::Value(TypedDataView::Length(list));
1883 } else {
1884 UNIMPLEMENTED();
1885 }
1886 return list_length;
1887 }
1888
1889
1864 // Update global type feedback recorded for a field recording the assignment 1890 // Update global type feedback recorded for a field recording the assignment
1865 // of the given value. 1891 // of the given value.
1866 // Arg0: Field object; 1892 // Arg0: Field object;
1867 // Arg1: Value that is being stored. 1893 // Arg1: Value that is being stored.
1868 DEFINE_RUNTIME_ENTRY(UpdateFieldCid, 2) { 1894 DEFINE_RUNTIME_ENTRY(UpdateFieldCid, 2) {
1869 ASSERT(arguments.ArgCount() == kUpdateFieldCidRuntimeEntry.argument_count()); 1895 ASSERT(arguments.ArgCount() == kUpdateFieldCidRuntimeEntry.argument_count());
1870 const Field& field = Field::CheckedHandle(arguments.ArgAt(0)); 1896 const Field& field = Field::CheckedHandle(arguments.ArgAt(0));
1871 const Object& value = Object::Handle(arguments.ArgAt(1)); 1897 const Object& value = Object::Handle(arguments.ArgAt(1));
1872 1898 const intptr_t cid = value.GetClassId();
1873 field.UpdateCid(value.GetClassId()); 1899 field.UpdateCid(cid);
1900 intptr_t list_length = Field::kNoLength;
1901 if ((field.guarded_cid() != kDynamicCid) &&
1902 field.is_final() && RawObject::IsBuiltinListClassId(cid)) {
1903 list_length = GetListLength(value);
1904 }
srdjan 2013/08/14 17:01:08 ASSERT(!field.is_final) ?
1905 field.UpdateLength(list_length);
1874 } 1906 }
1875 1907
1876 } // namespace dart 1908 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/flow_graph_builder.cc » ('j') | runtime/vm/flow_graph_builder.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698