-
-
Notifications
You must be signed in to change notification settings - Fork 402
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Value
refactor
#498
Value
refactor
#498
Conversation
Codecov Report
@@ Coverage Diff @@
## master #498 +/- ##
==========================================
+ Coverage 67.88% 68.06% +0.18%
==========================================
Files 165 169 +4
Lines 9932 9918 -14
==========================================
+ Hits 6742 6751 +9
+ Misses 3190 3167 -23
Continue to review full report at Codecov.
|
Benchmark for 20b71c0Click to view benchmark
|
Woww. The benchmarks are awesome. I did not expect that big of an improvement from an initial refactor of |
Apparently |
a2b8600
to
935ac2a
Compare
Benchmark for 0813346Click to view benchmark
|
Benchmark for b160799Click to view benchmark
|
Benchmark for 9f00b7cClick to view benchmark
|
Size of |
fd7ceff
to
fc1a8d8
Compare
Benchmark for de07dc4Click to view benchmark
|
Benchmark for d5b34c3Click to view benchmark
|
a3b996d
to
2ef288a
Compare
15f6b21
to
1d179d5
Compare
Benchmark for 5dff5c7Click to view benchmark
|
Benchmark for f7daf82Click to view benchmark
|
Benchmark for aab0800Click to view benchmark
|
This is ready for review :) @Razican @jasonwilliams |
c035f1a
to
d5025e2
Compare
Benchmark for 62c19c0Click to view benchmark
|
d5025e2
to
02e8ce4
Compare
Benchmark for aebb26eClick to view benchmark
|
I did a profile of The profile for And for There is a BTW: The gap seems to disappear if I run it a lot with very little time in between, which makes me think that the the file is being cached, that's why sometimes it appears, and other times not. |
@@ -28,7 +28,7 @@ use gc::{unsafe_empty_trace, Finalize, Trace}; | |||
use std::fmt::{self, Debug}; | |||
|
|||
/// _fn(this, arguments, ctx) -> ResultValue_ - The signature of a built-in function | |||
pub type NativeFunctionData = fn(&mut Value, &[Value], &mut Interpreter) -> ResultValue; | |||
pub type NativeFunctionData = fn(&Value, &[Value], &mut Interpreter) -> ResultValue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whats the reason behind the change here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whats the reason behind the change here?
It's because the Value
does not need to be mutable itself, except Object
and Object
is covered in a GcCell<...>
it has interior mutability, so we can borrow_mut
the Object
with a immutable reference to Value
.
This eliminated some places where we were awkwardly cloning the value and passing it to a function because the builtin function required it (&mut value.clone()
), instead of just passing the value direclty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, benchmarks are amazing!! 80% reduction in arithmetic operations is crazy!
Check my comments, they are mostly a bit of cleanup, part of it not even related to the PR. I think this code is very good!
Benchmark for 6de3aecClick to view benchmark
|
- Refactor `String` => `Rc<str>` - Refactor `Symbol` => `Rc<Symbol>` - Refactor `BigInt` => `RcBigInt` - Changed function signature, from `&mut Value` to `&Value` - Removed `Interpreter::value_to_rust_number() - Abstracted `Gc<GcCell<Object>>` to `GcObject` - Removed unnecessary `Box`s in global environment - Extracted `extensible` from internal slots - Made `to_primitive` throw errors - Removed `strict` parameter in `SameValue` function. - The `SameValue` function is not dependent on strict mode.
765e0ae
to
ca0fa50
Compare
Benchmark for f951c8fClick to view benchmark
|
Lets merge this :) |
This Pull Request fixes/closes #465
It changes the following:
Gc<...>
=>Value::Object(Gc<GcCell<Object>>)
ValueData
=>Value
RcString
,RcSymbol
,RcBigInt
Value::String(String)
=>Value::String(RcString)
Value::Symbol(Symbol)
=>Value::Symbol(RcSymbol)
Value::BigInt(BigInt)
=>Value::BigInt(RcBigInt)
Gc<GcCell<Object>>
=>GcObject
Value
size from40
bytes =>24
bytesthis
, from&mut Value
=>&Value
Interpreter::value_to_rust_number()
Box
s in global environmentextensible
forinternal_slots
to_primitive
,ordinary_to_primitive
andValue::equals
throw errors.strict
parameter ofSameValue
(it is not dependent on strict mode)