Skip to content

Commit

Permalink
CogVM source as per VMMaker.oscog-eem.2166
Browse files Browse the repository at this point in the history
InterpreterPrimitives:
Add a proper getenv: primitive, with full control for disabling from the
SecurityPlugin.  A valid declaration is <primitive: 'primitiveGetenv'>.

SecurityPlugin:
Ad support for environment access control.  Make all platforms agree that the
ioDisableFoo calls answer zero on success (unix answered 1).  Cut down the
amount of white space in the platform SecurityPlugin support files.

Cogit:
Fix the regression introduced in VMMaker.oscog-eem.2161 & VMMaker.oscog-eem.2160
when reintroducing the ceNewHash: trampoline.  ceNewhash: must /not/ be called
from Behavior's identityHash (175) only from ProtoObject's (75).

Sista:
Fix the determination of how much to free for the SistaMethodZone.
  • Loading branch information
eliotmiranda committed Mar 19, 2017
1 parent 686a241 commit 1f81775
Show file tree
Hide file tree
Showing 80 changed files with 2,314 additions and 608 deletions.
2 changes: 1 addition & 1 deletion nsspur64src/vm/cogit.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Automatically generated by
CCodeGenerator VMMaker.oscog-eem.2161 uuid: 6fbb916c-04e5-42c8-b844-12c5eead9dba
CCodeGenerator VMMaker.oscog-eem.2166 uuid: 7471b7ee-fa31-444f-bc3d-dee21ee090f2
*/


Expand Down
19 changes: 11 additions & 8 deletions nsspur64src/vm/cogitX64.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* Automatically generated by
CCodeGenerator VMMaker.oscog-eem.2160 uuid: 9fcce340-c6a2-4c79-b7f9-dda8ed959b81
CCodeGenerator VMMaker.oscog-eem.2166 uuid: 7471b7ee-fa31-444f-bc3d-dee21ee090f2
from
StackToRegisterMappingCogit VMMaker.oscog-eem.2160 uuid: 9fcce340-c6a2-4c79-b7f9-dda8ed959b81
StackToRegisterMappingCogit VMMaker.oscog-eem.2166 uuid: 7471b7ee-fa31-444f-bc3d-dee21ee090f2
*/
static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.2160 uuid: 9fcce340-c6a2-4c79-b7f9-dda8ed959b81 " __DATE__ ;
static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.2166 uuid: 7471b7ee-fa31-444f-bc3d-dee21ee090f2 " __DATE__ ;
char *__cogitBuildInfo = __buildInfo;


Expand Down Expand Up @@ -572,7 +572,7 @@ static sqInt NoDbgRegParms fillInBlockHeadersAt(sqInt startAddress);
static CogMethod * NoDbgRegParms fillInMethodHeadersizeselector(CogMethod *method, sqInt size, sqInt selector);
static sqInt NoDbgRegParms findBackwardBranchIsBackwardBranchMcpcBcpcMatchingBcpc(BytecodeDescriptor *descriptor, sqInt isBackwardBranchAndAnnotation, char *mcpc, sqInt bcpc, void *targetBcpc);
static usqInt NoDbgRegParms findBlockMethodWithEntrystartBcpc(sqInt blockEntryMcpc, sqInt startBcpc);
static sqInt NoDbgRegParms findMapLocationForMcpcinMethod(usqInt targetMcpc, CogMethod *cogMethod);
static usqInt NoDbgRegParms findMapLocationForMcpcinMethod(usqInt targetMcpc, CogMethod *cogMethod);
extern CogBlockMethod * findMethodForStartBcpcinHomeMethod(sqInt startbcpc, CogMethod *cogMethod);
static sqInt NoDbgRegParms findIsBackwardBranchMcpcBcpcMatchingMcpc(BytecodeDescriptor *descriptor, sqInt isBackwardBranchAndAnnotation, char *mcpc, sqInt bcpc, void *targetMcpc);
static usqInt NoDbgRegParms firstMappedPCFor(CogMethod *cogMethod);
Expand Down Expand Up @@ -644,7 +644,7 @@ static BytecodeDescriptor * loadBytesAndGetDescriptor(void);
static void NoDbgRegParms loadSubsequentBytesForDescriptorat(BytecodeDescriptor *descriptor, sqInt pc);
static AbstractInstruction * NoDbgRegParms gMoveAwR(sqInt address, sqInt reg);
static AbstractInstruction * NoDbgRegParms gMoveCwR(sqInt wordConstant, sqInt reg);
static sqInt NoDbgRegParms mapEndFor(CogMethod *cogMethod);
static usqInt NoDbgRegParms mapEndFor(CogMethod *cogMethod);
static sqInt NoDbgRegParms mapForperformUntilarg(CogMethod *cogMethod, sqInt (*functionSymbol)(sqInt annotation, char *mcpc, sqInt arg), sqInt arg);
static sqInt NoDbgRegParms mapObjectReferencesInClosedPIC(CogMethod *cPIC);
static void mapObjectReferencesInGeneratedRuntime(void);
Expand Down Expand Up @@ -2815,7 +2815,7 @@ static sqInt NoDbgRegParms
blockDispatchTargetsForperformarg(CogMethod *cogMethod, usqInt (*binaryFunction)(sqInt mcpc, sqInt arg), sqInt arg)
{
sqInt blockEntry;
sqInt end;
usqInt end;
sqInt pc;
sqInt result;
usqInt targetpc;
Expand Down Expand Up @@ -5434,7 +5434,7 @@ findBlockMethodWithEntrystartBcpc(sqInt blockEntryMcpc, sqInt startBcpc)
}

