Commit Graph

7663 Commits

Author SHA1 Message Date
Andreas Kling
1a10470c1d LibJS: Implement basic object property assignment
This is pretty naive, we just walk up the prototype chain and call any
NativeProperty setter that we find. If we don't find one, we put/set
the value as an own property of the object itself.
2020-03-19 17:44:06 +01:00
Liav A
7268499c76 LibCore: Use monotonic time when handling timers 2020-03-19 15:48:00 +01:00
Liav A
b536547c52 Process: Use monotonic time for timeouts 2020-03-19 15:48:00 +01:00
Liav A
b4c92c24ee Scheduler: Use monotonic time for blocking threads 2020-03-19 15:48:00 +01:00
Liav A
b2585b3577 Userland: Add functionality of changing system date in date utility 2020-03-19 15:48:00 +01:00
Liav A
64c73d0739 LibC: Add new syscall to allow changing the system date 2020-03-19 15:48:00 +01:00
Liav A
4484513b45 Kernel: Add new syscall to allow changing the system date 2020-03-19 15:48:00 +01:00
Liav A
4fcc10c6c3 Kernel: Delete unnecessary files 2020-03-19 15:48:00 +01:00
Liav A
9db291d885 Kernel: Introduce the new Time management subsystem
This new subsystem includes better abstractions of how time will be
handled in the OS. We take advantage of the existing RTC timer to aid
in keeping time synchronized. This is standing in contrast to how we
handled time-keeping in the kernel, where the PIT was responsible for
that function in addition to update the scheduler about ticks.
With that new advantage, we can easily change the ticking dynamically
and still keep the time synchronized.

In the process context, we no longer use a fixed declaration of
TICKS_PER_SECOND, but we call the TimeManagement singleton class to
provide us the right value. This allows us to use dynamic ticking in
the future, a feature known as tickless kernel.

The scheduler no longer does by himself the calculation of real time
(Unix time), and just calls the TimeManagment singleton class to provide
the value.

Also, we can use 2 new boot arguments:
- the "time" boot argument accpets either the value "modern", or
  "legacy". If "modern" is specified, the time management subsystem will
  try to setup HPET. Otherwise, for "legacy" value, the time subsystem
  will revert to use the PIT & RTC, leaving HPET disabled.
  If this boot argument is not specified, the default pattern is to try
  to setup HPET.
- the "hpet" boot argumet accepts either the value "periodic" or
  "nonperiodic". If "periodic" is specified, the HPET will scan for
  periodic timers, and will assert if none are found. If only one is
  found, that timer will be assigned for the time-keeping task. If more
  than one is found, both time-keeping task & scheduler-ticking task
  will be assigned to periodic timers.
  If this boot argument is not specified, the default pattern is to try
  to scan for HPET periodic timers. This boot argument has no effect if
  HPET is disabled.

In hardware context, PIT & RealTimeClock classes are merely inheriting
from the HardwareTimer class, and they allow to use the old i8254 (PIT)
and RTC devices, managing them via IO ports. By default, the RTC will be
programmed to a frequency of 1024Hz. The PIT will be programmed to a
frequency close to 1000Hz.

About HPET, depending if we need to scan for periodic timers or not,
we try to set a frequency close to 1000Hz for the time-keeping timer
and scheduler-ticking timer. Also, if possible, we try to enable the
Legacy replacement feature of the HPET. This feature if exists,
instructs the chipset to disconnect both i8254 (PIT) and RTC.
This behavior is observable on QEMU, and was verified against the source
code:
ce967e2f33

The HPETComparator class is inheriting from HardwareTimer class, and is
responsible for an individual HPET comparator, which is essentially a
timer. Therefore, it needs to call the singleton HPET class to perform
HPET-related operations.

