Skip to content

Commit

Permalink
JIT kind of fixed for Jailed devices
Browse files Browse the repository at this point in the history
WilliamLCobb committed May 2, 2016
1 parent f8e298d commit dd6b6cf
Showing 8 changed files with 47 additions and 55 deletions.
15 changes: 13 additions & 2 deletions desmume/src/ArmLJit.cpp
Original file line number Diff line number Diff line change
@@ -7451,16 +7451,27 @@ inc_t _inc = NULL;
u32 *p;
bool ready;

#define PAGESIZE 4096
uintptr_t * opPtr;

TEMPLATE static u32 cpuExecuteLJIT()
{
ArmOpCompiled opfun = (ArmOpCompiled)JITLUT_HANDLE(ARMPROC.instruct_adr, PROCNUM);
if (!opfun) {
if (opPtr) {
//Reprotect old page
}
opfun = armcpu_compile<PROCNUM>();
if (!opfun)
printf("Unable to compile JIT\n");
}
return opfun();

opPtr = (uintptr_t*)opfun;
opPtr = (uintptr_t *)((uintptr_t)opPtr & 0xFFFFF000); //Assuming page size is 4096
mprotect(opPtr, PAGESIZE* 2, PROT_READ | PROT_EXEC);
u32 cycles = opfun();
mprotect(opPtr, PAGESIZE * 2, PROT_WRITE);
return cycles;
}

static u32 cpuGetCacheReserve()
@@ -7475,7 +7486,7 @@ static void cpuSetCacheReserve(u32 reserveInMegs)

static const char* cpuDescription()
{
return "Arm LJitV3";
return "Arm LJitV4";
}

CpuBase arm_ljit =
Empty file modified desmume/src/GPU.cpp
100755 → 100644
Empty file.
1 change: 0 additions & 1 deletion desmume/src/utils/MemBuffer.cpp
Original file line number Diff line number Diff line change
@@ -144,7 +144,6 @@ u8* MemBuffer::Reserve(u32 size)
m_CommittedSize = 0;

