Skip to content

Commit

Permalink
Revert "XS: compartment proposal update"
Browse files Browse the repository at this point in the history
Reverts VirtualModuleRecord -> ModuleSource rename

This reverts commit 222e094
  • Loading branch information
mhofman committed Jan 13, 2023
1 parent 14bcde0 commit 59552a5
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 58 deletions.
19 changes: 9 additions & 10 deletions xs/sources/xsAll.h
Original file line number Diff line number Diff line change
Expand Up @@ -1792,13 +1792,12 @@ mxExport void fx_Compartment_prototype_evaluate(txMachine* the);
mxExport void fx_Compartment_prototype_import(txMachine* the);
mxExport void fx_Compartment_prototype_importNow(txMachine* the);

mxExport void fx_ModuleSource(txMachine* the);
mxExport void fx_ModuleSource_prototype_get_bindings(txMachine* the);
mxExport void fx_ModuleSource_prototype_get_needsImport(txMachine* the);
mxExport void fx_ModuleSource_prototype_get_needsImportMeta(txMachine* the);

mxExport void fxExecuteVirtualModuleSource(txMachine* the);
mxExport void fxExecuteVirtualModuleSourceImport(txMachine* the);
mxExport void fx_StaticModuleRecord(txMachine* the);
mxExport void fx_StaticModuleRecord_import(txMachine* the);
mxExport void fx_StaticModuleRecord_initialize(txMachine* the);
mxExport void fx_StaticModuleRecord_prototype_get_bindings(txMachine* the);
mxExport void fx_StaticModuleRecord_prototype_get_needsImport(txMachine* the);
mxExport void fx_StaticModuleRecord_prototype_get_needsImportMeta(txMachine* the);

