<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -343,17 +343,16 @@ length(VALUE self)
 
 /*
  * call-seq:
- *   context
+ *   runtime
  *
- * Returns context.
+ * Returns runtime.
  */
 static VALUE
-context(VALUE self)
+runtime(VALUE self)
 {
   RubyLandProxy* proxy;
   Data_Get_Struct(self, RubyLandProxy, proxy);
-  JSContext * context = johnson_get_current_context(proxy-&gt;runtime);
-  return (VALUE)JS_GetContextPrivate(context);
+  return (VALUE)JS_GetRuntimePrivate(proxy-&gt;runtime-&gt;js);
 }
 
 /*
@@ -547,7 +546,7 @@ void init_Johnson_SpiderMonkey_Proxy(VALUE spidermonkey)
   rb_define_method(proxy_class, &quot;to_s&quot;, to_s, 0);
 
   rb_define_private_method(proxy_class, &quot;native_call&quot;, native_call, -1);
-  rb_define_private_method(proxy_class, &quot;context&quot;, context, 0);
+  rb_define_private_method(proxy_class, &quot;runtime&quot;, runtime, 0);
   rb_define_private_method(proxy_class, &quot;function_property?&quot;, function_property_p, 1);
   rb_define_private_method(proxy_class, &quot;call_function_property&quot;, call_function_property, -1);
 }</diff>
      <filename>ext/spidermonkey/ruby_land_proxy.c</filename>
    </modified>
    <modified>
      <diff>@@ -33,10 +33,10 @@ module Johnson
   PRELUDE = IO.read(File.dirname(__FILE__) + &quot;/../js/johnson/prelude.js&quot;)
   
   def self.evaluate(expression, vars={})
-    context = Johnson::Context.new
-    vars.each { |key, value| context[key] = value }
+    runtime = Johnson::Runtime.new
+    vars.each { |key, value| runtime[key] = value }
     
-    context.evaluate(expression)
+    runtime.evaluate(expression)
   end
   
   def self.parse(js, *args)</diff>
      <filename>lib/johnson.rb</filename>
    </modified>
    <modified>
      <diff>@@ -7,25 +7,6 @@ module Johnson #:nodoc:
         @gcthings = {}
       end
       
-      protected
-      
-      def handle_js_exception(jsex)
-        raise jsex if Exception === jsex
-        raise Johnson::Error.new(jsex.to_s) unless Johnson::SpiderMonkey::RubyLandProxy === jsex
-        
-        # FIXME: sanitize stack traces
-        stack = jsex.stack rescue nil
-        
-        ex = Johnson::Error.new(jsex)
-        if stack
-          ex.set_backtrace(stack.split(&quot;\n&quot;) + caller)
-        else
-          ex.set_backtrace(caller)
-        end
-        
-        raise ex
-      end
-      
       # called from js_land_proxy.c:make_js_land_proxy
       def add_gcthing(thing)
         @gcthings[thing.object_id] = thing</diff>
      <filename>lib/johnson/spidermonkey/context.rb</filename>
    </modified>
    <modified>
      <diff>@@ -16,7 +16,7 @@ module Johnson #:nodoc:
       end
 
       def call(*args)
-        call_using(context.global, *args)
+        call_using(runtime.global, *args)
       end
 
       def call_using(this, *args)</diff>
      <filename>lib/johnson/spidermonkey/ruby_land_proxy.rb</filename>
    </modified>
    <modified>
      <diff>@@ -7,7 +7,8 @@ module Johnson #:nodoc:
       end
 
       def current_context
-        Thread.current[:johson_context] ||= Context.new(self)
+        contexts = (Thread.current[:johson_context_map] ||= {})
+        contexts[self.object_id] ||= Context.new(self)
       end
 
       def [](key)
@@ -17,6 +18,25 @@ module Johnson #:nodoc:
       def []=(key, value)
         global[key] = value
       end
+
+      protected
+      
+      def handle_js_exception(jsex)
+        raise jsex if Exception === jsex
+        raise Johnson::Error.new(jsex.to_s) unless Johnson::SpiderMonkey::RubyLandProxy === jsex
+        
+        # FIXME: sanitize stack traces
+        stack = jsex.stack rescue nil
+        
+        ex = Johnson::Error.new(jsex)
+        if stack
+          ex.set_backtrace(stack.split(&quot;\n&quot;) + caller)
+        else
+          ex.set_backtrace(caller)
+        end
+        
+        raise ex
+      end
     end
   end
 end</diff>
      <filename>lib/johnson/spidermonkey/runtime.rb</filename>
    </modified>
    <modified>
      <diff>@@ -21,14 +21,14 @@ module Johnson
     undef :default_test
     
     def assert_js(expression, options={})
-      context = options[:context] || @context
-      assert(context.evaluate(expression), &quot;Expected JS expression [#{expression}] to be true.&quot;)
+      runtime = options[:runtime] || @runtime
+      assert(runtime.evaluate(expression), &quot;Expected JS expression [#{expression}] to be true.&quot;)
     end
     
     def assert_js_equal(expected, expression, options={})
-      context = options.delete(:context) || @context
-      options.each { |k, v| context[k.to_s] = v }
-      assert_equal(expected, context.evaluate(expression))
+      runtime = options.delete(:runtime) || @runtime
+      options.each { |k, v| runtime[k.to_s] = v }
+      assert_equal(expected, runtime.evaluate(expression))
     end
   end
 </diff>
      <filename>test/helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -4,7 +4,7 @@ module Johnson
   module SpiderMonkey
     class RubyLandProxyTest &lt; Johnson::TestCase
       def setup
-        @context = Johnson::Context.new(Johnson::SpiderMonkey::Context)
+        @runtime = Johnson::Runtime.new(Johnson::SpiderMonkey::Runtime)
       end
       
       def test_constructing_a_proxy_directly_asplodes
@@ -12,18 +12,18 @@ module Johnson
       end
       
       def test_objects_get_wrapped_as_proxies
-        assert_kind_of(Johnson::SpiderMonkey::RubyLandProxy, @context.evaluate(&quot;x = {}&quot;))
-        assert_kind_of(Johnson::SpiderMonkey::RubyLandProxy, @context.evaluate(&quot;new Object()&quot;))
+        assert_kind_of(Johnson::SpiderMonkey::RubyLandProxy, @runtime.evaluate(&quot;x = {}&quot;))
+        assert_kind_of(Johnson::SpiderMonkey::RubyLandProxy, @runtime.evaluate(&quot;new Object()&quot;))
       end
       
       def test_proxies_get_unwrapped_when_roundtripping
-        proxy = @context.evaluate(&quot;x = {}&quot;)
-        @context[&quot;y&quot;] = proxy
-        assert(@context.evaluate(&quot;x === y&quot;))
+        proxy = @runtime.evaluate(&quot;x = {}&quot;)
+        @runtime[&quot;y&quot;] = proxy
+        assert(@runtime.evaluate(&quot;x === y&quot;))
       end
       
       def test_array_indexable
-        proxy = @context.evaluate(&quot;var x = [1,2,3]; x&quot;)
+        proxy = @runtime.evaluate(&quot;var x = [1,2,3]; x&quot;)
         assert_equal(1, proxy[0])
         assert_equal(1, proxy['0'])
 
@@ -32,7 +32,7 @@ module Johnson
       end
       
       def test_hash_indexable
-        proxy = @context.evaluate(&quot;var x = { 0: 1, 1: 2, 2: 3 }; x&quot;)
+        proxy = @runtime.evaluate(&quot;var x = { 0: 1, 1: 2, 2: 3 }; x&quot;)
         assert_equal(1, proxy[0])
         assert_equal(1, proxy['0'])
 
@@ -41,49 +41,49 @@ module Johnson
       end
 
       def test_functions_get_wrapped_as_proxies
-        f = @context.evaluate(&quot;function() {}&quot;)
+        f = @runtime.evaluate(&quot;function() {}&quot;)
         assert_kind_of(Johnson::SpiderMonkey::RubyLandProxy, f)
         assert(f.function?)
       end
 
       def test_function?
-        f = @context.evaluate(&quot;function() {}&quot;)
+        f = @runtime.evaluate(&quot;function() {}&quot;)
         assert_kind_of(Johnson::SpiderMonkey::RubyLandProxy, f)
         assert(f.function?)
 
-        f = @context.evaluate(&quot;new Object()&quot;)
+        f = @runtime.evaluate(&quot;new Object()&quot;)
         assert_kind_of(Johnson::SpiderMonkey::RubyLandProxy, f)
         assert(!f.function?)
       end
       
       def test_calling_non_functions_complains
-        assert_raise(Johnson::Error) { @context.evaluate(&quot;new Object()&quot;).call }
+        assert_raise(Johnson::Error) { @runtime.evaluate(&quot;new Object()&quot;).call }
       end
       
       def test_functions_can_be_called
-        f = @context.evaluate(&quot;function() { return 42; }&quot;)
+        f = @runtime.evaluate(&quot;function() { return 42; }&quot;)
         assert_equal(42, f.call)
       end
       
       def test_functions_can_be_called_with_args
-        f = @context.evaluate(&quot;function(x) { return x * 2; }&quot;)
+        f = @runtime.evaluate(&quot;function(x) { return x * 2; }&quot;)
         assert_equal(84, f.call(42))
       end
       
       def test_functions_can_be_used_as_procs
-        f = @context.evaluate(&quot;function(x) { return x * 2; }&quot;)
+        f = @runtime.evaluate(&quot;function(x) { return x * 2; }&quot;)
         a = [1, 2, 3]
         
         assert_equal([2, 4, 6], a.collect(&amp;f))
       end
       
       def test_function_proxies_are_called_with_a_global_this
-        f = @context.evaluate(&quot;x = 42; function() { return this.x; }&quot;)
+        f = @runtime.evaluate(&quot;x = 42; function() { return this.x; }&quot;)
         assert_equal(42, f.call)
       end
       
       def test_can_be_indexed_by_string
-        proxy = @context.evaluate(&quot;x = { foo: 42 }&quot;)
+        proxy = @runtime.evaluate(&quot;x = { foo: 42 }&quot;)
         assert_kind_of(Johnson::SpiderMonkey::RubyLandProxy, proxy)
         
         assert_equal(42, proxy[&quot;foo&quot;])
@@ -97,29 +97,29 @@ module Johnson
       end
       
       def test_multilevel_indexing_works
-        proxy = @context.evaluate(&quot;x = { foo: { bar: 42 , baz: function() { return 42 } } }&quot;)
+        proxy = @runtime.evaluate(&quot;x = { foo: { bar: 42 , baz: function() { return 42 } } }&quot;)
         assert_equal(42, proxy[&quot;foo&quot;][&quot;bar&quot;])
         assert_equal(42, proxy[&quot;foo&quot;][&quot;baz&quot;].call)
       end
       
       def test_respond_to_works
-        proxy = @context.evaluate(&quot;x = { foo: 42 }&quot;)
+        proxy = @runtime.evaluate(&quot;x = { foo: 42 }&quot;)
         assert(!proxy.respond_to?(:bar))
         assert(proxy.respond_to?(:foo))
       end
       
       def test_respond_to_always_returns_true_for_assignment
-        proxy = @context.evaluate(&quot;x = {}&quot;)
+        proxy = @runtime.evaluate(&quot;x = {}&quot;)
         assert(proxy.respond_to?(:bar=))
       end
       
       def test_accessor
-        proxy = @context.evaluate(&quot;x = { foo: 42 }&quot;)
+        proxy = @runtime.evaluate(&quot;x = { foo: 42 }&quot;)
         assert_equal(42, proxy.foo)
       end
       
       def test_mutator
-        proxy = @context.evaluate(&quot;x = {}&quot;)
+        proxy = @runtime.evaluate(&quot;x = {}&quot;)
         proxy.foo = 42
         
         assert_js_equal(42, &quot;x.foo&quot;)
@@ -127,22 +127,22 @@ module Johnson
       end
       
       def test_method_with_no_arguments
-        proxy = @context.evaluate(&quot;x = { foo: function() { return 42 } }&quot;)
+        proxy = @runtime.evaluate(&quot;x = { foo: function() { return 42 } }&quot;)
         assert_equal(42, proxy.foo)
       end
       
       def test_method_with_one_argument
-        proxy = @context.evaluate(&quot;f = { f: function(x) { return x * 2 } }&quot;)
+        proxy = @runtime.evaluate(&quot;f = { f: function(x) { return x * 2 } }&quot;)
         assert_equal(84, proxy.f(42))
       end
       
       def test_method_with_multiple_arguments
-        proxy = @context.evaluate(&quot;x = { add: function(x, y) { return x + y } }&quot;)
+        proxy = @runtime.evaluate(&quot;x = { add: function(x, y) { return x + y } }&quot;)
         assert_equal(42, proxy.add(40, 2))
       end
       
       def test_supports_each_on_arrays
-        proxy = @context.evaluate(&quot;[1, 2, 3]&quot;)
+        proxy = @runtime.evaluate(&quot;[1, 2, 3]&quot;)
         values = []
         
         proxy.each { |n| values &lt;&lt; n }
@@ -150,7 +150,7 @@ module Johnson
       end
       
       def test_supports_each_on_things_that_arent_arrays
-        proxy = @context.evaluate(&quot;x = { foo: 'fooval', bar: 'barval' }; x[0] = 42; x&quot;)
+        proxy = @runtime.evaluate(&quot;x = { foo: 'fooval', bar: 'barval' }; x[0] = 42; x&quot;)
         values = {}
         
         proxy.each { |k, v| values[k] = v }
@@ -158,7 +158,7 @@ module Johnson
       end
       
       def test_each_passes_an_exception
-        proxy = @context.evaluate(&quot;x = { foo: 'fooval', bar: 'barval' }; x[0] = 42; x&quot;)
+        proxy = @runtime.evaluate(&quot;x = { foo: 'fooval', bar: 'barval' }; x[0] = 42; x&quot;)
         values = {}
         
         assert_raise(RuntimeError) do
@@ -171,29 +171,29 @@ module Johnson
       end
       
       def test_is_enumerable
-        proxy = @context.evaluate(&quot;[1, 2, 3]&quot;)
+        proxy = @runtime.evaluate(&quot;[1, 2, 3]&quot;)
         assert_kind_of(Enumerable, proxy)
         
         assert_equal([2, 4, 6], proxy.collect { |n| n * 2 })
       end
       
       def test_has_a_length
-        proxy = @context.evaluate(&quot;[1, 2, 3]&quot;)
+        proxy = @runtime.evaluate(&quot;[1, 2, 3]&quot;)
         assert_equal(3, proxy.length)
       end
       
       def test_length_is_aliased_as_size
-        proxy = @context.evaluate(&quot;[1, 2, 3]&quot;)
+        proxy = @runtime.evaluate(&quot;[1, 2, 3]&quot;)
         assert_equal(3, proxy.size)
       end
       
       def test_length_for_arrays_ignores_non_numeric_properties
-        proxy = @context.evaluate(&quot;x = [1, 2, 3]; x['foo'] = 'bar'; x&quot;)
+        proxy = @runtime.evaluate(&quot;x = [1, 2, 3]; x['foo'] = 'bar'; x&quot;)
         assert_equal(3, proxy.length)
       end
       
       def test_length_for_objects_includes_all_properties
-        proxy = @context.evaluate(&quot;x = { foo: 'foo', bar: 'bar', 0: 42 }&quot;)
+        proxy = @runtime.evaluate(&quot;x = { foo: 'foo', bar: 'bar', 0: 42 }&quot;)
         assert_equal(3, proxy.length)
       end
 </diff>
      <filename>test/johnson/spidermonkey/ruby_land_proxy_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -9,7 +9,7 @@ class JohnsonTest &lt; Test::Unit::TestCase
     assert_equal(4, Johnson.evaluate(&quot;2 + foo&quot;, :foo =&gt; 2))
   end
   
-  def test_evaluate_uses_a_new_context_each_time
+  def test_evaluate_uses_a_new_runtime_each_time
     assert_equal(4, Johnson.evaluate(&quot;foo&quot;, :foo =&gt; 4))
     assert_raise(Johnson::Error) { Johnson.evaluate(&quot;foo&quot;) }
   end</diff>
      <filename>test/johnson_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>40f5721b35e94fe0630cb2372d246b62664c9439</id>
    </parent>
  </parents>
  <author>
    <name>Aaron Patterson</name>
    <email>aaron.patterson@gmail.com</email>
  </author>
  <url>http://github.com/jbarnette/johnson/commit/dc2a8331070fe0cb318d359ee5d439859d957604</url>
  <id>dc2a8331070fe0cb318d359ee5d439859d957604</id>
  <committed-date>2008-05-30T16:47:33-07:00</committed-date>
  <authored-date>2008-05-30T16:47:33-07:00</authored-date>
  <message>making more shit work</message>
  <tree>1938dd6db795c18a80d1a8b4b590f359df742b17</tree>
  <committer>
    <name>Aaron Patterson</name>
    <email>aaron.patterson@gmail.com</email>
  </committer>
</commit>
