Commit graph

13789 commits

Author SHA1 Message Date
Andreas Kling
2c0e153396 LibJS: Don't bother deferring GC during ensure_property_table()
This is not actually necessary, since no GC allocations are made during
this process. If we ever make property tables into heap cells, we'd
have to rethink this.
2020-10-16 08:59:51 +02:00
Andreas Kling
7ad8bb5be6 AK: Tune HashTable load factor
Double the capacity when used+deleted buckets crosses 60% of capacity.
This appears to be a sweet spot for performance based on some ad-hoc
testing with test-js. :^)
2020-10-16 08:47:10 +02:00
BenJilks
afd52e2576 PixelPaint: Tool properties panel
Each tool can have its own set of properties that can be modified
through a panel on the right side.

The tools I've added properties for are:

Pen:
	Thickness

Brush:
	Size
	Hardness

Spray:
	Thickness
	Density

Bucket:
	Threshold
2020-10-16 00:03:53 +02:00
Andreas Kling
544f2f3c96 AK: Add some more checks to the HashMap test 2020-10-16 00:02:23 +02:00
Andreas Kling
4e50079f36 AK: Redesign HashTable to use closed hashing
Instead of each hash bucket being a SinglyLinkedList, switch to using
closed hashing (open addressing). Buckets are chained together via
double hashing (hashing the hash until we find an unused bucket.)

This greatly reduces malloc traffic, since each added element no longer
allocates a new linked list node.

Appears performance neutral on test-js. Can definitely be tuned and
could use proper management of load factor, etc.
2020-10-15 23:49:53 +02:00
Andreas Kling
4387590e65 LibJS: Support move semantics for StringOrSymbol
This allows us to rehash property tables without a bunch of ref count
churn happening.
2020-10-15 23:49:53 +02:00
Andreas Kling
1d96ecf148 Everywhere: Add missing <AK/TemporaryChange.h> includes
Don't rely on HashTable.h pulling this in.
2020-10-15 23:49:53 +02:00
Andreas Kling
76aab2fe8d AK: Improve HashMap tests a little bit 2020-10-15 23:49:53 +02:00
Linus Groh
20907780bd FileManager: Only set ~/Desktop as model root path in desktop mode
Setting it as model root path in DirectoryView::setup_model() for
windowed mode as well would cause an issue with the following:

- "open ~/Desktop"
- "FileManager ~/Desktop"
- "Show in FileManager..." from Desktop context menu

When viewing the Desktop as the initial path it would be the same and
on_path_change wasn't called, leading to various widgets and window
properties not being updated.

Fixes #3772.
2020-10-15 23:49:34 +02:00
Linus Groh
ac98a48177 LibWeb: Fix EventDispatcher::dispatch()
We were never wrapping and using the actual DOM::Event but instead
wrapped the *target* twice and passed it to the event listener callback,
as this value and as argument.

This unbreaks "fun demo" and "canvas path quadratic curve test" - and
event dispatching in general, of course :^)

Fixes #3721.
2020-10-15 20:40:35 +02:00
Matthew L. Curry
a45ba638a7 seq: Add help option
Added a help option to the seq command that gives usage information. Further,
when a user gives an incorrect argument, usage is supplied on stderr.
2020-10-15 13:48:42 +02:00
nooga
7b481a2c73 Userland: Add --loop option for aplay
A tiny feature, useful when listening to your favorite song.
2020-10-15 13:47:42 +02:00
Marcin Gasperowicz
3039c36836 AudioApplet: Make the slider exponential for finer volume control
The volume slider was linear, which is not ideal for an audio volume 
control. Perceived volume would not change much within 30-100% range
and would change in leaps within 0-30% range where the resolution is
not sufficient for fine grained control.

