about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--subx/012elf.cc16
-rw-r--r--subx/037heap.cc29
-rw-r--r--subx/038---literal_strings.cc7
-rw-r--r--subx/053new-segment.subx13
-rw-r--r--subx/069allocate.subx8
5 files changed, 26 insertions, 47 deletions
diff --git a/subx/012elf.cc b/subx/012elf.cc
index 0f058504..6a31826e 100644
--- a/subx/012elf.cc
+++ b/subx/012elf.cc
@@ -129,15 +129,13 @@ void load_segment_from_program_header(uint8_t* elf_contents, int segment_index,
 }
 
 :(before "End Includes")
-// Very primitive/fixed/insecure ELF segments for now: just consecutive VMAs.
-//   code: 0x09000000 -> 0x09ffffff
-//   data/heap: 0x0a000000 -> 0x0affffff
-//   stack: 0x0b000ffc -> 0x0b000000 (downward)
-const int CODE_SEGMENT = 0x09000000;
-const int DATA_SEGMENT = 0x0a000000;  // keep sync'd with `Heap.limit` in allocate.subx
-const int STACK_SEGMENT = 0x0b000000;
-const int AFTER_STACK = 0x0c000000;
-const int ARGV_DATA_SEGMENT = 0x0c000000;
+// Very primitive/fixed/insecure ELF segments for now.
+//   code:  0x09000000 -> 0x09ffffff
+//   stack: 0xbe000000 -> 0xb0000000 (downward)
+const int CODE_SEGMENT      = 0x09000000;
+const int STACK_SEGMENT     = 0xb0000000;
+const int AFTER_STACK       = 0xbe000000;
+const int ARGV_DATA_SEGMENT = 0xbf000000;
 :(before "End Dump Info for Instruction")
 //? dump_stack();  // slow
 :(code)
diff --git a/subx/037heap.cc b/subx/037heap.cc
deleted file mode 100644
index 315fd0d5..00000000
--- a/subx/037heap.cc
+++ /dev/null
@@ -1,29 +0,0 @@
-//: Support for dynamic allocation.
-//:
-//: Just provide a special label marking the first unused address in the data
-//: segment. Then we'll write SubX helpers to make use of it.
-
-:(before "Begin rewrite_global_variables")
-insert_heap_global_variable(p);
-:(code)
-void insert_heap_global_variable(program& p) {
-  if (SIZE(p.segments) < 2)
-    return;  // no data segment defined
-  // Start-of-heap:
-  p.segments.at(1).lines.push_back(label("Start-of-heap"));
-}
-
-line label(string s) {
-  line result;
-  result.words.push_back(word());
-  result.words.back().data = (s+":");
-  return result;
-}
-
-line imm32(const string& s) {
-  line result;
-  result.words.push_back(word());
-  result.words.back().data = s;
-  result.words.back().metadata.push_back("imm32");
-  return result;
-}
diff --git a/subx/038---literal_strings.cc b/subx/038---literal_strings.cc
index 65a7740b..9b2c3902 100644
--- a/subx/038---literal_strings.cc
+++ b/subx/038---literal_strings.cc
@@ -184,6 +184,13 @@ void skip_comment(istream& in) {
   }
 }
 
+line label(string s) {
+  line result;
+  result.words.push_back(word());
+  result.words.back().data = (s+":");
+  return result;
+}
+
 // helper for tests
 void parse_instruction_character_by_character(const string& line_data) {
   vector<line> out;
diff --git a/subx/053new-segment.subx b/subx/053new-segment.subx
index 1669b097..21837628 100644
--- a/subx/053new-segment.subx
+++ b/subx/053new-segment.subx
@@ -1,4 +1,15 @@
-# Create a new segment (for data) using mmap().
+# Create a new segment (pool of memory for allocating chunks from) in the form
+# of an *allocation descriptor* that can be passed to the memory allocator
+# (defined in a later layer).
+#
+# Currently an allocation descriptor consists of just the bounds of the pool of
+# available memory:
+#
+#   curr : address
+#   end : address
+#
+# This isn't enough information to reclaim individual allocations. We can't
+# support arbitrary reclamation yet.
 
 == code
 #   instruction                     effective address                                                   register    displacement    immediate
diff --git a/subx/069allocate.subx b/subx/069allocate.subx
index 402467fe..14e9fd50 100644
--- a/subx/069allocate.subx
+++ b/subx/069allocate.subx
@@ -16,14 +16,6 @@
 # very same 'allocate' helper. They just need a new allocation descriptor for
 # their book-keeping.
 
-== data
-
-# The 'global' allocation descriptor. Pass this into 'allocate' to claim a
-# hitherto unused bit of memory.
-Heap:
-    Start-of-heap/imm32  # curr
-    0x0b000000/imm32  # limit; keep sync'd with DATA_SEGMENT + SEGMENT_ALIGNMENT
-
 == code
 #   instruction                     effective address                                                   register    displacement    immediate
 # . op          subop               mod             rm32          base        index         scale       r32