SlideShare une entreprise Scribd logo
1  sur  43
ALF
Diagramme de flux de
contrôle
Bibliographie pour aujourd'hui
Alfred V. Aho, Monica S. Lam, Ravi Sethi, Jeffrey
D. Ullman, Compilers: Principles, Techniques,
and Tools (2nd Edition)
– Chapitre 8
• 8.1
• 8.4
Contenu
• Web Assembly
• Diagramme de flux de
contrôle
Brendan Eich
• Américain
• University of Illinois at
Urbana-Champaign
• Co-fondateur de
Netscape
• Auteur de JavaScript
Diagramme de flux de contrôle
• Organisation de Three Address Code a
diagramme
• Start
• Stop
• Basic Block
– le flux d'instructions n'est pas interrompu par un saut
– il n'y a pas d'instruction d'étiquette (sauf la première
instruction)
– leader
Selection de leader
• premier instruction
• étiquette
• instruction après un saute (if, ifFalse, goto)
Exemple
var n = 0;
for (var i = 0; i < sqrt(n); i++)
{
if (n % i == 0) n = n + 1;
}
print (n);
Exemple
var n = 0;
for (var i = 0; i < sqrt(n); i++)
{
if (n % i == 0) n = n + 1;
}
print (n);
n = 0
i = 0
label for
param n
n1 = call sqrt, 1
n2 = i < n1
ifFalse e2 goto endfor
n4 = n % i
n5 = n4 == 0
ifFalse n5 goto endif
n = n + 1
label endif
i = i + 1
goto for
label endfor
param n
call print, 1
Exemple
n = 0
i = 0
label for
param n
n1 = call sqrt, 1
n2 = i < n1
ifFalse e2 goto endfor
n4 = n % i
n5 = n4 == 0
ifFalse n5 goto endif
n = n + 1
label endif
i = i + 1
goto for
label endfor
param n
call print, 1
Start
Stop
WebAssembly
• Architecture Harvard
– 32 bits
• Machine de pile infinie
• Mémoire program
• Mémoire données
• AST
S-expressions
(expression param1 param2 …)
(module …)
(module
(import …)
)
Instructions pour valeurs
Instruction Equivalence
i32.const valeur push valeur (32 bits int)
i64.const valeur push valeur (64 bits int)
f32.const valeur push valeur (32 bits float)
f64.const valeur push valeur (64 bits float)
Instructions pour mémoire
Instruction Equivalence
i32.load<dimension>_<sign> push MEM [pop] (32 bits)
i64.load<dimension>_<sign> push MEM [pop] (64 bits)
f32.load<dimension>_<sign> push MEM [pop] (32 bits float)
f64.load<dimension>_<sign> push MEM [pop] (64 bits float)
i32.store<dimension>_<sign> MEM[pop] = pop (32 bits)
i64.store <dimension>_<sign> MEM[pop] = pop (64 bits)
f32.store<dimension>_<sign> MEM[pop] = pop (32 bits float)
f64.store<dimension>_<sign> MEM[pop] = pop (62 bits float)
Instructions de saut
Instruction Equivalence
br $etiquete continue ou break etiquete
br_if $etiquete if (pop) continue ou break etiquete
return valeur push valeur
return
loop $etiquete … end continue
block $etiquete … end break
Instructions arithmétique
Instruction Equivalence
i32.add, i64.add, f32.add, f64.add push pop + pop
i32.sub, i64.sub, f32.sub, f64.sub push pop - pop
i32.mul, i64.mul, f32.mul, f64.mul push pop * pop
i32.div_s, i64.div_s, f32.div_s, f64.div_s push pop / pop (avec signe)
i32.div_u, i64.div_u, f32.div_u, f64.div_u push pop / pop
i32.rem, i64.rem push pop % pop
f32.sqrt, f64.sqrt push sqrt (pop)
push pop + pop
Instructions branche
Instruction Equivalence
if (return type) then … else … end if (){ … push valeur }
else { … push valeur }
Instructions logique
Instruction Equivalence
i32.and, i64.and … push pop AND pop (bit par bit)
i32.or, i64.or … push pop OR pop (bit par bit)
i32.xor, i64.xor … push pop XOR pop (bit par bit)
i32.shl, i64.shl …
(shift left)
push pop << pop (bit par bit)
i32.shr, i64.shr …
(shift right)
push pop >> pop (bit par bit)
i32.gt, i64.gt … push pop > pop (bit par bit)
i32.lt, i64.lt … push pop < pop (bit par bit)
…
Assignement
r = x op y r = op y
op: + - * / %
== <= >= < >
Assignement
• r = x op y
– prend x dans la pile
– prend y dans la pile
– op r x y
• r = x + y
– i32.const &x
– i32.load
– i32.const &y
– i32.load
– i32.add
• r = N op y
– pousser N dans la pile
– prend y dans la pile
– op r x y
• r = 60 + y
– i64.const 60
– i32.const &y
– i64.load
– i64.add
Exercices
• 2+3*5
• (6-2)*4
• 10/x + 2*y
• 3- (-2) *6
• -10/2 – (2+4)/2*(7-(-1))
Exercices (2+3*5)
+
*
3
5
2
i32.const 2
i32.const 3
i32.const 5
i32.mul
i32.add
Exercices (10/x + 2*y)
+
*
2
y
/
10
x
set r1 10
set r2 &x
load r2 r2
div r3 r1 r2
set r1 2
set r2 &y
load r2 r2
mul r4 r1 r2
add r1 r3 r4
Copie
x = y
Copie
• x = y
– prend y dans la pile
– stockez x de la pile
• x = y
– i32.const &y
– i64.load
– i32.const &x
– i64.store
Saut inconditionnel
• goto name
• label name
loop $next
br $next
end $next
x = 2 + 3 ; this is not reached
block $next
br $next
x = 2 + 3 ; this is jumped
end $next
Saut conditionnel
• if x goto name
• ifFalse x goto namefalse
• label name
if f next
x = 2 + 3 ; this is jumped if
f is true
label next
Saut conditionnel
• if x goto name
• ifFalse x goto namefalse
• label name
;; push x
if
…
else
add r1 r2 r3; this is
jumped if x is true
end
Exercises
if (x+y > 3)
{
a = 11;
}
Exemple
if (x+y > 3)
{
a = 11;
}
set r1 &x
load r1 r1
set r2, &y
load r2, r2
add r1, r1, r2
set r3, 3
test r1, r3
jle endif
set r4, 11
set r5, &a
Store r5, r4
endif:
Exercises
if (x+y > 3)
{
a = 11;
}
else
{
a = 12;
}
Exemple
if (x+y > 3)
{
a = 11;
}
else
{
a = 12;
}
set r1, &x
load r1 r1
set r2, &y
load r r2
add r1 r1 r2
set r3 3
test r1 r3
jle else
set r4 11
set r5, &a
store r5, r4
jmp endif
else:
set r4 12
set r5, &a
store r5 r4
endif:
Exercises
if (x+y > 3 && y < x+90)
{
a = 11;
}
else
{
a = 12;
}
Exercises
while (x > 3)
{
x = x + 1;
}
Exercises
do
{
x = x + 1;
} while (x+y > 3 && y < x+90);
Exercises
for (x=1; x + y > 3; x = x + 1)
{
y = y + 7;
}
Appel de fonction
• param parameter
• call f, n
• r = call f, n
p = power (a, n);
i32.const &a
i64.load
i32.const &n
i64.load
call $power
i32.const &p
i64.store
Exercises
void print (int x, int y)
{
printf (x);
}
print (2, 4);
Exercises
void print (int x, int y)
{
printf (x);
}
print (2, 4);
(func $print (param $x
i64) (param $y i64)
get_local $x
call $printf
)
i64.const 2
i64.const 4
call $print
Exercises
int expression (int x, int y, int z)
{
return x*(y+z);
}
expression (1, 2, 5);
Exercises
int expression (int x, int y, int z)
{
return x*(y+z);
}
expression (2+3, a+2*6, f(3));
Sujets
• Web Assembly
– Mémoire
– Instructions
• Three Address Code aWeb Assembly
WebAssembly
• WebAssembly Tutorial
https://developer.mozilla.org/en-
US/docs/WebAssembly/Understanding_the_t
ext_format
• WebAssembly Instructions
https://webassembly.org/docs/semantics/
Questions

Contenu connexe

Tendances

SdE 8 - Synchronisation de execution
SdE 8 - Synchronisation de executionSdE 8 - Synchronisation de execution
SdE 8 - Synchronisation de executionAlexandru Radovici
 
ALF 3 - Expressions régulières et Lexer
ALF 3 - Expressions régulières et LexerALF 3 - Expressions régulières et Lexer
ALF 3 - Expressions régulières et LexerAlexandru Radovici
 
Monitoring d'applications/environnements PHP: APM et Pinba
Monitoring d'applications/environnements PHP: APM et PinbaMonitoring d'applications/environnements PHP: APM et Pinba
Monitoring d'applications/environnements PHP: APM et PinbaPatrick Allaert
 
Annotation Java vs. Decorator Python
Annotation Java vs. Decorator PythonAnnotation Java vs. Decorator Python
Annotation Java vs. Decorator PythonDidier Plaindoux
 
Programmation fonctionnelle
Programmation fonctionnelleProgrammation fonctionnelle
Programmation fonctionnelleGeeks Anonymes
 
Coat::Persistent at FPW2009
Coat::Persistent at FPW2009Coat::Persistent at FPW2009
Coat::Persistent at FPW2009Alexis Sukrieh
 
SdE 8 - Synchronization de execution
SdE 8 - Synchronization de executionSdE 8 - Synchronization de execution
SdE 8 - Synchronization de executionAlexandru Radovici
 
ALF 7 - Arbre de syntaxe abstraite
ALF 7 - Arbre de syntaxe abstraiteALF 7 - Arbre de syntaxe abstraite
ALF 7 - Arbre de syntaxe abstraiteAlexandru Radovici
 
Programming language python 2021
Programming language python 2021Programming language python 2021
Programming language python 2021Dalila Chouaya
 
20080610 04 - Explorations visuelles de programmes
20080610 04 - Explorations visuelles de programmes20080610 04 - Explorations visuelles de programmes
20080610 04 - Explorations visuelles de programmesLeClubQualiteLogicielle
 

Tendances (20)

ALF 9 - Generation de code
ALF 9 - Generation de codeALF 9 - Generation de code
ALF 9 - Generation de code
 
ALF 6 - Parser Bottom-Up
ALF 6 - Parser Bottom-UpALF 6 - Parser Bottom-Up
ALF 6 - Parser Bottom-Up
 
ALF 6 - Parser
ALF 6 - ParserALF 6 - Parser
ALF 6 - Parser
 
ALF 6 - Parser Bottom-Up
ALF 6 - Parser Bottom-UpALF 6 - Parser Bottom-Up
ALF 6 - Parser Bottom-Up
 
ALF 5 - Parser
ALF 5 - ParserALF 5 - Parser
ALF 5 - Parser
 
ALF 1 - Automates finis
ALF 1 - Automates finis ALF 1 - Automates finis
ALF 1 - Automates finis
 
SdE 8 - Synchronisation de execution
SdE 8 - Synchronisation de executionSdE 8 - Synchronisation de execution
SdE 8 - Synchronisation de execution
 
ALF 2 - Automates Fini (2018)
ALF 2 - Automates Fini (2018)ALF 2 - Automates Fini (2018)
ALF 2 - Automates Fini (2018)
 
ALF 4 - Grammaires
ALF 4 - GrammairesALF 4 - Grammaires
ALF 4 - Grammaires
 
ALF 4 - Grammaires
ALF 4 - GrammairesALF 4 - Grammaires
ALF 4 - Grammaires
 
ALF 3 - Expressions régulières et Lexer
ALF 3 - Expressions régulières et LexerALF 3 - Expressions régulières et Lexer
ALF 3 - Expressions régulières et Lexer
 
Monitoring d'applications/environnements PHP: APM et Pinba
Monitoring d'applications/environnements PHP: APM et PinbaMonitoring d'applications/environnements PHP: APM et Pinba
Monitoring d'applications/environnements PHP: APM et Pinba
 
Programmation Fonctionnelle
Programmation FonctionnelleProgrammation Fonctionnelle
Programmation Fonctionnelle
 
Annotation Java vs. Decorator Python
Annotation Java vs. Decorator PythonAnnotation Java vs. Decorator Python
Annotation Java vs. Decorator Python
 
Programmation fonctionnelle
Programmation fonctionnelleProgrammation fonctionnelle
Programmation fonctionnelle
 
Coat::Persistent at FPW2009
Coat::Persistent at FPW2009Coat::Persistent at FPW2009
Coat::Persistent at FPW2009
 
SdE 8 - Synchronization de execution
SdE 8 - Synchronization de executionSdE 8 - Synchronization de execution
SdE 8 - Synchronization de execution
 
ALF 7 - Arbre de syntaxe abstraite
ALF 7 - Arbre de syntaxe abstraiteALF 7 - Arbre de syntaxe abstraite
ALF 7 - Arbre de syntaxe abstraite
 
Programming language python 2021
Programming language python 2021Programming language python 2021
Programming language python 2021
 
20080610 04 - Explorations visuelles de programmes
20080610 04 - Explorations visuelles de programmes20080610 04 - Explorations visuelles de programmes
20080610 04 - Explorations visuelles de programmes
 

Similaire à ALF 11 - WebAssembly

Lambda calcul Devoxx 2021
Lambda calcul Devoxx 2021Lambda calcul Devoxx 2021
Lambda calcul Devoxx 2021YassineMeherzi
 
Cours python avancé
Cours python avancéCours python avancé
Cours python avancépierrepo
 
SdE 2 - Langage C, Allocation de memoire
SdE 2 - Langage C, Allocation de memoireSdE 2 - Langage C, Allocation de memoire
SdE 2 - Langage C, Allocation de memoireAlexandru Radovici
 
TP3: Comportement Temps Réel de l'Agent Perception
TP3: Comportement Temps Réel de l'Agent PerceptionTP3: Comportement Temps Réel de l'Agent Perception
TP3: Comportement Temps Réel de l'Agent PerceptionSaid Benaissa
 
Fork / Join, Parallel Arrays, Lambdas : la programmation parallèle (trop ?) f...
Fork / Join, Parallel Arrays, Lambdas : la programmation parallèle (trop ?) f...Fork / Join, Parallel Arrays, Lambdas : la programmation parallèle (trop ?) f...
Fork / Join, Parallel Arrays, Lambdas : la programmation parallèle (trop ?) f...Normandy JUG
 
Android Optimisations Greendroid
Android Optimisations GreendroidAndroid Optimisations Greendroid
Android Optimisations GreendroidGDG Nantes
 
Lect14 dev2
Lect14 dev2Lect14 dev2
Lect14 dev2moisko
 
Coffee script
Coffee scriptCoffee script
Coffee scriptantho1404
 
Librairies Java qui changent la vie
Librairies Java qui changent la vieLibrairies Java qui changent la vie
Librairies Java qui changent la viecluelessjoe
 
Scala : programmation fonctionnelle
Scala : programmation fonctionnelleScala : programmation fonctionnelle
Scala : programmation fonctionnelleMICHRAFY MUSTAFA
 
La programmation fonctionnelle avec le langage OCaml
La programmation fonctionnelle avec le langage OCamlLa programmation fonctionnelle avec le langage OCaml
La programmation fonctionnelle avec le langage OCamlStéphane Legrand
 
Corrigé langage c
Corrigé langage cCorrigé langage c
Corrigé langage ccoursuniv
 
C1 - Langage C - ISIMA - Première partie
C1 - Langage C - ISIMA - Première partieC1 - Langage C - ISIMA - Première partie
C1 - Langage C - ISIMA - Première partieLoic Yon
 
Corrigés exercices langage C
Corrigés exercices langage CCorrigés exercices langage C
Corrigés exercices langage Ccoursuniv
 
Introduction au Machine Learning - Frédéric Enard, Data Scientist chez TF1 Le...
Introduction au Machine Learning - Frédéric Enard, Data Scientist chez TF1 Le...Introduction au Machine Learning - Frédéric Enard, Data Scientist chez TF1 Le...
Introduction au Machine Learning - Frédéric Enard, Data Scientist chez TF1 Le...Jedha Bootcamp
 

Similaire à ALF 11 - WebAssembly (20)

Mathématiques et Python
Mathématiques et PythonMathématiques et Python
Mathématiques et Python
 
Lambda calcul Devoxx 2021
Lambda calcul Devoxx 2021Lambda calcul Devoxx 2021
Lambda calcul Devoxx 2021
 
Cours python avancé
Cours python avancéCours python avancé
Cours python avancé
 
SdE 2 - Langage C, Allocation de memoire
SdE 2 - Langage C, Allocation de memoireSdE 2 - Langage C, Allocation de memoire
SdE 2 - Langage C, Allocation de memoire
 
TP3: Comportement Temps Réel de l'Agent Perception
TP3: Comportement Temps Réel de l'Agent PerceptionTP3: Comportement Temps Réel de l'Agent Perception
TP3: Comportement Temps Réel de l'Agent Perception
 
Fork / Join, Parallel Arrays, Lambdas : la programmation parallèle (trop ?) f...
Fork / Join, Parallel Arrays, Lambdas : la programmation parallèle (trop ?) f...Fork / Join, Parallel Arrays, Lambdas : la programmation parallèle (trop ?) f...
Fork / Join, Parallel Arrays, Lambdas : la programmation parallèle (trop ?) f...
 
Android Optimisations Greendroid
Android Optimisations GreendroidAndroid Optimisations Greendroid
Android Optimisations Greendroid
 
Ruby STAR
Ruby STARRuby STAR
Ruby STAR
 
Lect14 dev2
Lect14 dev2Lect14 dev2
Lect14 dev2
 
Coffee script
Coffee scriptCoffee script
Coffee script
 
Librairies Java qui changent la vie
Librairies Java qui changent la vieLibrairies Java qui changent la vie
Librairies Java qui changent la vie
 
COURS_PYTHON_22.ppt
COURS_PYTHON_22.pptCOURS_PYTHON_22.ppt
COURS_PYTHON_22.ppt
 
Theme 7
Theme 7Theme 7
Theme 7
 
Scala : programmation fonctionnelle
Scala : programmation fonctionnelleScala : programmation fonctionnelle
Scala : programmation fonctionnelle
 
La programmation fonctionnelle avec le langage OCaml
La programmation fonctionnelle avec le langage OCamlLa programmation fonctionnelle avec le langage OCaml
La programmation fonctionnelle avec le langage OCaml
 
Implementing a key/value store
Implementing a key/value storeImplementing a key/value store
Implementing a key/value store
 
Corrigé langage c
Corrigé langage cCorrigé langage c
Corrigé langage c
 
C1 - Langage C - ISIMA - Première partie
C1 - Langage C - ISIMA - Première partieC1 - Langage C - ISIMA - Première partie
C1 - Langage C - ISIMA - Première partie
 
Corrigés exercices langage C
Corrigés exercices langage CCorrigés exercices langage C
Corrigés exercices langage C
 
Introduction au Machine Learning - Frédéric Enard, Data Scientist chez TF1 Le...
Introduction au Machine Learning - Frédéric Enard, Data Scientist chez TF1 Le...Introduction au Machine Learning - Frédéric Enard, Data Scientist chez TF1 Le...
Introduction au Machine Learning - Frédéric Enard, Data Scientist chez TF1 Le...
 

Plus de Alexandru Radovici (20)

SdE2 - Pilot Tock
SdE2 - Pilot TockSdE2 - Pilot Tock
SdE2 - Pilot Tock
 
SdE2 - Systèmes embarquées
SdE2 - Systèmes embarquéesSdE2 - Systèmes embarquées
SdE2 - Systèmes embarquées
 
SdE2 - Planification, IPC
SdE2 - Planification, IPCSdE2 - Planification, IPC
SdE2 - Planification, IPC
 
ALF1 - Introduction
ALF1 - IntroductionALF1 - Introduction
ALF1 - Introduction
 
SdE2 - Introduction
SdE2 - IntroductionSdE2 - Introduction
SdE2 - Introduction
 
MDAD 6 - AIDL and Services
MDAD 6 - AIDL and ServicesMDAD 6 - AIDL and Services
MDAD 6 - AIDL and Services
 
