extending operational semantics of the java bytecode · pdf filehorizontal framework...

41
Extending Operational Semantics of the Java Bytecode Patryk Czarnik Aleksy Schubert Institute of Informatics Warsaw University Trustworthy Global Computing 2007

Upload: phamduong

Post on 11-Feb-2018

225 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Extending Operational Semantics of the Java Bytecode · PDF fileHorizontal Framework Realisation Horizontal Framework Realisation Bicolano State.t= heap * frame_stack step: Program->

Extending Operational Semanticsof the Java Bytecode

Patryk Czarnik Aleksy Schubert

Institute of InformaticsWarsaw University

Trustworthy Global Computing 2007

Page 2: Extending Operational Semantics of the Java Bytecode · PDF fileHorizontal Framework Realisation Horizontal Framework Realisation Bicolano State.t= heap * frame_stack step: Program->

Introduction Idea

Extending a Semantics

Existing formalisationonly basic properties

New formalisationbasic properties formalisationreusedadditional details specified

change of behaviour

P. Czarnik, A. Schubert (Warsaw Univ.) Extending Op. Sem. of the Java Bytecode TGC 2007 2 / 24

Page 3: Extending Operational Semantics of the Java Bytecode · PDF fileHorizontal Framework Realisation Horizontal Framework Realisation Bicolano State.t= heap * frame_stack step: Program->

Introduction Idea

Extending a Semantics

Existing formalisationonly basic properties

New formalisationbasic properties formalisationreusedadditional details specifiedchange of behaviour

P. Czarnik, A. Schubert (Warsaw Univ.) Extending Op. Sem. of the Java Bytecode TGC 2007 2 / 24

Page 4: Extending Operational Semantics of the Java Bytecode · PDF fileHorizontal Framework Realisation Horizontal Framework Realisation Bicolano State.t= heap * frame_stack step: Program->

Introduction Idea

Example: JVM, Heap Memory Size

New information to track: heap memory sizenew or newarray JVM instruction: size increasedMemory size exceeded: OutOfMemoryError

P. Czarnik, A. Schubert (Warsaw Univ.) Extending Op. Sem. of the Java Bytecode TGC 2007 3 / 24

Page 5: Extending Operational Semantics of the Java Bytecode · PDF fileHorizontal Framework Realisation Horizontal Framework Realisation Bicolano State.t= heap * frame_stack step: Program->

Introduction Background

Background

Mobius – Mobility, Ubiquity and Security:EU 6th Framework Programenabling proof-carrying code for Java on mobile devices

Coq proof assistant:strong logic base (Calculus of Inductive Constructions)module system

Bicolano [Pichardie 2006]:basic JVM formalisation for Mobiuslarge set of instructions (CLDC)modularly implemented in Coq (11.500 lines of code)

P. Czarnik, A. Schubert (Warsaw Univ.) Extending Op. Sem. of the Java Bytecode TGC 2007 4 / 24

Page 6: Extending Operational Semantics of the Java Bytecode · PDF fileHorizontal Framework Realisation Horizontal Framework Realisation Bicolano State.t= heap * frame_stack step: Program->

Introduction Background

Limitations of Original Bicolano

Idealised in various ways:unlimited resourcessingle-threadedno non-deterministic JVM errors

No support for extending state with additional data

Why not just modify Bicolano?The choice of additional features depends on application.

P. Czarnik, A. Schubert (Warsaw Univ.) Extending Op. Sem. of the Java Bytecode TGC 2007 5 / 24

Page 7: Extending Operational Semantics of the Java Bytecode · PDF fileHorizontal Framework Realisation Horizontal Framework Realisation Bicolano State.t= heap * frame_stack step: Program->

Introduction Background

Motivation for Extensions

JVM and system resources:heap memory sizecall stack sizenetwork transferpaid services (SMS etc) . . .

Logic:program tracesghost variables

Non-determinism:multi-threadingnon-deterministic JVM errors

P. Czarnik, A. Schubert (Warsaw Univ.) Extending Op. Sem. of the Java Bytecode TGC 2007 6 / 24

