summaryrefslogtreecommitdiff
path: root/Libraries/LibJS
AgeCommit message (Collapse)Author
2020-03-22LibJS: Use FlyString for identifiersAndreas Kling
This makes variable and property lookups a lot faster since comparing two FlyStrings is O(1).
2020-03-21LibJS: Parse "if" statementsAndreas Kling
This patch implements basic parsing of "if" statements. We don't yet support parsing "else", so I added a FIXME about that.
2020-03-21LibJS: Add Math.random() :^)Andreas Kling
2020-03-21LibJS+LibWeb: Fix some inconsistencies in NativeFunction callbacksAndreas Kling
These should always pass the arguments in a const Vector<JS::Value>&.
2020-03-21LibJS: Virtualize access to an Object's own propertiesAndreas Kling
Object now has virtual get_own_property() and put_own_property() member functions that can be overridden to provide custom behavior. We use these virtuals to move Array-specific access behavior to Array.
2020-03-21LibJS: Include the cell size in HeapBlock mmap namesAndreas Kling
HeapBlocks now show up in SystemMonitor as "LibJS: HeapBlock(32)" :^)
2020-03-21LibJS: Some optimizations for ObjectExpressionAndreas Kling
- move() the property map when constructing ObjectExpression instead of making a copy. - Use key+value iterators to traverse the property map in the execute() and dump() functions.
2020-03-21LibJS: Round cell sizes up to a multiple of 16 bytesAndreas Kling
This increases HeapBlock utilization significantly (and reduces overall memory usage.)
2020-03-21LibJS: Delete fully-empty HeapBlocks after garbage collectionAndreas Kling
We now deallocate GC blocks when they are found to have no live cells inside them.
2020-03-21LibJS: Parse object expressions0xtechnobabble
2020-03-20LibJS: Add ArrayPrototype and implement Array.prototype.push()Andreas Kling
This function is ultimately supposed to be generic and allow any |this| that has a length property, but for now it only works on our own Array object type.
2020-03-20LibJS: Support reading/writing elements in an Array via Object get/putAndreas Kling
I'm not completely thrilled about Object::get() and Object::put() doing special-case stuff for arrays, and we should probably come up with a better abstraction for it. But at least it works for now, which is really nice. :^)
2020-03-20LibJS: Parse computed MemberExpressionsAndreas Kling
MemberExpression comes in two flavors: computed: a[b] non-computed: a.b We can now parse both of the types. :^)
2020-03-20LibJS: Allow default-constructing a JS::Value (undefined)Andreas Kling
2020-03-20LibJS: Parse ArrayExpression and start implementing Array objectsAndreas Kling
Note that property lookup is not functional yet.
2020-03-20LibJS: Use StringBuilder::join()Andreas Kling
2020-03-20LibJS: Print a newline in each console.log()Andreas Kling
2020-03-19LibJS: Prefer FunctionDeclaration if a statement begins with "function"Andreas Kling
2020-03-19LibJS: Implement basic object property assignmentAndreas Kling
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-19LibJS: Parse FunctionExpressionsAndreas Kling
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-19LibJS: Add FunctionExpression AST nodeAndreas Kling
Most of the code is shared with FunctionDeclaration, so the shared bits are moved up into a common base called FunctionNode.
2020-03-19LibJS: Fix reference leak in ASTNode::append()Andreas Kling
Using make<T> like this would create an unadopted object whose refcount would never reach zero.
2020-03-18LibJS: Add missing copyright headersAndreas Kling
2020-03-18LibJS: Add Handle<T>, a strong C++ handle for keeping GC objects aliveAndreas Kling
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-18LibJS: Tolerate NativeFunction::call() with non-object 'this' for nowAndreas Kling
I'm not exactly sure why we end up in this situation, we'll have to look into it.
2020-03-18LibJS: Add Function to Forward.hAndreas Kling
2020-03-18LibJS: Add Interpreter::call(Function*, this_value, arguments)Andreas Kling
This helper function takes care of pushing/popping a call frame so you don't need to worry about it.
2020-03-18LibJS: Make the AST reference-countedAndreas Kling
This allows function objects to outlive the original parsed program without their ScopeNode disappearing.
2020-03-17LibJS: Implement typeof operatorConrad Pankoff
2020-03-17LibJS: Pass argument value vectors as const Vector<Value>&Andreas Kling
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-17LibJS: Protect function call "this" and arguments from GCAndreas Kling
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-16LibJS+js: Add a debug option (js -g) to GC after every allocationAndreas Kling
This is very useful for discovering collector bugs.
2020-03-16LibJS: Implement basic conservative garbage collectionAndreas Kling
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-16LibJS: Replace the global print() function with console.log() :^)Andreas Kling
2020-03-16LibJS: Add "Heap" and "Runtime" subdirectoriesAndreas Kling
Let's try to keep LibJS tidy as it expands. :^)
2020-03-16LibJS: Implement abstract equality and inequality0xtechnobabble
2020-03-16LibJS: Loosen type system0xtechnobabble
This commits makes effort towards tolerating some of javascript's quirks when it comes to its type system, note that the interpreter's way of handling type coercion is still not mature at all, for example, we still have to implement NaN instead of just crashing when trying to parse a string and failing.
2020-03-16LibJS/Parser: Parse logical expressions0xtechnobabble
2020-03-16LibJS: Specify overridden functions with 'override'0xtechnobabble
2020-03-16LibJS: Implement null and undefined literals0xtechnobabble
2020-03-16LibJS: Fix assignment of const variable on declaration0xtechnobabble
We were previously assuming that we were reassigning a variable even when we were not, oops, my bad. :/
2020-03-15LibJS: Add String.prototype.repeat() :^)Andreas Kling
2020-03-15LibJS: Pass "this" as an Object* to NativeFunction callbacksAndreas Kling
Instead of every NativeFunction callback having to ask the Interpreter for the current "this" value and then converting it to an Object etc, just pass "this" as an Object* directly.
2020-03-15LibJS: Add a mechanism for callback-based object propertiesAndreas Kling
This patch adds NativeProperty, which can be used to implement object properties that have C++ getters and/or setters. Use this to move String.prototype.length to its correct place. :^)
2020-03-15LibJS: Remove debug spam in Object::get()Andreas Kling
2020-03-15LibJS: Add ObjectPrototype and implement hasOwnProperty()Andreas Kling
All Objects will now have ObjectPrototype as their prototype, unless overridden.
2020-03-15LibJS: Rename collect_roots() => gather_roots()Andreas Kling
Since this is about finding the things we should *not* garabge collect, it seemed wrong to call it "collect_something" :^)
2020-03-15LibJS: Use the same StringPrototype globallyAndreas Kling
To make sure that everyone has the same instance of StringPrototype, hang a global prototype off of the Interpreter that can be fetched when constructing new StringObjects.
2020-03-15LibJS: Add Cell::interpreter() convenience helperAndreas Kling
This allows you to go from any Cell* to the Interpreter.
2020-03-15LibJS: Interpreter should make sure that the "this" stack gets markedAndreas Kling