Auto merge of #11173 - servo:requests, r=nox

Stop using JSAutoRequest.

Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data:
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

Either:
- [ ] There are tests for these changes OR
- [X] These changes do not require tests because no functional change

Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11173)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-05-13 06:41:22 -07:00
commit ea84601bf0
13 changed files with 13 additions and 26 deletions

View file

@ -2400,7 +2400,6 @@ class CGWrapMethod(CGAbstractMethod):
if not self.descriptor.isGlobal(): if not self.descriptor.isGlobal():
create = CreateBindingJSObject(self.descriptor, "scope") create = CreateBindingJSObject(self.descriptor, "scope")
return CGGeneric("""\ return CGGeneric("""\
let _ar = JSAutoRequest::new(cx);
let scope = scope.reflector().get_jsobject(); let scope = scope.reflector().get_jsobject();
assert!(!scope.get().is_null()); assert!(!scope.get().is_null());
assert!(((*JS_GetClass(scope.get())).flags & JSCLASS_IS_GLOBAL) != 0); assert!(((*JS_GetClass(scope.get())).flags & JSCLASS_IS_GLOBAL) != 0);
@ -2419,7 +2418,6 @@ Root::from_ref(&*raw)""" % {'copyUnforgeable': unforgeable, 'createObject': crea
else: else:
create = CreateBindingJSObject(self.descriptor) create = CreateBindingJSObject(self.descriptor)
return CGGeneric("""\ return CGGeneric("""\
let _ar = JSAutoRequest::new(cx);
%(createObject)s %(createObject)s
let _ac = JSAutoCompartment::new(cx, obj.ptr); let _ac = JSAutoCompartment::new(cx, obj.ptr);
@ -5546,7 +5544,7 @@ class CGBindingRoot(CGThing):
'js::jsapi::{JS_AtomizeAndPinString, JS_IsExceptionPending, JS_NewObject, JS_NewObjectWithGivenProto}', 'js::jsapi::{JS_AtomizeAndPinString, JS_IsExceptionPending, JS_NewObject, JS_NewObjectWithGivenProto}',
'js::jsapi::{JS_NewObjectWithoutMetadata, JS_NewStringCopyZ, JS_SetProperty}', 'js::jsapi::{JS_NewObjectWithoutMetadata, JS_NewStringCopyZ, JS_SetProperty}',
'js::jsapi::{JS_SetPrototype, JS_SetReservedSlot, JS_WrapValue, JSAutoCompartment}', 'js::jsapi::{JS_SetPrototype, JS_SetReservedSlot, JS_WrapValue, JSAutoCompartment}',
'js::jsapi::{JSAutoRequest, JSContext, JSClass, JSFreeOp, JSFunctionSpec}', 'js::jsapi::{JSContext, JSClass, JSFreeOp, JSFunctionSpec}',
'js::jsapi::{JSJitGetterCallArgs, JSJitInfo, JSJitMethodCallArgs, JSJitSetterCallArgs}', 'js::jsapi::{JSJitGetterCallArgs, JSJitInfo, JSJitMethodCallArgs, JSJitSetterCallArgs}',
'js::jsapi::{JSNative, JSObject, JSNativeWrapper, JSPropertySpec}', 'js::jsapi::{JSNative, JSObject, JSNativeWrapper, JSPropertySpec}',
'js::jsapi::{JSString, JSTracer, JSType, JSTypedMethodJitInfo, JSValueType}', 'js::jsapi::{JSString, JSTracer, JSType, JSTypedMethodJitInfo, JSValueType}',

View file

@ -17,7 +17,7 @@ use dom::window::Window;
use js::JSCLASS_IS_GLOBAL; use js::JSCLASS_IS_GLOBAL;
use js::glue::{CreateWrapperProxyHandler, ProxyTraps, NewWindowProxy}; use js::glue::{CreateWrapperProxyHandler, ProxyTraps, NewWindowProxy};
use js::glue::{GetProxyPrivate, SetProxyExtra, GetProxyExtra}; use js::glue::{GetProxyPrivate, SetProxyExtra, GetProxyExtra};
use js::jsapi::{Handle, HandleId, HandleObject, HandleValue, JSAutoCompartment, JSAutoRequest}; use js::jsapi::{Handle, HandleId, HandleObject, HandleValue, JSAutoCompartment};
use js::jsapi::{JSContext, JSPROP_READONLY, JSErrNum, JSObject, PropertyDescriptor, JS_DefinePropertyById}; use js::jsapi::{JSContext, JSPROP_READONLY, JSErrNum, JSObject, PropertyDescriptor, JS_DefinePropertyById};
use js::jsapi::{JS_ForwardGetPropertyTo, JS_ForwardSetPropertyTo, JS_GetClass, JSTracer, FreeOp}; use js::jsapi::{JS_ForwardGetPropertyTo, JS_ForwardSetPropertyTo, JS_GetClass, JSTracer, FreeOp};
use js::jsapi::{JS_GetOwnPropertyDescriptorById, JS_HasPropertyById, MutableHandle}; use js::jsapi::{JS_GetOwnPropertyDescriptorById, JS_HasPropertyById, MutableHandle};
@ -70,7 +70,6 @@ impl BrowsingContext {
assert!(!handler.is_null()); assert!(!handler.is_null());
let cx = window.get_cx(); let cx = window.get_cx();
let _ar = JSAutoRequest::new(cx);
let parent = window.reflector().get_jsobject(); let parent = window.reflector().get_jsobject();
assert!(!parent.get().is_null()); assert!(!parent.get().is_null());
assert!(((*JS_GetClass(parent.get())).flags & JSCLASS_IS_GLOBAL) != 0); assert!(((*JS_GetClass(parent.get())).flags & JSCLASS_IS_GLOBAL) != 0);

View file

@ -23,7 +23,7 @@ use dom::workerglobalscope::WorkerGlobalScopeInit;
use ipc_channel::ipc::{self, IpcReceiver, IpcSender}; use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
use ipc_channel::router::ROUTER; use ipc_channel::router::ROUTER;
use js::jsapi::{HandleValue, JS_SetInterruptCallback}; use js::jsapi::{HandleValue, JS_SetInterruptCallback};
use js::jsapi::{JSAutoCompartment, JSAutoRequest, JSContext, RootedValue}; use js::jsapi::{JSAutoCompartment, JSContext, RootedValue};
use js::jsval::UndefinedValue; use js::jsval::UndefinedValue;
use js::rust::Runtime; use js::rust::Runtime;
use msg::constellation_msg::PipelineId; use msg::constellation_msg::PipelineId;
@ -347,7 +347,6 @@ impl DedicatedWorkerGlobalScope {
WorkerScriptMsg::DOMMessage(data) => { WorkerScriptMsg::DOMMessage(data) => {
let scope = self.upcast::<WorkerGlobalScope>(); let scope = self.upcast::<WorkerGlobalScope>();
let target = self.upcast(); let target = self.upcast();
let _ar = JSAutoRequest::new(scope.get_cx());
let _ac = JSAutoCompartment::new(scope.get_cx(), let _ac = JSAutoCompartment::new(scope.get_cx(),
scope.reflector().get_jsobject().get()); scope.reflector().get_jsobject().get());
let mut message = RootedValue::new(scope.get_cx(), UndefinedValue()); let mut message = RootedValue::new(scope.get_cx(), UndefinedValue());

View file

@ -25,8 +25,7 @@ use dom::virtualmethods::VirtualMethods;
use dom::window::Window; use dom::window::Window;
use fnv::FnvHasher; use fnv::FnvHasher;
use heapsize::HeapSizeOf; use heapsize::HeapSizeOf;
use js::jsapi::{CompileFunction, JS_GetFunctionObject, RootedValue, RootedFunction}; use js::jsapi::{CompileFunction, JS_GetFunctionObject, RootedValue, RootedFunction, JSAutoCompartment};
use js::jsapi::{JSAutoCompartment, JSAutoRequest};
use js::rust::{AutoObjectVectorWrapper, CompileOptionsWrapper}; use js::rust::{AutoObjectVectorWrapper, CompileOptionsWrapper};
use libc::{c_char, size_t}; use libc::{c_char, size_t};
use std::collections::HashMap; use std::collections::HashMap;
@ -422,7 +421,6 @@ impl EventTarget {
let scopechain = AutoObjectVectorWrapper::new(cx); let scopechain = AutoObjectVectorWrapper::new(cx);
let _ar = JSAutoRequest::new(cx);
let _ac = JSAutoCompartment::new(cx, window.reflector().get_jsobject().get()); let _ac = JSAutoCompartment::new(cx, window.reflector().get_jsobject().get());
let mut handler = RootedFunction::new(cx, ptr::null_mut()); let mut handler = RootedFunction::new(cx, ptr::null_mut());
let rv = unsafe { let rv = unsafe {

View file

@ -30,7 +30,7 @@ use dom::urlhelper::UrlHelper;
use dom::virtualmethods::VirtualMethods; use dom::virtualmethods::VirtualMethods;
use dom::window::{ReflowReason, Window}; use dom::window::{ReflowReason, Window};
use ipc_channel::ipc; use ipc_channel::ipc;
use js::jsapi::{JSAutoCompartment, JSAutoRequest, RootedValue, JSContext, MutableHandleValue}; use js::jsapi::{JSAutoCompartment, RootedValue, JSContext, MutableHandleValue};
use js::jsval::{UndefinedValue, NullValue}; use js::jsval::{UndefinedValue, NullValue};
use layout_interface::ReflowQueryType; use layout_interface::ReflowQueryType;
use msg::constellation_msg::{ConstellationChan, LoadData}; use msg::constellation_msg::{ConstellationChan, LoadData};
@ -162,7 +162,6 @@ impl HTMLIFrameElement {
let window = window_from_node(self); let window = window_from_node(self);
let custom_event = unsafe { let custom_event = unsafe {
let cx = window.get_cx(); let cx = window.get_cx();
let _ar = JSAutoRequest::new(cx);
let _ac = JSAutoCompartment::new(cx, window.reflector().get_jsobject().get()); let _ac = JSAutoCompartment::new(cx, window.reflector().get_jsobject().get());
let mut detail = RootedValue::new(cx, UndefinedValue()); let mut detail = RootedValue::new(cx, UndefinedValue());
let event_name = Atom::from(event.name()); let event_name = Atom::from(event.name());

View file

@ -25,7 +25,7 @@ use dom::eventtarget::EventTarget;
use dom::messageevent::MessageEvent; use dom::messageevent::MessageEvent;
use dom::urlhelper::UrlHelper; use dom::urlhelper::UrlHelper;
use ipc_channel::ipc::{self, IpcReceiver, IpcSender}; use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
use js::jsapi::{JSAutoCompartment, JSAutoRequest, RootedValue}; use js::jsapi::{JSAutoCompartment, RootedValue};
use js::jsapi::{JS_GetArrayBufferData, JS_NewArrayBuffer}; use js::jsapi::{JS_GetArrayBufferData, JS_NewArrayBuffer};
use js::jsval::UndefinedValue; use js::jsval::UndefinedValue;
use libc::{uint32_t, uint8_t}; use libc::{uint32_t, uint8_t};
@ -591,7 +591,6 @@ impl Runnable for MessageReceivedTask {
// global.get_cx() returns a valid `JSContext` pointer, so this is safe. // global.get_cx() returns a valid `JSContext` pointer, so this is safe.
unsafe { unsafe {
let cx = global.r().get_cx(); let cx = global.r().get_cx();
let _ar = JSAutoRequest::new(cx);
let _ac = JSAutoCompartment::new(cx, ws.reflector().get_jsobject().get()); let _ac = JSAutoCompartment::new(cx, ws.reflector().get_jsobject().get());
let mut message = RootedValue::new(cx, UndefinedValue()); let mut message = RootedValue::new(cx, UndefinedValue());
match self.message { match self.message {

View file

@ -37,7 +37,7 @@ use gfx_traits::LayerId;
use ipc_channel::ipc::{self, IpcSender}; use ipc_channel::ipc::{self, IpcSender};
use js::jsapi::{Evaluate2, MutableHandleValue}; use js::jsapi::{Evaluate2, MutableHandleValue};
use js::jsapi::{HandleValue, JSContext}; use js::jsapi::{HandleValue, JSContext};
use js::jsapi::{JSAutoCompartment, JSAutoRequest, JS_GC, JS_GetRuntime, SetWindowProxy}; use js::jsapi::{JSAutoCompartment, JS_GC, JS_GetRuntime, SetWindowProxy};
use js::rust::CompileOptionsWrapper; use js::rust::CompileOptionsWrapper;
use js::rust::Runtime; use js::rust::Runtime;
use layout_interface::{ContentBoxResponse, ContentBoxesResponse, ResolvedStyleResponse, ScriptReflow}; use layout_interface::{ContentBoxResponse, ContentBoxesResponse, ResolvedStyleResponse, ScriptReflow};
@ -843,7 +843,6 @@ impl<'a, T: Reflectable> ScriptHelpers for &'a T {
rval: MutableHandleValue) { rval: MutableHandleValue) {
let global = self.global(); let global = self.global();
let cx = global.r().get_cx(); let cx = global.r().get_cx();
let _ar = JSAutoRequest::new(cx);
let globalhandle = global.r().reflector().get_jsobject(); let globalhandle = global.r().reflector().get_jsobject();
let code: Vec<u16> = code.encode_utf16().collect(); let code: Vec<u16> = code.encode_utf16().collect();
let filename = CString::new(filename).unwrap(); let filename = CString::new(filename).unwrap();
@ -1216,7 +1215,6 @@ impl Window {
self.browsing_context.set(Some(&browsing_context)); self.browsing_context.set(Some(&browsing_context));
let window = self.reflector().get_jsobject(); let window = self.reflector().get_jsobject();
let cx = self.get_cx(); let cx = self.get_cx();
let _ar = JSAutoRequest::new(cx);
let _ac = JSAutoCompartment::new(cx, window.get()); let _ac = JSAutoCompartment::new(cx, window.get());
unsafe { SetWindowProxy(cx, window, browsing_context.reflector().get_jsobject()); } unsafe { SetWindowProxy(cx, window, browsing_context.reflector().get_jsobject()); }
} }

View file

@ -22,7 +22,7 @@ use dom::messageevent::MessageEvent;
use dom::workerglobalscope::WorkerGlobalScopeInit; use dom::workerglobalscope::WorkerGlobalScopeInit;
use ipc_channel::ipc; use ipc_channel::ipc;
use js::jsapi::{HandleValue, JSContext, JSRuntime, RootedValue}; use js::jsapi::{HandleValue, JSContext, JSRuntime, RootedValue};
use js::jsapi::{JSAutoCompartment, JSAutoRequest, JS_RequestInterruptCallback}; use js::jsapi::{JSAutoCompartment, JS_RequestInterruptCallback};
use js::jsval::UndefinedValue; use js::jsval::UndefinedValue;
use js::rust::Runtime; use js::rust::Runtime;
use script_runtime::ScriptChan; use script_runtime::ScriptChan;
@ -133,7 +133,6 @@ impl Worker {
let global = worker.r().global(); let global = worker.r().global();
let target = worker.upcast(); let target = worker.upcast();
let _ar = JSAutoRequest::new(global.r().get_cx());
let _ac = JSAutoCompartment::new(global.r().get_cx(), target.reflector().get_jsobject().get()); let _ac = JSAutoCompartment::new(global.r().get_cx(), target.reflector().get_jsobject().get());
let mut message = RootedValue::new(global.r().get_cx(), UndefinedValue()); let mut message = RootedValue::new(global.r().get_cx(), UndefinedValue());
data.read(global.r(), message.handle_mut()); data.read(global.r(), message.handle_mut());

View file

@ -18,7 +18,7 @@ use dom::window::{base64_atob, base64_btoa};
use dom::workerlocation::WorkerLocation; use dom::workerlocation::WorkerLocation;
use dom::workernavigator::WorkerNavigator; use dom::workernavigator::WorkerNavigator;
use ipc_channel::ipc::IpcSender; use ipc_channel::ipc::IpcSender;
use js::jsapi::{HandleValue, JSAutoRequest, JSContext, JSRuntime, RootedValue}; use js::jsapi::{HandleValue, JSContext, JSRuntime, RootedValue};
use js::jsval::UndefinedValue; use js::jsval::UndefinedValue;
use js::rust::Runtime; use js::rust::Runtime;
use msg::constellation_msg::{ConstellationChan, PipelineId}; use msg::constellation_msg::{ConstellationChan, PipelineId};
@ -329,7 +329,6 @@ impl WorkerGlobalScope {
// TODO: An error needs to be dispatched to the parent. // TODO: An error needs to be dispatched to the parent.
// https://github.com/servo/servo/issues/6422 // https://github.com/servo/servo/issues/6422
println!("evaluate_script failed"); println!("evaluate_script failed");
let _ar = JSAutoRequest::new(self.runtime.cx());
report_pending_exception(self.runtime.cx(), self.reflector().get_jsobject().get()); report_pending_exception(self.runtime.cx(), self.reflector().get_jsobject().get());
} }
} }

View file

@ -53,7 +53,7 @@ use ipc_channel::ipc::{self, IpcSender};
use ipc_channel::router::ROUTER; use ipc_channel::router::ROUTER;
use js::glue::GetWindowProxyClass; use js::glue::GetWindowProxyClass;
use js::jsapi::{DOMProxyShadowsResult, HandleId, HandleObject, RootedValue}; use js::jsapi::{DOMProxyShadowsResult, HandleId, HandleObject, RootedValue};
use js::jsapi::{JSAutoRequest, JSContext, JS_SetWrapObjectCallbacks, JSTracer, SetWindowProxyClass}; use js::jsapi::{JSContext, JS_SetWrapObjectCallbacks, JSTracer, SetWindowProxyClass};
use js::jsval::UndefinedValue; use js::jsval::UndefinedValue;
use js::rust::Runtime; use js::rust::Runtime;
use layout_interface::{ReflowQueryType}; use layout_interface::{ReflowQueryType};
@ -1576,7 +1576,6 @@ impl ScriptThread {
// Turn javascript: URL into JS code to eval, according to the steps in // Turn javascript: URL into JS code to eval, according to the steps in
// https://html.spec.whatwg.org/multipage/#javascript-protocol // https://html.spec.whatwg.org/multipage/#javascript-protocol
let _ar = JSAutoRequest::new(self.get_cx());
// This slice of the URLs serialization is equivalent to (5.) to (7.): // This slice of the URLs serialization is equivalent to (5.) to (7.):
// Start with the scheme data of the parsed URL; // Start with the scheme data of the parsed URL;

View file

@ -1042,7 +1042,7 @@ dependencies = [
[[package]] [[package]]
name = "js" name = "js"
version = "0.1.2" version = "0.1.2"
source = "git+https://github.com/servo/rust-mozjs#8ad6c1148fd77e5b9dc2ce0f0ab40d4f455f6f4e" source = "git+https://github.com/servo/rust-mozjs#2bcfb73419ca893156f48b8e7966f0fc492ccfa0"
dependencies = [ dependencies = [
"heapsize 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",

2
ports/cef/Cargo.lock generated
View file

@ -955,7 +955,7 @@ dependencies = [
[[package]] [[package]]
name = "js" name = "js"
version = "0.1.2" version = "0.1.2"
source = "git+https://github.com/servo/rust-mozjs#8ad6c1148fd77e5b9dc2ce0f0ab40d4f455f6f4e" source = "git+https://github.com/servo/rust-mozjs#2bcfb73419ca893156f48b8e7966f0fc492ccfa0"
dependencies = [ dependencies = [
"heapsize 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",

2
ports/gonk/Cargo.lock generated
View file

@ -947,7 +947,7 @@ dependencies = [
[[package]] [[package]]
name = "js" name = "js"
version = "0.1.2" version = "0.1.2"
source = "git+https://github.com/servo/rust-mozjs#8ad6c1148fd77e5b9dc2ce0f0ab40d4f455f6f4e" source = "git+https://github.com/servo/rust-mozjs#2bcfb73419ca893156f48b8e7966f0fc492ccfa0"
dependencies = [ dependencies = [
"heapsize 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",