/* xsLockdown.c */
#ifdef mxLockdown
Expand Down Expand Up @@ -2458,7 +2457,7 @@ enum {
mxSharedArrayBufferPrototypeStackIndex,
mxBigIntPrototypeStackIndex,
mxCompartmentPrototypeStackIndex,
mxModuleSourcePrototypeStackIndex,
mxStaticModuleRecordPrototypeStackIndex,
mxWeakRefPrototypeStackIndex,
mxFinalizationRegistryPrototypeStackIndex,

Expand Down Expand Up @@ -2569,7 +2568,7 @@ enum {
#define mxRegExpConstructor the->stackPrototypes[-1 - _RegExp]
#define mxSetConstructor the->stackPrototypes[-1 - _Set]
#define mxSharedArrayBufferConstructor the->stackPrototypes[-1 - _SharedArrayBuffer]
#define mxModuleSourceConstructor the->stackPrototypes[-1 - _ModuleSource]
#define mxStaticModuleRecordConstructor the->stackPrototypes[-1 - _StaticModuleRecord]
#define mxStringConstructor the->stackPrototypes[-1 - _String]
#define mxSymbolConstructor the->stackPrototypes[-1 - _Symbol]
#define mxSyntaxErrorConstructor the->stackPrototypes[-1 - _SyntaxError]
Expand Down Expand Up @@ -2630,7 +2629,7 @@ enum {
#define mxSharedArrayBufferPrototype the->stackPrototypes[-1 - mxSharedArrayBufferPrototypeStackIndex]
#define mxBigIntPrototype the->stackPrototypes[-1 - mxBigIntPrototypeStackIndex]
#define mxCompartmentPrototype the->stackPrototypes[-1 - mxCompartmentPrototypeStackIndex]
#define mxModuleSourcePrototype the->stackPrototypes[-1 - mxModuleSourcePrototypeStackIndex]
#define mxStaticModuleRecordPrototype the->stackPrototypes[-1 - mxStaticModuleRecordPrototypeStackIndex]
#define mxWeakRefPrototype the->stackPrototypes[-1 - mxWeakRefPrototypeStackIndex]
#define mxFinalizationRegistryPrototype the->stackPrototypes[-1 - mxFinalizationRegistryPrototypeStackIndex]

Expand Down
2 changes: 1 addition & 1 deletion xs/sources/xsCommon.c
Original file line number Diff line number Diff line change
Expand Up @@ -1260,7 +1260,6 @@ const txString gxIDStrings[XS_ID_COUNT] = {
"JSON",
"Map",
"Math",
"ModuleSource",
"Number",
"Object",
"Promise",
Expand All @@ -1271,6 +1270,7 @@ const txString gxIDStrings[XS_ID_COUNT] = {
"RegExp",
"Set",
"SharedArrayBuffer",
"StaticModuleRecord",
"String",
"Symbol",
"SyntaxError",
Expand Down
2 changes: 1 addition & 1 deletion xs/sources/xsCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,6 @@ enum {
_JSON,
_Map,
_Math,
_ModuleSource,
_Number,
_Object,
_Promise,
Expand All @@ -694,6 +693,7 @@ enum {
_RegExp,
_Set,
_SharedArrayBuffer,
_StaticModuleRecord,
_String,
_Symbol,
_SyntaxError,
Expand Down
70 changes: 35 additions & 35 deletions xs/sources/xsModule.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ static txBoolean fxModuleSetPrototype(txMachine* the, txSlot* instance, txSlot*
static txSlot* fxCheckCompartmentInstance(txMachine* the, txSlot* slot);
static void fxPrepareCompartmentFunction(txMachine* the, txSlot* program, txSlot* instance);

static txSlot* fxCheckModuleSourceInstance(txMachine* the, txSlot* slot);
static txSlot* fxNewModuleSourceInstance(txMachine* the);
static txSlot* fxCheckStaticModuleRecordInstance(txMachine* the, txSlot* slot);
static txSlot* fxNewStaticModuleRecordInstance(txMachine* the);

const txBehavior ICACHE_FLASH_ATTR gxModuleBehavior = {
fxModuleGetProperty,
Expand Down Expand Up @@ -127,7 +127,7 @@ enum {

#define mxIsModule(THE_SLOT) \
(((THE_SLOT)->next) && ((THE_SLOT)->next->flag & XS_INTERNAL_FLAG) && ((THE_SLOT)->next->kind == XS_MODULE_KIND))
#define mxIsModuleSource(THE_SLOT) \
#define mxIsStaticModuleRecord(THE_SLOT) \
(((THE_SLOT)->next) && ((THE_SLOT)->next->flag & XS_INTERNAL_FLAG) && ((THE_SLOT)->next->kind == XS_MODULE_SOURCE_KIND))

#define mxModuleInstanceStatus(MODULE) ((MODULE)->next->next->ID)
Expand Down Expand Up @@ -198,13 +198,13 @@ void fxBuildModule(txMachine* the)

mxPush(mxObjectPrototype);
slot = fxLastProperty(the, fxNewObjectInstance(the));
slot = fxNextHostAccessorProperty(the, slot, mxCallback(fx_ModuleSource_prototype_get_bindings), C_NULL, mxID(_bindings), XS_DONT_ENUM_FLAG);
// slot = fxNextHostAccessorProperty(the, slot, mxCallback(fx_ModuleSource_prototype_get_needsImport), C_NULL, mxID(_needsImport), XS_DONT_ENUM_FLAG);
// slot = fxNextHostAccessorProperty(the, slot, mxCallback(fx_ModuleSource_prototype_get_needsImportMeta), C_NULL, mxID(_needsImportMeta), XS_DONT_ENUM_FLAG);
slot = fxNextStringXProperty(the, slot, "ModuleSource", mxID(_Symbol_toStringTag), XS_DONT_ENUM_FLAG | XS_DONT_SET_FLAG);
mxModuleSourcePrototype = *the->stack;
slot = fxBuildHostConstructor(the, mxCallback(fx_ModuleSource), 1, mxID(_ModuleSource));
mxModuleSourceConstructor = *the->stack;
slot = fxNextHostAccessorProperty(the, slot, mxCallback(fx_StaticModuleRecord_prototype_get_bindings), C_NULL, mxID(_bindings), XS_DONT_ENUM_FLAG);
// slot = fxNextHostAccessorProperty(the, slot, mxCallback(fx_StaticModuleRecord_prototype_get_needsImport), C_NULL, mxID(_needsImport), XS_DONT_ENUM_FLAG);
// slot = fxNextHostAccessorProperty(the, slot, mxCallback(fx_StaticModuleRecord_prototype_get_needsImportMeta), C_NULL, mxID(_needsImportMeta), XS_DONT_ENUM_FLAG);
slot = fxNextStringXProperty(the, slot, "StaticModuleRecord", mxID(_Symbol_toStringTag), XS_DONT_ENUM_FLAG | XS_DONT_SET_FLAG);
mxStaticModuleRecordPrototype = *the->stack;
slot = fxBuildHostConstructor(the, mxCallback(fx_StaticModuleRecord), 1, mxID(_StaticModuleRecord));
mxStaticModuleRecordConstructor = *the->stack;
mxPop();
}

Expand Down Expand Up @@ -411,15 +411,15 @@ void fxExecuteModulesRejected(txMachine* the)
fxExecuteModules(the, queue);
}

void fxExecuteVirtualModuleSource(txMachine* the)
void fx_StaticModuleRecord_initialize(txMachine* the)
{
txSlot* instance = mxFunction->value.reference;
txSlot* function = fxLastProperty(the, instance);
txSlot* home = mxFunctionInstanceHome(instance);
txSlot* module = home->value.home.module;
txSlot* internal = mxModuleInstanceInternal(module);
txSlot* meta = mxModuleInstanceMeta(module);
txSlot* closures = mxFunctionInstanceCode(instance)->value.callback.closures;
txSlot* closures = mxFunctionInstanceCode(instance)->value.code.closures;
txSlot* property;
if (mxIsUndefined(function))
return;
Expand All @@ -438,7 +438,7 @@ void fxExecuteVirtualModuleSource(txMachine* the)
/* ARGUMENTS */
mxPushReference(closures);
if (internal->flag & XS_IMPORT_FLAG) {
function = fxNewHostFunction(the, fxExecuteVirtualModuleSourceImport, 1, XS_NO_ID);
function = fxNewHostFunction(the, fx_StaticModuleRecord_import, 1, XS_NO_ID);
mxFunctionInstanceHome(function)->value.home.module = module;
}
else
Expand Down Expand Up @@ -1110,7 +1110,7 @@ void fxLoadVirtualModuleNamespace(txMachine* the, txSlot* object, txSlot* module
mxPullSlot(mxModuleInstanceExports(module));
}

void fxLoadVirtualModuleSource_disabled(txMachine* the, txSlot* record, txSlot* instance)
void fxLoadVirtualStaticModuleRecord_disabled(txMachine* the, txSlot* record, txSlot* instance)
{
txSlot* slot;
txSlot* function;
Expand All @@ -1119,13 +1119,13 @@ void fxLoadVirtualModuleSource_disabled(txMachine* the, txSlot* record, txSlot*
txSlot* transfer;

mxPushSlot(record);
mxGetID(fxID(the, "execute"));
mxGetID(fxID(the, "initialize"));
slot = the->stack;
if (!mxIsUndefined(slot)) {
if (!fxIsCallable(the, slot))
mxTypeError("execute is no function");
mxTypeError("initialize is no function");
}
function = fxNewHostFunction(the, fxExecuteVirtualModuleSource, 0, XS_NO_ID);
function = fxNewHostFunction(the, fx_StaticModuleRecord_initialize, 0, XS_NO_ID);
property = mxFunctionInstanceHome(function);
property->value.home.object = fxToInstance(the, record);
property->value.home.module = instance;
Expand Down Expand Up @@ -1649,7 +1649,7 @@ void fxMapModuleDescriptor(txMachine* the, txSlot* realm, txID moduleID, txSlot*
mxPop(); // property;

mxPushSlot(descriptor);
mxGetID(fxID(the, "source"));
mxGetID(fxID(the, "record"));
property = the->stack;
if (!mxIsUndefined(property)) {
if ((property->kind == XS_STRING_KIND) || (property->kind == XS_STRING_X_KIND)) {
Expand All @@ -1663,9 +1663,9 @@ void fxMapModuleDescriptor(txMachine* the, txSlot* realm, txID moduleID, txSlot*
goto done;
}
if (!mxIsReference(property))
mxTypeError("descriptor.source is no object");
if (!mxIsModuleSource(property->value.reference))
mxTypeError("descriptor.source is no module source");
mxTypeError("descriptor.record is no object");
if (!mxIsStaticModuleRecord(property->value.reference))
mxTypeError("descriptor.record is no static module record");
fxDuplicateModuleTransfers(the, property, module);
goto importMeta;
}
Expand Down Expand Up @@ -2866,19 +2866,19 @@ void fx_Compartment_prototype_importNow(txMachine* the)
mxPullSlot(mxResult);
}

txSlot* fxCheckModuleSourceInstance(txMachine* the, txSlot* slot)
txSlot* fxCheckStaticModuleRecordInstance(txMachine* the, txSlot* slot)
{
if (slot->kind == XS_REFERENCE_KIND) {
txSlot* instance = slot->value.reference;
if (((slot = instance->next)) && (slot->flag & XS_INTERNAL_FLAG) && (slot->kind == XS_MODULE_SOURCE_KIND)) {
return instance;
}
}
mxTypeError("this is no ModuleSource instance");
mxTypeError("this is no StaticModuleRecord instance");
return C_NULL;
}

txSlot* fxNewModuleSourceInstance(txMachine* the)
txSlot* fxNewStaticModuleRecordInstance(txMachine* the)
{
txSlot* instance;
txSlot* slot;
Expand Down Expand Up @@ -2914,7 +2914,7 @@ txSlot* fxNewModuleSourceInstance(txMachine* the)
return instance;
}

void fxExecuteVirtualModuleSourceImport(txMachine* the)
void fx_StaticModuleRecord_import(txMachine* the)
{
txSlot* instance = mxFunction->value.reference;
txSlot* home = mxFunctionInstanceHome(instance);
Expand All @@ -2925,17 +2925,17 @@ void fxExecuteVirtualModuleSourceImport(txMachine* the)
mxPullSlot(mxResult);
}

void fx_ModuleSource(txMachine* the)
void fx_StaticModuleRecord(txMachine* the)
{
txSlot* instance;
txSlot* slot;
txStringStream stream;
txScript* script;
if (mxIsUndefined(mxTarget))
mxTypeError("call: ModuleSource");
mxTypeError("call: StaticModuleRecord");
mxPushSlot(mxTarget);
fxGetPrototypeFromConstructor(the, &mxModuleSourcePrototype);
instance = fxNewModuleSourceInstance(the);
fxGetPrototypeFromConstructor(the, &mxStaticModuleRecordPrototype);
instance = fxNewStaticModuleRecordInstance(the);
mxPullSlot(mxResult);
if (mxArgc == 0)
mxPushUndefined();
Expand All @@ -2955,9 +2955,9 @@ void fx_ModuleSource(txMachine* the)
mxPop();
}

void fx_ModuleSource_prototype_get_bindings(txMachine* the)
void fx_StaticModuleRecord_prototype_get_bindings(txMachine* the)
{
txSlot* record = fxCheckModuleSourceInstance(the, mxThis);
txSlot* record = fxCheckStaticModuleRecordInstance(the, mxThis);
txSlot* resultInstance;
txSlot* resultArray;
txSlot* resultItem;
Expand Down Expand Up @@ -3071,17 +3071,17 @@ void fx_ModuleSource_prototype_get_bindings(txMachine* the)
fxCacheArray(the, resultInstance);
}

void fx_ModuleSource_prototype_get_needsImport(txMachine* the)
void fx_StaticModuleRecord_prototype_get_needsImport(txMachine* the)
{
txSlot* record = fxCheckModuleSourceInstance(the, mxThis);
txSlot* record = fxCheckStaticModuleRecordInstance(the, mxThis);
txFlag flag = mxModuleInstanceInternal(record)->flag;
mxResult->value.boolean = (flag & XS_IMPORT_FLAG) ? 1 : 0;
mxResult->kind = XS_BOOLEAN_KIND;
}

void fx_ModuleSource_prototype_get_needsImportMeta(txMachine* the)
void fx_StaticModuleRecord_prototype_get_needsImportMeta(txMachine* the)
{
txSlot* record = fxCheckModuleSourceInstance(the, mxThis);
txSlot* record = fxCheckStaticModuleRecordInstance(the, mxThis);
txFlag flag = mxModuleInstanceInternal(record)->flag;
mxResult->value.boolean = (flag & XS_IMPORT_META_FLAG) ? 1 : 0;
mxResult->kind = XS_BOOLEAN_KIND;
Expand Down
12 changes: 6 additions & 6 deletions xs/sources/xsSnapshot.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,6 @@ static txCallback gxCallbacks[mxCallbacksLength] = {
fx_Math_tan,
fx_Math_tanh,
fx_Math_trunc,
fx_ModuleSource,
fx_ModuleSource_prototype_get_bindings,
// fx_ModuleSource_prototype_get_needsImport,
// fx_ModuleSource_prototype_get_needsImportMeta,
fx_Number_isFinite,
fx_Number_isInteger,
fx_Number_isNaN,
Expand Down Expand Up @@ -435,6 +431,12 @@ static txCallback gxCallbacks[mxCallbacksLength] = {
fx_SharedArrayBuffer_prototype_slice,
fx_SharedArrayBuffer,
fx_species_get,
fx_StaticModuleRecord,
fx_StaticModuleRecord_import,
fx_StaticModuleRecord_initialize,
fx_StaticModuleRecord_prototype_get_bindings,
// fx_StaticModuleRecord_prototype_get_needsImport,
// fx_StaticModuleRecord_prototype_get_needsImportMeta,
fx_String_fromCharCode,
fx_String_fromCodePoint,
fx_String_prototype_at,
Expand Down Expand Up @@ -542,8 +544,6 @@ static txCallback gxCallbacks[mxCallbacksLength] = {
fxArrayLengthSetter,
fxExecuteModulesFulfilled,
fxExecuteModulesRejected,
fxExecuteVirtualModuleSource,
fxExecuteVirtualModuleSourceImport,
fxInitializeRegExp,
fxLoadModulesFulfilled,
fxLoadModulesRejected,
Expand Down
10 changes: 5 additions & 5 deletions xs/tools/xslStrip.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,6 @@ void fxStripCallbacks(txLinker* linker, txMachine* the)
fxStripCallback(linker, fx_Map);
else if (!c_strcmp(name, "Math"))
fxUnuseSymbol(linker, mxID(_Math));
else if (!c_strcmp(name, "ModuleSource")) {
fxStripCallback(linker, fx_ModuleSource);
fxStripCallback(linker, fx_ModuleSource_prototype_get_bindings);
}
else if (!c_strcmp(name, "Promise")) {
fxStripCallback(linker, fx_AsyncFromSyncIterator_prototype_next);
fxStripCallback(linker, fx_AsyncFromSyncIterator_prototype_return);
Expand Down Expand Up @@ -220,6 +216,10 @@ void fxStripCallbacks(txLinker* linker, txMachine* the)
fxStripCallback(linker, fx_Set);
else if (!c_strcmp(name, "SharedArrayBuffer"))
fxStripCallback(linker, fx_SharedArrayBuffer);
else if (!c_strcmp(name, "StaticModuleRecord")) {
fxStripCallback(linker, fx_StaticModuleRecord);
fxStripCallback(linker, fx_StaticModuleRecord_prototype_get_bindings);
}
else if (!c_strcmp(name, "Uint8Array")) {
fxUnuseSymbol(linker, mxID(_Uint8Array));
fxStripCallback(linker, fx_Uint8Array);
Expand All @@ -245,7 +245,7 @@ void fxStripCallbacks(txLinker* linker, txMachine* the)
else if (!c_strcmp(name, "eval")) {
fxStripCallback(linker, fx_Compartment_prototype_evaluate);
fxStripCallback(linker, fx_Function);
fxStripCallback(linker, fx_ModuleSource);
fxStripCallback(linker, fx_StaticModuleRecord);
fxStripCallback(linker, fx_eval);
fxUnuseCode(XS_CODE_ARGUMENTS_SLOPPY);
fxUnuseCode(XS_CODE_EVAL);
Expand Down

0 comments on commit 59552a5

Please sign in to comment.