The simplest solution is to bring the value into 0.0-1.0 range and 
square it to obtain an exponential curve. This is a decent 
approximation of the logarithmic taper used in audio potentiometers.
2020-10-15 13:47:27 +02:00
Stephen Gregoratto
5245277369 LibC: Make difftime a function
The previous define led to issues when compiling some ports, namely zsh
5.8.
2020-10-15 13:45:00 +02:00
AnotherTest
9545ed1c21 LibGUI: Fix wrong Sequence highlight range in ShellSyntaxHighlighter
This fixes the wrong highlight behaviour when a newline is used as
sequence separator:
```sh
echo foo
if foo {}
^ This character would previously be bold
```
2020-10-14 21:05:39 +02:00
AnotherTest
b1b202124c Shell: Use Node::kind() instead of Node::class_name() in formatter 2020-10-14 21:05:39 +02:00
AnotherTest
738f512919 Shell: Respect input sources' blank lines between sequences
But collapse them to a single empty line.
This makes the generated sources look significantly better.
2020-10-14 21:05:39 +02:00
AnotherTest
cd48ec2abd Shell: Put a space after the match pattern expression when formatting 2020-10-14 21:05:39 +02:00
BenJilks
5f15fb17d9 PixelPaint: Basic brush tool
This patch adds a very basic implementation of the classic brush
tool. It features a wide brush with a falloff around the edges.
2020-10-14 20:36:40 +02:00
Andreas Kling
1208f3fd75 LibC: We still need to use NULL (not nullptr) in C headers
Thanks to @alimpfard for noticing this.
2020-10-14 13:57:51 +02:00
asynts
c1823d8a34 AK: Don't forward declare abort.
There is no portable way to forward declare abort because the libc
implementations disagree on the signature.

Originally, I added a __portable_abort function with a "portable"
signature which just called abort. But I really don't like it and just
including <stdlib.h> is simpler.

Note that the headers we include in <AK/TestSuite.h> are no longer
commutative now, we have to include <stdlib.h> before anything else.
2020-10-14 11:29:29 +02:00
Linus Groh
e07490ce13 LibJS: Don't assume value for index < size in IndexedPropertyIterator
This assumption only works for the m_packed_elements Vector where a
missing value at a certain index still returns an empty value, but not
for the m_sparse_elements HashMap, which is being used for indices
>= 200 - in that case the Optional<ValueAndAttributes> result will not
have a value.

This fixes a crash in the js REPL where printing an array with a hole at
any index >= 200 would crash.
2020-10-14 00:52:47 +02:00
Andreas Kling
a1029738fd LibJS: Add some more items to CommonPropertyNames that I missed 2020-10-14 00:10:49 +02:00
Lenny Maiorani
2983215fb1 Base64: Pre-allocate size of input and output
Problem:
- Output of decode and encode grow as the decode and encode
  happen. This is inefficient because a large size will require many
  reallocations.
- `const` qualifiers are missing on variables which are not intended
  to change.

Solution:
- Since the size of the decoded or encoded message is known prior to
  starting, calculate the size and set the output to that size
  immediately. All appends will not incur the reallocation overhead.
- Add `const` qualifiers to show intent.
2020-10-13 23:59:46 +02:00
Andreas Kling
8f535435dc LibJS: Avoid property lookups during object initialization
When we're initializing objects, we're just adding a bunch of new
properties, without transition, and without overlap (we never add
the same property twice.)

