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

Side by Side Diff: src/vm/heap.cc

Issue 2067483002: More compact snapshots. (Closed) Base URL: git@github.com:dartino/sdk.git@master
Patch Set: Feedback Created 4 years, 6 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 | « src/vm/heap.h ('k') | src/vm/interpreter_arm.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) 2014, the Dartino project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dartino 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.md file. 3 // BSD-style license that can be found in the LICENSE.md file.
4 4
5 #include "src/vm/heap.h" 5 #include "src/vm/heap.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include "src/shared/assert.h" 9 #include "src/shared/assert.h"
10 #include "src/shared/flags.h" 10 #include "src/shared/flags.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 55
56 Object* Heap::Allocate(uword size) { 56 Object* Heap::Allocate(uword size) {
57 ASSERT(no_allocation_ == 0); 57 ASSERT(no_allocation_ == 0);
58 uword result = space_->Allocate(size); 58 uword result = space_->Allocate(size);
59 if (result == 0) { 59 if (result == 0) {
60 return HandleAllocationFailure(size); 60 return HandleAllocationFailure(size);
61 } 61 }
62 return HeapObject::FromAddress(result); 62 return HeapObject::FromAddress(result);
63 } 63 }
64 64
65 Object* Heap::CreateBooleanObject(uword position, Class* the_class,
66 Object* init_value) {
67 HeapObject* raw_result = HeapObject::FromAddress(position);
68 Instance* result = reinterpret_cast<Instance*>(raw_result);
69 result->set_class(the_class);
70 result->set_immutable(true);
71 result->InitializeIdentityHashCode(random());
72 result->Initialize(the_class->instance_format().fixed_size(), init_value);
73 return result;
74 }
75
65 Object* Heap::CreateInstance(Class* the_class, Object* init_value, 76 Object* Heap::CreateInstance(Class* the_class, Object* init_value,
66 bool immutable) { 77 bool immutable) {
67 uword size = the_class->instance_format().fixed_size(); 78 uword size = the_class->instance_format().fixed_size();
68 Object* raw_result = Allocate(size); 79 Object* raw_result = Allocate(size);
69 if (raw_result->IsFailure()) return raw_result; 80 if (raw_result->IsFailure()) return raw_result;
70 Instance* result = reinterpret_cast<Instance*>(raw_result); 81 Instance* result = reinterpret_cast<Instance*>(raw_result);
71 result->set_class(the_class); 82 result->set_class(the_class);
72 result->set_immutable(immutable); 83 result->set_immutable(immutable);
73 if (immutable) result->InitializeIdentityHashCode(random()); 84 if (immutable) result->InitializeIdentityHashCode(random());
74 ASSERT(size == the_class->instance_format().fixed_size()); 85 ASSERT(size == the_class->instance_format().fixed_size());
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 filename, current); 437 filename, current);
427 } 438 }
428 } 439 }
429 } 440 }
430 fclose(fp); 441 fclose(fp);
431 #endif // __linux 442 #endif // __linux
432 } 443 }
433 #endif // DEBUG 444 #endif // DEBUG
434 445
435 } // namespace dartino 446 } // namespace dartino
OLDNEW
« no previous file with comments | « src/vm/heap.h ('k') | src/vm/interpreter_arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698