Page 8: Extending Operational Semantics of the Java Bytecode · PDF fileHorizontal Framework Realisation Horizontal Framework Realisation Bicolano State.t= heap * frame_stack step: Program->

Introduction Our Work

Our Work

General frameworks for extending semantics:horizontal (HF)vertical (VF)

Module-based implementation in Coq:flexibleno changes in original Bicolano code

Extension examples:empty extension :)executed instructions counterheap memory sizecall stack sizeembedding of HF within VF

P. Czarnik, A. Schubert (Warsaw Univ.) Extending Op. Sem. of the Java Bytecode TGC 2007 7 / 24

Page 9: Extending Operational Semantics of the Java Bytecode · PDF fileHorizontal Framework Realisation Horizontal Framework Realisation Bicolano State.t= heap * frame_stack step: Program->

Horizontal Framework

P. Czarnik, A. Schubert (Warsaw Univ.) Extending Op. Sem. of the Java Bytecode TGC 2007 8 / 24

Page 10: Extending Operational Semantics of the Java Bytecode · PDF fileHorizontal Framework Realisation Horizontal Framework Realisation Bicolano State.t= heap * frame_stack step: Program->

Horizontal Framework Idea

Horizontal Framework

IdeaObservation of program runsAdditional information collectedNo change in behaviour

P. Czarnik, A. Schubert (Warsaw Univ.) Extending Op. Sem. of the Java Bytecode TGC 2007 9 / 24

Page 11: Extending Operational Semantics of the Java Bytecode · PDF fileHorizontal Framework Realisation Horizontal Framework Realisation Bicolano State.t= heap * frame_stack step: Program->

Horizontal Framework Realisation

Writing Extension in Horizontal Framework

Implementation of extension module:ACT: Type

action traceextended part of state

bookkeep: Program -> State.t -> State.t-> ACT -> ACT

how ACT is changed in a step

bookkeep input:Bicolano state before stepBicolano state after stepACT before step

bookkeep output:ACT after step

P. Czarnik, A. Schubert (Warsaw Univ.) Extending Op. Sem. of the Java Bytecode TGC 2007 10 / 24

Page 12: Extending Operational Semantics of the Java Bytecode · PDF fileHorizontal Framework Realisation Horizontal Framework Realisation Bicolano State.t= heap * frame_stack step: Program->

Horizontal Framework Realisation

Horizontal Framework Realisation

BicolanoState.t = heap * frame_stack

step : Program-> State.t -> State.t -> Prop

ExtensionACT: Type

bookkeep:Program -> State.t-> State.t -> ACT -> ACT

Extended semanticsExtState.t = State.t * ACT

Inductive ext_step : Program -> ExtState.t -> ExtState.t -> Prop :=ESS_step: forall ...,step p s t ->T = bookkeep p s t S ->ext_step p (s,S) (t,T)

P. Czarnik, A. Schubert (Warsaw Univ.) Extending Op. Sem. of the Java Bytecode TGC 2007 11 / 24

Page 13: Extending Operational Semantics of the Java Bytecode · PDF fileHorizontal Framework Realisation Horizontal Framework Realisation Bicolano State.t= heap * frame_stack step: Program->

Horizontal Framework Realisation

Horizontal Framework Realisation

BicolanoState.t = heap * frame_stack

step : Program-> State.t -> State.t -> Prop

ExtensionACT: Type

bookkeep:Program -> State.t-> State.t -> ACT -> ACT

Extended semanticsExtState.t = State.t * ACT

Inductive ext_step : Program -> ExtState.t -> ExtState.t -> Prop :=ESS_step: forall ...,step p s t ->T = bookkeep p s t S ->ext_step p (s,S) (t,T)

P. Czarnik, A. Schubert (Warsaw Univ.) Extending Op. Sem. of the Java Bytecode TGC 2007 11 / 24

Page 14: Extending Operational Semantics of the Java Bytecode · PDF fileHorizontal Framework Realisation Horizontal Framework Realisation Bicolano State.t= heap * frame_stack step: Program->

Horizontal Framework Realisation

Horizontal Framework Realisation

BicolanoState.t = heap * frame_stack

step : Program-> State.t -> State.t -> Prop