m_Baseptr = (u8*)mmap(NULL, m_ReservedSize, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
//m_Baseptr = (u8*)mmap(NULL, m_ReservedSize, PROT_EXEC | PROT_READ | PROT_WRITE , MAP_PRIVATE | MAP_ANON, -1, 0);
if (m_Baseptr == MAP_FAILED) {
printf("MMAP failed: %u\n", m_ReservedSize);
Release();
6 changes: 4 additions & 2 deletions desmume/src/utils/MemBuffer.h
Original file line number Diff line number Diff line change
@@ -55,17 +55,19 @@ class MemBuffer

int ConvertToLnxApi(int mode);

u8* m_Baseptr;

u32 m_ReservedSize;

protected:
bool Commit(u32 size);

private:
u8* m_Baseptr;

u32 m_Mode;

u32 m_DefSize;

u32 m_ReservedSize;
u32 m_ReservedPages;

u32 m_CommittedSize;
2 changes: 1 addition & 1 deletion iNDS/AppDelegate.m
Original file line number Diff line number Diff line change
@@ -475,7 +475,7 @@ - (WCEasySettingsViewController *)getSettingsViewController
if (sizeof(void*) == 4) {
engineOption = [[WCEasySettingsOption alloc] initWithIdentifier:@"cpuMode"
title:@"Emulator Engine"
options:@[@"Interpretor",
options:@[@"Interpreter",
@"JIT Recompiler (Beta)"
]
optionSubtitles:nil
27 changes: 1 addition & 26 deletions iNDS/Base.lproj/MainStoryboard.storyboard
Original file line number Diff line number Diff line change
@@ -1447,33 +1447,8 @@
</tableViewCellContentView>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</tableViewCell>
<tableViewCell clipsSubviews="YES" alpha="0.80000001192092896" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" textLabel="ViW-Yf-Np4" style="IBUITableViewCellStyleDefault" id="0xk-h6-lAZ">
<rect key="frame" x="0.0" y="352" width="260" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="0xk-h6-lAZ" id="n97-nx-2vR">
<rect key="frame" x="0.0" y="0.0" width="260" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Close Lid" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="ViW-Yf-Np4">
<rect key="frame" x="15" y="0.0" width="230" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" id="L4u-ga-pQq">
<rect key="frame" x="196" y="7" width="51" height="31"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
<connections>
<action selector="setLidClosed:" destination="nCc-cT-pGi" eventType="valueChanged" id="p8O-qZ-phM"/>
</connections>
</switch>
</subviews>
</tableViewCellContentView>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</tableViewCell>
<tableViewCell clipsSubviews="YES" alpha="0.80000000000000004" contentMode="scaleToFill" selectionStyle="none" accessoryType="disclosureIndicator" indentationWidth="10" textLabel="lt9-GU-1uI" style="IBUITableViewCellStyleDefault" id="02l-Qp-XOh">
<rect key="frame" x="0.0" y="396" width="260" height="44"/>
<rect key="frame" x="0.0" y="352" width="260" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="02l-Qp-XOh" id="eAi-hm-iHm">
<rect key="frame" x="0.0" y="0.0" width="227" height="43.5"/>
47 changes: 28 additions & 19 deletions iNDS/iNDSEmulatorViewController.mm
Original file line number Diff line number Diff line change
@@ -565,6 +565,7 @@ - (UIImage*)screenSnapshot:(NSInteger)num

- (void)suspendEmulation
{
[self setLidClosed:YES];
NSLog(@"Suspending");
[self pauseEmulation];
// Shutting down while editing a layout causes a ton of problems.
@@ -662,8 +663,8 @@ - (void)saveStateWithName:(NSString*)saveStateName

- (void)updateDisplay
{
if (texHandle[0] == 0) return;
// Clacl fps
if (texHandle[0] == 0 || !execute) return;
// Calculate fps
static CFTimeInterval lastDisplayTime = 0;
videoFps = videoFps * 0.95 + (1 / (CACurrentMediaTime() - lastDisplayTime)) * 0.05;
lastDisplayTime = CACurrentMediaTime();
@@ -891,25 +892,30 @@ - (IBAction)toggleSettings:(id)sender
{
UIView * statusBar = [self statuBarView];
if (!settingsShown) { //About to show settings
[volumeStealer performSelector:@selector(stopStealingVolumeButtonEvents) withObject:nil afterDelay:0.1]; //Non blocking
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"fullScreenSettings"]) {
[[UIApplication sharedApplication] setStatusBarHidden:NO];
statusBar.alpha = 0;
}
[self.settingsContainer setHidden:NO];
[self pauseEmulation];
[UIView animateWithDuration:0.3 animations:^{
self.darkenView.hidden = NO;
self.darkenView.alpha = 0.6;
self.settingsContainer.alpha = 1;
[self setLidClosed:YES];
// Give time for lid close
//dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[volumeStealer performSelector:@selector(stopStealingVolumeButtonEvents) withObject:nil afterDelay:0.1]; //Non blocking
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"fullScreenSettings"]) {
statusBar.alpha = 1;
[[UIApplication sharedApplication] setStatusBarHidden:NO];
statusBar.alpha = 0;
}
} completion:^(BOOL finished) {
settingsShown = YES;
if (!inEditingMode)
[CHBgDropboxSync start];
}];
[self.settingsContainer setHidden:NO];
[self pauseEmulation];
[UIView animateWithDuration:0.3 animations:^{
self.darkenView.hidden = NO;
self.darkenView.alpha = 0.6;
self.settingsContainer.alpha = 1;
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"fullScreenSettings"]) {
statusBar.alpha = 1;
}
} completion:^(BOOL finished) {
settingsShown = YES;
if (!inEditingMode)
[CHBgDropboxSync start];
}];
//});

} else {
if ([[NSUserDefaults standardUserDefaults] integerForKey:@"volumeBumper"]) {
[volumeStealer performSelector:@selector(startStealingVolumeButtonEvents) withObject:nil afterDelay:0.1];
@@ -927,6 +933,8 @@ - (IBAction)toggleSettings:(id)sender
}];

disableTouchScreen = [[NSUserDefaults standardUserDefaults] boolForKey:@"disableTouchScreen"];

[self setLidClosed:NO];
}

}
@@ -987,6 +995,7 @@ - (void)reloadEmulator
[self toggleSettings:self];
});
[self saveStateWithName:@"iNDSReloadState"];
//[self setLidClosed:NO];
}

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
4 changes: 0 additions & 4 deletions iNDS/iNDSSettingsTableViewController.m
Original file line number Diff line number Diff line change
@@ -119,10 +119,6 @@ - (IBAction)speedChanged:(UISegmentedControl*) control
[emulationController toggleSettings:self];
}

- (IBAction)setLidClosed:(UISwitch *)sender
{
[emulationController setLidClosed:sender.on];
}

#pragma mark - Table view data source

0 comments on commit dd6b6cf

Please sign in to comment.