SlideShare a Scribd company logo
1 of 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

More Related Content

What's hot

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
 

What's hot (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
 

Similar to 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
 

Similar to 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...
 

More from 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
 

Recently uploaded

Bibdoc 2024 - Ecologie du livre et creation de badge.pdf
Bibdoc 2024 - Ecologie du livre et creation de badge.pdfBibdoc 2024 - Ecologie du livre et creation de badge.pdf
Bibdoc 2024 - Ecologie du livre et creation de badge.pdfBibdoc 37
 
SciencesPo_Aix_InnovationPédagogique_Atelier_IA.pdf
SciencesPo_Aix_InnovationPédagogique_Atelier_IA.pdfSciencesPo_Aix_InnovationPédagogique_Atelier_IA.pdf
SciencesPo_Aix_InnovationPédagogique_Atelier_IA.pdfSKennel
 
Cours SE Gestion des périphériques - IG IPSET
Cours SE Gestion des périphériques - IG IPSETCours SE Gestion des périphériques - IG IPSET
Cours SE Gestion des périphériques - IG IPSETMedBechir
 
SciencesPo_Aix_InnovationPédagogique_Bilan.pdf
SciencesPo_Aix_InnovationPédagogique_Bilan.pdfSciencesPo_Aix_InnovationPédagogique_Bilan.pdf
SciencesPo_Aix_InnovationPédagogique_Bilan.pdfSKennel
 
SciencesPo_Aix_InnovationPédagogique_Conférence_SK.pdf
SciencesPo_Aix_InnovationPédagogique_Conférence_SK.pdfSciencesPo_Aix_InnovationPédagogique_Conférence_SK.pdf
SciencesPo_Aix_InnovationPédagogique_Conférence_SK.pdfSKennel
 
Bernard Réquichot.pptx Peintre français
Bernard Réquichot.pptx   Peintre françaisBernard Réquichot.pptx   Peintre français
Bernard Réquichot.pptx Peintre françaisTxaruka
 
Cours SE Le système Linux : La ligne de commande bash - IG IPSET
Cours SE Le système Linux : La ligne de commande bash - IG IPSETCours SE Le système Linux : La ligne de commande bash - IG IPSET
Cours SE Le système Linux : La ligne de commande bash - IG IPSETMedBechir
 
Le Lean sur une ligne de production : Formation et mise en application directe
Le Lean sur une ligne de production : Formation et mise en application directeLe Lean sur une ligne de production : Formation et mise en application directe
Le Lean sur une ligne de production : Formation et mise en application directeXL Groupe
 
SciencesPo_Aix_InnovationPédagogique_Atelier_FormationRecherche.pdf
SciencesPo_Aix_InnovationPédagogique_Atelier_FormationRecherche.pdfSciencesPo_Aix_InnovationPédagogique_Atelier_FormationRecherche.pdf
SciencesPo_Aix_InnovationPédagogique_Atelier_FormationRecherche.pdfSKennel
 
PIE-A2-P 5- Supports stagiaires.pptx.pdf
PIE-A2-P 5- Supports stagiaires.pptx.pdfPIE-A2-P 5- Supports stagiaires.pptx.pdf
PIE-A2-P 5- Supports stagiaires.pptx.pdfRiDaHAziz
 
LA MONTÉE DE L'ÉDUCATION DANS LE MONDE DE LA PRÉHISTOIRE À L'ÈRE CONTEMPORAIN...
LA MONTÉE DE L'ÉDUCATION DANS LE MONDE DE LA PRÉHISTOIRE À L'ÈRE CONTEMPORAIN...LA MONTÉE DE L'ÉDUCATION DANS LE MONDE DE LA PRÉHISTOIRE À L'ÈRE CONTEMPORAIN...
LA MONTÉE DE L'ÉDUCATION DANS LE MONDE DE LA PRÉHISTOIRE À L'ÈRE CONTEMPORAIN...Faga1939
 
