openbsd-ports/databases/riak/patches/patch-erlang-js-spidermonkey_c
jmatthew 4542265699 import riak
Riak combines a decentralized key-value store, a flexible map/reduce engine, 
and a friendly HTTP/JSON query interface to provide a database ideally suited 
for Web applications.

ok dlg@
2012-08-24 07:26:29 +00:00

56 lines
2.2 KiB
Plaintext

$OpenBSD: patch-erlang-js-spidermonkey_c,v 1.1.1.1 2012/08/24 07:26:29 jmatthew Exp $
Cope with API change between bundled spidermonkey 1.8 and external 1.9.
Use JS_SetOperationCallback instead of JS_SetBranchCallback to perform
periodic gc, and fix some compiler warnings in the call to JS_DefineFunction.
--- deps/erlang_js/c_src/spidermonkey.c.orig Fri Jul 13 23:29:23 2012
+++ deps/erlang_js/c_src/spidermonkey.c Wed Aug 8 11:35:56 2012
@@ -78,19 +78,19 @@ void on_error(JSContext *context, const char *message,
}
}
-JSBool on_branch(JSContext *context, JSScript *script) {
+JSBool on_operation(JSContext *context) {
JSBool return_value = JS_TRUE;
spidermonkey_state *state = (spidermonkey_state *) JS_GetContextPrivate(context);
- state->branch_count++;
+ state->operation_count++;
if (state->terminate) {
return_value = JS_FALSE;
}
- else if (state->branch_count == 550) {
+ else if (state->operation_count == 550) {
JS_GC(context);
- state->branch_count = 0;
+ state->operation_count = 0;
}
- else if(state->branch_count % 100 == 0) {
+ else if(state->operation_count % 100 == 0) {
JS_MaybeGC(context);
}
@@ -140,7 +140,7 @@ void sm_configure_locale(void) {
spidermonkey_vm *sm_initialize(long thread_stack, long heap_size) {
spidermonkey_vm *vm = ejs_alloc(sizeof(spidermonkey_vm));
spidermonkey_state *state = ejs_alloc(sizeof(spidermonkey_state));
- state->branch_count = 0;
+ state->operation_count = 0;
state->error = NULL;
state->terminate = 0;
int gc_size = (int) heap_size * 0.25;
@@ -158,10 +158,9 @@ spidermonkey_vm *sm_initialize(long thread_stack, long
vm->global = JS_NewObject(vm->context, &global_class, NULL, NULL);
JS_InitStandardClasses(vm->context, vm->global);
JS_SetErrorReporter(vm->context, on_error);
- JS_SetBranchCallback(vm->context, on_branch);
+ JS_SetOperationCallback(vm->context, on_operation);
JS_SetContextPrivate(vm->context, state);
- JSNative *funptr = (JSNative *) *js_log;
- JS_DefineFunction(vm->context, JS_GetGlobalObject(vm->context), "ejsLog", *funptr,
+ JS_DefineFunction(vm->context, JS_GetGlobalObject(vm->context), "ejsLog", (JSNative)js_log,
0, JSFUN_FAST_NATIVE);
end_request(vm);