Commit Graph

7623 Commits

Author SHA1 Message Date
Andreas Kling
70a3e738f5 js: Make it a little easier to add new AST builder functions 2020-03-09 21:58:27 +01:00
Andreas Kling
0d6be2cac2 LibJS: Make FunctionDeclaration and CallExpression scope-aware 2020-03-09 21:53:39 +01:00
Andreas Kling
ad401ca098 js: Add another little test AST to exercise marking of locals 2020-03-09 21:49:20 +01:00
Andreas Kling
363c40e3f3 LibJS: Make sure we mark everything reachable from the scope stack
This ensures that local variables survive GC.
2020-03-09 21:49:20 +01:00
Andreas Kling
26165cd92a LibJS: Add a very simple ObjectExpression for "var x = {}"
This allows us to allocate an empty new Object on the GC heap.
2020-03-09 21:49:20 +01:00
Andreas Kling
15d8b9c671 LibJS: Add magical "$gc" function that can be called to trigger GC
This will be immensely useful for testing.
2020-03-09 21:49:20 +01:00
Andreas Kling
1382dbc5e1 LibJS: Add basic support for (scoped) variables
It's now possible to assign expressions to variables. The variables are
put into the current scope of the interpreter.

Variable lookup follows the scope chain, ending in the global object.
2020-03-09 21:49:20 +01:00
Till Mayer
ac3c19b91c Games: Added solitaire to build-root-filesystem.sh 2020-03-09 21:36:59 +01:00
Till Mayer
fe5cc7ce68 Games: Added solitaire
Added a solitaire game. Currently there are graphics missing on some
of the cards, but the game is fully functional.

Press F12 to show the game-over animation manually.
2020-03-09 21:36:59 +01:00
Andreas Kling
c6e54d2a49 LibJS: Simplify Heap::mark_live_cells()
Instead of iterating over every single cell, simply iterate over the
live cells and mark them from there.

Thanks to Blam for suggesting this! :^)
2020-03-09 19:36:15 +01:00
Shannon Booth
0de2ead0e9 Shell: Validate only one directory is given to cd 2020-03-09 19:35:36 +01:00
Shannon Booth
d0fb816ac3 Shell: Implement a "cd history" (cdh) builtin
`cdh` with no arguments dumps the last 8 cd calls in history, and
`cdh [index]` can be used to cd to re-run a specific index from that
history. `cdh` itself it a thin wrapper of the `cd` builtin.

There's definitely some improvements that can be made for this command,
but this seems like a good starting point for getting a feel for it and
ideas for changing it in the future.

It's not entirely clear whether we should be storing the resolved path -
or simply just the last argument passed to cd. For now we just use the
last path passed into cd as this seemed like the better option for now.

This means:
 * invalid paths will still be stored in history (potentially useful)
 * cdh's can be repeated for duplicate directory names
 * the history looks a little nicer on the eyes

It might make sense to use resolved paths.

Closes #397
2020-03-09 19:35:36 +01:00
0xtechnobabble
5e817ee678 LibJS: Move logical not operator to new unary expression class 2020-03-09 19:33:07 +01:00
0xtechnobabble
65343388b8 LibJS: Add new bitwise and relational operators
Do note that when it comes to evaluating binary expressions, we are
asserting in multiple contexts that the values we're operating on are
numbers, we should probably handle other value types to be more tolerant
in the future, since for example, adding a number and a string, in
which case the number is converted to a string implicitly which is then
concatenated, although ugly, is valid javascript.
2020-03-09 19:33:07 +01:00
howar6hill
11aac6fdce
LibJS: Remove superfluous explicit in AST.h (#1395) 2020-03-09 14:37:08 +01:00
Shannon Booth
28731179b1 Userland: Use ArgParser in stat and support multiple files + links
The '-L' option can be used for calling stat instead of lstat
2020-03-09 12:37:49 +01:00
Liav A
0f45a1b5e7 Kernel: Allow to reboot in ACPI via PCI or MMIO access
Also, we determine if ACPI reboot is supported by checking the FADT
flags' field.
2020-03-09 10:53:13 +01:00
Liav A
8639ee2640 PCI: Enable LogStream output for addresses 2020-03-09 10:53:13 +01:00
Liav A
032ce1948e LibBareMetal: Return FlatPtr from PhysicalAddress::offset_in_page() 2020-03-09 10:53:13 +01:00
howar6hill
1c83c5ed08 LibJS: Implement While statements 2020-03-09 10:13:27 +01:00
Mr.doob
4dee1ec0be
js: Fixed program comment (#1391) 2020-03-09 07:33:39 +01:00
Stephan Unverwerth
1207187e97 LibJS: GC: Remove clear_all_mark_bits()
Clearing all marked flags has been integrated into the sweep function,
saving an additional full iteration over the heap.
2020-03-09 07:32:09 +01:00
Andreas Kling
b956e2d939 AK: Remove all the AK .host.o files on "make clean" in AK/Tests
This is a bit hackish, but sometimes these files stick around and mess
up rebuilds.
2020-03-08 21:40:40 +01:00
Andreas Kling
d9126b1ad5 js: Exercise the garbage collector a little bit 2020-03-08 19:59:59 +01:00
Andreas Kling
63e4b744ed LibJS: Add a basic mark&sweep garbage collector :^)
Objects can now be allocated via the interpreter's heap. Objects that
are allocated in this way will need to be provably reachable from at
least one of the known object graph roots.

The roots are currently determined by Heap::collect_roots().

Anything that wants be collectable garbage should inherit from Cell,
the fundamental atom of the GC heap.

This is pretty neat! :^)
2020-03-08 19:23:58 +01:00
howar6hill
6da131d5db AK: Reduce code duplication in StringBuilder 2020-03-08 17:08:18 +01:00
howar6hill
d8df9c510c AK: Improve the API of StringBuilder 2020-03-08 17:08:18 +01:00
Liav A
0433c0780d AK: Use default constructor of Optional if an unset bit is not found 2020-03-08 14:13:30 +01:00
Liav A
4479e874da Kernel: Ensure RTL8139NetworkAdapter uses virtual memory correctly 2020-03-08 14:13:30 +01:00
Liav A
9dbc273675 Kernel: Ensure E1000NetworkAdapter uses virtual memory correctly 2020-03-08 14:13:30 +01:00
Liav A
d6e122fd3a Kernel: Allow contiguous allocations in physical memory
For that, we have a new type of VMObject, called
ContiguousVMObject, that is responsible for allocating contiguous
physical pages.
2020-03-08 14:13:30 +01:00
Ben Wiederhake
b066586355 Kernel: Fix race in waitid
This is similar to 28e1da344d
and 4dd4dd2f3c.

