Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 // Generate a snapshot file after loading all the scripts specified on the | 5 // Generate a snapshot file after loading all the scripts specified on the |
| 6 // command line. | 6 // command line. |
| 7 | 7 |
| 8 #include <stdlib.h> | 8 #include <stdlib.h> |
| 9 #include <string.h> | 9 #include <string.h> |
| 10 #include <stdio.h> | 10 #include <stdio.h> |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 350 // Shutdown the isolate. | 350 // Shutdown the isolate. |
| 351 Dart_ExitScope(); | 351 Dart_ExitScope(); |
| 352 Dart_ShutdownIsolate(); | 352 Dart_ShutdownIsolate(); |
| 353 | 353 |
| 354 // Now load the specified script and create a script snapshot. | 354 // Now load the specified script and create a script snapshot. |
| 355 Dart_Isolate isolate = Dart_CreateIsolate(NULL, | 355 Dart_Isolate isolate = Dart_CreateIsolate(NULL, |
| 356 NULL, | 356 NULL, |
| 357 snapshot_buffer, | 357 snapshot_buffer, |
| 358 NULL, | 358 NULL, |
| 359 &error); | 359 &error); |
| 360 free(snapshot_buffer); | |
| 361 if (isolate == NULL) { | 360 if (isolate == NULL) { |
| 362 fprintf(stderr, "%s", error); | 361 fprintf(stderr, "%s", error); |
| 363 free(error); | 362 free(error); |
|
Ivan Posva
2012/10/18 05:45:52
"Leaking" the snapshot_buffer here.
siva
2012/10/18 17:55:43
Fixing in a new CL.
On 2012/10/18 05:45:52, Ivan
| |
| 364 exit(255); | 363 exit(255); |
| 365 } | 364 } |
| 366 Dart_EnterScope(); | 365 Dart_EnterScope(); |
| 367 | 366 |
| 368 // Setup generic library tag handler. | 367 // Setup generic library tag handler. |
| 369 result = Dart_SetLibraryTagHandler(DartUtils::LibraryTagHandler); | 368 result = Dart_SetLibraryTagHandler(DartUtils::LibraryTagHandler); |
| 370 CHECK_RESULT(result); | 369 CHECK_RESULT(result); |
| 371 | 370 |
| 372 // Get handle to builtin library. | 371 // Get handle to builtin library. |
| 373 Dart_Handle builtin_lib = | 372 Dart_Handle builtin_lib = |
| 374 Builtin::LoadAndCheckLibrary(Builtin::kBuiltinLibrary); | 373 Builtin::LoadAndCheckLibrary(Builtin::kBuiltinLibrary); |
| 375 CHECK_RESULT(builtin_lib); | 374 CHECK_RESULT(builtin_lib); |
| 376 | 375 |
| 377 // Prepare for script loading by setting up the 'print' and 'timer' | 376 // Prepare for script loading by setting up the 'print' and 'timer' |
| 378 // closures and setting up 'package root' for URI resolution. | 377 // closures and setting up 'package root' for URI resolution. |
| 379 result = DartUtils::PrepareForScriptLoading(package_root, builtin_lib); | 378 result = DartUtils::PrepareForScriptLoading(package_root, builtin_lib); |
| 380 CHECK_RESULT(result); | 379 CHECK_RESULT(result); |
| 381 | 380 |
| 382 // Load specified script. | 381 // Load specified script. |
| 383 library = DartUtils::LoadScript(app_script_name, true, builtin_lib); | 382 library = DartUtils::LoadScript(app_script_name, true, builtin_lib); |
| 384 | 383 |
| 385 // Now create and write snapshot of script. | 384 // Now create and write snapshot of script. |
| 386 CreateAndWriteSnapshot(true); | 385 CreateAndWriteSnapshot(true); |
| 386 | |
| 387 free(snapshot_buffer); | |
| 387 } | 388 } |
| 388 } else { | 389 } else { |
| 389 SetupForGenericSnapshotCreation(); | 390 SetupForGenericSnapshotCreation(); |
| 390 CreateAndWriteSnapshot(false); | 391 CreateAndWriteSnapshot(false); |
| 391 } | 392 } |
| 392 return 0; | 393 return 0; |
| 393 } | 394 } |
| OLD | NEW |