MDAD 5 - Threads
MDAD 5 - ThreadsMDAD 5 - Threads
MDAD 5 - Threads
 
MDAD 4 - Lists, adapters and recycling
MDAD 4 - Lists, adapters and recyclingMDAD 4 - Lists, adapters and recycling
MDAD 4 - Lists, adapters and recycling
 
MDAD 3 - Basics of UI Applications
MDAD 3 - Basics of UI ApplicationsMDAD 3 - Basics of UI Applications
MDAD 3 - Basics of UI Applications
 
MDAD 2 - Introduction to the Android Framework
MDAD 2 - Introduction to the Android FrameworkMDAD 2 - Introduction to the Android Framework
MDAD 2 - Introduction to the Android Framework
 
MDAD 1 - Hardware
MDAD 1 - HardwareMDAD 1 - Hardware
MDAD 1 - Hardware
 
MDAD 0 - Introduction
MDAD 0 - IntroductionMDAD 0 - Introduction
MDAD 0 - Introduction
 
SdE 11 - Reseau
SdE 11 - ReseauSdE 11 - Reseau
SdE 11 - Reseau
 
SdE 10 - Threads
SdE 10 - ThreadsSdE 10 - Threads
SdE 10 - Threads
 
SdE 8 - Memoire Virtuelle
SdE 8 - Memoire VirtuelleSdE 8 - Memoire Virtuelle
SdE 8 - Memoire Virtuelle
 
SdE 7 - Gestion de la Mémoire
SdE 7 - Gestion de la MémoireSdE 7 - Gestion de la Mémoire
SdE 7 - Gestion de la Mémoire
 
SdE 6 - Planification
SdE 6 - PlanificationSdE 6 - Planification
SdE 6 - Planification
 
SdE 5 - Planification
SdE 5 - PlanificationSdE 5 - Planification
SdE 5 - Planification
 
SdE2 4 - Processus
SdE2 4 - ProcessusSdE2 4 - Processus
SdE2 4 - Processus
 
SdE 3 - System de fichiers
SdE 3 - System de fichiersSdE 3 - System de fichiers
SdE 3 - System de fichiers
 

Dernier