The crux is that wait verifies that the outvalue (siginfo* infop)
is writable *before* waiting, and writes to it *after* waiting.
In the meantime, a concurrent thread can make the output region
unwritable, e.g. by deallocating it.
2020-03-08 14:12:12 +01:00
Ben Wiederhake
d8cd4e4902 Kernel: Fix race in select
This is similar to 28e1da344d
and 4dd4dd2f3c.

The crux is that select verifies that the filedescriptor sets
are writable *before* blocking, and writes to them *after* blocking.
In the meantime, a concurrent thread can make the output buffer
unwritable, e.g. by deallocating it.
2020-03-08 14:12:12 +01:00
Ben Wiederhake
36ba0a35ee Travis: Cache toolchain
This should give a significant boost to Travis speeds, because most of the
compile time is spent building the toolchain over and over again.
However, the toolchain (or libc or libm) changes only rarely,
so most rebuilds can skip this step.

The hashing has been put into a separate file to keep it
as decoupled as possible from BuiltIt.sh.
2020-03-08 14:09:08 +01:00
Ben Wiederhake
0edae63cc0 Kernel: Fix inconsistent inclusion style
This also makes it easier to automatically parse the dependency tree.
Thankfully, this is the only place where a change was necessary.
2020-03-08 14:09:08 +01:00
howar6hill
e72fb8f594 LibC: Fix a bug involving miscalculating week counts of last year 2020-03-08 13:56:01 +01:00
howar6hill
df40847c52 LibC: Reimplement asctime() in terms of strftime() 2020-03-08 13:56:01 +01:00
Andreas Kling
32f15f3c45 AK: Remove unused InlineLRUCache template
This was not used by anyone. If we ever need it, we can bring it back.
2020-03-08 13:13:34 +01:00
Andreas Kling
900f51ccd0 AK: Move memory stuff (fast memcpy, etc) to a separate header
Move the "fast memcpy" stuff out of StdLibExtras.h and into Memory.h.
This will break a ton of things that were relying on StdLibExtras.h
to include a bunch of other headers. Fix will follow immediately after.

This makes it possible to include StdLibExtras.h from Types.h, which is
the main point of this exercise.
2020-03-08 13:06:51 +01:00
Andreas Kling
fa9fba6901 Kernel: Add missing #includes now that <AK/StdLibExtras.h> is smaller 2020-03-08 13:06:51 +01:00
Andreas Kling
37fc6c117c Userspace: Add missing #includes now that AK/StdLibExtras.h is smaller 2020-03-08 13:06:51 +01:00
Andreas Kling
35d88f536c AK: Use __builtin_memset() and such to reduce header dependencies
We can use __builtin_memset() without including <string.h>.
This is pretty neat, as it will allow us to reduce the header deps
of AK templates a bit, if applied consistently.

Note that this is an enabling change for an upcoming #include removal.
2020-03-08 13:06:51 +01:00
Andreas Kling
b1058b33fb AK: Add global FlatPtr typedef. It's u32 or u64, based on sizeof(void*)
Use this instead of uintptr_t throughout the codebase. This makes it
possible to pass a FlatPtr to something that has u32 and u64 overloads.
2020-03-08 13:06:51 +01:00
Andreas Kling
b98d8ad5b0 AK: Add a Conditional<condition, TrueType, FalseType> template
This allows you to select a type based on a compile-time condition.
2020-03-08 13:06:51 +01:00
howar6hill
10e0d4a196
LibCore: Add format option for DateTime::to_string() (#1358) 2020-03-08 11:35:26 +01:00
0xtechnobabble
b6307beb6e LibJS: Implement if statements
If statements execute a certain action or an alternative one depending
on whether the tested condition is true or false, this commit helps
establish basic control flow capabilities in the AST.
2020-03-08 11:15:07 +01:00
0xtechnobabble
a96bf2c22e LibJS: Implement logical expressions
Logical expressions are expressions which can return either true or
false according to a provided condition.
2020-03-08 11:15:07 +01:00
0xtechnobabble
4e62dcd6e6 LibJS: Add typed comparison operator
The `===` operator allows us to compare two values while taking their
type into consideration.
2020-03-08 11:15:07 +01:00
0xtechnobabble
3fb0ff102c LibJS: Allow the dumping of literals that aren't numbers 2020-03-08 11:15:07 +01:00
Tibor Nagy
0d17e3bfa6 LibGUI: Fix null-termination of TextDocumentLine 2020-03-08 10:31:48 +01:00