ExtensionACT: Type

bookkeep:Program -> State.t-> State.t -> ACT -> ACT

Extended semanticsExtState.t = State.t * ACT

Inductive ext_step : Program -> ExtState.t -> ExtState.t -> Prop :=ESS_step: forall ...,step p s t ->T = bookkeep p s t S ->ext_step p (s,S) (t,T)

P. Czarnik, A. Schubert (Warsaw Univ.) Extending Op. Sem. of the Java Bytecode TGC 2007 11 / 24

Page 15: Extending Operational Semantics of the Java Bytecode · PDF fileHorizontal Framework Realisation Horizontal Framework Realisation Bicolano State.t= heap * frame_stack step: Program->

Horizontal Framework Example

Memory Example: HF Implementation

Module MemoryExt <: EXTENSION.

Definition ACT := nat.

Definition bookkeep (p: Program)(s1: State.t) (s2: State.t) (old_size: nat): nat :=(* ... *)

match instruction with| New c =>old_size + (size_of_object c)

| Newarray t =>old_size + (size_of_array t)

| _ => old_sizeend

(* ... *)End MemoryExt.

P. Czarnik, A. Schubert (Warsaw Univ.) Extending Op. Sem. of the Java Bytecode TGC 2007 12 / 24

Page 16: Extending Operational Semantics of the Java Bytecode · PDF fileHorizontal Framework Realisation Horizontal Framework Realisation Bicolano State.t= heap * frame_stack step: Program->

Vertical Framework

P. Czarnik, A. Schubert (Warsaw Univ.) Extending Op. Sem. of the Java Bytecode TGC 2007 13 / 24

Page 17: Extending Operational Semantics of the Java Bytecode · PDF fileHorizontal Framework Realisation Horizontal Framework Realisation Bicolano State.t= heap * frame_stack step: Program->

Vertical Framework Idea

Vertical Framework Idea

New, arbitrary definitions of state and stepOriginal definitions available for reuseTypical use:

extending original state typechanging behaviour in special circumstancesleaving original behaviour in most cases

P. Czarnik, A. Schubert (Warsaw Univ.) Extending Op. Sem. of the Java Bytecode TGC 2007 14 / 24

Page 18: Extending Operational Semantics of the Java Bytecode · PDF fileHorizontal Framework Realisation Horizontal Framework Realisation Bicolano State.t= heap * frame_stack step: Program->

Vertical Framework Realisation

Vertical Framework Components

SEM – signature for semantics instances:state_t: Typetype of stateget_bottom_state: state_t -> bt_state_t -> Propprojection to Bicolano statestep: Program -> state_t -> state_t -> Propsemantic stepadditional_step: Program -> state_t-> bt_state_t -> state_t -> Propused by further extensions to construct Bicolano statesin case of change of behaviour

BottomSemantics – Bicolano semanticswrapped in SEM signature

Extension: functor SEM→ SEM

P. Czarnik, A. Schubert (Warsaw Univ.) Extending Op. Sem. of the Java Bytecode TGC 2007 15 / 24

Page 19: Extending Operational Semantics of the Java Bytecode · PDF fileHorizontal Framework Realisation Horizontal Framework Realisation Bicolano State.t= heap * frame_stack step: Program->

Vertical Framework Realisation

Vertical Framework Components

SEM – signature for semantics instances:state_t: Typetype of stateget_bottom_state: state_t -> bt_state_t -> Propprojection to Bicolano statestep: Program -> state_t -> state_t -> Propsemantic stepadditional_step: Program -> state_t-> bt_state_t -> state_t -> Propused by further extensions to construct Bicolano statesin case of change of behaviour

BottomSemantics – Bicolano semanticswrapped in SEM signature

Extension: functor SEM→ SEM

P. Czarnik, A. Schubert (Warsaw Univ.) Extending Op. Sem. of the Java Bytecode TGC 2007 15 / 24

Page 20: Extending Operational Semantics of the Java Bytecode · PDF fileHorizontal Framework Realisation Horizontal Framework Realisation Bicolano State.t= heap * frame_stack step: Program->

Vertical Framework Realisation

