Closed nox closed 8 years ago
Looks good with comments addressed. Using a lazy static is a nice solution.
Reviewed 9 of 9 files at r1. Review status: all files reviewed at latest revision, 4 unresolved discussions.
[src/rust.rs, line 122 [r1]](https://reviewable.io:443/reviews/servo/rust-mozjs/267#-KJ1cbP0z76ASsUFqiDZ:-KJ1cbP0z76ASsUFqiD:2012083994) (raw file):_
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());
We still need this assert or some other form of null check. Creating a child runtime is just as fallible as creating the parent runtime, after all.
[src/rust.rs, line 125 [r1]](https://reviewable.io:443/reviews/servo/rust-mozjs/267#-KJ1cj9bFTm7b346r-M:-KJ1cj9bFTm7b346r-Ma:916274856) (raw file):_
assert!(JS_Init()); let runtime = JS_NewRuntime( default_heapsize, ChunkSize as u32, ptr::null_mut());
This should use as small a heap size as possible. The only JS ever running in here should be the self-hosted code. Not sure how best to figure out a good value, though.
src/rust.rs, line 128 [r1] (raw file):
assert!(!runtime.is_null()); let context = JS_NewContext( runtime, default_stacksize as size_t);
Much more important than the heap size, and should be much smaller. 1/16th (512kb) might well be enough, or even 1/32th (256kb).
src/rust.rs, line 130 [r1] (raw file):
runtime, default_stacksize as size_t); assert!(!context.is_null()); TopRuntime(runtime)
It might make sense to trigger a compacting GC at this point, as no new code execution should happen in this runtime afterwards. I also wonder if we can write-protect the runtime's heap afterwards?
Comments from Reviewable
@jandem informs me that both the stack and the heap are allocated lazily, so I guess my comments on their sizes can be safely ignored.
Put back the assertion. LGTM?
Review status: 8 of 9 files reviewed at latest revision, 4 unresolved discussions.
src/rust.rs, line 122 [r1] (raw file):
Done. That was mistakenly removed.
[src/rust.rs, line 125 [r1]](https://reviewable.io:443/reviews/servo/rust-mozjs/267#-KJ1cj9bFTm7b346r-M:-KJ1mslWCvAsMPvcJuLf:791938894) (raw file):_
So I don't need to do anything right? Following your last comment.
src/rust.rs, line 128 [r1] (raw file):
Same question.
src/rust.rs, line 130 [r1] (raw file):
Same question.
Comments from Reviewable
Yes, LGTM.
Reviewed 1 of 1 files at r2. Review status: all files reviewed at latest revision, all discussions resolved.
_Comments from Reviewable_
@bors-servo r+
:key: Insufficient privileges
@bors-servo r=tschneidereit
:pushpin: Commit a301cff has been approved by tschneidereit
:hourglass: Testing commit a301cff with merge c6f6817...
:sunny: Test successful - travis
CC @tschneidereit @Ms2ger @jdm
This change is