Commit Graph

21061 Commits

Author SHA1 Message Date
Ali Mohammad Pur
f740667fa1 LibCore: Add a standard error stream getter 2021-05-26 15:34:13 +04:30
Ali Mohammad Pur
800bcb9965 LibWasm: Drop previous frame when a structured end instruction is run 2021-05-26 15:34:13 +04:30
Ali Mohammad Pur
7966168fea LibWasm: Turn memory read failures into traps 2021-05-26 15:34:13 +04:30
Ali Mohammad Pur
c31a4e9013 LibWasm: Once more fix structured instruction label indices
This finally works correctly. ™️
2021-05-26 15:34:13 +04:30
Ali Mohammad Pur
d05e5dbdcf LibWasm: Drop the correct number of frames
Prior to this commit, we would be dropping an extra frame.
2021-05-26 15:34:13 +04:30
Ali Mohammad Pur
a21ebae652 LibWasm: Implement checked truncation instructions
This implements the 8 i<n>.truncate.f<n>_<s> instructions.
2021-05-26 15:34:13 +04:30
Ali Mohammad Pur
59e01e2813 AK: Define MakeSigned<...>::Type as void in the base struct
This was probably forgotten in the last rewrite, this would make
IsIntegeral<T> not work for floating points.
2021-05-26 15:34:13 +04:30
Ali Mohammad Pur
cf8b75c2e5 LibWasm+LibWeb: Partially resolve memory exports
This allows the JS side to access the wasm memory, assuming it's
exported by the module.
This can be used to draw stuff on the wasm side and display them from
the js side, for example :^)
2021-05-26 15:34:13 +04:30
Ali Mohammad Pur
4a459d2430 LibWasm: Correct memory init size when instantiating
These limits are in units of page size, not bytes.
Also fixes incorrect debug logs.
2021-05-26 15:34:13 +04:30
Ali Mohammad Pur
4fd43a8f96 LibJS: Allow ArrayBuffer to not own its backing data buffer as well
This is implemented as a ByteBuffer* in a variant, so its size should
only be increased by an index.
2021-05-26 15:34:13 +04:30
Ali Mohammad Pur
3926eab3b7 LibWasm+LibWeb: Implement (a very basic version of) the JS link/import
This allows Wasm code to call javascript functions.
2021-05-26 15:34:13 +04:30
Ali Mohammad Pur
a2af04837e LibWeb: Implement a very basic WebAssembly JS API
This impl is *extremely* simple, and is missing a lot of things, it's
also not particularly spec-compliant in some places, but it's definitely
a start :^)
2021-05-26 15:34:13 +04:30
Linus Groh
bdd7741ae1 js: Consolidate and re-implement the load() function
This replaces the two sloppy copies of the load() function with a
cleaned up implementation:

- Only use the first argument, to load multiple files just call the
  function multiple times
- Fix a crash when using any non-string argument
- Throw an error if the file can't be opened instead of logging to
  stderr
- Don't use parse_and_run(), which would print the AST of the loaded
  file when using -A, for example - it's used either way as the entry
  point in both REPL and non-REPL mode, so we already get exception
  handling and all that
2021-05-26 01:04:09 +01:00
Linus Groh
64f4dc9a36 js: Use default constructor and destructor for global objects 2021-05-26 01:01:07 +01:00
Marcin Gasperowicz
f2d2640c5f js: Define load() in global object for scripts
Having load() present is required in order to run test262.
2021-05-26 00:27:18 +01:00
Gunnar Beutner
c6299d1e5d Kernel: Don't try to send TCP packets larger than the MSS
Previously TCPSocket::send_tcp_packet() would try to send TCP packets
which matched whatever size the userspace program specified. We'd try to
break those packets up into smaller fragments, however a much better
approach is to limit TCP packets to the maximum segment size and
avoid fragmentation altogether.
2021-05-25 22:20:37 +02:00
Gunnar Beutner
dce97678ae LibCore: Handle partial writes in Socket::send()
Right now Socket::send() assumes that it can send everything in one
go. However, send() is allowed to do partial writes and while that
can't happen at the moment there's nothing that says this can't
happen in the future (like in the next commit).
2021-05-25 22:20:37 +02:00
Timothy Flynn
a428812ba2 Solitaire: Persist high score separately per game mode
With different scoring rules for one-card vs. three-card draw mode, it
makes more sense to separately track their high scores.
2021-05-25 21:20:50 +02:00
Timothy Flynn
5d4cca7e0c Solitaire: Award bonus points based on time elapsed
The exact formula used for bonus points seems to vary by implementation.
This uses Klondike Solitaire's formula:

    https://en.wikipedia.org/wiki/Klondike_(solitaire)#Scoring
2021-05-25 21:20:50 +02:00
Timothy Flynn
0f80e9e4db Solitaire: Tweak scoring for three-card draw mode
Currently, the player loses 100 points each time the waste stack is
recycled. In three-card draw mode, it's standard to only lose 20 points
after the third recycle event.
2021-05-25 21:20:50 +02:00
Timothy Flynn
cf9094cf46 Solitaire: Remove dead call to Game::start_game_over_animation
This invocation will exit immediately. There's also no reason to invoke
stop_game_over_animation here because that's the first thing that will
happen in the call to setup.
2021-05-25 21:20:50 +02:00
Timothy Flynn
0b30a0febb Solitaire: Only update high score after a victorious game
Doesn't make much sense to update the high score on a lost game.
2021-05-25 21:20:50 +02:00
Gunnar Beutner
95401d2ca2 Hearts: Don't advance the game's state when an animation is playing
Previously we'd end up cancelling an animation that was still playing
when the user selects a card.
2021-05-25 21:05:35 +02:00
Gunnar Beutner
fc99aa92bd Hearts: Fix animations that get stuck "mid-flight"
When an animation is stopped the cards should be moved to their final
position anyway. Otherwise they might end up getting stuck in the
middle of the animation.
2021-05-25 21:05:35 +02:00
Gunnar Beutner
87ace131bc Hearts: Add support for playing more than one hand
This changes the game so that more than one hand can be played. Once
one player has 100 or more points the game ends. A score card is shown
between each hand.

