Commit 2dc69c10 authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

[modules] Various minor cleanups.

Bug: 
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_chromium_rel_ng
Change-Id: I0ecc0af1668f5036bb591e8236d9a28fba61cea5
Reviewed-on: https://chromium-review.googlesource.com/881782
Commit-Queue: Georg Neis <neis@chromium.org>
Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50861}
parent 0eb64190
......@@ -1136,6 +1136,7 @@ class V8_EXPORT Module {
public:
/**
* The different states a module can be in.
*
* This corresponds to the states used in ECMAScript except that "evaluated"
* is split into kEvaluated and kErrored, indicating success and failure,
* respectively.
......@@ -1186,7 +1187,7 @@ class V8_EXPORT Module {
Local<Module> referrer);
/**
* ModuleDeclarationInstantiation
* Instantiates the module and its dependencies.
*
* Returns an empty Maybe<bool> if an exception occurred during
* instantiation. (In the case where the callback throws an exception, that
......@@ -1196,16 +1197,19 @@ class V8_EXPORT Module {
ResolveCallback callback);
/**
* ModuleEvaluation
* Evaluates the module and its dependencies.
*
* Returns the completion value.
* TODO(neis): Be more precise or say nothing.
* If status is kInstantiated, run the module's code. On success, set status
* to kEvaluated and return the completion value; on failure, set status to
* kErrored and propagate the thrown exception (which is then also available
* via |GetException|).
*/
V8_WARN_UNUSED_RESULT MaybeLocal<Value> Evaluate(Local<Context> context);
/**
* Returns the namespace object of this module.
* The module's status must be kEvaluated.
*
* The module's status must be at least kInstantiated.
*/
Local<Value> GetModuleNamespace();
};
......
......@@ -1296,7 +1296,7 @@ void Module::ModuleVerify() {
CHECK((status() >= kEvaluating && code()->IsModuleInfo()) ||
(status() == kInstantiated && code()->IsJSGeneratorObject()) ||
(status() >= kInstantiating && code()->IsJSFunction()) ||
(status() == kInstantiating && code()->IsJSFunction()) ||
(code()->IsSharedFunctionInfo()));
CHECK_EQ(status() == kErrored, !exception()->IsTheHole(GetIsolate()));
......
......@@ -24,17 +24,16 @@ class ModuleInfoEntry;
class String;
class Zone;
// A Module object is a mapping from export names to cells
// This is still very much in flux.
// The runtime representation of an ECMAScript module.
class Module : public Struct {
public:
DECL_CAST(Module)
DECL_VERIFIER(Module)
DECL_PRINTER(Module)
// The code representing this Module, or an abstraction thereof.
// This is either a SharedFunctionInfo or a JSFunction or a ModuleInfo
// depending on whether the module has been instantiated and evaluated. See
// The code representing this module, or an abstraction thereof.
// This is either a SharedFunctionInfo, a JSFunction, a JSGeneratorObject, or
// a ModuleInfo, depending on the state (status) the module is in. See
// Module::ModuleVerify() for the precise invariant.
DECL_ACCESSORS(code, Object)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment