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

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

Issue 2326483005: Shrink AOT snapshot size and memory usage. (Closed)
Patch Set: . Created 4 years, 3 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
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/gc_marker.h" 5 #include "vm/gc_marker.h"
6 6
7 #include "vm/allocation.h" 7 #include "vm/allocation.h"
8 #include "vm/dart_api_state.h" 8 #include "vm/dart_api_state.h"
9 #include "vm/isolate.h" 9 #include "vm/isolate.h"
10 #include "vm/log.h" 10 #include "vm/log.h"
(...skipping 11 matching lines...) Expand all
22 namespace dart { 22 namespace dart {
23 23
24 class SkippedCodeFunctions : public ZoneAllocated { 24 class SkippedCodeFunctions : public ZoneAllocated {
25 public: 25 public:
26 SkippedCodeFunctions() {} 26 SkippedCodeFunctions() {}
27 27
28 void Add(RawFunction* func) { 28 void Add(RawFunction* func) {
29 skipped_code_functions_.Add(func); 29 skipped_code_functions_.Add(func);
30 } 30 }
31 31
32 void DetachCode() { 32 void DetachCode() {
Florian Schneider 2016/09/14 21:32:52 Is code collection not disabled when running preco
rmacnak 2016/09/15 17:01:22 Code collection is always off for AOT. Done.
33 intptr_t unoptimized_code_count = 0; 33 intptr_t unoptimized_code_count = 0;
34 intptr_t current_code_count = 0; 34 intptr_t current_code_count = 0;
35 for (int i = 0; i < skipped_code_functions_.length(); i++) { 35 for (int i = 0; i < skipped_code_functions_.length(); i++) {
36 RawFunction* func = skipped_code_functions_[i]; 36 RawFunction* func = skipped_code_functions_[i];
37 RawCode* code = func->ptr()->code_; 37 RawCode* code = func->ptr()->code_;
38 if (!code->IsMarked()) { 38 if (!code->IsMarked()) {
39 // If the code wasn't strongly visited through other references 39 // If the code wasn't strongly visited through other references
40 // after skipping the function's code pointer, then we disconnect the 40 // after skipping the function's code pointer, then we disconnect the
41 // code from the function. 41 // code from the function.
42 func->StorePointer( 42 func->StorePointer(
43 &(func->ptr()->code_), 43 &(func->ptr()->code_),
44 StubCode::LazyCompile_entry()->code()); 44 StubCode::LazyCompile_entry()->code());
45 uword entry_point = StubCode::LazyCompile_entry()->EntryPoint(); 45 uword entry_point = StubCode::LazyCompile_entry()->EntryPoint();
46 func->ptr()->entry_point_ = entry_point; 46 func->ptr()->entry_point_ = entry_point;
47 if (FLAG_log_code_drop) { 47 if (FLAG_log_code_drop) {
48 // NOTE: This code runs while GC is in progress and runs within 48 // NOTE: This code runs while GC is in progress and runs within
49 // a NoHandleScope block. Hence it is not okay to use a regular Zone 49 // a NoHandleScope block. Hence it is not okay to use a regular Zone
50 // or Scope handle. We use a direct stack handle so the raw pointer in 50 // or Scope handle. We use a direct stack handle so the raw pointer in
51 // this handle is not traversed. The use of a handle is mainly to 51 // this handle is not traversed. The use of a handle is mainly to
52 // be able to reuse the handle based code and avoid having to add 52 // be able to reuse the handle based code and avoid having to add
53 // helper functions to the raw object interface. 53 // helper functions to the raw object interface.
54 String name; 54 String name;
55 name = func->ptr()->name_; 55 name = func->ptr()->name_;
56 THR_Print("Detaching code: %s\n", name.ToCString()); 56 THR_Print("Detaching code: %s\n", name.ToCString());
57 current_code_count++; 57 current_code_count++;
58 } 58 }
59 } 59 }
60 60
61 #if defined(DART_PRECOMPILED_RUNTIME)
62 UNREACHABLE();
63 #else
61 code = func->ptr()->unoptimized_code_; 64 code = func->ptr()->unoptimized_code_;
62 if (!code->IsMarked()) { 65 if (!code->IsMarked()) {
63 // If the code wasn't strongly visited through other references 66 // If the code wasn't strongly visited through other references
64 // after skipping the function's code pointer, then we disconnect the 67 // after skipping the function's code pointer, then we disconnect the
65 // code from the function. 68 // code from the function.
66 func->StorePointer(&(func->ptr()->unoptimized_code_), Code::null()); 69 func->StorePointer(&(func->ptr()->unoptimized_code_), Code::null());
67 if (FLAG_log_code_drop) { 70 if (FLAG_log_code_drop) {
68 unoptimized_code_count++; 71 unoptimized_code_count++;
69 } 72 }
70 } 73 }
74 #endif
71 } 75 }
72 if (FLAG_log_code_drop) { 76 if (FLAG_log_code_drop) {
73 THR_Print(" total detached current: %" Pd "\n", current_code_count); 77 THR_Print(" total detached current: %" Pd "\n", current_code_count);
74 THR_Print(" total detached unoptimized: %" Pd "\n", 78 THR_Print(" total detached unoptimized: %" Pd "\n",
75 unoptimized_code_count); 79 unoptimized_code_count);
76 } 80 }
77 // Clean up. 81 // Clean up.
78 skipped_code_functions_.Clear(); 82 skipped_code_functions_.Clear();
79 } 83 }
80 84
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 // Phase 3: Finalize results from all markers (detach code, etc.). 795 // Phase 3: Finalize results from all markers (detach code, etc.).
792 barrier.Exit(); 796 barrier.Exit();
793 } 797 }
794 ProcessWeakTables(page_space); 798 ProcessWeakTables(page_space);
795 ProcessObjectIdTable(isolate); 799 ProcessObjectIdTable(isolate);
796 } 800 }
797 Epilogue(isolate, invoke_api_callbacks); 801 Epilogue(isolate, invoke_api_callbacks);
798 } 802 }
799 803
800 } // namespace dart 804 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698