Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 1754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1934 | 1935 |
| 1935 void ClassFinalizer::ReportError(const char* format, ...) { | 1936 void ClassFinalizer::ReportError(const char* format, ...) { |
| 1936 va_list args; | 1937 va_list args; |
| 1937 va_start(args, format); | 1938 va_start(args, format); |
| 1938 const Error& error = Error::Handle( | 1939 const Error& error = Error::Handle( |
| 1939 Parser::FormatError(Script::Handle(), -1, "Error", format, args)); | 1940 Parser::FormatError(Script::Handle(), -1, "Error", format, args)); |
| 1940 va_end(args); | 1941 va_end(args); |
| 1941 ReportError(error); | 1942 ReportError(error); |
| 1942 } | 1943 } |
| 1943 | 1944 |
| 1945 | |
| 1946 void ClassFinalizer::VerifyImplicitFieldOffsets() { | |
| 1947 #ifdef DEBUG | |
| 1948 const ClassTable& class_table = *(Isolate::Current()->class_table()); | |
| 1949 Class& cls = Class::Handle(); | |
| 1950 Array& fields_array = Array::Handle(); | |
| 1951 Field& field = Field::Handle(); | |
| 1952 | |
| 1953 // First verify field offsets of all the TypedDataView classes. | |
| 1954 for (intptr_t cid = kTypedDataInt8ArrayViewCid; | |
| 1955 cid <= kTypedDataFloat32x4ArrayViewCid; | |
| 1956 cid++) { | |
| 1957 cls = class_table.At(cid); // Get the TypedDataView class. | |
| 1958 cls = cls.SuperClass(); // Get it's super class '_TypedListView'. | |
| 1959 fields_array ^= cls.fields(); | |
| 1960 ASSERT(fields_array.Length() == TypedDataView::NumberOfFields()); | |
| 1961 field ^= fields_array.At(0); | |
| 1962 ASSERT(field.Offset() == TypedDataView::data_offset()); | |
| 1963 field ^= fields_array.At(1); | |
| 1964 ASSERT(field.Offset() == TypedDataView::offset_in_bytes_offset()); | |
| 1965 field ^= fields_array.At(2); | |
| 1966 ASSERT(field.Offset() == TypedDataView::length_offset()); | |
| 1967 } | |
| 1968 | |
| 1969 // First verify field offsets of '_ByteDataView' class. | |
|
Florian Schneider
2013/04/04 09:33:14
Drop 'First' from comment.
siva
2013/04/05 02:01:56
Done.
| |
| 1970 cls = class_table.At(kByteDataViewCid); | |
| 1971 fields_array ^= cls.fields(); | |
| 1972 ASSERT(fields_array.Length() == TypedDataView::NumberOfFields()); | |
| 1973 field ^= fields_array.At(0); | |
| 1974 ASSERT(field.Offset() == TypedDataView::data_offset()); | |
| 1975 field ^= fields_array.At(1); | |
| 1976 ASSERT(field.Offset() == TypedDataView::offset_in_bytes_offset()); | |
| 1977 field ^= fields_array.At(2); | |
| 1978 ASSERT(field.Offset() == TypedDataView::length_offset()); | |
| 1979 | |
| 1980 #endif | |
| 1981 } | |
| 1982 | |
| 1944 } // namespace dart | 1983 } // namespace dart |
| OLD | NEW |