[INFER] Turn inference on by default, fold JS_DefinePropertyWithType into JS_DefineProperty, bug 619693.
authorBrian Hackett <bhackett1024@gmail.com>
Sun, 06 Mar 2011 22:57:13 -0800
changeset 74724 37ab40cd90adc157137e4571cc7003696cef6519
parent 74723 76e248c0dfa7738833b41b9dd79b44642a533596
child 74725 82b01abdfd9270c46c463efd7047e964f760c202
push id2
push userbsmedberg@mozilla.com
push dateFri, 19 Aug 2011 14:38:13 +0000
bugs619693
milestone2.0b12pre
[INFER] Turn inference on by default, fold JS_DefinePropertyWithType into JS_DefineProperty, bug 619693.
js/src/jsapi.cpp
js/src/jsapi.h
js/src/jsmath.cpp
js/src/jsnum.cpp
js/src/json.cpp
js/src/jsproxy.cpp
js/src/jsreflect.cpp
js/src/jstypedarray.cpp
js/src/perf/jsperf.cpp
js/src/shell/js.cpp
modules/libpref/src/init/all.js
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -3332,16 +3332,19 @@ DefinePropertyById(JSContext *cx, JSObje
     assertSameCompartment(cx, obj, id, value,
                             (attrs & JSPROP_GETTER)
                             ? JS_FUNC_TO_DATA_PTR(JSObject *, getter)
                             : NULL,
                             (attrs & JSPROP_SETTER)
                             ? JS_FUNC_TO_DATA_PTR(JSObject *, setter)
                             : NULL);
 
+    if (!getter || getter == PropertyStub)
+        cx->addTypePropertyId(obj->getType(), id, value);
+
     JSAutoResolveFlags rf(cx, JSRESOLVE_QUALIFIED | JSRESOLVE_DECLARING);
     if (flags != 0 && obj->isNative()) {
         return !!js_DefineNativeProperty(cx, obj, id, value, getter, setter,
                                          attrs, flags, tinyid, NULL);
     }
 
     return obj->defineProperty(cx, id, value, getter, setter, attrs);
 }
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -2249,34 +2249,16 @@ JS_DefineOwnProperty(JSContext *cx, JSOb
 /* Add properties to the type information for obj. */
 
 extern JS_PUBLIC_API(JSBool)
 JS_AddTypeProperty(JSContext *cx, JSObject *obj, const char *name, jsval value);
 
 extern JS_PUBLIC_API(JSBool)
 JS_AddTypePropertyById(JSContext *cx, JSObject *obj, jsid id, jsval value);
 
-static JS_ALWAYS_INLINE JSBool
-JS_DefinePropertyWithType(JSContext *cx, JSObject *obj,
-                          const char *name, jsval value,
-                          JSPropertyOp getter, JSStrictPropertyOp setter, uintN attrs)
-{
-    JS_AddTypeProperty(cx, obj, name, value);
-    return JS_DefineProperty(cx, obj, name, value, getter, setter, attrs);
-}
-
-static JS_ALWAYS_INLINE JSBool
-JS_DefinePropertyWithTypeById(JSContext *cx, JSObject *obj,
-                              jsid id, jsval value,
-                              JSPropertyOp getter, JSStrictPropertyOp setter, uintN attrs)
-{
-    JS_AddTypePropertyById(cx, obj, id, value);
-    return JS_DefinePropertyById(cx, obj, id, value, getter, setter, attrs);
-}
-
 /*
  * Determine the attributes (JSPROP_* flags) of a property on a given object.
  *
  * If the object does not have a property by that name, *foundp will be
  * JS_FALSE and the value of *attrsp is undefined.
  */
 extern JS_PUBLIC_API(JSBool)
 JS_GetPropertyAttributes(JSContext *cx, JSObject *obj, const char *name,
--- a/js/src/jsmath.cpp
+++ b/js/src/jsmath.cpp
@@ -900,18 +900,18 @@ js_InitMathClass(JSContext *cx, JSObject
     if (!Math)
         return NULL;
 
     types::TypeObject *type = cx->newTypeObject(js_Math_str, Math->getProto());
     if (!type)
         return NULL;
     Math->setType(type);
 
-    if (!JS_DefinePropertyWithType(cx, obj, js_Math_str, OBJECT_TO_JSVAL(Math),
-                                   JS_PropertyStub, JS_StrictPropertyStub, 0)) {
+    if (!JS_DefineProperty(cx, obj, js_Math_str, OBJECT_TO_JSVAL(Math),
+                           JS_PropertyStub, JS_StrictPropertyStub, 0)) {
         return NULL;
     }
 
     if (!JS_DefineFunctionsWithPrefix(cx, Math, math_static_methods, js_Math_str))
         return NULL;
     if (!JS_DefineConstDoubles(cx, Math, math_constants))
         return NULL;
 
--- a/js/src/jsnum.cpp
+++ b/js/src/jsnum.cpp
@@ -1093,26 +1093,26 @@ js_InitNumberClass(JSContext *cx, JSObje
     if (!proto || !(ctor = JS_GetConstructor(cx, proto)))
         return NULL;
     proto->setPrimitiveThis(Int32Value(0));
     if (!JS_DefineConstDoubles(cx, ctor, number_constants))
         return NULL;
 
     /* ECMA 15.1.1.1 */
     rt = cx->runtime;
-    if (!JS_DefinePropertyWithType(cx, obj, js_NaN_str, Jsvalify(rt->NaNValue),
-                                   JS_PropertyStub, JS_StrictPropertyStub,
-                                   JSPROP_PERMANENT | JSPROP_READONLY)) {
+    if (!JS_DefineProperty(cx, obj, js_NaN_str, Jsvalify(rt->NaNValue),
+                           JS_PropertyStub, JS_StrictPropertyStub,
+                           JSPROP_PERMANENT | JSPROP_READONLY)) {
         return NULL;
     }
 
     /* ECMA 15.1.1.2 */
-    if (!JS_DefinePropertyWithType(cx, obj, js_Infinity_str, Jsvalify(rt->positiveInfinityValue),
-                                   JS_PropertyStub, JS_StrictPropertyStub,
-                                   JSPROP_PERMANENT | JSPROP_READONLY)) {
+    if (!JS_DefineProperty(cx, obj, js_Infinity_str, Jsvalify(rt->positiveInfinityValue),
+                           JS_PropertyStub, JS_StrictPropertyStub,
+                           JSPROP_PERMANENT | JSPROP_READONLY)) {
         return NULL;
     }
 
     return proto;
 }
 
 namespace v8 {
 namespace internal {
--- a/js/src/json.cpp
+++ b/js/src/json.cpp
@@ -1258,17 +1258,17 @@ js_InitJSONClass(JSContext *cx, JSObject
     if (!JSON)
         return NULL;
 
     TypeObject *type = cx->newTypeObject(js_JSON_str, JSON->getProto());
     if (!type)
         return NULL;
     JSON->setType(type);
 
-    if (!JS_DefinePropertyWithType(cx, obj, js_JSON_str, OBJECT_TO_JSVAL(JSON),
-                                   JS_PropertyStub, JS_StrictPropertyStub, 0))
+    if (!JS_DefineProperty(cx, obj, js_JSON_str, OBJECT_TO_JSVAL(JSON),
+                           JS_PropertyStub, JS_StrictPropertyStub, 0))
         return NULL;
 
     if (!JS_DefineFunctionsWithPrefix(cx, JSON, json_static_methods, js_JSON_str))
         return NULL;
 
     return JSON;
 }
--- a/js/src/jsproxy.cpp
+++ b/js/src/jsproxy.cpp
@@ -1454,16 +1454,16 @@ js_InitProxyClass(JSContext *cx, JSObjec
     if (!module)
         return NULL;
 
     TypeObject *type = cx->newTypeObject(js_ProxyClass.name, module->getProto());
     if (!type)
         return NULL;
     module->setType(type);
 
-    if (!JS_DefinePropertyWithType(cx, obj, "Proxy", OBJECT_TO_JSVAL(module),
-                                   JS_PropertyStub, JS_StrictPropertyStub, 0)) {
+    if (!JS_DefineProperty(cx, obj, "Proxy", OBJECT_TO_JSVAL(module),
+                           JS_PropertyStub, JS_StrictPropertyStub, 0)) {
         return NULL;
     }
     if (!JS_DefineFunctionsWithPrefix(cx, module, static_methods, "Proxy"))
         return NULL;
     return module;
 }
--- a/js/src/jsreflect.cpp
+++ b/js/src/jsreflect.cpp
@@ -3315,18 +3315,18 @@ js_InitReflectClass(JSContext *cx, JSObj
     if (!Reflect)
         return NULL;
 
     types::TypeObject *type = cx->newTypeObject(js_ReflectClass.name, Reflect->getProto());
     if (!type)
         return NULL;
     Reflect->setType(type);
 
-    if (!JS_DefinePropertyWithType(cx, obj, js_Reflect_str, OBJECT_TO_JSVAL(Reflect),
-                                   JS_PropertyStub, JS_StrictPropertyStub, 0)) {
+    if (!JS_DefineProperty(cx, obj, js_Reflect_str, OBJECT_TO_JSVAL(Reflect),
+                           JS_PropertyStub, JS_StrictPropertyStub, 0)) {
         return NULL;
     }
 
     if (!JS_DefineFunctionsWithPrefix(cx, Reflect, static_methods, "Reflect"))
         return NULL;
 
     return Reflect;
 }
--- a/js/src/jstypedarray.cpp
+++ b/js/src/jstypedarray.cpp
@@ -1574,21 +1574,21 @@ do {                                    
         return NULL;                                                           \
     }                                                                          \
     if (!cx->addTypeProperty(proto->getType(), "buffer",                       \
                              (types::jstype) bufferType)) {                    \
         return NULL;                                                           \
     }                                                                          \
     JSObject *ctor = JS_GetConstructor(cx, proto);                             \
     if (!ctor ||                                                               \
-        !JS_DefinePropertyWithType(cx, ctor, "BYTES_PER_ELEMENT",              \
+        !JS_DefineProperty(cx, ctor, "BYTES_PER_ELEMENT",                      \
                            INT_TO_JSVAL(sizeof(_typedArray::ThisType)),        \
                            JS_PropertyStub, JS_StrictPropertyStub,             \
                            JSPROP_PERMANENT | JSPROP_READONLY) ||              \
-        !JS_DefinePropertyWithType(cx, proto, "BYTES_PER_ELEMENT",             \
+        !JS_DefineProperty(cx, proto, "BYTES_PER_ELEMENT",                     \
                            INT_TO_JSVAL(sizeof(_typedArray::ThisType)),        \
                            JS_PropertyStub, JS_StrictPropertyStub,             \
                            JSPROP_PERMANENT | JSPROP_READONLY))                \
     {                                                                          \
         return NULL;                                                           \
     }                                                                          \
     proto->setPrivate(0);                                                      \
 } while (0)
--- a/js/src/perf/jsperf.cpp
+++ b/js/src/perf/jsperf.cpp
@@ -262,18 +262,18 @@ RegisterPerfMeasurement(JSContext *cx, J
     if (!prototype)
         return 0;
 
     JSObject *ctor = JS_GetConstructor(cx, prototype);
     if (!ctor)
         return 0;
 
     for (const pm_const *c = pm_consts; c->name; c++) {
-        if (!JS_DefinePropertyWithType(cx, ctor, c->name, DOUBLE_TO_JSVAL(c->value),
-                                       JS_PropertyStub, JS_StrictPropertyStub, PM_CATTRS))
+        if (!JS_DefineProperty(cx, ctor, c->name, DOUBLE_TO_JSVAL(c->value),
+                               JS_PropertyStub, JS_StrictPropertyStub, PM_CATTRS))
             return 0;
     }
 
     if (!JS_FreezeObject(cx, prototype) ||
         !JS_FreezeObject(cx, ctor)) {
         return 0;
     }
 
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -732,18 +732,18 @@ ProcessArgs(JSContext *cx, JSObject *obj
     /*
      * Create arguments early and define it to root it, so it's safe from any
      * GC calls nested below, and so it is available to -f <file> arguments.
      */
     argsObj = JS_NewArrayObject(cx, 0, NULL);
     if (!argsObj)
         return 1;
 
-    if (!JS_DefinePropertyWithType(cx, obj, "arguments", OBJECT_TO_JSVAL(argsObj),
-                                   NULL, NULL, 0)) {
+    if (!JS_DefineProperty(cx, obj, "arguments", OBJECT_TO_JSVAL(argsObj),
+                           NULL, NULL, 0)) {
         return 1;
     }
 
     length = argc - i;
     for (j = 0; j < length; j++) {
         JSString *str = JS_NewStringCopyZ(cx, argv[i++]);
         if (!str)
             return 1;
@@ -4832,19 +4832,18 @@ split_setup(JSContext *cx, JSBool evalcx
         if (!JS_DefineFunctionsWithPrefix(cx, inner, shell_functions, "Shell") ||
             !JS_DefineProfilingFunctions(cx, inner)) {
             return NULL;
         }
 
         /* Create a dummy arguments object. */
         arguments = JS_NewArrayObject(cx, 0, NULL);
         if (!arguments ||
-            !JS_DefinePropertyWithType(cx, inner, "arguments",
-                                       OBJECT_TO_JSVAL(arguments),
-                                       NULL, NULL, 0)) {
+            !JS_DefineProperty(cx, inner, "arguments", OBJECT_TO_JSVAL(arguments),
+                               NULL, NULL, 0)) {
             return NULL;
         }
     }
 
     JS_ClearScope(cx, outer);
 
 #ifndef LAZY_STANDARD_CLASSES
     if (!JS_InitStandardClasses(cx, inner))
--- a/modules/libpref/src/init/all.js
+++ b/modules/libpref/src/init/all.js
@@ -600,17 +600,17 @@ pref("javascript.options.strict.debug", 
 pref("javascript.options.relimit",          true);
 pref("javascript.options.tracejit.content",  true);
 pref("javascript.options.tracejit.chrome",   true);
 pref("javascript.options.methodjit.content", true);
 pref("javascript.options.methodjit.chrome",  false);
 pref("javascript.options.jitprofiling.content", true);
 pref("javascript.options.jitprofiling.chrome",  false);
 pref("javascript.options.methodjit_always", false);
-pref("javascript.options.typeinference", false);
+pref("javascript.options.typeinference", true);
 // This preference limits the memory usage of javascript.
 // If you want to change these values for your device,
 // please find Bug 417052 comment 17 and Bug 456721
 // Comment 32 and Bug 613551.
 pref("javascript.options.mem.high_water_mark", 128);
 pref("javascript.options.mem.max", -1);
 pref("javascript.options.mem.gc_frequency",   300);
 pref("javascript.options.mem.gc_per_compartment", true);