Commit graph

8845 commits

Author SHA1 Message Date
Andreas Kling
f3fc294ac8 LibGfx: Use Checked<T> when creating new bitmaps 2020-04-15 16:58:46 +02:00
Andreas Kling
3cdf4cd204 LibX86: Use MakeUnsigned<T> from AK instead of making a custom one 2020-04-15 16:58:46 +02:00
Andreas Kling
b517670fc9 LibAudio: Use NumericLimits<T> 2020-04-15 16:58:46 +02:00
AnotherTest
6b513ca97e LibLine: Avoid crashing if given empty suggestions 2020-04-15 16:38:25 +02:00
Liav A
223a863c6d LibBareMetal: Accept a u16 type pointer in the appropriate IO functions 2020-04-15 12:35:10 +02:00
Andreas Kling
3f698db85d LibWeb: Limit the maximum size of <canvas> bitmap buffers
We will no longer create bitmap buffers for canvases that exceed a
total area of (16384 * 16384) pixels. This matches what some other
browser do.

Thanks to @itamar8910 for finding this! :^)
2020-04-15 12:29:21 +02:00
Andreas Kling
228ace854c LibGfx: Don't allow creating bitmaps whose sizes would overflow
If the area or size_in_bytes calculation for a Gfx::Bitmap would
overflow, we now refuse to create such a bitmap and return nullptr.

Thanks to @itamar8910 for finding this! :^)
2020-04-15 12:28:49 +02:00
Linus Groh
a8406aa117 LibJS: Check length property of Array.prototype.join in its test
I assume this was copied from the Array.prototype.push() test :^)
2020-04-15 12:20:08 +02:00
Andreas Kling
ad2aac5fde LibJS: Add Array.prototype.join()
And share the code with Array.prototype.toString() :^)
2020-04-15 10:06:01 +02:00
Andreas Kling
fa30355194 LibJS: Adding two values should convert them to primitives first 2020-04-15 09:48:25 +02:00
Andreas Kling
63499c2c9f LibJS: Pass the Interpreter& to binary/logical/unary helpers 2020-04-15 09:28:41 +02:00
Kesse Jones
994f1a79ad
LibJS: Add String.prototype.{trim, trimStart, trimEnd} (#1792) 2020-04-15 08:47:40 +02:00
AnotherTest
32276cba7a LibLine: Properly handle multiline suggestions 2020-04-15 08:46:42 +02:00
Andreas Kling
067ea5a2e0 LibWeb: Add CanvasRenderingContext2D.drawImage(image, x, y)
This function allows you to draw a loaded <img> element into a canvas.
2020-04-14 20:38:44 +02:00
Andreas Kling
370befbf52 LibWeb: Add a JavaScript wrapper for HTMLImageElement :^) 2020-04-14 20:37:01 +02:00
Andreas Kling
22de1e47ec LibWeb: Add is<HTMLImageElement>() 2020-04-14 20:35:49 +02:00
Andreas Kling
1813e083ff LibWeb: Dispatch a "load" event on HTMLImageElement 2020-04-14 20:10:48 +02:00
Andreas Kling
57464be8f1 LibGUI: Scroll AbstractView to top on model change 2020-04-14 19:12:10 +02:00
Linus Groh
1dee4d0049 LibJS: Redirect stderr to /dev/null when running js in run-tests
This "mutes" output from dbg() calls - which is not an issue inside
serenity itself but if the script is run on the host machine and stdout
and stderr are displayed in the same terminal window.
2020-04-14 18:38:55 +02:00
Linus Groh
823fb9d9aa LibJS: Add missing load("test-common.js") to comments-basic.js
This fixes the test which is currently failing with
"ReferenceError: 'assert' not known".
2020-04-14 17:26:57 +02:00
Andreas Kling
236dcf7702 LibBareMetal: Add more assertions in copy_{to,from}_user()
Assert that the source/destination address is in kernel space when
appropriate. This is mostly to give ourselves an error if we're doing
something we were not expecting to be doing.
2020-04-14 15:30:25 +02:00
Linus Groh
f7df521073 LibJS: Add Array.prototype.map() 2020-04-14 13:40:04 +02:00
Linus Groh
f03d005bc4 LibJS: Add Array.prototype.filter() 2020-04-14 13:40:04 +02:00
Linus Groh
866172a721 LibJS: Add Array.prototype.forEach() 2020-04-14 13:40:04 +02:00
Linus Groh
29253bf932 LibJS: Add Array.prototype.unshift() 2020-04-14 13:40:04 +02:00
Linus Groh
5da1a40ccf LibJS: Support multiple arguments in Array.prototype.push() 2020-04-14 13:40:04 +02:00
Linus Groh
9fab52a390 LibJS: Remove shift, pop, push functions from Array object
This abstraction isn't really that useful, as we can access the
underlying Vector<Value> using elements() and operate on it directly.
2020-04-14 13:40:04 +02:00
Brian Gianforcaro
d74ad81402 js/LibJS: Move test functions to pure javascript.
The addition of assert functions to Userland/js
was done before we had load(..) implemented. Now
that it exists, it seems like the right move the
test helper functions to pure javascript instead
of poluting js with random global functions.
2020-04-14 12:55:31 +02:00
Stephan Unverwerth
9477efe970 LibJS: Handle HTML-style comments 2020-04-14 12:54:09 +02:00
Itamar
e207de8449 LibELF: Add find_demangled_function
Also, added AK::String::index_of and fixed a bug in ELF::Loader::symbol_ptr
2020-04-13 23:20:59 +02:00
Andreas Kling
8249280500 LibJS: Use HashMap::ensure_capacity() in enter_scope()
Preallocate some space in the scope variable map. This avoids a bunch
of incremental rehashing in the common case.
2020-04-13 17:27:25 +02:00
Stephan Unverwerth
8f82f6c574 LibJS: Add more number test cases for #1680 2020-04-13 17:23:22 +02:00
Andreas Kling
062d6af16e LibJS: Remove Interpreter::declare_variable()
Since declarations are now hoisted and handled on scope entry, the job
of a VariableDeclaration becomes to actually initialize variables.

