Commit graph

25551 commits

Author SHA1 Message Date
Ali Mohammad Pur 4bef63fa6a Profiler: Show the symbol address in object file 2021-08-10 05:13:44 +04:30
Ali Mohammad Pur 64ccf2196c UserspaceEmulator+LibC: Add support for Region-of-Interest profiling 2021-08-10 05:13:44 +04:30
Daniel Bertalan 18b2484985 LibELF: Remove (FlatPtr)something.as_ptr() idiom
This is equivalent to `something.get()`, but more verbose.
2021-08-09 23:15:48 +02:00
Daniel Bertalan e0e3198d51 LibELF: Fix 'applying offset produced null pointer' UBSAN failure
These integer => pointer => integer conversions were technically prone
to UB, since they were used as offsets (which are perfectly fine to be
zero), but we calculated them with pointer arithmetic. This made Clang
insert pointer overflow UBSAN checks, which trigger in case of a zero
result.
2021-08-09 23:15:48 +02:00
Liav A d16d116b65 Kernel/USB: Tighten up USBManagement enumeration code a bit 2021-08-09 22:52:09 +02:00
Tetsui Ohkubo 1479ee3f3e LaunchServer: Do not provide file handlers for special files
With this change, LaunchServer will always return an empty list of file
handlers for special files e.g. sockets and devices. Before this change,
TextEditor was always returned as a default handler for these files.
2021-08-09 22:50:09 +02:00
Tobias Christiansen 2a77abf85e Everywhere: Use tobyase@serenityos.org for my copyright headers 2021-08-09 21:43:05 +02:00
Luke 7a86a8df90 Kernel/USB: Create controller base class and introduce USBManagement
This removes Pipes dependency on the UHCIController by introducing a
controller base class. This will be used to implement other controllers
such as OHCI.

Additionally, there can be multiple instances of a UHCI controller.
For example, multiple UHCI instances can be required for systems with
EHCI controllers. EHCI relies on using multiple of either UHCI or OHCI
controllers to drive USB 1.x devices.

This means UHCIController can no longer be a singleton. Multiple
instances of it can now be created and passed to the device and then to
the pipe.

To handle finding and creating these instances, USBManagement has been
introduced. It has the same pattern as the other management classes
such as NetworkManagement.
2021-08-09 21:05:25 +02:00
Jesse Buhagiar c5974d3518 USB: Fix wrong port read/write in portscan daemon
Port2 logic was errantly using `portsc1` registers, meaning that
the port wouldn't be reset properly. In effect, this puts devices
connected to Port2 in an undefined state.
2021-08-09 21:04:55 +02:00
Tom e3e52a4e61 Meta: Add SERENITY_CPUS environment variable to control number of CPUs 2021-08-09 21:02:23 +02:00
Kenneth Myhra 3e0d0847b6 Ports: Compile ncurses as a shared library
This sets the --with-shared switch for the configure script so that
ncurses is compiled as a shared library in addition the default which is
a static library.
Without the --with-shared switch ncurses will only be compiled as a
static library.

To properly set the environment variables LOCAL_LDFLAGS and
LOCAL_LDFLAGS2,  a case in the configure script had to be updated to
include '*serenity*'.
2021-08-09 20:08:36 +02:00
roytam1 6de6dff5b9 Ports: Add missing fnmatch patch for diffutils
It requires FNM_EXTMATCH in order to build.

This patch is based on an existing patch for gettext
(Ports/gettext/patches/fnmatch.patch).
2021-08-09 17:56:29 +01:00
davidot e1573991a3 LibJS: Fix this values in arrow functions
Also added a large this value test (and strict variant) to ensure this
values have no regressions.
2021-08-09 17:33:14 +01:00
davidot 151447bdf7 LibJS: Move Object::invoke to Value::invoke and fix it for primitives
This is a tiny difference and only changes anything for primitives in
strict mode. However this is tested in test262 and can be noticed by
overriding toString of primitive values.

This does now require one to wrap an object in a Value to call invoke
but all code using invoke has been migrated.
2021-08-09 17:33:14 +01:00
Andreas Kling 74e6a70958 Kernel/SMP: Don't process SMP messages in non-SMP mode
Processing SMP messages outside of non-SMP mode is a waste of time,
and now that we don't rely on the side effects of calling the message
processing function, let's stop calling it entirely. :^)
2021-08-09 13:39:08 +02:00
Andreas Kling a971de89d3 Kernel/SMP: Process the deferred call queue in exit_trap()
We were previously relying on a side effect of the critical section in
smp_process_pending_messages(): when exiting that section, it would
process any pending deferred calls.

Instead of relying on that, make the deferred invocations explicit by
calling deferred_call_execute_pending() in exit_trap().

This ensures that deferred calls get processed before entering the
scheduler at the end of exit_trap(). Since thread unblocking happens
via deferred calls, the threads don't have to wait until the next
scheduling opportunity when they could be ready *now*. :^)

This was the main reason Tom's SMP branch ran slowly in non-SMP mode.
2021-08-09 13:35:52 +02:00
Andreas Kling 57a7dfbd28 Kernel/SMP: Don't process SMP messages in exit_trap() in non-SMP mode 2021-08-09 13:23:42 +02:00
Andreas Kling f27e7bbbf4 Kernel/SMP: Don't enable interrupts in Processor::exit_trap
Enter a critical section in Processor::exit_trap so that processing
SMP messages doesn't enable interrupts upon leaving. We need to delay
this until the end where we call into the Scheduler if exiting the
trap results in being outside of a critical section and irq handler.

Co-authored-by: Tom <tomut@yahoo.com>
2021-08-09 13:22:22 +02:00
Andreas Kling cd0fc7f52c Kernel/SMP: Mark s_smp_enabled READONLY_AFTER_INIT
We can't enter/leave SMP mode once the kernel is up and running.
2021-08-09 13:19:26 +02:00
Andreas Kling f357fd91da Kernel: Don't hog MM lock in Memory::Region::clone()
We don't need to hold the MM lock across all of Region::clone().
2021-08-09 11:46:31 +02:00
Andreas Kling 08b4d8f0de Kernel: Fix deadlock in ~Memory::Region()
First off: unregister the region from MemoryManager before unmapping it.
The order of operations here was a bit strange, presumably to avoid a
situation where a fault would happen while unmapping, and the fault
handler would find the MemoryManager region list in an invalid state.

Unregistering it before unmapping sidesteps the whole problem, and
allows us to easily fix another problem: a deadlock could occur due
to inconsistent acquisition order (PageDirectory must come before MM.)
2021-08-09 11:46:31 +02:00
Andreas Kling 95c8e421ae Kernel: Don't hog MM lock in find_region_from_vaddr()
We don't want to be holding the MM lock if it's a user region and we
have to consult the page directory, since that can lead to a deadlock
if we don't already have the page directory lock.
2021-08-09 11:46:31 +02:00
Andreas Kling 96c7b70de3 Kernel: Remove unused list of user regions in MemoryManager
We were putting all the user Region objects on an intrusive list
but not using it for anything.
2021-08-09 11:46:31 +02:00
Andreas Kling ab5c422a29 Kernel/SMP: Make SMP message queueing work correctly
- Use the receiver's per-CPU entry in the message, instead of the
  sender's. (Using the sender's entry wasn't safe for broadcast
  messages since the same entry ended up on multiple message queues.)

- Retry the CAS until it *succeeds* instead of *fails*. This closes a
  race window, and also ensures a correct return value. The return value
  is used by the caller to decide whether to broadcast an IPI.
  This was the main reason smp=on was so slow. We had CPUs busy-waiting
  until someone else triggered an IPI and moved things along.

- Add a CPU pause hint to the spin loop. :^)
2021-08-09 11:46:31 +02:00
Andreas Kling 6283acb6b7 Kernel/SMP: Don't panic in inode fault if other CPU already paged it in
It may happen that CPU A manages to page in from the same inode
while we're just entering the same page fault handler on CPU B.

Handle it gracefully by checking if the data has already been paged in
(instead of VERIFY'ing that it hasn't) and then remap the page if that's
the case.
2021-08-09 11:46:31 +02:00
Andreas Kling 00bbbdeda6 Kernel/SMP: Always take PageDirectory lock before the MemoryManager lock
This prevents deadlocking due to inconsistent acquisition order.
2021-08-09 11:46:31 +02:00
Andreas Kling d21b8f9013 Kernel/SMP: Fix ProcessorMessage deallocation bug
Due to a boolean mistake in smp_return_to_pool(), we didn't retry
pushing the message onto the freelist after a failed attempt.

This caused the message pool to eventually become completely empty
after enough contentious access attempts.

This patch also adds a pause hint to the CPU in the failed attempt
code path.
2021-08-09 11:46:30 +02:00
Andreas Kling f3fed411d4 Kernel: Rename Processor::smp_queue_message() => smp_enqueue_message() 2021-08-09 11:46:30 +02:00
Andreas Kling 46215a8183 Kernel: Add Processor::pause() and use it to give the CPU a rest
On x86, the "pause" instruction is a "spin loop hint".
2021-08-09 11:46:30 +02:00
Andreas Kling b7129c57df Kernel: Only get register dump when we have a trap
Co-authored-by: Tom <tomut@yahoo.com>
2021-08-09 11:46:30 +02:00
Andreas Kling cebdb0b575 Kernel: Fix logic typo in ConsoleManagement::is_initialized()
Regressed in 2ff3c54153.
2021-08-09 11:46:30 +02:00
Mandar Kulkarni aaf232f903 Tests: Add test for String::bijective_base_from() 2021-08-09 14:14:07 +04:30
Mandar Kulkarni b0ff91ff09 Spreadsheet: Make convert_from_string() return Optional<size_t>
Earlier, we were using 0 value for characters not found in "map".

