mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 04:38:11 +00:00
LibJS: Make Script and Module GC-allocated
This ensures that code currently in any active or saved execution stack always stays alive.
This commit is contained in:
parent
cb15132146
commit
00c8f07192
18 changed files with 145 additions and 89 deletions
|
@ -16,28 +16,21 @@ namespace JS {
|
|||
|
||||
// 16.2.1.6 Source Text Module Records, https://tc39.es/ecma262/#sec-source-text-module-records
|
||||
class SourceTextModule final : public CyclicModule {
|
||||
JS_CELL(SourceTextModule, CyclicModule);
|
||||
|
||||
public:
|
||||
using ImportEntry = ImportStatement::ImportEntry;
|
||||
using ExportEntry = ExportStatement::ExportEntry;
|
||||
|
||||
static Result<NonnullRefPtr<SourceTextModule>, Vector<Parser::Error>> parse(StringView source_text, Realm&, StringView filename = {});
|
||||
static Result<NonnullGCPtr<SourceTextModule>, Vector<Parser::Error>> parse(StringView source_text, Realm&, StringView filename = {});
|
||||
|
||||
Program const& parse_node() const { return *m_ecmascript_code; }
|
||||
|
||||
virtual ThrowCompletionOr<Vector<FlyString>> get_exported_names(VM& vm, Vector<Module*> export_star_set) override;
|
||||
virtual ThrowCompletionOr<ResolvedBinding> resolve_export(VM& vm, FlyString const& export_name, Vector<ResolvedBinding> resolve_set = {}) override;
|
||||
|
||||
Object* import_meta()
|
||||
{
|
||||
if (m_import_meta.is_null())
|
||||
return nullptr;
|
||||
return m_import_meta.cell();
|
||||
}
|
||||
|
||||
void set_import_meta(Badge<MetaProperty>, Object* import_meta)
|
||||
{
|
||||
m_import_meta = make_handle(import_meta);
|
||||
}
|
||||
Object* import_meta() { return m_import_meta; }
|
||||
void set_import_meta(Badge<MetaProperty>, Object* import_meta) { m_import_meta = import_meta; }
|
||||
|
||||
protected:
|
||||
virtual ThrowCompletionOr<void> initialize_environment(VM& vm) override;
|
||||
|
@ -49,9 +42,11 @@ private:
|
|||
Vector<ExportEntry> indirect_export_entries, Vector<ExportEntry> star_export_entries,
|
||||
RefPtr<ExportStatement> default_export);
|
||||
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
NonnullRefPtr<Program> m_ecmascript_code; // [[ECMAScriptCode]]
|
||||
ExecutionContext m_execution_context; // [[Context]]
|
||||
Handle<Object> m_import_meta; // [[ImportMeta]]
|
||||
GCPtr<Object> m_import_meta; // [[ImportMeta]]
|
||||
Vector<ImportEntry> m_import_entries; // [[ImportEntries]]
|
||||
Vector<ExportEntry> m_local_export_entries; // [[LocalExportEntries]]
|
||||
Vector<ExportEntry> m_indirect_export_entries; // [[IndirectExportEntries]]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue