jbarnette-johnson 1.0.0.20090326161333 → 1.0.0.20090402144841

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG.rdoc CHANGED
@@ -1,5 +1,10 @@
1
- === 1.0.0 / 2008-03-11
1
+ === 1.1.0 (pending)
2
2
 
3
- * 1 major enhancement
4
- * Birthday!
3
+ * First real/RubyForge release!
4
+ * Cleaned up the build.
5
+ * Updated to a more recent SpiderMonkey.
6
+ * Fixed allocation-during-GC bugs.
5
7
 
8
+ === 1.0.0 (2008-03-11)
9
+
10
+ * Birthday!
data/Rakefile CHANGED
@@ -21,6 +21,7 @@ HOE = Hoe.new "johnson", Johnson::VERSION do |p|
21
21
  p.clean_globs << "lib/johnson/spidermonkey.bundle"
22
22
  p.clean_globs << "tmp"
23
23
  p.clean_globs << "vendor/spidermonkey/**/*.OBJ"
24
+ p.clean_globs << "ext/**/*.{o,so,bundle,a,log}"
24
25
 
25
26
  p.extra_deps << "rake"
26
27
  p.extra_dev_deps << "rake-compiler"
@@ -30,6 +30,30 @@ static JSTrapStatus trap_handler( JSContext *UNUSED(context),
30
30
  return JSTRAP_CONTINUE;
31
31
  }
32
32
 