The new abstraction of Hardware timers brings an opportunity of more new
features in the foreseeable future. For example, we can change the
callback function of each hardware timer, thus it makes it possible to
swap missions between hardware timers, or to allow to use a hardware
timer for other temporary missions (e.g. calibrating the LAPIC timer,
measuring the CPU frequency, etc).
2020-03-19 15:48:00 +01:00
Liav A
5d90e9cfb8 Kernel & LibC: Add CLOCK_REALTIME constant 2020-03-19 15:48:00 +01:00
Liav A
53d6fe8141 ACPI: Delete irrelevant HPET definitions
Also, the definition of the HPET ACPI table is correct now, in
accordance to the HPET specification, revision 1.0a, October 2004.
2020-03-19 15:48:00 +01:00
Liav A
a0a7204915 Interrupts: Add an interface to determine if SMP is enabled 2020-03-19 15:48:00 +01:00
Liav A
e880fe0765 Kernel: Use a const reference to RegisterState in IRQ handling 2020-03-19 15:48:00 +01:00
Liav A
aa43314e8b Kernel: Remove unnecessary include from PATAChannel.cpp 2020-03-19 15:48:00 +01:00
Liav A
9a303cc5a5 Kernel: Add the NonMaskableInterruptDisabler class
This class will be used later to disable NMIs when we
initialize the RTC timer.
2020-03-19 15:48:00 +01:00
Andreas Kling
07679e347c LibJS: Parse FunctionExpressions
FunctionExpression is mostly like FunctionDeclaration, except the name
is optional. Share the parsing logic in parse_function_node<NodeType>.

This allows us to do nice things like:

    document.addEventListener("DOMContentLoaded", function() {
        alert("Hello friends!");
    });
2020-03-19 11:54:11 +01:00
Andreas Kling
b1b4c9844e LibJS: Add FunctionExpression AST node
Most of the code is shared with FunctionDeclaration, so the shared bits
are moved up into a common base called FunctionNode.
2020-03-19 11:12:08 +01:00
Andreas Kling
f0b49ae04b LibJS: Fix reference leak in ASTNode::append()
Using make<T> like this would create an unadopted object whose refcount
would never reach zero.
2020-03-19 11:02:20 +01:00
Alex Muscar
d013753f83
Kernel: Resolve relative paths when there is a veil (#1474) 2020-03-19 09:57:34 +01:00
rhin123
6d26714ded Calendar: Allow the widget to resize with the window 2020-03-19 09:55:14 +01:00
rhin123
5744049b74 Calendar: Make const arrays static as well 2020-03-19 09:55:14 +01:00
rhin123
dc680d57aa Calendar: Don't assign next_month button variable to add_event button 2020-03-19 09:55:14 +01:00
Andreas Kling
961b4f2577 LibJS: Add missing copyright headers 2020-03-18 20:21:06 +01:00
Andreas Kling
0a9bd817bf LibWeb: Add missing copyright headers 2020-03-18 20:20:35 +01:00
Andreas Kling
41f3817b36 LibWeb: Use a JS::Handle to keep the EventListener function alive 2020-03-18 20:05:52 +01:00
Andreas Kling
a119b61782 LibJS: Add Handle<T>, a strong C++ handle for keeping GC objects alive
This is pretty heavy and unoptimized, but it will do the trick for now.
Basically, Heap now has a HashTable<HandleImpl*> and you can call
JS::make_handle(T*) to construct a Handle<T> that guarantees that the
pointee will always survive GC until the Handle<T> is destroyed.
2020-03-18 20:03:17 +01:00
Andreas Kling
e265058768 LibWeb: Fire "mousedown" and "mousemove" events in the DOM :^) 2020-03-18 17:13:22 +01:00
Andreas Kling
f39e5352f0 LibWeb: Start working on DOM event support
This patch adds the EventTarget class and makes Node inherit from it.

You can register event listeners on an EventTarget, and when you call
dispatch_event() on it, the event listeners will get invoked.

An event listener is basically a wrapper around a JS::Function*.

