Bug 887016 - Part 4: Add GetOwnNativeGetterPure. r=jandem
☠☠ backed out by dd34be112501 ☠ ☠
authorTooru Fujisawa <arai_a@mac.com>
Sun, 22 Nov 2015 03:01:02 +0900
changeset 290622 67346678966fc8c40546ab49521b43049fcc851f
parent 290621 043f06dd9135a5ce9e716f12805d4df686da2ebc
child 290623 b77cb94666ca383ff7586997aa820b692794f557
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs887016
milestone48.0a1
Bug 887016 - Part 4: Add GetOwnNativeGetterPure. r=jandem
js/src/jsobj.cpp
js/src/jsobj.h
--- a/js/src/jsobj.cpp
+++ b/js/src/jsobj.cpp
@@ -2423,16 +2423,40 @@ js::GetGetterPure(ExclusiveContext* cx, 
         return true;
     }
 
     return pobj->isNative() &&
            NativeGetGetterPureInline(&pobj->as<NativeObject>(), shape, fp);
 }
 
 bool
+js::GetOwnNativeGetterPure(JSContext* cx, JSObject* obj, jsid id, JSNative* native)
+{
+    JS::AutoCheckCannotGC nogc;
+    *native = nullptr;
+    Shape* shape;
+    if (!LookupOwnPropertyPure(cx, obj, id, &shape))
+        return false;
+
+    if (!shape || IsImplicitDenseOrTypedArrayElement(shape) || !shape->hasGetterObject())
+        return true;
+
+    JSObject* getterObj = shape->getterObject();
+    if (!getterObj->is<JSFunction>())
+        return true;
+
+    JSFunction* getter = &getterObj->as<JSFunction>();
+    if (!getter->isNative())
+        return true;
+
+    *native = getter->native();
+    return true;
+}
+
+bool
 JSObject::reportReadOnly(JSContext* cx, jsid id, unsigned report)
 {
     RootedValue val(cx, IdToValue(id));
     return ReportValueErrorFlags(cx, report, JSMSG_READ_ONLY,
                                  JSDVG_IGNORE_STACK, val, nullptr,
                                  nullptr, nullptr);
 }
 
--- a/js/src/jsobj.h
+++ b/js/src/jsobj.h
@@ -1221,16 +1221,19 @@ LookupOwnPropertyPure(ExclusiveContext* 
 
 bool
 GetPropertyPure(ExclusiveContext* cx, JSObject* obj, jsid id, Value* vp);
 
 bool
 GetGetterPure(ExclusiveContext* cx, JSObject* obj, jsid id, JSFunction** fp);
 
 bool
+GetOwnNativeGetterPure(JSContext* cx, JSObject* obj, jsid id, JSNative* native);
+
+bool
 GetOwnPropertyDescriptor(JSContext* cx, HandleObject obj, HandleId id,
                          MutableHandle<PropertyDescriptor> desc);
 
 bool
 GetOwnPropertyDescriptor(JSContext* cx, HandleObject obj, HandleId id, MutableHandleValue vp);
 
 /*
  * ES6 draft rev 32 (2015 Feb 2) 6.2.4.4 FromPropertyDescriptor(Desc).