Fixes #7374.
2021-05-25 21:05:35 +02:00
Gunnar Beutner
e636ed43eb Hearts: Let the AI continuously play games
When there are no human players (toggled with Shift-F10) the AI will
continuously start new games when the current game has finished.
2021-05-25 21:05:35 +02:00
Gunnar Beutner
ac1eba2f7c Hearts: Implement passing cards to other players
Fixes #7375.
2021-05-25 21:05:35 +02:00
Gunnar Beutner
fab073f33c Hearts: Move card click handler into a separate method 2021-05-25 21:05:35 +02:00
Gunnar Beutner
89d38b7e94 Hearts: Move sorting helper from Player::pick_lead_card into a method 2021-05-25 21:05:35 +02:00
Gunnar Beutner
4ba9cc82c0 Hearts: Move code to reposition cards into a separate method 2021-05-25 21:05:35 +02:00
Gunnar Beutner
9a6c6a98e5 Hearts: Move round initialization into a separate method 2021-05-25 21:05:35 +02:00
Gunnar Beutner
4e3a1f2da9 Hearts: Move hand sorting functionality into a method 2021-05-25 21:05:35 +02:00
Andreas Kling
6da481205b LibTest: Use fstatat() to speed up iterate_directory_recursively()
Employ the same technique as SpaceAnalyzer to avoid doing full path
resolution in the kernel over an over. Starting each path resolution
from the base of the directory iterator (using its fd) is significantly
faster and reduces test-js runtime by ~3%.
2021-05-25 20:53:59 +02:00
Andreas Kling
cfe3895991 LibJS: Fix broken dbgln_if(HEAP_DEBUG) 2021-05-25 19:44:32 +02:00
Andreas Kling
e6f8a5111f Profiler: Hide timeline scrollbars if we don't need them :^) 2021-05-25 19:04:17 +02:00
Andreas Kling
2de9139532 LibJS: Fix clang-tidy warnings about redundant types in Heap.cpp 2021-05-25 19:04:15 +02:00
Andreas Kling
679fc3066c LibJS: Fix clang-tidy warnings about unnecessary move()s in VM.cpp 2021-05-25 18:52:00 +02:00
Andreas Kling
47a4b2ba9f LibJS: Make Value::as_cell() return a Cell& 2021-05-25 18:48:11 +02:00
Andreas Kling
0de954e86b LibJS: Make Cell::Visitor::visit_impl() take a Cell&
Passing a null cell pointer is not supported.
2021-05-25 18:39:01 +02:00
Andreas Kling
789d20ebb7 LibJS: Replace Cell live bit with a cell state
So far we only have two states: Live and Dead. In the future, we can
add additional states to support incremental sweeping and/or multi-
stage cell destruction.
2021-05-25 18:37:37 +02:00
Andreas Kling
91656d63c7 LibJS: Inline Cell::Visitor::visit() functions
This allows the calls to MarkingVisitor::visit_impl() during GC to be
devirtualized in Heap::mark_live_cells().
2021-05-25 18:18:48 +02:00
Gunnar Beutner
c81b3e1ee3 LibC: Implement strerror_r()
This implements the XSI-compliant version of strerror_r() - as opposed
to the GNU-specific variant.

The function explicitly saves errno so as to not accidentally change it
with one of the calls to other functions.
2021-05-25 17:36:02 +02:00
Gunnar Beutner
3526fbbc5f LibC: Add definition for PRIxPTR 2021-05-25 17:36:02 +02:00
Brendan Coles
16094baffc HexEditor: Construct Find dialog from GML 2021-05-25 13:17:28 +01:00
Andreas Kling
7997c02b6c ls: Fix incorrect -t sort order
Dr. POSIX says -t should sort the output by mtime ascending.
2021-05-25 13:23:17 +02:00
Brian Gianforcaro
6830963321 Kernel: Validate we don't hold s_mm_lock during context switch
Since `s_mm_lock` is a RecursiveSpinlock, if a kernel thread gets
preempted while accidentally hold the lock during switch_context,
another thread running on the same processor could end up manipulating
the state of the memory manager even though they should not be able to.
It will just bump the recursion count and keep going.

This appears to be the root cause of weird bugs like: #7359
Where page protection magically appears to be wrong during execution.

To avoid these cases lets guard this specific unfortunate case and make
sure it can never go unnoticed ever again.

The assert was Tom's idea to help debug this, so I am going to tag him
as co-author of this commit.

Co-Authored-By: Tom <tomut@yahoo.com>
2021-05-25 10:35:41 +02:00
Tom
fe679de791 Kernel: Release the paging lock while reading from the disk
Because reading from the disk may preempt, we need to release the
paging lock.
2021-05-25 10:35:41 +02:00
Tom
1110c659ee Kernel: Add ScopedLockRelease to temporarily release a Lock 2021-05-25 10:35:41 +02:00
Gunnar Beutner
a808fff2ec Revert "Revert "Kernel: Fix PCI layout of i440fx QEMU machine""
This reverts commit 72c097530f.

With that patch applied audio doesn't work anymore.

Fixes #7445.
2021-05-25 09:38:25 +02:00
Tobias Christiansen
820224bb48 LibWeb: Match the :not pseudoclass
When a Selector features a :not() pseudoclass we now check whether the
current element matches with the given selector in the :not and act
accordingly.
2021-05-24 22:10:08 +01:00