-
Notifications
You must be signed in to change notification settings - Fork 425
Conversation
src/prepack-options.js
Outdated
@@ -101,6 +105,9 @@ export function getSerializerOptions({ | |||
trace, | |||
}; | |||
if (additionalFunctions) result.additionalFunctions = additionalFunctions; | |||
if (lazyObjectsRuntime != null) { |
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.
I'd prefer !== undefined
@@ -1202,7 +1212,6 @@ export class ResidualHeapSerializer { | |||
} | |||
|
|||
_serializeAbstractValueHelper(val: AbstractValue): BabelNodeExpression { | |||
invariant(val.kind !== "sentinel member expression", "invariant established by visitor"); |
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.
Why did you remove this invariant?
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.
This is a redundant invariant from previous checkin.
In "_serializeAbstractValue()" function, there is already same invariant.
// Holds object's lazy initializer bodies. | ||
// These bodies will be combined into a well-known callback after generator serialization is done and registered with the runtime. | ||
_lazyObjectInitializers: Map<ObjectValue, SerializedBody>; | ||
_currentSerializeLazyObject: ?ObjectValue; |
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.
void | ObjectValue. No need to allow two kinds of undefinedness.
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.
The approach with the subclass is quite beautiful! And for a v0 it looks very solid :-)
Long term, I see an issue with the subclass approach when it comes to combining features, such as delayed initialization and lazy objects. Switching to the getTarget
later might require re-architecting the modularity approach.
In any case, great work for the v0!
be35b79
to
b8de173
Compare
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.
@yinghuitan is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Release Note: introduce lazy objects feature for raw objects in Prepack.
Introduce lazy objects feature for raw objects in Prepack with supported runtime.
Lazy object is a collaboration feature between the Prepack and new runtime that supports this feature. With this feature, object can be created with a special LazyObjectsRuntime.createLazyObject() API. The object created with this API can be a light-weight placeholder object. Once the lazy object is touched/used the first time, runtime is responsible to callback the registered initialization function to hydrate the object into a real object.
By doing this we will save both memory and object creation speed.
Currently, Prepack only supports lazy for raw objects.
The APIs that runtime needs to support:
Under lazy objects mode, Prepack will serialize all lazy objects into two parts:
TODO:
Test Plan: