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

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();
regis 2013/04/09 20:27:39 I am getting a crash here in the case class finali
siva 2013/04/09 21:30:29 I guess in your case a type error occurred before
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 String& name = String::Handle();
1985 String& expected_name = String::Handle();
1986
1987 // First verify field offsets of all the TypedDataView classes.
1988 for (intptr_t cid = kTypedDataInt8ArrayViewCid;
1989 cid <= kTypedDataFloat32x4ArrayViewCid;
1990 cid++) {
1991 cls = class_table.At(cid); // Get the TypedDataView class.
1992 cls = cls.SuperClass(); // Get it's super class '_TypedListView'.
1993 fields_array ^= cls.fields();
1994 ASSERT(fields_array.Length() == TypedDataView::NumberOfFields());
1995 field ^= fields_array.At(0);
1996 ASSERT(field.Offset() == TypedDataView::data_offset());
1997 name ^= field.name();
1998 expected_name ^= String::New("_typeddata");
1999 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name));
2000 field ^= fields_array.At(1);
2001 ASSERT(field.Offset() == TypedDataView::offset_in_bytes_offset());
2002 name ^= field.name();
2003 ASSERT(name.Equals("offsetInBytes"));
2004 field ^= fields_array.At(2);
2005 ASSERT(field.Offset() == TypedDataView::length_offset());
2006 name ^= field.name();
2007 ASSERT(name.Equals("length"));
2008 }
2009
2010 // Now verify field offsets of '_ByteDataView' class.
2011 cls = class_table.At(kByteDataViewCid);
2012 fields_array ^= cls.fields();
2013 ASSERT(fields_array.Length() == TypedDataView::NumberOfFields());
2014 field ^= fields_array.At(0);
2015 ASSERT(field.Offset() == TypedDataView::data_offset());
2016 name ^= field.name();
2017 expected_name ^= String::New("_typeddata");
2018 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name));
2019 field ^= fields_array.At(1);
2020 ASSERT(field.Offset() == TypedDataView::offset_in_bytes_offset());
2021 name ^= field.name();
2022 expected_name ^= String::New("_offset");
2023 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name));
2024 field ^= fields_array.At(2);
2025 ASSERT(field.Offset() == TypedDataView::length_offset());
2026 name ^= field.name();
2027 ASSERT(name.Equals("length"));
2028 #endif
2029 }
2030
1976 } // namespace dart 2031 } // 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