Take advantage of this by skipping lookups entirely (no need to see
if we're overwriting an existing property) during initialization.

Another nice test-js speedup :^)
2020-10-13 23:57:45 +02:00
Andreas Kling
7b863330dc LibJS: Cache commonly used FlyStrings in the VM
Roughly 7% of test-js runtime was spent creating FlyStrings from string
literals. This patch frontloads that work and caches all the commonly
used names in LibJS on a CommonPropertyNames struct that hangs off VM.
2020-10-13 23:57:45 +02:00
Andreas Kling
9f6c5f68b6 LibJS: Tidy up CallExpression::execute() a little bit 2020-10-13 19:13:37 +02:00
Matthew L. Curry
909687ddf0 Userland/cp: Disallow copying directories into themselves
This patch causes cp to investigate whether a directory is being copied
into a subdirectory of itself. It uses realpath(3) to ensure that links
do not confound detection.
2020-10-13 18:37:32 +02:00
Paul Scharnofske
d94f674bbb
Use new format functions in remaining DevTools. (#3755)
* AK: Add formatter for JsonValue.

* Inspector: Use new format functions.

* Profiler: Use new format functions.

* UserspaceEmulator: Use new format functions.
2020-10-13 18:34:27 +02:00
Lenny Maiorani
626bb1be9c Base64: constexpr initialization of alphabet and lookup table
Problem:
- The Base64 alphabet and lookup table are initialized at
  run-time. This results in an initial start-up cost as well as a
  boolean evaluation and branch every time the function is called.

Solution:
- Provide `constexpr` functions which initialize the alphabet and
  lookup table at compile-time. These can be called and assigned to a
  `constexpr` variable so that there is no run-time cost associated
  with the initialization or lookup.
2020-10-13 18:33:21 +02:00
Stephen Gregoratto
b82da6b78b
Ports: Add pkgconf (#3757) 2020-10-13 13:53:17 +02:00
Matthew L. Curry
5d5c32cec1 Style: Remove uses of NULL, substituting nullptr 2020-10-13 13:52:52 +02:00
AnotherTest
93f4388e45 LibGfx+PixelPaint: Fix distortions in convolutions with size != 4 or 5 2020-10-12 20:04:48 +02:00
Tom
95434d70ed LibGfx: Allow specifying a separate source bitmap for Filter::apply
By allowing to specify a separate source bitmap when calling Filter::apply
the same filter can be applied to multiple areas, and also doesn't need
to use a temporary bitmap. This also enables us to apply the filter to
multiple regions properly, even if they are (almost) adjacent.

If no separate source bitmap is supplied then a temporary bitmap is still
necessary.
2020-10-12 20:04:48 +02:00
Tom
6ad6c4ffad LibGfx: Add overloads to Rect's shrink/inflate that accept a Size<T> 2020-10-12 20:04:48 +02:00
Tom
da8d87c297 LibGfx: Make Filter::Parameters more light-weight
By moving the Bitmap and Rect out of Filter::Parameters we can re-use
the parameters more efficiently, allowing the filter to be applied
to many bitmaps without having to re-create the filter every time.
2020-10-12 20:04:48 +02:00
Tom
6188c6e8a3 LibGfx: Add GenericConvolutionFilter::ApplyCache
Add an overload of GenericConvolutionFilter::apply that can be used
with a GenericConvolutionFilter::ApplyCache instance to avoid having
to allocate a temporary bitmap every time the filter is being applied.
2020-10-12 20:04:48 +02:00
Tom
a2bffc850a LibGfx: Add Size::contains 2020-10-12 20:04:48 +02:00
Tom
8af02fc8b3 LibGfx: Move filters from PixelPaint into LibGfx
This allows re-using the same filters outside of PixelPaint.
2020-10-12 20:04:48 +02:00
Tom
f9700ffb41 PixelPaint: Move GUI logic and filter parameters out of filters 2020-10-12 20:04:48 +02:00
Linus Groh
fb13ea2259 js: Print negative zero with minus sign 2020-10-12 20:03:54 +02:00
Andreas Kling
65cdac1a5b Kernel+LibC: Use uintptr_t as the main type in the syscall interface 2020-10-12 19:53:25 +02:00
Andreas Kling
583bfa04e2 Toolchain: Upgrade to Binutils 2.35.1 2020-10-12 19:53:25 +02:00
Andreas Kling
75d5f436bc Toolchain: Upgrade to GCC 10.2.0 2020-10-12 19:53:25 +02:00
Peter Elliott
b82f2df4c8 Piano: Add UI support for different lengths of notes 2020-10-12 19:41:53 +02:00
Peter Elliott
27b990ec19 Piano: Add note names to RollWidget 2020-10-12 19:41:53 +02:00
Peter Elliott
01bff0141e Piano: Highlight pressed key in roll widget 2020-10-12 19:41:53 +02:00
asynts
0c5497829e IPCCompiler: Use new SourceGenerator class. 2020-10-12 19:40:49 +02:00
asynts
b99cebf63a AK: Add SourceGenerator class. 2020-10-12 19:40:49 +02:00
asynts
71fd54f76b MemoryManager: Off-by-one error when collecting memory pages.
Notice that we ensured that the size is a multiple of the page size and
that there is at least one page there, otherwise, this change would be
invalid.

We create an empty region and then expand it:

    // First iteration.
    m_user_physical_regions.append(PhysicalRegion::create(addr, addr));

    // Following iterations.
    region->expand(region->lower(), addr);

So if the memory region only has one page, we would end up with an empty
region. Thus we need to do one more iteration.
2020-10-12 19:39:00 +02:00