Bug 1029933 - Tweak GenericCreateConstructor to make it usable with Error. r=Waldo
authorBobby Holley <bobbyholley@gmail.com>
Fri, 04 Jul 2014 12:41:28 -0700
changeset 192461 a7b254ac4fc4faaff076d9adadd74c21aa794768
parent 192460 30c45b56a2ef3e4a3ceac6d9328922606bc1cfd5
child 192462 7750f3e24883a7f3ac3a3988122829b50e28026d
push id45846
push userbobbyholley@gmail.com
push dateFri, 04 Jul 2014 19:41:43 +0000
treeherdermozilla-inbound@7750f3e24883 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersWaldo
bugs1029933
milestone33.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1029933 - Tweak GenericCreateConstructor to make it usable with Error. r=Waldo
js/src/jsarray.cpp
js/src/jsdate.cpp
js/src/vm/GlobalObject.h
js/src/vm/TypedArrayObject.cpp
--- a/js/src/jsarray.cpp
+++ b/js/src/jsarray.cpp
@@ -3124,17 +3124,17 @@ const Class ArrayObject::class_ = {
     JS_ResolveStub,
     JS_ConvertStub,
     nullptr,
     nullptr,        /* call        */
     nullptr,        /* hasInstance */
     nullptr,        /* construct   */
     nullptr,        /* trace       */
     {
-        GenericCreateConstructor<js_Array, NAME_OFFSET(Array), 1>,
+        GenericCreateConstructor<js_Array, 1, JSFunction::FinalizeKind>,
         CreateArrayPrototype,
         array_static_methods,
         array_methods
     }
 };
 
 /*
  * Array allocation functions.
--- a/js/src/jsdate.cpp
+++ b/js/src/jsdate.cpp
@@ -3020,17 +3020,17 @@ const Class DateObject::class_ = {
     JS_ResolveStub,
     date_convert,
     nullptr,                 /* finalize */
     nullptr,                 /* call */
     nullptr,                 /* hasInstance */
     nullptr,                 /* construct */
     nullptr,                 /* trace */
     {
-        GenericCreateConstructor<js_Date, NAME_OFFSET(Date), MAXARGS>,
+        GenericCreateConstructor<js_Date, MAXARGS, JSFunction::FinalizeKind>,
         GenericCreatePrototype<&DateObject::class_>,
         date_static_methods,
         date_methods,
         nullptr,
         FinishDateClassInit
     }
 };
 
--- a/js/src/vm/GlobalObject.h
+++ b/js/src/vm/GlobalObject.h
@@ -785,22 +785,24 @@ DefinePropertiesAndFunctions(JSContext *
 
 typedef HashSet<GlobalObject *, DefaultHasher<GlobalObject *>, SystemAllocPolicy> GlobalObjectSet;
 
 /*
  * Convenience templates to generic constructor and prototype creation functions
  * for ClassSpecs.
  */
 
-template<JSNative ctor, size_t atomOffset, unsigned length>
+template<JSNative ctor, unsigned length, gc::AllocKind kind>
 JSObject *
 GenericCreateConstructor(JSContext *cx, JSProtoKey key)
 {
-    JSAtom *atom = AtomStateOffsetToName(cx->names(), atomOffset);
-    return cx->global()->createConstructor(cx, ctor, atom, length);
+    // Note - We duplicate the trick from ClassName() so that we don't need to
+    // include jsatominlines.h here.
+    PropertyName *name = (&cx->names().Null)[key];
+    return cx->global()->createConstructor(cx, ctor, name, length, kind);
 }
 
 template<const Class *clasp>
 JSObject *
 GenericCreatePrototype(JSContext *cx, JSProtoKey key)
 {
     MOZ_ASSERT(key != JSProto_Object);
     JSProtoKey parentKey = ParentKeyForStandardClass(key);
--- a/js/src/vm/TypedArrayObject.cpp
+++ b/js/src/vm/TypedArrayObject.cpp
@@ -2150,18 +2150,18 @@ IMPL_TYPED_ARRAY_COMBINED_UNWRAPPERS(Int
 IMPL_TYPED_ARRAY_COMBINED_UNWRAPPERS(Uint16, uint16_t, uint16_t)
 IMPL_TYPED_ARRAY_COMBINED_UNWRAPPERS(Int32, int32_t, int32_t)
 IMPL_TYPED_ARRAY_COMBINED_UNWRAPPERS(Uint32, uint32_t, uint32_t)
 IMPL_TYPED_ARRAY_COMBINED_UNWRAPPERS(Float32, float, float)
 IMPL_TYPED_ARRAY_COMBINED_UNWRAPPERS(Float64, double, double)
 
 #define TYPED_ARRAY_CLASS_SPEC(_typedArray)                                    \
 {                                                                              \
-    GenericCreateConstructor<_typedArray##Object::class_constructor,           \
-                             NAME_OFFSET(_typedArray), 3>,                     \
+    GenericCreateConstructor<_typedArray##Object::class_constructor, 3,        \
+                             JSFunction::FinalizeKind>,                        \
     _typedArray##Object::CreatePrototype,                                      \
     nullptr,                                                                   \
     _typedArray##Object::jsfuncs,                                              \
     _typedArray##Object::jsprops,                                              \
     _typedArray##Object::FinishClassInit                                       \
 }
 
 #define IMPL_TYPED_ARRAY_PROTO_CLASS(_typedArray)                              \