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

Side by Side Diff: vm/snapshot_test.cc

Issue 8673002: - Refactor the isolate callback mechanism to also include creation of the (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: '' Created 9 years 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
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 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 " return obj;\n" 325 " return obj;\n"
326 " }\n" 326 " }\n"
327 "}\n"; 327 "}\n";
328 Dart_Handle result; 328 Dart_Handle result;
329 329
330 uint8_t* buffer; 330 uint8_t* buffer;
331 331
332 // Start an Isolate, load a script and create a full snapshot. 332 // Start an Isolate, load a script and create a full snapshot.
333 Timer timer1(true, "Snapshot_test"); 333 Timer timer1(true, "Snapshot_test");
334 timer1.Start(); 334 timer1.Start();
335 Dart_CreateIsolate(NULL, NULL); 335 Dart_CreateIsolate(NULL);
336 { 336 {
337 Dart_EnterScope(); // Start a Dart API scope for invoking API functions. 337 Dart_EnterScope(); // Start a Dart API scope for invoking API functions.
338 338
339 // Create a test library and Load up a test script in it. 339 // Create a test library and Load up a test script in it.
340 TestCase::LoadTestScript(kScriptChars, NULL); 340 TestCase::LoadTestScript(kScriptChars, NULL);
341 timer1.Stop(); 341 timer1.Stop();
342 OS::PrintErr("Without Snapshot: %dus\n", timer1.TotalElapsedTime()); 342 OS::PrintErr("Without Snapshot: %dus\n", timer1.TotalElapsedTime());
343 343
344 // Write snapshot with object content. 344 // Write snapshot with object content.
345 Isolate* isolate = Isolate::Current(); 345 Isolate* isolate = Isolate::Current();
346 Zone zone(isolate); 346 Zone zone(isolate);
347 HandleScope scope(isolate); 347 HandleScope scope(isolate);
348 SnapshotWriter writer(true, &buffer, &allocator); 348 SnapshotWriter writer(true, &buffer, &allocator);
349 writer.WriteFullSnapshot(); 349 writer.WriteFullSnapshot();
350 350
351 Dart_ExitScope(); // Exit the Dart API scope. 351 Dart_ExitScope(); // Exit the Dart API scope.
352 } 352 }
353 Dart_ShutdownIsolate(); 353 Dart_ShutdownIsolate();
354 354
355 // Now Create another isolate using the snapshot and execute a method 355 // Now Create another isolate using the snapshot and execute a method
356 // from the script. 356 // from the script.
357 Timer timer2(true, "Snapshot_test"); 357 Timer timer2(true, "Snapshot_test");
358 timer2.Start(); 358 timer2.Start();
359 Dart_CreateIsolate(buffer, NULL); 359 Dart_CreateIsolate(buffer);
360 { 360 {
361 Dart_EnterScope(); // Start a Dart API scope for invoking API functions. 361 Dart_EnterScope(); // Start a Dart API scope for invoking API functions.
362 timer2.Stop(); 362 timer2.Stop();
363 OS::PrintErr("From Snapshot: %dus\n", timer2.TotalElapsedTime()); 363 OS::PrintErr("From Snapshot: %dus\n", timer2.TotalElapsedTime());
364 364
365 // Invoke a function which returns an object. 365 // Invoke a function which returns an object.
366 result = Dart_InvokeStatic(TestCase::lib(), 366 result = Dart_InvokeStatic(TestCase::lib(),
367 Dart_NewString("FieldsTest"), 367 Dart_NewString("FieldsTest"),
368 Dart_NewString("testMain"), 368 Dart_NewString("testMain"),
369 0, 369 0,
(...skipping 15 matching lines...) Expand all
385 static const char kFullSnapshotScriptChars[] = { 385 static const char kFullSnapshotScriptChars[] = {
386 #include "snapshot_test.dat" 386 #include "snapshot_test.dat"
387 }; 387 };
388 const char* kScriptChars = kFullSnapshotScriptChars; 388 const char* kScriptChars = kFullSnapshotScriptChars;
389 389
390 uint8_t* buffer; 390 uint8_t* buffer;
391 391
392 // Start an Isolate, load a script and create a full snapshot. 392 // Start an Isolate, load a script and create a full snapshot.
393 Timer timer1(true, "Snapshot_test"); 393 Timer timer1(true, "Snapshot_test");
394 timer1.Start(); 394 timer1.Start();
395 Dart_CreateIsolate(NULL, NULL); 395 Dart_CreateIsolate(NULL);
396 { 396 {
397 Dart_EnterScope(); // Start a Dart API scope for invoking API functions. 397 Dart_EnterScope(); // Start a Dart API scope for invoking API functions.
398 Isolate* isolate = Isolate::Current(); 398 Isolate* isolate = Isolate::Current();
399 Zone zone(isolate); 399 Zone zone(isolate);
400 HandleScope scope(isolate); 400 HandleScope scope(isolate);
401 401
402 // Create a test library and Load up a test script in it. 402 // Create a test library and Load up a test script in it.
403 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); 403 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
404 ClassFinalizer::FinalizePendingClasses(); 404 ClassFinalizer::FinalizePendingClasses();
405 timer1.Stop(); 405 timer1.Stop();
(...skipping 12 matching lines...) Expand all
418 EXPECT_VALID(result); 418 EXPECT_VALID(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);
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 if (Dart_IsError(result)) { 440 if (Dart_IsError(result)) {
441 // Print the error. It is probably an unhandled exception. 441 // Print the error. It is probably an unhandled exception.
442 fprintf(stderr, "%s\n", Dart_GetError(result)); 442 fprintf(stderr, "%s\n", Dart_GetError(result));
443 } 443 }
444 EXPECT_VALID(result); 444 EXPECT_VALID(result);
445 445
446 Dart_ExitScope(); // Exit the Dart API scope. 446 Dart_ExitScope(); // Exit the Dart API scope.
447 } 447 }
448 Dart_ShutdownIsolate(); 448 Dart_ShutdownIsolate();
449 449
450 free(buffer); 450 free(buffer);
451 } 451 }
452 #endif // TARGET_ARCH_IA32. 452 #endif // TARGET_ARCH_IA32.
453 453
454 } // namespace dart 454 } // namespace dart
OLDNEW
« vm/isolate_win.cc ('K') | « vm/isolate_win.cc ('k') | vm/unit_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698