Lichen

Changeset

592:0b24363cbf9c
2017-02-17 Paul Boddie raw files shortlog changelog graph Reintroduced a private context variable where the context is not used for invocations. method-wrapper-for-context
optimiser.py (file) templates/ops.h (file) translator.py (file)
     1.1 --- a/optimiser.py	Fri Feb 17 18:52:18 2017 +0100
     1.2 +++ b/optimiser.py	Fri Feb 17 19:46:39 2017 +0100
     1.3 @@ -466,8 +466,12 @@
     1.4                      # Set the context, if appropriate.
     1.5  
     1.6                      if remaining == 1 and final_method != "assign" and context == "final-accessor":
     1.7 -                        emit(("<set_context>", accessor))
     1.8 -                        accessor = context_var = "<context>"
     1.9 +                        if final_method in ("access-invoke", "static-invoke"):
    1.10 +                            emit(("<set_context>", accessor))
    1.11 +                            accessor = context_var = "<context>"
    1.12 +                        else:
    1.13 +                            emit(("<set_private_context>", accessor))
    1.14 +                            accessor = context_var = "<private_context>"
    1.15  
    1.16                      # Perform the access only if not achieved directly.
    1.17  
    1.18 @@ -493,8 +497,12 @@
    1.19                      # Set the context, if appropriate.
    1.20  
    1.21                      if remaining == 1 and final_method != "assign" and context == "final-accessor":
    1.22 -                        emit(("<set_context>", accessor))
    1.23 -                        accessor = context_var = "<context>"
    1.24 +                        if final_method in ("access-invoke", "static-invoke"):
    1.25 +                            emit(("<set_context>", accessor))
    1.26 +                            accessor = context_var = "<context>"
    1.27 +                        else:
    1.28 +                            emit(("<set_private_context>", accessor))
    1.29 +                            accessor = context_var = "<private_context>"
    1.30  
    1.31                      # Perform the access only if not achieved directly.
    1.32  
     2.1 --- a/templates/ops.h	Fri Feb 17 18:52:18 2017 +0100
     2.2 +++ b/templates/ops.h	Fri Feb 17 19:46:39 2017 +0100
     2.3 @@ -75,6 +75,7 @@
     2.4  
     2.5  #define __get_context(__TARGET) (__tmp_contexts[__TARGET])
     2.6  #define __set_context(__TARGET, __ATTR) (__tmp_contexts[__TARGET] = (__ATTR).value)
     2.7 +#define __set_private_context(__ATTR) (__tmp_private_context = (__ATTR).value)
     2.8  #define __set_accessor(__ATTR) (__tmp_value = (__ATTR).value)
     2.9  #define __set_target_accessor(__ATTR) (__tmp_target_value = (__ATTR).value)
    2.10  
     3.1 --- a/translator.py	Fri Feb 17 18:52:18 2017 +0100
     3.2 +++ b/translator.py	Fri Feb 17 19:46:39 2017 +0100
     3.3 @@ -741,6 +741,8 @@
     3.4          temp_subs = {
     3.5              "<context>" : "__tmp_contexts",
     3.6              "<set_context>" : "__tmp_contexts",
     3.7 +            "<private_context>" : "__tmp_private_context",
     3.8 +            "<set_private_context>" : "__tmp_private_context",
     3.9              "<accessor>" : "__tmp_value",
    3.10              "<target_accessor>" : "__tmp_target_value",
    3.11              "<set_accessor>" : "__tmp_value",
    3.12 @@ -750,6 +752,7 @@
    3.13          op_subs = {
    3.14              "<context>" : "__get_context",
    3.15              "<set_context>" : "__set_context",
    3.16 +            "<set_private_context>" : "__set_private_context",
    3.17              "<set_accessor>" : "__set_accessor",
    3.18              "<set_target_accessor>" : "__set_target_accessor",
    3.19              }
    3.20 @@ -1374,11 +1377,11 @@
    3.21          # Methods accessed via unidentified accessors are obtained. 
    3.22  
    3.23          elif function:
    3.24 -            self.record_temp("__tmp_contexts")
    3.25              self.record_temp("__tmp_targets")
    3.26  
    3.27              if context_required:
    3.28                  if have_access_context:
    3.29 +                    self.record_temp("__tmp_contexts")
    3.30                      stages.append("__get_function(__tmp_contexts[%d], __tmp_targets[%d])" % (
    3.31                          self.function_target, self.function_target))
    3.32                  else:
    3.33 @@ -1942,6 +1945,8 @@
    3.34  
    3.35          # Add temporary variable usage details.
    3.36  
    3.37 +        if self.uses_temp(name, "__tmp_private_context"):
    3.38 +            self.writeline("__ref __tmp_private_context;")
    3.39          if self.uses_temp(name, "__tmp_value"):
    3.40              self.writeline("__ref __tmp_value;")
    3.41          if self.uses_temp(name, "__tmp_target_value"):