Skip to content
Merged
5 changes: 4 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ jobs:
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo add-apt-repository "deb http://apt.llvm.org/noble/ llvm-toolchain-noble-20 main"
sudo apt-get update
sudo apt-get install -y clang-20 clang-tidy-20
for i in 1 2 3; do
sudo apt-get install -y clang-20 clang-tidy-20 && break
sleep 17
done
if: matrix.compiler == 'clang'

- name: Install Clang Format
Expand Down
28 changes: 27 additions & 1 deletion SOM.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@
0AB80AD42C392B78006B6419 /* Print.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0AB80AD12C392B78006B6419 /* Print.cpp */; };
0AB80AD82C394806006B6419 /* Globals.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0AB80AD72C394806006B6419 /* Globals.cpp */; };
0AB80AD92C394806006B6419 /* Globals.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0AB80AD72C394806006B6419 /* Globals.cpp */; };
0ACA17172E509E6100FAC36B /* InfIntTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0ACA17162E509E6100FAC36B /* InfIntTests.cpp */; };
0AF394592D7CA9860036FDEF /* VMBigInteger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0AF394582D7CA9860036FDEF /* VMBigInteger.cpp */; };
0AF3945A2D7CA9860036FDEF /* VMBigInteger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0AF394582D7CA9860036FDEF /* VMBigInteger.cpp */; };
/* End PBXBuildFile section */

/* Begin PBXCopyFilesBuildPhase section */
Expand Down Expand Up @@ -252,6 +255,12 @@
0AB80AD62C3947F7006B6419 /* Globals.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Globals.h; sourceTree = "<group>"; };
0AB80AD72C394806006B6419 /* Globals.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Globals.cpp; sourceTree = "<group>"; };
0AB80ADA2C39AC27006B6419 /* InterpreterLoop.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = InterpreterLoop.h; sourceTree = "<group>"; };
0ACA17152E509E6100FAC36B /* InfIntTests.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = InfIntTests.h; path = unitTests/InfIntTests.h; sourceTree = "<group>"; };
0ACA17162E509E6100FAC36B /* InfIntTests.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = InfIntTests.cpp; path = unitTests/InfIntTests.cpp; sourceTree = "<group>"; };
0AF394542D7B91990036FDEF /* TaggingTests.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = TaggingTests.h; path = unitTests/TaggingTests.h; sourceTree = "<group>"; };
0AF394572D7CA9860036FDEF /* VMBigInteger.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VMBigInteger.h; sourceTree = "<group>"; };
0AF394582D7CA9860036FDEF /* VMBigInteger.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = VMBigInteger.cpp; sourceTree = "<group>"; };
0AF3945C2D7CAAF80036FDEF /* InfInt.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = InfInt.h; sourceTree = "<group>"; };
3F5202F10FA6624C00E75857 /* BytecodeGenerator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BytecodeGenerator.cpp; sourceTree = "<group>"; };
3F5202F20FA6624C00E75857 /* BytecodeGenerator.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = BytecodeGenerator.h; sourceTree = "<group>"; tabWidth = 4; };
3F5202F30FA6624C00E75857 /* ClassGenerationContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ClassGenerationContext.cpp; sourceTree = "<group>"; };
Expand Down Expand Up @@ -448,13 +457,16 @@
0A67EA7A19ACD44000830E3B /* unittests */ = {
isa = PBXGroup;
children = (
0AF394542D7B91990036FDEF /* TaggingTests.h */,
0A3FABE724F4670D002D4D69 /* BasicInterpreterTests.h */,
0A67EA7019ACD43A00830E3B /* CloneObjectsTest.cpp */,
0A67EA7119ACD43A00830E3B /* main.cpp */,
0ACA17152E509E6100FAC36B /* InfIntTests.h */,
0ACA17162E509E6100FAC36B /* InfIntTests.cpp */,
0A67EAA319ACE09700830E3B /* CloneObjectsTest.h */,
0A67EAA519ACE09700830E3B /* WalkObjectsTest.h */,
0A67EAA619ACE09700830E3B /* WriteBarrierTest.h */,
0A67EA7319ACD43A00830E3B /* WalkObjectsTest.cpp */,
0A67EAA619ACE09700830E3B /* WriteBarrierTest.h */,
0A67EA7419ACD43A00830E3B /* WriteBarrierTest.cpp */,
0A1C98562C3DD87300735850 /* unitTests/BytecodeGenerationTest.h */,
0A1C98572C3DD88500735850 /* unitTests/BytecodeGenerationTest.cpp */,
Expand All @@ -466,6 +478,14 @@
name = unittests;
sourceTree = "<group>";
};
0AF3945D2D7CAAF80036FDEF /* lib */ = {
isa = PBXGroup;
children = (
0AF3945C2D7CAAF80036FDEF /* InfInt.h */,
);
path = lib;
sourceTree = "<group>";
};
3F5202720FA661D900E75857 = {
isa = PBXGroup;
children = (
Expand All @@ -487,6 +507,7 @@
3F5202EF0FA6624C00E75857 /* src */ = {
isa = PBXGroup;
children = (
0AF3945D2D7CAAF80036FDEF /* lib */,
0A67EA7A19ACD44000830E3B /* unittests */,
3F5202F00FA6624C00E75857 /* compiler */,
3F5203000FA6624C00E75857 /* interpreter */,
Expand Down Expand Up @@ -656,6 +677,8 @@
3F5203380FA6624C00E75857 /* Signature.h */,
3F52033B0FA6624C00E75857 /* VMArray.cpp */,
3F52033C0FA6624C00E75857 /* VMArray.h */,
0AF394572D7CA9860036FDEF /* VMBigInteger.h */,
0AF394582D7CA9860036FDEF /* VMBigInteger.cpp */,
3F52033F0FA6624C00E75857 /* VMBlock.cpp */,
3F5203400FA6624C00E75857 /* VMBlock.h */,
3F5203410FA6624C00E75857 /* VMClass.cpp */,
Expand Down Expand Up @@ -907,6 +930,7 @@
0A1887351832C10E00A2CBCA /* MarkSweepCollector.cpp in Sources */,
0A5A7E912C5D45A00011C783 /* VMSafePrimitive.cpp in Sources */,
0A1886FB1832BCF500A2CBCA /* VMBlock.cpp in Sources */,
0AF3945A2D7CA9860036FDEF /* VMBigInteger.cpp in Sources */,
0A1887391832C12E00A2CBCA /* Timer.cpp in Sources */,
0A1887021832BCFA00A2CBCA /* VMMethod.cpp in Sources */,
0AB80AD32C392B78006B6419 /* Print.cpp in Sources */,
Expand Down Expand Up @@ -962,6 +986,7 @@
0A67EA9019ACD83200830E3B /* Lexer.cpp in Sources */,
0AB80AD92C394806006B6419 /* Globals.cpp in Sources */,
0A5A7E9D2C617EE00011C783 /* TestWithParsing.cpp in Sources */,
0AF394592D7CA9860036FDEF /* VMBigInteger.cpp in Sources */,
0A3A3CA71A5D546D004CB03B /* Object.cpp in Sources */,
0A3A3CB21A5D5476004CB03B /* PrimitiveContainer.cpp in Sources */,
0A1C98582C3DD88500735850 /* unitTests/BytecodeGenerationTest.cpp in Sources */,
Expand Down Expand Up @@ -996,6 +1021,7 @@
0AB80AD02C392811006B6419 /* IsValidObject.cpp in Sources */,
0A67EA9519ACD83900830E3B /* Interpreter.cpp in Sources */,
0A67EA8A19ACD74800830E3B /* VMSymbol.cpp in Sources */,
0ACA17172E509E6100FAC36B /* InfIntTests.cpp in Sources */,
0A67EA7C19ACD74800830E3B /* AbstractObject.cpp in Sources */,
0A67EA8E19ACD83200830E3B /* ClassGenerationContext.cpp in Sources */,
0A3A3CB31A5D5476004CB03B /* PrimitiveLoader.cpp in Sources */,
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/BytecodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,11 @@ void EmitPUSHCONSTANT(MethodGenerationContext& mgenc, const Parser& parser,
// we also make sure that we don't miss anything in the else
// branch of the class check
if (CLASS_OF(cst) == load_ptr(integerClass)) {
if (INT_VAL(cst) == 0LL) {
if (SMALL_INT_VAL(cst) == 0LL) {
Emit1(mgenc, BC_PUSH_0, 1);
return;
}
if (INT_VAL(cst) == 1LL) {
if (SMALL_INT_VAL(cst) == 1LL) {
Emit1(mgenc, BC_PUSH_1, 1);
return;
}
Expand Down
7 changes: 5 additions & 2 deletions src/compiler/Disassembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "../vm/Universe.h"
#include "../vmobjects/ObjectFormats.h"
#include "../vmobjects/Signature.h"
#include "../vmobjects/VMBigInteger.h"
#include "../vmobjects/VMClass.h"
#include "../vmobjects/VMDouble.h"
#include "../vmobjects/VMFrame.h"
Expand Down Expand Up @@ -66,15 +67,17 @@ void Disassembler::dispatch(vm_oop_t o) {
DebugPrint("{Block Class object}");
} else if (o == Universe::GetGlobal(SymbolFor("system"))) {
DebugPrint("{System}");
} else if (IS_SMALL_INT(o)) {
DebugPrint("%lld", SMALL_INT_VAL(o));
} else if (IS_BIG_INT(o)) {
DebugPrint("%s", AS_BIG_INT(o)->embeddedInteger.toString().c_str());
} else {
VMClass* c = CLASS_OF(o);
if (c == load_ptr(stringClass)) {
DebugPrint("\"%s\"",
static_cast<VMString*>(o)->GetStdString().c_str());
} else if (c == load_ptr(doubleClass)) {
DebugPrint("%g", static_cast<VMDouble*>(o)->GetEmbeddedDouble());
} else if (c == load_ptr(integerClass)) {
DebugPrint("%lld", INT_VAL(o));
} else if (c == load_ptr(symbolClass)) {
DebugPrint("#%s",
static_cast<VMSymbol*>(o)->GetStdString().c_str());
Expand Down
1 change: 1 addition & 0 deletions src/compiler/MethodGenerationContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include "../vm/Print.h"
#include "../vm/Universe.h"
#include "../vmobjects/ObjectFormats.h"
#include "../vmobjects/VMBigInteger.h" // NOLINT(misc-include-cleaner)
#include "../vmobjects/VMMethod.h"
#include "../vmobjects/VMPrimitive.h"
#include "../vmobjects/VMSymbol.h"
Expand Down
3 changes: 2 additions & 1 deletion src/compiler/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include "../vm/Symbols.h"
#include "../vm/Universe.h"
#include "../vmobjects/ObjectFormats.h"
#include "../vmobjects/VMBigInteger.h" // NOLINT(misc-include-cleaner)
#include "../vmobjects/VMClass.h"
#include "../vmobjects/VMDouble.h" // NOLINT(misc-include-cleaner) it's required to make the types complete
#include "../vmobjects/VMMethod.h"
Expand Down Expand Up @@ -782,7 +783,7 @@ vm_oop_t Parser::negativeDecimal() {
}

vm_oop_t Parser::literalInteger(bool negateValue) {
vm_oop_t i = ParseInteger(text.c_str(), 10, negateValue);
vm_oop_t i = ParseInteger(text.c_str(), negateValue);
expect(Integer);
return i;
}
Expand Down
28 changes: 13 additions & 15 deletions src/interpreter/Interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include "../vmobjects/ObjectFormats.h"
#include "../vmobjects/Signature.h"
#include "../vmobjects/VMArray.h"
#include "../vmobjects/VMBigInteger.h" // NOLINT(misc-include-cleaner)
#include "../vmobjects/VMBlock.h"
#include "../vmobjects/VMClass.h"
#include "../vmobjects/VMDouble.h"
Expand Down Expand Up @@ -1077,8 +1078,8 @@ void Interpreter::doReturnNonLocal() {
void Interpreter::doInc() {
vm_oop_t val = GetFrame()->Top();

if (IS_TAGGED(val) || CLASS_OF(val) == load_ptr(integerClass)) {
int64_t const result = (int64_t)INT_VAL(val) + 1;
if (IS_SMALL_INT(val)) {
int64_t const result = SMALL_INT_VAL(val) + 1;
val = NEW_INT(result);
} else if (CLASS_OF(val) == load_ptr(doubleClass)) {
double const d = static_cast<VMDouble*>(val)->GetEmbeddedDouble();
Expand All @@ -1093,8 +1094,8 @@ void Interpreter::doInc() {
void Interpreter::doDec() {
vm_oop_t val = GetFrame()->Top();

if (IS_TAGGED(val) || CLASS_OF(val) == load_ptr(integerClass)) {
int64_t const result = (int64_t)INT_VAL(val) - 1;
if (IS_SMALL_INT(val)) {
int64_t const result = SMALL_INT_VAL(val) - 1;
val = NEW_INT(result);
} else if (CLASS_OF(val) == load_ptr(doubleClass)) {
double const d = static_cast<VMDouble*>(val)->GetEmbeddedDouble();
Expand All @@ -1117,8 +1118,8 @@ void Interpreter::doIncField(uint8_t fieldIndex) {

vm_oop_t val = selfObj->GetField(fieldIndex);

if (IS_TAGGED(val) || CLASS_OF(val) == load_ptr(integerClass)) {
int64_t const result = (int64_t)INT_VAL(val) + 1;
if (IS_SMALL_INT(val)) {
int64_t const result = SMALL_INT_VAL(val) + 1;
val = NEW_INT(result);
} else if (CLASS_OF(val) == load_ptr(doubleClass)) {
double const d = static_cast<VMDouble*>(val)->GetEmbeddedDouble();
Expand All @@ -1141,8 +1142,8 @@ void Interpreter::doIncFieldPush(uint8_t fieldIndex) {

vm_oop_t val = selfObj->GetField(fieldIndex);

if (IS_TAGGED(val) || CLASS_OF(val) == load_ptr(integerClass)) {
int64_t const result = (int64_t)INT_VAL(val) + 1;
if (IS_SMALL_INT(val)) {
int64_t const result = SMALL_INT_VAL(val) + 1;
val = NEW_INT(result);
} else if (CLASS_OF(val) == load_ptr(doubleClass)) {
double const d = static_cast<VMDouble*>(val)->GetEmbeddedDouble();
Expand All @@ -1159,14 +1160,11 @@ bool Interpreter::checkIsGreater() {
vm_oop_t top = GetFrame()->Top();
vm_oop_t top2 = GetFrame()->Top2();

if ((IS_TAGGED(top) || CLASS_OF(top) == load_ptr(integerClass)) &&
(IS_TAGGED(top2) || CLASS_OF(top2) == load_ptr(integerClass))) {
return INT_VAL(top) > INT_VAL(top2);
if (IS_SMALL_INT(top) && IS_SMALL_INT(top2)) {
return SMALL_INT_VAL(top) > SMALL_INT_VAL(top2);
}
if ((CLASS_OF(top) == load_ptr(doubleClass)) &&
(CLASS_OF(top2) == load_ptr(doubleClass))) {
return static_cast<VMDouble*>(top)->GetEmbeddedDouble() >
static_cast<VMDouble*>(top2)->GetEmbeddedDouble();
if (IS_DOUBLE(top) && IS_DOUBLE(top2)) {
return AS_DOUBLE(top) > AS_DOUBLE(top2);
}

return false;
Expand Down
Loading