WARNING! Access to this system is limited to authorised users only.
Unauthorised users may be subject to prosecution.
Unauthorised access to this system is a criminal offence under Australian law (Federal Crimes Act 1914 Part VIA)
It is a criminal offence to:
(1) Obtain access to data without authority. -Penalty 2 years imprisonment.
(2) Damage, delete, alter or insert data without authority. -Penalty 10 years imprisonment.
User activity is monitored and recorded. Anyone using this system expressly consents to such monitoring and recording.

Commit 663c843e authored by Stefan Marr's avatar Stefan Marr
Browse files

Mark fields of VM objects as immutable where possible


Signed-off-by: default avatarStefan Marr <git@stefan-marr.de>
parent 136be2d0
......@@ -4,6 +4,8 @@ from rpython.rlib import jit
class Interpreter(object):
_immutable_fields_ = ["_universe"]
def __init__(self, universe):
self._universe = universe
self._frame = None
......@@ -306,7 +308,7 @@ def get_printable_location(bytecode_index, interp, method):
method.merge_point_string())
jitdriver = jit.JitDriver(
greens=['bytecode_index', 'interp', 'method'], #
greens=['bytecode_index', 'interp', 'method'],
reds=['frame'],
# virtualizables=['frame'],
get_printable_location=get_printable_location)
......
from som.vmobjects.object import Object
class Array(Object):
_immutable_fields_ = ["_indexable_fields"]
def __init__(self, nilObject, number_of_indexable_fields):
Object.__init__(self, nilObject)
......
from som.vmobjects.object import Object
class BigInteger(Object):
_immutable_fields_ = ["_embedded_biginteger"]
def __init__(self, nilObject, value):
Object.__init__(self, nilObject)
self._embedded_biginteger = value
......
from som.vmobjects.object import Object
class Double(Object):
_immutable_fields_ = ["_embedded_double"]
def __init__(self, nilObject, value):
Object.__init__(self, nilObject)
......
......@@ -15,6 +15,8 @@ class Frame(Array):
# Static field indices and number of frame fields
NUMBER_OF_FRAME_FIELDS = Array.NUMBER_OF_OBJECT_FIELDS
_immutable_fields_ = ["_method", "_context", "_previous_frame"]
def __init__(self, nilObject, num_elements, method, context, previous_frame):
Array.__init__(self, nilObject, num_elements)
......
......@@ -2,6 +2,8 @@ from som.vmobjects.object import Object
class Integer(Object):
_immutable_fields_ = ["_embedded_integer"]
def __init__(self, nilObject, value):
Object.__init__(self, nilObject)
self._embedded_integer = value
......
......@@ -9,6 +9,12 @@ class Method(Array):
HOLDER_INDEX = 1 + SIGNATURE_INDEX
NUMBER_OF_METHOD_FIELDS = 1 + HOLDER_INDEX
_immutable_fields_ = ["_bytecodes[*]",
"_inline_cache_class",
"_receiver_class_table",
"_number_of_locals",
"_maximum_number_of_stack_elements"]
def __init__(self, nilObject, num_literals, num_locals, max_stack_elements,
num_bytecodes, signature):
......
class Object(object):
_immutable_fields_ = ["_class", "_fields"]
# Static field indices and number of object fields
NUMBER_OF_OBJECT_FIELDS = 0
......@@ -24,7 +26,7 @@ class Object(object):
def get_number_of_fields(self):
# Get the number of fields in this object
return len(self._fields)
return len(self._fields)
def _get_default_number_of_fields(self):
# Return the default number of fields in an object
......
from som.vmobjects.object import Object
class Primitive(Object):
_immutable_fields_ = ["_invoke", "_is_empty"]
# Static field indices and number of primitive fields
SIGNATURE_INDEX = Object.NUMBER_OF_OBJECT_FIELDS
......
from som.vmobjects.object import Object
class String(Object):
_immutable_fields_ = ["_string"]
def __init__(self, nilObject, value):
Object.__init__(self, nilObject)
......
from som.vmobjects.object import Object
class Symbol(Object):
_immutable_fields_ = ["_string", "_number_of_signature_arguments"]
def __init__(self, nilObject, value):
Object.__init__(self, nilObject)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment