Commit Graph

31 Commits (9781342042798f7a75f3f7233872bae0fbde3ecc)

Author SHA1 Message Date
Jonathan Marler f0b8791da7 ArrayList(u8) support writer interface 2020-06-16 18:26:54 -04:00
Jesse Rudolph 100aa6fbaf pass allocator to self.resize() in appendNTimes() 2020-06-02 09:59:13 -05:00
Walter Mays e1186c88ea Remove unimplemented `init` call from ArrayListUnmanaged. 2020-05-26 15:59:56 -04:00
Andrew Kelley 080022f6c6 self-hosted: fix compile errors, except for codegen.zig 2020-05-13 20:06:01 -04:00
Andrew Kelley 619159cf48 self-hosted: rework the memory layout of ir.Module and related types
* add TypedValue.Managed which represents a Type, a Value, and some
   kind of memory management strategy.
 * introduce an analysis queue
 * flesh out how incremental compilation works with respect to exports
 * ir.text.Module is only capable of one error message during parsing
 * link.zig no longer has a decl table map and instead has structs that
   exist directly on ir.Module.Decl and ir.Module.Export
 * implement primitive .text block allocation
 * implement linker code for updating Decls and Exports
 * implement null Type

Some supporting std lib changes:
 * add std.ArrayList.appendSliceAssumeCapacity
 * add std.fs.File.copyRange and copyRangeAll
 * fix std.HashMap having modification safety on in ReleaseSmall builds
 * add std.HashMap.putAssumeCapacityNoClobber
2020-05-12 01:02:48 -04:00
Andrew Kelley a32d3a85d2 rework self-hosted compiler for incremental builds
* introduce std.ArrayListUnmanaged for when you have the allocator
   stored elsewhere
 * move std.heap.ArenaAllocator implementation to its own file. extract
   the main state into std.heap.ArenaAllocator.State, which can be
   stored as an alternative to storing the entire ArenaAllocator, saving
   24 bytes per ArenaAllocator on 64 bit targets.
 * std.LinkedList.Node pointer field now defaults to being null
   initialized.
 * Rework self-hosted compiler Package API
 * Delete almost all the bitrotted self-hosted compiler code. The only bit
   rotted code left is in main.zig and compilation.zig
 * Add call instruction to ZIR
 * self-hosted compiler ir API and link API are reworked to support
   a long-running compiler that incrementally updates declarations
 * Introduce the concept of scopes to ZIR semantic analysis
 * ZIR text format supports referencing named decls that are declared
   later in the file
 * Figure out how memory management works for the long-running compiler
   and incremental compilation. The main roots are top level
   declarations. There is a table of decls. The key is a cryptographic
   hash of the fully qualified decl name. Each decl has an arena
   allocator where all of the memory related to that decl is stored.
   Each code block has its own arena allocator for the lifetime of
   the block. Values that want to survive when going out of scope in
   a block must get copied into the outer block. Finally, values must
   get copied into the Decl arena to be long-lived.
 * Delete the unused MemoryCell struct. Instead, comptime pointers are
   based on references to Decl structs.
 * Figure out how caching works. Each Decl will store a set of other
   Decls which must be recompiled when it changes.

This branch is still work-in-progress; this commit breaks the build.
2020-05-10 02:05:54 -04:00
Vexu ca3bf6e6ad
translate-c cleanup and zig fmt 2020-04-15 15:15:32 +03:00
xackus dbc00e2424 ArrayList: remove old (before span) API 2020-04-11 20:40:34 -04:00
xackus d3ab0eb28d new ArrayList API: fix ArrayList.shrink 2020-04-02 15:15:20 +02:00
xackus dd570dbc0d new ArrayList API, fix enough std lib to test 2020-04-02 15:14:18 +02:00
Andrew Kelley 553f0e0546
fixups and revert a few things 2020-04-01 11:56:39 -04:00
daurnimator 0ee2462a31
std: add std.ArrayList(u8).outStream() 2020-04-01 10:36:38 -04:00
Andrew Kelley 231a4b8fde
fixups & make some API decisions
Removed:
  std.io.InStream.readUntilDelimiterBuffer

Deprecated:
  std.ArrayList.toSlice
  std.ArrayList.toSliceConst
  std.ArrayList.at
  std.ArrayList.ptrAt
  std.ArrayList.setOrError
  std.ArrayList.set
  std.ArrayList.swapRemoveOrError
  std.Buffer.toSlice
  std.Buffer.toSliceConst
  std.io.InStream.readFull => std.io.InStream.readAll
  std.io.InStream.readAllBuffer

New:
  std.ArrayList.span
  std.ArrayList.expandToCapacity
  std.Buffer.span
  std.io.InStream.readUntilDelimiterArrayList
2020-03-06 18:49:13 -05:00
daurnimator fd23decbd9
std: add ArrayList.eql for parity with std.Buffer 2020-03-06 18:49:12 -05:00
daurnimator 119ac13eda
std: add .startsWith and .endsWith to std.ArrayList 2020-03-06 18:49:10 -05:00
Bas 1483ae37f2
Add an appendValues method to ArrayList to append a value n times. (#4460) 2020-02-19 11:33:35 -05:00
Benjamin Feng 699c50a375 Switch a bunch of FBA to use testing.allocator 2020-02-12 17:17:56 -06:00
Benjamin Feng b077f3ab7d Promoted "leak_count_allocator" to the main testing.allocator 2020-01-29 22:22:00 -06:00
Benjamin Feng aa9caf5064 Create leak_count_allocator 2020-01-29 14:37:01 -06:00
Benjamin Feng 4d134a01f5 Move debug.global_allocator to testing.allocator 2020-01-29 12:21:29 -06:00
Benoit Giannangeli fb2f0cc497 ArrayList: ptrAt function returns pointer to item at given index 2019-12-29 18:46:59 -05:00
Andrew Kelley c3d8b1ffeb
remove iterator API from std.ArrayList
This is not a meaningful abstraction. Use a for loop on the result
of `toSlice` or `toSliceConst`.

An iterator can be implemented on top of ArrayList by applications which
want additional functionality, such as removing elements while
iterating.

Closes #3037.
2019-12-10 15:08:10 -05:00
Robin Voetter 4b4fbe3887
Replace @typeOf with @TypeOf in all zig source
This change was mostly made with `zig fmt` and this also modified some whitespace. Note that in some files, `zig fmt` produced incorrect code, so the change was made manually.
2019-12-10 11:09:41 -05:00
Andrew Kelley b36c07a95a
Merge remote-tracking branch 'origin/master' into remove-array-type-coercion 2019-12-01 09:56:01 -05:00
Andrew Kelley 0f2a9af4aa
Merge pull request #3769 from MCRusher/initcapacity-for-buffer-arraylist
Add initCapacity for buffer & arraylist
2019-11-27 13:40:39 -05:00
Andrew Kelley bf3ac66150
remove type coercion from array values to references
* Implements #3768. This is a sweeping breaking change that requires
   many (trivial) edits to Zig source code. Array values no longer
   coerced to slices; however one may use `&` to obtain a reference to
   an array value, which may then be coerced to a slice.

 * Adds `IrInstruction::dump`, for debugging purposes. It's useful to
   call to inspect the instruction when debugging Zig IR.

 * Fixes bugs with result location semantics. See the new behavior test
   cases, and compile error test cases.

 * Fixes bugs with `@typeInfo` not properly resolving const values.

 * Behavior tests are passing but std lib tests are not yet. There
   is more work to do before merging this branch.
2019-11-27 03:37:50 -05:00
Andrew Kelley bdf3680be1
zig fmt 2019-11-25 13:53:13 -05:00
MCRusher 10e6cde083
Added initCapacity and relevant test
Added ArrayList.initCapcity() as a way to preallocate a block of memory to reduce future allocations.

Added a test "std.ArrayList.initCapacity" that ensures initCapacity adds no elements and increases capacity by at least the requested amount
2019-11-23 22:54:33 -05:00
Andrew Kelley e0db54e89d
update the codebase to use `@as` 2019-11-08 15:57:24 -05:00
Nathan Michaels 6fdeaac338 Add some documentation for standard library things. (#3540)
* Add some documentation for standard library things.

Added a bunch of descriptions for array_list.
Added some usage notes for failing_allocator.
Documented some of mem.Allocator.
2019-10-28 03:57:23 -04:00
Andrew Kelley ed36dbbd9c
mv std/ lib/
that's all this commit does. further commits will fix cli flags and
such.

see #2221
2019-09-25 23:35:41 -04:00