Principe de fonctionnement d'un moteur 4 temps
Principe de fonctionnement d'un moteur 4 tempsPrincipe de fonctionnement d'un moteur 4 temps
Principe de fonctionnement d'un moteur 4 tempsRajiAbdelghani
 
Bibdoc 2024 - Les maillons de la chaine du livre face aux enjeux écologiques.pdf
Bibdoc 2024 - Les maillons de la chaine du livre face aux enjeux écologiques.pdfBibdoc 2024 - Les maillons de la chaine du livre face aux enjeux écologiques.pdf
Bibdoc 2024 - Les maillons de la chaine du livre face aux enjeux écologiques.pdfBibdoc 37
 
Presentation de la plateforme Moodle - avril 2024
Presentation de la plateforme Moodle - avril 2024Presentation de la plateforme Moodle - avril 2024
Presentation de la plateforme Moodle - avril 2024Gilles Le Page
 
SciencesPo_Aix_InnovationPédagogique_Atelier_EtudiantActeur.pdf
SciencesPo_Aix_InnovationPédagogique_Atelier_EtudiantActeur.pdfSciencesPo_Aix_InnovationPédagogique_Atelier_EtudiantActeur.pdf
SciencesPo_Aix_InnovationPédagogique_Atelier_EtudiantActeur.pdfSKennel
 
Zotero avancé - support de formation doctorants SHS 2024
Zotero avancé - support de formation doctorants SHS 2024Zotero avancé - support de formation doctorants SHS 2024
Zotero avancé - support de formation doctorants SHS 2024Alain Marois
 
PIE-A2-P4-support stagiaires sept 22-validé.pdf
PIE-A2-P4-support stagiaires sept 22-validé.pdfPIE-A2-P4-support stagiaires sept 22-validé.pdf
PIE-A2-P4-support stagiaires sept 22-validé.pdfRiDaHAziz
 
Annie Ernaux Extérieurs. pptx. Exposition basée sur un livre .
Annie   Ernaux  Extérieurs. pptx. Exposition basée sur un livre .Annie   Ernaux  Extérieurs. pptx. Exposition basée sur un livre .
Annie Ernaux Extérieurs. pptx. Exposition basée sur un livre .Txaruka
 

Recently uploaded (19)

Bibdoc 2024 - Ecologie du livre et creation de badge.pdf
Bibdoc 2024 - Ecologie du livre et creation de badge.pdfBibdoc 2024 - Ecologie du livre et creation de badge.pdf
Bibdoc 2024 - Ecologie du livre et creation de badge.pdf
 
SciencesPo_Aix_InnovationPédagogique_Atelier_IA.pdf
SciencesPo_Aix_InnovationPédagogique_Atelier_IA.pdfSciencesPo_Aix_InnovationPédagogique_Atelier_IA.pdf
SciencesPo_Aix_InnovationPédagogique_Atelier_IA.pdf
 
DO PALÁCIO À ASSEMBLEIA .
DO PALÁCIO À ASSEMBLEIA                 .DO PALÁCIO À ASSEMBLEIA                 .
DO PALÁCIO À ASSEMBLEIA .
 
Cours SE Gestion des périphériques - IG IPSET
Cours SE Gestion des périphériques - IG IPSETCours SE Gestion des périphériques - IG IPSET
Cours SE Gestion des périphériques - IG IPSET
 
SciencesPo_Aix_InnovationPédagogique_Bilan.pdf
SciencesPo_Aix_InnovationPédagogique_Bilan.pdfSciencesPo_Aix_InnovationPédagogique_Bilan.pdf
SciencesPo_Aix_InnovationPédagogique_Bilan.pdf
 
SciencesPo_Aix_InnovationPédagogique_Conférence_SK.pdf
SciencesPo_Aix_InnovationPédagogique_Conférence_SK.pdfSciencesPo_Aix_InnovationPédagogique_Conférence_SK.pdf
SciencesPo_Aix_InnovationPédagogique_Conférence_SK.pdf
 
Bernard Réquichot.pptx Peintre français
Bernard Réquichot.pptx   Peintre françaisBernard Réquichot.pptx   Peintre français
Bernard Réquichot.pptx Peintre français
 
