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

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

Issue 8401010: Add DART_CHECKVALID (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 1 month 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/isolate_test.cc ('k') | runtime/vm/unit_test.h » ('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/snapshot.h" 5 #include "vm/snapshot.h"
6 6
7 #include "vm/assert.h" 7 #include "vm/assert.h"
8 #include "vm/bigint_operations.h" 8 #include "vm/bigint_operations.h"
9 #include "vm/class_finalizer.h" 9 #include "vm/class_finalizer.h"
10 #include "vm/unit_test.h" 10 #include "vm/unit_test.h"
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 Dart_EnterScope(); // Start a Dart API scope for invoking API functions. 360 Dart_EnterScope(); // Start a Dart API scope for invoking API functions.
361 timer2.Stop(); 361 timer2.Stop();
362 OS::PrintErr("From Snapshot: %dus\n", timer2.TotalElapsedTime()); 362 OS::PrintErr("From Snapshot: %dus\n", timer2.TotalElapsedTime());
363 363
364 // Invoke a function which returns an object. 364 // Invoke a function which returns an object.
365 result = Dart_InvokeStatic(TestCase::lib(), 365 result = Dart_InvokeStatic(TestCase::lib(),
366 Dart_NewString("FieldsTest"), 366 Dart_NewString("FieldsTest"),
367 Dart_NewString("testMain"), 367 Dart_NewString("testMain"),
368 0, 368 0,
369 NULL); 369 NULL);
370 EXPECT(Dart_IsValid(result)); 370 EXPECT_VALID(result);
371 EXPECT(!Dart_ExceptionOccurred(result)); 371 EXPECT(!Dart_ExceptionOccurred(result));
372 372
373 Dart_ExitScope(); // Exit the Dart API scope. 373 Dart_ExitScope(); // Exit the Dart API scope.
374 } 374 }
375 Dart_ShutdownIsolate(); 375 Dart_ShutdownIsolate();
376 376
377 free(buffer); 377 free(buffer);
378 } 378 }
379 379
380 380
(...skipping 26 matching lines...) Expand all
407 // Write snapshot with object content. 407 // Write snapshot with object content.
408 SnapshotWriter writer(true, &buffer, &allocator); 408 SnapshotWriter writer(true, &buffer, &allocator);
409 writer.WriteFullSnapshot(); 409 writer.WriteFullSnapshot();
410 410
411 // Invoke a function which returns an object. 411 // Invoke a function which returns an object.
412 Dart_Handle result = Dart_InvokeStatic(lib, 412 Dart_Handle result = Dart_InvokeStatic(lib,
413 Dart_NewString("FieldsTest"), 413 Dart_NewString("FieldsTest"),
414 Dart_NewString("testMain"), 414 Dart_NewString("testMain"),
415 0, 415 0,
416 NULL); 416 NULL);
417 EXPECT(Dart_IsValid(result)); 417 EXPECT_VALID(result);
418 EXPECT(!Dart_ExceptionOccurred(result)); 418 EXPECT(!Dart_ExceptionOccurred(result));
419 419
420 Dart_ExitScope(); // Exit the Dart API scope. 420 Dart_ExitScope(); // Exit the Dart API scope.
421 } 421 }
422 Dart_ShutdownIsolate(); 422 Dart_ShutdownIsolate();
423 423
424 // Now Create another isolate using the snapshot and execute a method 424 // Now Create another isolate using the snapshot and execute a method
425 // from the script. 425 // from the script.
426 Timer timer2(true, "Snapshot_test"); 426 Timer timer2(true, "Snapshot_test");
427 timer2.Start(); 427 timer2.Start();
428 Dart_CreateIsolate(buffer, NULL); 428 Dart_CreateIsolate(buffer, NULL);
429 { 429 {
430 Dart_EnterScope(); // Start a Dart API scope for invoking API functions. 430 Dart_EnterScope(); // Start a Dart API scope for invoking API functions.
431 timer2.Stop(); 431 timer2.Stop();
432 OS::PrintErr("From Snapshot: %dus\n", timer2.TotalElapsedTime()); 432 OS::PrintErr("From Snapshot: %dus\n", timer2.TotalElapsedTime());
433 433
434 // Invoke a function which returns an object. 434 // Invoke a function which returns an object.
435 Dart_Handle result = Dart_InvokeStatic(TestCase::lib(), 435 Dart_Handle result = Dart_InvokeStatic(TestCase::lib(),
436 Dart_NewString("FieldsTest"), 436 Dart_NewString("FieldsTest"),
437 Dart_NewString("testMain"), 437 Dart_NewString("testMain"),
438 0, 438 0,
439 NULL); 439 NULL);
440 EXPECT(Dart_IsValid(result)); 440 EXPECT_VALID(result);
441 if (Dart_ExceptionOccurred(result)) { 441 if (Dart_ExceptionOccurred(result)) {
442 // Print the exception object. 442 // Print the exception object.
443 fprintf(stderr, "An unhandled exception has been thrown\n"); 443 fprintf(stderr, "An unhandled exception has been thrown\n");
444 Dart_Handle exception_result = Dart_GetException(result); 444 Dart_Handle exception_result = Dart_GetException(result);
445 assert(Dart_IsValid(exception_result)); 445 assert(Dart_IsValid(exception_result));
446 const char* obj_cstring = NULL; 446 const char* obj_cstring = NULL;
447 Dart_Handle retstr = Dart_StringToCString(exception_result, &obj_cstring); 447 Dart_Handle retstr = Dart_StringToCString(exception_result, &obj_cstring);
448 if (!Dart_IsValid(retstr)) { 448 if (!Dart_IsValid(retstr)) {
449 obj_cstring = Dart_GetError(retstr); 449 obj_cstring = Dart_GetError(retstr);
450 } 450 }
451 fprintf(stderr, "%s", obj_cstring); 451 fprintf(stderr, "%s", obj_cstring);
452 } 452 }
453 EXPECT(!Dart_ExceptionOccurred(result)); 453 EXPECT(!Dart_ExceptionOccurred(result));
454 454
455 Dart_ExitScope(); // Exit the Dart API scope. 455 Dart_ExitScope(); // Exit the Dart API scope.
456 } 456 }
457 Dart_ShutdownIsolate(); 457 Dart_ShutdownIsolate();
458 458
459 free(buffer); 459 free(buffer);
460 } 460 }
461 #endif // TARGET_ARCH_IA32. 461 #endif // TARGET_ARCH_IA32.
462 462
463 } // namespace dart 463 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/isolate_test.cc ('k') | runtime/vm/unit_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698