Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change Runtime::new to take a parent runtime #265

Merged
merged 1 commit into from May 23, 2016
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Change Runtime::new to take a parent runtime

SpiderMonkey shares some data, such as the self-hosting compartment and read-only atoms, between runtimes - but only if a parent runtime is passed when calling `JS_NewRuntime`. This is important for both memory usage and performance: compiling the self-hosted JS takes more than 30ms on a desktop machine, so doing that every time, say, a worker is created is quite wasteful.
  • Loading branch information
tschneidereit committed May 23, 2016
commit a493d195583f3ec803570409cfc64f6489be8d91
@@ -116,8 +116,8 @@ impl Runtime {
///
/// Calling this function concurrently can cause segfaults inside
/// SpiderMonkey
pub unsafe fn new() -> Runtime {
let js_runtime = JS_NewRuntime(default_heapsize, ChunkSize as u32, ptr::null_mut());
pub unsafe fn new(parent_rt: *mut JSRuntime) -> Runtime {
let js_runtime = JS_NewRuntime(default_heapsize, ChunkSize as u32, parent_rt);
assert!(!js_runtime.is_null());

// Unconstrain the runtime's threshold on nominal heap size, to avoid
@@ -30,7 +30,7 @@ fn callback() {
unsafe {
JS_Init();

let runtime = Runtime::new();
let runtime = Runtime::new(ptr::null_mut());
let context = runtime.cx();

let h_option = OnNewGlobalHookOption::FireOnNewGlobalHook;
@@ -19,7 +19,7 @@ use std::ptr;
fn evaluate() {
unsafe {
assert!(JS_Init());
let rt = Runtime::new();
let rt = Runtime::new(ptr::null_mut());
let cx = rt.cx();

let global = RootedObject::new(cx,
@@ -20,7 +20,7 @@ fn stack_limit() {
unsafe {
assert!(JS_Init());

let rt = Runtime::new();
let rt = Runtime::new(ptr::null_mut());
let cx = rt.cx();

let h_option = OnNewGlobalHookOption::FireOnNewGlobalHook;
@@ -25,7 +25,7 @@ fn vec_conversion() {
unsafe {
assert!(JS_Init());

let rt = Runtime::new();
let rt = Runtime::new(ptr::null_mut());
let cx = rt.cx();

let h_option = OnNewGlobalHookOption::FireOnNewGlobalHook;
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.