CompLit - Journal of European Literature, Arts and Society - n. 7 - Table of ...
CompLit - Journal of European Literature, Arts and Society - n. 7 - Table of ...CompLit - Journal of European Literature, Arts and Society - n. 7 - Table of ...
CompLit - Journal of European Literature, Arts and Society - n. 7 - Table of ...Universidad Complutense de Madrid
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI DẠY BUỔI 2) - TIẾNG ANH 6, 7 GLOBAL SUCCESS (2...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI DẠY BUỔI 2) - TIẾNG ANH 6, 7 GLOBAL SUCCESS (2...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI DẠY BUỔI 2) - TIẾNG ANH 6, 7 GLOBAL SUCCESS (2...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI DẠY BUỔI 2) - TIẾNG ANH 6, 7 GLOBAL SUCCESS (2...Nguyen Thanh Tu Collection
 
Copie de Engineering Software Marketing Plan by Slidesgo.pptx.pptx
Copie de Engineering Software Marketing Plan by Slidesgo.pptx.pptxCopie de Engineering Software Marketing Plan by Slidesgo.pptx.pptx
Copie de Engineering Software Marketing Plan by Slidesgo.pptx.pptxikospam0
 
Cours Généralités sur les systèmes informatiques
Cours Généralités sur les systèmes informatiquesCours Généralités sur les systèmes informatiques
Cours Généralités sur les systèmes informatiquesMohammedAmineHatoch
 
La mondialisation avantages et inconvénients
La mondialisation avantages et inconvénientsLa mondialisation avantages et inconvénients
La mondialisation avantages et inconvénientsJaouadMhirach
 
Conférence Sommet de la formation 2024 : Développer des compétences pour la m...
Conférence Sommet de la formation 2024 : Développer des compétences pour la m...Conférence Sommet de la formation 2024 : Développer des compétences pour la m...
Conférence Sommet de la formation 2024 : Développer des compétences pour la m...Technologia Formation
 
L'expression du but : fiche et exercices niveau C1 FLE
L'expression du but : fiche et exercices  niveau C1 FLEL'expression du but : fiche et exercices  niveau C1 FLE
L'expression du but : fiche et exercices niveau C1 FLElebaobabbleu
 
Formation qhse - GIASE saqit_105135.pptx
Formation qhse - GIASE saqit_105135.pptxFormation qhse - GIASE saqit_105135.pptx
Formation qhse - GIASE saqit_105135.pptxrajaakiass01
 
Apolonia, Apolonia.pptx Film documentaire
Apolonia, Apolonia.pptx         Film documentaireApolonia, Apolonia.pptx         Film documentaire
Apolonia, Apolonia.pptx Film documentaireTxaruka
 
Bilan énergétique des chambres froides.pdf
Bilan énergétique des chambres froides.pdfBilan énergétique des chambres froides.pdf
Bilan énergétique des chambres froides.pdfAmgdoulHatim
 
L application de la physique classique dans le golf.pptx
L application de la physique classique dans le golf.pptxL application de la physique classique dans le golf.pptx
L application de la physique classique dans le golf.pptxhamzagame
 
les_infections_a_streptocoques.pptkioljhk
les_infections_a_streptocoques.pptkioljhkles_infections_a_streptocoques.pptkioljhk
les_infections_a_streptocoques.pptkioljhkRefRama
 
RAPPORT DE STAGE D'INTERIM DE ATTIJARIWAFA BANK
RAPPORT DE STAGE D'INTERIM DE ATTIJARIWAFA BANKRAPPORT DE STAGE D'INTERIM DE ATTIJARIWAFA BANK
RAPPORT DE STAGE D'INTERIM DE ATTIJARIWAFA BANKNassimaMdh
 
STRATEGIE_D’APPRENTISSAGE flee_DU_FLE.pdf
STRATEGIE_D’APPRENTISSAGE flee_DU_FLE.pdfSTRATEGIE_D’APPRENTISSAGE flee_DU_FLE.pdf
STRATEGIE_D’APPRENTISSAGE flee_DU_FLE.pdfGamal Mansour
 
Formation échiquéenne jwhyCHESS, parallèle avec la planification de projet
Formation échiquéenne jwhyCHESS, parallèle avec la planification de projetFormation échiquéenne jwhyCHESS, parallèle avec la planification de projet
Formation échiquéenne jwhyCHESS, parallèle avec la planification de projetJeanYvesMoine
 
Neuvaine de la Pentecôte avec des textes de saint Jean Eudes
Neuvaine de la Pentecôte avec des textes de saint Jean EudesNeuvaine de la Pentecôte avec des textes de saint Jean Eudes
Neuvaine de la Pentecôte avec des textes de saint Jean EudesUnidad de Espiritualidad Eudista
 
658708519-Power-Point-Management-Interculturel.pdf
658708519-Power-Point-Management-Interculturel.pdf658708519-Power-Point-Management-Interculturel.pdf
658708519-Power-Point-Management-Interculturel.pdfMariaClaraAlves46
 
Télécommunication et transport .pdfcours
Télécommunication et transport .pdfcoursTélécommunication et transport .pdfcours
Télécommunication et transport .pdfcourshalima98ahlmohamed
 
Les roches magmatique géodynamique interne.pptx
Les roches magmatique géodynamique interne.pptxLes roches magmatique géodynamique interne.pptx
Les roches magmatique géodynamique interne.pptxShinyaHilalYamanaka
 

Dernier (20)

CompLit - Journal of European Literature, Arts and Society - n. 7 - Table of ...
CompLit - Journal of European Literature, Arts and Society - n. 7 - Table of ...CompLit - Journal of European Literature, Arts and Society - n. 7 - Table of ...
CompLit - Journal of European Literature, Arts and Society - n. 7 - Table of ...
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI DẠY BUỔI 2) - TIẾNG ANH 6, 7 GLOBAL SUCCESS (2...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI DẠY BUỔI 2) - TIẾNG ANH 6, 7 GLOBAL SUCCESS (2...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI DẠY BUỔI 2) - TIẾNG ANH 6, 7 GLOBAL SUCCESS (2...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI DẠY BUỔI 2) - TIẾNG ANH 6, 7 GLOBAL SUCCESS (2...
 
Copie de Engineering Software Marketing Plan by Slidesgo.pptx.pptx
Copie de Engineering Software Marketing Plan by Slidesgo.pptx.pptxCopie de Engineering Software Marketing Plan by Slidesgo.pptx.pptx
Copie de Engineering Software Marketing Plan by Slidesgo.pptx.pptx
 
Cours Généralités sur les systèmes informatiques
Cours Généralités sur les systèmes informatiquesCours Généralités sur les systèmes informatiques
Cours Généralités sur les systèmes informatiques
 
La mondialisation avantages et inconvénients
La mondialisation avantages et inconvénientsLa mondialisation avantages et inconvénients
La mondialisation avantages et inconvénients
 
Conférence Sommet de la formation 2024 : Développer des compétences pour la m...
Conférence Sommet de la formation 2024 : Développer des compétences pour la m...Conférence Sommet de la formation 2024 : Développer des compétences pour la m...
Conférence Sommet de la formation 2024 : Développer des compétences pour la m...
 
L'expression du but : fiche et exercices niveau C1 FLE
L'expression du but : fiche et exercices  niveau C1 FLEL'expression du but : fiche et exercices  niveau C1 FLE
L'expression du but : fiche et exercices niveau C1 FLE
 
Formation qhse - GIASE saqit_105135.pptx
Formation qhse - GIASE saqit_105135.pptxFormation qhse - GIASE saqit_105135.pptx
Formation qhse - GIASE saqit_105135.pptx
 
Apolonia, Apolonia.pptx Film documentaire
Apolonia, Apolonia.pptx         Film documentaireApolonia, Apolonia.pptx         Film documentaire
Apolonia, Apolonia.pptx Film documentaire
 
Bilan énergétique des chambres froides.pdf
Bilan énergétique des chambres froides.pdfBilan énergétique des chambres froides.pdf
Bilan énergétique des chambres froides.pdf
 
L application de la physique classique dans le golf.pptx
L application de la physique classique dans le golf.pptxL application de la physique classique dans le golf.pptx
L application de la physique classique dans le golf.pptx
 
les_infections_a_streptocoques.pptkioljhk
les_infections_a_streptocoques.pptkioljhkles_infections_a_streptocoques.pptkioljhk
les_infections_a_streptocoques.pptkioljhk
 
RAPPORT DE STAGE D'INTERIM DE ATTIJARIWAFA BANK
RAPPORT DE STAGE D'INTERIM DE ATTIJARIWAFA BANKRAPPORT DE STAGE D'INTERIM DE ATTIJARIWAFA BANK
RAPPORT DE STAGE D'INTERIM DE ATTIJARIWAFA BANK
 
STRATEGIE_D’APPRENTISSAGE flee_DU_FLE.pdf
STRATEGIE_D’APPRENTISSAGE flee_DU_FLE.pdfSTRATEGIE_D’APPRENTISSAGE flee_DU_FLE.pdf
STRATEGIE_D’APPRENTISSAGE flee_DU_FLE.pdf
 
Formation échiquéenne jwhyCHESS, parallèle avec la planification de projet
Formation échiquéenne jwhyCHESS, parallèle avec la planification de projetFormation échiquéenne jwhyCHESS, parallèle avec la planification de projet
Formation échiquéenne jwhyCHESS, parallèle avec la planification de projet
 
Neuvaine de la Pentecôte avec des textes de saint Jean Eudes
Neuvaine de la Pentecôte avec des textes de saint Jean EudesNeuvaine de la Pentecôte avec des textes de saint Jean Eudes
Neuvaine de la Pentecôte avec des textes de saint Jean Eudes
 
Echos libraries Burkina Faso newsletter 2024
Echos libraries Burkina Faso newsletter 2024Echos libraries Burkina Faso newsletter 2024
Echos libraries Burkina Faso newsletter 2024
 
658708519-Power-Point-Management-Interculturel.pdf
658708519-Power-Point-Management-Interculturel.pdf658708519-Power-Point-Management-Interculturel.pdf
658708519-Power-Point-Management-Interculturel.pdf
 
Télécommunication et transport .pdfcours
Télécommunication et transport .pdfcoursTélécommunication et transport .pdfcours
Télécommunication et transport .pdfcours
 
Les roches magmatique géodynamique interne.pptx
Les roches magmatique géodynamique interne.pptxLes roches magmatique géodynamique interne.pptx
Les roches magmatique géodynamique interne.pptx
 

ALF 11 - WebAssembly

  • 1. ALF Diagramme de flux de contrôle
  • 2. Bibliographie pour aujourd'hui Alfred V. Aho, Monica S. Lam, Ravi Sethi, Jeffrey D. Ullman, Compilers: Principles, Techniques, and Tools (2nd Edition) – Chapitre 8 • 8.1 • 8.4
  • 3. Contenu • Web Assembly • Diagramme de flux de contrôle
  • 4. Brendan Eich • Américain • University of Illinois at Urbana-Champaign • Co-fondateur de Netscape • Auteur de JavaScript
  • 5. Diagramme de flux de contrôle • Organisation de Three Address Code a diagramme • Start • Stop • Basic Block – le flux d'instructions n'est pas interrompu par un saut – il n'y a pas d'instruction d'étiquette (sauf la première instruction) – leader
  • 6. Selection de leader • premier instruction • étiquette • instruction après un saute (if, ifFalse, goto)
  • 7. Exemple var n = 0; for (var i = 0; i < sqrt(n); i++) { if (n % i == 0) n = n + 1; } print (n);
  • 8. Exemple var n = 0; for (var i = 0; i < sqrt(n); i++) { if (n % i == 0) n = n + 1; } print (n); n = 0 i = 0 label for param n n1 = call sqrt, 1 n2 = i < n1 ifFalse e2 goto endfor n4 = n % i n5 = n4 == 0 ifFalse n5 goto endif n = n + 1 label endif i = i + 1 goto for label endfor param n call print, 1
  • 9. Exemple n = 0 i = 0 label for param n n1 = call sqrt, 1 n2 = i < n1 ifFalse e2 goto endfor n4 = n % i n5 = n4 == 0 ifFalse n5 goto endif n = n + 1 label endif i = i + 1 goto for label endfor param n call print, 1 Start Stop
  • 10. WebAssembly • Architecture Harvard – 32 bits • Machine de pile infinie • Mémoire program • Mémoire données • AST
  • 11. S-expressions (expression param1 param2 …) (module …) (module (import …) )
  • 12. Instructions pour valeurs Instruction Equivalence i32.const valeur push valeur (32 bits int) i64.const valeur push valeur (64 bits int) f32.const valeur push valeur (32 bits float) f64.const valeur push valeur (64 bits float)
  • 13. Instructions pour mémoire Instruction Equivalence i32.load<dimension>_<sign> push MEM [pop] (32 bits) i64.load<dimension>_<sign> push MEM [pop] (64 bits) f32.load<dimension>_<sign> push MEM [pop] (32 bits float) f64.load<dimension>_<sign> push MEM [pop] (64 bits float) i32.store<dimension>_<sign> MEM[pop] = pop (32 bits) i64.store <dimension>_<sign> MEM[pop] = pop (64 bits) f32.store<dimension>_<sign> MEM[pop] = pop (32 bits float) f64.store<dimension>_<sign> MEM[pop] = pop (62 bits float)
  • 14. Instructions de saut Instruction Equivalence br $etiquete continue ou break etiquete br_if $etiquete if (pop) continue ou break etiquete return valeur push valeur return loop $etiquete … end continue block $etiquete … end break
  • 15. Instructions arithmétique Instruction Equivalence i32.add, i64.add, f32.add, f64.add push pop + pop i32.sub, i64.sub, f32.sub, f64.sub push pop - pop i32.mul, i64.mul, f32.mul, f64.mul push pop * pop i32.div_s, i64.div_s, f32.div_s, f64.div_s push pop / pop (avec signe) i32.div_u, i64.div_u, f32.div_u, f64.div_u push pop / pop i32.rem, i64.rem push pop % pop f32.sqrt, f64.sqrt push sqrt (pop) push pop + pop
  • 16. Instructions branche Instruction Equivalence if (return type) then … else … end if (){ … push valeur } else { … push valeur }
  • 17. Instructions logique Instruction Equivalence i32.and, i64.and … push pop AND pop (bit par bit) i32.or, i64.or … push pop OR pop (bit par bit) i32.xor, i64.xor … push pop XOR pop (bit par bit) i32.shl, i64.shl … (shift left) push pop << pop (bit par bit) i32.shr, i64.shr … (shift right) push pop >> pop (bit par bit) i32.gt, i64.gt … push pop > pop (bit par bit) i32.lt, i64.lt … push pop < pop (bit par bit) …
  • 18. Assignement r = x op y r = op y op: + - * / % == <= >= < >
  • 19. Assignement • r = x op y – prend x dans la pile – prend y dans la pile – op r x y • r = x + y – i32.const &x – i32.load – i32.const &y – i32.load – i32.add • r = N op y – pousser N dans la pile – prend y dans la pile – op r x y • r = 60 + y – i64.const 60 – i32.const &y – i64.load – i64.add
  • 20. Exercices • 2+3*5 • (6-2)*4 • 10/x + 2*y • 3- (-2) *6 • -10/2 – (2+4)/2*(7-(-1))
  • 21. Exercices (2+3*5) + * 3 5 2 i32.const 2 i32.const 3 i32.const 5 i32.mul i32.add
  • 22. Exercices (10/x + 2*y) + * 2 y / 10 x set r1 10 set r2 &x load r2 r2 div r3 r1 r2 set r1 2 set r2 &y load r2 r2 mul r4 r1 r2 add r1 r3 r4
  • 24. Copie • x = y – prend y dans la pile – stockez x de la pile • x = y – i32.const &y – i64.load – i32.const &x – i64.store
  • 25. Saut inconditionnel • goto name • label name loop $next br $next end $next x = 2 + 3 ; this is not reached block $next br $next x = 2 + 3 ; this is jumped end $next
  • 26. Saut conditionnel • if x goto name • ifFalse x goto namefalse • label name if f next x = 2 + 3 ; this is jumped if f is true label next
  • 27. Saut conditionnel • if x goto name • ifFalse x goto namefalse • label name ;; push x if … else add r1 r2 r3; this is jumped if x is true end
  • 28. Exercises if (x+y > 3) { a = 11; }
  • 29. Exemple if (x+y > 3) { a = 11; } set r1 &x load r1 r1 set r2, &y load r2, r2 add r1, r1, r2 set r3, 3 test r1, r3 jle endif set r4, 11 set r5, &a Store r5, r4 endif:
  • 30. Exercises if (x+y > 3) { a = 11; } else { a = 12; }
  • 31. Exemple if (x+y > 3) { a = 11; } else { a = 12; } set r1, &x load r1 r1 set r2, &y load r r2 add r1 r1 r2 set r3 3 test r1 r3 jle else set r4 11 set r5, &a store r5, r4 jmp endif else: set r4 12 set r5, &a store r5 r4 endif:
  • 32. Exercises if (x+y > 3 && y < x+90) { a = 11; } else { a = 12; }
  • 33. Exercises while (x > 3) { x = x + 1; }
  • 34. Exercises do { x = x + 1; } while (x+y > 3 && y < x+90);
  • 35. Exercises for (x=1; x + y > 3; x = x + 1) { y = y + 7; }
  • 36. Appel de fonction • param parameter • call f, n • r = call f, n p = power (a, n); i32.const &a i64.load i32.const &n i64.load call $power i32.const &p i64.store
  • 37. Exercises void print (int x, int y) { printf (x); } print (2, 4);
  • 38. Exercises void print (int x, int y) { printf (x); } print (2, 4); (func $print (param $x i64) (param $y i64) get_local $x call $printf ) i64.const 2 i64.const 4 call $print
  • 39. Exercises int expression (int x, int y, int z) { return x*(y+z); } expression (1, 2, 5);
  • 40. Exercises int expression (int x, int y, int z) { return x*(y+z); } expression (2+3, a+2*6, f(3));
  • 41. Sujets • Web Assembly – Mémoire – Instructions • Three Address Code aWeb Assembly