therubyracer 0.9.1 → 0.9.2beta1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of therubyracer might be problematic. Click here for more details.

@@ -8,14 +8,34 @@ using namespace v8;
8
8
  * Creates a new Persistent storage cell for `handle`
9
9
  * so that we can reference it from Ruby.
10
10
  */
11
- v8_handle::v8_handle(Handle<void> handle) : handle(Persistent<void>::New(handle)) {
11
+ v8_handle::v8_handle(Handle<void> object) {
12
12
  this->weakref_callback = Qnil;
13
13
  this->weakref_callback_parameters = Qnil;
14
14
  this->dead = false;
15
+ this->payload = new Payload(object);
15
16
  }
16
17
 
17
18
  v8_handle::~v8_handle() {}
18
19
 
20
+ v8_handle::Payload::Payload(Handle<void> object) {
21
+ rb_gc_register_address(&wrapper);
22
+ handle = Persistent<void>::New(object);
23
+ wrapper = Data_Wrap_Struct(rb_cObject, 0, destroy, this);
24
+ }
25
+
26
+ v8_handle::Payload::~Payload() {
27
+ rb_gc_unregister_address(&wrapper);
28
+ }
29
+
30
+ void v8_handle::Payload::release() {
31
+ handle.Dispose();
32
+ handle.Clear();
33
+ }
34
+
35
+ void v8_handle::Payload::destroy(v8_handle::Payload* payload) {
36
+ delete payload;
37
+ }
38
+
19
39
  namespace {
20
40
  /**
21
41
  * Holds dead references, that are no longer being held in Ruby, so that they can be garbage collected
@@ -33,14 +53,6 @@ namespace {
33
53
  rb_gc_mark(handle->weakref_callback_parameters);
34
54
  }
35
55
 
36
- /**
37
- * Deallocates this handle. This function is invoked on Zombie handles after they have
38
- * been released from V8 and finally
39
- */
40
- void v8_handle_free(v8_handle* handle) {
41
- delete handle;
42
- }
43
-
44
56
  /**
45
57
  * Whenver a V8::C::Handle becomes garbage collected, we do not free it immediately.
46
58
  * instead, we put them into a "zombie" queue, where its corresponding V8 storage cell
@@ -49,8 +61,7 @@ namespace {
49
61
  */
50
62
  void v8_handle_enqueue(v8_handle* handle) {
51
63
  handle->dead = true;
52
- VALUE zombie = Data_Wrap_Struct(rr_v8_handle_class(), 0, v8_handle_free, handle);
53
- rb_ary_unshift(handle_queue, zombie);
64
+ rb_ary_unshift(handle_queue, handle->payload->wrapper);
54
65
  }
55
66
 
56
67
  /**
@@ -63,10 +74,9 @@ namespace {
63
74
  */
64
75
  void v8_handle_dequeue(GCType type, GCCallbackFlags flags) {
65
76
  for (VALUE handle = rb_ary_pop(handle_queue); RTEST(handle); handle = rb_ary_pop(handle_queue)) {
66
- v8_handle* dead = NULL;
67
- Data_Get_Struct(handle, struct v8_handle, dead);
68
- dead->handle.Dispose();
69
- dead->handle.Clear();
77
+ v8_handle::Payload* payload = NULL;
78
+ Data_Get_Struct(handle, struct v8_handle::Payload, payload);
79
+ payload->release();
70
80
  }
71
81
  }
72
82
 
@@ -102,8 +112,7 @@ namespace {
102
112
  rb_funcall(callback, rb_intern("call"), 2, self, parameters);
103
113
  }
104
114
  value.Dispose();
105
- handle->handle.Dispose();
106
- handle->handle.Clear();
115
+ handle->payload->release();
107
116
  handle->dead = true;
108
117
 
109
118
  }
@@ -146,8 +155,8 @@ void rr_init_handle() {
146
155
  rr_define_method(HandleClass, "IsNearDeath", IsNearDeath, 0);
147
156
  rr_define_method(HandleClass, "IsWeak", IsWeak, 0);
148
157
 
149
- handle_queue = rb_ary_new();
150
158
  rb_gc_register_address(&handle_queue);
159
+ handle_queue = rb_ary_new();
151
160
  V8::AddGCPrologueCallback(v8_handle_dequeue);
152
161
  }
153
162
 
@@ -1,5 +1,5 @@
1
1
  #ifndef _RR_V8_HANDLE_
2
- #define _RR_V8_HANDLE_
2
+ #define _RR_V8_HANDLE_
3
3
 
4
4
  #include <v8.h>
5
5
  #include "ruby.h"
@@ -9,10 +9,20 @@
9
9
  * class for all of the low-level proxies that reference into V8
10
10
  */
11
11
  struct v8_handle {
12
+
13
+ struct Payload {
14
+ Payload(v8::Handle<void> object);
15
+ virtual ~Payload();
16
+ void release();
17
+ static void destroy(v8_handle::Payload* payload);
18
+ v8::Persistent<void> handle;
19
+ VALUE wrapper;
20
+ };
21
+
12
22
  v8_handle(v8::Handle<void> object);
13
23
  virtual ~v8_handle();
14
24
 
15
- v8::Persistent<void> handle;
25
+ Payload* payload;
16
26
  bool dead;
17
27
  VALUE weakref_callback;
18
28
  VALUE weakref_callback_parameters;
@@ -23,7 +33,7 @@ void rr_init_handle();
23
33
  v8_handle* rr_v8_handle_raw(VALUE value);
24
34
 
25
35
  template <class T> v8::Persistent<T>& rr_v8_handle(VALUE value) {
26
- return (v8::Persistent<T>&)(rr_v8_handle_raw(value)->handle);
36
+ return (v8::Persistent<T>&)(rr_v8_handle_raw(value)->payload->handle);
27
37
  }
28
38
  VALUE rr_v8_handle_new(VALUE rbclass, v8::Handle<void> handle);
29
39
  VALUE rr_v8_handle_class();
@@ -1,3 +1,3 @@
1
1
  module V8
2
- VERSION = "0.9.1"
2
+ VERSION = "0.9.2beta1"
3
3
  end
metadata CHANGED
@@ -1,8 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: therubyracer
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 0.9.1
4
+ hash: 62196257
5
+ prerelease: 5
6
+ segments:
7
+ - 0
8
+ - 9
9
+ - 2
10
+ - beta
11
+ - 1
12
+ version: 0.9.2beta1
6
13
  platform: ruby
7
14
  authors:
8
15
  - Charles Lowell
@@ -11,53 +18,70 @@ autorequire:
11
18
  bindir: bin
12
19
  cert_chain: []
13
20
 
14
- date: 2011-06-17 00:00:00 -05:00
21
+ date: 2011-06-21 00:00:00 -05:00
15
22
  default_executable:
16
23
  dependencies:
17
24
  - !ruby/object:Gem::Dependency
18
- name: libv8
25
+ type: :runtime
19
26
  requirement: &id001 !ruby/object:Gem::Requirement
20
27
  none: false
21
28
  requirements:
22
29
  - - ~>
23
30
  - !ruby/object:Gem::Version
31
+ hash: 31
32
+ segments:
33
+ - 3
34
+ - 3
35
+ - 10
24
36
  version: 3.3.10
25
- type: :runtime
26
- prerelease: false
27
37
  version_requirements: *id001
38
+ name: libv8
39
+ prerelease: false
28
40
  - !ruby/object:Gem::Dependency
29
- name: rake
41
+ type: :development
30
42
  requirement: &id002 !ruby/object:Gem::Requirement
31
43
  none: false
32
44
  requirements:
33
45
  - - ~>
34
46
  - !ruby/object:Gem::Version
47
+ hash: 57
48
+ segments:
49
+ - 0
50
+ - 9
51
+ - 1
35
52
  version: 0.9.1
36
- type: :development
37
- prerelease: false
38
53
  version_requirements: *id002
54
+ name: rake
55
+ prerelease: false
39
56
  - !ruby/object:Gem::Dependency
40
- name: rspec
57
+ type: :development
41
58
  requirement: &id003 !ruby/object:Gem::Requirement
42
59
  none: false
43
60
  requirements:
44
61
  - - ~>
45
62
  - !ruby/object:Gem::Version
63
+ hash: 3
64
+ segments:
65
+ - 2
66
+ - 0
46
67
  version: "2.0"
47
- type: :development
48
- prerelease: false
49
68
  version_requirements: *id003
69
+ name: rspec
70
+ prerelease: false
50
71
  - !ruby/object:Gem::Dependency
51
- name: rake-compiler
72
+ type: :development
52
73
  requirement: &id004 !ruby/object:Gem::Requirement
53
74
  none: false
54
75
  requirements:
55
76
  - - ">="
56
77
  - !ruby/object:Gem::Version
78
+ hash: 3
79
+ segments:
80
+ - 0
57
81
  version: "0"
58
- type: :development
59
- prerelease: false
60
82
  version_requirements: *id004
83
+ name: rake-compiler
84
+ prerelease: false
61
85
  description: Call javascript code and manipulate javascript objects from ruby. Call ruby code and manipulate ruby objects from javascript.
62
86
  email: cowboyd@thefrontside.net
63
87
  executables:
@@ -174,19 +198,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
174
198
  requirements:
175
199
  - - ">="
176
200
  - !ruby/object:Gem::Version
177
- hash: -3522882523621608294
201
+ hash: 3
178
202
  segments:
179
203
  - 0
180
204
  version: "0"
181
205
  required_rubygems_version: !ruby/object:Gem::Requirement
182
206
  none: false
183
207
  requirements:
184
- - - ">="
208
+ - - ">"
185
209
  - !ruby/object:Gem::Version
186
- hash: -3522882523621608294
210
+ hash: 25
187
211
  segments:
188
- - 0
189
- version: "0"
212
+ - 1
213
+ - 3
214
+ - 1
215
+ version: 1.3.1
190
216
  requirements: []
191
217
 
192
218
  rubyforge_project: therubyracer