mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Auto merge of #12395 - jdm:nowrap, r=Ms2ger
Avoid calling JS_WrapValue for same-compartment DOM reflectors This change shaves off 15-20ns per iteration of the node.firstChild getter test in tests/html/bindings_perf.html. Based on [similar Gecko code](http://searchfox.org/mozilla-central/rev/f43c9e0ffa92e72dbdbcbf57eecf04a43d46da63/dom/bindings/BindingUtils.h#781). --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix (partially) #12358 <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12395) <!-- Reviewable:end -->
This commit is contained in:
commit
e2e7013e76
2 changed files with 17 additions and 12 deletions
|
@ -5533,17 +5533,17 @@ class CGBindingRoot(CGThing):
|
|||
'js::jsapi::{JSJitInfo_AliasSet, JSJitInfo_ArgType, AutoIdVector, CallArgs, FreeOp}',
|
||||
'js::jsapi::{JSITER_SYMBOLS, JSPROP_ENUMERATE, JSPROP_PERMANENT, JSPROP_READONLY, JSPROP_SHARED}',
|
||||
'js::jsapi::{JSCLASS_RESERVED_SLOTS_SHIFT, JSITER_HIDDEN, JSITER_OWNONLY}',
|
||||
'js::jsapi::{GetGlobalForObjectCrossCompartment , GetPropertyKeys, Handle}',
|
||||
'js::jsapi::{GetPropertyKeys, Handle}',
|
||||
'js::jsapi::{HandleId, HandleObject, HandleValue, HandleValueArray}',
|
||||
'js::jsapi::{INTERNED_STRING_TO_JSID, IsCallable, JS_CallFunctionValue}',
|
||||
'js::jsapi::{JS_ComputeThis, JS_CopyPropertiesFrom, JS_ForwardGetPropertyTo}',
|
||||
'js::jsapi::{JS_CopyPropertiesFrom, JS_ForwardGetPropertyTo}',
|
||||
'js::jsapi::{JS_GetClass, JS_GetErrorPrototype, JS_GetFunctionPrototype}',
|
||||
'js::jsapi::{JS_GetGlobalForObject, JS_GetObjectPrototype, JS_GetProperty}',
|
||||
'js::jsapi::{JS_GetPropertyById, JS_GetPropertyDescriptorById, JS_GetReservedSlot}',
|
||||
'js::jsapi::{JS_HasProperty, JS_HasPropertyById, JS_InitializePropertiesFromCompatibleNativeObject}',
|
||||
'js::jsapi::{JS_AtomizeAndPinString, JS_IsExceptionPending, JS_NewObject, JS_NewObjectWithGivenProto}',
|
||||
'js::jsapi::{JS_NewObjectWithoutMetadata, JS_NewStringCopyZ, JS_SetProperty}',
|
||||
'js::jsapi::{JS_SetPrototype, JS_SetReservedSlot, JS_WrapValue, JSAutoCompartment}',
|
||||
'js::jsapi::{JS_AtomizeAndPinString, JS_NewObject, JS_NewObjectWithGivenProto}',
|
||||
'js::jsapi::{JS_NewObjectWithoutMetadata, JS_SetProperty}',
|
||||
'js::jsapi::{JS_SetPrototype, JS_SetReservedSlot, JSAutoCompartment}',
|
||||
'js::jsapi::{JSContext, JSClass, JSFreeOp, JSFunctionSpec}',
|
||||
'js::jsapi::{JSJitGetterCallArgs, JSJitInfo, JSJitMethodCallArgs, JSJitSetterCallArgs}',
|
||||
'js::jsapi::{JSNative, JSObject, JSNativeWrapper, JSPropertySpec}',
|
||||
|
@ -5556,8 +5556,7 @@ class CGBindingRoot(CGThing):
|
|||
'js::jsval::{NullValue, UndefinedValue}',
|
||||
'js::glue::{CallJitMethodOp, CallJitGetterOp, CallJitSetterOp, CreateProxyHandler}',
|
||||
'js::glue::{GetProxyPrivate, NewProxyObject, ProxyTraps}',
|
||||
'js::glue::{RUST_FUNCTION_VALUE_TO_JITINFO}',
|
||||
'js::glue::{RUST_JS_NumberValue, RUST_JSID_IS_STRING, int_to_jsid}',
|
||||
'js::glue::{RUST_JSID_IS_STRING, int_to_jsid}',
|
||||
'js::glue::AppendToAutoIdVector',
|
||||
'js::rust::{GCMethods, define_methods, define_properties}',
|
||||
'dom::bindings',
|
||||
|
|
|
@ -47,9 +47,9 @@ use js::glue::{RUST_JSID_IS_STRING, RUST_JSID_TO_STRING, UnwrapObject};
|
|||
use js::jsapi::{HandleId, HandleObject, HandleValue, JSClass, JSContext};
|
||||
use js::jsapi::{JSObject, JSString, JS_GetArrayBufferViewType, JS_GetClass};
|
||||
use js::jsapi::{JS_GetLatin1StringCharsAndLength, JS_GetObjectAsArrayBufferView};
|
||||
use js::jsapi::{JS_GetReservedSlot, JS_GetTwoByteStringCharsAndLength};
|
||||
use js::jsapi::{JS_GetReservedSlot, JS_GetTwoByteStringCharsAndLength, ToWindowProxyIfWindow};
|
||||
use js::jsapi::{JS_IsArrayObject, JS_NewStringCopyN, JS_StringHasLatin1Chars};
|
||||
use js::jsapi::{JS_WrapValue, MutableHandleValue, Type};
|
||||
use js::jsapi::{JS_WrapValue, MutableHandleValue, Type, IsObjectInContextCompartment};
|
||||
use js::jsval::{ObjectValue, StringValue};
|
||||
use js::rust::ToString;
|
||||
use libc;
|
||||
|
@ -276,9 +276,15 @@ impl ToJSValConvertible for Reflector {
|
|||
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
|
||||
let obj = self.get_jsobject().get();
|
||||
assert!(!obj.is_null());
|
||||
rval.set(ObjectValue(&*obj));
|
||||
if !JS_WrapValue(cx, rval) {
|
||||
panic!("JS_WrapValue failed.");
|
||||
let same_compartment = IsObjectInContextCompartment(obj, cx);
|
||||
if same_compartment {
|
||||
rval.set(ObjectValue(&*ToWindowProxyIfWindow(obj)));
|
||||
} else {
|
||||
rval.set(ObjectValue(&*obj));
|
||||
|
||||
if !JS_WrapValue(cx, rval) {
|
||||
panic!("JS_WrapValue failed.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue