Commit Graph

337 Commits

Author SHA1 Message Date
Andreas Kling
69dddd4ef5 LibJS: Start fleshing out a bytecode for the JavaScript engine :^)
This patch begins the work of implementing JavaScript execution in a
bytecode VM instead of an AST tree-walk interpreter.

It's probably quite naive, but we have to start somewhere.

The basic idea is that you call Bytecode::Generator::generate() on an
AST node and it hands you back a Bytecode::Block filled with
instructions that can then be interpreted by a Bytecode::Interpreter.

This first version only implements two instructions: Load and Add. :^)

Each bytecode block has infinity registers, and the interpreter resizes
its register file to fit the block being executed.

Two new `js` options are added in this patch as well:

`-d` will dump the generated bytecode
`-b` will execute the generated bytecode

Note that unless `-d` and/or `-b` are specified, none of the bytecode
related stuff in LibJS runs at all. This is implemented in parallel
with the existing AST interpreter. :^)
2021-06-07 18:11:59 +02:00
Gunnar Beutner
64754ba985 Utilities: Add support for testing null deferencing a RefPtr
This adds the new flag -R for the crash utility which tests what
happens when we dereference a null RefPtr. This is useful for testing
the output of the assertion message.
2021-06-06 22:16:11 +02:00
FalseHonesty
73ff571d24 Userland: Fix matroska utility displaying invalid track data 2021-06-06 23:46:59 +04:30
FalseHonesty
db20f7b6d8 Userland: Add matroska program to test parsing Matroska container files 2021-06-06 17:47:00 +02:00
Max Wipfli
30cdebfa9e LibProtocol: Use URL class in RequestClient::start_request argument
This changes the RequestClient::start_request() method to take a URL
object instead of a URL string as argument. All callers of the method
already had a URL object anyway, and start_request() in turn parses the
URL string back into a URL object. This removes this unnecessary
conversion.
2021-06-06 16:00:11 +02:00
Maciej Zygmanowski
104dc93220 ifconfig: Use shorter argument names
The previous argument names were so long that they won't fit
into the terminal, making help message unreadable.
2021-06-05 23:51:08 +04:30
Sahan Fernando
d02e7b3811 LibWasm: Move Wasm::BytecodeInterpreter into its own header 2021-06-05 14:31:54 +04:30
Tim Schumacher
f295ac3c0b rm: Allow empty paths if -f is specified
On most (if not all) systems rm ignores an empty paths array if -f or
--force is specified. This helps with scripts that may pass an empty
variable where the file paths are supposed to go.
2021-06-05 10:56:58 +02:00
Maciej Zygmanowski
bee1e06055 hostname: Handle 'sethostname' errors 2021-06-04 19:11:27 +02:00
Ali Mohammad Pur
1b083392fa LibWasm+wasm: Switch to east-const to comply with project style
Against my better judgement, this change is mandated by the project code
style rules, even if it's not actually enforced.
2021-06-04 16:07:42 +04:30
Ali Mohammad Pur
23fd8bfd69 Userland/wasm: Replace manual noop export with an automatic one
Instead of manually specifying the types and names of imports to stub
out, `--export-noop` can be used to export stub functions for any
unresolved function import.
This makes running and debugging random wasm files much easier.
2021-06-04 16:07:42 +04:30
Ali Mohammad Pur
be62e4d1d7 LibWasm: Load and instantiate tables
This commit is a fairly large refactor, mainly because it unified the
two different ways that existed to represent references.
Now Reference values are also a kind of value.
It also implements a printer for values/references instead of copying
the implementation everywhere.
2021-06-04 16:07:42 +04:30
Andreas Kling
bf8fd4c193 Everywhere: Remove accidental '\n' from various outln() invocations
Also convert outln(stderr, ...) to warnln(...)
2021-06-03 22:50:21 +02:00
Gunnar Beutner
bc174b0fd0 Utilities: Make sure columns for ps are properly aligned
This updates ps so that it calculates the ideal column width instead
of relying on hard-coded values. Previously the STATE column was too
small to fit the state for "FinalizerTask".
2021-06-03 17:53:59 +02:00
Gunnar Beutner
48da8a568d
AK: Remove unused JsonValue <=> IPv4Address conversion code
This removes code that isn't used anywhere.
2021-06-03 11:56:32 +01:00
Filip Kania
33cdc59dff Utilities: Add support for relative paths in open command 2021-06-02 17:34:27 +04:30
Ali Mohammad Pur
b250a6ae7e wasm: Add a way to create dummy function exports
This should allow running modules with their imports stubbed out
in wasm, to debug them.
2021-06-02 16:09:16 +04:30
Ali Mohammad Pur
56bf80251c LibWasm: Implement reference instructions (ref.{null,func,is_null}) 2021-06-02 16:09:16 +04:30
Gunnar Beutner
2df6c70b07 Utilities: Report correct memory addresses for pmap
While I think negative memory might be an interesting concept to
investigate I don't think we're quite ready for it yet:

7ca71000        8192 r-xs-  libcrypt.so: .text
7ca73000        4096 r----  libcrypt.so: .relro
7ca74000        4096 rw---  libcrypt.so: .data
-6d391000       45056 r-xs-  libttf.so: .text
-6d385000        4096 r----  libttf.so: .relro
-6d384000        4096 rw---  libttf.so: .data
2021-06-02 10:16:45 +01:00
Linus Groh
1580eeed98 md: Improve document parsing error message 2021-06-01 21:30:16 +01:00
Linus Groh
2a940464b8 Userland: Return 1 when help text is shown for insufficient args
ArgsParser also does this, but we don't use that (yet) in a couple of
places. Fix the behaviour manually for consistency.
2021-06-01 21:30:16 +01:00
Linus Groh
f5c35fccca Userland: Replace most printf-style APIs with AK::Format APIs :^) 2021-06-01 21:30:16 +01:00
Max Wipfli
628c7f094f LibGUI+Shell+bt+ls: Use proper APIs for creating file URLs
This patch replaces ad-hoc generation of file URL strings with using
URL::create_with_file_scheme().
2021-06-01 09:28:05 +02:00
Andreas Kling
d105747735 basename: Tidy up a little more
This looks a little nicer with a single outln() invocation. :^)
2021-06-01 09:13:17 +02:00
Andreas Kling
9388cf327f basename: Support suffix stripping
Allow passing an optional suffix argument to `basename` which is then
stripped from the resulting basename (unless the resulting basename is
identical to the suffix.)

https://pubs.opengroup.org/onlinepubs/9699919799/utilities/basename.html
2021-06-01 09:05:15 +02:00
Linus Groh
1f62aaa193 lsof: Replace copy with reference in a for loop 2021-05-31 18:03:54 +01:00
Linus Groh
304752fccb cal: Remove unused variable declarations 2021-05-31 18:02:48 +01:00
Linus Groh
1eb048bed0 Userland: Remove a bunch of unused includes
As reported by CLion.
2021-05-31 18:01:53 +01:00
Linus Groh
16d51d78c0 Userland: Avoid a bunch of JsonObject copies
JsonValue::as_object() returns a reference.
2021-05-31 17:59:02 +01:00
Andreas Kling
597539aa4c pls: Fix typo in TERM environment variable propagation 2021-05-30 23:13:52 +02:00
Andreas Kling
33f2eeea4a pls: Drastically simplify this program
Since this program is setuid-root, it should be as simple as possible.

To that end, remove `/etc/plsusers` and use filesystem permissions to
achieve the same thing. `/bin/pls` is now only executable by `root` or
members of the `wheel` group.

Also remove all the logic that went to great lengths to `unveil()` a
minimal set of filesystem paths that may be used for the command.
The complexity-to-benefit ratio did not seem justified, and I think
we're better off keeping this simple.

Finally, remove pledge promises the moment they are no longer needed.
2021-05-30 23:09:37 +02:00
brapru
d24dd7a3df Utilities: Implement ArmedScopeGuard in userdel to unlink temp files 2021-05-30 17:42:03 +01:00
brapru
54578ec5d4 Utilities: Update userdel to use /etc/shadow
Updates userdel to delete entries from /etc/shadow.

Fixes #4884
2021-05-30 17:42:03 +01:00
brapru
ff4f3dd586 Utilities: Update useradd to use /etc/shadow
This updates useradd to write the spwd struct entry into
the /etc/shadow file via putspent.

Fixes #4884
2021-05-30 17:42:03 +01:00
brapru
1560775494 Utilities: Change default shell of useradd to /bin/sh 2021-05-30 17:42:03 +01:00
Linus Groh
5d80aab038 which: Replace printf() with outln()/warnln() 2021-05-30 14:07:58 +01:00
Linus Groh
7b79758fc6 userdel: Replace fprintf(stderr) with warnln() 2021-05-30 14:07:58 +01:00
Linus Groh
65528d86d5 ntpquery: Replace printf()/fprintf(stderr) with out{,ln}()/warnln() 2021-05-30 14:07:58 +01:00
Brendan Coles
340cecaf80 pls: Unveil search paths with browse permissions 2021-05-30 10:41:25 +01:00
Ben Wiederhake
a7c265f341 Everywhere: Sort out superfluous QuickSort.h imports
They were sorta unneeded. :^)
2021-05-29 23:41:54 +01:00
Jesse Buhagiar
d44e2c9ad9 Userland: Check sudoers file perms and owner in pls
As per comment found in #6319 by @bcoles, `pls` should check the
permissions and owner of the sudoers file to ensure that it hasn't
been compromised.
2021-05-29 22:33:12 +04:30
Jesse Buhagiar
82b48d867d Userland: Implement pls, a sudo clone 2021-05-29 22:33:12 +04:30
Tim Schumacher
d7797c8bf8 Userland: Treat inet_pton returning 0 as an error
The POSIX man-page states that inet_pton returns 0 if the input is not a
valid IPv4 dotted-decimal string or a valid IPv6 address string. This is
also how it is implemented in SerenityOS.

This means that we should treat a return value of 0 as an error to avoid
using an invalid address (or 0.0.0.0).
2021-05-27 22:56:21 +02:00
Marcus Nilsson
c906987651 Utilites: Make dd truncate output file
Make dd truncate the output file as Gnu-dd does by default.
Fixes #7497
2021-05-27 15:19:06 +02:00
Ali Mohammad Pur
477ab6dc4c LibWasm: Let the interpreter itself manage the call frame 2021-05-27 17:28:41 +04:30
Ali Mohammad Pur
c5df55a8a2 LibWasm: Make Interpreter a virtual interface
This allows multiply different kinds of interpreters to be used by the
runtime; currently a BytecodeInterpreter and a
DebuggerBytecodeInterpreter is provided.
2021-05-27 17:28:41 +04:30
Ali Mohammad Pur
bc936a5fac LibWasm: Make Frame a value type as well
This means stack operations will no longer do extra allocations.
2021-05-27 17:28:41 +04:30
Arjan Zuidema
c7bc1f59d8 file: Output directory when path is a directory
Before file would output 'text/html' when the path was a directory.
2021-05-27 13:18:23 +01:00
Ali Mohammad Pur
ba5da79617 LibWasm: Add execution hooks and a debugger mode to the wasm tool
This is useful for debugging *our* implementation of wasm :P
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