As such, we can remove the part where we insert variables into the
nearest relevant scope. Less work == more speed! :^)
2020-04-13 17:22:24 +02:00
Andreas Kling
ac7459cb40 LibJS: Hoist variable declarations to the nearest relevant scope
"var" declarations are hoisted to the nearest function scope, while
"let" and "const" are hoisted to the nearest block scope.

This is done by the parser, which keeps two scope stacks, one stack
for the current var scope and one for the current let/const scope.

When the interpreter enters a scope, we walk all of the declarations
and insert them into the variable environment.

We don't support the temporal dead zone for let/const yet.
2020-04-13 17:22:23 +02:00
Linus Groh
b9415dc0e9 LibJS: Use assertNotReached() in tests 2020-04-13 16:28:50 +02:00
Linus Groh
92a9fe0e49 LibJS: Fix test files indentation (4 spaces) 2020-04-13 16:28:50 +02:00
Andreas Kling
94647fa4ab LibThread: Simplify the userspace Lock to remove CAS on unlock()
Instead of using a separate synchronization variable, just use the lock
holder TID for synchronization. This way, we only need to CAS when
first acquiring a lock.
2020-04-13 12:33:42 +02:00
Andreas Kling
d1ffdea550 LibC: Fix truncated strncpy() in getlogin() 2020-04-13 12:27:05 +02:00
Andreas Kling
dda9ffe906 LibC: Fix truncated strncpy() in /etc/group parsing 2020-04-13 12:27:05 +02:00
Andreas Kling
e3df925e48 LibC: Fix strncpy() overflow in /etc/passwd parsing 2020-04-13 12:27:05 +02:00
Andreas Kling
c1607dc41f LibC: Fix strncpy() overflow in gethostbyname() 2020-04-13 12:27:05 +02:00
Andreas Kling
038fdc2017 LibC: Simplify ASSERT() to reduce code size
Instead of pushing the message, file name, line# and function name
separately, we now mash the message, file name and line# into a string
constant and pass that.

This means that the failure path only has to push a single address onto
the stack, reducing the code size and causing the compiler to inline
many more functions containing an assertions (e.g RefPtr::operator*())

Obviously if you wanted minimal size, you could turn assertions off
entirely, but I really like running with assertions, so let's make
a little effort to reduce their impact. :^)
2020-04-13 12:27:05 +02:00
AnotherTest
8ebee4bce6 LibLine: Update display when deleting forward 2020-04-13 12:26:43 +02:00
Brian Gianforcaro
2a65db7c12
LibJS: Implement Error.prototype.name setter (#1776)
The MDN example for creating a custom error type in javascript uses:

    function CustomError(foo, message, fileName, lineNumber) {
        var instance = new Error(message, fileName, lineNumber);
        instance.name = 'CustomError';
        instance.foo = foo;
        Object.setPrototypeOf(instance, Object.getPrototypeOf(this));
        return instance;
    }

The name property on the Error prototype needs to be settable for
this to work properly.
2020-04-13 11:19:53 +02:00
Stephan Unverwerth
984c290ec0 LibJS: Do not execute scripts with parse errors
This adds missing checks in several LibJS consumers.
2020-04-13 10:42:25 +02:00
Andreas Kling
a0592912c3 LibC: Simplify the gettid() cache by just clearing the cache in fork()
It's hilarious how much better this is.

Thanks to Sergey for suggesting it! :^)
2020-04-13 10:27:14 +02:00
Stephan Unverwerth
bbd592cb6c LibJS: Tweak FunctionPrototype::to_string and constructors
The output of FunctionPrototype::to_string is now more in line
with the output in Firefox. The builtin constructors have been
extended to include their function name in the output.
2020-04-13 01:14:21 +02:00
Brian Gianforcaro
0d41e542b7 LibJS: Throw on assignment of an const variable
Was stubbed out as an assert, should be handled with a runtime exception.
2020-04-13 01:12:31 +02:00
Itamar
50fd2cabff ptrace: Report error in PT_PEEK via errno
The syscall wrapper for ptrace needs to return the peeked value when
using  PT_PEEK.
Because of this, the user has to check errno to detect an error in
PT_PEEK.

This commit changes the actual syscall's interface (only for PT_PEEK) to
allow the syscall wrapper to detect an error and change errno.
2020-04-13 00:53:22 +02:00
Itamar
9e51e295cf ptrace: Add PT_SETREGS
PT_SETTREGS sets the regsiters of the traced thread. It can only be
used when the tracee is stopped.

Also, refactor ptrace.
The implementation was getting long and cluttered the alraedy large
Process.cpp file.

This commit moves the bulk of the implementation to Kernel/Ptrace.cpp,
and factors out peek & poke to separate methods of the Process class.
2020-04-13 00:53:22 +02:00