We should return failure for invalid inputs.
So, I have changed the return type of function to Optional<size_t>.

Also changed caller to handle Optional return.
2021-08-09 14:14:07 +04:30
Mandar Kulkarni 2c44f2dc3c Spreadsheet: Fix column index string to number conversion
Fixed convert_from_string() function to return correct output.
The value of a number is equal to sum of each digit multiplied by it's
positional weight.
2021-08-09 14:14:07 +04:30
Idan Horowitz 151c940827 CI: Remove leftover ccache step and fix a broken link in the clang build 2021-08-09 09:03:31 +02:00
Marcus Nilsson b1b6a6d6e8 PixelPaint: Let Tools have different cursors
This adds support for the Tools in PixelPaint to use different cursors
within ImageEditor. For now most of them get the crosshair cursor since
it's the most fitting, but in the future we will want to add custom
cursors.
2021-08-09 00:57:44 +02:00
Daniel Bertalan 657fbc1e6c Toolchain: Remove static LLVM libraries
We link against these dynamically anyways, so having them around is not
useful. Removing them frees precious storage space on CI.
2021-08-08 23:54:00 +02:00
Daniel Bertalan d3595477d8 Toolchain: Build libLLVM as a dynamic library
This library is used by virtually all executables in the Clang
toolchain. By default, it is linked statically, which leads to huge
file sizes and us running out of artifact storage disk space on CI.
2021-08-08 23:54:00 +02:00
Brian Gianforcaro 8e93815846 Kernel: Fix panic loop when encountering an unknown boot_mode
The kernel panic handler now parses the kernels boot_mode to decide how
to handle the panic. So the previous logic could end up in an panic loop
until we blew out the kernel stack.

Instead only validate the kernel's boot mode once per boot, after
initializing the kernel command line.
2021-08-08 23:11:50 +02:00
Linus Groh 312946059b LibJS+Spreadsheet: Use js_string(VM&, ...) overload more 2021-08-08 21:32:58 +01:00
Idan Horowitz bac3c2cf6d CI: Split off clang toolchain builds from normal CI and schedule them
Clang builds will no longer be apart of the automated CI for every Push/
Pull Request, and will instead be ran at 00:00 UTC every day, with the
results posted to the discord #clang-toolchain channel.
2021-08-08 22:31:35 +02:00
Linus Groh 97010d4903 LibJS: Implement Intl[@@toStringTag] 2021-08-08 20:14:59 +01:00
Linus Groh 44a8b55c50 LibJS: Add preparation for Intl constructors and prototypes
Add a JS_ENUMERATE_INTL_OBJECTS macro and use it to generate:

- Forward declarations
- CommonPropertyNames class name members
- Constructor and prototype GlobalObject members, getters, visitors,
  and initialize_constructor() calls
2021-08-08 20:14:59 +01:00
Linus Groh a37dcf8ca7 LibJS: Add the Intl namespace object :^)
This is the start of implementing ECMA-402 in LibJS, better known as the
ECMAScript Internationalization API.

Much like Temporal this gets its own subdirectory (Runtime/Intl/) as
well as a new C++ namespace (JS::Intl) so we don't have to prefix all
the files and classes with "Intl".

https://tc39.es/ecma402/
2021-08-08 20:14:59 +01:00
Linus Groh 7d8c182359 LibJS: Implement Temporal.PlainYearMonth.prototype.getISOFields() 2021-08-08 17:45:06 +01:00
Linus Groh 5a260fcad1 LibJS: Implement Temporal.PlainYearMonth.prototype.valueOf() 2021-08-08 17:45:06 +01:00
Linus Groh d9ed0f1f47 LibJS: Implement Temporal.PlainYearMonth.prototype.inLeapYear 2021-08-08 17:45:06 +01:00
Linus Groh 3592a748b6 LibJS: Implement Temporal.PlainYearMonth.prototype.monthsInYear 2021-08-08 17:45:06 +01:00
Linus Groh 703eb1f7b4 LibJS: Implement Temporal.PlainYearMonth.prototype.daysInMonth 2021-08-08 17:45:06 +01:00
Linus Groh 1f1d7144bf LibJS: Implement Temporal.PlainYearMonth.prototype.daysInYear 2021-08-08 17:45:06 +01:00