Commit graph

4273 commits

Author SHA1 Message Date
Dmitrii Ubskii
4434e900af 2048: Evil AI settings entry 2021-05-18 08:51:56 +01:00
Dmitrii Ubskii
3e8220dec2 2048: Refactor tile sliding and score logic out of attempt_move() 2021-05-18 08:51:56 +01:00
stelar7
24c5b0e81c LibGfx: Add support for DDS images 2021-05-18 08:45:53 +01:00
DexesTTP
9f42ccd639 WebServer: Fix jailbreaking of server via .. relative paths
The recent patch to LexicalPath allowed relative paths like ../ to work
in requests to WebServer. This wasn't too dangerous because of unveil,
but let's still fix this :^)
2021-05-18 09:32:10 +02:00
Andreas Kling
7957f13e98 Revert "LibC: Simplify malloc size classes"
This reverts commit f91bcb8895.
2021-05-18 08:32:05 +02:00
Gunnar Beutner
f5c4d86592 Utilites: Make find respect lack of -L when iterating over directories
Previously find would follow symlinks when iterating over directories
even though the -L argument was not specified.
2021-05-18 08:11:42 +02:00
Marcus Nilsson
63897c469b
SystemMonitor: Don't try and show process window with nothing selected (#7221)
When right-clicking with no selected row in the process list,
SystemMonitor would still show a context menu. This disables
the context menu if index is invalid and also disables Alt+Enter
so that build_process_window() is never called with a PID of -1.

Fixes #7167.
2021-05-18 08:10:27 +02:00
Idan Horowitz
325febf4e5 LibCompress: Discard GZip NAME & COMMENT optional strings
We now discard these strings instead of copying them into a String
which we immediately destruct. This should result in both a perf uplift
and lower memory usage.
2021-05-18 08:09:21 +02:00
Gunnar Beutner
3ef6e31ded
LibC: Use ptsname_r() instead of ptsname() in openpty() (#7231)
This improves thread-safety because ptsname() is using a global
buffer that is shared between threads.
2021-05-18 08:08:30 +02:00
DexesTTP
812875bc89 LibWebSocket: Fixed occasional infinite loop with TLS sockets
This was caused by a double notifier on the TLS socket, which caused
the TLS code to freak out about not being able to read properly. In
addition, the existing loop inside of drain_read() has been replaced by
code that actually works, and which includes new warnings when the
drain method is called before initialization is done or after the
websocket gets closed.
2021-05-18 08:07:56 +02:00
Gunnar Beutner
2754112a7a Utilities: Make the STATE column for top slightly larger
The STATE column was slightly too small to fit the states for
NetworkTask and FinalizerTask.
2021-05-18 08:07:29 +02:00
Lenny Maiorani
31d24d8292 LibC: Remove static from function local constexpr variable
Problem:
- Function local `constexpr` variables do not need to be
  `static`. This consumes memory which is unnecessary and can prevent
  some optimizations.

Solution:
- Remove `static` keyword.
2021-05-18 08:07:21 +02:00
Lenny Maiorani
f91bcb8895 LibC: Simplify malloc size classes
Problem:
- `size_classes` is a C-style array which makes it difficult to use in
  algorithms.
- `all_of` algorithm is re-written for the specific implementation.

Solution:
- Change `size_classes` to be an `Array`.
- Directly use the generic `all_of` algorithm instead of
  reimplementing.
2021-05-18 08:06:01 +02:00
brapru
c2ae6c189e SystemMonitor: Show UDP sockets
Creates a new TableView in the socket list for UDP information.

Resolves #6980.
2021-05-18 08:03:40 +02:00
Linus Groh
63e8477a6b LibJS: Handle OOB access in GenericIndexedPropertyStorage::take_last()
We already do this for the SimpleIndexedPropertyStorage, so for indexed
properties with GenericIndexedPropertyStorage this would previously
crash. Since overwriting the array-like size with a larger value won't
magically insert values at previously unset indices, we need to handle
such an out of bounds access gracefully and just return an empty value.

Fixes #7043.
2021-05-17 23:20:29 +01:00
Linus Groh
c15121fef7 LibJS: Make length_setter_generic_storage_threshold a global constant
This was a bit hard to find as a local variable - rename it to uppercase
LENGTH_SETTER_GENERIC_STORAGE_THRESHOLD and move it to the top (next to
SPARSE_ARRAY_HOLE_THRESHOLD) for good visibility.
2021-05-17 23:15:18 +01:00
Andreas Kling
5f342c41b9 WindowServer: Don't attempt to make WindowServer inspectable 2021-05-17 23:32:37 +02:00
Andreas Kling
719168a1cd Browser: Move main browser window logic into a BrowserWindow class
Having so much the logic and lambdas in main() was getting unwieldy.
Moving it into a class simplifies this, and also opens up a path
towards supporting "Open in New Window" :^)
2021-05-17 23:32:35 +02:00
Andreas Kling
5d0c3bd564 WindowServer: Add Menu::is_open() to improve readability
"menu.is_open()" instead of "MenuManager::the().is_open(menu)"
2021-05-17 23:28:15 +02:00
Ali Mohammad Pur
7fec66dd1c LibWasm: Make clang happy by removing an 'extra' set of parenthesis
These aren't actually an extra set, without them the fold operation
would be syntactically invalid.
Also remove possible cast of float->double/double->float in Value::to()
2021-05-17 23:25:30 +02:00
Ali Mohammad Pur
95b9821f26 LibWasm: Implement memory.grow, memory.size and drop
These allow a very basic memory-using program to work.
2021-05-17 23:25:30 +02:00
Ali Mohammad Pur
3402381d7a LibWasm: Execute the start function, if one exists 2021-05-17 23:25:30 +02:00
Ali Mohammad Pur
d9ed3b504e Utilities/wasm: Say something when execution traps 2021-05-17 23:25:30 +02:00
Ali Mohammad Pur
84e3957dc3 LibWasm: Implement most of the remaining instructions
This commit is a bit of a mixed bag, but most of the changes are
repetitive enough to just include in a single commit.
The following instructions remain unimplemented:
- br.table
- table.init
- table.get
- table.set
- table.copy
- table.size
- table.grow
- table.fill
- ref.null
- ref.func
- ref.is_null
- drop
- i32/i64.clz
- i32/i64.ctz
- i32/i64.popcnt
- i32/i64.rotl
- i32/i64.rotr
- X.trunc.Y
- X.trunc_sat.Y
- memory.size
- memory.grow
- memory.init
- memory.copy
- memory.fill
- elem.drop
- data.drop
2021-05-17 23:25:30 +02:00
Ali Mohammad Pur
056be42c0b LibWasm: Start implementing a naive bytecode interpreter
As the parser now flattens out the instructions and inserts synthetic
nesting/structured instructions where needed, we can treat the whole
thing as a simple parsed bytecode stream.
This currently knows how to execute the following instructions:
- unreachable
- nop
- local.get
- local.set
- {i,f}{32,64}.const
- block
- loop
- if/else
- branch / branch_if
- i32_add
- i32_and/or/xor
- i32_ne

This also extends the 'wasm' utility to optionally execute the first
function in the module with optionally user-supplied arguments.
2021-05-17 23:25:30 +02:00
Ali Mohammad Pur
faa34a0a8b LibWasm: Do not resize() the function signature list to preallocate
Instead, use `ensure_capacity()`.
2021-05-17 23:25:30 +02:00
Ali Mohammad Pur
025b3349e4 LibWasm: Make structured_end() jump to the instruction after itself 2021-05-17 23:25:30 +02:00
Timothy Flynn
b7f00148ad LibWeb: Resolve 2-part and 3-part border-color values 2021-05-17 23:24:32 +02:00
Timothy Flynn
984a39f7c0 LibWeb: Resolve 3-part and 4-part border-width values 2021-05-17 23:24:32 +02:00
faxe1008
bfcc53a879 Playground: Show the modified state in the window title
Similar to how updating the title is implemented within TextEditor,
GML-Playground now also shows the modified state and requests for
saving before closing a modified document.
2021-05-17 21:04:54 +01:00
faxe1008
2b24fbdaaa LibGUI: Reset TextEditor modified state on sucessful write_to_file
Avoids missing reset of the state if saving is done in multiple places.
2021-05-17 21:04:54 +01:00
Andreas Kling
e0493c509e LibJS: Make the forward transition chain weakly cached
Before this patch, every shape would permanently remember every other
shape it had ever transitioned to. This could lead to pathological
accumulation of unused shape objects in some cases.

Fix this by using WeakPtr instead of a strongly visited Shape* in the
the forward transition chain map. This means that we will now miss out
on some shape sharing opportunities, but since this is not required
for correctness it doesn't matter.

Note that the backward transition chain is still strongly cached,
as it's necessary for the reification of property tables.

An interesting future optimization could be to allow property tables
to get garbage collected (by detaching them from the shape object)
and then reconstituted from the backwards transition chain (if needed.)
2021-05-17 21:40:18 +02:00
Gunnar Beutner
8c96640157 WebServer: Set no-cache header for responses
This sets the Pragma: no-cache header. Using Cache-Control would be
preferable but that's not part of the HTTP/1.0 standard.
2021-05-17 21:28:34 +02:00
Gunnar Beutner
7aca2d181a WebServer: Don't read until EOF
There's no guarantee that the client has closed the socket for
writing. Instead we should just read until the first empty line.