Vertical Framework Components

SEM – signature for semantics instances:state_t: Typetype of stateget_bottom_state: state_t -> bt_state_t -> Propprojection to Bicolano statestep: Program -> state_t -> state_t -> Propsemantic stepadditional_step: Program -> state_t-> bt_state_t -> state_t -> Propused by further extensions to construct Bicolano statesin case of change of behaviour

BottomSemantics – Bicolano semanticswrapped in SEM signature

Extension: functor SEM→ SEM

P. Czarnik, A. Schubert (Warsaw Univ.) Extending Op. Sem. of the Java Bytecode TGC 2007 15 / 24

Page 21: Extending Operational Semantics of the Java Bytecode · PDF fileHorizontal Framework Realisation Horizontal Framework Realisation Bicolano State.t= heap * frame_stack step: Program->

Vertical Framework Realisation

Vertical Framework Components

SEM – signature for semantics instances:state_t: Typetype of stateget_bottom_state: state_t -> bt_state_t -> Propprojection to Bicolano statestep: Program -> state_t -> state_t -> Propsemantic stepadditional_step: Program -> state_t-> bt_state_t -> state_t -> Propused by further extensions to construct Bicolano statesin case of change of behaviour

BottomSemantics – Bicolano semanticswrapped in SEM signature

Extension: functor SEM→ SEM

P. Czarnik, A. Schubert (Warsaw Univ.) Extending Op. Sem. of the Java Bytecode TGC 2007 15 / 24

Page 22: Extending Operational Semantics of the Java Bytecode · PDF fileHorizontal Framework Realisation Horizontal Framework Realisation Bicolano State.t= heap * frame_stack step: Program->

Vertical Framework Realisation

Vertical Framework Components

SEM – signature for semantics instances:state_t: Typetype of stateget_bottom_state: state_t -> bt_state_t -> Propprojection to Bicolano statestep: Program -> state_t -> state_t -> Propsemantic stepadditional_step: Program -> state_t-> bt_state_t -> state_t -> Propused by further extensions to construct Bicolano statesin case of change of behaviour

BottomSemantics – Bicolano semanticswrapped in SEM signature

Extension: functor SEM→ SEM

P. Czarnik, A. Schubert (Warsaw Univ.) Extending Op. Sem. of the Java Bytecode TGC 2007 15 / 24

Page 23: Extending Operational Semantics of the Java Bytecode · PDF fileHorizontal Framework Realisation Horizontal Framework Realisation Bicolano State.t= heap * frame_stack step: Program->

Vertical Framework Realisation

Vertical Framework Components

SEM – signature for semantics instances:state_t: Typetype of stateget_bottom_state: state_t -> bt_state_t -> Propprojection to Bicolano statestep: Program -> state_t -> state_t -> Propsemantic stepadditional_step: Program -> state_t-> bt_state_t -> state_t -> Propused by further extensions to construct Bicolano statesin case of change of behaviour

BottomSemantics – Bicolano semanticswrapped in SEM signature

Extension: functor SEM→ SEM

P. Czarnik, A. Schubert (Warsaw Univ.) Extending Op. Sem. of the Java Bytecode TGC 2007 15 / 24

Page 24: Extending Operational Semantics of the Java Bytecode · PDF fileHorizontal Framework Realisation Horizontal Framework Realisation Bicolano State.t= heap * frame_stack step: Program->

Vertical Framework Realisation

Semantics Hierarchy

...Last Extension

Bottom Semantics

Support Semantic

Current Extension

(Bicolano)

First Extension

get_bottom_state additional_stepstep

1

P. Czarnik, A. Schubert (Warsaw Univ.) Extending Op. Sem. of the Java Bytecode TGC 2007 16 / 24

Page 25: Extending Operational Semantics of the Java Bytecode · PDF fileHorizontal Framework Realisation Horizontal Framework Realisation Bicolano State.t= heap * frame_stack step: Program->

Vertical Framework Example

Memory Example: VF Implementation(1)

Module MemorySem (Support: SEM) <: SEM.Parameter max_heap_size: nat.

Definition state_t := Support.state_t * nat.

Inductive step :=| step_inherit_nn: forall ...,

(* ... *)~(current_ins sust1 (New c)) ->~(current_ins sust1 (Newarray t)) ->Support.step p sust1 sust2 ->step p (sust1, chs) (sust2, chs)

| step_new_ok: forall ...,(* ... *)

current_ins sust1 (New c) ->chs + (size_of_object c) <= max_heap_size ->Support.step p sust1 sust2 ->step p (sust1, chs) (sust2, (chs + (size_of_object c)))

(* ... *)

P. Czarnik, A. Schubert (Warsaw Univ.) Extending Op. Sem. of the Java Bytecode TGC 2007 17 / 24

Page 26: Extending Operational Semantics of the Java Bytecode · PDF fileHorizontal Framework Realisation Horizontal Framework Realisation Bicolano State.t= heap * frame_stack step: Program->

Vertical Framework Example

Memory Example: VF Implementation(1)

Module MemorySem (Support: SEM) <: SEM.Parameter max_heap_size: nat.

Definition state_t := Support.state_t * nat.

Inductive step :=| step_inherit_nn: forall ...,

(* ... *)~(current_ins sust1 (New c)) ->~(current_ins sust1 (Newarray t)) ->Support.step p sust1 sust2 ->step p (sust1, chs) (sust2, chs)

| step_new_ok: forall ...,(* ... *)

current_ins sust1 (New c) ->chs + (size_of_object c) <= max_heap_size ->Support.step p sust1 sust2 ->step p (sust1, chs) (sust2, (chs + (size_of_object c)))

(* ... *)

P. Czarnik, A. Schubert (Warsaw Univ.) Extending Op. Sem. of the Java Bytecode TGC 2007 17 / 24

Page 27: Extending Operational Semantics of the Java Bytecode · PDF fileHorizontal Framework Realisation Horizontal Framework Realisation Bicolano State.t= heap * frame_stack step: Program->

Vertical Framework Example

Memory Example: VF Implementation(1)

Module MemorySem (Support: SEM) <: SEM.Parameter max_heap_size: nat.

Definition state_t := Support.state_t * nat.

Inductive step :=| step_inherit_nn: forall ...,

(* ... *)~(current_ins sust1 (New c)) ->~(current_ins sust1 (Newarray t)) ->Support.step p sust1 sust2 ->step p (sust1, chs) (sust2, chs)

| step_new_ok: forall ...,(* ... *)

current_ins sust1 (New c) ->chs + (size_of_object c) <= max_heap_size ->Support.step p sust1 sust2 ->step p (sust1, chs) (sust2, (chs + (size_of_object c)))

(* ... *)

P. Czarnik, A. Schubert (Warsaw Univ.) Extending Op. Sem. of the Java Bytecode TGC 2007 17 / 24

Page 28: Extending Operational Semantics of the Java Bytecode · PDF fileHorizontal Framework Realisation Horizontal Framework Realisation Bicolano State.t= heap * frame_stack step: Program->

Vertical Framework Example

Memory Example: VF Implementation (2)

(* ... *)| step_new_OutOfMemory: forall ...,current_ins sust1 (New c) ->size_of_object p c = size ->chs + (size_of_object c) > max_heap_size ->

(* ...esize = OutOfMemoryError size,bost2 = bottom state after OutOfMemory thrown

*)Support.additional_step p sust1 bost2 sust2 ->step p (sust1, chs) (sust2, (chs + esize))

(* ... *)

P. Czarnik, A. Schubert (Warsaw Univ.) Extending Op. Sem. of the Java Bytecode TGC 2007 18 / 24

Page 29: Extending Operational Semantics of the Java Bytecode · PDF fileHorizontal Framework Realisation Horizontal Framework Realisation Bicolano State.t= heap * frame_stack step: Program->

The Frameworks Compared

P. Czarnik, A. Schubert (Warsaw Univ.) Extending Op. Sem. of the Java Bytecode TGC 2007 19 / 24

Page 30: Extending Operational Semantics of the Java Bytecode · PDF fileHorizontal Framework Realisation Horizontal Framework Realisation Bicolano State.t= heap * frame_stack step: Program->

