Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
d8aa5c0
Include file stream natives in translator output
shai-almog Dec 25, 2025
9661e4d
Use UTFDataFormatException for malformed DataInputStream UTF
shai-almog Dec 25, 2025
0ee75dc
Simplify DataInputStream UTF exceptions
shai-almog Dec 25, 2025
61c6112
Fix native runtime linking for file streams
shai-almog Dec 25, 2025
01e5649
Avoid Objective-C dependency for clean target outputs
shai-almog Dec 26, 2025
414a3c9
Add minimal wrapper classes to StampedLock integration mock API
shai-almog Dec 26, 2025
b7c74b8
Fix clean target runtime stubs for StampedLock
shai-almog Dec 26, 2025
7a458f0
Add string array stubs for clean runtime builds
shai-almog Dec 26, 2025
53157cb
Add File stub for StampedLock integration
shai-almog Dec 26, 2025
bbbb18a
Fix File pathSeparator literal in StampedLock test
shai-almog Dec 27, 2025
c4d2578
Add native stubs for translator clean builds
shai-almog Dec 27, 2025
fe25f55
Add primitive wrapper mocks for read/write lock integration
shai-almog Dec 27, 2025
1d4ad0d
Add ArrayIndexOutOfBoundsException mock for RW lock test
shai-almog Dec 27, 2025
9fe2e63
Add GC stubs to ReadWriteLock System mock
shai-almog Dec 27, 2025
d1f71e5
Add File mock for ReadWriteLock integration test
shai-almog Dec 27, 2025
d82026d
Patch java_io_File header for clean builds
shai-almog Dec 27, 2025
33d956d
Add file stream stubs to clean translator tests
shai-almog Dec 27, 2025
6580285
Add String valueOf overloads to clean translator stubs
shai-almog Dec 27, 2025
e1c1611
Patch HashMap stubs in ReadWriteLock integration
shai-almog Dec 28, 2025
812511f
Add HashMap Entry stubs for clean translator builds
shai-almog Dec 28, 2025
0e417c9
Handle CMakeLists without Objective-C
shai-almog Dec 28, 2025
11f10f0
Add clean target stubs for read/write lock integration
shai-almog Dec 28, 2025
03ff25a
Simplify clean-target HashMap mocks
shai-almog Dec 28, 2025
c038e84
Fix mock HashMap source in StampedLock integration test
shai-almog Dec 28, 2025
20496ea
Tighten clean target runtime stubs for integration tests
shai-almog Dec 28, 2025
f829c69
Use Java 8 compatible file reads in integration tests
shai-almog Dec 28, 2025
f9978be
Harden clean target integration stubs for native builds
shai-almog Dec 28, 2025
5338c7a
Fix clean target GC getter prototypes
shai-almog Jan 2, 2026
f40dae1
Add clean-target prototypes for runtime stubs
shai-almog Jan 3, 2026
b4e6e49
Add Throwable stack prototypes to clean-target native patching
shai-almog Jan 4, 2026
fa89021
Add primitive wrapper mocks to lock integration test
shai-almog Jan 4, 2026
f38d517
Add Integer stub to Lock integration mock API
shai-almog Jan 4, 2026
a7aef1a
Add Long wrapper to Lock integration mocks
shai-almog Jan 4, 2026
e9cbe12
Add float/double wrappers to Lock integration mock
shai-almog Jan 4, 2026
9bd30f7
Add ArrayIndexOutOfBoundsException stub for lock integration
shai-almog Jan 5, 2026
9f68588
Add GC stubs to lock integration System mock
shai-almog Jan 5, 2026
a43fd71
Add getBytes stub to Lock integration String mock
shai-almog Jan 5, 2026
4bbc16c
Add File stub to lock integration mock
shai-almog Jan 5, 2026
94b6511
Remove unused file stream natives from Lock integration harness
shai-almog Jan 5, 2026
666048f
Keep java.io.File outputs for Lock integration builds
shai-almog Jan 6, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions vm/ByteCodeTranslator/src/cn1_globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include <stdio.h>
#include <stdlib.h>

#define CN1_GLOBALS_IMPLEMENTED 1
#include "cn1_class_method_index.h"
#include <pthread.h>
#include <setjmp.h>
Expand Down
28 changes: 20 additions & 8 deletions vm/ByteCodeTranslator/src/cn1_globals.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "cn1_globals.h"
#include <assert.h>
#include <unistd.h>
#include "java_lang_Class.h"
#include "java_lang_Object.h"
#include "java_lang_Boolean.h"
Expand All @@ -14,13 +15,19 @@
#include "java_lang_Float.h"
#include "java_lang_Runnable.h"
#include "java_lang_System.h"

JAVA_BOOLEAN lowMemoryMode = JAVA_FALSE;
int mallocWhileSuspended = 0;
BOOL isAppSuspended = NO;
#include "java_lang_ArrayIndexOutOfBoundsException.h"
#if defined(__APPLE__) && defined(__OBJC__)
#import <mach/mach.h>
#import <mach/mach_host.h>
#define CN1_LOG(fmt, ...) NSLog(@fmt, ##__VA_ARGS__)
#else
#include <time.h>
#define NSLog(...) printf(__VA_ARGS__); printf("\n")
#include <stdio.h>
#define CN1_LOG(fmt, ...) printf(fmt "\n", ##__VA_ARGS__)
#endif

// The amount of memory allocated between GC cycle checks (generally 30 seconds)
Expand Down Expand Up @@ -261,6 +268,11 @@ static void init_gc_thresholds() {
DEBUG_GC_INIT 0, 999999, 0, 0, 0, 0, 0, 0, 0, 0, cn1_array_1_id_JAVA_DOUBLE, "double[]", JAVA_TRUE, 1, &class__java_lang_Double, JAVA_TRUE, &class__java_lang_Object, EMPTY_INTERFACES, 0, 0, 0
};

// Minimal stubs for String array classes so clean-target builds that only
// reference primitive wrappers still have constant pool backing storage.
struct clazz class_array1__java_lang_String = {0};
struct clazz class_array2__java_lang_String = {0};

struct clazz class_array2__JAVA_DOUBLE = {
DEBUG_GC_INIT 0, 999999, 0, 0, 0, 0, 0, 0, &gcMarkArrayObject, 0, cn1_array_2_id_JAVA_DOUBLE, "double[]", JAVA_TRUE, 2, &class__java_lang_Double, JAVA_TRUE, &class__java_lang_Object, EMPTY_INTERFACES, 0, 0, 0
};
Expand Down Expand Up @@ -586,8 +598,8 @@ void codenameOneGCMark() {
{ long later = time(0)-now;
if(later>10000)
{
NSLog(@"GC trapped for %d seconds waiting for thread %d in slot %d (%d)",
(int)(later/1000),(int)t->threadId,iter,t->threadKilled);
CN1_LOG("GC trapped for %d seconds waiting for thread %d in slot %d (%d)",
(int)(later/1000),(int)t->threadId,iter,t->threadKilled);
}
}
}
Expand Down Expand Up @@ -622,7 +634,7 @@ void codenameOneGCMark() {
}
if (CN1_EDT_THREAD_ID == t->threadId && agressiveAllocator) {
long freeMemory = get_free_memory();
NSLog(@"[GC] Blocking EDT as aggressive allocator, free memory=%lld", freeMemory);
CN1_LOG("[GC] Blocking EDT as aggressive allocator, free memory=%ld", freeMemory);

}

Expand Down Expand Up @@ -712,7 +724,7 @@ void printObjectsPostSweep(CODENAME_ONE_THREAD_STATE) {
}
}
int actualTotalMemory = 0;
NSLog(@"\n\n**** There are %i - %i = %i nulls available entries out of %i objects in heap which take up %i, sweep saved %i ****", nullSpaces, nullSpacesPreSweep, nullSpaces - nullSpacesPreSweep, t, totalAllocatedHeap, preSweepRam - totalAllocatedHeap);
CN1_LOG("\n\n**** There are %i - %i = %i nulls available entries out of %i objects in heap which take up %i, sweep saved %i ****", nullSpaces, nullSpacesPreSweep, nullSpaces - nullSpacesPreSweep, t, totalAllocatedHeap, preSweepRam - totalAllocatedHeap);
for(int iter = 0 ; iter < cn1_array_3_id_java_util_Vector ; iter++) {
if(classTypeCount[iter] > 0) {
if(classTypeCountPreSweep[iter] - classTypeCount[iter] > 0) {
Expand All @@ -731,7 +743,7 @@ void printObjectsPostSweep(CODENAME_ONE_THREAD_STATE) {
}
}
//NSLog(@"Actual ram = %i vs total mallocs = %i", actualTotalMemory, totalAllocatedHeap);
NSLog(@"**** GC cycle complete ****");
CN1_LOG("**** GC cycle complete ****");

free(arrayOfNames);
#if defined(__APPLE__) && defined(__OBJC__)
Expand Down Expand Up @@ -769,7 +781,7 @@ void printObjectTypesInHeap(CODENAME_ONE_THREAD_STATE) {
}
}
int actualTotalMemory = 0;
NSLog(@"There are %i null available entries out of %i objects in heap which take up %i", nullSpaces, t, totalAllocatedHeap);
CN1_LOG("There are %i null available entries out of %i objects in heap which take up %i", nullSpaces, t, totalAllocatedHeap);
for(int iter = 0 ; iter < cn1_array_3_id_java_util_Vector ; iter++) {
if(classTypeCount[iter] > 0) {
float f = ((float)classTypeCount[iter]) / ((float)t) * 100.0f;
Expand All @@ -787,7 +799,7 @@ void printObjectTypesInHeap(CODENAME_ONE_THREAD_STATE) {
actualTotalMemory += sizeInHeapForType[iter];
}
}
NSLog(@"Actual ram = %i vs total mallocs = %i", actualTotalMemory, totalAllocatedHeap);
CN1_LOG("Actual ram = %i vs total mallocs = %i", actualTotalMemory, totalAllocatedHeap);

free(arrayOfNames);
#if defined(__APPLE__) && defined(__OBJC__)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,14 @@ private static void handleCleanOutput(ByteCodeTranslator b, File[] sources, File
}
File xmlvm = new File(srcRoot, "xmlvm.h");
copy(ByteCodeTranslator.class.getResourceAsStream("/xmlvm.h"), new FileOutputStream(xmlvm));
File nativeMethods = new File(srcRoot, "nativeMethods.m");
File nativeMethods = new File(srcRoot, "nativeMethods.c");
copy(ByteCodeTranslator.class.getResourceAsStream("/nativeMethods.m"), new FileOutputStream(nativeMethods));
File javaIoFileM = new File(srcRoot, "java_io_File.m");
File cn1GlobalsM = new File(srcRoot, "cn1_globals.c");
copy(ByteCodeTranslator.class.getResourceAsStream("/cn1_globals.m"), new FileOutputStream(cn1GlobalsM));
File javaIoFileM = new File(srcRoot, "java_io_File.c");
copy(ByteCodeTranslator.class.getResourceAsStream("/java_io_File.m"), new FileOutputStream(javaIoFileM));
File javaIoFileStreamsM = new File(srcRoot, "java_io_FileStreams.c");
copy(ByteCodeTranslator.class.getResourceAsStream("/java_io_FileStreams.m"), new FileOutputStream(javaIoFileStreamsM));

Parser.writeOutput(srcRoot);

Expand Down Expand Up @@ -303,6 +307,8 @@ private static void handleIosOutput(ByteCodeTranslator b, File[] sources, File d
copy(ByteCodeTranslator.class.getResourceAsStream("/nativeMethods.m"), new FileOutputStream(nativeMethods));
File javaIoFileM = new File(srcRoot, "java_io_File.m");
copy(ByteCodeTranslator.class.getResourceAsStream("/java_io_File.m"), new FileOutputStream(javaIoFileM));
File javaIoFileStreamsM = new File(srcRoot, "java_io_FileStreams.m");
copy(ByteCodeTranslator.class.getResourceAsStream("/java_io_FileStreams.m"), new FileOutputStream(javaIoFileStreamsM));

if (System.getProperty("USE_RPMALLOC", "false").equals("true")) {
File malloc = new File(srcRoot, "malloc.c");
Expand Down
Loading
Loading