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

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

Issue 13472019: - Create an all static TypedDataView class which uses implicit field offset (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 8 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 | « runtime/vm/class_finalizer.h ('k') | runtime/vm/dart_api_impl.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/class_finalizer.h" 5 #include "vm/class_finalizer.h"
6 6
7 #include "vm/flags.h" 7 #include "vm/flags.h"
8 #include "vm/heap.h" 8 #include "vm/heap.h"
9 #include "vm/isolate.h" 9 #include "vm/isolate.h"
10 #include "vm/longjump.h" 10 #include "vm/longjump.h"
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 // Clear pending classes array. 160 // Clear pending classes array.
161 class_array = GrowableObjectArray::New(); 161 class_array = GrowableObjectArray::New();
162 object_store->set_pending_classes(class_array); 162 object_store->set_pending_classes(class_array);
163 } else { 163 } else {
164 retval = false; 164 retval = false;
165 } 165 }
166 isolate->set_long_jump_base(base); 166 isolate->set_long_jump_base(base);
167 if (FLAG_use_cha) { 167 if (FLAG_use_cha) {
168 RemoveOptimizedCode(added_subclasses_to_cids); 168 RemoveOptimizedCode(added_subclasses_to_cids);
169 } 169 }
170 VerifyImplicitFieldOffsets();
170 return retval; 171 return retval;
171 } 172 }
172 173
173 174
174 // Adds all interfaces of cls into 'collected'. Duplicate entries may occur. 175 // Adds all interfaces of cls into 'collected'. Duplicate entries may occur.
175 // No cycles are allowed. 176 // No cycles are allowed.
176 void ClassFinalizer::CollectInterfaces(const Class& cls, 177 void ClassFinalizer::CollectInterfaces(const Class& cls,
177 const GrowableObjectArray& collected) { 178 const GrowableObjectArray& collected) {
178 const Array& interface_array = Array::Handle(cls.interfaces()); 179 const Array& interface_array = Array::Handle(cls.interfaces());
179 AbstractType& interface = AbstractType::Handle(); 180 AbstractType& interface = AbstractType::Handle();
(...skipping 1786 matching lines...) Expand 10 before | Expand all | Expand 10 after
1966 1967
1967 void ClassFinalizer::ReportError(const char* format, ...) { 1968 void ClassFinalizer::ReportError(const char* format, ...) {
1968 va_list args; 1969 va_list args;
1969 va_start(args, format); 1970 va_start(args, format);
1970 const Error& error = Error::Handle( 1971 const Error& error = Error::Handle(
1971 Parser::FormatError(Script::Handle(), -1, "Error", format, args)); 1972 Parser::FormatError(Script::Handle(), -1, "Error", format, args));
1972 va_end(args); 1973 va_end(args);
1973 ReportError(error); 1974 ReportError(error);
1974 } 1975 }
1975 1976
1977
1978 void ClassFinalizer::VerifyImplicitFieldOffsets() {
1979 #ifdef DEBUG
1980 const ClassTable& class_table = *(Isolate::Current()->class_table());
1981 Class& cls = Class::Handle();
1982 Array& fields_array = Array::Handle();
1983 Field& field = Field::Handle();
1984
1985 // First verify field offsets of all the TypedDataView classes.
1986 for (intptr_t cid = kTypedDataInt8ArrayViewCid;
1987 cid <= kTypedDataFloat32x4ArrayViewCid;
1988 cid++) {
1989 cls = class_table.At(cid); // Get the TypedDataView class.
1990 cls = cls.SuperClass(); // Get it's super class '_TypedListView'.
1991 fields_array ^= cls.fields();
1992 ASSERT(fields_array.Length() == TypedDataView::NumberOfFields());
1993 field ^= fields_array.At(0);
1994 ASSERT(field.Offset() == TypedDataView::data_offset());
Ivan Posva 2013/04/05 04:23:55 You probably also want to check the name of the fi
1995 field ^= fields_array.At(1);
1996 ASSERT(field.Offset() == TypedDataView::offset_in_bytes_offset());
1997 field ^= fields_array.At(2);
1998 ASSERT(field.Offset() == TypedDataView::length_offset());
1999 }
2000
2001 // Now verify field offsets of '_ByteDataView' class.
2002 cls = class_table.At(kByteDataViewCid);
2003 fields_array ^= cls.fields();
2004 ASSERT(fields_array.Length() == TypedDataView::NumberOfFields());
2005 field ^= fields_array.At(0);
2006 ASSERT(field.Offset() == TypedDataView::data_offset());
2007 field ^= fields_array.At(1);
2008 ASSERT(field.Offset() == TypedDataView::offset_in_bytes_offset());
2009 field ^= fields_array.At(2);
2010 ASSERT(field.Offset() == TypedDataView::length_offset());
2011
2012 #endif
2013 }
2014
1976 } // namespace dart 2015 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/class_finalizer.h ('k') | runtime/vm/dart_api_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698