Fixes #7064.
2021-05-17 21:28:34 +02:00
Gunnar Beutner
f1dc8e12d2 LibHTTP: Make sure we're not sending an empty path in requests
When the path component of the request URL was empty we'd end up
sending requests like "GET  HTTP/1.1" (note the missing /). This
ensures that we always send a path.
2021-05-17 21:28:00 +02:00
Lenny Maiorani
6bc3ed6266 LibCrypto: Change static constexpr array to function local constexpr
Problem:
- Static variables take memory and can be subject to less optimization
  (https://serenityos.godbolt.org/z/7EYebr1aa)
- This static variable is only used in 1 place.

Solution:
- Move the variable into the function and make it non-static.
2021-05-17 19:37:56 +01:00
Andreas Kling
751ad19c86 LibJS: Don't consider cells in the lazy freelist in conservative scan
Cells after the lazy freelist bump index are guaranteed to not be
valid cell pointers, so ignore them during the conservative scan.
2021-05-17 19:57:40 +02:00
Andreas Kling
aa857bcdeb LibJS: Always prefer freelist over lazy freelist if possible
If we're able to allocate cells from a freelist, we should always
prefer that over the lazy freelist, since this may further defer
faulting in additional memory for the HeapBlock.

Thanks to @gunnarbeutner for pointing this out. :^)
2021-05-17 19:53:00 +02:00
Andreas Kling
6714cf3631 LibJS: Move Cell.{cpp,h} from Runtime/ to Heap/ 2021-05-17 19:53:00 +02:00
Gunnar Beutner
ee6600ea24 UE: Don't look up binaries in PATH when the user specified a full path
When the user specifies a path such as ./test we'd incorrectly look for
the binary in the PATH environment variable and end up executing an
incorrect binary (e.g. /bin/test). We should only look up binaries in
PATH if the user-specified path does not contain a slash.
2021-05-17 19:34:53 +02:00
Gunnar Beutner
26e711f953 UE: Use Vector<String> for the command-line arguments
Core::ArgsParser gained support for String a while ago. So let's use
that.
2021-05-17 19:34:53 +02:00
Andreas Kling
c2d9cd8d53 LibJS: Implement lazy freelist allocation for cells
HeapBlock now implements the same lazy freelist as LibC malloc() does,
where new blocks start out in a "bump allocator" mode that gets used
until we've bump-allocated all the way to the end of the block.

Then we fall back to the old freelist style as before.

This means we don't have to pre-initialize the freelist on HeapBlock
construction. This defers page faults and reduces memory usage for
blocks where all cells don't get used. :^)
2021-05-17 19:30:12 +02:00
Andreas Kling
a15c7b7944 Build: Stop using precompiled headers (PCH)
This had very bad interactions with ccache, often leading to rebuilds
with 100% cache misses, etc. Ali says it wasn't that big of a speedup
in the end anyway, so let's not bother with it.

We can always bring it back in the future if it seems like a good idea.
2021-05-17 19:30:12 +02:00
Jean-Baptiste Boric
0262a99a1f Chess: Fix signed/unsigned issues
Make everything signed so that we don't have to deal with silly casting
issues thoughout the Chess code. I am unsure if this affects the chess
AI negatively, it seems just as "intelligent" before and after this
change :^)
2021-05-17 18:14:05 +01:00
Jean-Baptiste Boric
d0eb376520 LibArchive: Move method implementations away from header 2021-05-17 18:14:05 +01:00
Jean-Baptiste Boric
3038edab00 Utilities: Correct non-standard assert macros includes 2021-05-17 18:14:05 +01:00
Linus Groh
b9d3df70e0 LibJS: Increase free stack space required for function calls to 32 kiB
The previous 16 kiB weren't sufficient with ASAN enabled and would
trigger stack overflow failures.
2021-05-17 18:03:10 +01:00
Linus Groh
0aab774343 Everywhere: Fix a bunch of typos 2021-05-17 17:48:55 +01:00
Daniel Bertalan
c1e292e5bc LibVT: Correct color handling
VT100's documentation says that more than one SGR (Set Graphics
Rendition) parameters may be included in a single escape sequence.
However, we treated those with more than 3 parameters as color
sequences, so this behavior was not replicated.
2021-05-17 18:19:49 +02:00
Daniel Bertalan
507ace5174 LibVT: Fix progress bars not getting reset 2021-05-17 18:19:49 +02:00