33
+ /*
34
+ * call-seq:
35
+ * clear_trap(script, line_num)
36
+ *
37
+ * Set the trap at +script+ and +line_num+ to +block+
38
+ */
39
+ static VALUE clear_trap(VALUE self, VALUE script, VALUE linenum)
40
+ {
41
+ JohnsonRuntime* runtime;
42
+ Data_Get_Struct(self, JohnsonRuntime, runtime);
43
+
44
+ JSContext * context = johnson_get_current_context(runtime);
45
+ jsval compiled_js;
46
+ if(!convert_to_js(runtime, script, &compiled_js))
47
+ rb_raise(rb_eRuntimeError, "Couldn't get compiled script.");
48
+
49
+ JSScript * js_script = (JSScript *)JS_GetPrivate(context, JSVAL_TO_OBJECT(compiled_js));
50
+
51
+ jsbytecode * pc = JS_LineNumberToPC(context, js_script, (uintN)NUM2INT(linenum));
52
+ JS_ClearTrap(context, js_script, pc, NULL, NULL);
53
+
54
+ return self;
55
+ }
56
+
33
57
  /*
34
58
  * call-seq:
35
59
  * set_trap(script, parsecode, block)
@@ -228,24 +252,21 @@ initialize_native(VALUE self, VALUE UNUSED(options))
228
252
  {
229
253
  JohnsonRuntime* runtime;
230
254
  Data_Get_Struct(self, JohnsonRuntime, runtime);
231
-
255
+
232
256
  if ((runtime->js = JS_NewRuntime(0x100000))
233
257
  && (runtime->jsids = create_id_hash())
234
- && (runtime->rbids = create_id_hash())
235
- )
258
+ && (runtime->rbids = create_id_hash()))
236
259
  {
237
260
  JS_SetRuntimePrivate(runtime->js, (void *)self);
238
261
  JS_SetGCCallbackRT(runtime->js, gc_callback);
239
262
 
240
263
  JSContext* context = johnson_get_current_context(runtime);
241
- if(
242
- (runtime->global = JS_GetGlobalObject(context))
243
- && (JS_AddNamedRoot(context, &(runtime->global), "runtime->global"))
244
- ) {
264
+
265
+ if (runtime->global = JS_GetGlobalObject(context))
245
266
  return self;
246
- }
247
267
  }
248
268
 
269
+ // clean up after an initialization failure
249
270
 
250
271
  if (runtime->rbids)
251
272
  JS_HashTableDestroy(runtime->rbids);
@@ -270,16 +291,18 @@ JSContext* johnson_get_current_context(JohnsonRuntime * runtime)
270
291
 
271
292
  static void deallocate(JohnsonRuntime* runtime)
272
293
  {
273
- JS_RemoveRoot(johnson_get_current_context(runtime), &(runtime->global));
274
-
275
- JSContext *context = NULL;
294
+ // our gc callback can create ruby objects, so disable it
295
+ JS_SetGCCallbackRT(runtime->js, NULL);
296
+
297
+ JSContext *context = NULL;
276
298
  JSContext *iterator = NULL;
277
299
 
278
300
  while ((context = JS_ContextIterator(runtime->js, &iterator)) != NULL) {
301
+ JS_SetContextPrivate(iterator, NULL);
279
302
  JS_DestroyContext(iterator);
280
303
  iterator = NULL;
281
304
  }
282
-
305
+
283
306
  JS_DestroyRuntime(runtime->js);
284
307
  free(runtime);
285
308
  }
@@ -303,4 +326,5 @@ void init_Johnson_SpiderMonkey_Runtime(VALUE spidermonkey)
303
326
  rb_define_method(klass, "evaluate_compiled_script", evaluate_compiled_script, 1);
304
327
  rb_define_private_method(klass, "native_compile", native_compile, 3);
305
328
  rb_define_private_method(klass, "set_trap", set_trap, 3);
329
+ rb_define_private_method(klass, "clear_trap", clear_trap, 2);
306
330
  }
data/johnson.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{johnson}
5
- s.version = "1.0.0.20090326161333"
5
+ s.version = "1.0.0.20090402144841"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["John Barnette", "Aaron Patterson", "Yehuda Katz", "Matthew Draper"]
9
- s.date = %q{2009-03-26}
9
+ s.date = %q{2009-04-02}
10
10
  s.default_executable = %q{johnson}
11
11
  s.description = %q{}
12
12
  s.email = ["jbarnette@rubyforge.org", "aaron.patterson@gmail.com", "wycats@gmail.com", "matthew@trebex.net"]
@@ -30,15 +30,15 @@ Gem::Specification.new do |s|
30
30
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
31
31
  s.add_runtime_dependency(%q<rake>, [">= 0"])
32
32
  s.add_development_dependency(%q<rake-compiler>, [">= 0"])
33
- s.add_development_dependency(%q<hoe>, [">= 1.11.0"])
33
+ s.add_development_dependency(%q<hoe>, [">= 1.12.1"])
34
34
  else
35
35
  s.add_dependency(%q<rake>, [">= 0"])
36
36
  s.add_dependency(%q<rake-compiler>, [">= 0"])
37
- s.add_dependency(%q<hoe>, [">= 1.11.0"])
37
+ s.add_dependency(%q<hoe>, [">= 1.12.1"])
38
38
  end
39
39
  else
40
40
  s.add_dependency(%q<rake>, [">= 0"])
41
41
  s.add_dependency(%q<rake-compiler>, [">= 0"])
42
- s.add_dependency(%q<hoe>, [">= 1.11.0"])
42
+ s.add_dependency(%q<hoe>, [">= 1.12.1"])
43
43
  end
44
44
  end
@@ -50,7 +50,7 @@ module Johnson
50
50
  end
51
51
 
52
52
  def evaluate_compiled_script(script)
53
- delegate.evaluate_compiled_script(script)
53
+ delegate.evaluate_compiled(script)
54
54
  end
55
55
 
56
56
  private
@@ -7,6 +7,7 @@ module Johnson #:nodoc:
7
7
  @debugger = nil
8
8
  @compiled_scripts = {}
9
9
  @gcthings = {}
10
+ @traps = []
10
11
  initialize_native(options)
11
12
  self["Ruby"] = Object
12
13
  end
@@ -42,6 +43,13 @@ module Johnson #:nodoc:
42
43
  evaluate_compiled_script(compiled_script)
43
44
  end
44
45
 
46
+ def evaluate_compiled script
47
+ evaluate_compiled_script(script)
48
+ @traps.each do |trap_tuple|
49
+ clear_trap(*trap_tuple)
50
+ end
51
+ end
52
+
45
53
  ###
46
54
  # Compile +script+ with +filename+ and +linenum+
47
55
  def compile(script, filename=nil, linenum=nil)
@@ -57,6 +65,7 @@ module Johnson #:nodoc:
57
65
 
58
66
  compiled_script = @compiled_scripts[filename]
59
67
  set_trap(compiled_script, linenum, block)
68
+ @traps << [compiled_script, linenum]
60
69
  end
61
70
 
62
71
  class << self
@@ -5,31 +5,31 @@ namespace :test do
5
5
  VALGRIND_BASIC_OPTS = "--num-callers=50 --error-limit=no --partial-loads-ok=yes --undef-value-errors=no"
6
6
 
7
7
  desc "run test suite under valgrind with basic ruby options"
8
- task :valgrind => :build do
9
- cmdline = "valgrind #{VALGRIND_BASIC_OPTS} #{test_suite_cmdline}"
8
+ task :valgrind => :compile do
9
+ cmdline = "valgrind #{VALGRIND_BASIC_OPTS} ruby #{HOE.make_test_cmd}"
10
10
  puts cmdline
11
11
  system cmdline
12
12
  end
13
13
 
14
14
  desc "run test suite under valgrind with memory-fill ruby options"
15
- task :valgrind_mem => :build do
15
+ task :valgrind_mem => :compile do
16
16
  # fill malloced memory with "m" and freed memory with "f"
17
- cmdline = "valgrind #{VALGRIND_BASIC_OPTS} --freelist-vol=100000000 --malloc-fill=6D --free-fill=66 #{test_suite_cmdline}"
17
+ cmdline = "valgrind #{VALGRIND_BASIC_OPTS} --freelist-vol=100000000 --malloc-fill=6D --free-fill=66 ruby #{HOE.make_test_cmd}"
18
18
  puts cmdline
19
19
  system cmdline
20
20
  end
21
21
 
22
22
  desc "run test suite under valgrind with memory-zero ruby options"
23
- task :valgrind_mem0 => :build do
23
+ task :valgrind_mem0 => :compile do
24
24
  # fill malloced and freed memory with 0
25
- cmdline = "valgrind #{VALGRIND_BASIC_OPTS} --freelist-vol=100000000 --malloc-fill=00 --free-fill=00 #{test_suite_cmdline}"
25
+ cmdline = "valgrind #{VALGRIND_BASIC_OPTS} --freelist-vol=100000000 --malloc-fill=00 --free-fill=00 ruby #{HOE.make_test_cmd}"
26
26
  puts cmdline
27
27
  system cmdline
28
28
  end
29
29
 
30
30
  desc "run test suite under gdb"
31
- task :gdb => :build do
32
- cmdline = "gdb --args #{test_suite_cmdline}"
31
+ task :gdb => :compile do
32
+ cmdline = "gdb --args ruby #{HOE.make_test_cmd}"
33
33
  puts cmdline
34
34
  system cmdline
35
35
  end
@@ -411,19 +411,6 @@ endif
411
411
  ifdef CROSS_COMPILE
412
412
  # jscpucfg needs to know when it's supposed to produce a config for the target
413
413
  JSCPUCFG_DEFINES = $(ACDEFINES)
414
-
415
- # This is incredibly hacky. Darwin NSPR uses the same MDCPUCFG for multiple
416
- # processors, and determines which processor to configure for based on
417
- # #ifdef i386. This macro is among the NSPR defines, but is also automatically
418
- # defined by the compiler when building for i386. It therefore needs to be
419
- # defined here if targeting i386, and explicitly undefined otherwise.
420
- ifeq ($(OS_ARCH),Darwin)
421
- ifeq ($(TARGET_CPU),powerpc)
422
- JSCPUCFG_DEFINES += -Ui386
423
- else
424
- JSCPUCFG_DEFINES += -Di386=1
425
- endif
426
- endif
427
414
  endif
428
415
 
429
416
  ifeq ($(OS_ARCH),QNX)
@@ -174,6 +174,7 @@ JS_HFILES = \
174
174
  jsscope.h \
175
175
  jsscript.h \
176
176
  jsstr.h \
177
+ jsutil.h \
177
178
  jsxdrapi.h \
178
179
  jsxml.h \
179
180
  $(NULL)
@@ -94,9 +94,6 @@ endif
94
94
  ifeq ($(OS_ARCH),Linux)
95
95
  OS_CONFIG := Linux_All
96
96
  else
97
- ifeq ($(OS_ARCH),FreeBSD)
98
- OS_CONFIG := FreeBSD
99
- else
100
97
  ifeq ($(OS_ARCH),dgux)
101
98
  OS_CONFIG := dgux
102
99
  else
@@ -107,7 +104,6 @@ OS_CONFIG := $(OS_ARCH)$(OS_OBJTYPE)$(OS_RELEASE)
107
104
  endif
108
105
  endif
109
106
  endif
110
- endif
111
107
 
112
108
  ASFLAGS =
113
109
  DEFINES =