Cours SE Le système Linux : La ligne de commande bash - IG IPSET
Cours SE Le système Linux : La ligne de commande bash - IG IPSETCours SE Le système Linux : La ligne de commande bash - IG IPSET
Cours SE Le système Linux : La ligne de commande bash - IG IPSET
 
Le Lean sur une ligne de production : Formation et mise en application directe
Le Lean sur une ligne de production : Formation et mise en application directeLe Lean sur une ligne de production : Formation et mise en application directe
Le Lean sur une ligne de production : Formation et mise en application directe
 
SciencesPo_Aix_InnovationPédagogique_Atelier_FormationRecherche.pdf
SciencesPo_Aix_InnovationPédagogique_Atelier_FormationRecherche.pdfSciencesPo_Aix_InnovationPédagogique_Atelier_FormationRecherche.pdf
SciencesPo_Aix_InnovationPédagogique_Atelier_FormationRecherche.pdf
 
PIE-A2-P 5- Supports stagiaires.pptx.pdf
PIE-A2-P 5- Supports stagiaires.pptx.pdfPIE-A2-P 5- Supports stagiaires.pptx.pdf
PIE-A2-P 5- Supports stagiaires.pptx.pdf
 
LA MONTÉE DE L'ÉDUCATION DANS LE MONDE DE LA PRÉHISTOIRE À L'ÈRE CONTEMPORAIN...
LA MONTÉE DE L'ÉDUCATION DANS LE MONDE DE LA PRÉHISTOIRE À L'ÈRE CONTEMPORAIN...LA MONTÉE DE L'ÉDUCATION DANS LE MONDE DE LA PRÉHISTOIRE À L'ÈRE CONTEMPORAIN...
LA MONTÉE DE L'ÉDUCATION DANS LE MONDE DE LA PRÉHISTOIRE À L'ÈRE CONTEMPORAIN...
 
Principe de fonctionnement d'un moteur 4 temps
Principe de fonctionnement d'un moteur 4 tempsPrincipe de fonctionnement d'un moteur 4 temps
Principe de fonctionnement d'un moteur 4 temps
 
Bibdoc 2024 - Les maillons de la chaine du livre face aux enjeux écologiques.pdf
Bibdoc 2024 - Les maillons de la chaine du livre face aux enjeux écologiques.pdfBibdoc 2024 - Les maillons de la chaine du livre face aux enjeux écologiques.pdf
Bibdoc 2024 - Les maillons de la chaine du livre face aux enjeux écologiques.pdf
 
Presentation de la plateforme Moodle - avril 2024
Presentation de la plateforme Moodle - avril 2024Presentation de la plateforme Moodle - avril 2024
Presentation de la plateforme Moodle - avril 2024
 
SciencesPo_Aix_InnovationPédagogique_Atelier_EtudiantActeur.pdf
SciencesPo_Aix_InnovationPédagogique_Atelier_EtudiantActeur.pdfSciencesPo_Aix_InnovationPédagogique_Atelier_EtudiantActeur.pdf
SciencesPo_Aix_InnovationPédagogique_Atelier_EtudiantActeur.pdf
 
Zotero avancé - support de formation doctorants SHS 2024
Zotero avancé - support de formation doctorants SHS 2024Zotero avancé - support de formation doctorants SHS 2024
Zotero avancé - support de formation doctorants SHS 2024
 
PIE-A2-P4-support stagiaires sept 22-validé.pdf
PIE-A2-P4-support stagiaires sept 22-validé.pdfPIE-A2-P4-support stagiaires sept 22-validé.pdf
PIE-A2-P4-support stagiaires sept 22-validé.pdf
 
Annie Ernaux Extérieurs. pptx. Exposition basée sur un livre .
Annie   Ernaux  Extérieurs. pptx. Exposition basée sur un livre .Annie   Ernaux  Extérieurs. pptx. Exposition basée sur un livre .
Annie Ernaux Extérieurs. pptx. Exposition basée sur un livre .
 

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