1. 25 Dec, 2018 1 commit
    • Yorick Peterse's avatar
      Reorganise and test std::time · 7f0cb46b
      Yorick Peterse authored
      std::time is now broken up into two modules:
      
      1. std::time, which provides time related types.
      2. std::time::duration, which provides the Duration type.
      
      This separation allows for the use of module methods to construct a
      Duration using different time units, instead of using methods defined on
      Duration itself. This means that instead of this:
      
          import std::time::Duration
      
          Duration.from_seconds(5)
      
      You now write this:
      
          import std::time::duration
      
          duration.from_seconds(5)
      
      == Renaming MonotonicTime to Instant
      
      MonotonicTime has been renamed to "Instant", which is a bit shorter and
      much easier to type. A new method has been added as well: "elapsed".
      This method can be used to measure the time that has elapsed since the
      Instant was created.
      
      == Adding and subtracting SystemTime and Instant
      
      The methods + and - for SystemTime and Instant no longer accept a
      ToFloat, instead they require a Duration. Accepting a ToFloat would
      allow you to add a SystemTime to another SystemTime, or add an Instant
      to an Instant. Neither make sense, so instead we now require the use of
      a Duration. This means that instead of this:
      
          import std::time
      
          time.now + 5
      
      You now have to write this:
      
          import std::time
          import std::time::duration
      
          time.now + duration.from_seconds(5)
      
      == Tests
      
      Finally, both std::time and std::time::duration have tests. These tests
      uncovered a few bugs in the implementation of SystemTime, which have
      been resolved.
      7f0cb46b
  2. 23 Dec, 2018 1 commit
  3. 22 Dec, 2018 1 commit
    • Yorick Peterse's avatar
      Added method Float.to_bits · a4c2d681
      Yorick Peterse authored
      This method can be used to obtain the bitwise representation of a Float.
      This in turn can be used to perform an approximate equality comparison
      by checking bits of a Float.
      a4c2d681
  4. 19 Dec, 2018 4 commits
    • Yorick Peterse's avatar
      Rename Immix bitmap structures to bytemaps · 57247e71
      Yorick Peterse authored
      These structures have been bytemaps for quite a while now, so let's
      start calling them that.
      57247e71
    • Yorick Peterse's avatar
      Fix lookups in ObjectMirror.implements_trait? · 9af64983
      Yorick Peterse authored
      This method would mistakingly keep looking up traits in the mirror
      subject, instead of using the objects in the prototype chain.
      9af64983
    • Yorick Peterse's avatar
      Added tests for std::trait · e33ed34f
      Yorick Peterse authored
      e33ed34f
    • Yorick Peterse's avatar
      Move all "class" methods to module methods · 1a577430
      Yorick Peterse authored
      In the past I have gone back and forth a bit on the idea of using
      class/static methods or not. With this commit I'm making a final
      decision on this topic: Inko will not have class/static methods, at
      least not until 1.0. Instead, Inko will use module methods. This means
      that the following methods have been changed:
      
      * HashMap.from_array  -> std::hash_map.from_array
      * Trait.implement_for -> std::trait.implement
      * Integer.from_string -> std::integer.parse
      * Float.from_string   -> std::float.parse
      
      To make this happen some compiler changes had to be made to optimise
      `hash_map.from_array` and to use `trait.implement` instead of
      `Trait.implement_for`.
      1a577430
  5. 17 Dec, 2018 1 commit
    • Yorick Peterse's avatar
      Enforce a limit on bytecode input sizes · 26f0023c
      Yorick Peterse authored
      This adds limits to various parts of the bytecode parser that are
      enforced when reading various literals, such as strings and Compiled
      Code objects. These limits prevent the VM from crashing with an OOM
      error when reading malformed (or _very_ large) bytecode files.
      26f0023c
  6. 16 Dec, 2018 1 commit
    • Yorick Peterse's avatar
      Parsing of Strings into Floats and Integers · 6558d6b5
      Yorick Peterse authored
      This adds support for parsing a String into a Float and an Integer.
      There are two ways of doing so:
      
      1. By sending `to_integer` or `to_float` to a `String`.
      2. Using `Integer.from_string` or `Float.from_string`.
      
      Using `to_integer` and `to_float` will perform a lossy conversion:
      returning 0 or 0.0 for invalid input. Using the `from_string` methods
      will result in a strict conversion, with an error being thrown for
      invalid input.
      
      Fixes #134
      Fixes #156
      6558d6b5
  7. 11 Dec, 2018 3 commits
    • Yorick Peterse's avatar
      Remove SystemTime.format and SystemTime.parse · a38d0f56
      Yorick Peterse authored
      At least for the time being Inko will not provide parsing and formatting
      of times in the standard library. There are many different input and
      output formats people may need to work with, and Inko can't possibly
      support all of them. I am also not sure what format Inko _would_ support
      at this time. Since supporting this is not crucial at this time, we'll
      simply skip it altogether.
      
      See #96 for more information.
      a38d0f56
    • Yorick Peterse's avatar
      Fixed racy tests for std::env · 4a985130
      Yorick Peterse authored
      These tests could randomly fail due to some removing an environment
      variable and expecting it to remain removed, while other tests would
      re-add the variable.
      
      Fixes #154
      4a985130
    • Yorick Peterse's avatar
      Move std::reflection into std::mirror · b3c7e36f
      Yorick Peterse authored
      This moves all code from `std::reflection` into `std::mirror`, finally
      removing the need for the two separate modules. We also renamed
      `kind_of?` to `implements_trait?`, and implemented both it and
      `instance_of?` in pure Inko. This in turn allows us to remove some
      specialised VM instructions.
      
      Fixes #153
      b3c7e36f
  8. 10 Dec, 2018 1 commit
    • Yorick Peterse's avatar
      Tests for std::process and remove receive_if · bf0d6d66
      Yorick Peterse authored
      This adds tests for `std::process`, and removes
      `std::process.receive_if`. The `receive_if` method has always been a bit
      of a weird method. It was originally meant to allow some form of pattern
      matching on messages, but this turned out to be less useful than hoped
      due to the return type still being `Dynamic`.
      
      The `timeout` argument was also not used properly, and solving this
      would not be easily doable.  This is because there was no single
      operation to apply the timeout to, instead the implementation of
      `receive_if` contained two `receive` calls, and some other logic.
      Handling all this would require us to keep track of the elapsed time
      ourselves, which is rather tricky should the process be stuck in a
      blocking receive.
      
      Instead of trying to come up with all kinds of crazy ideas, I have opted
      to simply remove `receive_if` for the time being. This makes some test
      runner code a bit more fragile (in theory), but I doubt this will pose
      any real problems any time soon.
      bf0d6d66
  9. 09 Dec, 2018 4 commits
  10. 08 Dec, 2018 3 commits
    • Yorick Peterse's avatar
      Reset maiting state when there is a process · a51d1b62
      Yorick Peterse authored
      When a process was waiting for a message and there is one now, we need
      to make sure we reset the waiting state.
      a51d1b62
    • Yorick Peterse's avatar
      Removed storing of entire process statuses · 86cadf10
      Yorick Peterse authored
      Obtaining the process status has always been a bit questionable. For
      one, it's not particularly useful to see that a process is running or
      being garbage collected. Second, it requires a full 8 bytes of memory
      per process to store.
      
      In this commit, we drop the storing of full process statuses, and add a
      boolean flag "waiting for message" that we use instead where necessary.
      Currently this won't reduce the size of a process due to alignment
      requirements, but in the future we may be able to work around this by
      reducing the size of other fields.
      86cadf10
    • Yorick Peterse's avatar
      Use two survivor spaces for local allocators · 3caf9631
      Yorick Peterse authored
      Using three survivor spaces instead of two does not really offer many
      benefits, as objects surviving two collections are likely to also
      survive a third. Removing one survivor space reduces the size of a
      process by at least 32 bytes.
      3caf9631
  11. 07 Dec, 2018 4 commits
  12. 06 Dec, 2018 5 commits
    • Yorick Peterse's avatar
      Clean up code for Clippy on Rust 1.31 · 05d8972f
      Yorick Peterse authored
      The latest version of Clippy introduced some new lints, and will now
      complain about the deprecated syntax. Unfortunately, the new tool_lints
      syntax doesn't work on older Rust versions so we can not yet start
      using it.
      
      This commit also refactors various disabled Clippy lints away. Some of
      the disable lines are still necessary as Clippy is overly pedantic, but
      this at least gets rid of a large portion of them.
      05d8972f
    • Yorick Peterse's avatar
      Move histograms from buckets to allocators · f0b6fde0
      Yorick Peterse authored
      This moves the mark and available histograms outside of the Bucket type
      and into the local and mailbox allocators, reducing the memory required
      per process by at least 100 bytes. Behaviour wise nothing changes, as
      for the LocalAllocator we would evacuate objects for all Buckets the
      moment we'd find one that was fragmented.
      f0b6fde0
    • Yorick Peterse's avatar
      Use i8 for the bucket ages · 5aaa746b
      Yorick Peterse authored
      An i8 is large enough to store all values, but requires only half the
      space compared to an i16. This reduces the size of the Process type by
      24 bytes.
      5aaa746b
    • Yorick Peterse's avatar
      Use u32 for block allocation thresholds · ff158aae
      Yorick Peterse authored
      An u32 is enough to represent 128 TB worth of Immix blocks, and means a
      GenerationConfig only takes up 8 bytes of space, instead of 16 bytes.
      ff158aae
    • Yorick Peterse's avatar
      Rework storage and use of GC statistics · e5b1919f
      Yorick Peterse authored
      This commit makes two main changes:
      
      1. Various configuration statistics that were duplicated in the
         GenerationConfig type have been removed, in favour of using the
         source values from the Config type directly.
      
      2. Updating garbage collection statistics has been reworked, to prevent
         garbage collection from running too frequently.
      
      The first change results in processes requiring less memory, though we
      are talking about only a handful of bytes.
      
      The second change is more interesting. Prior to this commit, the number
      of allocated blocks was reset to the number of live blocks. If this
      number would be great enough, the next garbage collection cycle could be
      scheduled much sooner than necessary.
      
      To illustrate this, let's say our threshold is 10 Immix blocks. For the
      first garbage collection to occur, we thus need to allocate 10 Immix
      blocks. If 5 Immix blocks remain live after a cycle, we would only need
      to allocate 5 Immix blocks to trigger the next cycle; instead of
      allocating 10 Immix blocks. This commit fixes this by resetting the
      number of allocated blocks after every cycle.
      e5b1919f
  13. 04 Dec, 2018 2 commits
    • Yorick Peterse's avatar
      Removed double zeroing of Immix histograms · 0a762c81
      Yorick Peterse authored
      Immix histograms use a Chunk under the hood, and the memory for a Chunk
      is already zeroed upon allocation. Since AtomicUsize has the same memory
      representation as usize, we can just leave out the additional zeroing in
      Histogram::new().
      0a762c81
    • Yorick Peterse's avatar
      Use 1 env variable for concurrency settings · d1496336
      Yorick Peterse authored
      The number of OS threads to use for the various worker pools in the VM
      is now controlled using a single environment variable
      (INKO_CONCURRENCY), instead of using one environment variable for every
      pool. This should make it a little easier to scale things up, without
      having to set five different environment variables accordingly.
      d1496336
  14. 03 Dec, 2018 1 commit
  15. 28 Nov, 2018 1 commit
  16. 27 Nov, 2018 2 commits
    • Yorick Peterse's avatar
      Add tests for std::iterator · ab0f61db
      Yorick Peterse authored
      ab0f61db
    • Yorick Peterse's avatar
      Improve remapping of initialised type parameters · 8450931d
      Yorick Peterse authored
      This improves the compiler's support for remapping type parameters to
      the appropriate type parameter instance. For example, consider type T
      that has type parameter A initialised to type parameter B, and B is
      initialised to C. Previously, when looking up the instance of A the
      compiler would produce B. As of this commit, the compiler would produce
      type C instead. This removes the need for type annotations in various
      cases, most notably when working with iterators.
      
      Fixes #117
      8450931d
  17. 26 Nov, 2018 1 commit
  18. 25 Nov, 2018 4 commits