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

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

Issue 1953673004: Remove unnecessary full GCs before snapshot creation. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « no previous file | runtime/vm/snapshot.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) 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 "include/dart_api.h" 5 #include "include/dart_api.h"
6 #include "include/dart_mirrors_api.h" 6 #include "include/dart_mirrors_api.h"
7 #include "include/dart_native_api.h" 7 #include "include/dart_native_api.h"
8 8
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "lib/stacktrace.h" 10 #include "lib/stacktrace.h"
(...skipping 1464 matching lines...) Expand 10 before | Expand all | Expand 10 after
1475 RETURN_NULL_ERROR(isolate_snapshot_buffer); 1475 RETURN_NULL_ERROR(isolate_snapshot_buffer);
1476 } 1476 }
1477 if (isolate_snapshot_size == NULL) { 1477 if (isolate_snapshot_size == NULL) {
1478 RETURN_NULL_ERROR(isolate_snapshot_size); 1478 RETURN_NULL_ERROR(isolate_snapshot_size);
1479 } 1479 }
1480 // Finalize all classes if needed. 1480 // Finalize all classes if needed.
1481 Dart_Handle state = Api::CheckAndFinalizePendingClasses(T); 1481 Dart_Handle state = Api::CheckAndFinalizePendingClasses(T);
1482 if (::Dart_IsError(state)) { 1482 if (::Dart_IsError(state)) {
1483 return state; 1483 return state;
1484 } 1484 }
1485 I->heap()->CollectAllGarbage();
1486 I->StopBackgroundCompiler(); 1485 I->StopBackgroundCompiler();
1487 1486
1488 #if defined(DEBUG) 1487 #if defined(DEBUG)
1488 I->heap()->CollectAllGarbage();
1489 FunctionVisitor check_canonical(T); 1489 FunctionVisitor check_canonical(T);
1490 I->heap()->IterateObjects(&check_canonical); 1490 I->heap()->IterateObjects(&check_canonical);
1491 #endif // #if defined(DEBUG). 1491 #endif // #if defined(DEBUG)
1492 1492
1493 FullSnapshotWriter writer(Snapshot::kCore, 1493 FullSnapshotWriter writer(Snapshot::kCore,
1494 vm_isolate_snapshot_buffer, 1494 vm_isolate_snapshot_buffer,
1495 isolate_snapshot_buffer, 1495 isolate_snapshot_buffer,
1496 ApiReallocate, 1496 ApiReallocate,
1497 NULL, /* instructions_writer */ 1497 NULL, /* instructions_writer */
1498 true /* vm_isolate_is_symbolic */); 1498 true /* vm_isolate_is_symbolic */);
1499 writer.WriteFullSnapshot(); 1499 writer.WriteFullSnapshot();
1500 *vm_isolate_snapshot_size = writer.VmIsolateSnapshotSize(); 1500 *vm_isolate_snapshot_size = writer.VmIsolateSnapshotSize();
1501 *isolate_snapshot_size = writer.IsolateSnapshotSize(); 1501 *isolate_snapshot_size = writer.IsolateSnapshotSize();
(...skipping 16 matching lines...) Expand all
1518 Dart_Handle state = Api::CheckAndFinalizePendingClasses(T); 1518 Dart_Handle state = Api::CheckAndFinalizePendingClasses(T);
1519 if (::Dart_IsError(state)) { 1519 if (::Dart_IsError(state)) {
1520 return state; 1520 return state;
1521 } 1521 }
1522 Library& lib = Library::Handle(Z); 1522 Library& lib = Library::Handle(Z);
1523 if (library == Dart_Null()) { 1523 if (library == Dart_Null()) {
1524 lib ^= I->object_store()->root_library(); 1524 lib ^= I->object_store()->root_library();
1525 } else { 1525 } else {
1526 lib ^= Api::UnwrapHandle(library); 1526 lib ^= Api::UnwrapHandle(library);
1527 } 1527 }
1528
1529 #if defined(DEBUG)
1528 I->heap()->CollectAllGarbage(); 1530 I->heap()->CollectAllGarbage();
1529 #if defined(DEBUG)
1530 FunctionVisitor check_canonical(T); 1531 FunctionVisitor check_canonical(T);
1531 I->heap()->IterateObjects(&check_canonical); 1532 I->heap()->IterateObjects(&check_canonical);
1532 #endif // #if defined(DEBUG). 1533 #endif // #if defined(DEBUG)
1534
1533 ScriptSnapshotWriter writer(buffer, ApiReallocate); 1535 ScriptSnapshotWriter writer(buffer, ApiReallocate);
1534 writer.WriteScriptSnapshot(lib); 1536 writer.WriteScriptSnapshot(lib);
1535 *size = writer.BytesWritten(); 1537 *size = writer.BytesWritten();
1536 return Api::Success(); 1538 return Api::Success();
1537 } 1539 }
1538 1540
1539 1541
1540 DART_EXPORT Dart_Handle Dart_CreateScriptSnapshot(uint8_t** buffer, 1542 DART_EXPORT Dart_Handle Dart_CreateScriptSnapshot(uint8_t** buffer,
1541 intptr_t* size) { 1543 intptr_t* size) {
1542 API_TIMELINE_DURATION; 1544 API_TIMELINE_DURATION;
(...skipping 4565 matching lines...) Expand 10 before | Expand all | Expand 10 after
6108 } 6110 }
6109 if (isolate_snapshot_size == NULL) { 6111 if (isolate_snapshot_size == NULL) {
6110 RETURN_NULL_ERROR(isolate_snapshot_size); 6112 RETURN_NULL_ERROR(isolate_snapshot_size);
6111 } 6113 }
6112 if (assembly_buffer == NULL) { 6114 if (assembly_buffer == NULL) {
6113 RETURN_NULL_ERROR(assembly_buffer); 6115 RETURN_NULL_ERROR(assembly_buffer);
6114 } 6116 }
6115 if (assembly_size == NULL) { 6117 if (assembly_size == NULL) {
6116 RETURN_NULL_ERROR(assembly_size); 6118 RETURN_NULL_ERROR(assembly_size);
6117 } 6119 }
6118 I->heap()->CollectAllGarbage();
6119 AssemblyInstructionsWriter instructions_writer(assembly_buffer, 6120 AssemblyInstructionsWriter instructions_writer(assembly_buffer,
6120 ApiReallocate, 6121 ApiReallocate,
6121 2 * MB /* initial_size */); 6122 2 * MB /* initial_size */);
6122 FullSnapshotWriter writer(Snapshot::kAppNoJIT, 6123 FullSnapshotWriter writer(Snapshot::kAppNoJIT,
6123 vm_isolate_snapshot_buffer, 6124 vm_isolate_snapshot_buffer,
6124 isolate_snapshot_buffer, 6125 isolate_snapshot_buffer,
6125 ApiReallocate, 6126 ApiReallocate,
6126 &instructions_writer, 6127 &instructions_writer,
6127 false /* vm_isolate_is_symbolic */); 6128 false /* vm_isolate_is_symbolic */);
6128 6129
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
6169 } 6170 }
6170 if (instructions_blob_size == NULL) { 6171 if (instructions_blob_size == NULL) {
6171 RETURN_NULL_ERROR(instructions_blob_size); 6172 RETURN_NULL_ERROR(instructions_blob_size);
6172 } 6173 }
6173 if (rodata_blob_buffer == NULL) { 6174 if (rodata_blob_buffer == NULL) {
6174 RETURN_NULL_ERROR(instructions_blob_buffer); 6175 RETURN_NULL_ERROR(instructions_blob_buffer);
6175 } 6176 }
6176 if (rodata_blob_size == NULL) { 6177 if (rodata_blob_size == NULL) {
6177 RETURN_NULL_ERROR(instructions_blob_size); 6178 RETURN_NULL_ERROR(instructions_blob_size);
6178 } 6179 }
6179 I->heap()->CollectAllGarbage();
6180 BlobInstructionsWriter instructions_writer(instructions_blob_buffer, 6180 BlobInstructionsWriter instructions_writer(instructions_blob_buffer,
6181 rodata_blob_buffer, 6181 rodata_blob_buffer,
6182 ApiReallocate, 6182 ApiReallocate,
6183 2 * MB /* initial_size */); 6183 2 * MB /* initial_size */);
6184 FullSnapshotWriter writer(Snapshot::kAppNoJIT, 6184 FullSnapshotWriter writer(Snapshot::kAppNoJIT,
6185 vm_isolate_snapshot_buffer, 6185 vm_isolate_snapshot_buffer,
6186 isolate_snapshot_buffer, 6186 isolate_snapshot_buffer,
6187 ApiReallocate, 6187 ApiReallocate,
6188 &instructions_writer, 6188 &instructions_writer,
6189 false /* vm_isolate_is_symbolic */); 6189 false /* vm_isolate_is_symbolic */);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
6266 RETURN_NULL_ERROR(instructions_blob_buffer); 6266 RETURN_NULL_ERROR(instructions_blob_buffer);
6267 } 6267 }
6268 if (rodata_blob_size == NULL) { 6268 if (rodata_blob_size == NULL) {
6269 RETURN_NULL_ERROR(instructions_blob_size); 6269 RETURN_NULL_ERROR(instructions_blob_size);
6270 } 6270 }
6271 // Finalize all classes if needed. 6271 // Finalize all classes if needed.
6272 Dart_Handle state = Api::CheckAndFinalizePendingClasses(T); 6272 Dart_Handle state = Api::CheckAndFinalizePendingClasses(T);
6273 if (::Dart_IsError(state)) { 6273 if (::Dart_IsError(state)) {
6274 return state; 6274 return state;
6275 } 6275 }
6276 I->heap()->CollectAllGarbage();
6277 I->StopBackgroundCompiler(); 6276 I->StopBackgroundCompiler();
6278 6277
6279 BlobInstructionsWriter instructions_writer(instructions_blob_buffer, 6278 BlobInstructionsWriter instructions_writer(instructions_blob_buffer,
6280 rodata_blob_buffer, 6279 rodata_blob_buffer,
6281 ApiReallocate, 6280 ApiReallocate,
6282 2 * MB /* initial_size */); 6281 2 * MB /* initial_size */);
6283 FullSnapshotWriter writer(Snapshot::kAppWithJIT, 6282 FullSnapshotWriter writer(Snapshot::kAppWithJIT,
6284 vm_isolate_snapshot_buffer, 6283 vm_isolate_snapshot_buffer,
6285 isolate_snapshot_buffer, 6284 isolate_snapshot_buffer,
6286 ApiReallocate, 6285 ApiReallocate,
(...skipping 16 matching lines...) Expand all
6303 6302
6304 DART_EXPORT bool Dart_IsPrecompiledRuntime() { 6303 DART_EXPORT bool Dart_IsPrecompiledRuntime() {
6305 #if defined(DART_PRECOMPILED_RUNTIME) 6304 #if defined(DART_PRECOMPILED_RUNTIME)
6306 return true; 6305 return true;
6307 #else 6306 #else
6308 return false; 6307 return false;
6309 #endif 6308 #endif
6310 } 6309 }
6311 6310
6312 } // namespace dart 6311 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698