This is pretty far from how DOM events should eventually work, but it's
a place to start and we'll build more on top of this. :^)
2020-03-18 17:13:22 +01:00
Andreas Kling
97674da502 LibJS: Tolerate NativeFunction::call() with non-object 'this' for now
I'm not exactly sure why we end up in this situation, we'll have to
look into it.
2020-03-18 17:13:22 +01:00
Andreas Kling
f64f7a4787 LibJS: Add Function to Forward.h 2020-03-18 17:13:22 +01:00
Andreas Kling
e96ef450f6 LibJS: Add Interpreter::call(Function*, this_value, arguments)
This helper function takes care of pushing/popping a call frame so you
don't need to worry about it.
2020-03-18 17:13:22 +01:00
Andreas Kling
47fdac7cea Browser: Fix unintentional Web::Element copy 2020-03-18 17:13:22 +01:00
Oriko
a115702746 HackStudio: Expand project tree view by default 2020-03-18 16:33:54 +01:00
Andreas Kling
01408a511f LibWeb: Don't try to repaint frameless documents in CSSStyleValue 2020-03-18 11:26:31 +01:00
Andreas Kling
ddd69e3660 LibJS: Make the AST reference-counted
This allows function objects to outlive the original parsed program
without their ScopeNode disappearing.
2020-03-18 11:23:53 +01:00
Itamar
d98fbd192e Terminal: Remove working directory argument
Applications that want to spawn Terminal in a specific
directory should chdir to it before execing it.
2020-03-18 08:23:31 +01:00
Itamar
c18f12bb96 Taskbar: chdir to home directory before launching apps 2020-03-18 08:23:31 +01:00
Itamar
e2b7e7c390 SystemMenu: chdir to home directory before launching apps 2020-03-18 08:23:31 +01:00
Itamar
a4497ce375 FileManager: chdir to appropriate directory before starting Terminal 2020-03-18 08:23:31 +01:00
Itamar
bd9f14e27e SystemServer: Add WorkingDirectory support
Services can now have their initial working directory
configured via `SystemServer.ini`.

This commit also configures Terminal's working directory
to be /home/anon
2020-03-18 08:23:31 +01:00
rhin123
39c21f368a Calendar: Implement basic GUI calendar application 2020-03-18 08:17:01 +01:00
rhin123
08a30a4961 LibCore: Moved cal.cpp functions to DateTime 2020-03-18 08:17:01 +01:00
Conrad Pankoff
46a897b59b LibJS: Implement typeof operator 2020-03-17 21:28:02 +01:00
Andreas Kling
0a71533aff LibJS: Pass argument value vectors as const Vector<Value>&
Now that Interpreter keeps all arguments in the CallFrame stack, we can
just pass a const-reference to the CallFrame's argument vector to each
function handler (instead of copying it.)
2020-03-17 16:24:53 +01:00
Andreas Kling
bf9912cc59 LibJS: Protect function call "this" and arguments from GC
This patch adds a CallFrame stack to Interpreter, which keeps track of
the "this" value and all argument values passed in function calls.

Interpreter::gather_roots() scans the call stack, making sure that all
argument values get marked. :^)
2020-03-17 11:06:00 +01:00
marprok
666f84b933 Base: Add Joi theme 2020-03-17 09:41:15 +01:00
Andreas Kling
cb2e7d1c5f LibJS+js: Add a debug option (js -g) to GC after every allocation
This is very useful for discovering collector bugs.
2020-03-16 19:18:46 +01:00
Andreas Kling
ab404a2f88 LibJS: Implement basic conservative garbage collection
We now scan the stack and CPU registers for potential pointers into the
GC heap, and include any valid Cell pointers in the set of roots.

This works pretty well but we'll also need to solve marking of things
passed to native functions, since those are currently in Vector<Value>
and the Vector storage is on the heap (not scanned.)
2020-03-16 19:14:09 +01:00
Andreas Kling
ad92a1e4bc Kernel: Add sys$get_stack_bounds() for finding the stack base & size
This will be useful when implementing conservative garbage collection.
2020-03-16 19:06:33 +01:00
Andreas Kling
086f68e878 LibJS: Replace the global print() function with console.log() :^) 2020-03-16 14:58:20 +01:00