/* Cogit>>#findMapLocationForMcpc:inMethod: */
static sqInt NoDbgRegParms
static usqInt NoDbgRegParms
findMapLocationForMcpcinMethod(usqInt targetMcpc, CogMethod *cogMethod)
{
sqInt annotation;
Expand Down Expand Up @@ -7266,7 +7266,7 @@ gMoveCwR(sqInt wordConstant, sqInt reg)
/* Answer the address of the null byte at the end of the method map. */

/* Cogit>>#mapEndFor: */
static sqInt NoDbgRegParms
static usqInt NoDbgRegParms
mapEndFor(CogMethod *cogMethod)
{
usqInt end;
Expand Down Expand Up @@ -13423,6 +13423,9 @@ genPrimitiveIdentityHash(void)
genoperand(RetN, 0);

jmpTarget(jumpNotSet, genoperandoperand(Label, (labelCounter += 1), bytecodePC));
if (!(primitiveIndex == 75)) {
return 0;
}
/* begin CallRT: */
abstractInstruction = genoperand(Call, ceNewHashTrampoline);
(abstractInstruction->annotation = IsRelativeCall);
Expand Down
65 changes: 58 additions & 7 deletions nsspur64src/vm/cointerp.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* Automatically generated by
CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2161 uuid: 6fbb916c-04e5-42c8-b844-12c5eead9dba
CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2165 uuid: 2fa022b2-1323-47d7-b2cd-66682edbaf80
from
CoInterpreter VMMaker.oscog-eem.2161 uuid: 6fbb916c-04e5-42c8-b844-12c5eead9dba
CoInterpreter VMMaker.oscog-eem.2165 uuid: 2fa022b2-1323-47d7-b2cd-66682edbaf80
*/
static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.2161 uuid: 6fbb916c-04e5-42c8-b844-12c5eead9dba " __DATE__ ;
static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.2165 uuid: 2fa022b2-1323-47d7-b2cd-66682edbaf80 " __DATE__ ;
char *__interpBuildInfo = __buildInfo;


Expand Down Expand Up @@ -738,6 +738,7 @@ static void primitiveForceDisplayUpdate(void);
static void primitiveFormPrint(void);
static void primitiveFractionalPart(void);
static void primitiveGetAttribute(void);
EXPORT(sqInt) primitiveGetenv(void);
#if IMMUTABILITY
static void primitiveGetImmutability(void);
#else
Expand Down Expand Up @@ -1906,6 +1907,7 @@ static void (*interruptCheckChain)(void) = 0;
sqInt suppressHeartbeatFlag;
sqInt debugCallbackInvokes;
sqInt debugCallbackReturns;
static int (*sHEAFn)() = 0;
static void (*externalPrimitiveTable[MaxExternalPrimitiveTableSize + 1 /* 4097 */])(void);
static void (*primitiveTable[MaxPrimitiveIndex + 2 /* 577 */])(void) = {
/* 0 */ (void (*)(void))0,
Expand Down Expand Up @@ -2518,7 +2520,7 @@ static signed char primitiveAccessorDepthTable[MaxPrimitiveIndex + 2 /* 577 */]
};
sqInt checkedPluginName;
char expensiveAsserts = 0;
const char *interpreterVersion = "Newspeak Virtual Machine CoInterpreterPrimitives_VMMaker.oscog-eem.2161";
const char *interpreterVersion = "Newspeak Virtual Machine CoInterpreterPrimitives_VMMaker.oscog-eem.2165";
sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */;
volatile int sendTrace;

Expand Down Expand Up @@ -18352,7 +18354,7 @@ ceSendMustBeBooleanTointerpretingAtDelta(sqInt aNonBooleanObject, sqInt jumpSize
sqInt oop;
char *p;
char *sp;
sqInt startBcpc;
unsigned short startBcpc;
sqInt top;

assert(addressCouldBeOop(aNonBooleanObject));
Expand Down Expand Up @@ -22970,7 +22972,7 @@ printFrameWithSP(char *theFP, char *theSP)
usqInt index;
sqInt methodField;
usqInt numArgs;
usqInt numTemps;
sqInt numTemps;
char *rcvrAddress;
sqInt rcvrOrClosure;
sqInt theMethod;
Expand Down Expand Up @@ -23815,6 +23817,7 @@ readImageFromFileHeapSizeStartingAt(sqImageFile f, usqInt desiredHeapSize, squea
while (GIV(globalSessionID) == 0) {
GIV(globalSessionID) = (time(NULL)) + (ioMSecs());
}
sHEAFn = ioLoadFunctionFrom("secHasEnvironmentAccess", "SecurityPlugin");
/* begin initializeCodeGenerator */
initializeCodeZoneFromupTo(memory(), (memory()) + GIV(cogCodeSize));
return dataSize;
Expand Down Expand Up @@ -33680,6 +33683,53 @@ primitiveGetAttribute(void)
}
}


/* Access to environment variables via getenv. No putenv or setenv as yet. */

/* InterpreterPrimitives>>#primitiveGetenv */
EXPORT(sqInt)
primitiveGetenv(void)
{ DECL_MAYBE_SQ_GLOBAL_STRUCT
sqInt oop;
char *result;
char *sp;
char *var;

if (sHEAFn != 0) {

/* secHasEnvironmentAccess */
if (!(sHEAFn())) {
/* begin primitiveFailFor: */
return (GIV(primFailCode) = PrimErrInappropriate);
}
}
var = cStringOrNullFor(longAt(GIV(stackPointer)));
if (var == 0) {
if (!GIV(primFailCode)) {
/* begin primitiveFailFor: */
return (GIV(primFailCode) = PrimErrBadArgument);
}
return 0;
}
result = getenv(var);
free(var);
if (result != 0) {
result = stringForCString(result);
if (!(result)) {
/* begin primitiveFailFor: */
return (GIV(primFailCode) = PrimErrNoMemory);
}
}
assert(GIV(primFailCode) == 0);
/* begin pop:thenPush: */
oop = (result == 0
? GIV(nilObj)
: result);
longAtput((sp = GIV(stackPointer) + ((2 - 1) * BytesPerWord)), oop);
GIV(stackPointer) = sp;
return 0;
}

/* InterpreterPrimitives>>#primitiveGetImmutability */
#if IMMUTABILITY
static void
Expand Down Expand Up @@ -74838,7 +74888,7 @@ removeFirstLinkOfList(sqInt aList)
static sqInt
retryPrimitiveOnFailure(void)
{ DECL_MAYBE_SQ_GLOBAL_STRUCT
signed char accessorDepth;
sqInt accessorDepth;
sqInt canRetry;
sqInt firstBytecode;
sqInt followDone;
Expand Down Expand Up @@ -82229,6 +82279,7 @@ void* vm_exports[][3] = {
{(void*)_m, "primitiveDivLargeIntegers\000\377", (void*)primitiveDivLargeIntegers},
{(void*)_m, "primitiveEqualLargeIntegers\000\377", (void*)primitiveEqualLargeIntegers},
{(void*)_m, "primitiveEventProcessingControl\000\377", (void*)primitiveEventProcessingControl},
{(void*)_m, "primitiveGetenv\000\377", (void*)primitiveGetenv},
{(void*)_m, "primitiveGetLogDirectory\000\377", (void*)primitiveGetLogDirectory},
{(void*)_m, "primitiveGetWindowLabel\000\377", (void*)primitiveGetWindowLabel},
{(void*)_m, "primitiveGetWindowSize\000\377", (void*)primitiveGetWindowSize},
Expand Down
2 changes: 1 addition & 1 deletion nsspur64src/vm/cointerp.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Automatically generated by
CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2161 uuid: 6fbb916c-04e5-42c8-b844-12c5eead9dba
CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2165 uuid: 2fa022b2-1323-47d7-b2cd-66682edbaf80
*/


Expand Down
65 changes: 58 additions & 7 deletions nsspur64src/vm/gcc3x-cointerp.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@


/* Automatically generated by
CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2161 uuid: 6fbb916c-04e5-42c8-b844-12c5eead9dba
CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2165 uuid: 2fa022b2-1323-47d7-b2cd-66682edbaf80
from
CoInterpreter VMMaker.oscog-eem.2161 uuid: 6fbb916c-04e5-42c8-b844-12c5eead9dba
CoInterpreter VMMaker.oscog-eem.2165 uuid: 2fa022b2-1323-47d7-b2cd-66682edbaf80
*/
static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.2161 uuid: 6fbb916c-04e5-42c8-b844-12c5eead9dba " __DATE__ ;
static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.2165 uuid: 2fa022b2-1323-47d7-b2cd-66682edbaf80 " __DATE__ ;
char *__interpBuildInfo = __buildInfo;


Expand Down Expand Up @@ -741,6 +741,7 @@ static void primitiveForceDisplayUpdate(void);
static void primitiveFormPrint(void);
static void primitiveFractionalPart(void);
static void primitiveGetAttribute(void);
EXPORT(sqInt) primitiveGetenv(void);
#if IMMUTABILITY
static void primitiveGetImmutability(void);
#else
Expand Down Expand Up @@ -1909,6 +1910,7 @@ static void (*interruptCheckChain)(void) = 0;
sqInt suppressHeartbeatFlag;
sqInt debugCallbackInvokes;
sqInt debugCallbackReturns;
static int (*sHEAFn)() = 0;
static void (*externalPrimitiveTable[MaxExternalPrimitiveTableSize + 1 /* 4097 */])(void);
static void (*primitiveTable[MaxPrimitiveIndex + 2 /* 577 */])(void) = {
/* 0 */ (void (*)(void))0,
Expand Down Expand Up @@ -2521,7 +2523,7 @@ static signed char primitiveAccessorDepthTable[MaxPrimitiveIndex + 2 /* 577 */]
};
sqInt checkedPluginName;
char expensiveAsserts = 0;
const char *interpreterVersion = "Newspeak Virtual Machine CoInterpreterPrimitives_VMMaker.oscog-eem.2161";
const char *interpreterVersion = "Newspeak Virtual Machine CoInterpreterPrimitives_VMMaker.oscog-eem.2165";
sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */;
volatile int sendTrace;

Expand Down Expand Up @@ -18361,7 +18363,7 @@ ceSendMustBeBooleanTointerpretingAtDelta(sqInt aNonBooleanObject, sqInt jumpSize
sqInt oop;
char *p;
char *sp;
sqInt startBcpc;
unsigned short startBcpc;
sqInt top;

assert(addressCouldBeOop(aNonBooleanObject));
Expand Down Expand Up @@ -22979,7 +22981,7 @@ printFrameWithSP(char *theFP, char *theSP)
usqInt index;
sqInt methodField;
usqInt numArgs;
usqInt numTemps;
sqInt numTemps;
char *rcvrAddress;
sqInt rcvrOrClosure;
sqInt theMethod;
Expand Down Expand Up @@ -23824,6 +23826,7 @@ readImageFromFileHeapSizeStartingAt(sqImageFile f, usqInt desiredHeapSize, squea
while (GIV(globalSessionID) == 0) {
GIV(globalSessionID) = (time(NULL)) + (ioMSecs());
}
sHEAFn = ioLoadFunctionFrom("secHasEnvironmentAccess", "SecurityPlugin");
/* begin initializeCodeGenerator */
initializeCodeZoneFromupTo(memory(), (memory()) + GIV(cogCodeSize));
return dataSize;
Expand Down Expand Up @@ -33689,6 +33692,53 @@ primitiveGetAttribute(void)
}
}


/* Access to environment variables via getenv. No putenv or setenv as yet. */

/* InterpreterPrimitives>>#primitiveGetenv */
EXPORT(sqInt)
primitiveGetenv(void)
{ DECL_MAYBE_SQ_GLOBAL_STRUCT
sqInt oop;
char *result;
char *sp;
char *var;

if (sHEAFn != 0) {

/* secHasEnvironmentAccess */
if (!(sHEAFn())) {
/* begin primitiveFailFor: */
return (GIV(primFailCode) = PrimErrInappropriate);
}
}
var = cStringOrNullFor(longAt(GIV(stackPointer)));
if (var == 0) {
if (!GIV(primFailCode)) {
/* begin primitiveFailFor: */
return (GIV(primFailCode) = PrimErrBadArgument);
}
return 0;
}
result = getenv(var);
free(var);
if (result != 0) {
result = stringForCString(result);
if (!(result)) {
/* begin primitiveFailFor: */
return (GIV(primFailCode) = PrimErrNoMemory);
}
}
assert(GIV(primFailCode) == 0);
/* begin pop:thenPush: */
oop = (result == 0
? GIV(nilObj)
: result);
longAtput((sp = GIV(stackPointer) + ((2 - 1) * BytesPerWord)), oop);
GIV(stackPointer) = sp;
return 0;
}

/* InterpreterPrimitives>>#primitiveGetImmutability */
#if IMMUTABILITY
static void
Expand Down Expand Up @@ -74847,7 +74897,7 @@ removeFirstLinkOfList(sqInt aList)
static sqInt
retryPrimitiveOnFailure(void)
{ DECL_MAYBE_SQ_GLOBAL_STRUCT
signed char accessorDepth;
sqInt accessorDepth;
sqInt canRetry;
sqInt firstBytecode;
sqInt followDone;
Expand Down Expand Up @@ -82238,6 +82288,7 @@ void* vm_exports[][3] = {
{(void*)_m, "primitiveDivLargeIntegers\000\377", (void*)primitiveDivLargeIntegers},
{(void*)_m, "primitiveEqualLargeIntegers\000\377", (void*)primitiveEqualLargeIntegers},
{(void*)_m, "primitiveEventProcessingControl\000\377", (void*)primitiveEventProcessingControl},
{(void*)_m, "primitiveGetenv\000\377", (void*)primitiveGetenv},
{(void*)_m, "primitiveGetLogDirectory\000\377", (void*)primitiveGetLogDirectory},
{(void*)_m, "primitiveGetWindowLabel\000\377", (void*)primitiveGetWindowLabel},
{(void*)_m, "primitiveGetWindowSize\000\377", (void*)primitiveGetWindowSize},
Expand Down
2 changes: 1 addition & 1 deletion nsspursrc/vm/cogit.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Automatically generated by
CCodeGenerator VMMaker.oscog-eem.2161 uuid: 6fbb916c-04e5-42c8-b844-12c5eead9dba
CCodeGenerator VMMaker.oscog-eem.2166 uuid: 7471b7ee-fa31-444f-bc3d-dee21ee090f2
*/


Expand Down
Loading

0 comments on commit 1f81775

Please sign in to comment.