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

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

Issue 9186058: Make the "sticky error" an Error instead of a String. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 8 years, 11 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/code_generator_ia32.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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 48
49 // Class finalization occurs: 49 // Class finalization occurs:
50 // a) when bootstrap process completes (VerifyBootstrapClasses). 50 // a) when bootstrap process completes (VerifyBootstrapClasses).
51 // b) after the user classes are loaded (dart_api). 51 // b) after the user classes are loaded (dart_api).
52 bool ClassFinalizer::FinalizePendingClasses(bool generating_snapshot) { 52 bool ClassFinalizer::FinalizePendingClasses(bool generating_snapshot) {
53 bool retval = true; 53 bool retval = true;
54 Isolate* isolate = Isolate::Current(); 54 Isolate* isolate = Isolate::Current();
55 ASSERT(isolate != NULL); 55 ASSERT(isolate != NULL);
56 ObjectStore* object_store = isolate->object_store(); 56 ObjectStore* object_store = isolate->object_store();
57 const String& error = String::Handle(object_store->sticky_error()); 57 const Error& error = Error::Handle(object_store->sticky_error());
58 if (!error.IsNull()) { 58 if (!error.IsNull()) {
59 return false; 59 return false;
60 } 60 }
61 LongJump* base = isolate->long_jump_base(); 61 LongJump* base = isolate->long_jump_base();
62 LongJump jump; 62 LongJump jump;
63 isolate->set_long_jump_base(&jump); 63 isolate->set_long_jump_base(&jump);
64 if (setjmp(*jump.Set()) == 0) { 64 if (setjmp(*jump.Set()) == 0) {
65 const Array& class_array = Array::Handle(object_store->pending_classes()); 65 const Array& class_array = Array::Handle(object_store->pending_classes());
66 ASSERT(!class_array.IsNull()); 66 ASSERT(!class_array.IsNull());
67 Class& cls = Class::Handle(); 67 Class& cls = Class::Handle();
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 cls ^= class_array.At(i); 236 cls ^= class_array.At(i);
237 if (cls.is_finalized() || cls.is_prefinalized()) { 237 if (cls.is_finalized() || cls.is_prefinalized()) {
238 // Pre-finalized bootstrap classes must not define any fields. 238 // Pre-finalized bootstrap classes must not define any fields.
239 ASSERT(Array::Handle(cls.fields()).Length() == 0); 239 ASSERT(Array::Handle(cls.fields()).Length() == 0);
240 } 240 }
241 } 241 }
242 242
243 // Finalize classes that aren't pre-finalized by Object::Init(). 243 // Finalize classes that aren't pre-finalized by Object::Init().
244 if (!FinalizePendingClasses()) { 244 if (!FinalizePendingClasses()) {
245 // TODO(srdjan): Exit like a real VM instead. 245 // TODO(srdjan): Exit like a real VM instead.
246 const String& err = String::Handle(object_store->sticky_error()); 246 const Error& err = Error::Handle(object_store->sticky_error());
247 OS::PrintErr("Could not verify bootstrap classes : %s\n", err.ToCString()); 247 OS::PrintErr("Could not verify bootstrap classes : %s\n",
248 err.ToErrorCString());
248 OS::Exit(255); 249 OS::Exit(255);
249 } 250 }
250 if (FLAG_trace_class_finalization) { 251 if (FLAG_trace_class_finalization) {
251 OS::Print("VerifyBootstrapClasses END.\n"); 252 OS::Print("VerifyBootstrapClasses END.\n");
252 } 253 }
253 Isolate::Current()->heap()->Verify(); 254 Isolate::Current()->heap()->Verify();
254 } 255 }
255 256
256 257
257 // Resolve unresolved_class in the library of cls. 258 // Resolve unresolved_class in the library of cls.
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 } else { 691 } else {
691 parameterized_type.set_is_finalized(); 692 parameterized_type.set_is_finalized();
692 } 693 }
693 return parameterized_type.Canonicalize(); 694 return parameterized_type.Canonicalize();
694 } 695 }
695 696
696 697
697 RawAbstractType* ClassFinalizer::FinalizeAndCanonicalizeType( 698 RawAbstractType* ClassFinalizer::FinalizeAndCanonicalizeType(
698 const Class& cls, 699 const Class& cls,
699 const AbstractType& type, 700 const AbstractType& type,
700 String* errmsg) { 701 Error* error) {
701 Isolate* isolate = Isolate::Current(); 702 Isolate* isolate = Isolate::Current();
702 ASSERT(isolate != NULL); 703 ASSERT(isolate != NULL);
703 LongJump* base = isolate->long_jump_base(); 704 LongJump* base = isolate->long_jump_base();
704 LongJump jump; 705 LongJump jump;
705 isolate->set_long_jump_base(&jump); 706 isolate->set_long_jump_base(&jump);
706 if (setjmp(*jump.Set()) == 0) { 707 if (setjmp(*jump.Set()) == 0) {
707 const AbstractType& finalized_type = 708 const AbstractType& finalized_type =
708 AbstractType::Handle(FinalizeType(cls, type)); 709 AbstractType::Handle(FinalizeType(cls, type));
709 isolate->set_long_jump_base(base); 710 isolate->set_long_jump_base(base);
710 *errmsg = String::null(); 711 *error = Error::null();
711 return finalized_type.raw(); 712 return finalized_type.raw();
712 } else { 713 } else {
713 // Error occured: Get the error message. 714 // Error occured: Get the error message.
714 isolate->set_long_jump_base(base); 715 isolate->set_long_jump_base(base);
715 *errmsg = isolate->object_store()->sticky_error(); 716 *error = isolate->object_store()->sticky_error();
716 return type.raw(); 717 return type.raw();
717 } 718 }
718 UNREACHABLE(); 719 UNREACHABLE();
719 return NULL; 720 return NULL;
720 } 721 }
721 722
722 723
723 void ClassFinalizer::ResolveAndFinalizeSignature(const Class& cls, 724 void ClassFinalizer::ResolveAndFinalizeSignature(const Class& cls,
724 const Function& function) { 725 const Function& function) {
725 // Resolve result type. 726 // Resolve result type.
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
1256 for (intptr_t i = 0; i < len; i++) { 1257 for (intptr_t i = 0; i < len; i++) {
1257 field ^= fields_array.At(i); 1258 field ^= fields_array.At(i);
1258 OS::Print(" %s\n", field.ToCString()); 1259 OS::Print(" %s\n", field.ToCString());
1259 } 1260 }
1260 } 1261 }
1261 1262
1262 1263
1263 void ClassFinalizer::ReportError(const Script& script, 1264 void ClassFinalizer::ReportError(const Script& script,
1264 intptr_t token_index, 1265 intptr_t token_index,
1265 const char* format, ...) { 1266 const char* format, ...) {
1266 const intptr_t kMessageBufferSize = 512;
1267 char message_buffer[kMessageBufferSize];
1268 va_list args; 1267 va_list args;
1269 va_start(args, format); 1268 va_start(args, format);
1270 Parser::FormatMessage(script, token_index, "Error", 1269 const Error& error = Error::Handle(
1271 message_buffer, kMessageBufferSize, 1270 Parser::FormatError(script, token_index, "Error", format, args));
1272 format, args); 1271 Isolate::Current()->long_jump_base()->Jump(1, error);
1273 Isolate::Current()->long_jump_base()->Jump(1, message_buffer);
1274 UNREACHABLE(); 1272 UNREACHABLE();
1275 } 1273 }
1276 1274
1277 1275
1278 void ClassFinalizer::ReportError(const char* format, ...) { 1276 void ClassFinalizer::ReportError(const char* format, ...) {
1279 const intptr_t kMessageBufferSize = 512;
1280 char message_buffer[kMessageBufferSize];
1281 va_list args; 1277 va_list args;
1282 va_start(args, format); 1278 va_start(args, format);
1283 Parser::FormatMessage(Script::Handle(), -1, "Error", 1279 const Error& error = Error::Handle(
1284 message_buffer, kMessageBufferSize, 1280 Parser::FormatError(Script::Handle(), -1, "Error", format, args));
1285 format, args);
1286 va_end(args); 1281 va_end(args);
1287 Isolate::Current()->long_jump_base()->Jump(1, message_buffer); 1282 Isolate::Current()->long_jump_base()->Jump(1, error);
1288 UNREACHABLE(); 1283 UNREACHABLE();
1289 } 1284 }
1290 1285
1291 1286
1292 void ClassFinalizer::ReportWarning(const Script& script, 1287 void ClassFinalizer::ReportWarning(const Script& script,
1293 intptr_t token_index, 1288 intptr_t token_index,
1294 const char* format, ...) { 1289 const char* format, ...) {
1295 if (FLAG_silent_warnings) return; 1290 if (FLAG_silent_warnings) return;
1296 const intptr_t kMessageBufferSize = 512;
1297 char message_buffer[kMessageBufferSize];
1298 va_list args; 1291 va_list args;
1299 va_start(args, format); 1292 va_start(args, format);
1300 Parser::FormatMessage(script, token_index, "Warning", 1293 const Error& error = Error::Handle(
1301 message_buffer, kMessageBufferSize, 1294 Parser::FormatError(script, token_index, "Warning", format, args));
1302 format, args);
1303 va_end(args); 1295 va_end(args);
1304 if (FLAG_warning_as_error) { 1296 if (FLAG_warning_as_error) {
1305 Isolate::Current()->long_jump_base()->Jump(1, message_buffer); 1297 Isolate::Current()->long_jump_base()->Jump(1, error);
1306 UNREACHABLE(); 1298 UNREACHABLE();
1307 } else { 1299 } else {
1308 OS::Print(message_buffer); 1300 OS::Print("%s", error.ToErrorCString());
1309 } 1301 }
1310 } 1302 }
1311 1303
1312 } // namespace dart 1304 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/class_finalizer.h ('k') | runtime/vm/code_generator_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698