forked from svaarala/duktape
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Some problem code used in investigating GH-294. | ||
*/ | ||
|
||
/*=== | ||
blitMask 11 52 123 | ||
done | ||
===*/ | ||
|
||
function Image() { | ||
} | ||
Image.prototype.blitMask = function (x, y, color) { | ||
print('blitMask', x, y, color); | ||
}; | ||
var myImage = new Image(); | ||
|
||
function CreateColor() { return 123; } | ||
|
||
this.spriteset = { | ||
directions: [ { frames: [ { index: 0 } ] } ], | ||
images: [ myImage ], | ||
}; | ||
this.directionID = 0; | ||
this.frameID = 0; | ||
this.xOff = 10; | ||
this.yOff = 50; | ||
|
||
this.blit = function(x, y, alpha) { | ||
alpha = alpha !== void null ? alpha : 255; | ||
|
||
this.spriteset.images[this.spriteset.directions[this.directionID].frames[this.frameID].index] | ||
.blitMask(x + this.xOff, y + this.yOff, CreateColor(255, 255, 255, alpha)); | ||
//print("*munch*"); | ||
}; | ||
|
||
this.blit(1,2,3); | ||
print('done'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Unwind and thr->ptr_curr_pc related bug when developing GH-294. | ||
*/ | ||
|
||
/*=== | ||
returning | ||
obj finalized | ||
returning | ||
obj finalized | ||
done | ||
===*/ | ||
|
||
function finalizer() { | ||
print('obj finalized'); | ||
} | ||
|
||
function func() { | ||
var obj = {}; | ||
Duktape.fin(obj, finalizer); | ||
|
||
print('returning'); | ||
} | ||
|
||
function test() { | ||
/* | ||
* During development of GH-294 there was a bug in thr->ptr_curr_pc | ||
* handling: thr->ptr_curr_pc was not NULLed before a longjmp (it was | ||
* synced though) with the assumption that the unwind path would never | ||
* touch it and it would therefore be harmless. | ||
* | ||
* However, if an unwind side effect (such as a finalizer call) causes | ||
* a function call, the call handling will use thr->ptr_curr_pc to sync | ||
* the current PC, but the topmost activation has changed. This leads | ||
* to the incorrect activation's curr_pc being updated. | ||
*/ | ||
|
||
func(); | ||
func(); | ||
} | ||
|
||
try { | ||
test(); | ||
print('done'); | ||
} catch (e) { | ||
print(e.stack || e); | ||
} |