diff --git a/src/compiler/rust b/src/compiler/rust index 0a677bcf6e3..c822d1070ac 160000 --- a/src/compiler/rust +++ b/src/compiler/rust @@ -1 +1 @@ -Subproject commit 0a677bcf6e359f6f013a7e580ef467b5f389e5b7 +Subproject commit c822d1070ac39871165df30ac8d09e733a6e7fb9 diff --git a/src/components/gfx/font.rs b/src/components/gfx/font.rs index afd35dcbd16..f79d6ca06f6 100644 --- a/src/components/gfx/font.rs +++ b/src/components/gfx/font.rs @@ -363,6 +363,7 @@ impl Font { impl Font { + #[fixed_stack_segment] pub fn draw_text_into_context(&mut self, rctx: &RenderContext, run: &TextRun, diff --git a/src/components/gfx/platform/linux/font.rs b/src/components/gfx/platform/linux/font.rs index aff744cae2d..2bc62b76a53 100644 --- a/src/components/gfx/platform/linux/font.rs +++ b/src/components/gfx/platform/linux/font.rs @@ -62,6 +62,7 @@ pub struct FontHandle { #[unsafe_destructor] impl Drop for FontHandle { + #[fixed_stack_segment] fn drop(&self) { assert!(self.face.is_not_null()); unsafe { @@ -99,6 +100,7 @@ impl FontHandleMethods for FontHandle { Err(()) => Err(()) }; + #[fixed_stack_segment] fn create_face_from_buffer(lib: FT_Library, cbuf: *u8, cbuflen: uint, pt_size: float) -> Result { @@ -130,12 +132,14 @@ impl FontHandleMethods for FontHandle { fn family_name(&self) -> ~str { unsafe { str::raw::from_c_str((*self.face).family_name) } } + #[fixed_stack_segment] fn face_name(&self) -> ~str { unsafe { str::raw::from_c_str(FT_Get_Postscript_Name(self.face)) } } fn is_italic(&self) -> bool { unsafe { (*self.face).style_flags & FT_STYLE_FLAG_ITALIC != 0 } } + #[fixed_stack_segment] fn boldness(&self) -> CSSFontWeight { let default_weight = FontWeight400; if unsafe { (*self.face).style_flags & FT_STYLE_FLAG_BOLD == 0 } { @@ -178,6 +182,7 @@ impl FontHandleMethods for FontHandle { } } + #[fixed_stack_segment] fn glyph_index(&self, codepoint: char) -> Option { assert!(self.face.is_not_null()); @@ -192,6 +197,7 @@ impl FontHandleMethods for FontHandle { } } + #[fixed_stack_segment] fn glyph_h_advance(&self, glyph: GlyphIndex) -> Option { assert!(self.face.is_not_null()); @@ -242,6 +248,7 @@ impl FontHandleMethods for FontHandle { } impl<'self> FontHandle { + #[fixed_stack_segment] fn set_char_size(face: FT_Face, pt_size: float) -> Result<(), ()>{ let char_width = float_to_fixed_ft(pt_size) as FT_F26Dot6; let char_height = float_to_fixed_ft(pt_size) as FT_F26Dot6; @@ -254,6 +261,7 @@ impl<'self> FontHandle { } } + #[fixed_stack_segment] pub fn new_from_file(fctx: &FontContextHandle, file: ~str, style: &SpecifiedFontStyle) -> Result { unsafe { @@ -281,6 +289,7 @@ impl<'self> FontHandle { } } + #[fixed_stack_segment] pub fn new_from_file_unstyled(fctx: &FontContextHandle, file: ~str) -> Result { unsafe { diff --git a/src/components/gfx/platform/linux/font_context.rs b/src/components/gfx/platform/linux/font_context.rs index 5a828ee7438..e2a97f55db6 100644 --- a/src/components/gfx/platform/linux/font_context.rs +++ b/src/components/gfx/platform/linux/font_context.rs @@ -17,6 +17,7 @@ struct FreeTypeLibraryHandle { } impl Drop for FreeTypeLibraryHandle { + #[fixed_stack_segment] fn drop(&self) { assert!(self.ctx.is_not_null()); unsafe { @@ -30,6 +31,7 @@ pub struct FontContextHandle { } impl FontContextHandle { + #[fixed_stack_segment] pub fn new() -> FontContextHandle { unsafe { let ctx: FT_Library = ptr::null(); diff --git a/src/components/gfx/platform/linux/font_list.rs b/src/components/gfx/platform/linux/font_list.rs index 5af148d0626..e5c637d7e53 100644 --- a/src/components/gfx/platform/linux/font_list.rs +++ b/src/components/gfx/platform/linux/font_list.rs @@ -39,6 +39,7 @@ impl FontListHandle { FontListHandle { fctx: fctx.clone() } } + #[fixed_stack_segment] pub fn get_available_families(&self) -> FontFamilyMap { let mut family_map : FontFamilyMap = HashMap::new(); unsafe { @@ -62,6 +63,7 @@ impl FontListHandle { return family_map; } + #[fixed_stack_segment] pub fn load_variations_for_family(&self, family: @mut FontFamily) { debug!("getting variations for %?", family); unsafe { @@ -138,6 +140,7 @@ struct AutoPattern { } impl Drop for AutoPattern { + #[fixed_stack_segment] fn drop(&self) { unsafe { FcPatternDestroy(self.pattern); @@ -145,6 +148,7 @@ impl Drop for AutoPattern { } } +#[fixed_stack_segment] pub fn path_from_identifier(name: ~str, style: &UsedFontStyle) -> Result<~str, ()> { unsafe { let config = FcConfigGetCurrent(); diff --git a/src/components/gfx/text/shaping/harfbuzz.rs b/src/components/gfx/text/shaping/harfbuzz.rs index 75358329e1e..3ef24173851 100644 --- a/src/components/gfx/text/shaping/harfbuzz.rs +++ b/src/components/gfx/text/shaping/harfbuzz.rs @@ -62,6 +62,7 @@ pub struct ShapedGlyphEntry { } impl ShapedGlyphData { + #[fixed_stack_segment] pub fn new(buffer: *hb_buffer_t) -> ShapedGlyphData { unsafe { let glyph_count = 0; @@ -142,6 +143,7 @@ pub struct Shaper { #[unsafe_destructor] impl Drop for Shaper { + #[fixed_stack_segment] fn drop(&self) { unsafe { assert!(self.hb_face.is_not_null()); @@ -157,6 +159,7 @@ impl Drop for Shaper { } impl Shaper { + #[fixed_stack_segment] pub fn new(font: @mut Font) -> Shaper { unsafe { // Indirection for Rust Issue #6248, dynamic freeze scope artifically extended @@ -166,7 +169,7 @@ impl Shaper { }; let hb_face: *hb_face_t = hb_face_create_for_tables(get_font_table_func, font_ptr as *c_void, - null()); + None); let hb_font: *hb_font_t = hb_font_create(hb_face); // Set points-per-em. if zero, performs no hinting in that direction. @@ -181,9 +184,9 @@ impl Shaper { // configure static function callbacks. // NB. This funcs structure could be reused globally, as it never changes. let hb_funcs: *hb_font_funcs_t = hb_font_funcs_create(); - hb_font_funcs_set_glyph_func(hb_funcs, glyph_func, null(), null()); - hb_font_funcs_set_glyph_h_advance_func(hb_funcs, glyph_h_advance_func, null(), null()); - hb_font_set_funcs(hb_font, hb_funcs, font_ptr as *c_void, null()); + hb_font_funcs_set_glyph_func(hb_funcs, glyph_func, null(), None); + hb_font_funcs_set_glyph_h_advance_func(hb_funcs, glyph_h_advance_func, null(), None); + hb_font_set_funcs(hb_font, hb_funcs, font_ptr as *c_void, None); Shaper { font: font, @@ -210,6 +213,7 @@ impl Shaper { impl ShaperMethods for Shaper { /// Calculate the layout metrics associated with the given text when rendered in a specific /// font. + #[fixed_stack_segment] fn shape_text(&self, text: &str, glyphs: &mut GlyphStore) { unsafe { let hb_buffer: *hb_buffer_t = hb_buffer_create(); diff --git a/src/components/main/compositing/mod.rs b/src/components/main/compositing/mod.rs index f5c7f48d3d9..fb8f000ab77 100644 --- a/src/components/main/compositing/mod.rs +++ b/src/components/main/compositing/mod.rs @@ -517,7 +517,7 @@ impl CompositorTask { }; // Enter the main event loop. - let tm = Timer::new().unwrap(); + let mut tm = Timer::new().unwrap(); while !done { // Check for new messages coming from the rendering task. check_for_messages(&self.port); diff --git a/src/components/main/servo.rc b/src/components/main/servo.rc index f1fbcfd2a36..ff68e9fb29c 100755 --- a/src/components/main/servo.rc +++ b/src/components/main/servo.rc @@ -136,7 +136,7 @@ fn run(opts: Opts) { let profiler_chan = profiler_chan.clone(); let period = (period * 1000f) as u64; do spawn { - let tm = Timer::new().unwrap(); + let mut tm = Timer::new().unwrap(); loop { tm.sleep(period); profiler_chan.send(PrintMsg); diff --git a/src/components/script/dom/bindings/codegen/CodegenRust.py b/src/components/script/dom/bindings/codegen/CodegenRust.py index c9dc5d28aee..5aae8dcec5a 100644 --- a/src/components/script/dom/bindings/codegen/CodegenRust.py +++ b/src/components/script/dom/bindings/codegen/CodegenRust.py @@ -1947,8 +1947,8 @@ class MethodDefiner(PropertyDefiner): decls = ''.join([stringDecl(m) for m in array]) return decls + self.generatePrefableArray( array, name, - ' JSFunctionSpec {name: &%s_name as *u8 as *libc::c_char, call: JSNativeWrapper {op: %s, info: %s}, nargs: %s, flags: %s as u16, selfHostedName: 0 as *libc::c_char }', - ' JSFunctionSpec {name: 0 as *libc::c_char, call: JSNativeWrapper {op: 0 as *u8, info: 0 as *JSJitInfo}, nargs: 0, flags: 0, selfHostedName: 0 as *libc::c_char }', + ' JSFunctionSpec {name: &%s_name as *u8 as *libc::c_char, call: JSNativeWrapper {op: Some(%s), info: %s}, nargs: %s, flags: %s as u16, selfHostedName: 0 as *libc::c_char }', + ' JSFunctionSpec {name: 0 as *libc::c_char, call: JSNativeWrapper {op: None, info: 0 as *JSJitInfo}, nargs: 0, flags: 0, selfHostedName: 0 as *libc::c_char }', 'JSFunctionSpec', pref, specData, doIdArrays) @@ -1969,16 +1969,16 @@ class AttrDefiner(PropertyDefiner): def getter(attr): native = ("genericLenientGetter" if attr.hasLenientThis() else "genericGetter") - return ("JSPropertyOpWrapper {op: %(native)s, info: &%(name)s_getterinfo as *JSJitInfo}" + return ("JSPropertyOpWrapper {op: Some(%(native)s), info: &%(name)s_getterinfo as *JSJitInfo}" % {"name" : attr.identifier.name, "native" : native}) def setter(attr): if attr.readonly: - return "JSStrictPropertyOpWrapper {op: 0 as *u8, info: 0 as *JSJitInfo}" + return "JSStrictPropertyOpWrapper {op: None, info: 0 as *JSJitInfo}" native = ("genericLenientSetter" if attr.hasLenientThis() else "genericSetter") - return ("JSStrictPropertyOpWrapper {op: %(native)s, info: &%(name)s_setterinfo as *JSJitInfo}" + return ("JSStrictPropertyOpWrapper {op: Some(%(native)s), info: &%(name)s_setterinfo as *JSJitInfo}" % {"name" : attr.identifier.name, "native" : native}) @@ -1996,7 +1996,7 @@ class AttrDefiner(PropertyDefiner): return decls + self.generatePrefableArray( array, name, ' JSPropertySpec { name: &%s_name as *u8 as *libc::c_char, tinyid: 0, flags: ((%s) & 0xFF) as u8, getter: %s, setter: %s }', - ' JSPropertySpec { name: 0 as *libc::c_char, tinyid: 0, flags: 0, getter: JSPropertyOpWrapper {op: 0 as *u8, info: 0 as *JSJitInfo}, setter: JSStrictPropertyOpWrapper {op: 0 as *u8, info: 0 as *JSJitInfo} }', + ' JSPropertySpec { name: 0 as *libc::c_char, tinyid: 0, flags: 0, getter: JSPropertyOpWrapper {op: None, info: 0 as *JSJitInfo}, setter: JSStrictPropertyOpWrapper {op: None, info: 0 as *JSJitInfo} }', 'JSPropertySpec', PropertyDefiner.getControllingPref, specData, doIdArrays) @@ -2201,7 +2201,7 @@ class CGDOMJSClass(CGThing): #return "extern DOMJSClass Class;\n" return "" def define(self): - traceHook = TRACE_HOOK_NAME if self.descriptor.customTrace else '0 as *u8' + traceHook = "Some(%s)" % TRACE_HOOK_NAME if self.descriptor.customTrace else 'None' return """ static Class_name: [u8, ..%i] = %s; static Class: DOMJSClass = DOMJSClass { @@ -2214,11 +2214,11 @@ static Class: DOMJSClass = DOMJSClass { enumerate: crust::JS_EnumerateStub, resolve: crust::JS_ResolveStub, convert: crust::JS_ConvertStub, - finalize: %s, /* finalize */ - checkAccess: 0 as *u8, /* checkAccess */ - call: 0 as *u8, /* call */ - hasInstance: 0 as *u8, /* hasInstance */ - construct: 0 as *u8, /* construct */ + finalize: Some(%s), /* finalize */ + checkAccess: None, /* checkAccess */ + call: None, /* call */ + hasInstance: None, /* hasInstance */ + construct: None, /* construct */ trace: %s, /* trace */ reserved: (0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, // 05 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, // 10 @@ -2261,12 +2261,12 @@ static PrototypeClass: JSClass = JSClass { enumerate: crust::JS_EnumerateStub, resolve: crust::JS_ResolveStub, convert: crust::JS_ConvertStub, - finalize: 0 as *u8, /* finalize */ - checkAccess: 0 as *u8, /* checkAccess */ - call: 0 as *u8, /* call */ - hasInstance: 0 as *u8, /* hasInstance */ - construct: 0 as *u8, /* construct */ - trace: 0 as *u8, /* trace */ + finalize: None, /* finalize */ + checkAccess: None, /* checkAccess */ + call: None, /* call */ + hasInstance: None, /* hasInstance */ + construct: None, /* construct */ + trace: None, /* trace */ reserved: (0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, // 05 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, // 10 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, // 15 @@ -2402,12 +2402,16 @@ class CGAbstractMethod(CGThing): def _decorators(self): decorators = [] if self.alwaysInline: - decorators.append('#[inline(always)]') + # FIXME Rust #8801 #[inline(always)] and #[fixed_stack_segment] not compatible + # decorators.append('#[inline(always)]') + pass elif self.inline: #decorators.append('inline') pass if self.extern: decorators.append('extern') + if not self.extern: + decorators.append('#[fixed_stack_segment]') if self.static: #decorators.append('static') pass @@ -2696,7 +2700,7 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod): %s);""" % ( "&PrototypeClass" if needInterfacePrototypeObject else "ptr::null()", "&InterfaceObjectClass" if needInterfaceObjectClass else "ptr::null()", - constructHook if needConstructor else "ptr::null()", + "Some(%s)" % constructHook if needConstructor else "None", constructArgs, domClass, arrayPtr("methods"), arrayPtr("attrs"), @@ -3171,13 +3175,13 @@ class CGGenericMethod(CGAbstractBindingMethod): """ def __init__(self, descriptor): args = [Argument('*JSContext', 'cx'), Argument('libc::c_uint', 'argc'), - Argument('*JSVal', 'vp')] + Argument('*mut JSVal', 'vp')] CGAbstractBindingMethod.__init__(self, descriptor, 'genericMethod', args) def generate_code(self): return CGIndenter(CGGeneric( - "let _info: *JSJitInfo = RUST_FUNCTION_VALUE_TO_JITINFO(JS_CALLEE(cx, vp));\n" - "return CallJitMethodOp(_info, cx, obj, this as *libc::c_void, argc, vp);")) + "let _info: *JSJitInfo = RUST_FUNCTION_VALUE_TO_JITINFO(JS_CALLEE(cx, &*vp));\n" + "return CallJitMethodOp(_info, cx, obj, this as *libc::c_void, argc, &*vp);")) class CGAbstractStaticMethod(CGAbstractMethod): """ @@ -3224,8 +3228,8 @@ class CGGenericGetter(CGAbstractBindingMethod): A class for generating the C++ code for an IDL attribute getter. """ def __init__(self, descriptor, lenientThis=False): - args = [Argument('*JSContext', 'cx'), Argument('uint', 'argc'), - Argument('*JSVal', 'vp')] + args = [Argument('*JSContext', 'cx'), Argument('libc::c_uint', 'argc'), + Argument('*mut JSVal', 'vp')] if lenientThis: name = "genericLenientGetter" unwrapFailureCode = ( @@ -3240,8 +3244,8 @@ class CGGenericGetter(CGAbstractBindingMethod): def generate_code(self): return CGIndenter(CGGeneric( - "let info: *JSJitInfo = RUST_FUNCTION_VALUE_TO_JITINFO(JS_CALLEE(cx, vp));\n" - "return CallJitPropertyOp(info, cx, obj, this as *libc::c_void, vp);")) + "let info: *JSJitInfo = RUST_FUNCTION_VALUE_TO_JITINFO(JS_CALLEE(cx, &*vp));\n" + "return CallJitPropertyOp(info, cx, obj, this as *libc::c_void, &*vp);")) class CGSpecializedGetter(CGAbstractExternMethod): """ @@ -3279,7 +3283,7 @@ class CGGenericSetter(CGAbstractBindingMethod): A class for generating the Rust code for an IDL attribute setter. """ def __init__(self, descriptor, lenientThis=False): - args = [Argument('*JSContext', 'cx'), Argument('uint', 'argc'), + args = [Argument('*JSContext', 'cx'), Argument('libc::c_uint', 'argc'), Argument('*mut JSVal', 'vp')] if lenientThis: name = "genericLenientSetter" @@ -3357,7 +3361,7 @@ class CGMemberJITInfo(CGThing): failstr = "true" if infallible else "false" return ("\n" "static %s: JSJitInfo = JSJitInfo {\n" - " op: %s,\n" + " op: %s as *u8,\n" " protoID: %s,\n" " depth: %s,\n" " isInfallible: %s, /* False in setters. */\n" @@ -4388,6 +4392,7 @@ class CGDictionary(CGThing): " return true;\n" " }\n" "\n" if not self.workers else "") + + " #[fixed_stack_segment]\n" + " pub fn Init(&mut self, cx: *JSContext, val: JSVal) -> JSBool {\n" " unsafe {\n" + # NOTE: jsids are per-runtime, so don't use them in workers diff --git a/src/components/script/dom/bindings/conversions.rs b/src/components/script/dom/bindings/conversions.rs index 81f71bcc78e..d1143b502c3 100644 --- a/src/components/script/dom/bindings/conversions.rs +++ b/src/components/script/dom/bindings/conversions.rs @@ -12,12 +12,14 @@ pub trait JSValConvertible { } impl JSValConvertible for u32 { + #[fixed_stack_segment] fn to_jsval(&self) -> JSVal { unsafe { RUST_UINT_TO_JSVAL(*self) } } + #[fixed_stack_segment] fn from_jsval(val: JSVal) -> Option { unsafe { Some(RUST_JSVAL_TO_INT(val) as u32) @@ -26,12 +28,14 @@ impl JSValConvertible for u32 { } impl JSValConvertible for i32 { + #[fixed_stack_segment] fn to_jsval(&self) -> JSVal { unsafe { RUST_UINT_TO_JSVAL(*self as u32) } } + #[fixed_stack_segment] fn from_jsval(val: JSVal) -> Option { unsafe { Some(RUST_JSVAL_TO_INT(val) as i32) @@ -40,12 +44,14 @@ impl JSValConvertible for i32 { } impl JSValConvertible for u16 { + #[fixed_stack_segment] fn to_jsval(&self) -> JSVal { unsafe { RUST_UINT_TO_JSVAL(*self as u32) } } + #[fixed_stack_segment] fn from_jsval(val: JSVal) -> Option { unsafe { Some(RUST_JSVAL_TO_INT(val) as u16) @@ -74,12 +80,14 @@ impl JSValConvertible for bool { } impl JSValConvertible for f32 { + #[fixed_stack_segment] fn to_jsval(&self) -> JSVal { unsafe { RUST_DOUBLE_TO_JSVAL(*self as f64) } } + #[fixed_stack_segment] fn from_jsval(val: JSVal) -> Option { unsafe { Some(RUST_JSVAL_TO_DOUBLE(val) as f32) @@ -88,12 +96,14 @@ impl JSValConvertible for f32 { } impl JSValConvertible for f64 { + #[fixed_stack_segment] fn to_jsval(&self) -> JSVal { unsafe { RUST_DOUBLE_TO_JSVAL(*self as f64) } } + #[fixed_stack_segment] fn from_jsval(val: JSVal) -> Option { unsafe { Some(RUST_JSVAL_TO_DOUBLE(val) as f64) diff --git a/src/components/script/dom/bindings/domparser.rs b/src/components/script/dom/bindings/domparser.rs index f54e7be4d88..42e1f5146a0 100644 --- a/src/components/script/dom/bindings/domparser.rs +++ b/src/components/script/dom/bindings/domparser.rs @@ -34,6 +34,7 @@ impl DerivedWrapper for DOMParser { fail!(~"nyi") } + #[fixed_stack_segment] fn wrap_shared(@mut self, cx: *JSContext, scope: *JSObject, vp: *mut JSVal) -> i32 { let obj = self.wrap_object_shared(cx, scope); if obj.is_null() { diff --git a/src/components/script/dom/bindings/element.rs b/src/components/script/dom/bindings/element.rs index 60d4ca9cfc2..f263f21bfa1 100644 --- a/src/components/script/dom/bindings/element.rs +++ b/src/components/script/dom/bindings/element.rs @@ -42,6 +42,7 @@ extern fn finalize(_fop: *JSFreeOp, obj: *JSObject) { pub extern fn trace(tracer: *mut JSTracer, obj: *JSObject) { let node = unsafe { unwrap(obj) }; + #[fixed_stack_segment] fn trace_node(tracer: *mut JSTracer, node: Option>, name: &str) { if node.is_none() { return; @@ -68,6 +69,7 @@ pub extern fn trace(tracer: *mut JSTracer, obj: *JSObject) { trace_node(tracer, node.prev_sibling(), "prev sibling"); } +#[fixed_stack_segment] pub fn init(compartment: @mut Compartment) { let obj = utils::define_empty_prototype(~"Element", Some(~"Node"), compartment); let attrs = @~[ @@ -75,14 +77,14 @@ pub fn init(compartment: @mut Compartment) { name: compartment.add_name(~"tagName"), tinyid: 0, flags: (JSPROP_ENUMERATE | JSPROP_SHARED | JSPROP_NATIVE_ACCESSORS) as u8, - getter: JSPropertyOpWrapper {op: getTagName, info: null()}, - setter: JSStrictPropertyOpWrapper {op: null(), info: null()}}, + getter: JSPropertyOpWrapper {op: Some(getTagName), info: null()}, + setter: JSStrictPropertyOpWrapper {op: None, info: null()}}, JSPropertySpec { name: null(), tinyid: 0, flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8, - getter: JSPropertyOpWrapper {op: null(), info: null()}, - setter: JSStrictPropertyOpWrapper {op: null(), info: null()}}]; + getter: JSPropertyOpWrapper {op: None, info: null()}, + setter: JSStrictPropertyOpWrapper {op: None, info: null()}}]; compartment.global_props.push(attrs); do attrs.as_imm_buf |specs, _len| { unsafe { @@ -91,22 +93,22 @@ pub fn init(compartment: @mut Compartment) { } let methods = @~[JSFunctionSpec {name: compartment.add_name(~"getClientRects"), - call: JSNativeWrapper {op: getClientRects, info: null()}, + call: JSNativeWrapper {op: Some(getClientRects), info: null()}, nargs: 0, flags: 0, selfHostedName: null()}, JSFunctionSpec {name: compartment.add_name(~"getBoundingClientRect"), - call: JSNativeWrapper {op: getBoundingClientRect, info: null()}, + call: JSNativeWrapper {op: Some(getBoundingClientRect), info: null()}, nargs: 0, flags: 0, selfHostedName: null()}, JSFunctionSpec {name: compartment.add_name(~"setAttribute"), - call: JSNativeWrapper {op: setAttribute, info: null()}, + call: JSNativeWrapper {op: Some(setAttribute), info: null()}, nargs: 0, flags: 0, selfHostedName: null()}, JSFunctionSpec {name: null(), - call: JSNativeWrapper {op: null(), info: null()}, + call: JSNativeWrapper {op: None, info: null()}, nargs: 0, flags: 0, selfHostedName: null()}]; @@ -129,13 +131,13 @@ pub fn init(compartment: @mut Compartment) { JSPropertySpec {name: compartment.add_name(~"width"), tinyid: 0, flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8, - getter: JSPropertyOpWrapper {op: HTMLImageElement_getWidth, info: null()}, - setter: JSStrictPropertyOpWrapper {op: HTMLImageElement_setWidth, info: null()}}, + getter: JSPropertyOpWrapper {op: Some(HTMLImageElement_getWidth), info: null()}, + setter: JSStrictPropertyOpWrapper {op: Some(HTMLImageElement_setWidth), info: null()}}, JSPropertySpec {name: null(), tinyid: 0, flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8, - getter: JSPropertyOpWrapper {op: null(), info: null()}, - setter: JSStrictPropertyOpWrapper {op: null(), info: null()}}]; + getter: JSPropertyOpWrapper {op: None, info: null()}, + setter: JSStrictPropertyOpWrapper {op: None, info: null()}}]; compartment.global_props.push(attrs); do attrs.as_imm_buf |specs, _len| { unsafe { @@ -144,7 +146,7 @@ pub fn init(compartment: @mut Compartment) { } } -extern fn getClientRects(cx: *JSContext, _argc: c_uint, vp: *JSVal) -> JSBool { +extern fn getClientRects(cx: *JSContext, _argc: c_uint, vp: *mut JSVal) -> JSBool { unsafe { let obj = JS_THIS_OBJECT(cx, vp); let mut node = unwrap(obj); @@ -160,7 +162,7 @@ extern fn getClientRects(cx: *JSContext, _argc: c_uint, vp: *JSVal) -> JSBool { } } -extern fn getBoundingClientRect(cx: *JSContext, _argc: c_uint, vp: *JSVal) -> JSBool { +extern fn getBoundingClientRect(cx: *JSContext, _argc: c_uint, vp: *mut JSVal) -> JSBool { unsafe { let obj = JS_THIS_OBJECT(cx, vp); let mut node = unwrap(obj); @@ -176,7 +178,7 @@ extern fn getBoundingClientRect(cx: *JSContext, _argc: c_uint, vp: *JSVal) -> JS } } -extern fn setAttribute(cx: *JSContext, argc: c_uint, vp: *JSVal) -> JSBool { +extern fn setAttribute(cx: *JSContext, argc: c_uint, vp: *mut JSVal) -> JSBool { unsafe { let obj = JS_THIS_OBJECT(cx, vp); let node = unwrap(obj); @@ -278,6 +280,7 @@ extern fn getTagName(cx: *JSContext, _argc: c_uint, vp: *mut JSVal) -> JSBool { return 1; } +#[fixed_stack_segment] pub fn create(cx: *JSContext, node: &mut AbstractNode) -> jsobj { let proto = match node.type_id() { ElementNodeTypeId(HTMLDivElementTypeId) => ~"HTMLDivElement", diff --git a/src/components/script/dom/bindings/node.rs b/src/components/script/dom/bindings/node.rs index 0d7b99776d4..cedea3354e9 100644 --- a/src/components/script/dom/bindings/node.rs +++ b/src/components/script/dom/bindings/node.rs @@ -85,6 +85,7 @@ use js::{JSPROP_ENUMERATE, JSPROP_SHARED, JSVAL_NULL}; use js::{JS_THIS_OBJECT, JSPROP_NATIVE_ACCESSORS}; use servo_util::tree::TreeNodeRef; +#[fixed_stack_segment] pub fn init(compartment: @mut Compartment) { let obj = utils::define_empty_prototype(~"Node", None, compartment); @@ -93,29 +94,29 @@ pub fn init(compartment: @mut Compartment) { name: compartment.add_name(~"firstChild"), tinyid: 0, flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8, - getter: JSPropertyOpWrapper {op: getFirstChild, info: null()}, - setter: JSStrictPropertyOpWrapper {op: null(), info: null()}}, + getter: JSPropertyOpWrapper {op: Some(getFirstChild), info: null()}, + setter: JSStrictPropertyOpWrapper {op: None, info: null()}}, JSPropertySpec { name: compartment.add_name(~"nextSibling"), tinyid: 0, flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8, - getter: JSPropertyOpWrapper {op: getNextSibling, info: null()}, - setter: JSStrictPropertyOpWrapper {op: null(), info: null()}}, + getter: JSPropertyOpWrapper {op: Some(getNextSibling), info: null()}, + setter: JSStrictPropertyOpWrapper {op: None, info: null()}}, JSPropertySpec { name: compartment.add_name(~"nodeType"), tinyid: 0, flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8, - getter: JSPropertyOpWrapper {op: getNodeType, info: null()}, - setter: JSStrictPropertyOpWrapper {op: null(), info: null()}}, + getter: JSPropertyOpWrapper {op: Some(getNodeType), info: null()}, + setter: JSStrictPropertyOpWrapper {op: None, info: null()}}, JSPropertySpec { name: null(), tinyid: 0, flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8, - getter: JSPropertyOpWrapper {op: null(), info: null()}, - setter: JSStrictPropertyOpWrapper {op: null(), info: null()}}]; + getter: JSPropertyOpWrapper {op: None, info: null()}, + setter: JSStrictPropertyOpWrapper {op: None, info: null()}}]; compartment.global_props.push(attrs); do attrs.as_imm_buf |specs, _len| { unsafe { diff --git a/src/components/script/dom/bindings/proxyhandler.rs b/src/components/script/dom/bindings/proxyhandler.rs index 3128c27d727..f0854e63cb4 100644 --- a/src/components/script/dom/bindings/proxyhandler.rs +++ b/src/components/script/dom/bindings/proxyhandler.rs @@ -47,7 +47,7 @@ pub extern fn getPropertyDescriptor(cx: *JSContext, proxy: *JSObject, id: jsid, pub extern fn defineProperty(cx: *JSContext, proxy: *JSObject, id: jsid, desc: *JSPropertyDescriptor) -> JSBool { unsafe { - if ((*desc).attrs & JSPROP_GETTER) != 0 && (*desc).setter == JS_StrictPropertyStub { + if ((*desc).attrs & JSPROP_GETTER) != 0 && (*desc).setter == Some(JS_StrictPropertyStub) { /*return JS_ReportErrorFlagsAndNumber(cx, JSREPORT_WARNING | JSREPORT_STRICT | JSREPORT_STRICT_MODE_ERROR, @@ -66,6 +66,7 @@ pub extern fn defineProperty(cx: *JSContext, proxy: *JSObject, id: jsid, } } +#[fixed_stack_segment] pub fn _obj_toString(cx: *JSContext, className: *libc::c_char) -> *JSString { unsafe { let name = str::raw::from_c_str(className); @@ -88,6 +89,7 @@ pub fn _obj_toString(cx: *JSContext, className: *libc::c_char) -> *JSString { } } +#[fixed_stack_segment] pub fn GetExpandoObject(obj: *JSObject) -> *JSObject { unsafe { assert!(is_dom_proxy(obj)); @@ -100,6 +102,7 @@ pub fn GetExpandoObject(obj: *JSObject) -> *JSObject { } } +#[fixed_stack_segment] pub fn EnsureExpandoObject(cx: *JSContext, obj: *JSObject) -> *JSObject { unsafe { assert!(is_dom_proxy(obj)); @@ -120,7 +123,7 @@ pub fn EnsureExpandoObject(cx: *JSContext, obj: *JSObject) -> *JSObject { pub fn FillPropertyDescriptor(desc: &mut JSPropertyDescriptor, obj: *JSObject, readonly: bool) { desc.obj = obj; desc.attrs = if readonly { JSPROP_READONLY } else { 0 } | JSPROP_ENUMERATE; - desc.getter = ptr::null(); - desc.setter = ptr::null(); + desc.getter = None; + desc.setter = None; desc.shortid = 0; } diff --git a/src/components/script/dom/bindings/text.rs b/src/components/script/dom/bindings/text.rs index efa8cc90206..dc24699a1af 100644 --- a/src/components/script/dom/bindings/text.rs +++ b/src/components/script/dom/bindings/text.rs @@ -67,6 +67,7 @@ pub fn init(compartment: @mut Compartment) { } +#[fixed_stack_segment] pub fn create(cx: *JSContext, node: &mut AbstractNode) -> jsobj { let (proto, instance) = match node.type_id() { TextNodeTypeId => (~"TextPrototype", ~"Text"), diff --git a/src/components/script/dom/bindings/utils.rs b/src/components/script/dom/bindings/utils.rs index 82cb15cdc0f..4b8686cab49 100644 --- a/src/components/script/dom/bindings/utils.rs +++ b/src/components/script/dom/bindings/utils.rs @@ -8,7 +8,9 @@ use dom::bindings::node; use dom::node::{AbstractNode, ScriptView}; use script_task::page_from_context; +use std::libc::c_uint; use std::cast; +use std::cell::Cell; use std::hashmap::HashMap; use std::libc; use std::ptr; @@ -29,6 +31,8 @@ use js::jsapi::{JS_NewStringCopyN, JS_DefineFunctions, JS_DefineProperty}; use js::jsapi::{JS_ValueToString, JS_GetReservedSlot, JS_SetReservedSlot}; use js::jsapi::{JSContext, JSObject, JSBool, jsid, JSClass, JSNative}; use js::jsapi::{JSFunctionSpec, JSPropertySpec, JSVal, JSPropertyDescriptor}; +use js::jsapi::{JSFreeOp, JSTracer}; +use js::jsapi::{JSPropertyOp, JSStrictPropertyOp, JSEnumerateOp, JSResolveOp, JSConvertOp}; use js::jsfriendapi::bindgen::JS_NewObjectWithUniqueType; use js::rust::Compartment; use js::{JSCLASS_HAS_RESERVED_SLOTS, JSPROP_ENUMERATE, JSVAL_NULL}; @@ -56,7 +60,7 @@ pub fn GlobalStaticData() -> GlobalStaticData { } } -extern fn InterfaceObjectToString(cx: *JSContext, _argc: uint, vp: *mut JSVal) -> JSBool { +extern fn InterfaceObjectToString(cx: *JSContext, _argc: c_uint, vp: *mut JSVal) -> JSBool { unsafe { let callee = RUST_JSVAL_TO_OBJECT(*JS_CALLEE(cx, cast::transmute(&vp))); let obj = JS_THIS_OBJECT(cx, cast::transmute(&vp)); @@ -126,6 +130,7 @@ fn is_dom_class(clasp: *JSClass) -> bool { } } +#[fixed_stack_segment] pub fn is_dom_proxy(obj: *JSObject) -> bool { unsafe { (js_IsObjectProxyClass(obj) || js_IsFunctionProxyClass(obj)) && @@ -133,6 +138,7 @@ pub fn is_dom_proxy(obj: *JSObject) -> bool { } } +#[fixed_stack_segment] pub unsafe fn unwrap(obj: *JSObject) -> T { let clasp = JS_GetClass(obj); let slot = if is_dom_class(clasp) { @@ -145,6 +151,7 @@ pub unsafe fn unwrap(obj: *JSObject) -> T { cast::transmute(RUST_JSVAL_TO_PRIVATE(val)) } +#[fixed_stack_segment] pub unsafe fn get_dom_class(obj: *JSObject) -> Result { let clasp = JS_GetClass(obj); if is_dom_class(clasp) { @@ -175,6 +182,7 @@ pub fn unwrap_object(obj: *JSObject, proto_id: PrototypeList::id::ID, proto_d } } +#[fixed_stack_segment] pub fn unwrap_value(val: *JSVal, proto_id: PrototypeList::id::ID, proto_depth: uint) -> Result { unsafe { let obj = RUST_JSVAL_TO_OBJECT(*val); @@ -189,6 +197,7 @@ pub unsafe fn squirrel_away(x: @mut T) -> *rust_box { } //XXX very incomplete +#[fixed_stack_segment] pub fn jsval_to_str(cx: *JSContext, v: JSVal) -> Result<~str, ()> { unsafe { let jsstr; @@ -208,6 +217,7 @@ pub fn jsval_to_str(cx: *JSContext, v: JSVal) -> Result<~str, ()> { } } +#[fixed_stack_segment] pub unsafe fn domstring_to_jsval(cx: *JSContext, string: &DOMString) -> JSVal { match string { &null_string => { @@ -249,72 +259,90 @@ extern fn has_instance(_cx: *JSContext, obj: **JSObject, v: *JSVal, bp: *mut JSB } pub fn prototype_jsclass(name: ~str) -> @fn(compartment: @mut Compartment) -> JSClass { + let name = Cell::new(name); let f: @fn(@mut Compartment) -> JSClass = |compartment: @mut Compartment| { - unsafe { - JSClass { - name: compartment.add_name(name.to_owned()), - flags: 0, - addProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as *u8, - delProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as *u8, - getProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as *u8, - setProperty: GetJSClassHookStubPointer(STRICT_PROPERTY_STUB) as *u8, - enumerate: GetJSClassHookStubPointer(ENUMERATE_STUB) as *u8, - resolve: GetJSClassHookStubPointer(RESOLVE_STUB) as *u8, - convert: GetJSClassHookStubPointer(CONVERT_STUB) as *u8, - finalize: null(), - checkAccess: null(), - call: null(), - hasInstance: has_instance, - construct: null(), - trace: null(), - reserved: (null(), null(), null(), null(), null(), // 05 - null(), null(), null(), null(), null(), // 10 - null(), null(), null(), null(), null(), // 15 - null(), null(), null(), null(), null(), // 20 - null(), null(), null(), null(), null(), // 25 - null(), null(), null(), null(), null(), // 30 - null(), null(), null(), null(), null(), // 35 - null(), null(), null(), null(), null()) // 40 + let name = name.take(); + #[fixed_stack_segment] + fn just_effin_do_it(name: ~str, compartment: @mut Compartment) -> JSClass { + unsafe { + JSClass { + name: compartment.add_name(name.to_owned()), + flags: 0, + addProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as JSPropertyOp, + delProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as JSPropertyOp, + getProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as JSPropertyOp, + setProperty: GetJSClassHookStubPointer(STRICT_PROPERTY_STUB) as JSStrictPropertyOp, + enumerate: GetJSClassHookStubPointer(ENUMERATE_STUB) as JSEnumerateOp, + resolve: GetJSClassHookStubPointer(RESOLVE_STUB) as JSResolveOp, + convert: GetJSClassHookStubPointer(CONVERT_STUB) as JSConvertOp, + finalize: None, + checkAccess: None, + call: None, + hasInstance: Some(has_instance), + construct: None, + trace: None, + reserved: (null(), null(), null(), null(), null(), // 05 + null(), null(), null(), null(), null(), // 10 + null(), null(), null(), null(), null(), // 15 + null(), null(), null(), null(), null(), // 20 + null(), null(), null(), null(), null(), // 25 + null(), null(), null(), null(), null(), // 30 + null(), null(), null(), null(), null(), // 35 + null(), null(), null(), null(), null()) // 40 + } } } + + just_effin_do_it(name, compartment) }; return f; } -pub fn instance_jsclass(name: ~str, finalize: *u8, trace: *u8) +pub fn instance_jsclass(name: ~str, finalize: extern "C" fn(*JSFreeOp, *JSObject), + trace: extern "C" fn(*mut JSTracer, *JSObject)) -> @fn(compartment: @mut Compartment) -> JSClass { + let name = Cell::new(name); let f: @fn(@mut Compartment) -> JSClass = |compartment: @mut Compartment| { - unsafe { - JSClass { - name: compartment.add_name(name.to_owned()), - flags: JSCLASS_HAS_RESERVED_SLOTS(1) | js::JSCLASS_IS_DOMJSCLASS, - addProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as *u8, - delProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as *u8, - getProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as *u8, - setProperty: GetJSClassHookStubPointer(STRICT_PROPERTY_STUB) as *u8, - enumerate: GetJSClassHookStubPointer(ENUMERATE_STUB) as *u8, - resolve: GetJSClassHookStubPointer(RESOLVE_STUB) as *u8, - convert: GetJSClassHookStubPointer(CONVERT_STUB) as *u8, - finalize: finalize, - checkAccess: null(), - call: null(), - hasInstance: has_instance, - construct: null(), - trace: trace, - reserved: (null(), null(), null(), null(), null(), // 05 - null(), null(), null(), null(), null(), // 10 - null(), null(), null(), null(), null(), // 15 - null(), null(), null(), null(), null(), // 20 - null(), null(), null(), null(), null(), // 25 - null(), null(), null(), null(), null(), // 30 - null(), null(), null(), null(), null(), // 35 - null(), null(), null(), null(), null()) // 40 + let name = name.take(); + #[fixed_stack_segment] + fn just_effin_do_it(name: ~str, finalize: extern "C" fn(*JSFreeOp, *JSObject), + trace: extern "C" fn(*mut JSTracer, *JSObject), + compartment: @mut Compartment) -> JSClass { + unsafe { + JSClass { + name: compartment.add_name(name.to_owned()), + flags: JSCLASS_HAS_RESERVED_SLOTS(1) | js::JSCLASS_IS_DOMJSCLASS, + addProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as JSPropertyOp, + delProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as JSPropertyOp, + getProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as JSPropertyOp, + setProperty: GetJSClassHookStubPointer(STRICT_PROPERTY_STUB) as JSStrictPropertyOp, + enumerate: GetJSClassHookStubPointer(ENUMERATE_STUB) as JSEnumerateOp, + resolve: GetJSClassHookStubPointer(RESOLVE_STUB) as JSResolveOp, + convert: GetJSClassHookStubPointer(CONVERT_STUB) as JSConvertOp, + finalize: Some(finalize), + checkAccess: None, + call: None, + hasInstance: Some(has_instance), + construct: None, + trace: Some(trace), + reserved: (null(), null(), null(), null(), null(), // 05 + null(), null(), null(), null(), null(), // 10 + null(), null(), null(), null(), null(), // 15 + null(), null(), null(), null(), null(), // 20 + null(), null(), null(), null(), null(), // 25 + null(), null(), null(), null(), null(), // 30 + null(), null(), null(), null(), null(), // 35 + null(), null(), null(), null(), null()) // 40 + } } } + + just_effin_do_it(name, finalize, trace, compartment) }; return f; } +#[fixed_stack_segment] pub fn define_empty_prototype(name: ~str, proto: Option<~str>, compartment: @mut Compartment) -> js::rust::jsobj { compartment.register_class(prototype_jsclass(name.to_owned())); @@ -330,8 +358,8 @@ pub fn define_empty_prototype(name: ~str, proto: Option<~str>, compartment: @mut unsafe { compartment.define_property(name.to_owned(), RUST_OBJECT_TO_JSVAL(obj.ptr), - GetJSClassHookStubPointer(PROPERTY_STUB) as *u8, - GetJSClassHookStubPointer(STRICT_PROPERTY_STUB) as *u8, + GetJSClassHookStubPointer(PROPERTY_STUB) as JSPropertyOp, + GetJSClassHookStubPointer(STRICT_PROPERTY_STUB) as JSStrictPropertyOp, JSPROP_ENUMERATE); compartment.stash_global_proto(name, obj); return obj; @@ -379,7 +407,7 @@ pub struct NativeProperties { pub struct NativePropertyHooks { resolve_own_property: *u8, - resolve_property: *u8, + resolve_property: extern "C" fn(*JSContext, *JSObject, jsid, bool, *mut JSPropertyDescriptor) -> bool, enumerate_own_properties: *u8, enumerate_properties: *u8, proto_hooks: *NativePropertyHooks @@ -420,6 +448,7 @@ pub struct DOMJSClass { dom_class: DOMClass } +#[fixed_stack_segment] pub fn GetProtoOrIfaceArray(global: *JSObject) -> **JSObject { unsafe { /*assert ((*JS_GetClass(global)).flags & JSCLASS_DOM_GLOBAL) != 0;*/ @@ -427,9 +456,10 @@ pub fn GetProtoOrIfaceArray(global: *JSObject) -> **JSObject { } } +#[fixed_stack_segment] pub fn CreateInterfaceObjects2(cx: *JSContext, global: *JSObject, receiver: *JSObject, protoProto: *JSObject, protoClass: *JSClass, - constructorClass: *JSClass, constructor: JSNative, + constructorClass: *JSClass, constructor: Option, ctorNargs: u32, domClass: *DOMClass, methods: *JSFunctionSpec, @@ -453,7 +483,7 @@ pub fn CreateInterfaceObjects2(cx: *JSContext, global: *JSObject, receiver: *JSO } let mut interface = ptr::null(); - if constructorClass.is_not_null() || constructor.is_not_null() { + if constructorClass.is_not_null() || constructor.is_some() { interface = do name.to_c_str().with_ref |s| { CreateInterfaceObject(cx, global, receiver, constructorClass, constructor, ctorNargs, proto, @@ -471,8 +501,9 @@ pub fn CreateInterfaceObjects2(cx: *JSContext, global: *JSObject, receiver: *JSO } } +#[fixed_stack_segment] fn CreateInterfaceObject(cx: *JSContext, global: *JSObject, receiver: *JSObject, - constructorClass: *JSClass, constructorNative: JSNative, + constructorClass: *JSClass, constructorNative: Option, ctorNargs: u32, proto: *JSObject, staticMethods: *JSFunctionSpec, constants: *ConstantSpec, @@ -486,7 +517,6 @@ fn CreateInterfaceObject(cx: *JSContext, global: *JSObject, receiver: *JSObject, JS_NewObject(cx, constructorClass, functionProto, global) } } else { - assert!(constructorNative.is_not_null()); let fun = JS_NewFunction(cx, constructorNative, ctorNargs, JSFUN_CONSTRUCTOR, global, name); if fun.is_null() { @@ -542,7 +572,7 @@ fn CreateInterfaceObject(cx: *JSContext, global: *JSObject, receiver: *JSObject, if alreadyDefined == 0 && JS_DefineProperty(cx, receiver, name, RUST_OBJECT_TO_JSVAL(constructor), - ptr::null(), ptr::null(), 0) == 0 { + None, None, 0) == 0 { return ptr::null(); } @@ -550,6 +580,7 @@ fn CreateInterfaceObject(cx: *JSContext, global: *JSObject, receiver: *JSObject, } } +#[fixed_stack_segment] fn DefineConstants(cx: *JSContext, obj: *JSObject, constants: *ConstantSpec) -> bool { let mut i = 0; loop { @@ -568,8 +599,8 @@ fn DefineConstants(cx: *JSContext, obj: *JSObject, constants: *ConstantSpec) -> VoidVal => JSVAL_VOID }; if JS_DefineProperty(cx, obj, spec.name, - jsval, ptr::null(), - ptr::null(), + jsval, None, + None, JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT) == 0 { return false; @@ -579,18 +610,21 @@ fn DefineConstants(cx: *JSContext, obj: *JSObject, constants: *ConstantSpec) -> } } +#[fixed_stack_segment] fn DefineMethods(cx: *JSContext, obj: *JSObject, methods: *JSFunctionSpec) -> bool { unsafe { JS_DefineFunctions(cx, obj, methods) != 0 } } +#[fixed_stack_segment] fn DefineProperties(cx: *JSContext, obj: *JSObject, properties: *JSPropertySpec) -> bool { unsafe { JS_DefineProperties(cx, obj, properties) != 0 } } +#[fixed_stack_segment] fn CreateInterfacePrototypeObject(cx: *JSContext, global: *JSObject, parentProto: *JSObject, protoClass: *JSClass, methods: *JSFunctionSpec, @@ -618,11 +652,12 @@ fn CreateInterfacePrototypeObject(cx: *JSContext, global: *JSObject, } } -pub extern fn ThrowingConstructor(_cx: *JSContext, _argc: uint, _vp: *JSVal) -> JSBool { +pub extern fn ThrowingConstructor(_cx: *JSContext, _argc: c_uint, _vp: *mut JSVal) -> JSBool { //XXX should trigger exception here return 0; } +#[fixed_stack_segment] pub fn initialize_global(global: *JSObject) { let protoArray = @mut ([0 as *JSObject, ..PrototypeList::id::_ID_Count as uint]); unsafe { @@ -664,6 +699,7 @@ impl WrapperCache { } } +#[fixed_stack_segment] pub fn WrapNewBindingObject(cx: *JSContext, scope: *JSObject, value: @mut CacheableWrapper, vp: *mut JSVal) -> bool { @@ -687,6 +723,7 @@ pub fn WrapNewBindingObject(cx: *JSContext, scope: *JSObject, } } +#[fixed_stack_segment] pub fn WrapNativeParent(cx: *JSContext, scope: *JSObject, mut p: Option<@mut CacheableWrapper>) -> *JSObject { match p { Some(ref mut p) => { @@ -707,6 +744,7 @@ pub trait BindingObject { fn GetParentObject(&self, cx: *JSContext) -> Option<@mut CacheableWrapper>; } +#[fixed_stack_segment] pub fn GetPropertyOnPrototype(cx: *JSContext, proxy: *JSObject, id: jsid, found: *mut bool, vp: *JSVal) -> bool { unsafe { @@ -730,6 +768,7 @@ pub fn GetPropertyOnPrototype(cx: *JSContext, proxy: *JSObject, id: jsid, found: } } +#[fixed_stack_segment] pub fn GetArrayIndexFromId(_cx: *JSContext, id: jsid) -> Option { unsafe { if RUST_JSID_IS_INT(id) != 0 { @@ -753,6 +792,7 @@ pub fn GetArrayIndexFromId(_cx: *JSContext, id: jsid) -> Option { }*/ } +#[fixed_stack_segment] pub fn XrayResolveProperty(cx: *JSContext, wrapper: *JSObject, id: jsid, @@ -779,9 +819,9 @@ pub fn XrayResolveProperty(cx: *JSContext, RUST_SET_JITINFO(fun, attr.getter.info); let funobj = JS_GetFunctionObject(fun); - (*desc).getter = funobj as *u8; + (*desc).getter = Some(funobj as JSPropertyOp); (*desc).attrs |= JSPROP_GETTER; - if attr.setter.op.is_not_null() { + if attr.setter.op.is_some() { let fun = JS_NewFunction(cx, attr.setter.op, 1, 0, global, ptr::null()); if fun.is_null() { return false @@ -789,10 +829,10 @@ pub fn XrayResolveProperty(cx: *JSContext, RUST_SET_JITINFO(fun, attr.setter.info); let funobj = JS_GetFunctionObject(fun); - (*desc).setter = funobj as *u8; + (*desc).setter = Some(funobj as JSStrictPropertyOp); (*desc).attrs |= JSPROP_SETTER; } else { - (*desc).setter = ptr::null(); + (*desc).setter = None; } } } @@ -802,6 +842,7 @@ pub fn XrayResolveProperty(cx: *JSContext, } } +#[fixed_stack_segment] fn InternJSString(cx: *JSContext, chars: *libc::c_char) -> Option { unsafe { let s = JS_InternString(cx, chars); @@ -834,6 +875,7 @@ pub trait DerivedWrapper { } impl DerivedWrapper for AbstractNode { + #[fixed_stack_segment] fn wrap(&mut self, cx: *JSContext, _scope: *JSObject, vp: *mut JSVal) -> i32 { let cache = self.get_wrappercache(); let wrapper = cache.get_wrapper(); @@ -862,6 +904,7 @@ pub struct EnumEntry { length: uint } +#[fixed_stack_segment] pub fn FindEnumStringIndex(cx: *JSContext, v: JSVal, values: &[EnumEntry]) -> Result { diff --git a/src/components/script/dom/clientrect.rs b/src/components/script/dom/clientrect.rs index a0ad4a96dc1..5062aabdff0 100644 --- a/src/components/script/dom/clientrect.rs +++ b/src/components/script/dom/clientrect.rs @@ -88,6 +88,7 @@ impl DerivedWrapper for ClientRect { fail!(~"nyi") } + #[fixed_stack_segment] fn wrap_shared(@mut self, cx: *JSContext, scope: *JSObject, vp: *mut JSVal) -> i32 { let obj = self.wrap_object_shared(cx, scope); if obj.is_null() { diff --git a/src/components/script/dom/document.rs b/src/components/script/dom/document.rs index 8547a0e3cc7..560618a3adf 100644 --- a/src/components/script/dom/document.rs +++ b/src/components/script/dom/document.rs @@ -85,6 +85,7 @@ pub struct Document { } impl Document { + #[fixed_stack_segment] pub fn new(root: AbstractNode, window: Option<@mut Window>, doctype: DocumentType) -> Document { let compartment = unsafe {(*window.get_ref().page).js_info.get_ref().js_compartment }; do root.with_base |base| { @@ -149,6 +150,7 @@ impl BindingObject for AbstractDocument { } impl DerivedWrapper for AbstractDocument { + #[fixed_stack_segment] fn wrap(&mut self, _cx: *JSContext, _scope: *JSObject, vp: *mut JSVal) -> i32 { let cache = self.get_wrappercache(); let wrapper = cache.get_wrapper(); @@ -446,6 +448,7 @@ impl Document { } } + #[fixed_stack_segment] pub fn teardown(&self) { unsafe { let compartment = (*self.window.get_ref().page).js_info.get_ref().js_compartment; diff --git a/src/components/script/dom/event.rs b/src/components/script/dom/event.rs index 78ccfa7e759..b8e17706c07 100644 --- a/src/components/script/dom/event.rs +++ b/src/components/script/dom/event.rs @@ -139,6 +139,7 @@ impl DerivedWrapper for Event { fail!(~"nyi") } + #[fixed_stack_segment] fn wrap_shared(@mut self, cx: *JSContext, scope: *JSObject, vp: *mut JSVal) -> i32 { let obj = self.wrap_object_shared(cx, scope); if obj.is_null() { diff --git a/src/components/script/dom/eventtarget.rs b/src/components/script/dom/eventtarget.rs index 84da6b182ae..74e2a0a9bca 100644 --- a/src/components/script/dom/eventtarget.rs +++ b/src/components/script/dom/eventtarget.rs @@ -53,6 +53,7 @@ impl DerivedWrapper for EventTarget { fail!(~"nyi") } + #[fixed_stack_segment] fn wrap_shared(@mut self, cx: *JSContext, scope: *JSObject, vp: *mut JSVal) -> i32 { let obj = self.wrap_object_shared(cx, scope); if obj.is_null() { diff --git a/src/components/script/dom/formdata.rs b/src/components/script/dom/formdata.rs index 873b539fdc3..4bac8e18966 100644 --- a/src/components/script/dom/formdata.rs +++ b/src/components/script/dom/formdata.rs @@ -76,6 +76,7 @@ impl DerivedWrapper for FormData { fail!(~"nyi") } + #[fixed_stack_segment] fn wrap_shared(@mut self, cx: *JSContext, scope: *JSObject, vp: *mut JSVal) -> i32 { let obj = self.wrap_object_shared(cx, scope); if obj.is_null() { diff --git a/src/components/script/dom/mouseevent.rs b/src/components/script/dom/mouseevent.rs index c8bc2da6d06..fe986d581a0 100644 --- a/src/components/script/dom/mouseevent.rs +++ b/src/components/script/dom/mouseevent.rs @@ -165,6 +165,7 @@ impl DerivedWrapper for MouseEvent { fail!(~"nyi") } + #[fixed_stack_segment] fn wrap_shared(@mut self, cx: *JSContext, scope: *JSObject, vp: *mut JSVal) -> i32 { let obj = self.wrap_object_shared(cx, scope); if obj.is_null() { diff --git a/src/components/script/dom/uievent.rs b/src/components/script/dom/uievent.rs index bc13edd7577..c9d67c8d7f9 100644 --- a/src/components/script/dom/uievent.rs +++ b/src/components/script/dom/uievent.rs @@ -139,6 +139,7 @@ impl DerivedWrapper for UIEvent { fail!(~"nyi") } + #[fixed_stack_segment] fn wrap_shared(@mut self, cx: *JSContext, scope: *JSObject, vp: *mut JSVal) -> i32 { let obj = self.wrap_object_shared(cx, scope); if obj.is_null() { diff --git a/src/components/script/dom/window.rs b/src/components/script/dom/window.rs index 38f7901eafb..84644c7acbf 100644 --- a/src/components/script/dom/window.rs +++ b/src/components/script/dom/window.rs @@ -14,9 +14,11 @@ use servo_msg::compositor_msg::ScriptListener; use js::glue::*; use js::jsapi::{JSObject, JSContext}; +use js::jsapi::{JSPropertyOp, JSStrictPropertyOp}; use js::{JSVAL_NULL, JSPROP_ENUMERATE}; use std::cast; +use std::cell::Cell; use std::comm; use std::comm::SharedChan; use std::io; @@ -146,9 +148,10 @@ impl Window { // Post a delayed message to the per-window timer task; it will dispatch it // to the relevant script handler that will deal with it. - let tm = Timer::new().unwrap(); + let tm = Cell::new(Timer::new().unwrap()); let chan = self.timer_chan.clone(); do spawn { + let mut tm = tm.take(); tm.sleep(timeout); chan.send(TimerMessage_Fire(~TimerData { funval: callback, @@ -164,6 +167,7 @@ impl Window { } } + #[fixed_stack_segment] pub fn new(page: *mut Page, script_chan: ScriptChan, compositor: @ScriptListener) -> @mut Window { let script_chan_clone = script_chan.clone(); @@ -194,8 +198,8 @@ impl Window { win.wrap_object_shared(compartment.cx.ptr, ptr::null()); //XXXjdm proper scope compartment.define_property(~"window", RUST_OBJECT_TO_JSVAL((*cache).wrapper), - GetJSClassHookStubPointer(PROPERTY_STUB) as *u8, - GetJSClassHookStubPointer(STRICT_PROPERTY_STUB) as *u8, + GetJSClassHookStubPointer(PROPERTY_STUB) as JSPropertyOp, + GetJSClassHookStubPointer(STRICT_PROPERTY_STUB) as JSStrictPropertyOp, JSPROP_ENUMERATE); } win diff --git a/src/components/script/script_task.rs b/src/components/script/script_task.rs index 870dec7468d..b4a891629c2 100644 --- a/src/components/script/script_task.rs +++ b/src/components/script/script_task.rs @@ -368,6 +368,7 @@ pub struct ScriptTask { } /// Returns the relevant page from the associated JS Context. +#[fixed_stack_segment] pub fn page_from_context(js_context: *JSContext) -> *mut Page { unsafe { JS_GetContextPrivate(js_context) as *mut Page @@ -503,6 +504,7 @@ impl ScriptTask { } /// Handles a timer that fired. + #[fixed_stack_segment] fn handle_fire_timer_msg(&mut self, id: PipelineId, timer_data: ~TimerData) { let page = self.page_tree.find(id).expect("ScriptTask: received fire timer msg for a pipeline ID not associated with this script task. This is a bug.").page; diff --git a/src/platform/macos/rust-cocoa b/src/platform/macos/rust-cocoa index 25495d9a80f..fcc8d5865e0 160000 --- a/src/platform/macos/rust-cocoa +++ b/src/platform/macos/rust-cocoa @@ -1 +1 @@ -Subproject commit 25495d9a80f11fdde4fa3cc6bcb3c0ea7462e0bb +Subproject commit fcc8d5865e0002d8d75f1098e956c120d8131c8d diff --git a/src/platform/macos/rust-core-foundation b/src/platform/macos/rust-core-foundation index c5dafee99ad..9755a007a02 160000 --- a/src/platform/macos/rust-core-foundation +++ b/src/platform/macos/rust-core-foundation @@ -1 +1 @@ -Subproject commit c5dafee99adea0a31acea07dce09d4f81271a14a +Subproject commit 9755a007a0294294740d728ba14de30b45b769e5 diff --git a/src/platform/macos/rust-core-graphics b/src/platform/macos/rust-core-graphics index 479bccc6f32..4c4662a5d60 160000 --- a/src/platform/macos/rust-core-graphics +++ b/src/platform/macos/rust-core-graphics @@ -1 +1 @@ -Subproject commit 479bccc6f323bc698856f3dc5a9ab93f4ffc8958 +Subproject commit 4c4662a5d6077b547466d33c9a00cb33df9f6f26 diff --git a/src/platform/macos/rust-core-text b/src/platform/macos/rust-core-text index d0c3681561e..36b060d0aef 160000 --- a/src/platform/macos/rust-core-text +++ b/src/platform/macos/rust-core-text @@ -1 +1 @@ -Subproject commit d0c3681561eb83b85773207e44bd2c22aa8445d2 +Subproject commit 36b060d0aef4b3d3f644ef221a0aaca4cd31bcdb diff --git a/src/platform/macos/rust-io-surface b/src/platform/macos/rust-io-surface index 0679efa35b6..e775ce635a0 160000 --- a/src/platform/macos/rust-io-surface +++ b/src/platform/macos/rust-io-surface @@ -1 +1 @@ -Subproject commit 0679efa35b682863d25ac19fdb520c35f9a364a5 +Subproject commit e775ce635a063bf1d5d6b5b0c5339cbb818116ab diff --git a/src/support/alert/rust-alert b/src/support/alert/rust-alert index 3f4841a4853..6fbd1581ae7 160000 --- a/src/support/alert/rust-alert +++ b/src/support/alert/rust-alert @@ -1 +1 @@ -Subproject commit 3f4841a48534b167284ea04b0c2b5952fef936e7 +Subproject commit 6fbd1581ae7baede892c543c05f3509ded1ce8ed diff --git a/src/support/azure/rust-azure b/src/support/azure/rust-azure index cb2c8b0e28b..f564836fb59 160000 --- a/src/support/azure/rust-azure +++ b/src/support/azure/rust-azure @@ -1 +1 @@ -Subproject commit cb2c8b0e28b9e5bd957217109709f2603d7a5e78 +Subproject commit f564836fb59e3a37b7cd9c903bd6282b61a2fea4 diff --git a/src/support/css/rust-cssparser b/src/support/css/rust-cssparser index 77921ee3f24..8700565717e 160000 --- a/src/support/css/rust-cssparser +++ b/src/support/css/rust-cssparser @@ -1 +1 @@ -Subproject commit 77921ee3f243ab90944ec44131ec98d20bc9551f +Subproject commit 8700565717e8c94f6615761f074dafe8e6283d9f diff --git a/src/support/glfw/glfw-rs b/src/support/glfw/glfw-rs index 16fe7a91f0c..e8377820c6a 160000 --- a/src/support/glfw/glfw-rs +++ b/src/support/glfw/glfw-rs @@ -1 +1 @@ -Subproject commit 16fe7a91f0cb201a461b8d05340b859e8f578a8f +Subproject commit e8377820c6ae53973202f19aa2988bd8bef07dff diff --git a/src/support/harfbuzz/rust-harfbuzz b/src/support/harfbuzz/rust-harfbuzz index ca00f10d255..1ed1ed819a9 160000 --- a/src/support/harfbuzz/rust-harfbuzz +++ b/src/support/harfbuzz/rust-harfbuzz @@ -1 +1 @@ -Subproject commit ca00f10d255757d4f112a68b17f37afdc5462147 +Subproject commit 1ed1ed819a90fc6c559282d3a5c02fc8cf3fba09 diff --git a/src/support/hubbub/rust-hubbub b/src/support/hubbub/rust-hubbub index b99f72ccde8..df7d4e1467a 160000 --- a/src/support/hubbub/rust-hubbub +++ b/src/support/hubbub/rust-hubbub @@ -1 +1 @@ -Subproject commit b99f72ccde8ca973add1246426540849ffc50792 +Subproject commit df7d4e1467a2341a4b4186d848df1d1d0adf9b7c diff --git a/src/support/netsurfcss/rust-netsurfcss b/src/support/netsurfcss/rust-netsurfcss index a55ab9e2834..5f144e1c22c 160000 --- a/src/support/netsurfcss/rust-netsurfcss +++ b/src/support/netsurfcss/rust-netsurfcss @@ -1 +1 @@ -Subproject commit a55ab9e2834b1cc898e68a02795ab68861f95f73 +Subproject commit 5f144e1c22ca6d944333ff854a3b0a88d3aa04d7 diff --git a/src/support/opengles/rust-opengles b/src/support/opengles/rust-opengles index ec61bd34561..6286216e162 160000 --- a/src/support/opengles/rust-opengles +++ b/src/support/opengles/rust-opengles @@ -1 +1 @@ -Subproject commit ec61bd34561ec6dd22d792713d385f7480863d38 +Subproject commit 6286216e162319c049e3aa7c8435478668bb06d2 diff --git a/src/support/png/rust-png b/src/support/png/rust-png index d01eb726c0d..698124d5994 160000 --- a/src/support/png/rust-png +++ b/src/support/png/rust-png @@ -1 +1 @@ -Subproject commit d01eb726c0dcd46d71611e524ede00d28f382f29 +Subproject commit 698124d5994d99183cbc51d07d15d1c16b0f75a4 diff --git a/src/support/sharegl/sharegl b/src/support/sharegl/sharegl index e677e258612..8dc1939cdf3 160000 --- a/src/support/sharegl/sharegl +++ b/src/support/sharegl/sharegl @@ -1 +1 @@ -Subproject commit e677e2586128acfbae7517a4916e7ea826ab3206 +Subproject commit 8dc1939cdf37dda742d4910e3265cf03c0fc9609 diff --git a/src/support/spidermonkey/rust-mozjs b/src/support/spidermonkey/rust-mozjs index 9278870fc5b..df9286ea88a 160000 --- a/src/support/spidermonkey/rust-mozjs +++ b/src/support/spidermonkey/rust-mozjs @@ -1 +1 @@ -Subproject commit 9278870fc5b79678a04ebd2d9eca305ac1706892 +Subproject commit df9286ea88a2552690cc80e3232f854412deb3dc diff --git a/src/support/stb-image/rust-stb-image b/src/support/stb-image/rust-stb-image index 2fdf1f166a7..095ca819d5e 160000 --- a/src/support/stb-image/rust-stb-image +++ b/src/support/stb-image/rust-stb-image @@ -1 +1 @@ -Subproject commit 2fdf1f166a7e8d0930b9e55a91601a4fcb35357f +Subproject commit 095ca819d5edd7ba1f63cc4279c261d74138b5d5 diff --git a/src/support/wapcaplet/rust-wapcaplet b/src/support/wapcaplet/rust-wapcaplet index 89029c798d3..881bdb753b3 160000 --- a/src/support/wapcaplet/rust-wapcaplet +++ b/src/support/wapcaplet/rust-wapcaplet @@ -1 +1 @@ -Subproject commit 89029c798d3b4a95a41c695e565d13b47b4a5b90 +Subproject commit 881bdb753b3a51023d54b653cd88b7e266788476