Author: Stephan <step...@stzal.com> Branch: Changeset: r312:8d5191d68fe4 Date: 2012-12-11 16:21 +0100 http://bitbucket.org/pypy/lang-js/changeset/8d5191d68fe4/
Log: strange hack to make references more jit-friendly diff --git a/js/lexical_environment.py b/js/lexical_environment.py --- a/js/lexical_environment.py +++ b/js/lexical_environment.py @@ -52,7 +52,10 @@ def get_base(self): return self.base_value - def get_referenced_name(self): + # XXX passing identifier is a obscure hack but cfbolz sayz so! + def get_referenced_name(self, identifier=None): + if identifier is not None: + return identifier return self.referenced def is_strict_reference(self): @@ -76,15 +79,15 @@ return True return False - def get_value(self): - return get_value(self) + def get_value(self, identifier=None): + return get_value(self, identifier) - def put_value(self, value): - put_value(self, value) + def put_value(self, value, identifier=None): + put_value(self, value, identifier) # 8.7.1 -def get_value(v): +def get_value(v, identifier=None): if not isinstance(v, Reference): return v @@ -98,13 +101,13 @@ base_env = v.base_env from js.environment_record import EnvironmentRecord assert isinstance(base_env, EnvironmentRecord) - name = v.get_referenced_name() + name = v.get_referenced_name(identifier) strict = v.is_strict_reference() return base_env.get_binding_value(name, strict) # 8.7.2 -def put_value(v, w): +def put_value(v, w, identifier): if not isinstance(v, Reference): raise JsReferenceError('unresolvable reference') @@ -113,7 +116,7 @@ referenced = v.get_referenced_name() raise JsReferenceError(referenced) else: - name = v.get_referenced_name() + name = v.get_referenced_name(identifier) # TODO how to solve this ???? from js.object_space import object_space global_object = object_space.global_object @@ -125,6 +128,6 @@ base_env = v.base_env from js.environment_record import EnvironmentRecord assert isinstance(base_env, EnvironmentRecord) - name = v.get_referenced_name() + name = v.get_referenced_name(identifier) strict = v.is_strict_reference() base_env.set_mutable_binding(name, w, strict) diff --git a/js/opcodes.py b/js/opcodes.py --- a/js/opcodes.py +++ b/js/opcodes.py @@ -143,8 +143,8 @@ # 11.1.2 def eval(self, ctx): # TODO put ref onto stack - value = ref.get_value() ref = ctx.get_ref(self.identifier, self.index) + value = ref.get_value(self.identifier) ctx.stack_append(value) def __str__(self): @@ -501,8 +501,8 @@ def eval(self, ctx): value = ctx.stack_top() - ref.put_value(value) ref = ctx.get_ref(self.identifier, self.index) + ref.put_value(value, self.identifier) def __str__(self): return 'STORE "%s"' % (self.identifier) _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit