| OLD | NEW |
| 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 #ifndef SRC_VM_HEAP_H_ | 5 #ifndef SRC_VM_HEAP_H_ |
| 6 #define SRC_VM_HEAP_H_ | 6 #define SRC_VM_HEAP_H_ |
| 7 | 7 |
| 8 #include "src/shared/globals.h" | 8 #include "src/shared/globals.h" |
| 9 #include "src/shared/random.h" | 9 #include "src/shared/random.h" |
| 10 #include "src/vm/object.h" | 10 #include "src/vm/object.h" |
| 11 #include "src/vm/object_memory.h" | 11 #include "src/vm/object_memory.h" |
| 12 #include "src/vm/weak_pointer.h" | 12 #include "src/vm/weak_pointer.h" |
| 13 | 13 |
| 14 namespace fletch { | 14 namespace dartino { |
| 15 | 15 |
| 16 class ExitReference; | 16 class ExitReference; |
| 17 | 17 |
| 18 // Heap represents the container for all HeapObjects. | 18 // Heap represents the container for all HeapObjects. |
| 19 class Heap { | 19 class Heap { |
| 20 public: | 20 public: |
| 21 explicit Heap(RandomXorShift* random, int maximum_initial_size = 0); | 21 explicit Heap(RandomXorShift* random, int maximum_initial_size = 0); |
| 22 ~Heap(); | 22 ~Heap(); |
| 23 | 23 |
| 24 // Allocate raw object. Returns a failure if a garbage collection is | 24 // Allocate raw object. Returns a failure if a garbage collection is |
| (...skipping 17 matching lines...) Expand all Loading... |
| 42 Object* CreateArray(Class* the_class, int length, Object* init_value); | 42 Object* CreateArray(Class* the_class, int length, Object* init_value); |
| 43 | 43 |
| 44 // Allocate byte array. | 44 // Allocate byte array. |
| 45 Object* CreateByteArray(Class* the_class, int length); | 45 Object* CreateByteArray(Class* the_class, int length); |
| 46 | 46 |
| 47 // Allocate heap integer. | 47 // Allocate heap integer. |
| 48 Object* CreateLargeInteger(Class* the_class, int64 value); | 48 Object* CreateLargeInteger(Class* the_class, int64 value); |
| 49 void TryDeallocInteger(LargeInteger* object); | 49 void TryDeallocInteger(LargeInteger* object); |
| 50 | 50 |
| 51 // Allocate double. | 51 // Allocate double. |
| 52 Object* CreateDouble(Class* the_class, fletch_double value); | 52 Object* CreateDouble(Class* the_class, dartino_double value); |
| 53 | 53 |
| 54 // Allocate boxed. | 54 // Allocate boxed. |
| 55 Object* CreateBoxed(Class* the_class, Object* value); | 55 Object* CreateBoxed(Class* the_class, Object* value); |
| 56 | 56 |
| 57 // Allocate static variable info. | 57 // Allocate static variable info. |
| 58 Object* CreateInitializer(Class* the_class, Function* function); | 58 Object* CreateInitializer(Class* the_class, Function* function); |
| 59 | 59 |
| 60 // Allocate dispatch table entry. | 60 // Allocate dispatch table entry. |
| 61 Object* CreateDispatchTableEntry(Class* the_class); | 61 Object* CreateDispatchTableEntry(Class* the_class); |
| 62 | 62 |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 } | 248 } |
| 249 | 249 |
| 250 // Read [object] as an integer int64 value. | 250 // Read [object] as an integer int64 value. |
| 251 // | 251 // |
| 252 // [object] must be either a Smi or a LargeInteger. | 252 // [object] must be either a Smi or a LargeInteger. |
| 253 inline int64 AsForeignInt64(Object* object) { | 253 inline int64 AsForeignInt64(Object* object) { |
| 254 return object->IsSmi() ? Smi::cast(object)->value() | 254 return object->IsSmi() ? Smi::cast(object)->value() |
| 255 : LargeInteger::cast(object)->value(); | 255 : LargeInteger::cast(object)->value(); |
| 256 } | 256 } |
| 257 | 257 |
| 258 } // namespace fletch | 258 } // namespace dartino |
| 259 | 259 |
| 260 #endif // SRC_VM_HEAP_H_ | 260 #endif // SRC_VM_HEAP_H_ |
| OLD | NEW |