Is Dalvik's memory model the same as Java?

Is the Dalvik memory model the same as Java ? I am particularly interested in whether the reads and writes of referenced and not long / not double primitive variables are atomic, but I would also like to know if there are differences between the memory models of the two platforms.

+29
java android memory-model dalvik java-memory-model
Jan 03 2018-11-11T00:
source share
3 answers

Starting with 4.0 (an ice cream sandwich), Dalvik's behavior should be consistent with JSR-133 (Java memory model).

Starting with version 3.0 (Honeycomb), most of the parts were in place, but some minor things were missed that would be hard to find in practice (for example, some cases of edges at the end).

Starting with version 2.3 (Gingerbread), Dalvik, as a rule, was right on single-processor systems, but some key functions necessary for correct behavior on SMP equipment (for example, correct final field processing) were absent.

Pre-Gingerbread, there were no memory barriers at all, and basic things like volatile long were broken.

+57
Jan 6 2018-11-11T00:
source share

In the source of Dalvik there is which states:

In terms of a piece of code written in the Java programming language or aimed in the same way at .class files, Dalvik VM aims to behave in a way that is fully consistent with the definition of the language. That is, the code running in Dalvik will behave the same as in any other virtual machine.

This should mean that the behavior is the same as in the correct Java. Actually or not, I have no idea.

+12
Jan 03 2018-11-11T00:
source share

The specification states that all operations on 32-bit numbers (non-double, short-lived numbers) are atomic. There is no guarantee that operations with 64-bit numbers are also atomic.

0
Jan 03 2018-11-11T00:
source share



All Articles