The Frameworks Compared Expressive Power

Change of Behaviour Only in VF

Horizontal framework

Inductive ext_step :=ESS_step: forall ...,step p s t ->T = bookkeep p s t S ->ext_step p (s,S) (t,T)

inductive definition

s and t unchanged

behaviour guaranteednot to change

Vertical framework

Parameter step : Program-> state_t -> state_t -> Prop

arbitrary step definition

P. Czarnik, A. Schubert (Warsaw Univ.) Extending Op. Sem. of the Java Bytecode TGC 2007 20 / 24

Page 31: Extending Operational Semantics of the Java Bytecode · PDF fileHorizontal Framework Realisation Horizontal Framework Realisation Bicolano State.t= heap * frame_stack step: Program->

The Frameworks Compared Expressive Power

Embedding of HF within VF

P. Czarnik, A. Schubert (Warsaw Univ.) Extending Op. Sem. of the Java Bytecode TGC 2007 21 / 24

Propertiesany horizontal extension allowedequivalent to ordinary horizontal framework(when applied to BottomSem)

Page 32: Extending Operational Semantics of the Java Bytecode · PDF fileHorizontal Framework Realisation Horizontal Framework Realisation Bicolano State.t= heap * frame_stack step: Program->

The Frameworks Compared Cost

Cost of Frameworks

Source code size (lines)

Extension HF VFHeap mem. size 50 204

Instr. counter 26 173

Compiled code size (KB)

Extension HF VFHeap mem. size 148 181

Instr. counter 136 158

HF conceptually simpleronly the extended part of state in mindbookkeep function easy to writestep and additional_step relations hard to write

P. Czarnik, A. Schubert (Warsaw Univ.) Extending Op. Sem. of the Java Bytecode TGC 2007 22 / 24

Page 33: Extending Operational Semantics of the Java Bytecode · PDF fileHorizontal Framework Realisation Horizontal Framework Realisation Bicolano State.t= heap * frame_stack step: Program->

The Frameworks Compared Cost

Choosing Appropriate Framework

Horizontal FrameworkNo change in behaviour

Tracking additional information:counting use of resourceslogic strengthening (ghost variables, program traces)

Vertical frameworkAdditional behaviour needed:

new errors and exceptions signalledstep not allowed in some circumstances

Adding non-determinism:multi-threadingnon-deterministic errors

P. Czarnik, A. Schubert (Warsaw Univ.) Extending Op. Sem. of the Java Bytecode TGC 2007 23 / 24

Page 34: Extending Operational Semantics of the Java Bytecode · PDF fileHorizontal Framework Realisation Horizontal Framework Realisation Bicolano State.t= heap * frame_stack step: Program->

Summary

Summary

Two frameworks for extending semantics:applied to Bicolano (Mobius basic JVM formalisation)developed in Coqmodular

Extension examples and frameworks comparison

Vertical framework more general:arbitrary state and semantics definitionschange in behaviour allowed

Horizontal framework still usable:less expensive in usebehaviour guaranteed not to be changedactually used in (extended) Mobius base logic

P. Czarnik, A. Schubert (Warsaw Univ.) Extending Op. Sem. of the Java Bytecode TGC 2007 24 / 24

Page 35: Extending Operational Semantics of the Java Bytecode · PDF fileHorizontal Framework Realisation Horizontal Framework Realisation Bicolano State.t= heap * frame_stack step: Program->

Appendix

Story

1 Primary motivation – resource control for Bicolano2 Horizontal framework idea

no change of behaviour recognised as a limitation3 Vertical framework idea and implementation

change of behaviour found disadvantageous in some applications4 Horizontal framework implemented for ”simpler cases”

P. Czarnik, A. Schubert (Warsaw Univ.) Extending Op. Sem. of the Java Bytecode TGC 2007 25 / 24

Page 36: Extending Operational Semantics of the Java Bytecode · PDF fileHorizontal Framework Realisation Horizontal Framework Realisation Bicolano State.t= heap * frame_stack step: Program->

Appendix

Related Work

Peter D. Mosses; Action Semantics; 1992similar to HF

Sheng Liang & Paul Hudak; Modular Denotational Semanticsfor Compiler Construction; 1996

modular monadic semantics

In both of them framework build with extensions in mindOur framworks: attention paid on reusing Bicolano formalisation

P. Czarnik, A. Schubert (Warsaw Univ.) Extending Op. Sem. of the Java Bytecode TGC 2007 26 / 24

Page 37: Extending Operational Semantics of the Java Bytecode · PDF fileHorizontal Framework Realisation Horizontal Framework Realisation Bicolano State.t= heap * frame_stack step: Program->

Appendix

Future Work

Horizontal framework:composing several extensions into one extension

Vertical framework:extending instructions setextending basic datatypes setmake ”extensions subclasses” modularly

P. Czarnik, A. Schubert (Warsaw Univ.) Extending Op. Sem. of the Java Bytecode TGC 2007 27 / 24

Page 38: Extending Operational Semantics of the Java Bytecode · PDF fileHorizontal Framework Realisation Horizontal Framework Realisation Bicolano State.t= heap * frame_stack step: Program->

Appendix

Bicolano Flavours

Bicolano semantics given in 2 flavours:small stepbig step

Vertical framework – small step flavourHorizontal framework – both flavours

small step – no changes in existing Bicolano codebig step – small changes in Bicolano code(cyclic module dependencies)big step actually used in (extended) Mobius program logic

P. Czarnik, A. Schubert (Warsaw Univ.) Extending Op. Sem. of the Java Bytecode TGC 2007 28 / 24

Page 39: Extending Operational Semantics of the Java Bytecode · PDF fileHorizontal Framework Realisation Horizontal Framework Realisation Bicolano State.t= heap * frame_stack step: Program->

Appendix

additional_step in Details

additional_step : Program ->state_t -> bt_state_t -> state_t

Provided for further extensions applied to current one:assume SEM2 extends SEM1

Used when SEM2 changes behaviour, example:1 S1 – SEM1’s part of SEM2’s state before step2 B1 – projection of S1 to bottom state3 SEM2 changes bottom part of state from B1 to B24 SEM2 needs SEM1’s state constructed over B25 SEM2 calls SEM1’s additional_step p S1 B26 S2 – result, SEM1’s state after ”additional step”7 SEM2 builds its state over S2

In fact additional_step : Program ->state_t -> bt_state_t -> state_t -> Prop

P. Czarnik, A. Schubert (Warsaw Univ.) Extending Op. Sem. of the Java Bytecode TGC 2007 29 / 24

Page 40: Extending Operational Semantics of the Java Bytecode · PDF fileHorizontal Framework Realisation Horizontal Framework Realisation Bicolano State.t= heap * frame_stack step: Program->

Appendix

VF: Axiom in SEM

Axiom add_step_step_compat: forall ...,step p st1 st2 ->get_bottom_state st2 bost2 ->additional_step p st1 bost2 st2.

P. Czarnik, A. Schubert (Warsaw Univ.) Extending Op. Sem. of the Java Bytecode TGC 2007 30 / 24

Page 41: Extending Operational Semantics of the Java Bytecode · PDF fileHorizontal Framework Realisation Horizontal Framework Realisation Bicolano State.t= heap * frame_stack step: Program->

Appendix

”Subclasses” in VF

Deterministic projectionsParameter fget_bottom_state: state_t -> bottom_state_t.Axiom get_bottom_state_ok: forall sust bost,get_bottom_state sust bost <-> fget_bottom_state sust = bost.

Axiom additional_step_proj: forall p st1 bost2 st2,additional_step p st1 bost2 st2 -> get_bottom_state st2 bost2.

ConservativityAxiom support_step_implies_step: forall p t s’,Support.step p (get_support_state t) s’ ->exists t’: state_t, step p t t’ AND (get_support_state t’) = s’.

Axiom step_implies_support_step:forall p t t’, step p t t’ ->Support.step p (get_support_state t) (get_support_state t’).

P. Czarnik, A. Schubert (Warsaw Univ.) Extending Op. Sem. of the Java Bytecode TGC 2007 31 / 24